1 23 package org.infoglue.cms.controllers.kernel.impl.simple; 24 25 import java.sql.Timestamp ; 26 import java.util.ArrayList ; 27 import java.util.Date ; 28 import java.util.List ; 29 30 import org.infoglue.cms.entities.content.ContentVersionVO; 31 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO; 32 import org.infoglue.cms.entities.management.LanguageVO; 33 34 37 public class ExtendedSearchCriterias 38 { 39 42 public static final int NO_DATE_CRITERIA_TYPE = 0; 43 44 47 public static final int FROM_DATE_CRITERIA_TYPE = 1; 48 49 52 public static final int TO_DATE_CRITERIA_TYPE = 2; 53 54 57 public static final int BOTH_DATE_CRITERIA_TYPE = 3; 58 59 62 private Integer stateId; 63 64 69 private String freetext; 70 71 74 private List xmlAttributes; 76 79 private LanguageVO languageVO; 80 81 84 private List contentTypeDefinitionVOs; 86 89 private CategoryConditions categories; 90 91 94 private Timestamp fromDate; 95 96 99 private Timestamp toDate; 100 101 104 public ExtendedSearchCriterias() 105 { 106 this(ContentVersionVO.WORKING_STATE.intValue()); 107 } 108 109 114 public ExtendedSearchCriterias(final int stateId) 115 { 116 super(); 117 this.stateId = new Integer (stateId); 118 } 119 120 127 public void setFreetext(final String freetext, final List xmlAttributes) 128 { 129 this.freetext = freetext; 130 if(xmlAttributes != null) 131 { 132 this.xmlAttributes = new ArrayList (xmlAttributes); 133 } 134 } 135 136 141 public void setLanguage(final LanguageVO languageVO) 142 { 143 this.languageVO = languageVO; 144 } 145 146 151 public void setContentTypeDefinitions(final ContentTypeDefinitionVO contentTypeDefinitionVO) 152 { 153 if(contentTypeDefinitionVO != null) 154 { 155 contentTypeDefinitionVOs = new ArrayList (); 156 contentTypeDefinitionVOs.add(contentTypeDefinitionVO); 157 } 158 } 159 160 165 public void setContentTypeDefinitions(final List contentTypeDefinitionVOs) 166 { 167 if(contentTypeDefinitionVOs != null) 168 { 169 this.contentTypeDefinitionVOs = new ArrayList (contentTypeDefinitionVOs); 170 } 171 } 172 173 178 public void setCategoryConditions(final CategoryConditions categories) 179 { 180 this.categories = categories; 181 } 182 183 189 public void setDates(final Date from, final Date to) 190 { 191 this.fromDate = (from == null) ? null : new Timestamp (from.getTime()); 192 this.toDate = (to == null) ? null : new Timestamp (to.getTime()); 193 } 194 195 200 public boolean hasFreetextCritera() 201 { 202 return freetext != null && freetext.length() > 0 && xmlAttributes != null && !xmlAttributes.isEmpty(); 203 } 204 205 210 public boolean hasLanguageCriteria() 211 { 212 return languageVO != null; 213 } 214 215 220 public boolean hasContentTypeDefinitionVOsCriteria() 221 { 222 return contentTypeDefinitionVOs != null && !contentTypeDefinitionVOs.isEmpty(); 223 } 224 225 230 public boolean hasCategoryConditions() 231 { 232 return categories != null && categories.hasCondition(); 233 } 234 235 240 public int getDateCriteriaType() 241 { 242 if(toDate == null && fromDate == null) 243 { 244 return NO_DATE_CRITERIA_TYPE; 245 } 246 if(toDate != null && fromDate == null) 247 { 248 return NO_DATE_CRITERIA_TYPE; 249 } 250 if(toDate == null && fromDate != null) 251 { 252 return FROM_DATE_CRITERIA_TYPE; 253 } 254 return BOTH_DATE_CRITERIA_TYPE; 255 } 256 257 262 public Integer getStateId() 263 { 264 return this.stateId; 265 } 266 267 272 public String getFreetext() 273 { 274 return this.freetext; 275 } 276 277 282 public List getXmlAttributes() 283 { 284 return this.xmlAttributes; 285 } 286 287 292 public LanguageVO getLanguage() 293 { 294 return this.languageVO; 295 } 296 297 302 public List getContentTypeDefinitions() 303 { 304 return this.contentTypeDefinitionVOs; 305 } 306 307 312 public CategoryConditions getCategories() 313 { 314 return this.categories; 315 } 316 317 322 public Timestamp getFromDate() 323 { 324 return this.fromDate; 325 } 326 327 332 public Timestamp getToDate() 333 { 334 return this.toDate; 335 } 336 } 337 | Popular Tags |