001/** 002 * Copyright 2005-2016 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 053 public String getTest(){ 054 return test; 055 } 056 public void setTest(String test){ 057 this.test = test; 058 } 059 060 public ActionListFilterForm() { 061 filter = new ActionListFilter(); 062 } 063 064 public String getCreateDateTo() { 065 return createDateTo; 066 } 067 public void setCreateDateTo(String createDateTo) { 068 if(createDateTo == null){ 069 createDateTo = ""; 070 } 071 else{ 072 this.createDateTo = createDateTo.trim(); 073 } 074 } 075 public String getLastAssignedDateFrom() { 076 return lastAssignedDateFrom; 077 } 078 public void setLastAssignedDateFrom(String lastAssignedDateFrom) { 079 if(lastAssignedDateFrom == null){ 080 lastAssignedDateFrom = ""; 081 } 082 else{ 083 this.lastAssignedDateFrom = lastAssignedDateFrom.trim(); 084 } 085 } 086 public String getCreateDateFrom() { 087 return createDateFrom; 088 } 089 public void setCreateDateFrom(String createDate) { 090 if(createDate == null){ 091 createDate = ""; 092 } 093 else{ 094 this.createDateFrom = createDate.trim(); 095 } 096 } 097 098 public ActionListFilter getFilter() { 099 return filter; 100 } 101 102 public String getMethodToCall() { 103 return methodToCall; 104 } 105 106 public void setMethodToCall(String methodToCall) { 107 this.methodToCall = methodToCall; 108 } 109 110 public void setFilter(ActionListFilter filter) { 111 this.filter = filter; 112 if (filter.getCreateDateFrom() != null) { 113 setCreateDateFrom(RiceConstants.getDefaultDateFormat().format(filter.getCreateDateFrom())); 114 } 115 if (filter.getCreateDateTo() != null) { 116 setCreateDateTo(RiceConstants.getDefaultDateFormat().format(filter.getCreateDateTo())); 117 } 118 if (filter.getLastAssignedDateFrom() != null) { 119 setLastAssignedDateFrom(RiceConstants.getDefaultDateFormat().format(filter.getLastAssignedDateFrom())); 120 } 121 if (filter.getLastAssignedDateTo() != null) { 122 setLastAssignedDateTo(RiceConstants.getDefaultDateFormat().format(filter.getLastAssignedDateTo())); 123 } 124 } 125 126 public String getLastAssignedDateTo() { 127 return lastAssignedDateTo; 128 } 129 130 public void setLastAssignedDateTo(String lastAssignedDate) { 131 if(lastAssignedDate == null){ 132 lastAssignedDate = ""; 133 } 134 else{ 135 this.lastAssignedDateTo = lastAssignedDate.trim(); 136 } 137 } 138 139 public void validateDates() { 140 //List errors = new ArrayList(); 141 //ActionErrors errors = new ActionErrors(); 142 if (getCreateDateFrom() != null && getCreateDateFrom().length() != 0) { 143 try { 144 RiceConstants.getDefaultDateFormat().parse(getCreateDateFrom()); 145 } catch (ParseException e) { 146 GlobalVariables.getMessageMap().putError(CREATE_DATE_FROM, "general.error.fieldinvalid", "Create Date From"); 147 } 148 } 149 if (getCreateDateTo() != null && getCreateDateTo().length() != 0) { 150 try { 151 RiceConstants.getDefaultDateFormat().parse(getCreateDateTo()); 152 } catch (ParseException e) { 153 GlobalVariables.getMessageMap().putError(CREATE_DATE_TO, "general.error.fieldinvalid", "Create Date To"); 154 } 155 } 156 if (getLastAssignedDateFrom() != null && getLastAssignedDateFrom().length() != 0) { 157 try { 158 RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateFrom()); 159 } catch (ParseException e1) { 160 GlobalVariables.getMessageMap().putError(LAST_ASSIGNED_DATE_FROM, "general.error.fieldinvalid", "Last Assigned Date From"); 161 } 162 } 163 if (getLastAssignedDateTo() != null && getLastAssignedDateTo().length() != 0) { 164 try { 165 RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateTo()); 166 } catch (ParseException e1) { 167 GlobalVariables.getMessageMap().putError(LAST_ASSIGNED_DATE_TO, "general.error.fieldinvalid", "Last Assigned Date To"); 168 } 169 } 170 } 171 172 public ActionListFilter getLoadedFilter()/* throws ParseException*/ { 173 try { 174 if (getCreateDateFrom() != null && getCreateDateFrom().length() != 0) { 175 filter.setCreateDateFrom(RiceConstants.getDefaultDateFormat().parse(getCreateDateFrom())); 176 } 177 if (getCreateDateTo() != null && getCreateDateTo().length() != 0) { 178 filter.setCreateDateTo(RiceConstants.getDefaultDateFormat().parse(getCreateDateTo())); 179 } 180 if (getLastAssignedDateFrom() != null && getLastAssignedDateFrom().length() != 0) { 181 filter.setLastAssignedDateFrom(RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateFrom())); 182 } 183 if (getLastAssignedDateTo() != null && getLastAssignedDateTo().length() != 0) { 184 filter.setLastAssignedDateTo(RiceConstants.getDefaultDateFormat().parse(getLastAssignedDateTo())); 185 } 186 if (getDocTypeFullName() != null && ! "".equals(getDocTypeFullName())) { 187 filter.setDocumentType(getDocTypeFullName()); 188 } 189 } catch (ParseException e) { 190 //error caught and displayed in validateDates() 191 } 192 193 return filter; 194 } 195 196 public String getLookupableImplServiceName() { 197 return lookupableImplServiceName; 198 } 199 200 public void setLookupableImplServiceName(String lookupableImplServiceName) { 201 this.lookupableImplServiceName = lookupableImplServiceName; 202 } 203 204 public String getLookupType() { 205 return lookupType; 206 } 207 208 public void setLookupType(String lookupType) { 209 this.lookupType = lookupType; 210 } 211 212 public String getDocTypeFullName() { 213 return docTypeFullName; 214 } 215 216 public void setDocTypeFullName(String docTypeFullName) { 217 this.docTypeFullName = docTypeFullName; 218 } 219 220 public List getUserWorkgroups() { 221 return userWorkgroups; 222 } 223 224 public void setUserWorkgroups(List userWorkgroups) { 225 this.userWorkgroups = userWorkgroups; 226 } 227 228 public String getCssFile() { 229 return this.cssFile; 230 } 231 232 public void setCssFile(String cssFile) { 233 this.cssFile = cssFile; 234 } 235 236}