Search in sources :

Example 46 with ProcessInstance

use of org.jbpm.process.instance.ProcessInstance in project jbpm by kiegroup.

the class SubProcessNodeInstance method getContextInstance.

@Override
public ContextInstance getContextInstance(Context context) {
    ContextInstanceFactory conf = ContextInstanceFactoryRegistry.INSTANCE.getContextInstanceFactory(context);
    if (conf == null) {
        throw new IllegalArgumentException("Illegal context type (registry not found): " + context.getClass());
    }
    ContextInstance contextInstance = (ContextInstance) conf.getContextInstance(context, this, (ProcessInstance) getProcessInstance());
    if (contextInstance == null) {
        throw new IllegalArgumentException("Illegal context type (instance not found): " + context.getClass());
    }
    return contextInstance;
}
Also used : ContextInstance(org.jbpm.process.instance.ContextInstance) ProcessInstance(org.jbpm.process.instance.ProcessInstance) ContextInstanceFactory(org.jbpm.process.instance.impl.ContextInstanceFactory)

Example 47 with ProcessInstance

use of org.jbpm.process.instance.ProcessInstance in project jbpm by kiegroup.

the class CompositeContextNodeInstance method getContextInstance.

public ContextInstance getContextInstance(final Context context) {
    ContextInstanceFactory conf = ContextInstanceFactoryRegistry.INSTANCE.getContextInstanceFactory(context);
    if (conf == null) {
        throw new IllegalArgumentException("Illegal context type (registry not found): " + context.getClass());
    }
    ContextInstance contextInstance = (ContextInstance) conf.getContextInstance(context, this, (ProcessInstance) getProcessInstance());
    if (contextInstance == null) {
        throw new IllegalArgumentException("Illegal context type (instance not found): " + context.getClass());
    }
    return contextInstance;
}
Also used : ContextInstance(org.jbpm.process.instance.ContextInstance) ProcessInstance(org.jbpm.process.instance.ProcessInstance) ContextInstanceFactory(org.jbpm.process.instance.impl.ContextInstanceFactory)

Example 48 with ProcessInstance

use of org.jbpm.process.instance.ProcessInstance in project jbpm by kiegroup.

the class NodeInstanceImpl method setVariable.

public void setVariable(String variableName, Object value) {
    VariableScopeInstance variableScope = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName);
    if (variableScope == null) {
        variableScope = (VariableScopeInstance) getProcessInstance().getContextInstance(VariableScope.VARIABLE_SCOPE);
        if (variableScope.getVariableScope().findVariable(variableName) == null) {
            variableScope = null;
        }
    }
    if (variableScope == null) {
        logger.error("Could not find variable {}", variableName);
        logger.error("Using process-level scope");
        variableScope = (VariableScopeInstance) ((ProcessInstance) getProcessInstance()).getContextInstance(VariableScope.VARIABLE_SCOPE);
    }
    variableScope.setVariable(variableName, value);
}
Also used : VariableScopeInstance(org.jbpm.process.instance.context.variable.VariableScopeInstance) WorkflowProcessInstance(org.jbpm.workflow.instance.WorkflowProcessInstance) ProcessInstance(org.jbpm.process.instance.ProcessInstance)

Example 49 with ProcessInstance

use of org.jbpm.process.instance.ProcessInstance in project jbpm by kiegroup.

the class RuleConstraintEvaluator method evaluate.

public boolean evaluate(NodeInstance instance, Connection connection, Constraint constraint) {
    WorkflowProcessInstance processInstance = instance.getProcessInstance();
    InternalAgenda agenda = (InternalAgenda) ((ProcessInstance) processInstance).getKnowledgeRuntime().getAgenda();
    String rule = "RuleFlow-Split-" + processInstance.getProcessId() + "-" + ((Node) instance.getNode()).getUniqueId() + "-" + ((Node) connection.getTo()).getUniqueId() + "-" + connection.getToType();
    return agenda.isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", rule, processInstance.getId());
}
Also used : InternalAgenda(org.drools.core.common.InternalAgenda) ProcessInstance(org.jbpm.process.instance.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance)

Aggregations

ProcessInstance (org.jbpm.process.instance.ProcessInstance)49 KieSession (org.kie.api.runtime.KieSession)34 StringReader (java.io.StringReader)33 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)33 Test (org.junit.Test)33 Reader (java.io.Reader)30 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)16 TestWorkItemHandler (org.jbpm.integrationtests.handler.TestWorkItemHandler)10 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)8 DroolsError (org.drools.compiler.compiler.DroolsError)6 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)6 Person (org.jbpm.integrationtests.test.Person)5 WorkItem (org.kie.api.runtime.process.WorkItem)5 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)5 KieRuntime (org.kie.api.runtime.KieRuntime)4 WorkItemHandlerNotFoundException (org.drools.core.WorkItemHandlerNotFoundException)3 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)3 WorkItem (org.drools.core.process.instance.WorkItem)3 Message (org.jbpm.integrationtests.test.Message)3