Search in sources :

Example 1 with CollectionDescription

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;
}
Also used : CollectionMember(org.cristalise.kernel.collection.CollectionMember) CollectionDescription(org.cristalise.kernel.collection.CollectionDescription) Collection(org.cristalise.kernel.collection.Collection) Dependency(org.cristalise.kernel.collection.Dependency) CollectionArrayList(org.cristalise.kernel.collection.CollectionArrayList)

Aggregations

Collection (org.cristalise.kernel.collection.Collection)1 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)1 CollectionDescription (org.cristalise.kernel.collection.CollectionDescription)1 CollectionMember (org.cristalise.kernel.collection.CollectionMember)1 Dependency (org.cristalise.kernel.collection.Dependency)1