mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 23:13:10 +00:00
Fix bug so that comparator can be used for sets
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.content.comparator;
|
||||
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
|
||||
@@ -25,7 +26,14 @@ public class NameAscendingComparator implements Comparator<DSpaceObject>{
|
||||
}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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -7,32 +7,33 @@
|
||||
*/
|
||||
package org.dspace.content;
|
||||
|
||||
import mockit.NonStrictExpectations;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.AuthorizeUtil;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.* ;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import mockit.*;
|
||||
import org.dspace.app.util.AuthorizeUtil;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.core.Constants;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit Tests for class Item
|
||||
|
Reference in New Issue
Block a user