use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class ConstraintHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Constrainable parent = (Constrainable) parser.getParent();
Constraint constraint = new ConstraintImpl();
final String toNodeIdString = element.getAttribute("toNodeId");
String toType = element.getAttribute("toType");
ConnectionRef connectionRef = null;
if (toNodeIdString != null && toNodeIdString.trim().length() > 0) {
int toNodeId = new Integer(toNodeIdString);
if (toType == null || toType.trim().length() == 0) {
toType = NodeImpl.CONNECTION_DEFAULT_TYPE;
}
connectionRef = new ConnectionRef(toNodeId, toType);
}
final String name = element.getAttribute("name");
constraint.setName(name);
final String priority = element.getAttribute("priority");
if (priority != null && priority.length() != 0) {
constraint.setPriority(new Integer(priority));
}
final String type = element.getAttribute("type");
constraint.setType(type);
final String dialect = element.getAttribute("dialect");
constraint.setDialect(dialect);
String text = ((Text) element.getChildNodes().item(0)).getWholeText();
if (text != null) {
text = text.trim();
if ("".equals(text)) {
text = null;
}
}
constraint.setConstraint(text);
parent.addConstraint(connectionRef, constraint);
return null;
}
use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class StateNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
StateNode stateNode = (StateNode) node;
writeNode("state", stateNode, xmlDump, includeMeta);
xmlDump.append(">\n");
if (includeMeta) {
writeMetaData(stateNode, xmlDump);
}
for (String eventType : stateNode.getActionTypes()) {
writeActions(eventType, stateNode.getActions(eventType), xmlDump);
}
writeTimers(stateNode.getTimers(), xmlDump);
if (!stateNode.getConstraints().isEmpty()) {
xmlDump.append(" <constraints>" + EOL);
for (Map.Entry<ConnectionRef, Constraint> entry : stateNode.getConstraints().entrySet()) {
ConnectionRef connection = entry.getKey();
Constraint constraint = entry.getValue();
xmlDump.append(" <constraint " + "toNodeId=\"" + connection.getNodeId() + "\" ");
String name = constraint.getName();
if (name != null && !"".equals(name)) {
xmlDump.append("name=\"" + XmlDumper.replaceIllegalChars(constraint.getName()) + "\" ");
}
int priority = constraint.getPriority();
if (priority != 0) {
xmlDump.append("priority=\"" + constraint.getPriority() + "\" ");
}
String constraintString = constraint.getConstraint();
if (constraintString != null) {
xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</constraint>" + EOL);
} else {
xmlDump.append("/>" + EOL);
}
}
xmlDump.append(" </constraints>" + EOL);
}
endNode("state", xmlDump);
}
use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class Split method isDefault.
public boolean isDefault(final Connection connection) {
if (connection == null) {
throw new IllegalArgumentException("connection is null");
}
if (this.type == TYPE_OR || this.type == TYPE_XOR) {
ConnectionRef ref = new ConnectionRef((String) connection.getMetaData().get("UniqueId"), connection.getTo().getId(), connection.getToType());
Constraint constraint = this.constraints.get(ref);
String defaultConnection = (String) getMetaData().get("Default");
String connectionId = (String) connection.getMetaData().get("UniqueId");
if (constraint != null) {
return constraint.isDefault();
} else if (constraint == null && connectionId.equals(defaultConnection)) {
return true;
} else {
return false;
}
}
throw new UnsupportedOperationException("Constraints are " + "only supported with XOR or OR split types, not with: " + getType());
}
use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class ProcessHandler method buildConstraint.
private static Constraint buildConstraint(SequenceFlow connection, NodeImpl node) {
if (connection.getExpression() == null) {
return null;
}
Constraint constraint = new ConstraintImpl();
String defaultConnection = (String) node.getMetaData("Default");
if (defaultConnection != null && defaultConnection.equals(connection.getId())) {
constraint.setDefault(true);
}
if (connection.getName() != null) {
constraint.setName(connection.getName());
} else {
constraint.setName("");
}
if (connection.getType() != null) {
constraint.setType(connection.getType());
} else {
constraint.setType("code");
}
if (connection.getLanguage() != null) {
constraint.setDialect(connection.getLanguage());
}
if (connection.getExpression() != null) {
constraint.setConstraint(connection.getExpression());
}
constraint.setPriority(connection.getPriority());
return constraint;
}
use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class ProcessHandler method linkConnections.
public void linkConnections(NodeContainer nodeContainer, List<SequenceFlow> connections) {
if (connections != null) {
for (SequenceFlow connection : connections) {
String sourceRef = connection.getSourceRef();
Node source = findNodeByIdOrUniqueIdInMetadata(nodeContainer, sourceRef, "Could not find source node for connection:" + sourceRef);
if (source instanceof EventNode) {
for (EventFilter eventFilter : ((EventNode) source).getEventFilters()) {
if (eventFilter instanceof EventTypeFilter) {
if ("Compensation".equals(((EventTypeFilter) eventFilter).getType())) {
// BPMN Method & Style, 2nd Ed. (Silver), states this on P. 131
throw new IllegalArgumentException("A Compensation Boundary Event can only be *associated* with a compensation activity via an Association, not via a Sequence Flow element.");
}
}
}
}
String targetRef = connection.getTargetRef();
Node target = findNodeByIdOrUniqueIdInMetadata(nodeContainer, targetRef, "Could not find target node for connection:" + targetRef);
Connection result = new ConnectionImpl(source, NodeImpl.CONNECTION_DEFAULT_TYPE, target, NodeImpl.CONNECTION_DEFAULT_TYPE);
result.setMetaData("bendpoints", connection.getBendpoints());
result.setMetaData("UniqueId", connection.getId());
if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) {
NodeImpl nodeImpl = (NodeImpl) source;
Constraint constraint = buildConstraint(connection, nodeImpl);
if (constraint != null) {
nodeImpl.addConstraint(new ConnectionRef(connection.getId(), target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
}
} else if (source instanceof Split) {
Split split = (Split) source;
Constraint constraint = buildConstraint(connection, split);
split.addConstraint(new ConnectionRef(connection.getId(), target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE), constraint);
}
}
}
}
Aggregations