View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    *
4    *
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    * http://www.opensource.org/licenses/ecl2.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.rice.kew.rule.web;
18  
19  import org.apache.commons.lang.StringUtils;
20  import org.apache.struts.action.ActionErrors;
21  import org.apache.struts.action.ActionMapping;
22  import org.apache.struts.action.ActionMessage;
23  import org.apache.struts.action.ActionMessages;
24  import org.kuali.rice.core.api.util.ConcreteKeyValue;
25  import org.kuali.rice.core.api.util.KeyValue;
26  import org.kuali.rice.kew.doctype.bo.DocumentType;
27  import org.kuali.rice.kew.doctype.service.DocumentTypeService;
28  import org.kuali.rice.kew.service.KEWServiceLocator;
29  import org.kuali.rice.kew.util.KEWConstants;
30  import org.kuali.rice.kns.web.struts.form.KualiForm;
31  import org.kuali.rice.kns.web.ui.Row;
32  
33  import javax.servlet.http.HttpServletRequest;
34  import java.util.ArrayList;
35  import java.util.HashMap;
36  import java.util.List;
37  import java.util.Map;
38  
39  
40  /**
41   * Struts ActionForm for the {@link RoutingReportAction}.
42   *
43   * @author Kuali Rice Team (rice.collab@kuali.org)
44   */
45  public class RoutingReportForm extends KualiForm {
46  
47  	private static final long serialVersionUID = 509542372934250061L;
48  
49      private String ruleTemplateId;
50      private String lookupableImplServiceName;
51      private String documentType;
52      private String reportType;
53  
54      // fields below used for document type report URL
55      private String documentTypeParam;
56      private String initiatorPrincipalId;
57      private String documentContent;
58      private String backUrl;
59      private String showCloseButton;
60  
61      private String dateRef;
62      private String effectiveHour;
63      private String effectiveMinute;
64      private String amPm;
65  
66      private List ruleTemplates;
67      private List actionRequests;
68      private Map fields;
69  
70      /*chb: 15Jan2009
71      ruleTemplateAttributes is set by RoutingReportAction.loadRuleTemplateOnForm(...)
72      */
73      private List<Row> ruleTemplateAttributes;
74      private List attributes;
75  
76      private boolean showFields;
77      private boolean showViewResults;
78  
79      public RoutingReportForm() {
80          attributes = new ArrayList();
81          ruleTemplates = new ArrayList();
82          actionRequests = new ArrayList();
83          fields = new HashMap();
84          ruleTemplateAttributes = new ArrayList();
85      }
86  
87      @Override
88  	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
89  
90          ActionErrors errors = new ActionErrors();
91          if (getReportType() != null && getReportType().equals(RoutingReportAction.DOC_TYPE_REPORTING)) {
92              if (!org.apache.commons.lang.StringUtils.isEmpty(getDocumentType())) {
93                  DocumentType docType = getDocumentTypeService().findByName(getDocumentType());
94                  if (docType == null) {
95                      ActionMessage error = new ActionMessage("routereport.documenttype.invalid");
96                      errors.add(ActionMessages.GLOBAL_MESSAGE, error);
97                  }
98              }
99          }
100         return errors;
101     }
102 
103     public String getLookupableImplServiceName() {
104         return lookupableImplServiceName;
105     }
106 
107     public void setLookupableImplServiceName(String lookupableImplServiceName) {
108         this.lookupableImplServiceName = lookupableImplServiceName;
109     }
110 
111     public List<Row> getRuleTemplateAttributes() {
112         return ruleTemplateAttributes;
113     }
114 
115     //chb: 15Jan2009 set in RoutingReportAction.loadRuleTemplateOnForm(...)
116     public void setRuleTemplateAttributes(List<Row> ruleTemplateAttributes) {
117         this.ruleTemplateAttributes = ruleTemplateAttributes;
118     }
119 
120     public Map getFields() {
121         return fields;
122     }
123 
124     public void setFields(Map fields) {
125         this.fields = fields;
126     }
127 
128     public List getRuleTemplates() {
129         return ruleTemplates;
130     }
131 
132     public void setRuleTemplates(List ruleTemplates) {
133         this.ruleTemplates = ruleTemplates;
134     }
135 
136     public List<KeyValue> getHours() {
137     	List<KeyValue> hours = new ArrayList<KeyValue>();
138         hours.add(new ConcreteKeyValue("0", "12"));
139         for (int i = 1; i < 12; i++) {
140             hours.add(new ConcreteKeyValue(i + "", i + ""));
141         }
142         return hours;
143     }
144     public List<KeyValue> getMinutes() {
145     	List<KeyValue> mins = new ArrayList<KeyValue>();
146         for (int i = 0; i < 60; i++) {
147             mins.add(new ConcreteKeyValue(i + "", ":" + (i < 10 ? "0" : "") + i + ""));
148         }
149         return mins;
150     }
151 
152     public String getRuleTemplateId() {
153         return ruleTemplateId;
154     }
155 
156     public void setRuleTemplateId(String ruleTemplateId) {
157         this.ruleTemplateId = ruleTemplateId;
158     }
159 
160     public List getActionRequests() {
161         return actionRequests;
162     }
163 
164     public void setActionRequests(List actionRequests) {
165         this.actionRequests = actionRequests;
166     }
167 
168     public void setDocTypeFullName(String documentType) {
169         this.documentType = documentType;
170     }
171 
172     public void setDocTypeGroupName(String docTypeGroupName) {
173         this.documentType = docTypeGroupName;
174     }
175 
176     public String getDocumentType() {
177         return documentType;
178     }
179 
180     public void setDocumentType(String documentType) {
181         this.documentType = documentType;
182     }
183 
184     public List getAttributes() {
185         return attributes;
186     }
187 
188     public void setAttributes(List attributes) {
189         this.attributes = attributes;
190     }
191 
192     public String getReportType() {
193         return reportType;
194     }
195 
196     public void setReportType(String reportType) {
197         this.reportType = reportType;
198     }
199 
200     public boolean isShowFields() {
201         return showFields;
202     }
203 
204     public void setShowFields(boolean showFields) {
205         this.showFields = showFields;
206     }
207 
208     public boolean isShowViewResults() {
209         return showViewResults;
210     }
211 
212     public void setShowViewResults(boolean showViewResults) {
213         this.showViewResults = showViewResults;
214     }
215 
216     private DocumentTypeService getDocumentTypeService() {
217         return (DocumentTypeService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE);
218     }
219 
220     public String getDateRef() {
221         return dateRef;
222     }
223 
224     public void setDateRef(String dateRef) {
225         this.dateRef = dateRef;
226     }
227 
228     public String getEffectiveHour() {
229         return effectiveHour;
230     }
231 
232     public void setEffectiveHour(String effectiveHour) {
233         this.effectiveHour = effectiveHour;
234     }
235 
236     public String getEffectiveMinute() {
237         return effectiveMinute;
238     }
239 
240     public void setEffectiveMinute(String effectiveMinute) {
241         this.effectiveMinute = effectiveMinute;
242     }
243 
244     public String getAmPm() {
245         return amPm;
246     }
247 
248     public void setAmPm(String amPm) {
249         this.amPm = amPm;
250     }
251 
252     public String getDocumentContent() {
253         return documentContent;
254     }
255 
256     public void setDocumentContent(String documentContent) {
257         this.documentContent = documentContent;
258     }
259 
260     public String getInitiatorPrincipalId() {
261         return initiatorPrincipalId;
262     }
263 
264     public void setInitiatorPrincipalId(String initiatorNetworkId) {
265         this.initiatorPrincipalId = initiatorNetworkId;
266     }
267 
268     public String getBackUrl() {
269         if (StringUtils.isBlank(backUrl)) {
270             return null;
271         }
272         return backUrl;
273     }
274 
275     public void setBackUrl(String backUrl) {
276         this.backUrl = backUrl;
277     }
278 
279     public boolean isDisplayCloseButton() {
280         return (KEWConstants.DISPLAY_CLOSE_BUTTON_TRUE_VALUE.equals(getShowCloseButton()));
281     }
282 
283     public String getShowCloseButton() {
284         return showCloseButton;
285     }
286 
287     public void setShowCloseButton(String showCloseButton) {
288         this.showCloseButton = showCloseButton;
289     }
290 
291     public String getDocumentTypeParam() {
292         return documentTypeParam;
293     }
294 
295     public void setDocumentTypeParam(String documentTypeParam) {
296         this.documentTypeParam = documentTypeParam;
297         this.documentType = documentTypeParam;
298     }
299 
300 }