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