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