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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations