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