1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.rule.web; |
18 | |
|
19 | |
import org.apache.commons.lang.StringUtils; |
20 | |
import org.apache.struts.action.ActionForm; |
21 | |
import org.apache.struts.action.ActionForward; |
22 | |
import org.apache.struts.action.ActionMapping; |
23 | |
import org.apache.struts.action.ActionMessages; |
24 | |
import org.kuali.rice.kew.actionrequest.ActionRequestValue; |
25 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
26 | |
import org.kuali.rice.kew.doctype.service.DocumentTypeService; |
27 | |
import org.kuali.rice.kew.engine.ActivationContext; |
28 | |
import org.kuali.rice.kew.engine.RouteContext; |
29 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
30 | |
import org.kuali.rice.kew.engine.node.RouteNodeInstance; |
31 | |
import org.kuali.rice.kew.routeheader.AttributeDocumentContent; |
32 | |
import org.kuali.rice.kew.routeheader.DocumentContent; |
33 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
34 | |
import org.kuali.rice.kew.routelog.web.RouteLogAction; |
35 | |
import org.kuali.rice.kew.routelog.web.RouteLogForm; |
36 | |
import org.kuali.rice.kew.rule.FlexRM; |
37 | |
import org.kuali.rice.kew.rule.WorkflowAttribute; |
38 | |
import org.kuali.rice.kew.rule.bo.RuleAttribute; |
39 | |
import org.kuali.rice.kew.rule.bo.RuleTemplate; |
40 | |
import org.kuali.rice.kew.rule.bo.RuleTemplateAttribute; |
41 | |
import org.kuali.rice.kew.rule.service.RuleTemplateService; |
42 | |
import org.kuali.rice.kew.rule.xmlrouting.GenericXMLRuleAttribute; |
43 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
44 | |
import org.kuali.rice.kew.util.KEWConstants; |
45 | |
import org.kuali.rice.kew.web.KewKualiAction; |
46 | |
import org.kuali.rice.kns.UserSession; |
47 | |
import org.kuali.rice.kns.exception.ValidationException; |
48 | |
import org.kuali.rice.kns.util.GlobalVariables; |
49 | |
import org.kuali.rice.kns.web.ui.Field; |
50 | |
import org.kuali.rice.kns.web.ui.Row; |
51 | |
|
52 | |
import javax.servlet.http.HttpServletRequest; |
53 | |
import javax.servlet.http.HttpServletResponse; |
54 | |
import java.sql.Timestamp; |
55 | |
import java.text.SimpleDateFormat; |
56 | |
import java.util.*; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | 0 | public class RoutingReportAction extends KewKualiAction { |
65 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(RoutingReportAction.class); |
66 | |
|
67 | |
public static final String DOC_TYPE_REPORTING = "documentType"; |
68 | |
public static final String TEMPLATE_REPORTING = "template"; |
69 | |
|
70 | |
@Override |
71 | |
public ActionForward execute(ActionMapping mapping, ActionForm form, |
72 | |
HttpServletRequest request, HttpServletResponse response) |
73 | |
throws Exception { |
74 | 0 | this.initiateForm(request, form); |
75 | 0 | RoutingReportForm routingForm = (RoutingReportForm)form; |
76 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(routingForm.getDateRef())) { |
77 | 0 | SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); |
78 | 0 | routingForm.setEffectiveHour("5"); |
79 | 0 | routingForm.setEffectiveMinute("0"); |
80 | 0 | routingForm.setAmPm("1"); |
81 | 0 | routingForm.setDateRef(sdf.format(new Date())); |
82 | 0 | routingForm.setReportType(TEMPLATE_REPORTING); |
83 | |
} |
84 | 0 | if (DOC_TYPE_REPORTING.equals(routingForm.getReportType())) { |
85 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(routingForm.getDocumentTypeParam())) { |
86 | 0 | throw new RuntimeException("No document type was given"); |
87 | |
} |
88 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(routingForm.getInitiatorPrincipalId())) { |
89 | 0 | throw new RuntimeException("No initiator principal id was given"); |
90 | |
} |
91 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(routingForm.getDocumentContent())) { |
92 | 0 | throw new RuntimeException("No document content was given"); |
93 | |
} |
94 | 0 | } else if (!(TEMPLATE_REPORTING.equals(routingForm.getReportType()))) { |
95 | |
|
96 | 0 | throw new RuntimeException("The Routing Report type is not set"); |
97 | |
} |
98 | 0 | return super.execute(mapping, form, request, response); |
99 | |
} |
100 | |
|
101 | |
public ActionForward calculateRoute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
102 | 0 | RoutingReportForm routingForm = (RoutingReportForm) form; |
103 | |
|
104 | 0 | List errors = new ArrayList(); |
105 | |
|
106 | 0 | if (getDocumentTypeService().findByName(routingForm.getDocumentType()) == null) { |
107 | 0 | GlobalVariables.getMessageMap().putError("Document type is required.", "doctype.documenttypeservice.doctypename.required"); |
108 | |
} |
109 | 0 | Timestamp date = null; |
110 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(routingForm.getDateRef())) { |
111 | 0 | SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); |
112 | |
try { |
113 | 0 | Calendar calendar = Calendar.getInstance(); |
114 | 0 | calendar.setTime(sdf.parse(routingForm.getDateRef())); |
115 | 0 | calendar.set(Calendar.HOUR, Integer.parseInt(routingForm.getEffectiveHour())); |
116 | 0 | calendar.set(Calendar.MINUTE, Integer.parseInt(routingForm.getEffectiveMinute())); |
117 | 0 | calendar.set(Calendar.AM_PM, Integer.parseInt(routingForm.getAmPm())); |
118 | 0 | date = new Timestamp(calendar.getTimeInMillis()); |
119 | 0 | } catch (Exception e) { |
120 | 0 | LOG.error("error parsing date", e); |
121 | 0 | GlobalVariables.getMessageMap().putError("Invalid date.", "routereport.effectiveDate.invalid"); |
122 | 0 | } |
123 | |
} |
124 | |
|
125 | 0 | if (!GlobalVariables.getMessageMap().hasNoErrors()) { |
126 | 0 | throw new ValidationException("Errors populating rule attributes."); |
127 | |
} |
128 | |
|
129 | 0 | DocumentTypeService documentTypeService = (DocumentTypeService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE); |
130 | 0 | DocumentType docType = documentTypeService.findByName(routingForm.getDocumentType()); |
131 | |
|
132 | 0 | DocumentRouteHeaderValue routeHeader = new DocumentRouteHeaderValue(); |
133 | 0 | routeHeader.setDocumentId(""); |
134 | 0 | routeHeader.setDocumentTypeId(docType.getDocumentTypeId()); |
135 | 0 | routeHeader.setDocRouteLevel(new Integer(0)); |
136 | 0 | routeHeader.setDocVersion(new Integer(KEWConstants.CURRENT_DOCUMENT_VERSION)); |
137 | |
|
138 | 0 | List<RouteReportRuleTemplateContainer> ruleTemplateContainers = new ArrayList<RouteReportRuleTemplateContainer>(); |
139 | 0 | if (routingForm.getReportType().equals(DOC_TYPE_REPORTING)) { |
140 | |
|
141 | 0 | List routeNodes = KEWServiceLocator.getRouteNodeService().getFlattenedNodes(docType, true); |
142 | 0 | for (Iterator iter = routeNodes.iterator(); iter.hasNext();) { |
143 | 0 | RouteNode routeNode = (RouteNode) iter.next(); |
144 | 0 | if (routeNode.isFlexRM()) { |
145 | 0 | RuleTemplate ruleTemplate = getRuleTemplateService().findByRuleTemplateName(routeNode.getRouteMethodName()); |
146 | 0 | if (ruleTemplate != null) { |
147 | 0 | ruleTemplateContainers.add(new RouteReportRuleTemplateContainer(ruleTemplate, routeNode)); |
148 | 0 | if (ruleTemplate.getDelegationTemplate() != null) { |
149 | 0 | ruleTemplateContainers.add(new RouteReportRuleTemplateContainer(ruleTemplate.getDelegationTemplate(), routeNode)); |
150 | |
} |
151 | |
} |
152 | |
} |
153 | 0 | } |
154 | 0 | } else { |
155 | 0 | RuleTemplate ruleTemplate = getRuleTemplateService().findByRuleTemplateId(routingForm.getRuleTemplateId()); |
156 | 0 | RouteNode routeNode = new RouteNode(); |
157 | 0 | routeNode.setRouteNodeName(ruleTemplate.getName()); |
158 | 0 | ruleTemplateContainers.add(new RouteReportRuleTemplateContainer(ruleTemplate, routeNode)); |
159 | 0 | if (ruleTemplate.getDelegationTemplate() != null) { |
160 | 0 | ruleTemplateContainers.add(new RouteReportRuleTemplateContainer(ruleTemplate.getDelegationTemplate(), routeNode)); |
161 | |
} |
162 | |
} |
163 | |
|
164 | 0 | String xmlDocumentContent = routingForm.getDocumentContent(); |
165 | 0 | if (routingForm.getReportType().equals(TEMPLATE_REPORTING)) { |
166 | 0 | List attributes = new ArrayList(); |
167 | 0 | for (Object element : ruleTemplateContainers) { |
168 | 0 | RouteReportRuleTemplateContainer ruleTemplateContainer = (RouteReportRuleTemplateContainer) element; |
169 | 0 | RuleTemplate ruleTemplate = ruleTemplateContainer.ruleTemplate; |
170 | 0 | for (Object element2 : ruleTemplate.getActiveRuleTemplateAttributes()) { |
171 | 0 | RuleTemplateAttribute ruleTemplateAttribute = (RuleTemplateAttribute) element2; |
172 | 0 | if (!ruleTemplateAttribute.isWorkflowAttribute()) { |
173 | 0 | continue; |
174 | |
} |
175 | 0 | WorkflowAttribute workflowAttribute = ruleTemplateAttribute.getWorkflowAttribute(); |
176 | |
|
177 | 0 | RuleAttribute ruleAttribute = ruleTemplateAttribute.getRuleAttribute(); |
178 | 0 | if (ruleAttribute.getType().equals(KEWConstants.RULE_XML_ATTRIBUTE_TYPE)) { |
179 | 0 | ((GenericXMLRuleAttribute) workflowAttribute).setRuleAttribute(ruleAttribute); |
180 | |
} |
181 | 0 | List attValidationErrors = workflowAttribute.validateRoutingData(routingForm.getFields()); |
182 | 0 | if (attValidationErrors != null && !attValidationErrors.isEmpty()) { |
183 | 0 | errors.addAll(attValidationErrors); |
184 | |
} |
185 | 0 | attributes.add(workflowAttribute); |
186 | 0 | } |
187 | 0 | } |
188 | |
|
189 | 0 | if (!GlobalVariables.getMessageMap().hasNoErrors()) { |
190 | 0 | throw new ValidationException("errors in search criteria"); |
191 | |
} |
192 | |
|
193 | 0 | DocumentContent docContent = new AttributeDocumentContent(attributes); |
194 | 0 | xmlDocumentContent = docContent.getDocContent(); |
195 | |
} |
196 | |
|
197 | 0 | routeHeader.setDocContent(xmlDocumentContent); |
198 | 0 | routeHeader.setInitiatorWorkflowId(getUserSession(request).getPrincipalId()); |
199 | 0 | routeHeader.setDocRouteStatus(KEWConstants.ROUTE_HEADER_INITIATED_CD); |
200 | 0 | routeHeader.setDocTitle("Routing Report"); |
201 | 0 | routeHeader.setRoutingReport(true); |
202 | 0 | long magicCounter = 0; |
203 | |
|
204 | 0 | FlexRM flexRM = new FlexRM(date); |
205 | |
|
206 | 0 | int numberOfRules = 0; |
207 | 0 | int numberOfActionRequests = 0; |
208 | 0 | Set<String> alreadyProcessedRuleTemplateNames = new HashSet<String>(); |
209 | 0 | for (Object element : ruleTemplateContainers) { |
210 | |
|
211 | 0 | RouteContext context = RouteContext.createNewRouteContext(); |
212 | 0 | context.setActivationContext(new ActivationContext(ActivationContext.CONTEXT_IS_SIMULATION)); |
213 | |
try { |
214 | 0 | RouteReportRuleTemplateContainer ruleTemplateContainer = (RouteReportRuleTemplateContainer) element; |
215 | 0 | RuleTemplate ruleTemplate = ruleTemplateContainer.ruleTemplate; |
216 | 0 | RouteNode routeLevel = ruleTemplateContainer.routeNode; |
217 | |
|
218 | 0 | if (!alreadyProcessedRuleTemplateNames.contains(ruleTemplate.getName())) { |
219 | 0 | alreadyProcessedRuleTemplateNames.add(ruleTemplate.getName()); |
220 | 0 | List actionRequests = flexRM.getActionRequests(routeHeader, routeLevel, null, ruleTemplate.getName()); |
221 | |
|
222 | 0 | numberOfActionRequests += actionRequests.size(); |
223 | 0 | numberOfRules += flexRM.getNumberOfMatchingRules(); |
224 | |
|
225 | 0 | magicCounter = populateActionRequestsWithRouteLevelInformationAndIterateMagicCounter(routeLevel, actionRequests, magicCounter); |
226 | |
|
227 | 0 | routeHeader.getSimulatedActionRequests().addAll(actionRequests); |
228 | |
} |
229 | |
} finally { |
230 | 0 | RouteContext.clearCurrentRouteContext(); |
231 | 0 | } |
232 | 0 | } |
233 | |
|
234 | 0 | if (numberOfActionRequests == 0) { |
235 | 0 | if (numberOfRules == 0) { |
236 | 0 | GlobalVariables.getMessageMap().putError("*", "routereport.noRules"); |
237 | |
} else { |
238 | 0 | GlobalVariables.getMessageMap().putError("*", "routereport.noMatchingRules"); |
239 | |
} |
240 | 0 | if (GlobalVariables.getMessageMap().hasErrors()) { |
241 | 0 | throw new ValidationException("errors in search criteria"); |
242 | |
} |
243 | |
} |
244 | |
|
245 | |
|
246 | |
|
247 | 0 | RouteLogForm routeLogForm = new RouteLogForm(); |
248 | 0 | routeLogForm.setShowFuture(true); |
249 | 0 | if (StringUtils.isNotBlank(routingForm.getBackUrl())) { |
250 | 0 | routeLogForm.setReturnUrlLocation(routingForm.getBackUrl()); |
251 | |
} |
252 | 0 | LOG.debug("Value of getDisplayCloseButton " + routingForm.getShowCloseButton()); |
253 | 0 | LOG.debug("Value of isDisplayCloseButton " + routingForm.isDisplayCloseButton()); |
254 | 0 | routeLogForm.setShowCloseButton(routingForm.isDisplayCloseButton()); |
255 | 0 | request.setAttribute("routeHeader", routeHeader); |
256 | 0 | new RouteLogAction().populateRouteLogFormActionRequests(routeLogForm, routeHeader); |
257 | 0 | request.setAttribute("KualiForm", routeLogForm); |
258 | |
|
259 | |
|
260 | |
|
261 | 0 | return mapping.findForward("routeLog"); |
262 | |
} |
263 | |
|
264 | 0 | private class RouteReportRuleTemplateContainer { |
265 | 0 | public RuleTemplate ruleTemplate = null; |
266 | 0 | public RouteNode routeNode = null; |
267 | 0 | public RouteReportRuleTemplateContainer(RuleTemplate template, RouteNode node) { |
268 | 0 | this.ruleTemplate = template; |
269 | 0 | this.routeNode = node; |
270 | 0 | } |
271 | |
} |
272 | |
|
273 | |
public long populateActionRequestsWithRouteLevelInformationAndIterateMagicCounter(RouteNode routeLevel, List actionRequests, long magicCounter) { |
274 | |
|
275 | 0 | for (Iterator iter = actionRequests.iterator(); iter.hasNext();) { |
276 | 0 | ActionRequestValue actionRequest = (ActionRequestValue) iter.next(); |
277 | 0 | populateActionRequestsWithRouteLevelInformationAndIterateMagicCounter(routeLevel, actionRequest.getChildrenRequests(), magicCounter); |
278 | 0 | actionRequest.setStatus(KEWConstants.ACTION_REQUEST_INITIALIZED); |
279 | |
|
280 | 0 | RouteNodeInstance routeNode = new RouteNodeInstance(); |
281 | 0 | routeNode.setRouteNode(routeLevel); |
282 | 0 | actionRequest.setNodeInstance(routeNode); |
283 | 0 | actionRequest.setRouteLevel(new Integer(0)); |
284 | 0 | magicCounter++; |
285 | 0 | actionRequest.setActionRequestId(new Long(magicCounter)); |
286 | 0 | } |
287 | 0 | return magicCounter; |
288 | |
} |
289 | |
|
290 | |
@Override |
291 | |
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
292 | 0 | return mapping.findForward("basic"); |
293 | |
} |
294 | |
|
295 | |
private ActionMessages initiateForm(HttpServletRequest request, ActionForm form) throws Exception { |
296 | 0 | RoutingReportForm routingReportForm = (RoutingReportForm) form; |
297 | 0 | if (routingReportForm.getReportType() == null) { |
298 | |
|
299 | 0 | if ( (!org.apache.commons.lang.StringUtils.isEmpty(routingReportForm.getDocumentTypeParam())) || |
300 | |
(!org.apache.commons.lang.StringUtils.isEmpty(routingReportForm.getInitiatorPrincipalId())) || |
301 | |
(!org.apache.commons.lang.StringUtils.isEmpty(routingReportForm.getDocumentContent())) ) { |
302 | |
|
303 | 0 | routingReportForm.setReportType(DOC_TYPE_REPORTING); |
304 | |
} else { |
305 | |
|
306 | 0 | routingReportForm.setReportType(TEMPLATE_REPORTING); |
307 | |
} |
308 | |
} |
309 | |
|
310 | 0 | if (routingReportForm.getReportType().equals(DOC_TYPE_REPORTING)) { |
311 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(routingReportForm.getDocumentTypeParam())) { |
312 | 0 | throw new RuntimeException("Document Type was not given"); |
313 | |
} else { |
314 | 0 | DocumentType docType = getDocumentTypeService().findByName(routingReportForm.getDocumentTypeParam()); |
315 | 0 | if (docType == null) { |
316 | 0 | throw new RuntimeException("Document Type is invalid"); |
317 | |
} |
318 | |
} |
319 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(routingReportForm.getInitiatorPrincipalId())) { |
320 | 0 | throw new RuntimeException("Initiator Principal ID was not given"); |
321 | |
} else { |
322 | 0 | KEWServiceLocator.getIdentityHelperService().getPrincipal(routingReportForm.getInitiatorPrincipalId()); |
323 | |
} |
324 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(routingReportForm.getDocumentContent())) { |
325 | 0 | throw new RuntimeException("Document Content was not given"); |
326 | |
} |
327 | |
|
328 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(routingReportForm.getDocumentType())) { |
329 | 0 | DocumentType docType = getDocumentTypeService().findByName(routingReportForm.getDocumentType()); |
330 | 0 | if (docType == null) { |
331 | 0 | throw new RuntimeException("Document Type is missing or invalid"); |
332 | |
} |
333 | 0 | routingReportForm.getRuleTemplateAttributes().clear(); |
334 | 0 | List routeNodes = KEWServiceLocator.getRouteNodeService().getFlattenedNodes(docType, true); |
335 | 0 | for (Iterator iter = routeNodes.iterator(); iter.hasNext();) { |
336 | 0 | RouteNode routeNode = (RouteNode) iter.next(); |
337 | 0 | if (routeNode.isFlexRM()) { |
338 | 0 | RuleTemplate ruleTemplate = getRuleTemplateService().findByRuleTemplateName(routeNode.getRouteMethodName()); |
339 | 0 | if (ruleTemplate != null) { |
340 | 0 | loadRuleTemplateOnForm(ruleTemplate, routingReportForm, request, false); |
341 | 0 | if (ruleTemplate.getDelegationTemplate() != null) { |
342 | 0 | loadRuleTemplateOnForm(ruleTemplate.getDelegationTemplate(), routingReportForm, request, true); |
343 | |
} |
344 | |
} |
345 | |
} |
346 | 0 | } |
347 | 0 | } |
348 | |
|
349 | 0 | } else if (routingReportForm.getReportType().equals(TEMPLATE_REPORTING)) { |
350 | 0 | routingReportForm.setRuleTemplates(getRuleTemplateService().findAll()); |
351 | 0 | if (routingReportForm.getRuleTemplateId() != null) { |
352 | 0 | RuleTemplate ruleTemplate = getRuleTemplateService().findByRuleTemplateId(routingReportForm.getRuleTemplateId()); |
353 | 0 | routingReportForm.getRuleTemplateAttributes().clear(); |
354 | 0 | loadRuleTemplateOnForm(ruleTemplate, routingReportForm, request, false); |
355 | 0 | if (ruleTemplate.getDelegationTemplate() != null) { |
356 | 0 | loadRuleTemplateOnForm(ruleTemplate.getDelegationTemplate(), routingReportForm, request, true); |
357 | |
} |
358 | |
} |
359 | |
} |
360 | 0 | return null; |
361 | |
} |
362 | |
|
363 | |
private void loadRuleTemplateOnForm(RuleTemplate ruleTemplate, RoutingReportForm routingReportForm, HttpServletRequest request, boolean isDelegate) { |
364 | |
|
365 | 0 | Map fieldValues = new HashMap(); |
366 | |
|
367 | 0 | List ruleTemplateAttributes = ruleTemplate.getActiveRuleTemplateAttributes(); |
368 | 0 | Collections.sort(ruleTemplateAttributes); |
369 | |
|
370 | 0 | List rows = new ArrayList(); |
371 | 0 | for (Iterator iter = ruleTemplateAttributes.iterator(); iter.hasNext();) { |
372 | 0 | RuleTemplateAttribute ruleTemplateAttribute = (RuleTemplateAttribute) iter.next(); |
373 | 0 | if (!ruleTemplateAttribute.isWorkflowAttribute()) { |
374 | 0 | continue; |
375 | |
} |
376 | 0 | WorkflowAttribute workflowAttribute = ruleTemplateAttribute.getWorkflowAttribute(); |
377 | |
|
378 | 0 | RuleAttribute ruleAttribute = ruleTemplateAttribute.getRuleAttribute(); |
379 | 0 | if (ruleAttribute.getType().equals(KEWConstants.RULE_XML_ATTRIBUTE_TYPE)) { |
380 | 0 | ((GenericXMLRuleAttribute) workflowAttribute).setRuleAttribute(ruleAttribute); |
381 | |
} |
382 | 0 | for (Object element : workflowAttribute.getRoutingDataRows()) { |
383 | 0 | Row row = (Row) element; |
384 | |
|
385 | 0 | List fields = new ArrayList(); |
386 | 0 | for (Object element2 : row.getFields()) { |
387 | 0 | Field field = (Field) element2; |
388 | 0 | if (request.getParameter(field.getPropertyName()) != null) { |
389 | 0 | field.setPropertyValue(request.getParameter(field.getPropertyName())); |
390 | 0 | } else if (routingReportForm.getFields() != null && !routingReportForm.getFields().isEmpty()) { |
391 | 0 | field.setPropertyValue((String) routingReportForm.getFields().get(field.getPropertyName())); |
392 | |
} |
393 | 0 | fields.add(field); |
394 | 0 | fieldValues.put(field.getPropertyName(), field.getPropertyValue()); |
395 | 0 | } |
396 | 0 | } |
397 | |
|
398 | 0 | workflowAttribute.validateRuleData(fieldValues); |
399 | 0 | List<Row> rdRows = workflowAttribute.getRoutingDataRows(); |
400 | 0 | for (Row row : rdRows) |
401 | |
{ |
402 | 0 | List fields = new ArrayList(); |
403 | 0 | List<Field> rowFields = row.getFields(); |
404 | 0 | for (Field field : rowFields ) |
405 | |
{ |
406 | 0 | if (request.getParameter(field.getPropertyName()) != null) { |
407 | 0 | field.setPropertyValue(request.getParameter(field.getPropertyName())); |
408 | 0 | } else if (routingReportForm.getFields() != null && !routingReportForm.getFields().isEmpty()) { |
409 | 0 | field.setPropertyValue((String) routingReportForm.getFields().get(field.getPropertyName())); |
410 | |
} |
411 | 0 | fields.add(field); |
412 | 0 | fieldValues.put(field.getPropertyName(), field.getPropertyValue()); |
413 | |
} |
414 | 0 | row.setFields(fields); |
415 | 0 | rows.add(row); |
416 | |
|
417 | 0 | } |
418 | 0 | } |
419 | |
|
420 | 0 | routingReportForm.getFields().putAll(fieldValues); |
421 | 0 | routingReportForm.getRuleTemplateAttributes().addAll(rows); |
422 | 0 | routingReportForm.setShowFields(true); |
423 | 0 | routingReportForm.setShowViewResults(true); |
424 | 0 | } |
425 | |
|
426 | |
public ActionForward loadTemplate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
427 | 0 | RoutingReportForm routingReportForm = (RoutingReportForm) form; |
428 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(routingReportForm.getDateRef())) { |
429 | 0 | SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); |
430 | 0 | routingReportForm.setEffectiveHour("5"); |
431 | 0 | routingReportForm.setEffectiveMinute("0"); |
432 | 0 | routingReportForm.setAmPm("1"); |
433 | 0 | routingReportForm.setDateRef(sdf.format(new Date())); |
434 | |
} |
435 | 0 | return mapping.findForward("basic"); |
436 | |
} |
437 | |
|
438 | |
private RuleTemplateService getRuleTemplateService() { |
439 | 0 | return (RuleTemplateService) KEWServiceLocator.getService(KEWServiceLocator.RULE_TEMPLATE_SERVICE); |
440 | |
} |
441 | |
|
442 | |
private DocumentTypeService getDocumentTypeService() { |
443 | 0 | return (DocumentTypeService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE); |
444 | |
} |
445 | |
|
446 | |
private UserSession getUserSession(HttpServletRequest request) { |
447 | 0 | return GlobalVariables.getUserSession(); |
448 | |
} |
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | |
} |