01: package org.jbpm.jpdl.el.impl;
02:
03: import org.jbpm.JbpmConfiguration;
04: import org.jbpm.context.exe.ContextInstance;
05: import org.jbpm.graph.exe.ExecutionContext;
06: import org.jbpm.graph.exe.Token;
07: import org.jbpm.jpdl.el.ELException;
08: import org.jbpm.jpdl.el.VariableResolver;
09: import org.jbpm.taskmgmt.exe.SwimlaneInstance;
10: import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
11:
12: public class JbpmVariableResolver implements VariableResolver {
13:
14: public Object resolveVariable(String name) throws ELException {
15: ExecutionContext executionContext = ExecutionContext
16: .currentExecutionContext();
17: Object value = null;
18:
19: if ("taskInstance".equals(name)) {
20: value = executionContext.getTaskInstance();
21:
22: } else if ("processInstance".equals(name)) {
23: value = executionContext.getProcessInstance();
24:
25: } else if ("processDefinition".equals(name)) {
26: value = executionContext.getProcessDefinition();
27:
28: } else if ("token".equals(name)) {
29: value = executionContext.getToken();
30:
31: } else if ("taskMgmtInstance".equals(name)) {
32: value = executionContext.getTaskMgmtInstance();
33:
34: } else if ("contextInstance".equals(name)) {
35: value = executionContext.getContextInstance();
36:
37: } else if ((executionContext.getTaskInstance() != null)
38: && (executionContext.getTaskInstance()
39: .hasVariableLocally(name))) {
40: value = executionContext.getTaskInstance()
41: .getVariable(name);
42:
43: } else {
44: ContextInstance contextInstance = executionContext
45: .getContextInstance();
46: TaskMgmtInstance taskMgmtInstance = executionContext
47: .getTaskMgmtInstance();
48: Token token = executionContext.getToken();
49:
50: if ((contextInstance != null)
51: && (contextInstance.hasVariable(name))) {
52: value = contextInstance.getVariable(name, token);
53:
54: } else if ((contextInstance != null)
55: && (contextInstance.hasTransientVariable(name))) {
56: value = contextInstance.getTransientVariable(name);
57:
58: } else if ((taskMgmtInstance != null)
59: && (taskMgmtInstance.getSwimlaneInstances() != null)
60: && (taskMgmtInstance.getSwimlaneInstances()
61: .containsKey(name))) {
62: SwimlaneInstance swimlaneInstance = taskMgmtInstance
63: .getSwimlaneInstance(name);
64: value = (swimlaneInstance != null ? swimlaneInstance
65: .getActorId() : null);
66:
67: } else if ((contextInstance != null)
68: && (contextInstance.hasTransientVariable(name))) {
69: value = contextInstance.getTransientVariable(name);
70:
71: } else if (JbpmConfiguration.Configs.hasObject(name)) {
72: value = JbpmConfiguration.Configs.getObject(name);
73: }
74: }
75:
76: return value;
77: }
78: }
|