01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.kuali.workflow.workgroup.web;
18:
19: import javax.servlet.http.HttpServletRequest;
20: import javax.servlet.http.HttpServletResponse;
21:
22: import org.apache.commons.lang.StringUtils;
23: import org.apache.struts.action.ActionForm;
24: import org.apache.struts.action.ActionForward;
25: import org.apache.struts.action.ActionMapping;
26: import org.apache.struts.action.ActionMessages;
27: import org.kuali.workflow.workgroup.WorkgroupType;
28: import org.kuali.workflow.workgroup.WorkgroupTypeService;
29:
30: import edu.iu.uis.eden.KEWServiceLocator;
31: import edu.iu.uis.eden.export.ExportDataSet;
32: import edu.iu.uis.eden.export.ExportFormat;
33: import edu.iu.uis.eden.routetemplate.RuleTemplate;
34: import edu.iu.uis.eden.routetemplate.RuleTemplateService;
35: import edu.iu.uis.eden.web.WorkflowAction;
36:
37: /**
38: * A Struts Action for interactig with {@link RuleTemplate}s.
39: *
40: * @see RuleTemplateService
41: *
42: * @author rkirkend
43: * @author bmcgough
44: * @author jhopf
45: */
46: public class WorkgroupTypeAction extends WorkflowAction {
47:
48: public ActionForward start(ActionMapping mapping, ActionForm form,
49: HttpServletRequest request, HttpServletResponse response)
50: throws Exception {
51: return report(mapping, form, request, response);
52: }
53:
54: public ActionMessages establishRequiredState(
55: HttpServletRequest request, ActionForm form)
56: throws Exception {
57: return null;
58: }
59:
60: public ActionForward report(ActionMapping mapping, ActionForm form,
61: HttpServletRequest request, HttpServletResponse response)
62: throws Exception {
63: WorkgroupTypeForm workgroupTypeForm = (WorkgroupTypeForm) form;
64: if (workgroupTypeForm.getWorkgroupTypeId() != null) {
65: WorkgroupType workgroupType = getWorkgroupTypeService()
66: .findById(workgroupTypeForm.getWorkgroupTypeId());
67: workgroupTypeForm.setWorkgroupType(workgroupType);
68: } else if (!StringUtils.isBlank(workgroupTypeForm.getName())) {
69: WorkgroupType workgroupType = getWorkgroupTypeService()
70: .findByName(workgroupTypeForm.getName());
71: workgroupTypeForm.setWorkgroupType(workgroupType);
72: }
73: return mapping.findForward("report");
74: }
75:
76: public ActionForward export(ActionMapping mapping, ActionForm form,
77: HttpServletRequest request, HttpServletResponse response)
78: throws Exception {
79: WorkgroupTypeForm workgroupTypeForm = (WorkgroupTypeForm) form;
80: ExportDataSet dataSet = new ExportDataSet(ExportFormat.XML);
81: if (workgroupTypeForm.getWorkgroupTypeId() != null) {
82: WorkgroupType workgroupType = getWorkgroupTypeService()
83: .findById(workgroupTypeForm.getWorkgroupTypeId());
84: dataSet.getWorkgroupTypes().add(workgroupType);
85: }
86: return exportDataSet(request, dataSet);
87: }
88:
89: private WorkgroupTypeService getWorkgroupTypeService() {
90: return (WorkgroupTypeService) KEWServiceLocator
91: .getWorkgroupTypeService();
92: }
93:
94: }
|