Coverage Report - org.kuali.rice.kew.docsearch.SearchAttributeCriteriaComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
SearchAttributeCriteriaComponent
0%
0/69
0%
0/10
1.129
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.docsearch;
 18  
 
 19  
 import org.apache.commons.collections.CollectionUtils;
 20  
 import org.apache.commons.lang.StringUtils;
 21  
 import org.kuali.rice.kew.util.KEWConstants;
 22  
 
 23  
 import java.io.Serializable;
 24  
 import java.util.List;
 25  
 
 26  
 
 27  
 /**
 28  
  *
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  */
 31  
 public class SearchAttributeCriteriaComponent implements Serializable {
 32  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SearchAttributeCriteriaComponent.class);
 33  
         
 34  
         private static final long serialVersionUID = -5927435567057306529L;
 35  
 
 36  
         private String formKey;  // this if the field that is used in the UI for the form
 37  
     private String value;
 38  
     private List<String> values;
 39  
     private String lookupableFieldType;
 40  0
     private boolean caseSensitive = false;
 41  0
     private boolean searchInclusive = true;  // not just for ranges... used by single date searches
 42  
     private SearchableAttributeValue searchableAttributeValue;
 43  0
     private boolean searchable = true;
 44  0
     private boolean canHoldMultipleValues = false;
 45  
     
 46  
     // range properties
 47  0
     private boolean rangeSearch = false;
 48  0
     private boolean allowInlineRange = false;
 49  
     // this is the field that is saved to the database
 50  
     private String savedKey;
 51  
 
 52  
         /**
 53  
          * @param formKey key value associated with the search form
 54  
          * @param value value the user is searching on
 55  
          * @param savedKey key value associated with the value saved in the database
 56  
          */
 57  
         public SearchAttributeCriteriaComponent(String formKey, String value, boolean rangeSearch) {
 58  0
                 super();
 59  0
                 this.formKey = formKey;
 60  0
                 this.value = value;
 61  0
                 this.rangeSearch = rangeSearch;
 62  0
                 if (!rangeSearch) {
 63  0
                         this.savedKey = formKey;
 64  
                 }
 65  0
         }
 66  
         
 67  
         /**
 68  
          * @param formKey key value associated with the search form
 69  
          * @param value value the user is searching on
 70  
          * @param savedKey key value associated with the value saved in the database
 71  
          */
 72  
         public SearchAttributeCriteriaComponent(String formKey, String value, String savedKey) {
 73  0
                 super();
 74  0
                 this.formKey = formKey;
 75  0
                 this.value = value;
 76  0
                 this.savedKey = savedKey;
 77  0
         }
 78  
         
 79  
         /**
 80  
          * @param formKey key value associated with the search form
 81  
          * @param value value the user is searching on
 82  
          * @param savedKey key value associated with the value saved in the database
 83  
          * @param searchableAttributeValue
 84  
          */
 85  
         public SearchAttributeCriteriaComponent(String formKey, String value, String savedKey, SearchableAttributeValue searchableAttributeValue) {
 86  0
                 super();
 87  0
                 this.formKey = formKey;
 88  0
                 this.value = value;
 89  0
                 this.savedKey = savedKey;
 90  0
                 this.searchableAttributeValue = searchableAttributeValue;
 91  0
         }
 92  
         
 93  
         public boolean isComponentLowerBoundValue() {
 94  0
                 return isComponentGivenBoundValue(KEWConstants.SearchableAttributeConstants.RANGE_LOWER_BOUND_PROPERTY_PREFIX);
 95  
         }
 96  
         
 97  
         public boolean isComponentUpperBoundValue() {
 98  0
                 return isComponentGivenBoundValue(KEWConstants.SearchableAttributeConstants.RANGE_UPPER_BOUND_PROPERTY_PREFIX);
 99  
         }
 100  
         
 101  
         private boolean isComponentGivenBoundValue(String boundKeyPrefix) {
 102  0
                 if (!isRangeSearch()) {
 103  0
                         String errorMsg = "Criteria Component with formKey value '" + formKey + "' is not part of a range search";
 104  0
                         LOG.error("isComponentGivenBoundValue() " + errorMsg);
 105  0
                         throw new RuntimeException(errorMsg);
 106  
                 }
 107  0
                 return formKey.indexOf(boundKeyPrefix) == 0;
 108  
         }
 109  
     
 110  
     public boolean isNonBlankValueGiven() {
 111  0
         return ( (StringUtils.isNotBlank(getValue())) || (!CollectionUtils.isEmpty(getValues())) );
 112  
     }
 113  
 
 114  
         /**
 115  
      * @return the canHoldMultipleValues
 116  
      */
 117  
     public boolean isCanHoldMultipleValues() {
 118  0
         return canHoldMultipleValues;
 119  
     }
 120  
 
 121  
     /**
 122  
      * @param canHoldMultipleValues the canHoldMultipleValues to set
 123  
      */
 124  
     public void setCanHoldMultipleValues(boolean canHoldMultipleValues) {
 125  0
         this.canHoldMultipleValues = canHoldMultipleValues;
 126  0
     }
 127  
 
 128  
     /**
 129  
      * @return the searchable
 130  
      */
 131  
     public boolean isSearchable() {
 132  0
         return searchable;
 133  
     }
 134  
 
 135  
     /**
 136  
      * @param searchable the searchable to set
 137  
      */
 138  
     public void setSearchable(boolean searchable) {
 139  0
         this.searchable = searchable;
 140  0
     }
 141  
 
 142  
         /**
 143  
          * @return the caseSensitive
 144  
          */
 145  
         public boolean isCaseSensitive() {
 146  0
                 return caseSensitive;
 147  
         }
 148  
 
 149  
         /**
 150  
          * @param caseSensitive the caseSensitive to set
 151  
          */
 152  
         public void setCaseSensitive(boolean caseSensitive) {
 153  0
                 this.caseSensitive = caseSensitive;
 154  0
         }
 155  
 
 156  
         /**
 157  
          * @return the formKey
 158  
          */
 159  
         public String getFormKey() {
 160  0
                 return formKey;
 161  
         }
 162  
 
 163  
         /**
 164  
          * @param formKey the formKey to set
 165  
          */
 166  
         public void setFormKey(String formKey) {
 167  0
                 this.formKey = formKey;
 168  0
         }
 169  
 
 170  
         /**
 171  
          * @return the rangeSearch
 172  
          */
 173  
         public boolean isRangeSearch() {
 174  0
                 return rangeSearch;
 175  
         }
 176  
 
 177  
         /**
 178  
          * @param rangeSearch the rangeSearch to set
 179  
          */
 180  
         public void setRangeSearch(boolean rangeSearch) {
 181  0
                 this.rangeSearch = rangeSearch;
 182  0
         }
 183  
 
 184  
         /**
 185  
          * @return the savedKey
 186  
          */
 187  
         public String getSavedKey() {
 188  0
                 return savedKey;
 189  
         }
 190  
 
 191  
         /**
 192  
          * @param savedKey the savedKey to set
 193  
          */
 194  
         public void setSavedKey(String savedKey) {
 195  0
                 this.savedKey = savedKey;
 196  0
         }
 197  
 
 198  
         /**
 199  
          * @return the searchableAttributeValue
 200  
          */
 201  
         public SearchableAttributeValue getSearchableAttributeValue() {
 202  0
                 return searchableAttributeValue;
 203  
         }
 204  
 
 205  
         /**
 206  
          * @param searchableAttributeValue the searchableAttributeValue to set
 207  
          */
 208  
         public void setSearchableAttributeValue(
 209  
                         SearchableAttributeValue searchableAttributeValue) {
 210  0
                 this.searchableAttributeValue = searchableAttributeValue;
 211  0
         }
 212  
 
 213  
         /**
 214  
          * @return the searchInclusive
 215  
          */
 216  
         public boolean isSearchInclusive() {
 217  0
                 return searchInclusive;
 218  
         }
 219  
 
 220  
         /**
 221  
          * @param searchInclusive the searchInclusive to set
 222  
          */
 223  
         public void setSearchInclusive(boolean searchInclusive) {
 224  0
                 this.searchInclusive = searchInclusive;
 225  0
         }
 226  
 
 227  
         /**
 228  
          * @return the value
 229  
          */
 230  
         public String getValue() {
 231  0
                 return value;
 232  
         }
 233  
 
 234  
         /**
 235  
          * @param value the value to set
 236  
          */
 237  
         public void setValue(String value) {
 238  0
                 this.value = value;
 239  0
         }
 240  
 
 241  
     /**
 242  
      * @return the values
 243  
      */
 244  
     public List<String> getValues() {
 245  0
         return values;
 246  
     }
 247  
 
 248  
     /**
 249  
      * @param values the values to set
 250  
      */
 251  
     public void setValues(List<String> values) {
 252  0
         this.values = values;
 253  0
     }
 254  
 
 255  
     /**
 256  
      * @return the lookupableFieldType
 257  
      */
 258  
     public String getLookupableFieldType() {
 259  0
         return lookupableFieldType;
 260  
     }
 261  
 
 262  
     /**
 263  
      * @param lookupableFieldType the lookupableFieldType to set
 264  
      */
 265  
     public void setLookupableFieldType(String lookupableFieldType) {
 266  0
         this.lookupableFieldType = lookupableFieldType;
 267  0
     }
 268  
 
 269  
         /**
 270  
          * @return the allowInlineRange
 271  
          */
 272  
         public boolean isAllowInlineRange() {
 273  0
                 return this.allowInlineRange;
 274  
         }
 275  
 
 276  
         /**
 277  
          * @param allowInlineRange the allowInlineRange to set
 278  
          */
 279  
         public void setAllowInlineRange(boolean allowInlineRange) {
 280  0
                 this.allowInlineRange = allowInlineRange;
 281  0
         }
 282  
 
 283  
 }