use of org.cristalise.kernel.collection.AggregationDescription in project kernel by cristal-ise.
the class ImportAggregation method create.
public org.cristalise.kernel.collection.Aggregation create() throws InvalidCollectionModification, ObjectNotFoundException, ObjectAlreadyExistsException {
Aggregation newAgg = isDescription ? new AggregationDescription(name) : new AggregationInstance(name);
if (version != null)
newAgg.setVersion(version);
for (ImportAggregationMember thisMem : aggregationMemberList) {
StringBuffer classProps = new StringBuffer();
ItemPath itemPath = null;
if (thisMem.itemDescriptionPath != null && thisMem.itemDescriptionPath.length() > 0) {
try {
itemPath = new ItemPath(thisMem.itemDescriptionPath);
} catch (InvalidItemPathException ex) {
itemPath = new DomainPath(thisMem.itemDescriptionPath).getItemPath();
}
String descVer = thisMem.itemDescriptionVersion == null ? "last" : thisMem.itemDescriptionVersion;
PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer, null);
for (PropertyDescription pd : propList.list) {
thisMem.props.put(pd.getName(), pd.getDefaultValue());
if (pd.getIsClassIdentifier())
classProps.append((classProps.length() > 0 ? "," : "")).append(pd.getName());
}
}
if (thisMem.itemPath != null && thisMem.itemPath.length() > 0) {
try {
itemPath = new ItemPath(thisMem.itemPath);
} catch (InvalidItemPathException ex) {
itemPath = new DomainPath(thisMem.itemPath).getItemPath();
}
}
newAgg.addMember(itemPath, thisMem.props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height);
}
return newAgg;
}
use of org.cristalise.kernel.collection.AggregationDescription in project kernel by cristal-ise.
the class AddNewCollectionDescription method runActivityLogic.
/**
* Params: 0 - collection name 1 - collection type (Aggregation, Dependency)
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData, Object locker) throws InvalidDataException, ObjectAlreadyExistsException, PersistencyException {
// extract parameters
String[] params = getDataList(requestData);
if (Logger.doLog(3))
Logger.msg(3, "AddNewCollectionDescription: called by " + agent + " on " + item + " with parameters " + Arrays.toString(params));
if (params.length != 2)
throw new InvalidDataException("AddNewCollectionDescription: Invalid parameters " + Arrays.toString(params));
String collName = params[0];
String collType = params[1];
// check if collection already exists
try {
Gateway.getStorage().get(item, ClusterType.COLLECTION + "/" + collName + "/last", locker);
throw new ObjectAlreadyExistsException("Collection '" + collName + "' already exists");
} catch (ObjectNotFoundException ex) {
// collection doesn't exist
}
CollectionDescription<?> newCollDesc;
if (collType.equalsIgnoreCase("Aggregation"))
newCollDesc = new AggregationDescription(collName);
else if (collType.equalsIgnoreCase("Dependency"))
newCollDesc = new DependencyDescription(collName);
else
throw new InvalidDataException("AddNewCollectionDescription: Invalid type: '" + collType + "' /Aggregation or Dependency)");
// store it
try {
Gateway.getStorage().put(item, newCollDesc, locker);
} catch (PersistencyException e) {
throw new PersistencyException("AddNewCollectionDescription: Error saving new collection '" + collName + "': " + e.getMessage());
}
return requestData;
}
Aggregations