001/**
002 * Copyright 2005-2017 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.actionlist.web;
017
018import org.kuali.rice.core.api.util.RiceConstants;
019import org.kuali.rice.kew.actionlist.ActionListFilter;
020import org.kuali.rice.kns.web.struts.form.KualiForm;
021import org.kuali.rice.krad.util.GlobalVariables;
022
023import java.text.ParseException;
024import java.util.List;
025
026
027/**
028 * Struts form class for ActionListFilterAction
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 *
032 */
033public class ActionListFilterForm extends KualiForm {
034
035        private static final long serialVersionUID = -1149636352016711445L;
036    private static String CREATE_DATE_FROM = "createDateFrom";
037    private static String CREATE_DATE_TO = "createDateTo";
038    private static String LAST_ASSIGNED_DATE_FROM = "lastAssignedDateFrom";
039    private static String LAST_ASSIGNED_DATE_TO = "lastAssignedDateTo";
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    private String cssFile = "kuali.css";
051    private String test = "";
052    private String documentTargetSpec;
053    private String routeLogTargetSpec;
054
055
056    public String getTest(){
057        return test;
058    }
059    public void setTest(String test){
060        this.test = test;
061    }
062
063    public ActionListFilterForm() {
064        filter = new ActionListFilter();
065    }
066
067    public String getCreateDateTo() {
068        return createDateTo;
069    }
070    public void setCreateDateTo(String createDateTo) {
071        if(createDateTo == null){
072                createDateTo = "";
073        }
074        else{
075                this.createDateTo = createDateTo.trim();
076        }
077    }
078    public String getLastAssignedDateFrom() {
079        return lastAssignedDateFrom;
080    }
081    public void setLastAssignedDateFrom(String lastAssignedDateFrom) {
082        if(lastAssignedDateFrom == null){
083                lastAssignedDateFrom = "";
084        }
085        else{
086                this.lastAssignedDateFrom = lastAssignedDateFrom.trim();
087        }
088    }
089    public String getCreateDateFrom() {
090        return createDateFrom;
091    }
092    public void setCreateDateFrom(String createDate) {
093        if(createDate == null){
094                createDate = "";
095        }
096        else{
097                this.createDateFrom = createDate.trim();
098        }
099    }
100
101    public ActionListFilter getFilter() {
102        return filter;
103    }
104
105    public String getMethodToCall() {
106        return methodToCall;
107    }
108
109    public void setMethodToCall(String methodToCall) {
110        this.methodToCall = methodToCall;
111    }
112
113    public void setFilter(ActionListFilter filter) {
114        this.filter = filter;
115        if (filter.getCreateDateFrom() != null) {
116            setCreateDateFrom(RiceConstants.getDefaultDateFormat().format(filter.getCreateDateFrom()));
117        }
118        if (filter.getCreateDateTo() != null) {
119            setCreateDateTo(RiceConstants.getDefaultDateFormat().format(filter.getCreateDateTo()));
120        }
121        if (filter.getLastAssignedDateFrom() != null) {
122            setLastAssignedDateFrom(RiceConstants.getDefaultDateFormat().format(filter.getLastAssignedDateFrom()));
123        }
124        if (filter.getLastAssignedDateTo() != null) {
125            setLastAssignedDateTo(RiceConstants.getDefaultDateFormat().format(filter.getLastAssignedDateTo()));
126        }
127    }
128
129    public String getLastAssignedDateTo() {
130        return lastAssignedDateTo;
131    }
132
133    public void setLastAssignedDateTo(String lastAssignedDate) {
134        if(lastAssignedDate == null){
135                lastAssignedDate = "";
136        }
137        else{
138                this.lastAssignedDateTo = lastAssignedDate.trim();
139        }
140    }
141
142    public void validateDates() {
143        //List errors = new ArrayList();
144        //ActionErrors errors = new ActionErrors();
145        if (getCreateDateFrom() != null && getCreateDateFrom().length() != 0) {
146            try {
147                RiceConstants.getDefaultDateFormat().parse(getCreateDateFrom());
148            } catch (ParseException e) {
149                GlobalVariables.getMessageMap().putError(CREATE_DATE_FROM, "general.error.fieldinvalid", "Create Date From");
150            }
151        }
152        if (getCreateDateTo() != null && getCreateDateTo().length() != 0) {
153            try {
154                RiceConstants.getDefaultDateFormat().parse(getCreateDateTo());
155            } catch (ParseException e) {
156                GlobalVariables.getMessageMap().putError(CREATE_DATE_TO, "general.error.fieldinvalid", "Create Date To");
157            }
158        }
159        if (getLastAssignedDateFrom() != null && getLastAssignedDateFrom().length() != 0) {
160            try {
161                RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateFrom());
162            } catch (ParseException e1) {
163                GlobalVariables.getMessageMap().putError(LAST_ASSIGNED_DATE_FROM, "general.error.fieldinvalid", "Last Assigned Date From");
164            }
165        }
166        if (getLastAssignedDateTo() != null && getLastAssignedDateTo().length() != 0) {
167            try {
168                RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateTo());
169            } catch (ParseException e1) {
170                GlobalVariables.getMessageMap().putError(LAST_ASSIGNED_DATE_TO, "general.error.fieldinvalid", "Last Assigned Date To");
171            }
172        }
173    }
174
175    public ActionListFilter getLoadedFilter()/* throws ParseException*/ {
176        try {
177            if (getCreateDateFrom() != null && getCreateDateFrom().length() != 0) {
178                filter.setCreateDateFrom(RiceConstants.getDefaultDateFormat().parse(getCreateDateFrom()));
179            }
180            if (getCreateDateTo() != null && getCreateDateTo().length() != 0) {
181                filter.setCreateDateTo(RiceConstants.getDefaultDateFormat().parse(getCreateDateTo()));
182            }
183            if (getLastAssignedDateFrom() != null && getLastAssignedDateFrom().length() != 0) {
184                filter.setLastAssignedDateFrom(RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateFrom()));
185            }
186            if (getLastAssignedDateTo() != null && getLastAssignedDateTo().length() != 0) {
187                filter.setLastAssignedDateTo(RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateTo()));
188            }
189            if (getDocTypeFullName() != null && ! "".equals(getDocTypeFullName())) {
190                filter.setDocumentType(getDocTypeFullName());
191            }
192        } catch (ParseException e) {
193            //error caught and displayed in validateDates()
194        }
195
196        return filter;
197    }
198
199    public String getLookupableImplServiceName() {
200        return lookupableImplServiceName;
201    }
202
203    public void setLookupableImplServiceName(String lookupableImplServiceName) {
204        this.lookupableImplServiceName = lookupableImplServiceName;
205    }
206
207    public String getLookupType() {
208        return lookupType;
209    }
210
211    public void setLookupType(String lookupType) {
212        this.lookupType = lookupType;
213    }
214
215    public String getDocTypeFullName() {
216        return docTypeFullName;
217    }
218
219    public void setDocTypeFullName(String docTypeFullName) {
220        this.docTypeFullName = docTypeFullName;
221    }
222
223    public List getUserWorkgroups() {
224        return userWorkgroups;
225    }
226
227    public void setUserWorkgroups(List userWorkgroups) {
228        this.userWorkgroups = userWorkgroups;
229    }
230
231        public String getCssFile() {
232                return this.cssFile;
233        }
234
235        public void setCssFile(String cssFile) {
236                this.cssFile = cssFile;
237        }
238
239    public String getDocumentTargetSpec() {
240        return documentTargetSpec;
241    }
242
243    public void setDocumentTargetSpec(String documentTargetSpec) {
244        this.documentTargetSpec = documentTargetSpec;
245    }
246
247    public String getRouteLogTargetSpec() {
248        return routeLogTargetSpec;
249    }
250
251    public void setRouteLogTargetSpec(String routeLogTargetSpec) {
252        this.routeLogTargetSpec = routeLogTargetSpec;
253    }
254
255}