Mercurial > hg > LGServices
comparison src/main/java/de/mpiwg/web/books/SortBooksByEditor.java @ 16:a7e9c1f8edb4
new: sorting in books page, adding books package
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 01 Jun 2015 14:40:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:d81a5401b9af | 16:a7e9c1f8edb4 |
---|---|
1 package de.mpiwg.web.books; | |
2 | |
3 import java.util.Comparator; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import de.mpiwg.gazetteer.db.DBBook; | |
8 | |
9 | |
10 public class SortBooksByEditor implements Comparator<DBBook>{ | |
11 | |
12 public int compare(DBBook o1, DBBook o2) { | |
13 | |
14 if(o1.getCurrentSectionVersion() == null && o2.getCurrentSectionVersion() == null) { | |
15 return o1.getId().compareTo(o2.getId()); | |
16 } else if (o1.getCurrentSectionVersion() == null) { | |
17 return -1; | |
18 } else if (o2.getCurrentSectionVersion() == null){ | |
19 return 1; | |
20 } else { | |
21 return o1.getCurrentSectionVersion().getEditor().compareTo(o2.getCurrentSectionVersion().getEditor()); | |
22 } | |
23 } | |
24 | |
25 } |