Fix integration tests. Remove Hibernate Sort annotations as a collection name can change and this breaks the Set semantics

This commit is contained in:
Tom Desair
2017-05-22 15:06:44 +02:00
committed by Tim Donohue
parent cc3342894b
commit 027a5a68f9
3 changed files with 29 additions and 19 deletions

View File

@@ -86,8 +86,7 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
joinColumns = {@JoinColumn(name = "collection_id") },
inverseJoinColumns = {@JoinColumn(name = "community_id") }
)
@Sort(type = SortType.COMPARATOR, comparator = NameAscendingComparator.class)
private Set<Community> communities = new TreeSet<>(new NameAscendingComparator());
private Set<Community> communities = new HashSet<>();
@Transient
private transient CollectionService collectionService;
@@ -268,7 +267,10 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
public List<Community> getCommunities() throws SQLException
{
// We return a copy because we do not want people to add elements to this collection directly.
return Arrays.asList(communities.toArray(new Community[]{}));
// We return a list to maintain backwards compatibility
Community[] output = communities.toArray(new Community[]{});
Arrays.sort(output, new NameAscendingComparator());
return Arrays.asList(output);
}
void addCommunity(Community community) {
@@ -276,7 +278,7 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
setModified();
}
void removeCommunity(Community community){
void removeCommunity(Community community) {
this.communities.remove(community);
setModified();
}