01: package org.emforge.jbpm;
02:
03: import org.apache.commons.collections.Transformer;
04: import org.emforge.jbpm.web.bean.TaskController;
05: import org.emforge.xfer.HistoryTO;
06: import org.jbpm.graph.log.ProcessInstanceCreateLog;
07: import org.jbpm.graph.log.ProcessInstanceEndLog;
08: import org.jbpm.logging.log.ProcessLog;
09: import org.jbpm.taskmgmt.log.TaskEndLog;
10:
11: import ru.emdev.EmForge.EmForgeContext;
12: import ru.emdev.EmForge.util.Helper;
13:
14: /** Transformer for converting ProcessLog entries to the History objects
15: *
16: */
17: public class ProcessLogTransformer implements Transformer {
18: EmForgeContext emForgeContext;
19: Long taskId;
20:
21: public ProcessLogTransformer(EmForgeContext emForgeContext,
22: Long taskId) {
23: this .emForgeContext = emForgeContext;
24: this .taskId = taskId;
25: }
26:
27: public HistoryTO transform(Object i_input) {
28: ProcessLog processLog = (ProcessLog) i_input;
29: HistoryTO history = new HistoryTO();
30:
31: // we need to check all logic we had before - it is as comment at the end of this class
32: history.setActor(processLog.getActorId());
33: history.setDate(processLog.getDate());
34:
35: String message = null;
36: if (processLog instanceof ProcessInstanceCreateLog) {
37: message = "Start New Process";
38: } else if (processLog instanceof ProcessInstanceEndLog) {
39: ProcessInstanceEndLog pl = (ProcessInstanceEndLog) processLog;
40: message = "Process Finished: "
41: + pl.getToken().getNode().getName();
42: } else if (processLog instanceof TaskEndLog) {
43: TaskEndLog pl = (TaskEndLog) processLog;
44: message = "End Task: " + pl.getTaskInstance().getName();
45: }
46:
47: history.setMessage(message);
48:
49: // set link
50: String link = Helper.concatUrl(emForgeContext
51: .getApplicationPath(), TaskController.TASK_PAGE_NAME);
52:
53: link = Helper.concatUrl(link, taskId.toString());
54:
55: history.setLink(link);
56:
57: return history;
58: }
59:
60: }
|