mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Collection presents its list of Items
This commit is contained in:
@@ -32,6 +32,9 @@ public class Collection {
|
||||
private List<Integer> parentCommunityIDList = new ArrayList<Integer>();
|
||||
private List<Integer> itemIDList = new ArrayList<Integer>();
|
||||
|
||||
@XmlElement(name = "items")
|
||||
private List<LiteItem> items = new ArrayList<LiteItem>();
|
||||
|
||||
//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<LiteItem>();
|
||||
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");
|
||||
|
@@ -115,6 +115,10 @@ public class Community {
|
||||
this.addExpand("subCommunities");
|
||||
}
|
||||
|
||||
if(!expandFields.contains("all")) {
|
||||
this.addExpand("all");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user