Search in sources :

Example 16 with VariableScope

use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.

the class ForEachNode method setOutputVariable.

public void setOutputVariable(String variableName, DataType type) {
    this.outputVariableName = variableName;
    VariableScope variableScope = (VariableScope) getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE);
    List<Variable> variables = variableScope.getVariables();
    if (variables == null) {
        variables = new ArrayList<Variable>();
        variableScope.setVariables(variables);
    }
    Variable variable = new Variable();
    variable.setName(variableName);
    variable.setType(type);
    variables.add(variable);
    Variable tmpvariable = new Variable();
    tmpvariable.setName("foreach_output");
    tmpvariable.setType(type);
    variables.add(tmpvariable);
}
Also used : Variable(org.jbpm.process.core.context.variable.Variable) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Example 17 with VariableScope

use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.

the class XmlWorkflowProcessDumper method visitHeader.

protected void visitHeader(WorkflowProcess process, StringBuilder xmlDump, boolean includeMeta) {
    xmlDump.append("  <header>" + EOL);
    visitImports(((org.jbpm.process.core.Process) process).getImports(), xmlDump);
    visitGlobals(((org.jbpm.process.core.Process) process).getGlobals(), xmlDump);
    visitFunctionImports(((org.jbpm.process.core.Process) process).getFunctionImports(), xmlDump);
    VariableScope variableScope = (VariableScope) ((org.jbpm.process.core.Process) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
    if (variableScope != null) {
        visitVariables(variableScope.getVariables(), xmlDump);
    }
    SwimlaneContext swimlaneContext = (SwimlaneContext) ((org.jbpm.process.core.Process) process).getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE);
    if (swimlaneContext != null) {
        visitSwimlanes(swimlaneContext.getSwimlanes(), xmlDump);
    }
    ExceptionScope exceptionScope = (ExceptionScope) ((org.jbpm.process.core.Process) process).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
    if (exceptionScope != null) {
        visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump);
    }
    xmlDump.append("  </header>" + EOL + EOL);
}
Also used : SwimlaneContext(org.jbpm.process.core.context.swimlane.SwimlaneContext) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Example 18 with VariableScope

use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.

the class CompositeNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
    super.writeNode(getNodeName(), node, xmlDump, includeMeta);
    CompositeNode compositeNode = (CompositeNode) node;
    writeAttributes(compositeNode, xmlDump, includeMeta);
    xmlDump.append(">" + EOL);
    if (includeMeta) {
        writeMetaData(compositeNode, xmlDump);
    }
    for (String eventType : compositeNode.getActionTypes()) {
        writeActions(eventType, compositeNode.getActions(eventType), xmlDump);
    }
    writeTimers(compositeNode.getTimers(), xmlDump);
    if (compositeNode instanceof CompositeContextNode) {
        VariableScope variableScope = (VariableScope) ((CompositeContextNode) compositeNode).getDefaultContext(VariableScope.VARIABLE_SCOPE);
        if (variableScope != null) {
            List<Variable> variables = variableScope.getVariables();
            XmlWorkflowProcessDumper.visitVariables(variables, xmlDump);
        }
        ExceptionScope exceptionScope = (ExceptionScope) ((CompositeContextNode) compositeNode).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
        if (exceptionScope != null) {
            XmlWorkflowProcessDumper.visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump);
        }
    }
    List<Node> subNodes = getSubNodes(compositeNode);
    xmlDump.append("      <nodes>" + EOL);
    for (Node subNode : subNodes) {
        XmlRuleFlowProcessDumper.INSTANCE.visitNode(subNode, xmlDump, includeMeta);
    }
    xmlDump.append("      </nodes>" + EOL);
    List<Connection> connections = getSubConnections(compositeNode);
    xmlDump.append("      <connections>" + EOL);
    for (Connection connection : connections) {
        XmlRuleFlowProcessDumper.INSTANCE.visitConnection(connection, xmlDump, includeMeta);
    }
    xmlDump.append("      </connections>" + EOL);
    Map<String, CompositeNode.NodeAndType> inPorts = getInPorts(compositeNode);
    xmlDump.append("      <in-ports>" + EOL);
    for (Map.Entry<String, CompositeNode.NodeAndType> entry : inPorts.entrySet()) {
        xmlDump.append("        <in-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeInType=\"" + entry.getValue().getType() + "\" />" + EOL);
    }
    xmlDump.append("      </in-ports>" + EOL);
    Map<String, CompositeNode.NodeAndType> outPorts = getOutPorts(compositeNode);
    xmlDump.append("      <out-ports>" + EOL);
    for (Map.Entry<String, CompositeNode.NodeAndType> entry : outPorts.entrySet()) {
        xmlDump.append("        <out-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeOutType=\"" + entry.getValue().getType() + "\" />" + EOL);
    }
    xmlDump.append("      </out-ports>" + EOL);
    endNode(getNodeName(), xmlDump);
}
Also used : Variable(org.jbpm.process.core.context.variable.Variable) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) Node(org.jbpm.workflow.core.Node) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) Connection(org.kie.api.definition.process.Connection) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) Map(java.util.Map) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Example 19 with VariableScope

use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.

the class CompositeNodeFactory method variable.

public CompositeNodeFactory variable(String name, DataType type, Object value) {
    Variable variable = new Variable();
    variable.setName(name);
    variable.setType(type);
    variable.setValue(value);
    VariableScope variableScope = (VariableScope) getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE);
    if (variableScope == null) {
        variableScope = new VariableScope();
        getCompositeNode().addContext(variableScope);
        getCompositeNode().setDefaultContext(variableScope);
    }
    variableScope.getVariables().add(variable);
    return this;
}
Also used : Variable(org.jbpm.process.core.context.variable.Variable) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Example 20 with VariableScope

use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.

the class DynamicNodeFactory method variable.

public DynamicNodeFactory variable(String name, DataType type, Object value) {
    Variable variable = new Variable();
    variable.setName(name);
    variable.setType(type);
    variable.setValue(value);
    VariableScope variableScope = (VariableScope) getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE);
    if (variableScope == null) {
        variableScope = new VariableScope();
        getCompositeNode().addContext(variableScope);
        getCompositeNode().setDefaultContext(variableScope);
    }
    variableScope.getVariables().add(variable);
    return this;
}
Also used : Variable(org.jbpm.process.core.context.variable.Variable) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Aggregations

VariableScope (org.jbpm.process.core.context.variable.VariableScope)24 Variable (org.jbpm.process.core.context.variable.Variable)11 Map (java.util.Map)7 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)6 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ContextContainer (org.jbpm.process.core.ContextContainer)3 ExceptionScope (org.jbpm.process.core.context.exception.ExceptionScope)3 VariableScopeInstance (org.jbpm.process.instance.context.variable.VariableScopeInstance)3 Node (org.jbpm.workflow.core.Node)3 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)3 HashSet (java.util.HashSet)2 DescrBuildError (org.drools.compiler.compiler.DescrBuildError)2 MVELCompilationUnit (org.drools.core.base.mvel.MVELCompilationUnit)2 MVELDialectRuntimeData (org.drools.core.rule.MVELDialectRuntimeData)2 ItemDefinition (org.jbpm.bpmn2.core.ItemDefinition)2 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)2 IntegerDataType (org.jbpm.process.core.datatype.impl.type.IntegerDataType)2 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)2