Export all collections of a community recursively

This commit is contained in:
Keiji Suzuki
2013-07-07 11:07:42 +09:00
parent 28502b115c
commit 2b4633a87c
4 changed files with 124 additions and 17 deletions

View File

@@ -793,6 +793,48 @@ public class Community extends DSpaceObject
return communityArray;
}
/**
* Return an array of collections of this community and its subcommunities
*
* @return an array of colections
*/
public Collection[] getAllCollections() throws SQLException
{
List<Collection> collectionList = new ArrayList<Collection>();
for (Community subcommunity : getSubcommunities())
{
addCollectionList(subcommunity, collectionList);
}
for (Collection collection : getCollections())
{
collectionList.add(collection);
}
// Put them in an array
Collection[] collectionArray = new Collection[collectionList.size()];
collectionArray = (Collection[]) collectionList.toArray(collectionArray);
return collectionArray;
}
/**
* Internal method to process subcommunities recursively
*/
private void addCollectionList(Community community, List<Collection> collectionList) throws SQLException
{
for (Community subcommunity : community.getSubcommunities())
{
addCollectionList(subcommunity, collectionList);
}
for (Collection collection : community.getCollections())
{
collectionList.add(collection);
}
}
/**
* Create a new collection within this community. The collection is created
* without any workflow groups or default submitter group.