use of org.cristalise.kernel.property.PropertyDescriptionList 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.property.PropertyDescriptionList 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.property.PropertyDescriptionList in project kernel by cristal-ise.
the class DependencyDescription method newInstance.
@Override
public Collection<DependencyMember> newInstance() throws ObjectNotFoundException {
// HACK: Knock the special 'prime' off the end for the case of descriptions of descriptions
String depName = getName().replaceFirst("\'$", "");
Dependency newDep = new Dependency(depName);
// constrain the members based on the property description
if (mMembers.list.size() == 1) {
DependencyMember mem = mMembers.list.get(0);
String descVer = getDescVer(mem);
PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath(), descVer, null);
if (pdList != null) {
newDep.setProperties(PropertyUtility.convertTransitiveProperties(pdList));
newDep.setClassProps(pdList.getClassProps());
}
}
return newDep;
}
use of org.cristalise.kernel.property.PropertyDescriptionList in project kernel by cristal-ise.
the class Bootstrap method createResourceItem.
/**
* @param impHandler
* @param itemName
* @param ns
* @param itemPath
* @return the ItemProxy representing the newly create Item
* @throws Exception
*/
private static ItemProxy createResourceItem(ResourceImportHandler impHandler, String itemName, String ns, ItemPath itemPath) throws Exception {
// create props
PropertyDescriptionList pdList = impHandler.getPropDesc();
PropertyArrayList props = new PropertyArrayList();
LookupManager lookupManager = Gateway.getLookupManager();
for (int i = 0; i < pdList.list.size(); i++) {
PropertyDescription pd = pdList.list.get(i);
String propName = pd.getName();
String propVal = pd.getDefaultValue();
if (propName.equals(NAME.toString()))
propVal = itemName;
else if (propName.equals(MODULE.toString()))
propVal = (ns == null) ? "kernel" : ns;
props.list.add(new Property(propName, propVal, pd.getIsMutable()));
}
CompositeActivity ca = new CompositeActivity();
try {
ca = (CompositeActivity) ((CompositeActivityDef) LocalObjectLoader.getActDef(impHandler.getWorkflowName(), 0)).instantiate();
} catch (ObjectNotFoundException ex) {
Logger.error(ex);
Logger.error("Module resource workflow " + impHandler.getWorkflowName() + " not found. Using empty.");
}
Gateway.getCorbaServer().createItem(itemPath);
lookupManager.add(itemPath);
DomainPath newDomPath = impHandler.getPath(itemName, ns);
newDomPath.setItemPath(itemPath);
lookupManager.add(newDomPath);
ItemProxy newItemProxy = Gateway.getProxyManager().getProxy(itemPath);
newItemProxy.initialise(systemAgents.get("system").getPath(), props, ca, null);
return newItemProxy;
}
use of org.cristalise.kernel.property.PropertyDescriptionList in project kernel by cristal-ise.
the class AggregationDescription method newInstance.
/**
* For each member get the {@link PropertyDescriptionList} of the member item and look for an explicit version
*/
@Override
public Aggregation newInstance() throws ObjectNotFoundException {
AggregationInstance newInstance = new AggregationInstance(getName());
for (int i = 0; i < size(); i++) {
AggregationMember mem = mMembers.list.get(i);
//
String descVer = getDescVer(mem);
PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath(), descVer, null);
if (pdList != null) {
// create the new props of the member object
try {
Vertex v = getLayout().getVertexById(mem.getID());
newInstance.addMember(null, PropertyUtility.convertTransitiveProperties(pdList), pdList.getClassProps(), v.getCentrePoint(), v.getWidth(), v.getHeight());
} catch (InvalidCollectionModification e) {
} catch (ObjectAlreadyExistsException e) {
}
} else {
Logger.error("AggregationDescription::newInstance() There is no PropertyDescription. Cannot instantiate. " + mem.getItemPath());
return null;
}
}
return newInstance;
}
Aggregations