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.actionlist.web;
018:
019: import java.text.ParseException;
020: import java.util.ArrayList;
021: import java.util.List;
022:
023: import org.apache.struts.action.ActionForm;
024:
025: import edu.iu.uis.eden.EdenConstants;
026: import edu.iu.uis.eden.WorkflowServiceErrorException;
027: import edu.iu.uis.eden.WorkflowServiceErrorImpl;
028: import edu.iu.uis.eden.actionlist.ActionListFilter;
029:
030: /**
031: * Struts form class for ActionListFilterAction
032: *
033: * @author rkirkend
034: *
035: */
036: public class ActionListFilterForm extends ActionForm {
037:
038: private static final long serialVersionUID = -1149636352016711445L;
039:
040: private ActionListFilter filter;
041: private String createDateFrom;
042: private String createDateTo;
043: private String lastAssignedDateTo;
044: private String lastAssignedDateFrom;
045: private String methodToCall = "";
046: private String lookupableImplServiceName;
047: private String lookupType;
048: private String docTypeFullName;
049: private List userWorkgroups;
050:
051: public ActionListFilterForm() {
052: filter = new ActionListFilter();
053: }
054:
055: public String getCreateDateTo() {
056: return createDateTo;
057: }
058:
059: public void setCreateDateTo(String createDateTo) {
060: this .createDateTo = createDateTo.trim();
061: }
062:
063: public String getLastAssignedDateFrom() {
064: return lastAssignedDateFrom;
065: }
066:
067: public void setLastAssignedDateFrom(String lastAssignedDateFrom) {
068: this .lastAssignedDateFrom = lastAssignedDateFrom.trim();
069: }
070:
071: public String getCreateDateFrom() {
072: return createDateFrom;
073: }
074:
075: public void setCreateDateFrom(String createDate) {
076: this .createDateFrom = createDate.trim();
077: }
078:
079: public ActionListFilter getFilter() {
080: return filter;
081: }
082:
083: public String getMethodToCall() {
084: return methodToCall;
085: }
086:
087: public void setMethodToCall(String methodToCall) {
088: this .methodToCall = methodToCall;
089: }
090:
091: public void setFilter(ActionListFilter filter) {
092: this .filter = filter;
093: if (filter.getCreateDateFrom() != null) {
094: setCreateDateFrom(EdenConstants.getDefaultDateFormat()
095: .format(filter.getCreateDateFrom()));
096: }
097: if (filter.getCreateDateTo() != null) {
098: setCreateDateTo(EdenConstants.getDefaultDateFormat()
099: .format(filter.getCreateDateTo()));
100: }
101: if (filter.getLastAssignedDateFrom() != null) {
102: setLastAssignedDateFrom(EdenConstants
103: .getDefaultDateFormat().format(
104: filter.getLastAssignedDateFrom()));
105: }
106: if (filter.getLastAssignedDateTo() != null) {
107: setLastAssignedDateTo(EdenConstants.getDefaultDateFormat()
108: .format(filter.getLastAssignedDateTo()));
109: }
110: }
111:
112: public String getLastAssignedDateTo() {
113: return lastAssignedDateTo;
114: }
115:
116: public void setLastAssignedDateTo(String lastAssignedDate) {
117: this .lastAssignedDateTo = lastAssignedDate.trim();
118: }
119:
120: public void validateDates() {
121: List errors = new ArrayList();
122: if (getCreateDateFrom() != null
123: && getCreateDateFrom().length() != 0) {
124: try {
125: EdenConstants.getDefaultDateFormat().parse(
126: getCreateDateFrom());
127: } catch (ParseException e) {
128: errors.add(new WorkflowServiceErrorImpl(
129: "Error with Create Date From",
130: "general.error.fieldinvalid",
131: "Create Date From"));
132: }
133: }
134: if (getCreateDateTo() != null
135: && getCreateDateTo().length() != 0) {
136: try {
137: EdenConstants.getDefaultDateFormat().parse(
138: getCreateDateTo());
139: } catch (ParseException e) {
140: errors
141: .add(new WorkflowServiceErrorImpl(
142: "Error with Create Date To",
143: "general.error.fieldinvalid",
144: "Create Date To"));
145: }
146: }
147: if (getLastAssignedDateFrom() != null
148: && getLastAssignedDateFrom().length() != 0) {
149: try {
150: EdenConstants.getDefaultDateFormat().parse(
151: getLastAssignedDateFrom());
152: } catch (ParseException e1) {
153: errors.add(new WorkflowServiceErrorImpl(
154: "Error with Last Assigned Date From",
155: "general.error.fieldinvalid",
156: "Last Assigned Date From"));
157: }
158: }
159: if (getLastAssignedDateTo() != null
160: && getLastAssignedDateTo().length() != 0) {
161: try {
162: EdenConstants.getDefaultDateFormat().parse(
163: getLastAssignedDateTo());
164: } catch (ParseException e1) {
165: errors.add(new WorkflowServiceErrorImpl(
166: "Error with Last Assigned Date To",
167: "general.error.fieldinvalid",
168: "Last Assigned Date To"));
169: }
170: }
171: if (!errors.isEmpty()) {
172: throw new WorkflowServiceErrorException(
173: "Action List Filter Dates Validation Error", errors);
174: }
175: }
176:
177: public ActionListFilter getLoadedFilter() throws ParseException {
178: if (getCreateDateFrom() != null
179: && getCreateDateFrom().length() != 0) {
180: filter.setCreateDateFrom(EdenConstants
181: .getDefaultDateFormat().parse(getCreateDateFrom()));
182: }
183: if (getCreateDateTo() != null
184: && getCreateDateTo().length() != 0) {
185: filter.setCreateDateTo(EdenConstants.getDefaultDateFormat()
186: .parse(getCreateDateTo()));
187: }
188: if (getLastAssignedDateFrom() != null
189: && getLastAssignedDateFrom().length() != 0) {
190: filter.setLastAssignedDateFrom(EdenConstants
191: .getDefaultDateFormat().parse(
192: getLastAssignedDateFrom()));
193: }
194: if (getLastAssignedDateTo() != null
195: && getLastAssignedDateTo().length() != 0) {
196: filter.setLastAssignedDateTo(EdenConstants
197: .getDefaultDateFormat().parse(
198: getLastAssignedDateTo()));
199: }
200: if (getDocTypeFullName() != null
201: && !"".equals(getDocTypeFullName())) {
202: filter.setDocumentType(getDocTypeFullName());
203: }
204:
205: return filter;
206: }
207:
208: public String getLookupableImplServiceName() {
209: return lookupableImplServiceName;
210: }
211:
212: public void setLookupableImplServiceName(
213: String lookupableImplServiceName) {
214: this .lookupableImplServiceName = lookupableImplServiceName;
215: }
216:
217: public String getLookupType() {
218: return lookupType;
219: }
220:
221: public void setLookupType(String lookupType) {
222: this .lookupType = lookupType;
223: }
224:
225: public String getDocTypeFullName() {
226: return docTypeFullName;
227: }
228:
229: public void setDocTypeFullName(String docTypeFullName) {
230: this .docTypeFullName = docTypeFullName;
231: }
232:
233: public List getUserWorkgroups() {
234: return userWorkgroups;
235: }
236:
237: public void setUserWorkgroups(List userWorkgroups) {
238: this.userWorkgroups = userWorkgroups;
239: }
240:
241: }
|