Package org.jbpm.graph.exe

Examples of org.jbpm.graph.exe.ProcessInstance


                final Token token = (Token) entity;
                final ContextInstance contextInstance = token.getProcessInstance().getContextInstance();
                oldValue = contextInstance.getVariable(name, token);
                contextInstance.deleteVariable(name, token);
            } else if (entity instanceof ProcessInstance) {
                final ProcessInstance processInstance = (ProcessInstance) entity;
                final ContextInstance contextInstance = processInstance.getContextInstance();
                oldValue = contextInstance.getVariable(name);
                contextInstance.deleteVariable(name);
            } else {
                context.setError("Error removing variable", "The value given for the 'entity' attribute is not a task, token, or process instance");
                return;
View Full Code Here


            if (!(processValue instanceof ProcessDefinition)) {
                context.setError("Error starting process", "Attempted to start something other than a process");
                return;
            }
            final ProcessDefinition definition = (ProcessDefinition) processValue;
            final ProcessInstance instance = definition.createProcessInstance();
            // Signal the root token based on the following criteria:
            // 1. If there is no start task, and
            // 2. If the root token is still at the start state, and
            // 3. If the start state has a default leaving transition, then
            // signal the token along the default transition.
            context.addSuccessMessage("Started process");

            final TaskMgmtInstance taskMgmtInstance = instance.getTaskMgmtInstance();
            final TaskInstance startTaskInstance = taskMgmtInstance.createStartTaskInstance();

            /* next piece causes NPE.
             * and i don't think it is needed to signal a new process automatically.  that can
             * be done in the console itself as well. 
             * TODO it would be nice if the console automatically navigated to the screen where
             * you can see the root token and actually give the signal

            if (startTaskInstance == null) {
                // There is no start task
                final Node initialNode = definition.getStartState();
                final Token rootToken = instance.getRootToken();
                final Node rootTokenNode = rootToken.getNode();
                if (initialNode.getId() == rootTokenNode.getId()) {
                    // The root token is still at the start node
                    final Transition defaultLeavingTransition = initialNode.getDefaultLeavingTransition();
                    if (defaultLeavingTransition != null) {
                        // There's a default transition
                        rootToken.signal(defaultLeavingTransition);
                        context.addSuccessMessage("Signalled root token");
                    }
                }
            }
            */
           
            context.selectOutcome("started");
            if (instance.hasEnded()) {
                context.selectOutcome("finished");
                context.addSuccessMessage("Process completed");
            }
            if (instanceExpression != null) {
                try {
View Full Code Here

    }
  }
 
  public ContextInstance getContextInstance() {
    Token token = getToken();
    ProcessInstance processInstance = (token!=null ? token.getProcessInstance() : null);
    return (processInstance!=null ? processInstance.getContextInstance() : null);
  }
View Full Code Here

        JobSession jobSession = jbpmContext.getJobSession();
        Job job = jobSession.getFirstAcquirableJob(lockOwner);

        if (job != null) {
          if (job.isExclusive()) {
            ProcessInstance processInstance = job.getProcessInstance();
            log.debug("loaded exclusive " + job + ", finding exclusive jobs for " + processInstance);
            acquiredJobs = jobSession.findExclusiveJobs(lockOwner, processInstance);
            log.debug("trying to obtain locks on " + acquiredJobs + " for " + processInstance);
          }
          else {
View Full Code Here

      // batch tokens
      if (processInstanceIds != null && processInstanceIds.length > 0)
      {
        for (int i = 0; i < processInstanceIds.length; i++)
        {
          ProcessInstance pi = jbpmContext.loadProcessInstanceForUpdate(processInstanceIds[i]);
          result.add(execute(pi));
        }
      }

      // search for ProcessInstances according to parameters
      if (processName != null)
      {
        operateOnSingleObject = false;

        GetProcessInstancesCommand cmd = new GetProcessInstancesCommand();
        cmd.setProcessDefinitionName(processName);
        cmd.setOnlyRunning(onlyRunning);
        if (processVersion > 0) cmd.setVersion(String.valueOf(processVersion));

        List processInstanceList = (List) cmd.execute(jbpmContext);

        Iterator iter = processInstanceList.iterator();
        while (iter.hasNext())
        {
          ProcessInstance pi = (ProcessInstance) iter.next();
          result.add(
              execute(pi));
        }
      }
View Full Code Here

    this.processDefinition = this;
    ProcessFactory.addNodesAndTransitions(this, nodes, transitions);
  }

  public ProcessInstance createProcessInstance() {
    return new ProcessInstance(this);
  }
View Full Code Here

  public ProcessInstance createProcessInstance() {
    return new ProcessInstance(this);
  }

  public ProcessInstance createProcessInstance(Map<String, Object> variables) {
    return new ProcessInstance(this, variables, null);
  }
View Full Code Here

  public ProcessInstance createProcessInstance(Map<String, Object> variables) {
    return new ProcessInstance(this, variables, null);
  }

  public ProcessInstance createProcessInstance(Map<String, Object> variables, String businessKey) {
    return new ProcessInstance(this, variables, businessKey);
  }
View Full Code Here

  }

  // module definitions ///////////////////////////////////////////////////////

  public Object createInstance() {
    return new ProcessInstance(this);
  }
View Full Code Here

    return null;
  }

  protected void cancelProcess(long processInstanceIdToCancel)
  {
    ProcessInstance pi = jbpmContext.getProcessInstanceForUpdate(processInstanceIdToCancel);

    log.info("cancel process instance " + pi.getId());

    // Record a standardized variable that we can use to determine that this
    // process has been 'canceled' and not just ended.
    pi.getContextInstance().createVariable(CANCELLATION_INDICATOR_VARIABLE_NAME, Clock.getCurrentTime());

    try
    {
      // End the process instance and any open tokens
      // TODO: Think about maybe canceling sub processes?
      cancelToken(pi.getRootToken());

      pi.end();

      log.info("finished process cancellation");
    }
    catch (RuntimeException ex)
    {
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.