use of org.cristalise.kernel.graph.model.GraphableVertex in project kernel by cristal-ise.
the class CompositeActivityDef method propagateCollectionProperties.
/**
* Reading collections during configureInstance() the properties of CAInstance can be updated to
* contain CastorHashMaps, which contain properties to be propagated to the Vertices of CAInstance.
*
* @param caInstance the CompAct instance beeing instantiated
* @throws InvalidDataException
*/
private void propagateCollectionProperties(CompositeActivity caInstance) throws InvalidDataException {
// Propagate now properties to Vertices
CastorHashMap caProps = caInstance.getProperties();
List<String> keysToDelete = new ArrayList<String>();
for (Entry<String, Object> aCAProp : caProps.entrySet()) {
if (aCAProp.getValue() instanceof CastorHashMap) {
for (Vertex vertex : caInstance.getChildrenGraphModel().getVertices()) {
CastorHashMap propsToPropagate = (CastorHashMap) aCAProp.getValue();
propsToPropagate.dump(8);
BuiltInVertexProperties builtInProp = BuiltInVertexProperties.getValue(aCAProp.getKey());
if (builtInProp == null) {
((GraphableVertex) vertex).updatePropertiesFromCollection(Integer.parseInt(aCAProp.getKey()), propsToPropagate);
} else {
((GraphableVertex) vertex).updatePropertiesFromCollection(builtInProp, propsToPropagate);
}
}
keysToDelete.add(aCAProp.getKey());
}
}
for (String key : keysToDelete) caProps.remove(key);
}
use of org.cristalise.kernel.graph.model.GraphableVertex in project kernel by cristal-ise.
the class CompositeActivityDef method hasGoodNumberOfActivity.
/**
* @return boolean
*/
public boolean hasGoodNumberOfActivity() {
int endingAct = 0;
GraphableVertex[] graphableVertices = this.getLayoutableChildren();
if (graphableVertices != null)
for (GraphableVertex graphableVertice : graphableVertices) {
WfVertexDef vertex = (WfVertexDef) graphableVertice;
if (getChildrenGraphModel().getOutEdges(vertex).length == 0)
endingAct++;
}
if (endingAct > 1)
return false;
return true;
}
use of org.cristalise.kernel.graph.model.GraphableVertex in project kernel by cristal-ise.
the class CompositeActivityDef method export.
@Override
public void export(Writer imports, File dir) throws InvalidDataException, ObjectNotFoundException, IOException {
// rebuild the child refs in case any slots have been removed
setRefChildActDef(findRefActDefs(getChildrenGraphModel()));
// export child activitz defs, routing scripts and schemas
for (GraphableVertex vert : getChildren()) {
if (vert instanceof AndSplitDef) {
try {
((AndSplitDef) vert).getRoutingScript().export(imports, dir);
} catch (ObjectNotFoundException ex) {
}
} else if (vert instanceof ActivitySlotDef) {
ActivityDef refAct = ((ActivitySlotDef) vert).getTheActivityDef();
refAct.export(imports, dir);
}
}
String tc = COMP_ACT_DESC_RESOURCE.getTypeCode();
try {
// export marshalled compAct
String compactXML = Gateway.getMarshaller().marshall(this);
FileStringUtility.string2File(new File(new File(dir, tc), getActName() + (getVersion() == null ? "" : "_" + getVersion()) + ".xml"), compactXML);
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException("Couldn't marshall composite activity def " + getActName());
}
if (imports != null) {
imports.write("<Workflow " + getExportAttributes(tc) + ">" + getExportCollections());
for (ActivityDef childActDef : refChildActDef) {
imports.write("<Activity name=\"" + childActDef.getActName() + "\" id=\"" + childActDef.getItemID() + "\" version=\"" + childActDef.getVersion() + "\"/>");
}
imports.write("</Workflow>\n");
}
}
use of org.cristalise.kernel.graph.model.GraphableVertex in project kernel by cristal-ise.
the class CompositeActivityDef method intantiateVertices.
/**
* Loops through the vertices of children graph model and calls their instantiate method
*
* @param ca the parent CompositeActivity instance which will be set as a Parent
* @return the instantiated array of WfVertex instances
*/
public WfVertex[] intantiateVertices(CompositeActivity ca) throws ObjectNotFoundException, InvalidDataException {
GraphableVertex[] vertexDefs = getLayoutableChildren();
WfVertex[] wfVertices = new WfVertex[vertexDefs.length];
for (int i = 0; i < vertexDefs.length; i++) {
WfVertexDef vertDef = (WfVertexDef) vertexDefs[i];
wfVertices[i] = vertDef.instantiate();
wfVertices[i].setParent(ca);
}
return wfVertices;
}
use of org.cristalise.kernel.graph.model.GraphableVertex in project kernel by cristal-ise.
the class CompositeActivityDef method verify.
@Override
public boolean verify() {
boolean err = super.verify();
GraphableVertex[] vChildren = getChildren();
for (int i = 0; i < vChildren.length; i++) {
WfVertexDef wfvChild = (WfVertexDef) vChildren[i];
if (!(wfvChild.verify())) {
mErrors.add(wfvChild.getName() + ": " + wfvChild.getErrors());
err = false;
}
}
return err;
}
Aggregations