Search in sources :

Example 36 with Variable

use of org.jbpm.process.core.context.variable.Variable 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 37 with Variable

use of org.jbpm.process.core.context.variable.Variable 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)

Example 38 with Variable

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

the class ProcessCreatorForHelp method newProcessWithOneVariableAndOneWork.

public static RuleFlowProcess newProcessWithOneVariableAndOneWork(String processId, String variableName, String workName) {
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId(processId);
    List<Variable> variables = new ArrayList<Variable>();
    Variable variable = new Variable();
    variable.setName(variableName);
    ObjectDataType extendingSerializableDataType = new ObjectDataType();
    extendingSerializableDataType.setClassName(Person.class.getName());
    variable.setType(extendingSerializableDataType);
    variables.add(variable);
    process.getVariableScope().setVariables(variables);
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    WorkItemNode workItemNode = new WorkItemNode();
    workItemNode.setName("workItemNode");
    workItemNode.setId(2);
    Work work = new WorkImpl();
    work.setName(workName);
    workItemNode.setWork(work);
    EndNode endNode = new EndNode();
    endNode.setName("EndNode");
    endNode.setId(4);
    connect(startNode, workItemNode);
    connect(workItemNode, endNode);
    process.addNode(startNode);
    process.addNode(workItemNode);
    process.addNode(endNode);
    return process;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) Variable(org.jbpm.process.core.context.variable.Variable) ArrayList(java.util.ArrayList) Work(org.jbpm.process.core.Work) WorkImpl(org.jbpm.process.core.impl.WorkImpl) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) Person(org.jbpm.persistence.session.objects.Person)

Aggregations

Variable (org.jbpm.process.core.context.variable.Variable)38 ArrayList (java.util.ArrayList)18 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)17 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)16 EndNode (org.jbpm.workflow.core.node.EndNode)14 StartNode (org.jbpm.workflow.core.node.StartNode)14 ActionNode (org.jbpm.workflow.core.node.ActionNode)12 VariableScope (org.jbpm.process.core.context.variable.VariableScope)11 DroolsAction (org.jbpm.workflow.core.DroolsAction)10 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)10 Test (org.junit.Test)10 Action (org.jbpm.process.instance.impl.Action)9 TestProcessEventListener (org.jbpm.process.test.TestProcessEventListener)9 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)9 KieSession (org.kie.api.runtime.KieSession)9 ProcessContext (org.kie.api.runtime.process.ProcessContext)9 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)8 ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)8 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)8 EventNode (org.jbpm.workflow.core.node.EventNode)7