use of org.cristalise.kernel.collection.CollectionArrayList in project kernel by cristal-ise.
the class ImportItem method createCollections.
/**
* @return
* @throws InvalidCollectionModification
* @throws ObjectNotFoundException
* @throws ObjectAlreadyExistsException
*/
protected CollectionArrayList createCollections() throws InvalidCollectionModification, ObjectNotFoundException, ObjectAlreadyExistsException {
CollectionArrayList colls = new CollectionArrayList();
for (ImportDependency element : dependencyList) {
Dependency newDep = element.create();
colls.put(newDep);
}
for (ImportAggregation element : aggregationList) {
Aggregation newAgg = element.create();
colls.put(newAgg);
}
return colls;
}
use of org.cristalise.kernel.collection.CollectionArrayList 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.CollectionArrayList in project kernel by cristal-ise.
the class CreateItemFromDescription method initialiseItem.
/**
* @param agent
* @param descItemPath
* @param locker
* @param input
* @param newName
* @param descVer
* @param context
* @param newItemPath
* @param newItem
* @throws ObjectCannotBeUpdated
* @throws CannotManageException
* @throws InvalidDataException
* @throws ObjectAlreadyExistsException
* @throws PersistencyException
* @throws ObjectNotFoundException
*/
protected void initialiseItem(ItemOperations newItem, AgentPath agent, ItemPath descItemPath, PropertyArrayList initProps, String newName, String descVer, DomainPath context, ItemPath newItemPath, Object locker) throws ObjectCannotBeUpdated, CannotManageException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException {
// initialise it with its properties and workflow
Logger.msg(3, "CreateItemFromDescription.initialiseItem() - Initializing Item:" + newName);
try {
PropertyArrayList newProps = instantiateProperties(descItemPath, descVer, initProps, newName, agent, locker);
CollectionArrayList newColls = instantiateCollections(descItemPath, descVer, newProps, locker);
CompositeActivity newWorkflow = instantiateWorkflow(descItemPath, descVer, locker);
newItem.initialise(agent.getSystemKey(), Gateway.getMarshaller().marshall(newProps), Gateway.getMarshaller().marshall(newWorkflow), Gateway.getMarshaller().marshall(newColls));
} catch (MarshalException | ValidationException | AccessRightsException | IOException | MappingException | InvalidCollectionModification e) {
Logger.error(e);
Gateway.getLookupManager().delete(newItemPath);
throw new InvalidDataException("CreateItemFromDescription: Problem initializing new Item. See log: " + e.getMessage());
} catch (InvalidDataException | ObjectNotFoundException | PersistencyException e) {
Logger.error(e);
Gateway.getLookupManager().delete(newItemPath);
throw e;
}
// add its domain path
Logger.msg(3, "CreateItemFromDescription - Creating " + context);
context.setItemPath(newItemPath);
Gateway.getLookupManager().add(context);
}
use of org.cristalise.kernel.collection.CollectionArrayList in project kernel by cristal-ise.
the class ModuleActivity method create.
@Override
public Path create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException, InvalidDataException {
try {
domainPath = Bootstrap.verifyResource(ns, name, version, type.getTypeCode(), itemPath, getResourceLocation(), reset);
itemPath = domainPath.getItemPath();
} catch (Exception e) {
Logger.error(e);
throw new CannotManageException("Exception verifying module resource " + ns + "/" + name);
}
actDef = LocalObjectLoader.getActDef(name, version);
populateActivityDef();
CollectionArrayList colls;
try {
colls = actDef.makeDescCollections();
} catch (InvalidDataException e) {
Logger.error(e);
throw new CannotManageException("Could not create description collections for " + getName() + ".");
}
for (Collection<?> coll : colls.list) {
try {
Gateway.getStorage().put(itemPath, coll, null);
// create last collection
coll.setVersion(null);
Gateway.getStorage().put(itemPath, coll, null);
} catch (PersistencyException e) {
Logger.error(e);
throw new CannotManageException("Persistency exception storing description collections for " + getName() + ".");
}
}
return domainPath;
}
use of org.cristalise.kernel.collection.CollectionArrayList 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