Package org.jbpm.graph.exe

Examples of org.jbpm.graph.exe.ProcessInstance


    ProcessDefinition definition =
      ProcessDefinition.parseXmlResource("simple.par/processdefinition.xml");
    assertNotNull("Definition should not be null", definition);

    // Create an instance of the process definition.
    ProcessInstance instance = new ProcessInstance(definition);
    assertEquals(
        "Instance is in start state",
        instance.getRootToken().getNode().getName(),
        "start");
    assertNull(
        "Message variable should not exist yet",
        instance.getContextInstance().getVariable("message"));

    // Move the process instance from its start state to the first state.
    // The configured action should execute and the appropriate message
    // should appear in the message process variable.
    instance.signal();
    assertEquals(
        "Instance is in first state",
        instance.getRootToken().getNode().getName(),
        "first");
    assertEquals(
        "Message variable contains message",
        instance.getContextInstance().getVariable("message"),
        "Going to the first state!");

    // Move the process instance to the end state. The configured action
    // should execute again. The message variable contains a new value.
    instance.signal();
    assertEquals(
        "Instance is in end state",
        instance.getRootToken().getNode().getName(),
        "end");
    assertTrue("Instance has ended", instance.hasEnded());
    assertEquals(
        "Message variable is changed",
        instance.getContextInstance().getVariable("message"),
        "About to finish!");

  }
View Full Code Here


  public void testRetrievalFromSpringContext() throws Exception {
    Action action = processDefinition.getAction("myAction");
    ActionHandler delegate = (ActionHandler) action.getActionDelegation().getInstance();

    // create the context and pass it on to the action
    ProcessInstance instance = processDefinition.createProcessInstance();
    // we have to use transient variables or otherwise HB will get in the way
    instance.getContextInstance().setTransientVariable(DummyActionHandler.TEST_LABEL,
        applicationContext.getBean("jbpmAction"));
    Token token = instance.getRootToken();

    delegate.execute(new ExecutionContext(token));
  }
View Full Code Here

  public void testJbpmHandler() throws Exception {
    Action action = processDefinition.getAction("myAction");
    ActionHandler delegate = (ActionHandler) action.getActionDelegation().getInstance();

    // create the context and pass it on to the action
    ProcessInstance instance = processDefinition.createProcessInstance();
    // we have to use transient variables or otherwise HB will get in the way
    instance.getContextInstance().setTransientVariable(DummyActionHandler.TEST_LABEL,
        applicationContext.getBean("jbpmAction"));
    Token token = instance.getRootToken();

    delegate.execute(new ExecutionContext(token));
  }
View Full Code Here

    //     Load it again, individually
    ProcessDefinition pd2 = graphSession.loadProcessDefinition(pd.getId());

    //     Create an instance of the Process Def with Task
    ProcessInstance processInstance = new ProcessInstance(pd2);
    TaskInstance jbpmTaskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();

    //     Persist these changes
    graphSession.saveProcessInstance(processInstance);

    //     Be polite, like the template is.
View Full Code Here

  public TimerInfo(Timer timer) {
    timerId = timer.getId();
    timerName = timer.getName();
    Token token = timer.getToken();
    tokenId = (token!=null ? token.getId() : -1);
    ProcessInstance processInstance = timer.getProcessInstance();
    processInstanceId = (processInstance!=null ? processInstance.getId() : -1);
  }
View Full Code Here

    if (engine.isTrace()) log().setTrace(true);
    this.workflow = workflow;
    this.engine = engine;
    this.id = id;
    log().t("instance",id,workflow.getName(),variables);
    processInstance = new ProcessInstance(workflow.getProcessDefinition());
       
    ContextInstance contextInstance = processInstance.getContextInstance();
    if (variables != null) contextInstance.setVariables(variables);
    contextInstance.setProcessInstance(processInstance);
//    contextInstance.setVariable(JBpmContext.VAR_ENGINE, engine.getBpm());
View Full Code Here

      // set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)     
      Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));

      if (taskControllerDelegation != null) {
        TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
        ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
        ContextInstance contextInstance = (processInstance != null ? processInstance.getContextInstance() : null);
        Token token = taskInstance.getToken();

        if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
          UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerInitialization(taskControllerHandler, taskInstance, contextInstance, token);
        } else {
          taskControllerHandler.initializeTaskVariables(taskInstance, contextInstance, token);
        }

      } else {
        Token token = taskInstance.getToken();
        ProcessInstance processInstance = token.getProcessInstance();
        ContextInstance contextInstance = processInstance.getContextInstance();

        if (variableAccesses != null) {
          for (VariableAccess variableAccess : variableAccesses) {
            String mappedName = variableAccess.getMappedName();
            if (variableAccess.isReadable()) {
View Full Code Here

      // set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
      Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));

      if (taskControllerDelegation != null) {
        TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
        ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
        ContextInstance contextInstance = (processInstance != null ? processInstance.getContextInstance() : null);
        Token token = taskInstance.getToken();

        if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
          UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerSubmission(taskControllerHandler, taskInstance, contextInstance, token);
        } else {
          taskControllerHandler.submitTaskVariables(taskInstance, contextInstance, token);
        }

      } else {

        Token token = taskInstance.getToken();
        ProcessInstance processInstance = token.getProcessInstance();
        ContextInstance contextInstance = processInstance.getContextInstance();

        if (variableAccesses != null) {
          String missingTaskVariables = null;
          for (VariableAccess variableAccess : variableAccesses) {
            String mappedName = variableAccess.getMappedName();
View Full Code Here

  public Object execute(JbpmContext jbpmContext) throws Exception
  {
    Object object = super.execute(jbpmContext);
    if (object instanceof ProcessInstance)
    {
      ProcessInstance processInstance = (ProcessInstance)object;
      if (startTransitionName == null || startTransitionName.length() == 0)
        processInstance.signal();
      else
        processInstance.signal(startTransitionName);
     
      // [JBPM-1876] Missing jpbmContext.save on StartProcessInstanceCommand
      jbpmContext.save(processInstance);
    }
    return object;
View Full Code Here

            final FacesContext facesContext = FacesContext.getCurrentInstance();
            final ELContext elContext = facesContext.getELContext();
            final Object value = valueExpression.getValue(elContext);
            final Map<String,Object> updatesMap;
            if (value instanceof ProcessInstance) {
                final ProcessInstance processInstance = (ProcessInstance) value;
                updatesMap = new UpdatesHashMap(processInstance.getContextInstance().getVariables());
            } else if (value instanceof Token) {
                final Token token = (Token) value;
                updatesMap = new UpdatesHashMap(token.getProcessInstance().getContextInstance().getVariables(token));
            } else if (value instanceof TaskInstance) {
                final TaskInstance task = (TaskInstance) value;
View Full Code Here

TOP

Related Classes of org.jbpm.graph.exe.ProcessInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.