Search in sources :

Example 6 with Vertex

use of org.cristalise.kernel.graph.model.Vertex 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 7 with Vertex

use of org.cristalise.kernel.graph.model.Vertex 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;
}
Also used : Vertex(org.cristalise.kernel.graph.model.Vertex) InvalidCollectionModification(org.cristalise.kernel.common.InvalidCollectionModification) PropertyDescriptionList(org.cristalise.kernel.property.PropertyDescriptionList) ObjectAlreadyExistsException(org.cristalise.kernel.common.ObjectAlreadyExistsException)

Example 8 with Vertex

use of org.cristalise.kernel.graph.model.Vertex 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)

Example 9 with Vertex

use of org.cristalise.kernel.graph.model.Vertex in project kernel by cristal-ise.

the class Loop method verify.

/**
 * @see org.cristalise.kernel.lifecycle.instance.WfVertex#verify()
 */
@Override
public boolean verify() {
    boolean err = super.verify();
    Vertex[] nexts = getOutGraphables();
    Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
    int k = 0;
    int l = 0;
    Vertex[] brothers = getParent().getChildren();
    for (Vertex brother : brothers) if (brother instanceof Loop)
        l++;
    for (Vertex next : nexts) {
        for (Vertex anteVertice : anteVertices) if (next.getID() == anteVertice.getID())
            k++;
    }
    if (k != 1 && !(l > 1)) {
        mErrors.add("bad number of pointing back nexts");
        return false;
    }
    // }
    return err;
}
Also used : Vertex(org.cristalise.kernel.graph.model.Vertex)

Example 10 with Vertex

use of org.cristalise.kernel.graph.model.Vertex in project kernel by cristal-ise.

the class Loop method isInPrev.

private boolean isInPrev(Vertex vertex) {
    int id = vertex.getID();
    Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
    for (Vertex anteVertice : anteVertices) {
        if (anteVertice.getID() == id) {
            return true;
        }
    }
    return false;
}
Also used : Vertex(org.cristalise.kernel.graph.model.Vertex)

Aggregations

Vertex (org.cristalise.kernel.graph.model.Vertex)14 GraphPoint (org.cristalise.kernel.graph.model.GraphPoint)7 WfVertex (org.cristalise.kernel.lifecycle.instance.WfVertex)3 DirectedEdge (org.cristalise.kernel.graph.model.DirectedEdge)2 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1 CollectionArrayList (org.cristalise.kernel.collection.CollectionArrayList)1 InvalidCollectionModification (org.cristalise.kernel.common.InvalidCollectionModification)1 InvalidDataException (org.cristalise.kernel.common.InvalidDataException)1 ObjectAlreadyExistsException (org.cristalise.kernel.common.ObjectAlreadyExistsException)1 ObjectNotFoundException (org.cristalise.kernel.common.ObjectNotFoundException)1 BuiltInVertexProperties (org.cristalise.kernel.graph.model.BuiltInVertexProperties)1 GraphableVertex (org.cristalise.kernel.graph.model.GraphableVertex)1 PropertyDescriptionList (org.cristalise.kernel.property.PropertyDescriptionList)1 CastorHashMap (org.cristalise.kernel.utils.CastorHashMap)1 KeyValuePair (org.cristalise.kernel.utils.KeyValuePair)1