use of org.cristalise.kernel.collection.DependencyMember 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.DependencyMember 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;
}
Aggregations