Mercurial > hg > LGServices
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/mpiwg/web/books/SortBooksByEditor.java Mon Jun 01 14:40:48 2015 +0200 @@ -0,0 +1,25 @@ +package de.mpiwg.web.books; + +import java.util.Comparator; + +import org.apache.log4j.Logger; + +import de.mpiwg.gazetteer.db.DBBook; + + +public class SortBooksByEditor implements Comparator<DBBook>{ + + public int compare(DBBook o1, DBBook o2) { + + if(o1.getCurrentSectionVersion() == null && o2.getCurrentSectionVersion() == null) { + return o1.getId().compareTo(o2.getId()); + } else if (o1.getCurrentSectionVersion() == null) { + return -1; + } else if (o2.getCurrentSectionVersion() == null){ + return 1; + } else { + return o1.getCurrentSectionVersion().getEditor().compareTo(o2.getCurrentSectionVersion().getEditor()); + } + } + +}