use of org.cristalise.kernel.collection.Dependency in project kernel by cristal-ise.
the class ActivityDef method makeDescCollection.
public Dependency makeDescCollection(BuiltInCollections collection, DescriptionObject... descs) throws InvalidDataException {
// TODO: restrict membership based on kernel property desc
Dependency descDep = new Dependency(collection.getName());
if (mVersion != null && mVersion > -1) {
descDep.setVersion(mVersion);
}
for (DescriptionObject thisDesc : descs) {
if (thisDesc == null)
continue;
try {
DependencyMember descMem = descDep.addMember(thisDesc.getItemPath());
descMem.setBuiltInProperty(VERSION, thisDesc.getVersion());
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("Problem creating description collection for " + thisDesc + " in " + getName());
}
}
return descDep;
}
use of org.cristalise.kernel.collection.Dependency 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;
}
use of org.cristalise.kernel.collection.Dependency in project kernel by cristal-ise.
the class Script method makeDescCollections.
/**
*/
@Override
public CollectionArrayList makeDescCollections() throws InvalidDataException, ObjectNotFoundException {
CollectionArrayList retArr = new CollectionArrayList();
Dependency includeColl = new Dependency(INCLUDE);
for (Script script : mIncludes) {
try {
includeColl.addMember(script.getItemPath());
} catch (InvalidCollectionModification e) {
throw new InvalidDataException("Could not add " + script.getName() + " to description collection. " + e.getMessage());
} catch (ObjectAlreadyExistsException e) {
throw new InvalidDataException("Script " + script.getName() + " included more than once.");
}
//
}
retArr.put(includeColl);
return retArr;
}
Aggregations