1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.engine;
18
19 import java.io.Serializable;
20 import java.util.HashMap;
21 import java.util.LinkedList;
22 import java.util.List;
23 import java.util.Map;
24
25 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
26 import org.kuali.rice.kew.engine.node.RouteNodeInstance;
27 import org.kuali.rice.kew.exception.WorkflowRuntimeException;
28 import org.kuali.rice.kew.routeheader.DocumentContent;
29 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
30 import org.kuali.rice.kew.routeheader.StandardDocumentContent;
31
32
33
34
35
36
37
38 public class RouteContext implements Serializable {
39
40 private static final long serialVersionUID = -7125137491367944594L;
41
42 private DocumentRouteHeaderValue routeHeader;
43
44 private DocumentContent documentContent;
45
46 private RouteNodeInstance nodeInstance;
47
48 private EngineState engineState;
49
50 private ActionRequestValue actionRequest;
51
52 private ActivationContext activationContext = new ActivationContext(!ActivationContext.CONTEXT_IS_SIMULATION);
53
54 private boolean doNotSendApproveNotificationEmails = false;
55
56 private Map parameters = new HashMap();
57
58 private boolean searchIndexingRequestedForContext = false;
59
60 public RouteContext() {
61 }
62
63 private static ThreadLocal<List<RouteContext>> ROUTE_CONTEXT_STACK = new ThreadLocal<List<RouteContext>>() {
64 protected List<RouteContext> initialValue() {
65 List<RouteContext> contextStack = new LinkedList<RouteContext>();
66 contextStack.add(0, new RouteContext());
67 return contextStack;
68 }
69 };
70
71 public static RouteContext getCurrentRouteContext() {
72 return ROUTE_CONTEXT_STACK.get().get(0);
73 }
74
75 public static void clearCurrentRouteContext() {
76 ROUTE_CONTEXT_STACK.get().remove(0);
77 ROUTE_CONTEXT_STACK.get().add(0, new RouteContext());
78 }
79
80 public static RouteContext createNewRouteContext() {
81 ROUTE_CONTEXT_STACK.get().add(0, new RouteContext());
82 return getCurrentRouteContext();
83 }
84
85 public static RouteContext releaseCurrentRouteContext() {
86 return ROUTE_CONTEXT_STACK.get().remove(0);
87 }
88
89
90
91
92 public DocumentRouteHeaderValue getRouteHeader() {
93 return routeHeader;
94 }
95
96
97
98
99 public void setRouteHeader(DocumentRouteHeaderValue routeHeader) {
100 this.routeHeader = routeHeader;
101 }
102
103 public DocumentRouteHeaderValue getDocument() {
104 return routeHeader;
105 }
106
107 public void setDocument(DocumentRouteHeaderValue routeHeader) {
108 this.routeHeader = routeHeader;
109 try {
110 setDocumentContent(new StandardDocumentContent(routeHeader.getDocContent(), this));
111 } catch (Exception e) {
112 throw new WorkflowRuntimeException(e);
113 }
114 }
115
116 public DocumentContent getDocumentContent() {
117 return documentContent;
118 }
119
120 public void setDocumentContent(DocumentContent documentContent) {
121 this.documentContent = documentContent;
122 }
123
124 public RouteNodeInstance getNodeInstance() {
125 return nodeInstance;
126 }
127
128 public void setNodeInstance(RouteNodeInstance nodeInstance) {
129 this.nodeInstance = nodeInstance;
130 }
131
132 public EngineState getEngineState() {
133 return engineState;
134 }
135
136 public void setEngineState(EngineState engineState) {
137 this.engineState = engineState;
138 }
139
140 public ActionRequestValue getActionRequest() {
141 return actionRequest;
142 }
143
144 public void setActionRequest(ActionRequestValue actionRequest) {
145 this.actionRequest = actionRequest;
146 }
147
148 public boolean isSimulation() {
149 if (activationContext == null) {
150 return false;
151 }
152 return activationContext.isSimulation();
153 }
154
155 public ActivationContext getActivationContext() {
156 return activationContext;
157 }
158
159 public void setActivationContext(ActivationContext activationContext) {
160 this.activationContext = activationContext;
161 }
162
163 public boolean isDoNotSendApproveNotificationEmails() {
164 return doNotSendApproveNotificationEmails;
165 }
166
167 public void setDoNotSendApproveNotificationEmails(boolean sendNotificationEmails) {
168 this.doNotSendApproveNotificationEmails = sendNotificationEmails;
169 }
170
171 public Map getParameters() {
172 return parameters;
173 }
174
175 public void setParameters(Map parameters) {
176 this.parameters = parameters;
177 }
178
179
180
181
182
183 public boolean isSearchIndexingRequestedForContext() {
184 return this.searchIndexingRequestedForContext;
185 }
186
187
188
189
190 public void requestSearchIndexingForContext() {
191 this.searchIndexingRequestedForContext = true;
192 }
193
194 }