01: package org.jbpm.command;
02:
03: import java.util.Iterator;
04: import java.util.List;
05:
06: import org.jbpm.JbpmContext;
07: import org.jbpm.graph.def.ProcessDefinition;
08:
09: /**
10: * This Command returns all process definitions (or only the latest if
11: * onlyLatest is true)
12: *
13: * @author Bernd Ruecker (bernd.ruecker@camunda.com)
14: */
15: public class GetProcessDefinitionsCommand extends
16: AbstractGetObjectBaseCommand {
17:
18: private static final long serialVersionUID = -1908847549444051495L;
19:
20: private boolean onlyLatest = true;
21:
22: public GetProcessDefinitionsCommand() {
23: }
24:
25: public GetProcessDefinitionsCommand(boolean onlyLatest) {
26: this .onlyLatest = onlyLatest;
27: }
28:
29: public Object execute(JbpmContext jbpmContext) throws Exception {
30: setJbpmContext(jbpmContext);
31: List result = (onlyLatest ? jbpmContext.getGraphSession()
32: .findLatestProcessDefinitions() : jbpmContext
33: .getGraphSession().findAllProcessDefinitions());
34:
35: /*
36: * traverse and access property if it is missing in the default
37: * fetchgroup
38: */
39: Iterator iter = result.iterator();
40: while (iter.hasNext()) {
41: ProcessDefinition pd = (ProcessDefinition) iter.next();
42: retrieveProcessDefinition(pd);
43: }
44:
45: return result;
46: }
47:
48: public boolean isOnlyLatest() {
49: return onlyLatest;
50: }
51:
52: public void setOnlyLatest(boolean onlyLatest) {
53: this.onlyLatest = onlyLatest;
54: }
55:
56: }
|