Search in sources :

Example 1 with ConnectionRef

use of io.automatiko.engine.workflow.process.core.impl.ConnectionRef in project automatiko-engine by automatiko-io.

the class StateNodeFactory method constraint.

public StateNodeFactory constraint(String connectionId, long nodeId, String type, String dialect, String constraint, int priority) {
    ConstraintImpl constraintImpl = new ConstraintImpl();
    constraintImpl.setName(connectionId);
    constraintImpl.setType(type);
    constraintImpl.setDialect(dialect);
    constraintImpl.setConstraint(constraint);
    constraintImpl.setPriority(priority);
    getStateNode().addConstraint(new ConnectionRef(connectionId, nodeId, CONNECTION_DEFAULT_TYPE), constraintImpl);
    return this;
}
Also used : ConstraintImpl(io.automatiko.engine.workflow.process.core.impl.ConstraintImpl) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef)

Example 2 with ConnectionRef

use of io.automatiko.engine.workflow.process.core.impl.ConnectionRef in project automatiko-engine by automatiko-io.

the class SplitFactory method constraint.

public SplitFactory constraint(long toNodeId, String name, String type, String dialect, ReturnValueEvaluator evaluator, int priority) {
    ReturnValueConstraintEvaluator constraintImpl = new ReturnValueConstraintEvaluator();
    constraintImpl.setName(name);
    constraintImpl.setType(type);
    constraintImpl.setDialect(dialect);
    constraintImpl.setPriority(priority);
    constraintImpl.setEvaluator(evaluator);
    constraintImpl.setConstraint("expression already given as evaluator");
    getSplit().addConstraint(new ConnectionRef(name, toNodeId, Node.CONNECTION_DEFAULT_TYPE), constraintImpl);
    return this;
}
Also used : ReturnValueConstraintEvaluator(io.automatiko.engine.workflow.base.instance.impl.ReturnValueConstraintEvaluator) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef)

Example 3 with ConnectionRef

use of io.automatiko.engine.workflow.process.core.impl.ConnectionRef in project automatiko-engine by automatiko-io.

the class SplitFactory method constraint.

public SplitFactory constraint(long toNodeId, String name, String type, String dialect, String constraint, int priority) {
    ReturnValueConstraintEvaluator constraintImpl = new ReturnValueConstraintEvaluator();
    constraintImpl.setName(name);
    constraintImpl.setType(type);
    constraintImpl.setDialect(dialect);
    constraintImpl.setConstraint(constraint);
    constraintImpl.setPriority(priority);
    if (dialect.equals("jq")) {
        constraintImpl.setEvaluator(new JqReturnValueEvaluator(constraint));
    }
    getSplit().addConstraint(new ConnectionRef(name, toNodeId, Node.CONNECTION_DEFAULT_TYPE), constraintImpl);
    return this;
}
Also used : JqReturnValueEvaluator(io.automatiko.engine.workflow.base.instance.impl.jq.JqReturnValueEvaluator) ReturnValueConstraintEvaluator(io.automatiko.engine.workflow.base.instance.impl.ReturnValueConstraintEvaluator) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef)

Example 4 with ConnectionRef

use of io.automatiko.engine.workflow.process.core.impl.ConnectionRef 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;
}
Also used : Constrainable(io.automatiko.engine.workflow.process.core.node.Constrainable) Constraint(io.automatiko.engine.workflow.process.core.Constraint) ConstraintImpl(io.automatiko.engine.workflow.process.core.impl.ConstraintImpl) Element(org.w3c.dom.Element) Text(org.w3c.dom.Text) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef) Constraint(io.automatiko.engine.workflow.process.core.Constraint)

Example 5 with ConnectionRef

use of io.automatiko.engine.workflow.process.core.impl.ConnectionRef 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);
}
Also used : Constraint(io.automatiko.engine.workflow.process.core.Constraint) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) Map(java.util.Map) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef) Constraint(io.automatiko.engine.workflow.process.core.Constraint)

Aggregations

ConnectionRef (io.automatiko.engine.workflow.process.core.impl.ConnectionRef)11 Constraint (io.automatiko.engine.workflow.process.core.Constraint)7 Split (io.automatiko.engine.workflow.process.core.node.Split)3 Map (java.util.Map)3 ReturnValueConstraintEvaluator (io.automatiko.engine.workflow.base.instance.impl.ReturnValueConstraintEvaluator)2 ConstraintImpl (io.automatiko.engine.workflow.process.core.impl.ConstraintImpl)2 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)2 Parameter (com.github.javaparser.ast.body.Parameter)1 EnclosedExpr (com.github.javaparser.ast.expr.EnclosedExpr)1 IntegerLiteralExpr (com.github.javaparser.ast.expr.IntegerLiteralExpr)1 LambdaExpr (com.github.javaparser.ast.expr.LambdaExpr)1 LongLiteralExpr (com.github.javaparser.ast.expr.LongLiteralExpr)1 NameExpr (com.github.javaparser.ast.expr.NameExpr)1 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 ReturnStmt (com.github.javaparser.ast.stmt.ReturnStmt)1 UnknownType (com.github.javaparser.ast.type.UnknownType)1 Node (io.automatiko.engine.api.definition.process.Node)1 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)1 EventFilter (io.automatiko.engine.workflow.base.core.event.EventFilter)1