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;
|
package org.dspace.content.comparator;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.ObjectUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
|
|
||||||
@@ -25,7 +26,14 @@ public class NameAscendingComparator implements Comparator<DSpaceObject>{
|
|||||||
}else {
|
}else {
|
||||||
String name1 = StringUtils.trimToEmpty(dso1.getName());
|
String name1 = StringUtils.trimToEmpty(dso1.getName());
|
||||||
String name2 = StringUtils.trimToEmpty(dso2.getName());
|
String name2 = StringUtils.trimToEmpty(dso2.getName());
|
||||||
return name1.compareToIgnoreCase(name2);
|
|
||||||
|
//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,38 +7,39 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content;
|
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.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.sql.SQLException;
|
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 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 static org.hamcrest.CoreMatchers.*;
|
||||||
import mockit.*;
|
import static org.junit.Assert.*;
|
||||||
import org.dspace.app.util.AuthorizeUtil;
|
|
||||||
import org.dspace.authorize.ResourcePolicy;
|
|
||||||
import org.dspace.core.Constants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit Tests for class Item
|
* Unit Tests for class Item
|
||||||
* @author pvillega
|
* @author pvillega
|
||||||
*/
|
*/
|
||||||
public class ItemTest extends AbstractDSpaceObjectTest
|
public class ItemTest extends AbstractDSpaceObjectTest
|
||||||
{
|
{
|
||||||
|
|
||||||
/** log4j category */
|
/** log4j category */
|
||||||
|
Reference in New Issue
Block a user