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.routetemplate.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 javax.servlet.http.HttpServletRequest;
025:
026: import org.apache.commons.lang.StringUtils;
027: import org.apache.struts.action.ActionErrors;
028: import org.apache.struts.action.ActionForm;
029: import org.apache.struts.action.ActionMapping;
030: import org.apache.struts.action.ActionMessage;
031: import org.apache.struts.action.ActionMessages;
032:
033: import edu.iu.uis.eden.KEWServiceLocator;
034: import edu.iu.uis.eden.doctype.DocumentType;
035: import edu.iu.uis.eden.doctype.DocumentTypeService;
036: import edu.iu.uis.eden.util.Utilities;
037: import edu.iu.uis.eden.web.KeyValue;
038:
039: /**
040: * Struts ActionForm for the {@link RoutingReportAction}.
041: *
042: * @author jhopf
043: * @author rkirkend
044: * @author delyea
045: */
046: public class RoutingReportForm extends ActionForm {
047:
048: private static final long serialVersionUID = 509542372934250061L;
049: public static final String DOCUMENT_TYPE_NAME_ATTRIBUTE_NAME = "documentTypeParam";
050: public static final String INITIATOR_ID_ATTRIBUTE_NAME = "initiatorNetworkId";
051: public static final String DOCUMENT_CONTENT_ATTRIBUTE_NAME = "documentContent";
052: public static final String RETURN_URL_ATTRIBUTE_NAME = "backUrl";
053: public static final String DISPLAY_CLOSE_BUTTON_ATTRIBUTE_NAME = "showCloseButton";
054: public static final String DISPLAY_CLOSE_BUTTON_TRUE_VALUE = "showCloseButton";
055:
056: private Long ruleTemplateId;
057: private String methodToCall = "";
058: private String lookupableImplServiceName;
059: private String documentType;
060: private String reportType;
061:
062: // fields below used for document type report URL
063: private String documentTypeParam;
064: private String initiatorNetworkId;
065: private String documentContent;
066: private String backUrl;
067: private String showCloseButton;
068:
069: private String dateRef;
070: private String effectiveHour;
071: private String effectiveMinute;
072: private String amPm;
073:
074: private List ruleTemplates;
075: private List actionRequests;
076: private Map fields;
077: private List ruleTemplateAttributes;
078: private List attributes;
079:
080: private boolean showFields;
081: private boolean showViewResults;
082:
083: public RoutingReportForm() {
084: attributes = new ArrayList();
085: ruleTemplates = new ArrayList();
086: actionRequests = new ArrayList();
087: fields = new HashMap();
088: ruleTemplateAttributes = new ArrayList();
089: }
090:
091: public ActionErrors validate(ActionMapping mapping,
092: HttpServletRequest request) {
093:
094: ActionErrors errors = new ActionErrors();
095: if (getReportType() != null
096: && getReportType().equals(
097: RoutingReportAction.DOC_TYPE_REPORTING)) {
098: if (!Utilities.isEmpty(getDocumentType())) {
099: DocumentType docType = getDocumentTypeService()
100: .findByName(getDocumentType());
101: if (docType == null) {
102: ActionMessage error = new ActionMessage(
103: "routereport.documenttype.invalid");
104: errors.add(ActionMessages.GLOBAL_MESSAGE, error);
105: }
106: }
107: }
108: return errors;
109: }
110:
111: public String getLookupableImplServiceName() {
112: return lookupableImplServiceName;
113: }
114:
115: public void setLookupableImplServiceName(
116: String lookupableImplServiceName) {
117: this .lookupableImplServiceName = lookupableImplServiceName;
118: }
119:
120: public String getMethodToCall() {
121: return methodToCall;
122: }
123:
124: public void setMethodToCall(String methodToCall) {
125: this .methodToCall = methodToCall;
126: }
127:
128: public List getRuleTemplateAttributes() {
129: return ruleTemplateAttributes;
130: }
131:
132: public void setRuleTemplateAttributes(List ruleTemplateAttributes) {
133: this .ruleTemplateAttributes = ruleTemplateAttributes;
134: }
135:
136: public Map getFields() {
137: return fields;
138: }
139:
140: public void setFields(Map fields) {
141: this .fields = fields;
142: }
143:
144: public List getRuleTemplates() {
145: return ruleTemplates;
146: }
147:
148: public void setRuleTemplates(List ruleTemplates) {
149: this .ruleTemplates = ruleTemplates;
150: }
151:
152: public List getHours() {
153: List hours = new ArrayList();
154: hours.add(new KeyValue("0", "12"));
155: for (int i = 1; i < 12; i++) {
156: hours.add(new KeyValue(i + "", i + ""));
157: }
158: return hours;
159: }
160:
161: public List getMinutes() {
162: List mins = new ArrayList();
163: for (int i = 0; i < 60; i++) {
164: mins.add(new KeyValue(i + "", ":" + (i < 10 ? "0" : "") + i
165: + ""));
166: }
167: return mins;
168: }
169:
170: public Long getRuleTemplateId() {
171: return ruleTemplateId;
172: }
173:
174: public void setRuleTemplateId(Long ruleTemplateId) {
175: this .ruleTemplateId = ruleTemplateId;
176: }
177:
178: public List getActionRequests() {
179: return actionRequests;
180: }
181:
182: public void setActionRequests(List actionRequests) {
183: this .actionRequests = actionRequests;
184: }
185:
186: public void setDocTypeFullName(String documentType) {
187: this .documentType = documentType;
188: }
189:
190: public void setDocTypeGroupName(String docTypeGroupName) {
191: this .documentType = docTypeGroupName;
192: }
193:
194: public String getDocumentType() {
195: return documentType;
196: }
197:
198: public void setDocumentType(String documentType) {
199: this .documentType = documentType;
200: }
201:
202: public List getAttributes() {
203: return attributes;
204: }
205:
206: public void setAttributes(List attributes) {
207: this .attributes = attributes;
208: }
209:
210: public String getReportType() {
211: return reportType;
212: }
213:
214: public void setReportType(String reportType) {
215: this .reportType = reportType;
216: }
217:
218: public boolean isShowFields() {
219: return showFields;
220: }
221:
222: public void setShowFields(boolean showFields) {
223: this .showFields = showFields;
224: }
225:
226: public boolean isShowViewResults() {
227: return showViewResults;
228: }
229:
230: public void setShowViewResults(boolean showViewResults) {
231: this .showViewResults = showViewResults;
232: }
233:
234: private DocumentTypeService getDocumentTypeService() {
235: return (DocumentTypeService) KEWServiceLocator
236: .getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE);
237: }
238:
239: public String getDateRef() {
240: return dateRef;
241: }
242:
243: public void setDateRef(String dateRef) {
244: this .dateRef = dateRef;
245: }
246:
247: public String getEffectiveHour() {
248: return effectiveHour;
249: }
250:
251: public void setEffectiveHour(String effectiveHour) {
252: this .effectiveHour = effectiveHour;
253: }
254:
255: public String getEffectiveMinute() {
256: return effectiveMinute;
257: }
258:
259: public void setEffectiveMinute(String effectiveMinute) {
260: this .effectiveMinute = effectiveMinute;
261: }
262:
263: public String getAmPm() {
264: return amPm;
265: }
266:
267: public void setAmPm(String amPm) {
268: this .amPm = amPm;
269: }
270:
271: public String getDocumentContent() {
272: return documentContent;
273: }
274:
275: public void setDocumentContent(String documentContent) {
276: this .documentContent = documentContent;
277: }
278:
279: public String getInitiatorNetworkId() {
280: return initiatorNetworkId;
281: }
282:
283: public void setInitiatorNetworkId(String initiatorNetworkId) {
284: this .initiatorNetworkId = initiatorNetworkId;
285: }
286:
287: public String getBackUrl() {
288: if (StringUtils.isBlank(backUrl)) {
289: return null;
290: }
291: return backUrl;
292: }
293:
294: public void setBackUrl(String backUrl) {
295: this .backUrl = backUrl;
296: }
297:
298: public boolean isDisplayCloseButton() {
299: return (DISPLAY_CLOSE_BUTTON_TRUE_VALUE
300: .equals(getShowCloseButton()));
301: }
302:
303: public String getShowCloseButton() {
304: return showCloseButton;
305: }
306:
307: public void setShowCloseButton(String showCloseButton) {
308: this .showCloseButton = showCloseButton;
309: }
310:
311: public String getDocumentTypeParam() {
312: return documentTypeParam;
313: }
314:
315: public void setDocumentTypeParam(String documentTypeParam) {
316: this.documentTypeParam = documentTypeParam;
317: this.documentType = documentTypeParam;
318: }
319: }
|