forked from DSpace/DSpace
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DSpace#1768 from tdonohue/DS-3406-master
Forward port of DS-3406 and DS-3599 (Collection/Community alpha sorting) to master
- Loading branch information
Showing
11 changed files
with
309 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
dspace-api/src/main/java/org/dspace/content/comparator/NameAscendingComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.content.comparator; | ||
|
||
import org.apache.commons.lang.ObjectUtils; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.dspace.content.DSpaceObject; | ||
|
||
import java.util.Comparator; | ||
|
||
public class NameAscendingComparator implements Comparator<DSpaceObject>{ | ||
|
||
@Override | ||
public int compare(DSpaceObject dso1, DSpaceObject dso2) { | ||
if (dso1 == dso2){ | ||
return 0; | ||
}else if (dso1 == null){ | ||
return -1; | ||
}else if (dso2 == null){ | ||
return 1; | ||
}else { | ||
String name1 = StringUtils.trimToEmpty(dso1.getName()); | ||
String name2 = StringUtils.trimToEmpty(dso2.getName()); | ||
|
||
//When two DSO's have the same name, use their UUID to put them in an order | ||
if(name1.equals(name2)) { | ||
return ObjectUtils.compare(dso1.getID(), dso2.getID()); | ||
} else { | ||
return name1.compareToIgnoreCase(name2); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.