use of org.cristalise.kernel.collection.Dependency in project kernel by cristal-ise.
the class ImportDependency method create.
public Dependency create() throws InvalidCollectionModification, ObjectNotFoundException, ObjectAlreadyExistsException {
Dependency newDep = isDescription ? new DependencyDescription(name) : new Dependency(name);
if (version != null)
newDep.setVersion(version);
if (itemDescriptionPath != null && itemDescriptionPath.length() > 0) {
ItemPath itemPath;
try {
itemPath = new ItemPath(itemDescriptionPath);
} catch (InvalidItemPathException ex) {
itemPath = new DomainPath(itemDescriptionPath).getItemPath();
}
String descVer = itemDescriptionVersion == null ? "last" : itemDescriptionVersion;
PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer, null);
StringBuffer classProps = new StringBuffer();
for (PropertyDescription pd : propList.list) {
props.put(pd.getName(), pd.getDefaultValue());
if (pd.getIsClassIdentifier())
classProps.append((classProps.length() > 0 ? "," : "")).append(pd.getName());
}
newDep.setProperties(props);
newDep.setClassProps(classProps.toString());
}
for (ImportDependencyMember thisMem : dependencyMemberList) {
ItemPath itemPath;
try {
itemPath = new ItemPath(thisMem.itemPath);
} catch (InvalidItemPathException ex) {
itemPath = new DomainPath(thisMem.itemPath).getItemPath();
}
org.cristalise.kernel.collection.DependencyMember newDepMem = newDep.addMember(itemPath);
newDepMem.getProperties().putAll(thisMem.props);
}
return newDep;
}
use of org.cristalise.kernel.collection.Dependency in project kernel by cristal-ise.
the class ActivityDef method configureInstance.
/**
*/
@Override
public void configureInstance(WfVertex act) throws InvalidDataException, ObjectNotFoundException {
super.configureInstance(act);
try {
for (String collName : Gateway.getStorage().getClusterContents(itemPath, ClusterType.COLLECTION)) {
Logger.msg(5, "ActivityDef.configureInstance(" + getName() + ") - Processing collection:" + collName);
String verStr = (mVersion == null || mVersion == -1) ? "last" : String.valueOf(mVersion);
Dependency dep = null;
try {
dep = (Dependency) Gateway.getStorage().get(itemPath, ClusterType.COLLECTION + "/" + collName + "/" + verStr, null);
} catch (ObjectNotFoundException e) {
if (Logger.doLog(8))
Logger.warning("Unavailable Collection path:" + itemPath + "/" + ClusterType.COLLECTION + "/" + collName + "/" + verStr);
} catch (PersistencyException e) {
Logger.error(e);
throw new InvalidDataException("Collection:" + collName + " error:" + e.getMessage());
}
if (dep != null)
dep.addToVertexProperties(act.getProperties());
}
} catch (PersistencyException e) {
Logger.error(e);
throw new InvalidDataException(e.getMessage());
}
}
use of org.cristalise.kernel.collection.Dependency in project kernel by cristal-ise.
the class ActivityDef method getBuiltInCollectionResource.
protected DescriptionObject[] getBuiltInCollectionResource(BuiltInCollections collection) throws ObjectNotFoundException, InvalidDataException {
ArrayList<DescriptionObject> retArr = new ArrayList<DescriptionObject>();
if (itemPath == null) {
Logger.warning("ActivityDef.getBuiltInCollectionResource(actName:" + getName() + ", collection:" + collection + ") - itemPath is null! CANNOT resolve data in ClusterStorage");
return retArr.toArray(new DescriptionObject[0]);
// throw new InvalidDataException("actName:"+getName()+", collection:"+collection+" - itemPath is null! CANNOT resolve data in ClusterStorage");
}
Logger.msg(5, "ActivityDef.getBuiltInCollectionResource(actName:" + getName() + ") - Loading from collection:" + collection);
Dependency resColl;
try {
String clusterPath = ClusterType.COLLECTION + "/" + collection + "/" + ((mVersion == null || mVersion == -1) ? "last" : String.valueOf(mVersion));
String[] contents = Gateway.getStorage().getClusterContents(itemPath, clusterPath);
if (contents != null && contents.length > 0)
resColl = (Dependency) Gateway.getStorage().get(itemPath, clusterPath, null);
else
return retArr.toArray(new DescriptionObject[retArr.size()]);
} catch (PersistencyException e) {
Logger.error(e);
throw new InvalidDataException("Error loading description collection " + collection);
}
for (DependencyMember resMem : resColl.getMembers().list) {
String resUUID = resMem.getChildUUID();
Integer resVer = deriveVersionNumber(resMem.getBuiltInProperty(VERSION));
if (resVer == null) {
throw new InvalidDataException("Version is null for Item:" + itemPath + ", Collection:" + collection + ", DependencyMember:" + resUUID);
}
if (collection != ACTIVITY && retArr.size() > 0) {
throw new InvalidDataException("actName:" + getName() + " has an invalid dependency:" + collection);
}
switch(collection) {
case SCHEMA:
retArr.add(LocalObjectLoader.getSchema(resUUID, resVer));
break;
case SCRIPT:
retArr.add(LocalObjectLoader.getScript(resUUID, resVer));
break;
case QUERY:
retArr.add(LocalObjectLoader.getQuery(resUUID, resVer));
break;
case STATE_MACHINE:
retArr.add(LocalObjectLoader.getStateMachine(resUUID, resVer));
break;
case ACTIVITY:
retArr.add(LocalObjectLoader.getActDef(resUUID, resVer));
break;
default:
throw new InvalidDataException("");
}
}
return retArr.toArray(new DescriptionObject[retArr.size()]);
}
use of org.cristalise.kernel.collection.Dependency in project kernel by cristal-ise.
the class AddMemberToCollection method runActivityLogic.
/**
* <pre>
* Generates a new slot in a Dependency for the given item
*
* Params:
* 0 - collection name
* 1 - target entity key
* 2 - slot properties
* </pre>
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException, ObjectNotFoundException, InvalidCollectionModification {
String collName;
ItemPath newChild;
Dependency dep;
CastorHashMap props = null;
// extract parameters
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddMemberToCollection: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
try {
collName = params[0];
try {
newChild = new ItemPath(params[1]);
} catch (InvalidItemPathException e) {
newChild = new DomainPath(params[1]).getItemPath();
}
if (params.length > 2) {
Logger.msg(5, "AddMemberToCollection: Unmarshalling Properties:" + params[2]);
props = (CastorHashMap) Gateway.getMarshaller().unmarshall(params[2]);
}
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("AddMemberToCollection: Invalid parameters " + Arrays.toString(params));
}
// load collection
C2KLocalObject collObj = Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
if (!(collObj instanceof Dependency))
throw new InvalidDataException("AddMemberToCollection operates on Dependency only.");
dep = (Dependency) collObj;
// find member and assign entity
if (props == null)
dep.addMember(newChild);
else
dep.addMember(newChild, props, dep.getClassProps());
Gateway.getStorage().put(item, dep, locker);
return requestData;
}
use of org.cristalise.kernel.collection.Dependency 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;
}
Aggregations