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.api.WorkflowRuntimeException; |
27 | |
import org.kuali.rice.kew.engine.node.RouteNodeInstance; |
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 | 0 | private ActivationContext activationContext = new ActivationContext(!ActivationContext.CONTEXT_IS_SIMULATION); |
53 | |
|
54 | 0 | private boolean doNotSendApproveNotificationEmails = false; |
55 | |
|
56 | 0 | private Map parameters = new HashMap(); |
57 | |
|
58 | 0 | private boolean searchIndexingRequestedForContext = false; |
59 | |
|
60 | 0 | public RouteContext() { |
61 | 0 | } |
62 | |
|
63 | 0 | private static ThreadLocal<List<RouteContext>> ROUTE_CONTEXT_STACK = new ThreadLocal<List<RouteContext>>() { |
64 | |
protected List<RouteContext> initialValue() { |
65 | 0 | List<RouteContext> contextStack = new LinkedList<RouteContext>(); |
66 | 0 | contextStack.add(0, new RouteContext()); |
67 | 0 | return contextStack; |
68 | |
} |
69 | |
}; |
70 | |
|
71 | |
public static RouteContext getCurrentRouteContext() { |
72 | 0 | return ROUTE_CONTEXT_STACK.get().get(0); |
73 | |
} |
74 | |
|
75 | |
public static void clearCurrentRouteContext() { |
76 | 0 | ROUTE_CONTEXT_STACK.get().remove(0); |
77 | 0 | ROUTE_CONTEXT_STACK.get().add(0, new RouteContext()); |
78 | 0 | } |
79 | |
|
80 | |
public static RouteContext createNewRouteContext() { |
81 | 0 | ROUTE_CONTEXT_STACK.get().add(0, new RouteContext()); |
82 | 0 | return getCurrentRouteContext(); |
83 | |
} |
84 | |
|
85 | |
public static RouteContext releaseCurrentRouteContext() { |
86 | 0 | return ROUTE_CONTEXT_STACK.get().remove(0); |
87 | |
} |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
public DocumentRouteHeaderValue getRouteHeader() { |
93 | 0 | return routeHeader; |
94 | |
} |
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
public void setRouteHeader(DocumentRouteHeaderValue routeHeader) { |
100 | 0 | this.routeHeader = routeHeader; |
101 | 0 | } |
102 | |
|
103 | |
public DocumentRouteHeaderValue getDocument() { |
104 | 0 | return routeHeader; |
105 | |
} |
106 | |
|
107 | |
public void setDocument(DocumentRouteHeaderValue routeHeader) { |
108 | 0 | this.routeHeader = routeHeader; |
109 | |
try { |
110 | 0 | setDocumentContent(new StandardDocumentContent(routeHeader.getDocContent(), this)); |
111 | 0 | } catch (Exception e) { |
112 | 0 | throw new WorkflowRuntimeException(e); |
113 | 0 | } |
114 | 0 | } |
115 | |
|
116 | |
public DocumentContent getDocumentContent() { |
117 | 0 | return documentContent; |
118 | |
} |
119 | |
|
120 | |
public void setDocumentContent(DocumentContent documentContent) { |
121 | 0 | this.documentContent = documentContent; |
122 | 0 | } |
123 | |
|
124 | |
public RouteNodeInstance getNodeInstance() { |
125 | 0 | return nodeInstance; |
126 | |
} |
127 | |
|
128 | |
public void setNodeInstance(RouteNodeInstance nodeInstance) { |
129 | 0 | this.nodeInstance = nodeInstance; |
130 | 0 | } |
131 | |
|
132 | |
public EngineState getEngineState() { |
133 | 0 | return engineState; |
134 | |
} |
135 | |
|
136 | |
public void setEngineState(EngineState engineState) { |
137 | 0 | this.engineState = engineState; |
138 | 0 | } |
139 | |
|
140 | |
public ActionRequestValue getActionRequest() { |
141 | 0 | return actionRequest; |
142 | |
} |
143 | |
|
144 | |
public void setActionRequest(ActionRequestValue actionRequest) { |
145 | 0 | this.actionRequest = actionRequest; |
146 | 0 | } |
147 | |
|
148 | |
public boolean isSimulation() { |
149 | 0 | if (activationContext == null) { |
150 | 0 | return false; |
151 | |
} |
152 | 0 | return activationContext.isSimulation(); |
153 | |
} |
154 | |
|
155 | |
public ActivationContext getActivationContext() { |
156 | 0 | return activationContext; |
157 | |
} |
158 | |
|
159 | |
public void setActivationContext(ActivationContext activationContext) { |
160 | 0 | this.activationContext = activationContext; |
161 | 0 | } |
162 | |
|
163 | |
public boolean isDoNotSendApproveNotificationEmails() { |
164 | 0 | return doNotSendApproveNotificationEmails; |
165 | |
} |
166 | |
|
167 | |
public void setDoNotSendApproveNotificationEmails(boolean sendNotificationEmails) { |
168 | 0 | this.doNotSendApproveNotificationEmails = sendNotificationEmails; |
169 | 0 | } |
170 | |
|
171 | |
public Map getParameters() { |
172 | 0 | return parameters; |
173 | |
} |
174 | |
|
175 | |
public void setParameters(Map parameters) { |
176 | 0 | this.parameters = parameters; |
177 | 0 | } |
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
public boolean isSearchIndexingRequestedForContext() { |
184 | 0 | return this.searchIndexingRequestedForContext; |
185 | |
} |
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
public void requestSearchIndexingForContext() { |
191 | 0 | this.searchIndexingRequestedForContext = true; |
192 | 0 | } |
193 | |
|
194 | |
} |