Codota Logo
ProcessContext
Code IndexAdd Codota to your IDE (free)

How to use
ProcessContext
in
org.drools.core.spi

Best Java code snippets using org.drools.core.spi.ProcessContext (Showing top 18 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
LocalDateTime l =
  • Codota Iconnew LocalDateTime()
  • Codota IconLocalDateTime.now()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseLocalDateTime(text)
  • Smart code suggestions by Codota
}
origin: kiegroup/jbpm

public boolean evaluate(NodeInstance instance,
            Connection connection,
            Constraint constraint) {
  Object value;
  try {
    ProcessContext context = new ProcessContext(((ProcessInstance)instance.getProcessInstance()).getKnowledgeRuntime());
    context.setNodeInstance( instance );
    value = this.evaluator.evaluate( context );
  } catch ( Exception e ) {
    throw new RuntimeException( "unable to execute ReturnValueEvaluator: ",
                  e );
  }
  if ( !(value instanceof Boolean) ) {
    throw new RuntimeException( "Constraints must return boolean values: " + value + " for expression " + constraint);
  }
  return ((Boolean) value).booleanValue();
}
origin: kiegroup/jbpm

public void handleException(ExceptionHandler handler, String exception, Object params) {
  
  if (handler instanceof ActionExceptionHandler) {
    ActionExceptionHandler exceptionHandler = (ActionExceptionHandler) handler;
    Action action = (Action) exceptionHandler.getAction().getMetaData("Action");
    try {
      ProcessInstance processInstance = getProcessInstance();
      ProcessContext processContext = new ProcessContext(processInstance.getKnowledgeRuntime());
      ContextInstanceContainer contextInstanceContainer = getContextInstanceContainer();
      if (contextInstanceContainer instanceof NodeInstance) {
        processContext.setNodeInstance((NodeInstance) contextInstanceContainer);
      } else {
        processContext.setProcessInstance(processInstance);
      }
      String faultVariable = exceptionHandler.getFaultVariable();
      if (faultVariable != null) {
        processContext.setVariable(faultVariable, params);
      }
      action.execute(processContext);
    } catch (Exception e) {
      throw new RuntimeException("unable to execute Action", e);
    }
  } else {
    throw new IllegalArgumentException("Unknown exception handler " + handler);
  }
}
origin: org.drools/drools-core

@Test
public void testProcessContextGetDataAndAssignmentWithoutInsert() {
  KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
  KieSession ksession = kbase.newKieSession();
  assertNotNull(ksession);
  ProcessContext processContext = new ProcessContext(ksession);
  CaseData caseData = processContext.getCaseData();
  assertNull(caseData);
  CaseAssignment caseAssignment = processContext.getCaseAssignment();
  assertNull(caseAssignment);
}
origin: org.jbpm.contrib/java-workitem

  localksession = engine.getKieSession();
ProcessContext kcontext = new ProcessContext(localksession);
try {
  WorkflowProcessInstance processInstance = (WorkflowProcessInstance)
  localksession.getProcessInstance(workItem.getProcessInstanceId());
  kcontext.setProcessInstance(processInstance);
  WorkItemNodeInstance nodeInstance = findNodeInstance(workItem.getId(),
                             processInstance);
  kcontext.setNodeInstance(nodeInstance);
  Map<String, Object> results = handler.execute(kcontext);
origin: kiegroup/jbpm

ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() );
((Action) actionNode.getAction().getMetaData("Action")).execute( processContext );
origin: org.drools/drools-core

@Test
public void testProcessContextGetData() {
  KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
  KieSession ksession = kbase.newKieSession();
  assertNotNull(ksession);
  CaseInformation caseInfo = new CaseInformation();
  caseInfo.add("test", "value");
  ksession.insert(caseInfo);
  ProcessContext processContext = new ProcessContext(ksession);
  CaseData caseData = processContext.getCaseData();
  assertNotNull(caseData);
  Map<String, Object> allData = caseData.getData();
  assertNotNull(allData);
  assertEquals(1, allData.size());
  assertEquals("value", caseData.getData("test"));
}
origin: org.drools/drools-core

@Test
public void testProcessContextGetAssignment() {
  KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
  KieSession ksession = kbase.newKieSession();
  assertNotNull(ksession);
  CaseInformation caseInfo = new CaseInformation();
  caseInfo.assign("owner", new OrganizationalEntity() {
    @Override
    public String getId() {
      return "testUser";
    }
    @Override
    public void writeExternal(ObjectOutput out) throws IOException {
    }
    @Override
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    }
  });
  ksession.insert(caseInfo);
  ProcessContext processContext = new ProcessContext(ksession);
  CaseAssignment caseAssignment = processContext.getCaseAssignment();
  assertNotNull(caseAssignment);
  Collection<OrganizationalEntity> forRole = caseAssignment.getAssignments("owner");
  assertNotNull(forRole);
  assertEquals(1, forRole.size());
}
origin: kiegroup/jbpm

ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() );
((MVELAction) actionNode.getAction().getMetaData("Action")).compile( data );
((Action)actionNode.getAction().getMetaData("Action")).execute( processContext );
origin: kiegroup/jbpm

private void handleAssignment(Assignment assignment) {
  AssignmentAction action = (AssignmentAction) assignment.getMetaData("Action");
  try {
    ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
    context.setNodeInstance(this);
    action.execute(getWorkItem(), context);
  } catch (Exception e) {
    throw new RuntimeException("unable to execute Assignment", e);
  }
}
origin: org.jbpm/jbpm-flow

