mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-10 19:43:10 +00:00
Fix integration tests. Remove Hibernate Sort annotations as a collection name can change and this breaks the Set semantics
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
@@ -48,16 +48,13 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
joinColumns = {@JoinColumn(name = "parent_comm_id") },
|
||||
inverseJoinColumns = {@JoinColumn(name = "child_comm_id") }
|
||||
)
|
||||
@Sort(type = SortType.COMPARATOR, comparator = NameAscendingComparator.class)
|
||||
private Set<Community> subCommunities = new TreeSet<Community>(new NameAscendingComparator());
|
||||
private Set<Community> subCommunities = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "subCommunities")
|
||||
@Sort(type = SortType.COMPARATOR, comparator = NameAscendingComparator.class)
|
||||
private Set<Community> parentCommunities = new TreeSet<Community>(new NameAscendingComparator());;
|
||||
private Set<Community> parentCommunities = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "communities", cascade = {CascadeType.PERSIST})
|
||||
@Sort(type = SortType.COMPARATOR, comparator = NameAscendingComparator.class)
|
||||
private Set<Collection> collections =new TreeSet<Collection>(new NameAscendingComparator());;
|
||||
private Set<Collection> collections = new HashSet<>();
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "admin")
|
||||
@@ -148,7 +145,10 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
public List<Collection> getCollections()
|
||||
{
|
||||
// We return a copy because we do not want people to add elements to this collection directly.
|
||||
return Arrays.asList(collections.toArray(new Collection[]{}));
|
||||
// We return a list to maintain backwards compatibility
|
||||
Collection[] output = collections.toArray(new Collection[]{});
|
||||
Arrays.sort(output, new NameAscendingComparator());
|
||||
return Arrays.asList(output);
|
||||
}
|
||||
|
||||
void addCollection(Collection collection)
|
||||
@@ -171,7 +171,10 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
public List<Community> getSubcommunities()
|
||||
{
|
||||
// We return a copy because we do not want people to add elements to this collection directly.
|
||||
return Arrays.asList(subCommunities.toArray(new Community[]{}));
|
||||
// We return a list to maintain backwards compatibility
|
||||
Community[] output = subCommunities.toArray(new Community[]{});
|
||||
Arrays.sort(output, new NameAscendingComparator());
|
||||
return Arrays.asList(output);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +186,10 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
public List<Community> getParentCommunities()
|
||||
{
|
||||
// We return a copy because we do not want people to add elements to this collection directly.
|
||||
return Arrays.asList(parentCommunities.toArray(new Community[]{}));
|
||||
// We return a list to maintain backwards compatibility
|
||||
Community[] output = parentCommunities.toArray(new Community[]{});
|
||||
Arrays.sort(output, new NameAscendingComparator());
|
||||
return Arrays.asList(output);
|
||||
}
|
||||
|
||||
void addParentCommunity(Community parentCommunity) {
|
||||
@@ -191,13 +197,13 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
}
|
||||
|
||||
void clearParentCommunities(){
|
||||
this.parentCommunities.clear();
|
||||
this.parentCommunities = null;
|
||||
parentCommunities.clear();
|
||||
}
|
||||
|
||||
public void removeParentCommunity(Community parentCommunity)
|
||||
{
|
||||
this.parentCommunities.remove(parentCommunity);
|
||||
parentCommunities.remove(parentCommunity);
|
||||
setModified();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -79,8 +79,7 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
joinColumns = {@JoinColumn(name = "item_id") },
|
||||
inverseJoinColumns = {@JoinColumn(name = "collection_id") }
|
||||
)
|
||||
@Sort(type = SortType.COMPARATOR, comparator = NameAscendingComparator.class)
|
||||
private final Set<Collection> collections = new TreeSet<>(new NameAscendingComparator());
|
||||
private final Set<Collection> collections = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "items")
|
||||
private final List<Bundle> bundles = new ArrayList<>();
|
||||
@@ -233,7 +232,10 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
public List<Collection> getCollections()
|
||||
{
|
||||
// We return a copy because we do not want people to add elements to this collection directly.
|
||||
return Arrays.asList(collections.toArray(new Collection[]{}));
|
||||
// We return a list to maintain backwards compatibility
|
||||
Collection[] output = collections.toArray(new Collection[]{});
|
||||
Arrays.sort(output, new NameAscendingComparator());
|
||||
return Arrays.asList(output);
|
||||
}
|
||||
|
||||
void addCollection(Collection collection)
|
||||
|
Reference in New Issue
Block a user