mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-10 11:33:11 +00:00
Merge pull request #2051 from Georgetown-University-Libraries/ds3650
[DS-3650] Add subcommunities link to community object
This commit is contained in:
@@ -14,6 +14,7 @@ import org.dspace.app.rest.model.CollectionRest;
|
|||||||
import org.dspace.app.rest.model.CommunityRest;
|
import org.dspace.app.rest.model.CommunityRest;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.content.Community;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -45,14 +46,25 @@ public class CommunityConverter
|
|||||||
com.setLogo(bitstreamConverter.convert(logo));
|
com.setLogo(bitstreamConverter.convert(logo));
|
||||||
}
|
}
|
||||||
List<Collection> collections = obj.getCollections();
|
List<Collection> collections = obj.getCollections();
|
||||||
if (collections != null) {
|
|
||||||
List<CollectionRest> collectionsRest = new ArrayList<CollectionRest>();
|
List<CollectionRest> collectionsRest = new ArrayList<CollectionRest>();
|
||||||
|
if (collections != null) {
|
||||||
for (Collection col : collections) {
|
for (Collection col : collections) {
|
||||||
CollectionRest colrest = collectionConverter.fromModel(col);
|
CollectionRest colrest = collectionConverter.fromModel(col);
|
||||||
collectionsRest.add(colrest);
|
collectionsRest.add(colrest);
|
||||||
}
|
}
|
||||||
com.setCollections(collectionsRest);
|
|
||||||
}
|
}
|
||||||
|
com.setCollections(collectionsRest);
|
||||||
|
|
||||||
|
List<Community> subCommunities = obj.getSubcommunities();
|
||||||
|
List<CommunityRest> communityRest = new ArrayList<CommunityRest>();
|
||||||
|
if (subCommunities != null) {
|
||||||
|
for (Community scom : subCommunities) {
|
||||||
|
CommunityRest scomrest = this.fromModel(scom);
|
||||||
|
communityRest.add(scomrest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
com.setSubCommunities(communityRest);
|
||||||
|
|
||||||
return com;
|
return com;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,7 +23,6 @@ public class CommunityRest extends DSpaceObjectRest {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BitstreamRest logo;
|
private BitstreamRest logo;
|
||||||
|
|
||||||
|
|
||||||
private List<CollectionRest> collections;
|
private List<CollectionRest> collections;
|
||||||
|
|
||||||
@LinkRest(linkClass = CollectionRest.class)
|
@LinkRest(linkClass = CollectionRest.class)
|
||||||
@@ -36,6 +35,18 @@ public class CommunityRest extends DSpaceObjectRest {
|
|||||||
this.collections = collections;
|
this.collections = collections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<CommunityRest> subcommunities;
|
||||||
|
|
||||||
|
@LinkRest(linkClass = CommunityRest.class)
|
||||||
|
@JsonIgnore
|
||||||
|
public List<CommunityRest> getSubcommunities() {
|
||||||
|
return subcommunities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubCommunities(List<CommunityRest> subcommunities) {
|
||||||
|
this.subcommunities = subcommunities;
|
||||||
|
}
|
||||||
|
|
||||||
public BitstreamRest getLogo() {
|
public BitstreamRest getLogo() {
|
||||||
return logo;
|
return logo;
|
||||||
}
|
}
|
||||||
|
@@ -178,6 +178,9 @@ public class CommunityRestRepositoryIT extends AbstractControllerIntegrationTest
|
|||||||
.containsString("/api/core/communities/" + parentCommunity.getID().toString() + "/logo")))
|
.containsString("/api/core/communities/" + parentCommunity.getID().toString() + "/logo")))
|
||||||
.andExpect(jsonPath("$._links.collections.href", Matchers
|
.andExpect(jsonPath("$._links.collections.href", Matchers
|
||||||
.containsString("/api/core/communities/" + parentCommunity.getID().toString() + "/collections")))
|
.containsString("/api/core/communities/" + parentCommunity.getID().toString() + "/collections")))
|
||||||
|
.andExpect(jsonPath("$._links.subcommunities.href", Matchers
|
||||||
|
.containsString("/api/core/communities/" + parentCommunity.getID().toString() +
|
||||||
|
"/subcommunities")))
|
||||||
;
|
;
|
||||||
|
|
||||||
getClient().perform(get("/api/core/communities/" + parentCommunity.getID().toString() + "/logo"))
|
getClient().perform(get("/api/core/communities/" + parentCommunity.getID().toString() + "/logo"))
|
||||||
@@ -187,12 +190,23 @@ public class CommunityRestRepositoryIT extends AbstractControllerIntegrationTest
|
|||||||
getClient().perform(get("/api/core/communities/" + child1.getID().toString() + "/logo"))
|
getClient().perform(get("/api/core/communities/" + child1.getID().toString() + "/logo"))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
|
//Main community has no collections, therefore contentType is not set
|
||||||
getClient().perform(get("/api/core/communities/" + parentCommunity.getID().toString() + "/collections"))
|
getClient().perform(get("/api/core/communities/" + parentCommunity.getID().toString() + "/collections"))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
//.andExpect(status().isNoContent()); //TODO After DS-3808 is implemented
|
||||||
|
|
||||||
getClient().perform(get("/api/core/communities/" + child1.getID().toString() + "/collections"))
|
getClient().perform(get("/api/core/communities/" + child1.getID().toString() + "/collections"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType));
|
.andExpect(content().contentType(contentType));
|
||||||
|
|
||||||
|
getClient().perform(get("/api/core/communities/" + parentCommunity.getID().toString() + "/subcommunities"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().contentType(contentType));
|
||||||
|
|
||||||
|
//child1 subcommunity has no subcommunities, therefore contentType is not set
|
||||||
|
getClient().perform(get("/api/core/communities/" + child1.getID().toString() + "/subcommunities"))
|
||||||
|
.andExpect(status().isOk());
|
||||||
|
//.andExpect(status().isNoContent()); //TODO After DS-3808 is implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user