public void handleException(ExceptionHandler handler, String exception, Object params) {
  
  if (handler instanceof ActionExceptionHandler) {
    ActionExceptionHandler exceptionHandler = (ActionExceptionHandler) handler;
    Action action = (Action) exceptionHandler.getAction().getMetaData("Action");
    try {
      ProcessInstance processInstance = getProcessInstance();
      ProcessContext processContext = new ProcessContext(processInstance.getKnowledgeRuntime());
      ContextInstanceContainer contextInstanceContainer = getContextInstanceContainer();
      if (contextInstanceContainer instanceof NodeInstance) {
        processContext.setNodeInstance((NodeInstance) contextInstanceContainer);
      } else {
        processContext.setProcessInstance(processInstance);
      }
      String faultVariable = exceptionHandler.getFaultVariable();
      if (faultVariable != null) {
        processContext.setVariable(faultVariable, params);
      }
      action.execute(processContext);
    } catch (Exception e) {
      throw new RuntimeException("unable to execute Action", e);
    }
  } else {
    throw new IllegalArgumentException("Unknown exception handler " + handler);
  }
}
origin: kiegroup/jbpm

wm.setGlobal( "list", list );        
ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() );
((Action) actionNode.getAction().getMetaData("Action")).execute( processContext );
origin: kiegroup/jbpm

/**
 * This method is used in both instances of the {@link ExtendedNodeInstanceImpl}
 * and {@link ActionNodeInstance} instances in order to handle 
 * exceptions thrown when executing actions.
 * 
 * @param action An {@link Action} instance.
 */
protected void executeAction(Action action) {
  ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
  context.setNodeInstance(this);
  try {
    action.execute(context);
  } catch (Exception e) {
    String exceptionName = e.getClass().getName();
    ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance)
      resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
    if (exceptionScopeInstance == null) {
      throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
    }
    
    exceptionScopeInstance.handleException(exceptionName, e);
    cancel();
  }
}

origin: kiegroup/jbpm

ProcessContext processContext = new ProcessContext( ((InternalWorkingMemory) wm).getKnowledgeRuntime() );
((Action) actionNode.getAction().getMetaData("Action")).execute(processContext);
origin: kiegroup/jbpm

public void internalTrigger(final NodeInstance from, String type) {
  if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
    throw new IllegalArgumentException(
      "An ActionNode only accepts default incoming connections!");
  }
  Action action = (Action) getActionNode().getAction().getMetaData("Action");
  try {
    ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
    context.setNodeInstance(this);
    executeAction(action);
  } catch( WorkflowRuntimeException wre) { 
    throw wre;
  } catch (Exception e) {
    // for the case that one of the following throws an exception
    // - the ProcessContext() constructor 
    // - or context.setNodeInstance(this) 
    throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
  } 
  triggerCompleted();
}
origin: org.jbpm/jbpm-flow

public boolean evaluate(NodeInstance instance,
            Connection connection,
            Constraint constraint) {
  Object value;
  try {
    ProcessContext context = new ProcessContext(((ProcessInstance)instance.getProcessInstance()).getKnowledgeRuntime());
    context.setNodeInstance( instance );
    value = this.evaluator.evaluate( context );
  } catch ( Exception e ) {
    throw new RuntimeException( "unable to execute ReturnValueEvaluator: ",
                  e );
  }
  if ( !(value instanceof Boolean) ) {
    throw new RuntimeException( "Constraints must return boolean values: " + value + " for expression " + constraint);
  }
  return ((Boolean) value).booleanValue();
}
origin: org.jbpm/jbpm-flow

private void handleAssignment(Assignment assignment) {
  AssignmentAction action = (AssignmentAction) assignment.getMetaData("Action");
  try {
    ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
    context.setNodeInstance(this);
    action.execute(getWorkItem(), context);
  } catch (Exception e) {
    throw new RuntimeException("unable to execute Assignment", e);
  }
}
origin: org.jbpm/jbpm-flow

/**
 * This method is used in both instances of the {@link ExtendedNodeInstanceImpl}
 * and {@link ActionNodeInstance} instances in order to handle 
 * exceptions thrown when executing actions.
 * 
 * @param action An {@link Action} instance.
 */
protected void executeAction(Action action) {
  ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
  context.setNodeInstance(this);
  try {
    action.execute(context);
  } catch (Exception e) {
    String exceptionName = e.getClass().getName();
    ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance)
      resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName);
    if (exceptionScopeInstance == null) {
      throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
    }
    
    exceptionScopeInstance.handleException(exceptionName, e);
    cancel();
  }
}

origin: org.jbpm/jbpm-flow

public void internalTrigger(final NodeInstance from, String type) {
  if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
    throw new IllegalArgumentException(
      "An ActionNode only accepts default incoming connections!");
  }
  Action action = (Action) getActionNode().getAction().getMetaData("Action");
  try {
    ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
    context.setNodeInstance(this);
    executeAction(action);
  } catch( WorkflowRuntimeException wre) { 
    throw wre;
  } catch (Exception e) {
    // for the case that one of the following throws an exception
    // - the ProcessContext() constructor 
    // - or context.setNodeInstance(this) 
    throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
  } 
  triggerCompleted();
}
org.drools.core.spiProcessContext

Most used methods

  • <init>
  • setNodeInstance
  • setProcessInstance
  • getCaseAssignment
  • getCaseData
  • setVariable

Popular in Java

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • putExtra (Intent)
  • runOnUiThread (Activity)
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now