Search in sources :

Example 1 with GraphableVertex

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);
}
Also used : Vertex(org.cristalise.kernel.graph.model.Vertex) WfVertex(org.cristalise.kernel.lifecycle.instance.WfVertex) GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex) CastorHashMap(org.cristalise.kernel.utils.CastorHashMap) ArrayList(java.util.ArrayList) CollectionArrayList(org.cristalise.kernel.collection.CollectionArrayList) GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex) BuiltInVertexProperties(org.cristalise.kernel.graph.model.BuiltInVertexProperties)

Example 2 with GraphableVertex

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;
}
Also used : GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 3 with GraphableVertex

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");
    }
}
Also used : ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) File(java.io.File) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException) IOException(java.io.IOException)

Example 4 with GraphableVertex

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;
}
Also used : WfVertex(org.cristalise.kernel.lifecycle.instance.WfVertex) GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Example 5 with GraphableVertex

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;
}
Also used : GraphableVertex(org.cristalise.kernel.graph.model.GraphableVertex) GraphPoint(org.cristalise.kernel.graph.model.GraphPoint)

Aggregations

GraphableVertex (org.cristalise.kernel.graph.model.GraphableVertex)8 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)4 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)2 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)2 WfVertex (org.cristalise.kernel.lifecycle.instance.WfVertex)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)1 BuiltInVertexProperties (org.cristalise.kernel.graph.model.BuiltInVertexProperties)1 Vertex (org.cristalise.kernel.graph.model.Vertex)1 Workflow (org.cristalise.kernel.lifecycle.instance.Workflow)1 Outcome (org.cristalise.kernel.persistency.outcome.Outcome)1 Schema (org.cristalise.kernel.persistency.outcome.Schema)1 Viewpoint (org.cristalise.kernel.persistency.outcome.Viewpoint)1 CastorHashMap (org.cristalise.kernel.utils.CastorHashMap)1