1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.dto; |
18 | |
|
19 | |
import org.apache.commons.lang.ArrayUtils; |
20 | |
import org.apache.commons.lang.StringUtils; |
21 | |
import org.apache.log4j.Logger; |
22 | |
import org.kuali.rice.core.api.exception.RiceRuntimeException; |
23 | |
import org.kuali.rice.core.api.reflect.DataDefinition; |
24 | |
import org.kuali.rice.core.api.reflect.ObjectDefinition; |
25 | |
import org.kuali.rice.core.api.reflect.PropertyDefinition; |
26 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
27 | |
import org.kuali.rice.core.framework.persistence.jdbc.sql.SQLUtils; |
28 | |
import org.kuali.rice.core.util.ConcreteKeyValue; |
29 | |
import org.kuali.rice.core.util.KeyValue; |
30 | |
import org.kuali.rice.core.util.xml.XmlHelper; |
31 | |
import org.kuali.rice.core.util.xml.XmlJotter; |
32 | |
import org.kuali.rice.kew.actionitem.ActionItem; |
33 | |
import org.kuali.rice.kew.actionrequest.ActionRequestFactory; |
34 | |
import org.kuali.rice.kew.actionrequest.ActionRequestValue; |
35 | |
import org.kuali.rice.kew.actionrequest.KimGroupRecipient; |
36 | |
import org.kuali.rice.kew.actionrequest.KimPrincipalRecipient; |
37 | |
import org.kuali.rice.kew.actionrequest.Recipient; |
38 | |
import org.kuali.rice.kew.actions.ValidActions; |
39 | |
import org.kuali.rice.kew.actiontaken.ActionTakenValue; |
40 | |
import org.kuali.rice.kew.api.WorkflowRuntimeException; |
41 | |
import org.kuali.rice.kew.api.action.ActionRequest; |
42 | |
import org.kuali.rice.kew.api.action.ActionTaken; |
43 | |
import org.kuali.rice.kew.api.action.AdHocRevoke; |
44 | |
import org.kuali.rice.kew.api.action.MovePoint; |
45 | |
import org.kuali.rice.kew.api.document.DocumentContentUpdate; |
46 | |
import org.kuali.rice.kew.api.document.DocumentDetail; |
47 | |
import org.kuali.rice.kew.api.document.InvalidDocumentContentException; |
48 | |
import org.kuali.rice.kew.api.document.WorkflowAttributeDefinition; |
49 | |
import org.kuali.rice.kew.definition.AttributeDefinition; |
50 | |
import org.kuali.rice.kew.docsearch.DocSearchCriteriaDTO; |
51 | |
import org.kuali.rice.kew.docsearch.DocSearchUtils; |
52 | |
import org.kuali.rice.kew.docsearch.DocumentSearchResult; |
53 | |
import org.kuali.rice.kew.docsearch.DocumentSearchResultComponents; |
54 | |
import org.kuali.rice.kew.docsearch.SearchableAttribute; |
55 | |
import org.kuali.rice.kew.docsearch.web.SearchAttributeFormContainer; |
56 | |
import org.kuali.rice.kew.docsearch.xml.GenericXMLSearchableAttribute; |
57 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
58 | |
import org.kuali.rice.kew.documentlink.DocumentLink; |
59 | |
import org.kuali.rice.kew.engine.node.Branch; |
60 | |
import org.kuali.rice.kew.engine.node.BranchState; |
61 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
62 | |
import org.kuali.rice.kew.engine.node.RouteNodeInstance; |
63 | |
import org.kuali.rice.kew.engine.node.State; |
64 | |
import org.kuali.rice.kew.engine.simulation.SimulationActionToTake; |
65 | |
import org.kuali.rice.kew.engine.simulation.SimulationCriteria; |
66 | |
import org.kuali.rice.kew.exception.WorkflowException; |
67 | |
import org.kuali.rice.kew.notes.Note; |
68 | |
import org.kuali.rice.kew.notes.service.NoteService; |
69 | |
import org.kuali.rice.kew.postprocessor.ActionTakenEvent; |
70 | |
import org.kuali.rice.kew.postprocessor.AfterProcessEvent; |
71 | |
import org.kuali.rice.kew.postprocessor.BeforeProcessEvent; |
72 | |
import org.kuali.rice.kew.postprocessor.DeleteEvent; |
73 | |
import org.kuali.rice.kew.postprocessor.DocumentLockingEvent; |
74 | |
import org.kuali.rice.kew.postprocessor.DocumentRouteLevelChange; |
75 | |
import org.kuali.rice.kew.postprocessor.DocumentRouteStatusChange; |
76 | |
import org.kuali.rice.kew.routeheader.DocumentContent; |
77 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
78 | |
import org.kuali.rice.kew.routeheader.DocumentStatusTransition; |
79 | |
import org.kuali.rice.kew.routeheader.StandardDocumentContent; |
80 | |
import org.kuali.rice.kew.rule.RuleBaseValues; |
81 | |
import org.kuali.rice.kew.rule.RuleDelegation; |
82 | |
import org.kuali.rice.kew.rule.RuleExtension; |
83 | |
import org.kuali.rice.kew.rule.RuleExtensionValue; |
84 | |
import org.kuali.rice.kew.rule.RuleResponsibility; |
85 | |
import org.kuali.rice.kew.rule.WorkflowAttribute; |
86 | |
import org.kuali.rice.kew.rule.WorkflowAttributeValidationError; |
87 | |
import org.kuali.rice.kew.rule.WorkflowAttributeXmlValidator; |
88 | |
import org.kuali.rice.kew.rule.bo.RuleAttribute; |
89 | |
import org.kuali.rice.kew.rule.xmlrouting.GenericXMLRuleAttribute; |
90 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
91 | |
import org.kuali.rice.kew.user.RoleRecipient; |
92 | |
import org.kuali.rice.kew.util.KEWConstants; |
93 | |
import org.kuali.rice.kew.util.ResponsibleParty; |
94 | |
import org.kuali.rice.kew.web.KeyValueSort; |
95 | |
import org.kuali.rice.kim.api.group.Group; |
96 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
97 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
98 | |
import org.kuali.rice.kim.bo.Person; |
99 | |
import org.w3c.dom.Document; |
100 | |
import org.w3c.dom.Element; |
101 | |
import org.w3c.dom.NodeList; |
102 | |
import org.xml.sax.SAXException; |
103 | |
|
104 | |
import javax.xml.parsers.DocumentBuilder; |
105 | |
import javax.xml.parsers.DocumentBuilderFactory; |
106 | |
import javax.xml.parsers.ParserConfigurationException; |
107 | |
import javax.xml.transform.TransformerException; |
108 | |
import java.io.IOException; |
109 | |
import java.sql.Timestamp; |
110 | |
import java.util.ArrayList; |
111 | |
import java.util.Arrays; |
112 | |
import java.util.Collection; |
113 | |
import java.util.Date; |
114 | |
import java.util.HashMap; |
115 | |
import java.util.HashSet; |
116 | |
import java.util.Iterator; |
117 | |
import java.util.List; |
118 | |
import java.util.Map; |
119 | |
import java.util.Set; |
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | 0 | public class DTOConverter { |
128 | 0 | private static final Logger LOG = Logger.getLogger(DTOConverter.class); |
129 | |
|
130 | |
public static RouteHeaderDTO convertRouteHeader(DocumentRouteHeaderValue routeHeader, String principalId) throws WorkflowException { |
131 | 0 | RouteHeaderDTO routeHeaderVO = new RouteHeaderDTO(); |
132 | 0 | if (routeHeader == null) { |
133 | 0 | return null; |
134 | |
} |
135 | 0 | populateRouteHeaderVO(routeHeaderVO, routeHeader); |
136 | |
|
137 | 0 | if (principalId != null) { |
138 | 0 | routeHeaderVO.setUserBlanketApprover(false); |
139 | 0 | if (routeHeader.getDocumentType() != null) { |
140 | 0 | boolean isBlanketApprover = KEWServiceLocator.getDocumentTypePermissionService().canBlanketApprove(principalId, routeHeader.getDocumentType(), routeHeader.getDocRouteStatus(), routeHeader.getInitiatorWorkflowId()); |
141 | 0 | routeHeaderVO.setUserBlanketApprover(isBlanketApprover); |
142 | |
} |
143 | 0 | Map<String, String> actionsRequested = KEWServiceLocator.getActionRequestService().getActionsRequested(routeHeader, principalId, true); |
144 | 0 | for (String actionRequestCode : actionsRequested.keySet()) { |
145 | 0 | if (KEWConstants.ACTION_REQUEST_FYI_REQ.equals(actionRequestCode)) { |
146 | 0 | routeHeaderVO.setFyiRequested(Boolean.parseBoolean(actionsRequested.get(actionRequestCode))); |
147 | |
} |
148 | 0 | else if (KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ.equals(actionRequestCode)) { |
149 | 0 | routeHeaderVO.setAckRequested(Boolean.parseBoolean(actionsRequested.get(actionRequestCode))); |
150 | |
} |
151 | 0 | else if (KEWConstants.ACTION_REQUEST_APPROVE_REQ.equals(actionRequestCode)) { |
152 | 0 | routeHeaderVO.setApproveRequested(Boolean.parseBoolean(actionsRequested.get(actionRequestCode))); |
153 | |
} |
154 | |
else { |
155 | 0 | routeHeaderVO.setCompleteRequested(Boolean.parseBoolean(actionsRequested.get(actionRequestCode))); |
156 | |
} |
157 | |
} |
158 | |
|
159 | 0 | routeHeaderVO.setNotesToDelete(null); |
160 | 0 | routeHeaderVO.setNotes(convertNotesArrayListToNoteVOArray(routeHeader.getNotes())); |
161 | |
} |
162 | |
|
163 | |
|
164 | 0 | if (principalId != null) { |
165 | 0 | Principal principal = KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId); |
166 | 0 | routeHeaderVO.setValidActions(convertValidActions(KEWServiceLocator.getActionRegistry().getValidActions(principal, routeHeader))); |
167 | |
} |
168 | 0 | return routeHeaderVO; |
169 | |
} |
170 | |
|
171 | |
public static ValidActionsDTO convertValidActions(ValidActions validActions) { |
172 | 0 | ValidActionsDTO validActionsVO = new ValidActionsDTO(); |
173 | 0 | for (String actionTakenCode : validActions.getActionTakenCodes()) { |
174 | 0 | validActionsVO.addValidActionsAllowed(actionTakenCode); |
175 | |
} |
176 | 0 | return validActionsVO; |
177 | |
} |
178 | |
|
179 | |
private static void populateRouteHeaderVO(RouteHeaderDTO routeHeaderVO, DocumentRouteHeaderValue routeHeader) throws WorkflowException { |
180 | 0 | routeHeaderVO.setDocumentId(routeHeader.getDocumentId()); |
181 | 0 | routeHeaderVO.setAppDocId(routeHeader.getAppDocId()); |
182 | 0 | routeHeaderVO.setDateApproved(SQLUtils.convertTimestamp(routeHeader.getApprovedDate())); |
183 | 0 | routeHeaderVO.setDateCreated(SQLUtils.convertTimestamp(routeHeader.getCreateDate())); |
184 | 0 | routeHeaderVO.setDateFinalized(SQLUtils.convertTimestamp(routeHeader.getFinalizedDate())); |
185 | 0 | routeHeaderVO.setDateLastModified(SQLUtils.convertTimestamp(routeHeader.getStatusModDate())); |
186 | 0 | routeHeaderVO.setAppDocStatus(routeHeader.getAppDocStatus()); |
187 | 0 | routeHeaderVO.setAppDocStatusDate(SQLUtils.convertTimestamp(routeHeader.getAppDocStatusDate())); |
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | 0 | routeHeaderVO.setDocRouteLevel(routeHeader.getDocRouteLevel()); |
202 | 0 | routeHeaderVO.setCurrentRouteNodeNames(routeHeader.getCurrentRouteLevelName()); |
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | 0 | routeHeaderVO.setDocRouteStatus(routeHeader.getDocRouteStatus()); |
213 | 0 | routeHeaderVO.setDocTitle(routeHeader.getDocTitle()); |
214 | 0 | if (routeHeader.getDocumentType() != null) { |
215 | 0 | routeHeaderVO.setDocTypeName(routeHeader.getDocumentType().getName()); |
216 | 0 | routeHeaderVO.setDocumentUrl(routeHeader.getDocumentType().getDocHandlerUrl()); |
217 | 0 | routeHeaderVO.setDocTypeId(routeHeader.getDocumentTypeId()); |
218 | |
} |
219 | 0 | routeHeaderVO.setDocVersion(routeHeader.getDocVersion()); |
220 | 0 | routeHeaderVO.setInitiatorPrincipalId(routeHeader.getInitiatorWorkflowId()); |
221 | 0 | routeHeaderVO.setRoutedByPrincipalId(routeHeader.getRoutedByUserWorkflowId()); |
222 | |
|
223 | |
|
224 | |
|
225 | 0 | Branch routeNodeInstanceBranch = routeHeader.getRootBranch(); |
226 | |
|
227 | |
|
228 | 0 | if (routeNodeInstanceBranch != null) { |
229 | 0 | List listOfBranchStates = routeNodeInstanceBranch.getBranchState(); |
230 | 0 | Iterator it = listOfBranchStates.iterator(); |
231 | 0 | while (it.hasNext()) { |
232 | 0 | BranchState bs = (BranchState) it.next(); |
233 | 0 | if (bs.getKey() != null && bs.getKey().startsWith(BranchState.VARIABLE_PREFIX)) { |
234 | 0 | LOG.debug("Setting branch state variable on vo: " + bs.getKey() + "=" + bs.getValue()); |
235 | 0 | routeHeaderVO.setVariable(bs.getKey().substring(BranchState.VARIABLE_PREFIX.length()), bs.getValue()); |
236 | |
} |
237 | 0 | } |
238 | |
} |
239 | 0 | } |
240 | |
|
241 | |
public static DocumentRouteHeaderValue convertRouteHeaderVO(RouteHeaderDTO routeHeaderVO) throws WorkflowException { |
242 | 0 | DocumentRouteHeaderValue routeHeader = new DocumentRouteHeaderValue(); |
243 | 0 | routeHeader.setAppDocId(routeHeaderVO.getAppDocId()); |
244 | 0 | routeHeader.setApprovedDate(SQLUtils.convertCalendar(routeHeaderVO.getDateApproved())); |
245 | 0 | routeHeader.setCreateDate(SQLUtils.convertCalendar(routeHeaderVO.getDateCreated())); |
246 | 0 | if (StringUtils.isEmpty(routeHeader.getDocContent())) { |
247 | 0 | routeHeader.setDocContent(KEWConstants.DEFAULT_DOCUMENT_CONTENT); |
248 | |
} |
249 | 0 | routeHeader.setDocRouteLevel(routeHeaderVO.getDocRouteLevel()); |
250 | 0 | routeHeader.setDocRouteStatus(routeHeaderVO.getDocRouteStatus()); |
251 | 0 | routeHeader.setDocTitle(routeHeaderVO.getDocTitle()); |
252 | 0 | if (routeHeaderVO.getDocTypeName() != null) { |
253 | 0 | DocumentType documentType = KEWServiceLocator.getDocumentTypeService().findByName(routeHeaderVO.getDocTypeName()); |
254 | 0 | if (documentType == null) { |
255 | 0 | throw new RiceRuntimeException("Could not locate the given document type name: " + routeHeaderVO.getDocTypeName()); |
256 | |
} |
257 | 0 | routeHeader.setDocumentTypeId(documentType.getDocumentTypeId()); |
258 | |
} |
259 | 0 | routeHeader.setDocVersion(routeHeaderVO.getDocVersion()); |
260 | 0 | routeHeader.setFinalizedDate(SQLUtils.convertCalendar(routeHeaderVO.getDateFinalized())); |
261 | 0 | routeHeader.setInitiatorWorkflowId(routeHeaderVO.getInitiatorPrincipalId()); |
262 | 0 | routeHeader.setRoutedByUserWorkflowId(routeHeaderVO.getRoutedByPrincipalId()); |
263 | 0 | routeHeader.setDocumentId(routeHeaderVO.getDocumentId()); |
264 | 0 | routeHeader.setStatusModDate(SQLUtils.convertCalendar(routeHeaderVO.getDateLastModified())); |
265 | 0 | routeHeader.setAppDocStatus(routeHeaderVO.getAppDocStatus()); |
266 | 0 | routeHeader.setAppDocStatusDate(SQLUtils.convertCalendar(routeHeaderVO.getAppDocStatusDate())); |
267 | |
|
268 | |
|
269 | |
|
270 | 0 | List<KeyValue> variables = routeHeaderVO.getVariables(); |
271 | 0 | if( variables != null && !variables.isEmpty()){ |
272 | 0 | for(KeyValue kvp : variables){ |
273 | 0 | routeHeader.setVariable(kvp.getKey(), kvp.getValue()); |
274 | |
} |
275 | |
} |
276 | |
|
277 | 0 | return routeHeader; |
278 | |
} |
279 | |
|
280 | |
public static ActionItemDTO convertActionItem(ActionItem actionItem) { |
281 | 0 | ActionItemDTO actionItemVO = new ActionItemDTO(); |
282 | 0 | actionItemVO.setActionItemId(actionItem.getActionItemId()); |
283 | 0 | actionItemVO.setActionItemIndex(actionItem.getActionItemIndex()); |
284 | 0 | actionItemVO.setActionRequestCd(actionItem.getActionRequestCd()); |
285 | 0 | actionItemVO.setActionRequestId(actionItem.getActionRequestId()); |
286 | 0 | actionItemVO.setActionToTake(actionItem.getActionToTake()); |
287 | 0 | actionItemVO.setDateAssigned(actionItem.getDateAssigned()); |
288 | 0 | actionItemVO.setDateAssignedString(actionItem.getDateAssignedString()); |
289 | 0 | actionItemVO.setDelegationType(actionItem.getDelegationType()); |
290 | 0 | actionItemVO.setDelegatorPrincipalId(actionItem.getDelegatorWorkflowId()); |
291 | 0 | actionItemVO.setDelegatorGroupId(actionItem.getDelegatorGroupId()); |
292 | 0 | actionItemVO.setDocHandlerURL(actionItem.getDocHandlerURL()); |
293 | 0 | actionItemVO.setDocLabel(actionItem.getDocLabel()); |
294 | 0 | actionItemVO.setDocName(actionItem.getDocName()); |
295 | 0 | actionItemVO.setDocTitle(actionItem.getDocTitle()); |
296 | 0 | actionItemVO.setResponsibilityId(actionItem.getResponsibilityId()); |
297 | 0 | actionItemVO.setRoleName(actionItem.getRoleName()); |
298 | 0 | actionItemVO.setDocumentId(actionItem.getDocumentId()); |
299 | 0 | actionItemVO.setPrincipalId(actionItem.getPrincipalId()); |
300 | 0 | actionItemVO.setGroupId(actionItem.getGroupId()); |
301 | 0 | return actionItemVO; |
302 | |
} |
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
public static String buildUpdatedDocumentContent(DocumentContentDTO documentContentVO) throws WorkflowException { |
310 | 0 | DocumentType documentType = null; |
311 | 0 | String documentContent = KEWConstants.DEFAULT_DOCUMENT_CONTENT; |
312 | |
try { |
313 | |
|
314 | 0 | String existingDocContent = KEWConstants.DEFAULT_DOCUMENT_CONTENT; |
315 | 0 | if (documentContentVO.getDocumentId() != null) { |
316 | 0 | DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentContentVO.getDocumentId()); |
317 | 0 | documentType = document.getDocumentType(); |
318 | 0 | existingDocContent = document.getDocContent(); |
319 | |
} |
320 | 0 | StandardDocumentContent standardDocContent = new StandardDocumentContent(existingDocContent); |
321 | 0 | DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
322 | 0 | Document document = builder.newDocument(); |
323 | 0 | Element root = document.createElement(KEWConstants.DOCUMENT_CONTENT_ELEMENT); |
324 | 0 | document.appendChild(root); |
325 | 0 | Element applicationContentElement = standardDocContent.getApplicationContent(); |
326 | 0 | if (documentContentVO.getApplicationContent() != null) { |
327 | |
|
328 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(documentContentVO.getApplicationContent())) { |
329 | 0 | applicationContentElement = document.createElement(KEWConstants.APPLICATION_CONTENT_ELEMENT); |
330 | 0 | XmlHelper.appendXml(applicationContentElement, documentContentVO.getApplicationContent()); |
331 | |
} else { |
332 | |
|
333 | 0 | applicationContentElement = null; |
334 | |
} |
335 | |
} |
336 | 0 | Element attributeContentElement = createDocumentContentSection(document, standardDocContent.getAttributeContent(), documentContentVO.getAttributeDefinitions(), documentContentVO.getAttributeContent(), KEWConstants.ATTRIBUTE_CONTENT_ELEMENT, documentType); |
337 | 0 | Element searchableContentElement = createDocumentContentSection(document, standardDocContent.getSearchableContent(), documentContentVO.getSearchableDefinitions(), documentContentVO.getSearchableContent(), KEWConstants.SEARCHABLE_CONTENT_ELEMENT, documentType); |
338 | 0 | if (applicationContentElement != null) { |
339 | 0 | root.appendChild(applicationContentElement); |
340 | |
} |
341 | 0 | if (attributeContentElement != null) { |
342 | 0 | root.appendChild(attributeContentElement); |
343 | |
} |
344 | 0 | if (searchableContentElement != null) { |
345 | 0 | root.appendChild(searchableContentElement); |
346 | |
} |
347 | 0 | documentContent = XmlJotter.jotNode(document); |
348 | 0 | } catch (Exception e) { |
349 | 0 | handleException("Error parsing document content.", e); |
350 | 0 | } |
351 | 0 | return documentContent; |
352 | |
} |
353 | |
|
354 | |
private static Element createDocumentContentSection(Document document, Element existingAttributeElement, WorkflowAttributeDefinitionDTO[] definitions, String content, String elementName, DocumentType documentType) throws Exception { |
355 | 0 | Element contentSectionElement = existingAttributeElement; |
356 | |
|
357 | 0 | if (content != null) { |
358 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(content)) { |
359 | 0 | contentSectionElement = document.createElement(elementName); |
360 | |
|
361 | |
|
362 | 0 | Element incomingAttributeElement = XmlHelper.readXml(content).getDocumentElement(); |
363 | 0 | NodeList children = incomingAttributeElement.getChildNodes(); |
364 | 0 | for (int index = 0; index < children.getLength(); index++) { |
365 | 0 | contentSectionElement.appendChild(document.importNode(children.item(index), true)); |
366 | |
} |
367 | 0 | } else { |
368 | 0 | contentSectionElement = null; |
369 | |
} |
370 | |
} |
371 | |
|
372 | 0 | if (!ArrayUtils.isEmpty(definitions)) { |
373 | 0 | String errorMessage = ""; |
374 | 0 | boolean inError = false; |
375 | 0 | if (contentSectionElement == null) { |
376 | 0 | contentSectionElement = document.createElement(elementName); |
377 | |
} |
378 | 0 | for (WorkflowAttributeDefinitionDTO definitionVO : definitions) { |
379 | 0 | AttributeDefinition definition = convertWorkflowAttributeDefinitionVO(definitionVO, documentType); |
380 | 0 | RuleAttribute ruleAttribute = definition.getRuleAttribute(); |
381 | 0 | Object attribute = GlobalResourceLoader.getResourceLoader().getObject(definition.getObjectDefinition()); |
382 | 0 | boolean propertiesAsMap = false; |
383 | 0 | if (KEWConstants.RULE_XML_ATTRIBUTE_TYPE.equals(ruleAttribute.getType())) { |
384 | 0 | ((GenericXMLRuleAttribute) attribute).setRuleAttribute(ruleAttribute); |
385 | 0 | propertiesAsMap = true; |
386 | 0 | } else if (KEWConstants.SEARCHABLE_XML_ATTRIBUTE_TYPE.equals(ruleAttribute.getType())) { |
387 | 0 | ((GenericXMLSearchableAttribute) attribute).setRuleAttribute(ruleAttribute); |
388 | 0 | propertiesAsMap = true; |
389 | |
} |
390 | 0 | if (propertiesAsMap) { |
391 | 0 | for (PropertyDefinitionDTO propertyDefinitionVO : definitionVO.getProperties()) { |
392 | 0 | if (attribute instanceof GenericXMLRuleAttribute) { |
393 | 0 | ((GenericXMLRuleAttribute) attribute).getParamMap().put(propertyDefinitionVO.getName(), propertyDefinitionVO.getValue()); |
394 | 0 | } else if (attribute instanceof GenericXMLSearchableAttribute) { |
395 | 0 | ((GenericXMLSearchableAttribute) attribute).getParamMap().put(propertyDefinitionVO.getName(), propertyDefinitionVO.getValue()); |
396 | |
} |
397 | |
} |
398 | |
} |
399 | |
|
400 | |
|
401 | 0 | if (attribute instanceof WorkflowAttributeXmlValidator) { |
402 | 0 | List<WorkflowAttributeValidationError> errors = ((WorkflowAttributeXmlValidator) attribute).validateClientRoutingData(); |
403 | 0 | if (!errors.isEmpty()) { |
404 | 0 | inError = true; |
405 | 0 | errorMessage += "Error validating attribute " + definitionVO.getAttributeName() + " "; |
406 | 0 | for (WorkflowAttributeValidationError error : errors) { |
407 | 0 | errorMessage += error.getMessage() + " "; |
408 | |
} |
409 | |
} |
410 | |
} |
411 | |
|
412 | 0 | if (!inError) { |
413 | 0 | if (attribute instanceof WorkflowAttribute) { |
414 | 0 | String attributeDocContent = ((WorkflowAttribute) attribute).getDocContent(); |
415 | 0 | if (!StringUtils.isEmpty(attributeDocContent)) { |
416 | 0 | XmlHelper.appendXml(contentSectionElement, attributeDocContent); |
417 | |
} |
418 | 0 | } else if (attribute instanceof SearchableAttribute) { |
419 | 0 | String searcheAttributeContent = |
420 | |
((SearchableAttribute) attribute).getSearchContent(DocSearchUtils.getDocumentSearchContext("", documentType.getName(), "")); |
421 | 0 | if (!StringUtils.isEmpty(searcheAttributeContent)) { |
422 | 0 | XmlHelper.appendXml(contentSectionElement, searcheAttributeContent); |
423 | |
} |
424 | |
} |
425 | |
} |
426 | |
} |
427 | 0 | if (inError) { |
428 | 0 | throw new WorkflowRuntimeException(errorMessage); |
429 | |
} |
430 | |
|
431 | |
} |
432 | 0 | if (contentSectionElement != null) { |
433 | |
|
434 | |
|
435 | |
|
436 | 0 | contentSectionElement = (Element) document.importNode(contentSectionElement, true); |
437 | |
} |
438 | 0 | return contentSectionElement; |
439 | |
} |
440 | |
|
441 | |
|
442 | |
|
443 | |
|
444 | |
public static String buildUpdatedDocumentContent(String existingDocContent, DocumentContentUpdate documentContentUpdate, String documentTypeName) { |
445 | 0 | if (existingDocContent == null) { |
446 | 0 | existingDocContent = KEWConstants.DEFAULT_DOCUMENT_CONTENT; |
447 | |
} |
448 | 0 | String documentContent = KEWConstants.DEFAULT_DOCUMENT_CONTENT; |
449 | 0 | StandardDocumentContent standardDocContent = new StandardDocumentContent(existingDocContent); |
450 | |
try { |
451 | 0 | DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); |
452 | 0 | Document document = builder.newDocument(); |
453 | 0 | Element root = document.createElement(KEWConstants.DOCUMENT_CONTENT_ELEMENT); |
454 | 0 | document.appendChild(root); |
455 | 0 | Element applicationContentElement = standardDocContent.getApplicationContent(); |
456 | 0 | if (documentContentUpdate.getApplicationContent() != null) { |
457 | |
|
458 | 0 | if (!StringUtils.isEmpty(documentContentUpdate.getApplicationContent())) { |
459 | 0 | applicationContentElement = document.createElement(KEWConstants.APPLICATION_CONTENT_ELEMENT); |
460 | 0 | XmlHelper.appendXml(applicationContentElement, documentContentUpdate.getApplicationContent()); |
461 | |
} else { |
462 | |
|
463 | 0 | applicationContentElement = null; |
464 | |
} |
465 | |
} |
466 | 0 | Element attributeContentElement = createDocumentContentSection(document, standardDocContent.getAttributeContent(), documentContentUpdate.getAttributeDefinitions(), documentContentUpdate.getAttributeContent(), KEWConstants.ATTRIBUTE_CONTENT_ELEMENT, documentTypeName); |
467 | 0 | Element searchableContentElement = createDocumentContentSection(document, standardDocContent.getSearchableContent(), documentContentUpdate.getSearchableDefinitions(), documentContentUpdate.getSearchableContent(), KEWConstants.SEARCHABLE_CONTENT_ELEMENT, documentTypeName); |
468 | 0 | if (applicationContentElement != null) { |
469 | 0 | root.appendChild(applicationContentElement); |
470 | |
} |
471 | 0 | if (attributeContentElement != null) { |
472 | 0 | root.appendChild(attributeContentElement); |
473 | |
} |
474 | 0 | if (searchableContentElement != null) { |
475 | 0 | root.appendChild(searchableContentElement); |
476 | |
} |
477 | 0 | documentContent = XmlJotter.jotNode(document); |
478 | 0 | } catch (ParserConfigurationException e) { |
479 | 0 | throw new RiceRuntimeException("Failed to initialize XML parser.", e); |
480 | 0 | } catch (SAXException e) { |
481 | 0 | throw new InvalidDocumentContentException("Failed to parse XML.", e); |
482 | 0 | } catch (IOException e) { |
483 | 0 | throw new InvalidDocumentContentException("Failed to parse XML.", e); |
484 | 0 | } catch (TransformerException e) { |
485 | 0 | throw new InvalidDocumentContentException("Failed to parse XML.", e); |
486 | 0 | } |
487 | 0 | return documentContent; |
488 | |
} |
489 | |
|
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
|
497 | |
private static Element createDocumentContentSection(Document document, Element existingAttributeElement, List<WorkflowAttributeDefinition> definitions, String content, String elementName, String documentTypeName) throws TransformerException, SAXException, IOException, ParserConfigurationException { |
498 | 0 | Element contentSectionElement = existingAttributeElement; |
499 | |
|
500 | 0 | if (content != null) { |
501 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(content)) { |
502 | 0 | contentSectionElement = document.createElement(elementName); |
503 | |
|
504 | |
|
505 | 0 | Element incomingAttributeElement = XmlHelper.readXml(content).getDocumentElement(); |
506 | 0 | NodeList children = incomingAttributeElement.getChildNodes(); |
507 | 0 | for (int index = 0; index < children.getLength(); index++) { |
508 | 0 | contentSectionElement.appendChild(document.importNode(children.item(index), true)); |
509 | |
} |
510 | 0 | } else { |
511 | 0 | contentSectionElement = null; |
512 | |
} |
513 | |
} |
514 | |
|
515 | 0 | if (definitions != null && !definitions.isEmpty()) { |
516 | 0 | String errorMessage = ""; |
517 | 0 | boolean inError = false; |
518 | 0 | if (contentSectionElement == null) { |
519 | 0 | contentSectionElement = document.createElement(elementName); |
520 | |
} |
521 | 0 | for (WorkflowAttributeDefinition definitionVO : definitions) { |
522 | 0 | AttributeDefinition definition = convertWorkflowAttributeDefinition(definitionVO); |
523 | 0 | RuleAttribute ruleAttribute = definition.getRuleAttribute(); |
524 | 0 | Object attribute = GlobalResourceLoader.getResourceLoader().getObject(definition.getObjectDefinition()); |
525 | 0 | boolean propertiesAsMap = false; |
526 | 0 | if (KEWConstants.RULE_XML_ATTRIBUTE_TYPE.equals(ruleAttribute.getType())) { |
527 | 0 | ((GenericXMLRuleAttribute) attribute).setRuleAttribute(ruleAttribute); |
528 | 0 | propertiesAsMap = true; |
529 | 0 | } else if (KEWConstants.SEARCHABLE_XML_ATTRIBUTE_TYPE.equals(ruleAttribute.getType())) { |
530 | 0 | ((GenericXMLSearchableAttribute) attribute).setRuleAttribute(ruleAttribute); |
531 | 0 | propertiesAsMap = true; |
532 | |
} |
533 | 0 | if (propertiesAsMap) { |
534 | 0 | for (org.kuali.rice.kew.api.document.PropertyDefinition propertyDefinitionVO : definitionVO.getPropertyDefinitions()) { |
535 | 0 | if (attribute instanceof GenericXMLRuleAttribute) { |
536 | 0 | ((GenericXMLRuleAttribute) attribute).getParamMap().put(propertyDefinitionVO.getName(), propertyDefinitionVO.getValue()); |
537 | 0 | } else if (attribute instanceof GenericXMLSearchableAttribute) { |
538 | 0 | ((GenericXMLSearchableAttribute) attribute).getParamMap().put(propertyDefinitionVO.getName(), propertyDefinitionVO.getValue()); |
539 | |
} |
540 | |
} |
541 | |
} |
542 | |
|
543 | |
|
544 | 0 | if (attribute instanceof WorkflowAttributeXmlValidator) { |
545 | 0 | List<WorkflowAttributeValidationError> errors = ((WorkflowAttributeXmlValidator) attribute).validateClientRoutingData(); |
546 | 0 | if (!errors.isEmpty()) { |
547 | 0 | inError = true; |
548 | 0 | errorMessage += "Error validating attribute " + definitionVO.getAttributeName() + " "; |
549 | 0 | for (WorkflowAttributeValidationError error : errors) { |
550 | 0 | errorMessage += error.getMessage() + " "; |
551 | |
} |
552 | |
} |
553 | |
} |
554 | |
|
555 | 0 | if (!inError) { |
556 | 0 | if (attribute instanceof WorkflowAttribute) { |
557 | 0 | String attributeDocContent = ((WorkflowAttribute) attribute).getDocContent(); |
558 | 0 | if (!StringUtils.isEmpty(attributeDocContent)) { |
559 | 0 | XmlHelper.appendXml(contentSectionElement, attributeDocContent); |
560 | |
} |
561 | 0 | } else if (attribute instanceof SearchableAttribute) { |
562 | 0 | String searcheAttributeContent = |
563 | |
((SearchableAttribute) attribute).getSearchContent(DocSearchUtils.getDocumentSearchContext("", documentTypeName, "")); |
564 | 0 | if (!StringUtils.isEmpty(searcheAttributeContent)) { |
565 | 0 | XmlHelper.appendXml(contentSectionElement, searcheAttributeContent); |
566 | |
} |
567 | |
} |
568 | |
} |
569 | 0 | } |
570 | 0 | if (inError) { |
571 | 0 | throw new WorkflowRuntimeException(errorMessage); |
572 | |
} |
573 | |
|
574 | |
} |
575 | 0 | if (contentSectionElement != null) { |
576 | |
|
577 | |
|
578 | |
|
579 | 0 | contentSectionElement = (Element) document.importNode(contentSectionElement, true); |
580 | |
} |
581 | 0 | return contentSectionElement; |
582 | |
} |
583 | |
|
584 | |
|
585 | |
|
586 | |
|
587 | |
|
588 | |
public static AttributeDefinition convertWorkflowAttributeDefinition(WorkflowAttributeDefinition definition) { |
589 | 0 | if (definition == null) { |
590 | 0 | return null; |
591 | |
} |
592 | |
|
593 | 0 | RuleAttribute ruleAttribute = KEWServiceLocator.getRuleAttributeService().findByClassName(definition.getAttributeName()); |
594 | 0 | if (ruleAttribute == null) { |
595 | 0 | ruleAttribute = KEWServiceLocator.getRuleAttributeService().findByName(definition.getAttributeName()); |
596 | |
} |
597 | 0 | if (ruleAttribute == null) { |
598 | 0 | throw new WorkflowRuntimeException("Attribute " + definition.getAttributeName() + " not found"); |
599 | |
} |
600 | |
|
601 | 0 | ObjectDefinition objectDefinition = new ObjectDefinition(ruleAttribute.getClassName()); |
602 | 0 | if (definition.getParameters() != null) { |
603 | 0 | for (String parameter : definition.getParameters()) { |
604 | 0 | objectDefinition.addConstructorParameter(new DataDefinition(parameter, String.class)); |
605 | |
} |
606 | |
} |
607 | 0 | boolean propertiesAsMap = KEWConstants.RULE_XML_ATTRIBUTE_TYPE.equals(ruleAttribute.getType()) || KEWConstants.SEARCHABLE_XML_ATTRIBUTE_TYPE.equals(ruleAttribute.getType()); |
608 | 0 | if (!propertiesAsMap && definition.getPropertyDefinitions() != null) { |
609 | 0 | for (org.kuali.rice.kew.api.document.PropertyDefinition propertyDefinition : definition.getPropertyDefinitions()) { |
610 | 0 | objectDefinition.addProperty(new PropertyDefinition(propertyDefinition.getName(), new DataDefinition(propertyDefinition.getValue(), String.class))); |
611 | |
} |
612 | |
} |
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
|
622 | |
|
623 | |
|
624 | 0 | return new AttributeDefinition(ruleAttribute, objectDefinition); |
625 | |
} |
626 | |
|
627 | |
public static DocumentContentDTO convertDocumentContent(String documentContentValue, String documentId) throws WorkflowException { |
628 | 0 | if (documentContentValue == null) { |
629 | 0 | return null; |
630 | |
} |
631 | 0 | DocumentContentDTO documentContentVO = new DocumentContentDTO(); |
632 | |
|
633 | 0 | documentContentVO.setApplicationContent(""); |
634 | 0 | documentContentVO.setAttributeContent(""); |
635 | 0 | documentContentVO.setSearchableContent(""); |
636 | 0 | documentContentVO.setDocumentId(documentId); |
637 | |
try { |
638 | 0 | DocumentContent documentContent = new StandardDocumentContent(documentContentValue); |
639 | 0 | if (documentContent.getApplicationContent() != null) { |
640 | 0 | documentContentVO.setApplicationContent(XmlJotter.jotNode(documentContent.getApplicationContent())); |
641 | |
} |
642 | 0 | if (documentContent.getAttributeContent() != null) { |
643 | 0 | documentContentVO.setAttributeContent(XmlJotter.jotNode(documentContent.getAttributeContent())); |
644 | |
} |
645 | 0 | if (documentContent.getSearchableContent() != null) { |
646 | 0 | documentContentVO.setSearchableContent(XmlJotter.jotNode(documentContent.getSearchableContent())); |
647 | |
} |
648 | 0 | } catch (Exception e) { |
649 | 0 | handleException("Error parsing document content.", e); |
650 | 0 | } |
651 | 0 | return documentContentVO; |
652 | |
} |
653 | |
|
654 | |
public static ActionRequestDTO convertActionRequest(ActionRequestValue actionRequest) { |
655 | 0 | return convertActionRequest(actionRequest, true); |
656 | |
} |
657 | |
|
658 | |
protected static ActionRequestDTO convertActionRequest(ActionRequestValue actionRequest, boolean includeActionTaken) { |
659 | 0 | ActionRequestDTO actionRequestVO = new ActionRequestDTO(); |
660 | 0 | actionRequestVO.setActionRequested(actionRequest.getActionRequested()); |
661 | 0 | actionRequestVO.setActionRequestId(actionRequest.getActionRequestId()); |
662 | |
|
663 | 0 | if (includeActionTaken && (actionRequest.getActionTaken() != null)) { |
664 | 0 | actionRequestVO.setActionTakenId(actionRequest.getActionTakenId()); |
665 | 0 | actionRequestVO.setActionTaken(convertActionTaken(actionRequest.getActionTaken())); |
666 | |
} |
667 | |
|
668 | 0 | actionRequestVO.setAnnotation(actionRequest.getAnnotation()); |
669 | 0 | actionRequestVO.setDateCreated(SQLUtils.convertTimestamp(actionRequest.getCreateDate())); |
670 | 0 | actionRequestVO.setDocVersion(actionRequest.getDocVersion()); |
671 | 0 | actionRequestVO.setPrincipalId(actionRequest.getPrincipalId()); |
672 | 0 | actionRequestVO.setForceAction(actionRequest.getForceAction()); |
673 | 0 | actionRequestVO.setPriority(actionRequest.getPriority()); |
674 | 0 | actionRequestVO.setRecipientTypeCd(actionRequest.getRecipientTypeCd()); |
675 | 0 | actionRequestVO.setResponsibilityDesc(actionRequest.getResponsibilityDesc()); |
676 | 0 | actionRequestVO.setResponsibilityId(actionRequest.getResponsibilityId()); |
677 | 0 | actionRequestVO.setDocumentId(actionRequest.getDocumentId()); |
678 | 0 | actionRequestVO.setRouteLevel(actionRequest.getRouteLevel()); |
679 | 0 | actionRequestVO.setNodeName(actionRequest.getPotentialNodeName()); |
680 | 0 | actionRequestVO.setNodeInstanceId((actionRequest.getNodeInstance() == null ? null : actionRequest.getNodeInstance().getRouteNodeInstanceId())); |
681 | |
|
682 | 0 | actionRequestVO.setRoleName(actionRequest.getQualifiedRoleName()); |
683 | 0 | actionRequestVO.setQualifiedRoleName(actionRequest.getQualifiedRoleName()); |
684 | 0 | actionRequestVO.setQualifiedRoleNameLabel(actionRequest.getQualifiedRoleNameLabel()); |
685 | 0 | actionRequestVO.setStatus(actionRequest.getStatus()); |
686 | 0 | actionRequestVO.setGroupId(actionRequest.getGroupId()); |
687 | 0 | actionRequestVO.setDelegationType(actionRequest.getDelegationType()); |
688 | 0 | actionRequestVO.setParentActionRequestId(actionRequest.getParentActionRequestId()); |
689 | 0 | actionRequestVO.setRequestLabel(actionRequest.getRequestLabel()); |
690 | 0 | ActionRequestDTO[] childRequestVOs = new ActionRequestDTO[actionRequest.getChildrenRequests().size()]; |
691 | 0 | int index = 0; |
692 | 0 | for (ActionRequestValue childRequest : actionRequest.getChildrenRequests()) { |
693 | 0 | ActionRequestDTO childRequestVO = convertActionRequest(childRequest); |
694 | 0 | childRequestVOs[index++] = childRequestVO; |
695 | 0 | } |
696 | 0 | actionRequestVO.setChildrenRequests(childRequestVOs); |
697 | 0 | return actionRequestVO; |
698 | |
} |
699 | |
|
700 | |
public static ActionTakenDTO convertActionTakenWithActionRequests(ActionTakenValue actionTaken) { |
701 | 0 | return convertActionTaken(actionTaken, true); |
702 | |
} |
703 | |
|
704 | |
public static ActionTakenDTO convertActionTaken(ActionTakenValue actionTaken) { |
705 | 0 | return convertActionTaken(actionTaken, false); |
706 | |
} |
707 | |
|
708 | |
protected static ActionTakenDTO convertActionTaken(ActionTakenValue actionTaken, boolean fetchActionRequests) { |
709 | 0 | if (actionTaken == null) { |
710 | 0 | return null; |
711 | |
} |
712 | 0 | ActionTakenDTO actionTakenVO = new ActionTakenDTO(); |
713 | 0 | actionTakenVO.setActionDate(SQLUtils.convertTimestamp(actionTaken.getActionDate())); |
714 | 0 | actionTakenVO.setActionTaken(actionTaken.getActionTaken()); |
715 | 0 | actionTakenVO.setActionTakenId(actionTaken.getActionTakenId()); |
716 | 0 | actionTakenVO.setAnnotation(actionTaken.getAnnotation()); |
717 | 0 | actionTakenVO.setDocVersion(actionTaken.getDocVersion()); |
718 | 0 | actionTakenVO.setDocumentId(actionTaken.getDocumentId()); |
719 | 0 | actionTakenVO.setPrincipalId(actionTaken.getPrincipalId()); |
720 | 0 | actionTakenVO.setDelegatorPrincpalId(actionTaken.getDelegatorPrincipalId()); |
721 | 0 | actionTakenVO.setDelegatorGroupId(actionTaken.getDelegatorGroupId()); |
722 | 0 | if (fetchActionRequests) { |
723 | 0 | ActionRequestDTO[] actionRequests = new ActionRequestDTO[actionTaken.getActionRequests().size()]; |
724 | 0 | int index = 0; |
725 | 0 | for (Object element : actionTaken.getActionRequests()) { |
726 | 0 | ActionRequestValue actionRequest = (ActionRequestValue) element; |
727 | 0 | actionRequests[index++] = convertActionRequest(actionRequest, false); |
728 | 0 | } |
729 | 0 | actionTakenVO.setActionRequests(actionRequests); |
730 | |
} |
731 | 0 | return actionTakenVO; |
732 | |
} |
733 | |
|
734 | |
public static ResponsiblePartyDTO convertResponsibleParty(ResponsibleParty responsibleParty) { |
735 | 0 | if (responsibleParty == null) { |
736 | 0 | return null; |
737 | |
} |
738 | 0 | ResponsiblePartyDTO responsiblePartyVO = new ResponsiblePartyDTO(); |
739 | 0 | responsiblePartyVO.setGroupId(responsibleParty.getGroupId()); |
740 | 0 | responsiblePartyVO.setPrincipalId(responsibleParty.getPrincipalId()); |
741 | 0 | responsiblePartyVO.setRoleName(responsibleParty.getRoleName()); |
742 | 0 | return responsiblePartyVO; |
743 | |
} |
744 | |
|
745 | |
public static ResponsibleParty convertResponsiblePartyVO(ResponsiblePartyDTO responsiblePartyVO) { |
746 | 0 | if (responsiblePartyVO == null) { |
747 | 0 | return null; |
748 | |
} |
749 | 0 | ResponsibleParty responsibleParty = new ResponsibleParty(); |
750 | 0 | responsibleParty.setGroupId(responsiblePartyVO.getGroupId()); |
751 | 0 | responsibleParty.setPrincipalId(responsiblePartyVO.getPrincipalId()); |
752 | 0 | responsibleParty.setRoleName(responsiblePartyVO.getRoleName()); |
753 | 0 | return responsibleParty; |
754 | |
} |
755 | |
|
756 | |
|
757 | |
|
758 | |
|
759 | |
|
760 | |
|
761 | |
|
762 | |
public static Recipient convertResponsiblePartyVOtoRecipient(ResponsiblePartyDTO responsiblePartyVO) { |
763 | 0 | if (responsiblePartyVO == null) { |
764 | 0 | return null; |
765 | |
} |
766 | 0 | if (responsiblePartyVO.getRoleName() != null) { |
767 | 0 | return new RoleRecipient(responsiblePartyVO.getRoleName()); |
768 | |
} |
769 | 0 | String groupId = responsiblePartyVO.getGroupId(); |
770 | 0 | if (groupId != null) { |
771 | 0 | Group group = KimApiServiceLocator.getGroupService().getGroup(groupId); |
772 | 0 | if (group == null) { |
773 | 0 | throw new RiceRuntimeException("Failed to locate group with ID: " + groupId); |
774 | |
} |
775 | 0 | return new KimGroupRecipient(group); |
776 | |
} |
777 | 0 | String principalId = responsiblePartyVO.getPrincipalId(); |
778 | 0 | if (principalId != null) { |
779 | 0 | return new KimPrincipalRecipient(principalId); |
780 | |
} |
781 | 0 | throw new WorkflowRuntimeException("ResponsibleParty of unknown type"); |
782 | |
} |
783 | |
|
784 | |
|
785 | |
|
786 | |
|
787 | 0 | public static interface RouteNodeInstanceLoader { |
788 | |
RouteNodeInstance load(String routeNodeInstanceID); |
789 | |
} |
790 | |
|
791 | |
|
792 | |
|
793 | |
|
794 | |
|
795 | |
|
796 | |
|
797 | |
|
798 | |
|
799 | |
public static ActionRequestValue convertActionRequestDTO(ActionRequestDTO actionRequestDTO) { |
800 | 0 | return convertActionRequestDTO(actionRequestDTO, null); |
801 | |
} |
802 | |
|
803 | |
|
804 | |
|
805 | |
|
806 | |
|
807 | |
|
808 | |
|
809 | |
public static ActionRequestValue convertActionRequestDTO(ActionRequestDTO actionRequestDTO, |
810 | |
RouteNodeInstanceLoader routeNodeInstanceLoader) { |
811 | |
|
812 | 0 | if (actionRequestDTO == null) { |
813 | 0 | return null; |
814 | |
} |
815 | 0 | if (actionRequestDTO.getParentActionRequestId() != null) { |
816 | 0 | throw new IllegalArgumentException("Cannot convert a non-root ActionRequestVO"); |
817 | |
} |
818 | 0 | ActionRequestValue actionRequest = new ActionRequestFactory().createBlankActionRequest(); |
819 | 0 | populateActionRequest(actionRequest, actionRequestDTO, routeNodeInstanceLoader); |
820 | 0 | if (actionRequestDTO.getChildrenRequests() != null) { |
821 | 0 | for (int i = 0; i < actionRequestDTO.getChildrenRequests().length; i++) { |
822 | 0 | ActionRequestDTO childVO = actionRequestDTO.getChildrenRequests()[i]; |
823 | 0 | actionRequest.getChildrenRequests().add(convertActionRequestVO(childVO, actionRequest, routeNodeInstanceLoader)); |
824 | |
} |
825 | |
} |
826 | 0 | return actionRequest; |
827 | |
} |
828 | |
|
829 | |
|
830 | |
protected static ActionRequestValue convertActionRequestVO(ActionRequestDTO actionRequestDTO, ActionRequestValue parentActionRequest, |
831 | |
RouteNodeInstanceLoader routeNodeInstanceLoader) { |
832 | 0 | if (actionRequestDTO == null) { |
833 | 0 | return null; |
834 | |
} |
835 | 0 | ActionRequestValue actionRequest = new ActionRequestFactory().createBlankActionRequest(); |
836 | 0 | populateActionRequest(actionRequest, actionRequestDTO, routeNodeInstanceLoader); |
837 | 0 | actionRequest.setParentActionRequest(parentActionRequest); |
838 | 0 | actionRequest.setParentActionRequestId(parentActionRequest.getActionRequestId()); |
839 | 0 | if (actionRequestDTO.getChildrenRequests() != null) { |
840 | 0 | for (int i = 0; i < actionRequestDTO.getChildrenRequests().length; i++) { |
841 | 0 | ActionRequestDTO childVO = actionRequestDTO.getChildrenRequests()[i]; |
842 | 0 | actionRequest.getChildrenRequests().add(convertActionRequestVO(childVO, actionRequest, routeNodeInstanceLoader)); |
843 | |
} |
844 | |
} |
845 | 0 | return actionRequest; |
846 | |
} |
847 | |
|
848 | |
|
849 | |
|
850 | |
|
851 | |
private static void populateActionRequest(ActionRequestValue actionRequest, ActionRequestDTO actionRequestDTO, |
852 | |
RouteNodeInstanceLoader routeNodeInstanceLoader) { |
853 | |
|
854 | 0 | actionRequest.setActionRequested(actionRequestDTO.getActionRequested()); |
855 | 0 | actionRequest.setActionRequestId(actionRequestDTO.getActionRequestId()); |
856 | 0 | actionRequest.setActionTakenId(actionRequestDTO.getActionTakenId()); |
857 | 0 | actionRequest.setAnnotation(actionRequestDTO.getAnnotation()); |
858 | 0 | actionRequest.setApprovePolicy(actionRequestDTO.getApprovePolicy()); |
859 | 0 | actionRequest.setCreateDate(new Timestamp(new Date().getTime())); |
860 | 0 | actionRequest.setCurrentIndicator(actionRequestDTO.getCurrentIndicator()); |
861 | 0 | actionRequest.setDelegationType(actionRequestDTO.getDelegationType()); |
862 | 0 | actionRequest.setDocVersion(actionRequestDTO.getDocVersion()); |
863 | 0 | actionRequest.setForceAction(actionRequestDTO.getForceAction()); |
864 | 0 | actionRequest.setPriority(actionRequestDTO.getPriority()); |
865 | 0 | actionRequest.setQualifiedRoleName(actionRequestDTO.getQualifiedRoleName()); |
866 | 0 | actionRequest.setQualifiedRoleNameLabel(actionRequestDTO.getQualifiedRoleNameLabel()); |
867 | 0 | actionRequest.setRecipientTypeCd(actionRequestDTO.getRecipientTypeCd()); |
868 | 0 | actionRequest.setResponsibilityDesc(actionRequestDTO.getResponsibilityDesc()); |
869 | 0 | actionRequest.setResponsibilityId(actionRequestDTO.getResponsibilityId()); |
870 | 0 | actionRequest.setRoleName(actionRequestDTO.getRoleName()); |
871 | 0 | String documentId = actionRequestDTO.getDocumentId(); |
872 | 0 | if (documentId != null) { |
873 | 0 | actionRequest.setDocumentId(documentId); |
874 | |
|
875 | |
} |
876 | 0 | actionRequest.setRouteLevel(actionRequestDTO.getRouteLevel()); |
877 | |
|
878 | 0 | actionRequest.setStatus(actionRequestDTO.getStatus()); |
879 | 0 | actionRequest.setPrincipalId(actionRequestDTO.getPrincipalId()); |
880 | 0 | actionRequest.setGroupId(actionRequestDTO.getGroupId()); |
881 | |
|
882 | 0 | if (routeNodeInstanceLoader != null && actionRequestDTO.getNodeInstanceId() != null) { |
883 | 0 | actionRequest.setNodeInstance(routeNodeInstanceLoader.load(actionRequestDTO.getNodeInstanceId())); |
884 | |
} |
885 | 0 | } |
886 | |
|
887 | |
public static ActionTakenValue convertActionTakenVO(ActionTakenDTO actionTakenVO) { |
888 | 0 | if (actionTakenVO == null) { |
889 | 0 | return null; |
890 | |
} |
891 | 0 | ActionTakenValue actionTaken = new ActionTakenValue(); |
892 | 0 | actionTaken.setActionDate(new Timestamp(actionTakenVO.getActionDate().getTimeInMillis())); |
893 | 0 | actionTaken.setActionTaken(actionTakenVO.getActionTaken()); |
894 | 0 | actionTaken.setActionTakenId(actionTakenVO.getActionTakenId()); |
895 | 0 | actionTaken.setAnnotation(actionTakenVO.getAnnotation()); |
896 | 0 | actionTaken.setCurrentIndicator(Boolean.TRUE); |
897 | 0 | actionTaken.setPrincipalId(actionTakenVO.getPrincipalId()); |
898 | 0 | actionTaken.setDelegatorPrincipalId(actionTakenVO.getDelegatorPrincpalId()); |
899 | 0 | actionTaken.setDelegatorGroupId(actionTakenVO.getDelegatorGroupId()); |
900 | 0 | actionTaken.setDocVersion(actionTakenVO.getDocVersion()); |
901 | 0 | KEWServiceLocator.getRouteHeaderService().getRouteHeader(actionTakenVO.getDocumentId()); |
902 | |
|
903 | 0 | actionTaken.setDocumentId(actionTaken.getDocumentId()); |
904 | 0 | return actionTaken; |
905 | |
} |
906 | |
|
907 | |
public static DocumentRouteStatusChangeDTO convertDocumentRouteStatusChange(DocumentRouteStatusChange statusChange) { |
908 | 0 | if (statusChange == null) { |
909 | 0 | return null; |
910 | |
} |
911 | 0 | DocumentRouteStatusChangeDTO statusChangeVO = new DocumentRouteStatusChangeDTO(); |
912 | 0 | statusChangeVO.setDocumentId(statusChange.getDocumentId()); |
913 | 0 | statusChangeVO.setAppDocId(statusChange.getAppDocId()); |
914 | 0 | statusChangeVO.setOldRouteStatus(statusChange.getOldRouteStatus()); |
915 | 0 | statusChangeVO.setNewRouteStatus(statusChange.getNewRouteStatus()); |
916 | 0 | return statusChangeVO; |
917 | |
} |
918 | |
|
919 | |
public static DocumentRouteLevelChangeDTO convertDocumentRouteLevelChange(DocumentRouteLevelChange routeLevelChange) { |
920 | 0 | if (routeLevelChange == null) { |
921 | 0 | return null; |
922 | |
} |
923 | 0 | DocumentRouteLevelChangeDTO routeLevelChangeVO = new DocumentRouteLevelChangeDTO(); |
924 | 0 | routeLevelChangeVO.setDocumentId(routeLevelChange.getDocumentId()); |
925 | 0 | routeLevelChangeVO.setAppDocId(routeLevelChange.getAppDocId()); |
926 | 0 | routeLevelChangeVO.setOldRouteLevel(routeLevelChange.getOldRouteLevel()); |
927 | 0 | routeLevelChangeVO.setNewRouteLevel(routeLevelChange.getNewRouteLevel()); |
928 | 0 | routeLevelChangeVO.setOldNodeName(routeLevelChange.getOldNodeName()); |
929 | 0 | routeLevelChangeVO.setNewNodeName(routeLevelChange.getNewNodeName()); |
930 | 0 | routeLevelChangeVO.setOldNodeInstanceId(routeLevelChange.getOldNodeInstanceId()); |
931 | 0 | routeLevelChangeVO.setNewNodeInstanceId(routeLevelChange.getNewNodeInstanceId()); |
932 | 0 | return routeLevelChangeVO; |
933 | |
} |
934 | |
|
935 | |
public static DeleteEventDTO convertDeleteEvent(DeleteEvent deleteEvent) { |
936 | 0 | if (deleteEvent == null) { |
937 | 0 | return null; |
938 | |
} |
939 | 0 | DeleteEventDTO deleteEventVO = new DeleteEventDTO(); |
940 | 0 | deleteEventVO.setDocumentId(deleteEvent.getDocumentId()); |
941 | 0 | deleteEventVO.setAppDocId(deleteEvent.getAppDocId()); |
942 | 0 | return deleteEventVO; |
943 | |
} |
944 | |
|
945 | |
public static ActionTakenEventDTO convertActionTakenEvent(ActionTakenEvent actionTakenEvent) { |
946 | 0 | if (actionTakenEvent == null) { |
947 | 0 | return null; |
948 | |
} |
949 | 0 | ActionTakenEventDTO actionTakenEventVO = new ActionTakenEventDTO(); |
950 | 0 | actionTakenEventVO.setDocumentId(actionTakenEvent.getDocumentId()); |
951 | 0 | actionTakenEventVO.setAppDocId(actionTakenEvent.getAppDocId()); |
952 | 0 | actionTakenEventVO.setActionTaken(convertActionTaken(actionTakenEvent.getActionTaken())); |
953 | 0 | return actionTakenEventVO; |
954 | |
} |
955 | |
|
956 | |
public static BeforeProcessEventDTO convertBeforeProcessEvent(BeforeProcessEvent event) { |
957 | 0 | if (event == null) { |
958 | 0 | return null; |
959 | |
} |
960 | 0 | BeforeProcessEventDTO beforeProcessEvent = new BeforeProcessEventDTO(); |
961 | 0 | beforeProcessEvent.setDocumentId(event.getDocumentId()); |
962 | 0 | beforeProcessEvent.setAppDocId(event.getAppDocId()); |
963 | 0 | beforeProcessEvent.setNodeInstanceId(event.getNodeInstanceId()); |
964 | 0 | return beforeProcessEvent; |
965 | |
} |
966 | |
|
967 | |
public static AfterProcessEventDTO convertAfterProcessEvent(AfterProcessEvent event) { |
968 | 0 | if (event == null) { |
969 | 0 | return null; |
970 | |
} |
971 | 0 | AfterProcessEventDTO afterProcessEvent = new AfterProcessEventDTO(); |
972 | 0 | afterProcessEvent.setDocumentId(event.getDocumentId()); |
973 | 0 | afterProcessEvent.setAppDocId(event.getAppDocId()); |
974 | 0 | afterProcessEvent.setNodeInstanceId(event.getNodeInstanceId()); |
975 | 0 | afterProcessEvent.setSuccessfullyProcessed(event.isSuccessfullyProcessed()); |
976 | 0 | return afterProcessEvent; |
977 | |
} |
978 | |
|
979 | |
public static DocumentLockingEventDTO convertDocumentLockingEvent(DocumentLockingEvent event) { |
980 | 0 | if (event == null) { |
981 | 0 | return null; |
982 | |
} |
983 | 0 | DocumentLockingEventDTO documentLockingEvent = new DocumentLockingEventDTO(); |
984 | 0 | documentLockingEvent.setDocumentId(event.getDocumentId()); |
985 | 0 | documentLockingEvent.setAppDocId(event.getAppDocId()); |
986 | 0 | return documentLockingEvent; |
987 | |
} |
988 | |
|
989 | |
|
990 | |
public static AttributeDefinition convertWorkflowAttributeDefinitionVO(WorkflowAttributeDefinitionDTO definitionVO, org.kuali.rice.kew.doctype.bo.DocumentType documentType) { |
991 | 0 | if (definitionVO == null) { |
992 | 0 | return null; |
993 | |
} |
994 | |
|
995 | 0 | RuleAttribute ruleAttribute = KEWServiceLocator.getRuleAttributeService().findByClassName(definitionVO.getAttributeName()); |
996 | 0 | if (ruleAttribute == null) { |
997 | 0 | ruleAttribute = KEWServiceLocator.getRuleAttributeService().findByName(definitionVO.getAttributeName()); |
998 | |
} |
999 | 0 | if (ruleAttribute == null) { |
1000 | 0 | throw new WorkflowRuntimeException("Attribute " + definitionVO.getAttributeName() + " not found"); |
1001 | |
} |
1002 | |
|
1003 | 0 | ObjectDefinition definition = new ObjectDefinition(ruleAttribute.getClassName()); |
1004 | 0 | for (int index = 0; index < definitionVO.getConstructorParameters().length; index++) { |
1005 | 0 | String parameter = definitionVO.getConstructorParameters()[index]; |
1006 | 0 | definition.addConstructorParameter(new DataDefinition(parameter, String.class)); |
1007 | |
} |
1008 | 0 | boolean propertiesAsMap = KEWConstants.RULE_XML_ATTRIBUTE_TYPE.equals(ruleAttribute.getType()) || KEWConstants.SEARCHABLE_XML_ATTRIBUTE_TYPE.equals(ruleAttribute.getType()); |
1009 | 0 | if (!propertiesAsMap) { |
1010 | 0 | for (int index = 0; index < definitionVO.getProperties().length; index++) { |
1011 | 0 | PropertyDefinitionDTO propertyDefVO = definitionVO.getProperties()[index]; |
1012 | 0 | definition.addProperty(new PropertyDefinition(propertyDefVO.getName(), new DataDefinition(propertyDefVO.getValue(), String.class))); |
1013 | |
} |
1014 | |
} |
1015 | |
|
1016 | |
|
1017 | 0 | if (ruleAttribute.getApplicationId() != null) { |
1018 | 0 | definition.setApplicationId(ruleAttribute.getApplicationId()); |
1019 | |
} else { |
1020 | |
|
1021 | 0 | if (documentType != null) { |
1022 | 0 | definition.setApplicationId(documentType.getApplicationId()); |
1023 | |
} |
1024 | |
} |
1025 | |
|
1026 | 0 | return new AttributeDefinition(ruleAttribute, definition); |
1027 | |
} |
1028 | |
|
1029 | |
public static DocumentDetailDTO convertDocumentDetail(DocumentRouteHeaderValue routeHeader) throws WorkflowException { |
1030 | 0 | if (routeHeader == null) { |
1031 | 0 | return null; |
1032 | |
} |
1033 | 0 | DocumentDetailDTO detail = new DocumentDetailDTO(); |
1034 | 0 | populateRouteHeaderVO(detail, routeHeader); |
1035 | 0 | Map nodeInstances = new HashMap(); |
1036 | 0 | List actionRequestVOs = new ArrayList(); |
1037 | 0 | List rootActionRequests = KEWServiceLocator.getActionRequestService().getRootRequests(routeHeader.getActionRequests()); |
1038 | 0 | for (Iterator iterator = rootActionRequests.iterator(); iterator.hasNext();) { |
1039 | 0 | ActionRequestValue actionRequest = (ActionRequestValue) iterator.next(); |
1040 | 0 | actionRequestVOs.add(convertActionRequest(actionRequest)); |
1041 | 0 | RouteNodeInstance nodeInstance = actionRequest.getNodeInstance(); |
1042 | 0 | if (nodeInstance == null) { |
1043 | 0 | continue; |
1044 | |
} |
1045 | 0 | if (nodeInstance.getRouteNodeInstanceId() == null) { |
1046 | 0 | throw new WorkflowException("Error creating document detail structure because of NULL node instance id."); |
1047 | |
} |
1048 | 0 | nodeInstances.put(nodeInstance.getRouteNodeInstanceId(), nodeInstance); |
1049 | 0 | } |
1050 | 0 | detail.setActionRequests((ActionRequestDTO[]) actionRequestVOs.toArray(new ActionRequestDTO[0])); |
1051 | 0 | List nodeInstanceVOs = new ArrayList(); |
1052 | 0 | for (Iterator iterator = nodeInstances.values().iterator(); iterator.hasNext();) { |
1053 | 0 | RouteNodeInstance nodeInstance = (RouteNodeInstance) iterator.next(); |
1054 | 0 | nodeInstanceVOs.add(convertRouteNodeInstance(nodeInstance)); |
1055 | 0 | } |
1056 | 0 | detail.setNodeInstances((RouteNodeInstanceDTO[]) nodeInstanceVOs.toArray(new RouteNodeInstanceDTO[0])); |
1057 | 0 | List actionTakenVOs = new ArrayList(); |
1058 | 0 | for (Object element : routeHeader.getActionsTaken()) { |
1059 | 0 | ActionTakenValue actionTaken = (ActionTakenValue) element; |
1060 | 0 | actionTakenVOs.add(convertActionTaken(actionTaken)); |
1061 | 0 | } |
1062 | 0 | detail.setActionsTaken((ActionTakenDTO[]) actionTakenVOs.toArray(new ActionTakenDTO[0])); |
1063 | 0 | return detail; |
1064 | |
} |
1065 | |
|
1066 | |
public static DocumentDetail convertDocumentDetailNew(DocumentRouteHeaderValue routeHeader) { |
1067 | 0 | if (routeHeader == null) { |
1068 | 0 | return null; |
1069 | |
} |
1070 | 0 | org.kuali.rice.kew.api.document.Document document = DocumentRouteHeaderValue.to(routeHeader); |
1071 | 0 | DocumentDetail.Builder detail = DocumentDetail.Builder.create(document); |
1072 | 0 | Map<String, RouteNodeInstance> nodeInstances = new HashMap<String, RouteNodeInstance>(); |
1073 | 0 | List<ActionRequest> actionRequestVOs = new ArrayList<ActionRequest>(); |
1074 | 0 | List<ActionRequestValue> rootActionRequests = KEWServiceLocator.getActionRequestService().getRootRequests(routeHeader.getActionRequests()); |
1075 | 0 | for (Iterator<ActionRequestValue> iterator = rootActionRequests.iterator(); iterator.hasNext();) { |
1076 | 0 | ActionRequestValue actionRequest = iterator.next(); |
1077 | 0 | actionRequestVOs.add(ActionRequestValue.to(actionRequest)); |
1078 | 0 | RouteNodeInstance nodeInstance = actionRequest.getNodeInstance(); |
1079 | 0 | if (nodeInstance == null) { |
1080 | 0 | continue; |
1081 | |
} |
1082 | 0 | if (nodeInstance.getRouteNodeInstanceId() == null) { |
1083 | 0 | throw new IllegalStateException("Error creating document detail structure because of NULL node instance id."); |
1084 | |
} |
1085 | 0 | nodeInstances.put(nodeInstance.getRouteNodeInstanceId(), nodeInstance); |
1086 | 0 | } |
1087 | 0 | detail.setActionRequests(actionRequestVOs); |
1088 | 0 | List<org.kuali.rice.kew.api.document.RouteNodeInstance> nodeInstanceVOs = new ArrayList<org.kuali.rice.kew.api.document.RouteNodeInstance>(); |
1089 | 0 | for (Iterator<RouteNodeInstance> iterator = nodeInstances.values().iterator(); iterator.hasNext();) { |
1090 | 0 | RouteNodeInstance nodeInstance = iterator.next(); |
1091 | 0 | nodeInstanceVOs.add(RouteNodeInstance.to(nodeInstance)); |
1092 | 0 | } |
1093 | 0 | detail.setRouteNodeInstances(nodeInstanceVOs); |
1094 | 0 | List<ActionTaken> actionTakenVOs = new ArrayList<ActionTaken>(); |
1095 | 0 | for (Object element : routeHeader.getActionsTaken()) { |
1096 | 0 | ActionTakenValue actionTaken = (ActionTakenValue) element; |
1097 | 0 | actionTakenVOs.add(ActionTakenValue.to(actionTaken)); |
1098 | 0 | } |
1099 | 0 | detail.setActionsTaken(actionTakenVOs); |
1100 | 0 | return detail.build(); |
1101 | |
} |
1102 | |
|
1103 | |
|
1104 | |
public static RouteNodeInstanceDTO convertRouteNodeInstance(RouteNodeInstance nodeInstance) throws WorkflowException { |
1105 | 0 | if (nodeInstance == null) { |
1106 | 0 | return null; |
1107 | |
} |
1108 | 0 | RouteNodeInstanceDTO nodeInstanceVO = new RouteNodeInstanceDTO(); |
1109 | 0 | nodeInstanceVO.setActive(nodeInstance.isActive()); |
1110 | 0 | nodeInstanceVO.setBranchId(nodeInstance.getBranch().getBranchId()); |
1111 | 0 | nodeInstanceVO.setComplete(nodeInstance.isComplete()); |
1112 | 0 | nodeInstanceVO.setDocumentId(nodeInstance.getDocumentId()); |
1113 | 0 | nodeInstanceVO.setInitial(nodeInstance.isInitial()); |
1114 | 0 | nodeInstanceVO.setName(nodeInstance.getName()); |
1115 | 0 | nodeInstanceVO.setProcessId(nodeInstance.getProcess() != null ? nodeInstance.getProcess().getRouteNodeInstanceId() : null); |
1116 | 0 | nodeInstanceVO.setRouteNodeId(nodeInstance.getRouteNode().getRouteNodeId()); |
1117 | 0 | nodeInstanceVO.setRouteNodeInstanceId(nodeInstance.getRouteNodeInstanceId()); |
1118 | 0 | nodeInstanceVO.setState(convertStates(nodeInstance.getState())); |
1119 | |
|
1120 | 0 | nodeInstanceVO.setNextNodes(new RouteNodeInstanceDTO[nodeInstance.getNextNodeInstances().size()]); |
1121 | 0 | int i = 0; |
1122 | 0 | for (Iterator iter = nodeInstance.getNextNodeInstances().iterator(); iter.hasNext(); i++) { |
1123 | 0 | RouteNodeInstance nextNodeInstance = (RouteNodeInstance) iter.next(); |
1124 | 0 | nodeInstanceVO.getNextNodes()[i] = convertRouteNodeInstance(nextNodeInstance); |
1125 | |
} |
1126 | |
|
1127 | 0 | return nodeInstanceVO; |
1128 | |
} |
1129 | |
|
1130 | |
public static StateDTO[] convertStates(Collection states) { |
1131 | 0 | if (states == null) { |
1132 | 0 | return null; |
1133 | |
} |
1134 | 0 | StateDTO[] stateVOs = new StateDTO[states.size()]; |
1135 | 0 | int index = 0; |
1136 | 0 | for (Iterator iterator = states.iterator(); iterator.hasNext();) { |
1137 | 0 | State state = (State) iterator.next(); |
1138 | 0 | stateVOs[index++] = convertState(state); |
1139 | 0 | } |
1140 | 0 | return stateVOs; |
1141 | |
} |
1142 | |
|
1143 | |
public static StateDTO convertState(State nodeState) { |
1144 | 0 | if (nodeState == null) { |
1145 | 0 | return null; |
1146 | |
} |
1147 | 0 | StateDTO stateVO = new StateDTO(); |
1148 | 0 | stateVO.setStateId(nodeState.getStateId()); |
1149 | 0 | stateVO.setKey(nodeState.getKey()); |
1150 | 0 | stateVO.setValue(nodeState.getValue()); |
1151 | 0 | return stateVO; |
1152 | |
} |
1153 | |
|
1154 | |
public static MovePoint convertMovePointVO(MovePointDTO movePointVO) { |
1155 | 0 | return MovePoint.create(movePointVO.getStartNodeName(), movePointVO.getStepsToMove()); |
1156 | |
} |
1157 | |
|
1158 | |
|
1159 | |
|
1160 | |
|
1161 | |
public static AdHocRevoke convertAdHocRevokeVO(AdHocRevokeDTO revokeVO) throws WorkflowException { |
1162 | 0 | Set<String> nodeNames = new HashSet<String>(); |
1163 | 0 | Set<String> principalIds = new HashSet<String>(); |
1164 | 0 | Set<String> groupIds = new HashSet<String>(); |
1165 | 0 | if (revokeVO.getNodeName() != null) { |
1166 | 0 | nodeNames.add(revokeVO.getNodeName()); |
1167 | |
} |
1168 | 0 | if (revokeVO.getPrincipalId() != null) { |
1169 | 0 | principalIds.add(revokeVO.getPrincipalId()); |
1170 | |
} |
1171 | 0 | if (revokeVO.getGroupId() != null) { |
1172 | 0 | principalIds.add(revokeVO.getGroupId()); |
1173 | |
} |
1174 | 0 | return AdHocRevoke.create(nodeNames, principalIds, groupIds); |
1175 | |
} |
1176 | |
|
1177 | |
public static WorkflowAttributeValidationErrorDTO convertWorkflowAttributeValidationError(WorkflowAttributeValidationError error) { |
1178 | 0 | return new WorkflowAttributeValidationErrorDTO(error.getKey(), error.getMessage()); |
1179 | |
} |
1180 | |
|
1181 | |
|
1182 | |
public static void updateNotes(RouteHeaderDTO routeHeaderVO, String documentId) { |
1183 | 0 | NoteDTO[] notes = routeHeaderVO.getNotes(); |
1184 | 0 | NoteDTO[] notesToDelete = routeHeaderVO.getNotesToDelete(); |
1185 | 0 | Note noteToDelete = null; |
1186 | 0 | Note noteToSave = null; |
1187 | |
|
1188 | |
|
1189 | 0 | if (notes != null) { |
1190 | 0 | for (NoteDTO note : notes) { |
1191 | 0 | if (note != null) { |
1192 | 0 | noteToSave = new Note(); |
1193 | 0 | noteToSave.setNoteId(note.getNoteId()); |
1194 | 0 | noteToSave.setDocumentId(documentId); |
1195 | 0 | noteToSave.setNoteAuthorWorkflowId(note.getNoteAuthorWorkflowId()); |
1196 | 0 | noteToSave.setNoteCreateDate(SQLUtils.convertCalendar(note.getNoteCreateDate())); |
1197 | 0 | noteToSave.setNoteText(note.getNoteText()); |
1198 | 0 | noteToSave.setLockVerNbr(note.getLockVerNbr()); |
1199 | |
|
1200 | 0 | getNoteService().saveNote(noteToSave); |
1201 | |
} |
1202 | |
} |
1203 | |
|
1204 | |
} |
1205 | |
|
1206 | |
|
1207 | 0 | if (notesToDelete != null) { |
1208 | 0 | for (NoteDTO element : notesToDelete) { |
1209 | 0 | noteToDelete = getNoteService().getNoteByNoteId(element.getNoteId()); |
1210 | 0 | if (noteToDelete != null) { |
1211 | 0 | getNoteService().deleteNote(noteToDelete); |
1212 | |
} |
1213 | |
} |
1214 | 0 | routeHeaderVO.setNotesToDelete(null); |
1215 | |
} |
1216 | 0 | } |
1217 | |
|
1218 | |
private static NoteService getNoteService() { |
1219 | 0 | return (NoteService) KEWServiceLocator.getService(KEWServiceLocator.NOTE_SERVICE); |
1220 | |
} |
1221 | |
|
1222 | |
private static NoteDTO[] convertNotesArrayListToNoteVOArray(List notesArrayList) { |
1223 | 0 | if (notesArrayList.size() > 0) { |
1224 | 0 | NoteDTO[] noteVOArray = new NoteDTO[notesArrayList.size()]; |
1225 | 0 | int i = 0; |
1226 | |
Note tempNote; |
1227 | |
NoteDTO tempNoteVO; |
1228 | 0 | for (Iterator it = notesArrayList.iterator(); it.hasNext();) { |
1229 | 0 | tempNote = (Note) it.next(); |
1230 | 0 | tempNoteVO = new NoteDTO(); |
1231 | 0 | tempNoteVO.setNoteId(tempNote.getNoteId()); |
1232 | 0 | tempNoteVO.setDocumentId(tempNote.getDocumentId()); |
1233 | 0 | tempNoteVO.setNoteAuthorWorkflowId(tempNote.getNoteAuthorWorkflowId()); |
1234 | 0 | tempNoteVO.setNoteCreateDate(SQLUtils.convertTimestamp(tempNote.getNoteCreateDate())); |
1235 | 0 | tempNoteVO.setNoteText(tempNote.getNoteText()); |
1236 | 0 | tempNoteVO.setLockVerNbr(tempNote.getLockVerNbr()); |
1237 | 0 | noteVOArray[i] = tempNoteVO; |
1238 | 0 | i++; |
1239 | |
} |
1240 | 0 | return noteVOArray; |
1241 | |
} else { |
1242 | 0 | return null; |
1243 | |
} |
1244 | |
} |
1245 | |
|
1246 | |
public static SimulationCriteria convertReportCriteriaDTO(ReportCriteriaDTO criteriaVO) { |
1247 | 0 | if (criteriaVO == null) { |
1248 | 0 | return null; |
1249 | |
} |
1250 | 0 | SimulationCriteria criteria = new SimulationCriteria(); |
1251 | 0 | criteria.setDestinationNodeName(criteriaVO.getTargetNodeName()); |
1252 | 0 | criteria.setDocumentId(criteriaVO.getDocumentId()); |
1253 | 0 | criteria.setDocumentTypeName(criteriaVO.getDocumentTypeName()); |
1254 | 0 | criteria.setXmlContent(criteriaVO.getXmlContent()); |
1255 | 0 | criteria.setActivateRequests(criteriaVO.getActivateRequests()); |
1256 | 0 | criteria.setFlattenNodes(criteriaVO.isFlattenNodes()); |
1257 | 0 | if (criteriaVO.getRoutingPrincipalId() != null) { |
1258 | 0 | Principal kPrinc = KEWServiceLocator.getIdentityHelperService().getPrincipal(criteriaVO.getRoutingPrincipalId()); |
1259 | 0 | Person user = KimApiServiceLocator.getPersonService().getPerson(kPrinc.getPrincipalId()); |
1260 | 0 | if (user == null) { |
1261 | 0 | throw new RiceRuntimeException("Could not locate user for the given id: " + criteriaVO.getRoutingPrincipalId()); |
1262 | |
} |
1263 | 0 | criteria.setRoutingUser(user); |
1264 | |
} |
1265 | 0 | if (criteriaVO.getRuleTemplateNames() != null) { |
1266 | 0 | for (int index = 0; index < criteriaVO.getRuleTemplateNames().length; index++) { |
1267 | 0 | String ruleTemplateName = criteriaVO.getRuleTemplateNames()[index]; |
1268 | 0 | criteria.getRuleTemplateNames().add(ruleTemplateName); |
1269 | |
} |
1270 | |
} |
1271 | 0 | if (criteriaVO.getNodeNames() != null) { |
1272 | 0 | for (int i = 0; i < criteriaVO.getNodeNames().length; i++) { |
1273 | 0 | String nodeName = criteriaVO.getNodeNames()[i]; |
1274 | 0 | criteria.getNodeNames().add(nodeName); |
1275 | |
} |
1276 | |
} |
1277 | 0 | if (criteriaVO.getTargetPrincipalIds() != null) { |
1278 | 0 | for (String targetPrincipalId : criteriaVO.getTargetPrincipalIds()) { |
1279 | 0 | Principal principal = KEWServiceLocator.getIdentityHelperService().getPrincipal(targetPrincipalId); |
1280 | 0 | criteria.getDestinationRecipients().add(new KimPrincipalRecipient(principal)); |
1281 | |
} |
1282 | |
} |
1283 | 0 | if (criteriaVO.getActionsToTake() != null) { |
1284 | 0 | for (int index = 0; index < criteriaVO.getActionsToTake().length; index++) { |
1285 | 0 | ReportActionToTakeDTO actionToTakeVO = criteriaVO.getActionsToTake()[index]; |
1286 | 0 | criteria.getActionsToTake().add(convertReportActionToTakeVO(actionToTakeVO)); |
1287 | |
} |
1288 | |
} |
1289 | 0 | return criteria; |
1290 | |
} |
1291 | |
|
1292 | |
public static SimulationActionToTake convertReportActionToTakeVO(ReportActionToTakeDTO actionToTakeVO) { |
1293 | 0 | if (actionToTakeVO == null) { |
1294 | 0 | return null; |
1295 | |
} |
1296 | 0 | SimulationActionToTake actionToTake = new SimulationActionToTake(); |
1297 | 0 | actionToTake.setNodeName(actionToTakeVO.getNodeName()); |
1298 | 0 | if (StringUtils.isBlank(actionToTakeVO.getActionToPerform())) { |
1299 | 0 | throw new IllegalArgumentException("ReportActionToTakeVO must contain an action taken code and does not"); |
1300 | |
} |
1301 | 0 | actionToTake.setActionToPerform(actionToTakeVO.getActionToPerform()); |
1302 | 0 | if (actionToTakeVO.getPrincipalId() == null) { |
1303 | 0 | throw new IllegalArgumentException("ReportActionToTakeVO must contain a principalId and does not"); |
1304 | |
} |
1305 | 0 | Principal kPrinc = KEWServiceLocator.getIdentityHelperService().getPrincipal(actionToTakeVO.getPrincipalId()); |
1306 | 0 | Person user = KimApiServiceLocator.getPersonService().getPerson(kPrinc.getPrincipalId()); |
1307 | 0 | if (user == null) { |
1308 | 0 | throw new RiceRuntimeException("Could not locate Person for the given id: " + actionToTakeVO.getPrincipalId()); |
1309 | |
} |
1310 | 0 | actionToTake.setUser(user); |
1311 | 0 | return actionToTake; |
1312 | |
} |
1313 | |
|
1314 | |
public static RuleDelegationDTO convertRuleDelegation(RuleDelegation ruleDelegation) throws WorkflowException { |
1315 | 0 | if (ruleDelegation == null) { |
1316 | 0 | return null; |
1317 | |
} |
1318 | 0 | RuleDelegationDTO ruleDelegationVO = new RuleDelegationDTO(); |
1319 | 0 | ruleDelegationVO.setDelegationType(ruleDelegation.getDelegationType()); |
1320 | 0 | ruleDelegationVO.setDelegationRule(convertRule(ruleDelegation.getDelegationRuleBaseValues())); |
1321 | 0 | return ruleDelegationVO; |
1322 | |
} |
1323 | |
|
1324 | |
|
1325 | |
|
1326 | |
public static Collection<RuleExtensionDTO> convertRuleExtension(RuleExtension ruleExtension) throws WorkflowException { |
1327 | 0 | if (ruleExtension == null) { |
1328 | 0 | return null; |
1329 | |
} |
1330 | 0 | List<RuleExtensionDTO> extensionVOs = new ArrayList<RuleExtensionDTO>(); |
1331 | 0 | for (Object element : ruleExtension.getExtensionValues()) { |
1332 | 0 | RuleExtensionValue extensionValue = (RuleExtensionValue) element; |
1333 | 0 | extensionVOs.add(new RuleExtensionDTO(extensionValue.getKey(), extensionValue.getValue())); |
1334 | 0 | } |
1335 | 0 | return extensionVOs; |
1336 | |
} |
1337 | |
|
1338 | |
public static KeyValue convertRuleExtensionVO(RuleExtensionDTO ruleExtensionVO) throws WorkflowException { |
1339 | 0 | if (ruleExtensionVO == null) { |
1340 | 0 | return null; |
1341 | |
} |
1342 | 0 | return new ConcreteKeyValue(ruleExtensionVO.getKey(), ruleExtensionVO.getValue()); |
1343 | |
} |
1344 | |
|
1345 | |
public static RuleResponsibilityDTO convertRuleResponsibility(RuleResponsibility ruleResponsibility) throws WorkflowException { |
1346 | 0 | if (ruleResponsibility == null) { |
1347 | 0 | return null; |
1348 | |
} |
1349 | 0 | RuleResponsibilityDTO ruleResponsibilityVO = new RuleResponsibilityDTO(); |
1350 | 0 | ruleResponsibilityVO.setActionRequestedCd(ruleResponsibility.getActionRequestedCd()); |
1351 | 0 | ruleResponsibilityVO.setApprovePolicy(ruleResponsibility.getApprovePolicy()); |
1352 | 0 | ruleResponsibilityVO.setPriority(ruleResponsibility.getPriority()); |
1353 | 0 | ruleResponsibilityVO.setResponsibilityId(ruleResponsibility.getResponsibilityId()); |
1354 | 0 | ruleResponsibilityVO.setRoleName(ruleResponsibility.getRole()); |
1355 | 0 | if (ruleResponsibility.getPrincipal() != null) { |
1356 | 0 | ruleResponsibilityVO.setPrincipalId(ruleResponsibility.getPrincipal().getPrincipalId()); |
1357 | 0 | } else if (ruleResponsibility.getGroup() != null) { |
1358 | 0 | ruleResponsibilityVO.setGroupId(ruleResponsibility.getGroup().getId()); |
1359 | 0 | } else if (ruleResponsibility.getRole() != null) { |
1360 | 0 | ruleResponsibilityVO.setRoleName(ruleResponsibility.getRole()); |
1361 | |
} |
1362 | 0 | for (Object element : ruleResponsibility.getDelegationRules()) { |
1363 | 0 | RuleDelegation ruleDelegation = (RuleDelegation) element; |
1364 | 0 | ruleResponsibilityVO.addDelegationRule(convertRuleDelegation(ruleDelegation)); |
1365 | 0 | } |
1366 | 0 | return ruleResponsibilityVO; |
1367 | |
} |
1368 | |
|
1369 | |
|
1370 | |
|
1371 | |
|
1372 | |
public static RuleDTO convertRule(RuleBaseValues ruleValues) throws WorkflowException { |
1373 | 0 | if (ruleValues == null) { |
1374 | 0 | return null; |
1375 | |
} |
1376 | 0 | RuleDTO rule = new RuleDTO(); |
1377 | 0 | rule.setActiveInd(ruleValues.getActiveInd()); |
1378 | 0 | rule.setDescription(ruleValues.getDescription()); |
1379 | 0 | rule.setDocTypeName(ruleValues.getDocTypeName()); |
1380 | 0 | rule.setFromDate(ruleValues.getFromDateString()); |
1381 | 0 | rule.setToDate(ruleValues.getToDateString()); |
1382 | 0 | rule.setForceAction(ruleValues.getForceAction()); |
1383 | 0 | rule.setRuleTemplateId(ruleValues.getRuleTemplateId()); |
1384 | 0 | rule.setRuleTemplateName(ruleValues.getRuleTemplateName()); |
1385 | |
|
1386 | |
|
1387 | 0 | for (Object element : ruleValues.getRuleExtensions()) { |
1388 | 0 | RuleExtension ruleExtension = (RuleExtension) element; |
1389 | 0 | rule.addRuleExtensions(convertRuleExtension(ruleExtension)); |
1390 | 0 | } |
1391 | |
|
1392 | 0 | for (Object element : ruleValues.getResponsibilities()) { |
1393 | 0 | RuleResponsibility ruleResponsibility = (RuleResponsibility) element; |
1394 | 0 | rule.addRuleResponsibility(convertRuleResponsibility(ruleResponsibility)); |
1395 | 0 | } |
1396 | 0 | return rule; |
1397 | |
} |
1398 | |
|
1399 | |
public static DocSearchCriteriaDTO convertDocumentSearchCriteriaDTO(DocumentSearchCriteriaDTO criteriaVO) throws WorkflowException { |
1400 | 0 | DocSearchCriteriaDTO criteria = new DocSearchCriteriaDTO(); |
1401 | 0 | criteria.setAppDocId(criteriaVO.getAppDocId()); |
1402 | 0 | criteria.setApprover(criteriaVO.getApprover()); |
1403 | 0 | criteria.setDocRouteStatus(criteriaVO.getDocRouteStatus()); |
1404 | 0 | criteria.setDocTitle(criteriaVO.getDocTitle()); |
1405 | 0 | criteria.setDocTypeFullName(criteriaVO.getDocTypeFullName()); |
1406 | 0 | criteria.setDocVersion(criteriaVO.getDocVersion()); |
1407 | 0 | criteria.setFromDateApproved(criteriaVO.getFromDateApproved()); |
1408 | 0 | criteria.setFromDateCreated(criteriaVO.getFromDateCreated()); |
1409 | 0 | criteria.setFromDateFinalized(criteriaVO.getFromDateFinalized()); |
1410 | 0 | criteria.setFromDateLastModified(criteriaVO.getFromDateLastModified()); |
1411 | 0 | criteria.setInitiator(criteriaVO.getInitiator()); |
1412 | 0 | criteria.setIsAdvancedSearch((criteriaVO.isAdvancedSearch()) ? DocSearchCriteriaDTO.ADVANCED_SEARCH_INDICATOR_STRING : "NO"); |
1413 | 0 | criteria.setSuperUserSearch((criteriaVO.isSuperUserSearch()) ? DocSearchCriteriaDTO.SUPER_USER_SEARCH_INDICATOR_STRING : "NO"); |
1414 | 0 | criteria.setDocumentId(criteriaVO.getDocumentId()); |
1415 | 0 | criteria.setViewer(criteriaVO.getViewer()); |
1416 | 0 | criteria.setWorkgroupViewerName(criteriaVO.getGroupViewerName()); |
1417 | 0 | criteria.setToDateApproved(criteriaVO.getToDateApproved()); |
1418 | 0 | criteria.setToDateCreated(criteriaVO.getToDateCreated()); |
1419 | 0 | criteria.setToDateFinalized(criteriaVO.getToDateFinalized()); |
1420 | 0 | criteria.setToDateLastModified(criteriaVO.getToDateLastModified()); |
1421 | 0 | criteria.setThreshold(criteriaVO.getThreshold()); |
1422 | 0 | criteria.setSaveSearchForUser(criteriaVO.isSaveSearchForUser()); |
1423 | |
|
1424 | |
|
1425 | 0 | if ( (StringUtils.isNotBlank(criteriaVO.getDocRouteNodeName())) && (StringUtils.isBlank(criteriaVO.getDocTypeFullName())) ) { |
1426 | 0 | throw new WorkflowException("No document type name specified when attempting to search by route node name '" + criteriaVO.getDocRouteNodeName() + "'"); |
1427 | 0 | } else if ( (StringUtils.isNotBlank(criteriaVO.getDocRouteNodeName())) && (StringUtils.isNotBlank(criteriaVO.getDocTypeFullName())) ) { |
1428 | 0 | criteria.setDocRouteNodeLogic(criteriaVO.getDocRouteNodeLogic()); |
1429 | 0 | List routeNodes = KEWServiceLocator.getRouteNodeService().getFlattenedNodes(getDocumentTypeByName(criteria.getDocTypeFullName()), true); |
1430 | 0 | boolean foundRouteNode = false; |
1431 | 0 | for (Iterator iterator = routeNodes.iterator(); iterator.hasNext();) { |
1432 | 0 | RouteNode routeNode = (RouteNode) iterator.next(); |
1433 | 0 | if (criteriaVO.getDocRouteNodeName().equals(routeNode.getRouteNodeName())) { |
1434 | 0 | foundRouteNode = true; |
1435 | 0 | break; |
1436 | |
} |
1437 | 0 | } |
1438 | 0 | if (!foundRouteNode) { |
1439 | 0 | throw new WorkflowException("Could not find route node name '" + criteriaVO.getDocRouteNodeName() + "' for document type name '" + criteriaVO.getDocTypeFullName() + "'"); |
1440 | |
} |
1441 | 0 | criteria.setDocRouteNodeId(criteriaVO.getDocRouteNodeName()); |
1442 | |
} |
1443 | |
|
1444 | |
|
1445 | 0 | HashMap<String, List<String>> searchAttributeValues = new HashMap<String,List<String>>(); |
1446 | 0 | for (KeyValue keyValueVO : criteriaVO.getSearchAttributeValues()) { |
1447 | 0 | if (searchAttributeValues.containsKey(keyValueVO.getKey())) { |
1448 | 0 | searchAttributeValues.get(keyValueVO.getKey()).add(keyValueVO.getValue()); |
1449 | |
} else { |
1450 | 0 | searchAttributeValues.put(keyValueVO.getKey(), Arrays.asList(new String[]{keyValueVO.getValue()})); |
1451 | |
} |
1452 | |
} |
1453 | |
|
1454 | 0 | List propertyFields = new ArrayList(); |
1455 | 0 | for (String key : searchAttributeValues.keySet()) { |
1456 | 0 | List<String> values = searchAttributeValues.get(key); |
1457 | 0 | SearchAttributeFormContainer container = null; |
1458 | 0 | if (values.size() == 1) { |
1459 | 0 | container = new SearchAttributeFormContainer(key, values.get(0)); |
1460 | 0 | } else if (values.size() > 1) { |
1461 | 0 | container = new SearchAttributeFormContainer(key, (String[])values.toArray()); |
1462 | |
} |
1463 | 0 | if (container != null) { |
1464 | 0 | propertyFields.add(container); |
1465 | |
} |
1466 | 0 | } |
1467 | 0 | DocSearchUtils.addSearchableAttributesToCriteria(criteria, propertyFields, true); |
1468 | 0 | return criteria; |
1469 | |
} |
1470 | |
|
1471 | |
private static DocumentType getDocumentTypeByName(String documentTypeName) { |
1472 | 0 | return KEWServiceLocator.getDocumentTypeService().findByName(documentTypeName); |
1473 | |
} |
1474 | |
|
1475 | |
public static DocumentSearchResultDTO convertDocumentSearchResultComponents(DocumentSearchResultComponents searchResult) throws WorkflowException { |
1476 | 0 | DocumentSearchResultDTO resultsVO = new DocumentSearchResultDTO(); |
1477 | 0 | resultsVO.setSearchResults(convertDocumentSearchResults(searchResult.getSearchResults())); |
1478 | 0 | return resultsVO; |
1479 | |
} |
1480 | |
|
1481 | |
private static List<DocumentSearchResultRowDTO> convertDocumentSearchResults(List<DocumentSearchResult> searchResults) throws WorkflowException { |
1482 | 0 | List<DocumentSearchResultRowDTO> rowVOs = new ArrayList<DocumentSearchResultRowDTO>(); |
1483 | 0 | for (DocumentSearchResult documentSearchResult : searchResults) { |
1484 | 0 | rowVOs.add(convertDocumentSearchResult(documentSearchResult)); |
1485 | |
} |
1486 | 0 | return rowVOs; |
1487 | |
} |
1488 | |
|
1489 | |
public static DocumentSearchResultRowDTO convertDocumentSearchResult(DocumentSearchResult resultRow) throws WorkflowException { |
1490 | 0 | DocumentSearchResultRowDTO rowVO = new DocumentSearchResultRowDTO(); |
1491 | 0 | List<ConcreteKeyValue> fieldValues = new ArrayList<ConcreteKeyValue>(); |
1492 | 0 | for (KeyValueSort keyValueSort : resultRow.getResultContainers()) { |
1493 | 0 | fieldValues.add(new ConcreteKeyValue(keyValueSort.getKey(),keyValueSort.getUserDisplayValue())); |
1494 | |
} |
1495 | 0 | rowVO.setFieldValues(fieldValues); |
1496 | 0 | return rowVO; |
1497 | |
} |
1498 | |
|
1499 | |
public static DocumentStatusTransitionDTO convertDocumentStatusTransition(DocumentStatusTransition transition) throws WorkflowException { |
1500 | 0 | DocumentStatusTransitionDTO tranVO = new DocumentStatusTransitionDTO(); |
1501 | 0 | tranVO.setStatusTransitionId(transition.getStatusTransitionId()); |
1502 | 0 | tranVO.setDocumentId(transition.getDocumentId()); |
1503 | 0 | tranVO.setOldAppDocStatus(transition.getOldAppDocStatus()); |
1504 | 0 | tranVO.setNewAppDocStatus(transition.getNewAppDocStatus()); |
1505 | 0 | tranVO.setStatusTransitionDate(transition.getStatusTransitionDate()); |
1506 | 0 | return tranVO; |
1507 | |
} |
1508 | |
|
1509 | |
|
1510 | |
|
1511 | |
private static void handleException(String message, Exception e) throws WorkflowException { |
1512 | 0 | if (e instanceof RuntimeException) { |
1513 | 0 | throw (RuntimeException) e; |
1514 | 0 | } else if (e instanceof WorkflowException) { |
1515 | 0 | throw (WorkflowException) e; |
1516 | |
} |
1517 | 0 | throw new WorkflowException(message, e); |
1518 | |
} |
1519 | |
|
1520 | |
|
1521 | |
public static DocumentLinkDTO[] convertDocumentLink(Collection<DocumentLink> links) { |
1522 | 0 | if (links == null) { |
1523 | 0 | return null; |
1524 | |
} |
1525 | 0 | DocumentLinkDTO[] docLinkVOs = new DocumentLinkDTO[links.size()]; |
1526 | |
|
1527 | 0 | int index = 0; |
1528 | |
|
1529 | 0 | for (DocumentLink link: links) { |
1530 | 0 | docLinkVOs[index++] = convertDocumentLink(link); |
1531 | |
} |
1532 | 0 | return docLinkVOs; |
1533 | |
} |
1534 | |
|
1535 | |
|
1536 | |
public static List<DocumentLinkDTO> convertDocumentLinkToArrayList(Collection<DocumentLink> links) { |
1537 | 0 | if (links == null) { |
1538 | 0 | return null; |
1539 | |
} |
1540 | 0 | List<DocumentLinkDTO> docLinkVOs = new ArrayList<DocumentLinkDTO>(links.size()); |
1541 | |
|
1542 | 0 | for (DocumentLink link: links) { |
1543 | 0 | docLinkVOs.add(convertDocumentLink(link)); |
1544 | |
} |
1545 | 0 | return docLinkVOs; |
1546 | |
} |
1547 | |
|
1548 | |
|
1549 | |
public static DocumentLinkDTO convertDocumentLink(DocumentLink link) { |
1550 | 0 | if (link == null) { |
1551 | 0 | return null; |
1552 | |
} |
1553 | 0 | DocumentLinkDTO linkVO = new DocumentLinkDTO(); |
1554 | 0 | linkVO.setLinbkId(link.getDocLinkId()); |
1555 | 0 | linkVO.setOrgnDocId(link.getOrgnDocId()); |
1556 | 0 | linkVO.setDestDocId(link.getDestDocId()); |
1557 | |
|
1558 | 0 | return linkVO; |
1559 | |
} |
1560 | |
|
1561 | |
} |