01: package org.jbpm.command;
02:
03: import java.util.Iterator;
04:
05: import org.apache.commons.logging.Log;
06: import org.apache.commons.logging.LogFactory;
07: import org.jbpm.JbpmContext;
08: import org.jbpm.graph.exe.ProcessInstance;
09: import org.jbpm.graph.exe.Token;
10: import org.jbpm.logging.log.ProcessLog;
11:
12: /**
13: * This command can retrieve the matching process instances (e.g. for admin
14: * client) with the given process-id, token id or task-id
15: *
16: * @author Bernd Ruecker (bernd.ruecker@camunda.com)
17: */
18: public class GetProcessInstanceCommand extends
19: AbstractGetObjectBaseCommand {
20:
21: private static final long serialVersionUID = -8436697080972165601L;
22:
23: private static final Log log = LogFactory
24: .getLog(GetProcessInstanceCommand.class);
25:
26: private long processInstanceId;
27:
28: private long tokenId;
29:
30: private long taskInstanceId;
31:
32: public GetProcessInstanceCommand() {
33: }
34:
35: public GetProcessInstanceCommand(long processInstanceId) {
36: this .processInstanceId = processInstanceId;
37: }
38:
39: public GetProcessInstanceCommand(long processInstanceId,
40: boolean includeVariables, boolean includeLogs) {
41: super (true, true);
42: this .processInstanceId = processInstanceId;
43: }
44:
45: public Object execute(JbpmContext jbpmContext) throws Exception {
46: setJbpmContext(jbpmContext);
47:
48: ProcessInstance processInstance = null;
49: if (processInstanceId != 0)
50: processInstance = jbpmContext
51: .getProcessInstance(processInstanceId);
52: else if (tokenId != 0)
53: processInstance = jbpmContext.getToken(tokenId)
54: .getProcessInstance();
55: else if (taskInstanceId != 0)
56: processInstance = jbpmContext.getTaskInstance(
57: taskInstanceId).getProcessInstance();
58:
59: if (processInstance != null) {
60: processInstance = retrieveProcessInstance(processInstance);
61: }
62: return processInstance;
63: }
64:
65: public long getProcessInstanceId() {
66: return processInstanceId;
67: }
68:
69: public void setProcessInstanceId(long processInstanceId) {
70: this .processInstanceId = processInstanceId;
71: }
72:
73: public long getTaskInstanceId() {
74: return taskInstanceId;
75: }
76:
77: public void setTaskInstanceId(long taskInstanceId) {
78: this .taskInstanceId = taskInstanceId;
79: }
80:
81: public long getTokenId() {
82: return tokenId;
83: }
84:
85: public void setTokenId(long tokenId) {
86: this.tokenId = tokenId;
87: }
88:
89: }
|