1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.workflow.service.impl; |
17 | |
|
18 | |
import java.rmi.RemoteException; |
19 | |
import java.util.ArrayList; |
20 | |
import java.util.List; |
21 | |
|
22 | |
import org.apache.log4j.Logger; |
23 | |
import org.kuali.rice.kew.dto.ActionItemDTO; |
24 | |
import org.kuali.rice.kew.dto.ActionRequestDTO; |
25 | |
import org.kuali.rice.kew.dto.ActionTakenDTO; |
26 | |
import org.kuali.rice.kew.dto.DocumentSearchCriteriaDTO; |
27 | |
import org.kuali.rice.kew.dto.DocumentSearchResultDTO; |
28 | |
import org.kuali.rice.kew.dto.DocumentTypeDTO; |
29 | |
import org.kuali.rice.kew.dto.ReportCriteriaDTO; |
30 | |
import org.kuali.rice.kew.dto.RouteHeaderDTO; |
31 | |
import org.kuali.rice.kew.exception.WorkflowException; |
32 | |
import org.kuali.rice.kew.exception.WorkflowRuntimeException; |
33 | |
import org.kuali.rice.kew.service.WorkflowInfo; |
34 | |
import org.kuali.rice.kew.util.KEWConstants; |
35 | |
import org.kuali.rice.kim.api.entity.principal.Principal; |
36 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
37 | |
|
38 | |
import org.kuali.rice.kns.util.KNSConstants; |
39 | |
import org.kuali.rice.kns.workflow.service.KualiWorkflowInfo; |
40 | |
import org.springframework.transaction.annotation.Transactional; |
41 | |
|
42 | |
|
43 | |
@SuppressWarnings("deprecation") |
44 | |
@Transactional |
45 | |
public class KualiWorkflowInfoImpl implements KualiWorkflowInfo { |
46 | |
|
47 | 0 | private static final Logger LOG = Logger.getLogger(KualiWorkflowInfoImpl.class); |
48 | |
|
49 | |
private WorkflowInfo workflowInfo; |
50 | |
|
51 | 0 | public KualiWorkflowInfoImpl() { |
52 | 0 | workflowInfo = new WorkflowInfo(); |
53 | 0 | } |
54 | |
|
55 | |
private WorkflowInfo getWorkflowUtility() { |
56 | 0 | return workflowInfo; |
57 | |
} |
58 | |
|
59 | |
public RouteHeaderDTO getRouteHeader(String principalId, String documentId) throws WorkflowException { |
60 | 0 | return getWorkflowUtility().getRouteHeader(principalId, documentId); |
61 | |
} |
62 | |
|
63 | |
public RouteHeaderDTO getRouteHeader(String documentId) throws WorkflowException { |
64 | 0 | Principal principal = KimApiServiceLocator.getIdentityManagementService().getPrincipalByPrincipalName(KNSConstants.SYSTEM_USER); |
65 | 0 | if (principal == null) { |
66 | 0 | throw new WorkflowException("Failed to locate System User with principal name 'kr'"); |
67 | |
} |
68 | 0 | return getWorkflowUtility().getRouteHeader(principal.getPrincipalId(), documentId); |
69 | |
} |
70 | |
|
71 | |
public DocumentTypeDTO getDocType(Long documentTypeId) throws WorkflowException { |
72 | 0 | return getWorkflowUtility().getDocType(documentTypeId); |
73 | |
} |
74 | |
|
75 | |
public DocumentTypeDTO getDocType(String documentTypeName) throws WorkflowException { |
76 | 0 | return getWorkflowUtility().getDocType(documentTypeName); |
77 | |
} |
78 | |
|
79 | |
public Long getNewResponsibilityId() throws WorkflowException { |
80 | 0 | return getWorkflowUtility().getNewResponsibilityId(); |
81 | |
} |
82 | |
|
83 | |
public ActionRequestDTO[] getActionRequests(String documentId) throws WorkflowException { |
84 | 0 | return getWorkflowUtility().getActionRequests(documentId); |
85 | |
} |
86 | |
|
87 | |
public ActionRequestDTO[] getActionRequests(String documentId, String nodeName, String principalId) throws WorkflowException { |
88 | 0 | return getWorkflowUtility().getActionRequests(documentId, nodeName, principalId); |
89 | |
} |
90 | |
|
91 | |
public ActionTakenDTO[] getActionsTaken(String documentId) throws WorkflowException { |
92 | 0 | return getWorkflowUtility().getActionsTaken(documentId); |
93 | |
} |
94 | |
|
95 | |
public void reResolveRoleByDocTypeName(String documentTypeName, String roleName, String qualifiedRoleNameLabel) throws WorkflowException { |
96 | 0 | getWorkflowUtility().reResolveRoleByDocTypeName(documentTypeName, roleName, qualifiedRoleNameLabel); |
97 | 0 | } |
98 | |
|
99 | |
public void reResolveRoleByDocumentId(String documentId, String roleName, String qualifiedRoleNameLabel) throws WorkflowException { |
100 | 0 | getWorkflowUtility().reResolveRoleByDocumentId(documentId, roleName, qualifiedRoleNameLabel); |
101 | 0 | } |
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public boolean routeHeaderExists(String documentId) { |
108 | 0 | if (documentId == null) { |
109 | 0 | throw new IllegalArgumentException("Null argument passed in for documentId."); |
110 | |
} |
111 | |
|
112 | 0 | RouteHeaderDTO routeHeader = null; |
113 | |
try { |
114 | 0 | routeHeader = getRouteHeader(documentId); |
115 | |
} |
116 | 0 | catch (WorkflowException e) { |
117 | 0 | LOG.error("Caught Exception from workflow", e); |
118 | 0 | throw new WorkflowRuntimeException(e); |
119 | 0 | } |
120 | |
|
121 | 0 | if (routeHeader == null) { |
122 | 0 | return false; |
123 | |
} |
124 | |
else { |
125 | 0 | return true; |
126 | |
} |
127 | |
} |
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
public boolean documentWillHaveAtLeastOneActionRequest(ReportCriteriaDTO reportCriteriaDTO, String[] actionRequestedCodes) throws WorkflowException { |
134 | 0 | return documentWillHaveAtLeastOneActionRequest(reportCriteriaDTO, actionRequestedCodes, false); |
135 | |
} |
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
public boolean documentWillHaveAtLeastOneActionRequest(ReportCriteriaDTO reportCriteriaDTO, String[] actionRequestedCodes, boolean ignoreCurrentlyActiveRequests) throws WorkflowException { |
141 | 0 | return getWorkflowUtility().documentWillHaveAtLeastOneActionRequest(reportCriteriaDTO, actionRequestedCodes, ignoreCurrentlyActiveRequests); |
142 | |
} |
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
public List<String> getApprovalRequestedUsers(String documentId) throws WorkflowException { |
148 | 0 | ActionItemDTO[] actionItemVOs = getWorkflowUtility().getActionItems(documentId, new String[]{KEWConstants.ACTION_REQUEST_COMPLETE_REQ, KEWConstants.ACTION_REQUEST_APPROVE_REQ}); |
149 | 0 | List<String> users = new ArrayList<String>(); |
150 | 0 | for (int i = 0; i < actionItemVOs.length; i++) { |
151 | 0 | ActionItemDTO actionItemVO = actionItemVOs[i]; |
152 | 0 | users.add(actionItemVO.getPrincipalId()); |
153 | |
} |
154 | 0 | return users; |
155 | |
} |
156 | |
|
157 | |
public DocumentSearchResultDTO performDocumentSearch(DocumentSearchCriteriaDTO criteriaVO) throws WorkflowException { |
158 | 0 | return getWorkflowUtility().performDocumentSearch(criteriaVO); |
159 | |
} |
160 | |
|
161 | |
public DocumentSearchResultDTO performDocumentSearch(String principalId, DocumentSearchCriteriaDTO criteriaVO) throws RemoteException, WorkflowException { |
162 | 0 | return getWorkflowUtility().performDocumentSearch(principalId, criteriaVO); |
163 | |
} |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
public boolean isCurrentActiveDocumentType(String documentTypeName) throws WorkflowException { |
171 | 0 | return getWorkflowUtility().isCurrentActiveDocumentType( documentTypeName ); |
172 | |
} |
173 | |
} |