01: package org.jbpm.command;
02:
03: import java.util.Iterator;
04: import java.util.List;
05: import java.util.Map;
06:
07: import org.jbpm.JbpmContext;
08: import org.jbpm.graph.exe.Token;
09: import org.jbpm.logging.log.ProcessLog;
10:
11: /**
12: * Retrieve the <code>org.jbpm.logging.log.ProcessLog</code> for the
13: * process with the given process-id
14: *
15: * returns a map that maps {@link Token}s to {@link List}s.
16: *
17: * @author Bernd Ruecker (bernd.ruecker@camunda.com)
18: *
19: */
20: public class GetProcessInstanceLogCommand implements Command {
21:
22: private static final long serialVersionUID = -2812852941518870502L;
23:
24: private long processInstanceId;
25:
26: public GetProcessInstanceLogCommand() {
27: }
28:
29: public GetProcessInstanceLogCommand(long processInstanceId) {
30: this .processInstanceId = processInstanceId;
31: }
32:
33: public Object execute(JbpmContext jbpmContext) throws Exception {
34: Map logMap = jbpmContext.getLoggingSession()
35: .findLogsByProcessInstance(processInstanceId);
36: return loadLogdFromMap(logMap);
37: }
38:
39: /**
40: * access everything on all ProcessLog objects,
41: * which is not in the default fetch group from hibernate,
42: * but needs to be accesible from the client
43: *
44: * overwrite this method, if you need more details in your client
45: *
46: * @param m
47: */
48: protected Map loadLogdFromMap(Map logMap) {
49: Iterator iter = logMap.keySet().iterator();
50: while (iter.hasNext()) {
51: Token t = (Token) iter.next();
52:
53: List logs = (List) logMap.get(t);
54: Iterator iter2 = logs.iterator();
55: while (iter2.hasNext()) {
56: ProcessLog pl = (ProcessLog) iter2.next();
57: // TODO: I am not sure if we need that, write a test for it
58: pl.getActorId();
59: pl.toString();
60: }
61: }
62: return logMap;
63: }
64:
65: /**
66: * @deprecated use getProcessInstanceId instead
67: */
68: public long getProcessId() {
69: return processInstanceId;
70: }
71:
72: /**
73: * @deprecated use setProcessInstanceId instead
74: */
75: public void setProcessId(long processId) {
76: this .processInstanceId = processId;
77: }
78:
79: public long getProcessInstanceId() {
80: return processInstanceId;
81: }
82:
83: public void setProcessInstanceId(long processInstanceId) {
84: this.processInstanceId = processInstanceId;
85: }
86:
87: }
|