use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class StateNodeInstance method signalEvent.
public void signalEvent(String type, Object event) {
if ("signal".equals(type)) {
if (event instanceof String) {
for (Connection connection : getStateNode().getOutgoingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE)) {
boolean selected = false;
Constraint constraint = getStateNode().getConstraint(connection);
if (constraint == null) {
if (((String) event).equals(connection.getTo().getName())) {
selected = true;
}
} else if (((String) event).equals(constraint.getName())) {
selected = true;
}
if (selected) {
triggerEvent(ExtendedNodeImpl.EVENT_NODE_EXIT);
removeEventListeners();
((io.automatiko.engine.workflow.process.instance.NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this);
triggerConnection(connection);
return;
}
}
}
} else if ("variableChanged".equals(type)) {
if (isCompleted()) {
triggerCompleted();
}
} else {
super.signalEvent(type, event);
}
}
use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class SplitNodeVisitor method visitNode.
@Override
public void visitNode(WorkflowProcess process, String factoryField, Split node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
body.addStatement(getAssignedFactoryMethod(factoryField, SplitFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId()))).addStatement(getNameMethod(node, "Split")).addStatement(getFactoryMethod(getNodeId(node), METHOD_TYPE, new IntegerLiteralExpr(node.getType())));
visitMetaData(node.getMetaData(), body, getNodeId(node));
if (node.getType() == Split.TYPE_OR || node.getType() == Split.TYPE_XOR) {
for (Entry<ConnectionRef, Constraint> entry : node.getConstraints().entrySet()) {
if (entry.getValue() != null) {
String dialect = entry.getValue().getDialect();
if ("jq".equals(dialect)) {
body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT, new LongLiteralExpr(entry.getKey().getNodeId()), new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")), new StringLiteralExpr(entry.getKey().getToType()), new StringLiteralExpr(entry.getValue().getDialect()), new StringLiteralExpr(entry.getValue().getConstraint()), new IntegerLiteralExpr(entry.getValue().getPriority())));
} else {
BlockStmt actionBody = new BlockStmt();
LambdaExpr lambda = new // (kcontext) ->
LambdaExpr(// (kcontext) ->
new Parameter(new UnknownType(), KCONTEXT_VAR), actionBody);
for (Variable v : variableScope.getVariables()) {
actionBody.addStatement(makeAssignment(v));
}
variableScope.getVariables().stream().filter(v -> v.hasTag(Variable.VERSIONED_TAG)).map(ActionNodeVisitor::makeAssignmentVersions).forEach(actionBody::addStatement);
if (entry.getValue().getConstraint().contains(System.getProperty("line.separator"))) {
BlockStmt constraintBody = new BlockStmt();
constraintBody.addStatement(entry.getValue().getConstraint());
actionBody.addStatement(constraintBody);
} else {
actionBody.addStatement(new ReturnStmt(new EnclosedExpr(new NameExpr(entry.getValue().getConstraint()))));
}
body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT, new LongLiteralExpr(entry.getKey().getNodeId()), new StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")), new StringLiteralExpr(entry.getKey().getToType()), new StringLiteralExpr(entry.getValue().getDialect()), lambda, new IntegerLiteralExpr(entry.getValue().getPriority())));
}
}
}
}
body.addStatement(getDoneMethod(getNodeId(node)));
}
use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class SplitNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
Split splitNode = (Split) node;
writeNode("split", splitNode, xmlDump, includeMeta);
int type = splitNode.getType();
if (type != 0) {
xmlDump.append("type=\"" + type + "\" ");
}
if (splitNode.getConstraints().isEmpty()) {
endNode(xmlDump);
} else {
xmlDump.append(">" + EOL);
if (includeMeta) {
writeMetaData(splitNode, xmlDump);
}
xmlDump.append(" <constraints>" + EOL);
for (Map.Entry<ConnectionRef, Constraint> entry : splitNode.getConstraints().entrySet()) {
ConnectionRef connection = entry.getKey();
Constraint constraint = entry.getValue();
xmlDump.append(" <constraint " + "toNodeId=\"" + connection.getNodeId() + "\" " + "toType=\"" + connection.getToType() + "\" ");
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() + "\" ");
}
xmlDump.append("type=\"" + constraint.getType() + "\" ");
String dialect = constraint.getDialect();
if (dialect != null && !"".equals(dialect)) {
xmlDump.append("dialect=\"" + dialect + "\" ");
}
String constraintString = constraint.getConstraint();
if (constraintString != null) {
xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</constraint>" + EOL);
} else {
xmlDump.append("/>" + EOL);
}
}
xmlDump.append(" </constraints>" + EOL);
endNode("split", xmlDump);
}
}
use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class XmlBPMNProcessDumper method visitConnection.
public void visitConnection(Connection connection, StringBuilder xmlDump, int metaDataType) {
// if the connection was generated by a link event, don't dump.
if (isConnectionRepresentingLinkEvent(connection)) {
return;
}
// if the connection is a hidden one (compensations), don't dump
Object hidden = ((ConnectionImpl) connection).getMetaData("hidden");
if (hidden != null && ((Boolean) hidden)) {
return;
}
xmlDump.append(" <sequenceFlow id=\"" + getUniqueNodeId(connection.getFrom()) + "-" + getUniqueNodeId(connection.getTo()) + "\" sourceRef=\"" + getUniqueNodeId(connection.getFrom()) + "\" ");
// TODO fromType, toType
xmlDump.append("targetRef=\"" + getUniqueNodeId(connection.getTo()) + "\" ");
if (metaDataType == META_DATA_AS_NODE_PROPERTY) {
String bendpoints = (String) connection.getMetaData().get("bendpoints");
if (bendpoints != null) {
xmlDump.append("g:bendpoints=\"" + bendpoints + "\" ");
}
}
if (connection.getFrom() instanceof Split) {
Split split = (Split) connection.getFrom();
if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR) {
Constraint constraint = split.getConstraint(connection);
if (constraint == null) {
xmlDump.append(">" + EOL + " <conditionExpression xsi:type=\"tFormalExpression\" />");
} else {
if (constraint.getName() != null && constraint.getName().trim().length() > 0) {
xmlDump.append("name=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(constraint.getName()) + "\" ");
}
if (constraint.getPriority() != 0) {
xmlDump.append("tns:priority=\"" + constraint.getPriority() + "\" ");
}
xmlDump.append(">" + EOL + " <conditionExpression xsi:type=\"tFormalExpression\" ");
if ("code".equals(constraint.getType())) {
if ("java".equals(constraint.getDialect())) {
xmlDump.append("language=\"" + JAVA_LANGUAGE + "\" ");
} else if ("XPath".equals(constraint.getDialect())) {
xmlDump.append("language=\"" + XPATH_LANGUAGE + "\" ");
} else if ("JavaScript".equals(constraint.getDialect())) {
xmlDump.append("language=\"" + JAVASCRIPT_LANGUAGE + "\" ");
} else if ("FEEL".equals(constraint.getDialect())) {
xmlDump.append("language=\"" + FEEL_LANGUAGE + "\" ");
}
} else {
xmlDump.append("language=\"" + RULE_LANGUAGE + "\" ");
}
String constraintString = constraint.getConstraint();
if (constraintString == null) {
constraintString = "";
}
xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</conditionExpression>");
}
xmlDump.append(EOL + " </sequenceFlow>" + EOL);
} else {
xmlDump.append("/>" + EOL);
}
} else {
xmlDump.append("/>" + EOL);
}
}
use of io.automatiko.engine.workflow.process.core.Constraint in project automatiko-engine by automatiko-io.
the class SplitHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
Split split = (Split) node;
String type = null;
switch(split.getType()) {
case Split.TYPE_AND:
type = "parallelGateway";
writeNode(type, node, xmlDump, metaDataType);
break;
case Split.TYPE_XOR:
type = "exclusiveGateway";
writeNode(type, node, xmlDump, metaDataType);
for (Map.Entry<ConnectionRef, Constraint> entry : split.getConstraints().entrySet()) {
if (entry.getValue() != null && entry.getValue().isDefault()) {
xmlDump.append("default=\"" + XmlBPMNProcessDumper.getUniqueNodeId(split) + "-" + XmlBPMNProcessDumper.getUniqueNodeId(node.getParentContainer().getNode(entry.getKey().getNodeId())) + "\" ");
break;
}
}
break;
case Split.TYPE_OR:
type = "inclusiveGateway";
writeNode(type, node, xmlDump, metaDataType);
for (Map.Entry<ConnectionRef, Constraint> entry : split.getConstraints().entrySet()) {
if (entry.getValue() != null && entry.getValue().isDefault()) {
xmlDump.append("default=\"" + XmlBPMNProcessDumper.getUniqueNodeId(split) + "-" + XmlBPMNProcessDumper.getUniqueNodeId(node.getParentContainer().getNode(entry.getKey().getNodeId())) + "\" ");
break;
}
}
break;
case Split.TYPE_XAND:
type = "eventBasedGateway";
writeNode(type, node, xmlDump, metaDataType);
break;
default:
type = "complexGateway";
writeNode(type, node, xmlDump, metaDataType);
}
xmlDump.append("gatewayDirection=\"Diverging\" >" + EOL);
writeExtensionElements(node, xmlDump);
endNode(type, xmlDump);
}
Aggregations