Search in sources :

Example 1 with KeyValuePair

use of org.cristalise.kernel.utils.KeyValuePair in project kernel by cristal-ise.

the class WfVertexDef method configureInstance.

/**
 * Copies Properties from vertex definition to vertex instance, and also set the Edges
 *
 * @param newVertex the vertex instance to be configured
 * @throws InvalidDataException inconsistent data
 * @throws ObjectNotFoundException data was not found
 */
public void configureInstance(WfVertex newVertex) throws InvalidDataException, ObjectNotFoundException {
    for (KeyValuePair element : getProperties().getKeyValuePairs()) {
        newVertex.getProperties().put(element.getKey(), element.getValue(), element.isAbstract());
    }
    newVertex.setID(getID());
    if (getIsLayoutable()) {
        newVertex.setInEdgeIds(getInEdgeIds());
        newVertex.setOutEdgeIds(getOutEdgeIds());
        newVertex.setCentrePoint(getCentrePoint());
        newVertex.setOutlinePoints(getOutlinePoints());
    }
}
Also used : KeyValuePair(org.cristalise.kernel.utils.KeyValuePair)

Example 2 with KeyValuePair

use of org.cristalise.kernel.utils.KeyValuePair in project kernel by cristal-ise.

the class ActivitySlotDef method configureInstance.

private void configureInstance(Activity act) {
    KeyValuePair[] k = getProperties().getKeyValuePairs();
    for (KeyValuePair element : k) act.getProperties().put(element.getKey(), element.getValue(), element.isAbstract());
    act.setCentrePoint(getCentrePoint());
    act.setOutlinePoints(getOutlinePoints());
    act.setInEdgeIds(getInEdgeIds());
    act.setOutEdgeIds(getOutEdgeIds());
    act.setName(getActName());
    act.setID(getID());
}
Also used : KeyValuePair(org.cristalise.kernel.utils.KeyValuePair)

Example 3 with KeyValuePair

use of org.cristalise.kernel.utils.KeyValuePair in project kernel by cristal-ise.

the class ActivitySlotDef method verify.

/**
 * @see org.cristalise.kernel.lifecycle.WfVertexDef#verify()
 */
/**
 * launch the verification of the ActivityDef
 */
@Override
public boolean verify() {
    mErrors.removeAllElements();
    boolean err = true;
    int nbInEdgres = getInEdges().length;
    int nbOutEdges = getOutEdges().length;
    if (nbInEdgres == 0 && this.getID() != getParent().getChildrenGraphModel().getStartVertexId()) {
        mErrors.add("Unreachable");
        err = false;
    }
    if (nbInEdgres > 1) {
        mErrors.add("Bad nb of previous");
        err = false;
    }
    if (nbOutEdges > 1) {
        mErrors.add("too many next");
        err = false;
    }
    if (nbOutEdges == 0) {
        if (!((CompositeActivityDef) getParent()).hasGoodNumberOfActivity()) {
            mErrors.add("too many endpoints");
            err = false;
        }
    }
    Vertex[] allSiblings = getParent().getChildrenGraphModel().getVertices();
    String thisName = (String) getBuiltInProperty(NAME);
    if (thisName == null || thisName.length() == 0) {
        mErrors.add("Slot name is empty");
    } else {
        for (Vertex v : allSiblings) {
            if (v instanceof ActivitySlotDef && v.getID() != getID()) {
                ActivitySlotDef otherSlot = (ActivitySlotDef) v;
                String otherName = (String) otherSlot.getBuiltInProperty(NAME);
                if (otherName != null && otherName.equals(thisName)) {
                    mErrors.add("Duplicate slot name");
                    err = false;
                }
            }
        }
    }
    KeyValuePair[] props;
    try {
        props = getTheActivityDef().getProperties().getKeyValuePairs();
        for (KeyValuePair prop : props) {
            if (prop.isAbstract() && !getProperties().containsKey(prop.getKey())) {
                mErrors.add("Abstract property '" + prop.getKey() + "' not defined in slot");
                err = false;
            }
        }
    } catch (Exception ex) {
    }
    // Loop check
    Vertex[] outV = getOutGraphables();
    Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
    boolean errInLoop = false;
    for (Vertex element : outV) {
        for (Vertex anteVertice : anteVertices) {
            if (!loop() && element.getID() == anteVertice.getID())
                errInLoop = true;
        }
    }
    if (errInLoop) {
        mErrors.add("Problem in Loop");
        err = false;
    }
    return err;
}
Also used : Vertex(org.cristalise.kernel.graph.model.Vertex) WfVertex(org.cristalise.kernel.lifecycle.instance.WfVertex) KeyValuePair(org.cristalise.kernel.utils.KeyValuePair) InvalidDataException(org.cristalise.kernel.common.InvalidDataException) ObjectNotFoundException(org.cristalise.kernel.common.ObjectNotFoundException)

Aggregations

KeyValuePair (org.cristalise.kernel.utils.KeyValuePair)3 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 Vertex (org.cristalise.kernel.graph.model.Vertex)1 WfVertex (org.cristalise.kernel.lifecycle.instance.WfVertex)1