001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.web;
018:
019: import java.util.ArrayList;
020: import java.util.HashMap;
021: import java.util.List;
022: import java.util.Map;
023:
024: import org.apache.struts.action.ActionForm;
025:
026: import edu.iu.uis.eden.EdenConstants;
027: import edu.iu.uis.eden.KEWServiceLocator;
028: import edu.iu.uis.eden.clientapp.IDocHandler;
029: import edu.iu.uis.eden.clientapp.WorkflowDocument;
030: import edu.iu.uis.eden.user.WorkflowUser;
031: import edu.iu.uis.eden.util.CodeTranslator;
032: import edu.iu.uis.eden.workgroup.WorkflowGroupId;
033: import edu.iu.uis.eden.workgroup.Workgroup;
034: import edu.iu.uis.eden.workgroup.WorkgroupService;
035:
036: /**
037: * A Struts ActionForm which can be extended by ActionForms which need to add
038: * support for document routing to a Struts Action.
039: *
040: * @author bmcgough
041: * @author rkirkend
042: */
043: public class WorkflowRoutingForm extends ActionForm {
044:
045: private static final long serialVersionUID = -3537002710069757806L;
046: private WorkflowDocument flexDoc;
047: private Long docId;
048: private String docTypeName;
049: private String initiateURL;
050: private String command;
051: private String annotation;
052:
053: //private Integer destRouteLevel;
054: private boolean showBlanketApproveButton;
055: protected Map appSpecificRouteActionRequestCds = new HashMap();
056: protected AppSpecificRouteRecipient appSpecificRouteRecipient = new AppSpecificRouteRecipient();
057: protected List appSpecificRouteList = new ArrayList();
058:
059: protected String appSpecificRouteRecipientType = "person";
060: protected String appSpecificRouteActionRequestCd;
061: protected Integer recipientIndex;
062: protected String docHandlerReturnUrl;
063: protected String removedAppSpecificRecipient;
064:
065: public void resetAppSpecificRoute() {
066: appSpecificRouteRecipient = new AppSpecificRouteRecipient();
067: }
068:
069: public Map getAppSpecificRouteActionRequestCds() {
070: return appSpecificRouteActionRequestCds;
071: }
072:
073: /**
074: * @return Returns the destRouteLevel.
075: */
076: /*public Integer getDestRouteLevel() {
077: return destRouteLevel;
078: }*/
079:
080: /**
081: * @param destRouteLevel The destRouteLevel to set.
082: */
083: /*public void setDestRouteLevel(Integer destRouteLevel) {
084: this.destRouteLevel = destRouteLevel;
085: }*/
086: /**
087: * @return Returns the initiateURL.
088: */
089: public String getInitiateURL() {
090: return initiateURL;
091: }
092:
093: /**
094: * @param initiateURL The initiateURL to set.
095: */
096: public void setInitiateURL(String initiateURL) {
097: this .initiateURL = initiateURL;
098: }
099:
100: /**
101: * @return Returns the command.
102: */
103: public String getCommand() {
104: return command;
105: }
106:
107: /**
108: * @param command The command to set.
109: */
110: public void setCommand(String command) {
111: this .command = command;
112: }
113:
114: /**
115: * @return Returns the annotation.
116: */
117: public String getAnnotation() {
118: return annotation;
119: }
120:
121: /**
122: * @param annotation The annotation to set.
123: */
124: public void setAnnotation(String annotation) {
125: this .annotation = annotation;
126: }
127:
128: /**
129: * @return Returns the showBlanketApproveButton.
130: */
131: public boolean isShowBlanketApproveButton() {
132: return showBlanketApproveButton;
133: }
134:
135: /**
136: * @param showBlanketApproveButton The showBlanketApproveButton to set.
137: */
138: public void setShowBlanketApproveButton(boolean blanketApprove) {
139: this .showBlanketApproveButton = blanketApprove;
140: }
141:
142: /**
143: * @return Returns the docId.
144: */
145: public Long getDocId() {
146: return docId;
147: }
148:
149: /**
150: * @param docId The docId to set.
151: */
152: public void setDocId(Long docId) {
153: this .docId = docId;
154: }
155:
156: /**
157: * @return Returns the flexDoc.
158: */
159: public WorkflowDocument getFlexDoc() {
160: return flexDoc;
161: }
162:
163: /**
164: * @param flexDoc The flexDoc to set.
165: */
166: public void setFlexDoc(WorkflowDocument flexDoc) {
167: this .flexDoc = flexDoc;
168: }
169:
170: /**
171: * @return Returns the previousRouteLevels.
172: */
173: /*public List getPreviousRouteLevels() {
174: List previousRouteLevels = new ArrayList();
175: if (flexDoc != null && flexDoc.getDocRouteLevel() != null) {
176: for (int i = flexDoc.getDocRouteLevel().intValue(); i > 0; --i) {
177: previousRouteLevels.add(new KeyValue(Integer.toString(i - 1), Integer.toString(i - 1)));
178: }
179: }
180: return previousRouteLevels;
181: }*/
182: /**
183: * @return Returns the superUserSearch.
184: */
185: public boolean isSuperUserSearch() {
186: return (command != null && command
187: .equals(IDocHandler.SUPERUSER_COMMAND));
188: }
189:
190: public String getDocTypeName() {
191: return docTypeName;
192: }
193:
194: public void setDocTypeName(String docTypeName) {
195: this .docTypeName = docTypeName;
196: }
197:
198: public void setAppSpecificPersonId(String networkId) {
199: if (networkId != null && !networkId.trim().equals("")) {
200: getAppSpecificRouteRecipient().setId(networkId);
201: }
202: getAppSpecificRouteRecipient().setType("person");
203: }
204:
205: public void setAppSpecificWorkgroupId(Long workgroupId) {
206: if (workgroupId != null) {
207: Workgroup workgroup = getWorkgroupService().getWorkgroup(
208: new WorkflowGroupId(workgroupId));
209: if (workgroup != null) {
210: getAppSpecificRouteRecipient().setId(
211: workgroup.getGroupNameId().getNameId());
212: }
213: }
214: getAppSpecificRouteRecipient().setType("workgroup");
215: }
216:
217: private WorkgroupService getWorkgroupService() {
218: return (WorkgroupService) KEWServiceLocator
219: .getService(KEWServiceLocator.WORKGROUP_SRV);
220: }
221:
222: public AppSpecificRouteRecipient getAppSpecificRouteRecipient() {
223: return appSpecificRouteRecipient;
224: }
225:
226: public void setAppSpecificRouteRecipient(
227: AppSpecificRouteRecipient appSpecificRouteRecipient) {
228: this .appSpecificRouteRecipient = appSpecificRouteRecipient;
229: }
230:
231: public List getAppSpecificRouteList() {
232: return appSpecificRouteList;
233: }
234:
235: public void setAppSpecificRouteList(List appSpecificRouteList) {
236: this .appSpecificRouteList = appSpecificRouteList;
237: }
238:
239: public void setAppSpecificRouteRecipientType(
240: String appSpecificRouteRecipientType) {
241: this .appSpecificRouteRecipientType = appSpecificRouteRecipientType;
242: }
243:
244: public String getAppSpecificRouteRecipientType() {
245: return appSpecificRouteRecipientType;
246: }
247:
248: public AppSpecificRouteRecipient getAppSpecificRoute(int index) {
249: while (getAppSpecificRouteList().size() <= index) {
250: getAppSpecificRouteList().add(
251: new AppSpecificRouteRecipient());
252: }
253: return (AppSpecificRouteRecipient) getAppSpecificRouteList()
254: .get(index);
255: }
256:
257: public void setAppSpecificRoute(int index,
258: AppSpecificRouteRecipient appSpecificRouteRecipient) {
259: appSpecificRouteList.set(index, appSpecificRouteRecipient);
260: }
261:
262: public String getAppSpecificRouteActionRequestCd() {
263: return appSpecificRouteActionRequestCd;
264: }
265:
266: public void setAppSpecificRouteActionRequestCd(
267: String appSpecificRouteActionRequestCd) {
268: this .appSpecificRouteActionRequestCd = appSpecificRouteActionRequestCd;
269: }
270:
271: public Integer getRecipientIndex() {
272: return recipientIndex;
273: }
274:
275: public void setRecipientIndex(Integer recipientIndex) {
276: this .recipientIndex = recipientIndex;
277: }
278:
279: public void establishVisibleActionRequestCds() {
280: try {
281: if (getFlexDoc() != null) {
282: Long docId = flexDoc.getRouteHeaderId();
283: Workgroup suWorkgroup = KEWServiceLocator
284: .getRouteHeaderService().getRouteHeader(docId)
285: .getDocumentType().getSuperUserWorkgroup();
286: WorkflowUser docUser = KEWServiceLocator
287: .getUserService().getWorkflowUser(
288: flexDoc.getUserId());
289: boolean isSuperUser = suWorkgroup.hasMember(docUser);
290: if (isSuperUser) {
291: appSpecificRouteActionRequestCds = CodeTranslator.arLabels;
292: } else if (flexDoc.isFYIRequested()) {
293: appSpecificRouteActionRequestCds.clear();
294: appSpecificRouteActionRequestCds.put(
295: EdenConstants.ACTION_REQUEST_FYI_REQ,
296: EdenConstants.ACTION_REQUEST_FYI_REQ_LABEL);
297: } else if (flexDoc.isAcknowledgeRequested()) {
298: appSpecificRouteActionRequestCds.clear();
299: appSpecificRouteActionRequestCds
300: .put(
301: EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
302: EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
303: appSpecificRouteActionRequestCds.put(
304: EdenConstants.ACTION_REQUEST_FYI_REQ,
305: EdenConstants.ACTION_REQUEST_FYI_REQ_LABEL);
306: } else if (flexDoc.isApprovalRequested()
307: || flexDoc.isCompletionRequested()
308: || flexDoc.stateIsInitiated()) {
309: appSpecificRouteActionRequestCds = CodeTranslator.arLabels;
310: }
311: }
312: } catch (Exception e) {
313: throw new RuntimeException(
314: "Caught exception building ad hoc action dropdown",
315: e);
316: }
317: }
318:
319: public String getDocHandlerReturnUrl() {
320: return docHandlerReturnUrl;
321: }
322:
323: public void setDocHandlerReturnUrl(String docHandlerReturnUrl) {
324: this .docHandlerReturnUrl = docHandlerReturnUrl;
325: }
326:
327: public String getRemovedAppSpecificRecipient() {
328: return removedAppSpecificRecipient;
329: }
330:
331: public void setRemovedAppSpecificRecipient(
332: String removedAppSpecificRecipient) {
333: this.removedAppSpecificRecipient = removedAppSpecificRecipient;
334: }
335: }
|