Package org.jbpm.command

Source Code of org.jbpm.command.StartProcessInstanceCommand

package org.jbpm.command;

import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;

/**
* Graph command to start a new process and signal it immidiatly. The transition named in
* <code>startTransitionName</code> is used (or the default transition if it is null).
*
* The result of this command, if requested, is a {@link Long} value containing the process instance id.
*
* @author Jim Rigsbee, Tom Baeyens, Bernd Ruecker
*/
public class StartProcessInstanceCommand extends NewProcessInstanceCommand
{

  private static final long serialVersionUID = -2428234069404269048L;

  /**
   * this transition name is used for signalling (if null, the default transition is used)
   */
  private String startTransitionName = null;

  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;
  }

  public String getStartTransitionName()
  {
    return startTransitionName;
  }

  public void setStartTransitionName(String startTransitionName)
  {
    this.startTransitionName = startTransitionName;
  }

  @Override
  public String getAdditionalToStringInformation()
  {
    return super.getAdditionalToStringInformation()
      + ";startTransitionName=" + startTransitionName;
 
 
  // methods for fluent programming

  public StartProcessInstanceCommand startTransitionName(String startTransitionName)
  {
    setStartTransitionName(startTransitionName);
    return this;
  }

}
TOP

Related Classes of org.jbpm.command.StartProcessInstanceCommand

TOP
Copyright © 2018 www.massapi.com. 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.