diff --git a/dspace-rest/src/main/java/org/dspace/rest/common/Collection.java b/dspace-rest/src/main/java/org/dspace/rest/common/Collection.java index 72f6a18879..5f93f3b4d0 100644 --- a/dspace-rest/src/main/java/org/dspace/rest/common/Collection.java +++ b/dspace-rest/src/main/java/org/dspace/rest/common/Collection.java @@ -32,6 +32,9 @@ public class Collection { private List parentCommunityIDList = new ArrayList(); private List itemIDList = new ArrayList(); + @XmlElement(name = "items") + private List items = new ArrayList(); + //Internal metadata private String name; private String handle; @@ -110,7 +113,7 @@ public class Collection { setName(collection.getName()); setHandle(collection.getHandle()); - if(expandFields.contains("parentCommunityIDList")) { + if(expandFields.contains("parentCommunityIDList") || expandFields.contains("all")) { org.dspace.content.Community[] parentCommunities = collection.getCommunities(); for(org.dspace.content.Community parentCommunity : parentCommunities) { this.addParentCommunityIDList(parentCommunity.getID()); @@ -119,24 +122,25 @@ public class Collection { this.addExpand("parentCommunityIDList"); } - if(expandFields.contains("parentCommunityID")) { + if(expandFields.contains("parentCommunityID") | expandFields.contains("all")) { org.dspace.content.Community parentCommunity = (org.dspace.content.Community) collection.getParentObject(); this.setParentCommunityID(parentCommunity.getID()); } else { this.addExpand("parentCommunityID"); } - if(expandFields.contains("itemIDList")) { + if(expandFields.contains("items") || expandFields.contains("all")) { ItemIterator childItems = collection.getItems(); + items = new ArrayList(); while(childItems.hasNext()) { org.dspace.content.Item item = childItems.next(); - this.addItemIDToList(item.getID()); + items.add(new LiteItem(item)); } } else { - this.addExpand("itemIDList"); + this.addExpand("items"); } - if(expandFields.contains("license")) { + if(expandFields.contains("license") || expandFields.contains("all")) { setLicense(collection.getLicense()); } else { this.addExpand("license"); diff --git a/dspace-rest/src/main/java/org/dspace/rest/common/Community.java b/dspace-rest/src/main/java/org/dspace/rest/common/Community.java index e5e305dea9..8976b7182c 100644 --- a/dspace-rest/src/main/java/org/dspace/rest/common/Community.java +++ b/dspace-rest/src/main/java/org/dspace/rest/common/Community.java @@ -115,6 +115,10 @@ public class Community { this.addExpand("subCommunities"); } + if(!expandFields.contains("all")) { + this.addExpand("all"); + } + } catch (Exception e) { log.error(e.getMessage()); } diff --git a/dspace-rest/src/main/java/org/dspace/rest/common/LiteItem.java b/dspace-rest/src/main/java/org/dspace/rest/common/LiteItem.java new file mode 100644 index 0000000000..f86e059548 --- /dev/null +++ b/dspace-rest/src/main/java/org/dspace/rest/common/LiteItem.java @@ -0,0 +1,70 @@ +package org.dspace.rest.common; + +import javax.xml.bind.annotation.XmlElement; + +/** + * Created with IntelliJ IDEA. + * User: peterdietz + * Date: 9/29/13 + * Time: 11:28 AM + * To change this template use File | Settings | File Templates. + */ +public class LiteItem { + //Internal value + private Integer itemID; + + @XmlElement(name = "type", required = true) + final String type = "item"; + + @XmlElement(name = "link", required = true) + private String link; + + //Internal metadata + private String name; + private String handle; + + public LiteItem() { + + } + + public LiteItem(org.dspace.content.Item item) { + this.itemID = item.getID(); + this.name = item.getName(); + this.handle = item.getHandle(); + + link = "/items/" + this.itemID; + } + + + public Integer getItemID() { + return itemID; + } + + public void setItemID(Integer itemID) { + this.itemID = itemID; + } + + public String getType() { + return type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getHandle() { + return handle; + } + + public void setHandle(String handle) { + this.handle = handle; + } + + public String getLink() { + return link; + } +}