Search in sources :

Example 6 with ConnectionRef

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

the class Split method removeConstraint.

public void removeConstraint(Connection connection) {
    ConnectionRef ref = new ConnectionRef((String) connection.getMetaData().get("UniqueId"), connection.getTo().getId(), connection.getToType());
    internalRemoveConstraint(ref);
}
Also used : ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef)

Example 7 with ConnectionRef

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

Example 8 with ConnectionRef

use of io.automatiko.engine.workflow.process.core.impl.ConnectionRef 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);
            }
        }
    }
}
Also used : NodeImpl(io.automatiko.engine.workflow.process.core.impl.NodeImpl) ExtendedNodeImpl(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl) Constraint(io.automatiko.engine.workflow.process.core.Constraint) SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Node(io.automatiko.engine.api.definition.process.Node) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) Connection(io.automatiko.engine.workflow.process.core.Connection) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) Split(io.automatiko.engine.workflow.process.core.node.Split) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef)

Example 9 with ConnectionRef

use of io.automatiko.engine.workflow.process.core.impl.ConnectionRef 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)));
}
Also used : IntegerLiteralExpr(com.github.javaparser.ast.expr.IntegerLiteralExpr) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) Constraint(io.automatiko.engine.workflow.process.core.Constraint) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) LambdaExpr(com.github.javaparser.ast.expr.LambdaExpr) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) NameExpr(com.github.javaparser.ast.expr.NameExpr) SplitFactory(io.automatiko.engine.workflow.process.executable.core.factory.SplitFactory) UnknownType(com.github.javaparser.ast.type.UnknownType) LongLiteralExpr(com.github.javaparser.ast.expr.LongLiteralExpr) Parameter(com.github.javaparser.ast.body.Parameter) EnclosedExpr(com.github.javaparser.ast.expr.EnclosedExpr) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef) ReturnStmt(com.github.javaparser.ast.stmt.ReturnStmt)

Example 10 with ConnectionRef

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