All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbpm.command.GetProcessDefinitionCommand Maven / Gradle / Ivy

The newest version!
package org.jbpm.command;

import org.jbpm.JbpmContext;

/**
 * This Command return the process definition
 * 
 * @author Bernd Ruecker ([email protected])
 */
public class GetProcessDefinitionCommand extends AbstractGetObjectBaseCommand {

  private static final long serialVersionUID = -1908847549444051495L;

  private int version = -1;

  private String name;

  public GetProcessDefinitionCommand() {
  }

  public GetProcessDefinitionCommand(String name) {
    super();
    this.name = name;
  }

  public GetProcessDefinitionCommand(String name, int version) {
    super();
    this.version = version;
    this.name = name;
  }

  public Object execute(JbpmContext jbpmContext) throws Exception {
    if (version >= 0)
      return retrieveProcessDefinition(jbpmContext.getGraphSession().findProcessDefinition(name,
          version));
    else
      return retrieveProcessDefinition(jbpmContext.getGraphSession().findLatestProcessDefinition(
          name));
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getVersion() {
    return version;
  }

  public void setVersion(int version) {
    this.version = version;
  }

  public String getAdditionalToStringInformation() {
    return "name=" + name + ";version=" + version;
  }

  // methods for fluent programming

  public GetProcessDefinitionCommand version(int version) {
    setVersion(version);
    return this;
  }

  public GetProcessDefinitionCommand name(String name) {
    setName(name);
    return this;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy