001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.core.workflow.service.impl;
017:
018: import org.apache.log4j.Logger;
019: import org.kuali.RiceConstants;
020: import org.kuali.core.util.spring.Cached;
021: import org.kuali.core.workflow.service.KualiWorkflowInfo;
022: import org.springframework.transaction.annotation.Transactional;
023:
024: import edu.iu.uis.eden.clientapp.WorkflowInfo;
025: import edu.iu.uis.eden.clientapp.vo.ActionRequestVO;
026: import edu.iu.uis.eden.clientapp.vo.ActionTakenVO;
027: import edu.iu.uis.eden.clientapp.vo.DocumentTypeVO;
028: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
029: import edu.iu.uis.eden.clientapp.vo.ReportCriteriaVO;
030: import edu.iu.uis.eden.clientapp.vo.RouteHeaderVO;
031: import edu.iu.uis.eden.clientapp.vo.RouteTemplateEntryVO;
032: import edu.iu.uis.eden.clientapp.vo.UserIdVO;
033: import edu.iu.uis.eden.clientapp.vo.UserVO;
034: import edu.iu.uis.eden.clientapp.vo.WorkflowGroupIdVO;
035: import edu.iu.uis.eden.clientapp.vo.WorkgroupIdVO;
036: import edu.iu.uis.eden.clientapp.vo.WorkgroupNameIdVO;
037: import edu.iu.uis.eden.clientapp.vo.WorkgroupVO;
038: import edu.iu.uis.eden.exception.InvalidWorkgroupException;
039: import edu.iu.uis.eden.exception.WorkflowException;
040: import edu.iu.uis.eden.exception.WorkflowRuntimeException;
041: import edu.iu.uis.eden.util.Utilities;
042:
043: @SuppressWarnings("deprecation")
044: @Transactional
045: public class KualiWorkflowInfoImpl implements KualiWorkflowInfo {
046:
047: private static final Logger LOG = Logger
048: .getLogger(KualiWorkflowInfoImpl.class);
049:
050: private WorkflowInfo workflowInfo;
051:
052: public KualiWorkflowInfoImpl() {
053: workflowInfo = new WorkflowInfo();
054: }
055:
056: private WorkflowInfo getWorkflowUtility() {
057: return workflowInfo;
058: }
059:
060: public RouteHeaderVO getRouteHeader(UserIdVO userId,
061: Long routeHeaderId) throws WorkflowException {
062: return getWorkflowUtility().getRouteHeader(userId,
063: routeHeaderId);
064: }
065:
066: public RouteHeaderVO getRouteHeader(Long routeHeaderId)
067: throws WorkflowException {
068: try {
069: return getWorkflowUtility().getRouteHeader(
070: new NetworkIdVO(RiceConstants.SYSTEM_USER),
071: routeHeaderId);
072: } catch (Exception e) {
073: throw new WorkflowException(e);
074: }
075: }
076:
077: /**
078: * @deprecated
079: */
080: public WorkgroupVO getWorkgroup(String workgroupName)
081: throws WorkflowException {
082: if (Utilities.isEmpty(workgroupName)) {
083: throw new InvalidWorkgroupException(
084: "Workgroup name cannot be empty");
085: }
086: return getWorkgroup(new WorkgroupNameIdVO(workgroupName));// getWorkflowUtility().getWorkgroup(new
087: // WorkgroupNameIdVO(workgroupName));
088: }
089:
090: /**
091: * @deprecated
092: */
093: public WorkgroupVO getWorkgroup(Long workgroupId)
094: throws WorkflowException {
095: if (workgroupId == null) {
096: throw new InvalidWorkgroupException(
097: "Workgroup name cannot be empty");
098: }
099: return getWorkgroup(new WorkflowGroupIdVO(workgroupId));
100: }
101:
102: public WorkgroupVO getWorkgroup(WorkgroupIdVO workgroupId)
103: throws WorkflowException {
104: try {
105: return getWorkflowUtility().getWorkgroup(workgroupId);
106: } catch (Exception e) {
107: throw new WorkflowException(e);
108: }
109: }
110:
111: @Cached
112: public UserVO getWorkflowUser(UserIdVO userId)
113: throws WorkflowException {
114: try {
115: return getWorkflowUtility().getWorkflowUser(userId);
116: } catch (Exception e) {
117: throw new WorkflowException(e);
118: }
119: }
120:
121: /**
122: * @deprecated use getDocType using the name
123: */
124: public RouteTemplateEntryVO[] getRoute(String documentTypeName)
125: throws WorkflowException {
126: try {
127: return getWorkflowUtility().getRoute(documentTypeName);
128: } catch (Exception e) {
129: throw new WorkflowException(e);
130: }
131: }
132:
133: public DocumentTypeVO getDocType(Long documentTypeId)
134: throws WorkflowException {
135: try {
136: return getWorkflowUtility().getDocType(documentTypeId);
137: } catch (Exception e) {
138: throw new WorkflowException(e);
139: }
140: }
141:
142: public DocumentTypeVO getDocType(String documentTypeName)
143: throws WorkflowException {
144: try {
145: // throw new WorkflowException("not supported");
146: return getWorkflowUtility().getDocType(documentTypeName);
147: } catch (Exception e) {
148: throw new WorkflowException(e);
149: }
150: }
151:
152: public Long getNewResponsibilityId() throws WorkflowException {
153: try {
154: return getWorkflowUtility().getNewResponsibilityId();
155: } catch (Exception e) {
156: throw new WorkflowException(e);
157: }
158: }
159:
160: public WorkgroupVO[] getUserWorkgroups(UserIdVO userId)
161: throws WorkflowException {
162: try {
163: return getWorkflowUtility().getUserWorkgroups(userId);
164: } catch (Exception e) {
165: throw new WorkflowException(e);
166: }
167: }
168:
169: public ActionRequestVO[] getActionRequests(Long routeHeaderId)
170: throws WorkflowException {
171: try {
172: return getWorkflowUtility()
173: .getActionRequests(routeHeaderId);
174: } catch (Exception e) {
175: throw new WorkflowException(e);
176: }
177: }
178:
179: public ActionRequestVO[] getActionRequests(Long routeHeaderId,
180: String nodeName, UserIdVO userId) throws WorkflowException {
181: try {
182: return getWorkflowUtility().getActionRequests(
183: routeHeaderId, nodeName, userId);
184: } catch (Exception e) {
185: throw new WorkflowException(e);
186: }
187: }
188:
189: public ActionTakenVO[] getActionsTaken(Long routeHeaderId)
190: throws WorkflowException {
191: try {
192: return getWorkflowUtility().getActionsTaken(routeHeaderId);
193: } catch (Exception e) {
194: throw new WorkflowException(e);
195: }
196: }
197:
198: public void reResolveRole(String documentTypeName, String roleName,
199: String qualifiedRoleNameLabel) throws WorkflowException {
200: try {
201: getWorkflowUtility().reResolveRole(documentTypeName,
202: roleName, qualifiedRoleNameLabel);
203: } catch (Exception e) {
204: throw new WorkflowException(e);
205: }
206: }
207:
208: public void reResolveRole(Long routeHeaderId, String roleName,
209: String qualifiedRoleNameLabel) throws WorkflowException {
210: try {
211: getWorkflowUtility().reResolveRole(routeHeaderId, roleName,
212: qualifiedRoleNameLabel);
213: } catch (Exception e) {
214: throw new WorkflowException(e);
215: }
216: }
217:
218: /**
219: *
220: * @see org.kuali.core.workflow.service.KualiWorkflowInfo#routeHeaderExists(java.lang.Long)
221: */
222: public boolean routeHeaderExists(Long routeHeaderId) {
223: if (routeHeaderId == null) {
224: throw new IllegalArgumentException(
225: "Null argument passed in for routeHeaderId.");
226: }
227:
228: RouteHeaderVO routeHeader = null;
229: try {
230: routeHeader = getRouteHeader(routeHeaderId);
231: } catch (WorkflowException e) {
232: LOG.error("Caught Exception from workflow", e);
233: throw new WorkflowRuntimeException(e);
234: }
235:
236: if (routeHeader == null) {
237: return false;
238: } else {
239: return true;
240: }
241: }
242:
243: /**
244: * @see org.kuali.core.workflow.service.KualiWorkflowInfo#documentWillHaveAtLeastOneActionRequest(java.lang.Long, java.lang.String, java.lang.String[])
245: */
246: public boolean documentWillHaveAtLeastOneActionRequest(
247: ReportCriteriaVO reportCriteriaVO,
248: String[] actionRequestedCodes) throws WorkflowException {
249: try {
250: return getWorkflowUtility()
251: .documentWillHaveAtLeastOneActionRequest(
252: reportCriteriaVO, actionRequestedCodes);
253: } catch (Exception e) {
254: throw new WorkflowException(e);
255: }
256: }
257: }
|