use of org.cristalise.kernel.collection.CollectionDescription in project kernel by cristal-ise.
the class CreateItemFromDescription method instantiateCollections.
/**
* Copies the CollectionDescriptions of the Item requesting this predefined step.
*
* @param descItemPath
* @param descVer
* @param locker
* @return the new collection
* @throws ObjectNotFoundException
* @throws PersistencyException
* @throws InvalidDataException
*/
protected CollectionArrayList instantiateCollections(ItemPath descItemPath, String descVer, PropertyArrayList newProps, Object locker) throws ObjectNotFoundException, PersistencyException, InvalidDataException {
// loop through collections, collecting instantiated descriptions and finding the default workflow def
CollectionArrayList colls = new CollectionArrayList();
String[] collNames = Gateway.getStorage().getClusterContents(descItemPath, ClusterType.COLLECTION);
for (String collName : collNames) {
@SuppressWarnings("unchecked") Collection<? extends CollectionMember> thisCol = (Collection<? extends CollectionMember>) Gateway.getStorage().get(descItemPath, ClusterType.COLLECTION + "/" + collName + "/" + descVer, locker);
if (thisCol instanceof CollectionDescription) {
Logger.msg(5, "CreateItemFromDescription - Instantiating CollectionDescription:" + collName);
CollectionDescription<?> thisDesc = (CollectionDescription<?>) thisCol;
colls.put(thisDesc.newInstance());
} else if (thisCol instanceof Dependency) {
Logger.msg(5, "CreateItemFromDescription - Instantiating Dependency:" + collName);
((Dependency) thisCol).addToItemProperties(newProps);
} else {
Logger.warning("CreateItemFromDescription - CANNOT instantiate collection:" + collName + " class:" + thisCol.getClass().getName());
}
}
return colls;
}
Aggregations