01: package org.jbpm.command;
02:
03: import org.jbpm.JbpmContext;
04: import org.jbpm.graph.exe.ProcessInstance;
05:
06: /**
07: * Graph command to start a new process and signal it immidiatly.
08: * The transition named in <code>startTransitionName</code> is used (or the default transition if it is null).
09: *
10: * The result of this command, if requested, is a {@link Long} value containing
11: * the process instance id.
12: *
13: * @author Jim Rigsbee, Tom Baeyens, Bernd Ruecker
14: */
15: public class StartProcessInstanceCommand extends
16: NewProcessInstanceCommand implements Command {
17:
18: private static final long serialVersionUID = -2428234069404269048L;
19:
20: /**
21: * this transition name is used for signalling (if null, the default
22: * transition is used)
23: */
24: private String startTransitionName = null;
25:
26: public Object execute(JbpmContext jbpmContext) throws Exception {
27: Object object = super .execute(jbpmContext);
28: if (object instanceof ProcessInstance) {
29: ProcessInstance processInstance = (ProcessInstance) object;
30: if (startTransitionName == null
31: || startTransitionName.length() == 0)
32: processInstance.signal();
33: else
34: processInstance.signal(startTransitionName);
35: }
36: return object;
37: }
38:
39: public String getStartTransitionName() {
40: return startTransitionName;
41: }
42:
43: public void setStartTransitionName(String startTransitionName) {
44: this.startTransitionName = startTransitionName;
45: }
46:
47: }
|