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.docsearch;
018:
019: import java.io.Serializable;
020: import java.util.List;
021:
022: import org.apache.commons.lang.StringUtils;
023:
024: import edu.iu.uis.eden.util.Utilities;
025:
026: /**
027: *
028: * @author delyea
029: */
030: public class SearchAttributeCriteriaComponent implements Serializable {
031: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
032: .getLogger(SearchAttributeCriteriaComponent.class);
033:
034: private static final long serialVersionUID = -5927435567057306529L;
035:
036: private String formKey; // this if the field that is used in the UI for the form
037: private String value;
038: private List<String> values;
039: private String lookupableFieldType;
040: private boolean allowWildcards = true;
041: private boolean autoWildcardBeginning = false;
042: private boolean autoWildcardEnd = false;
043: private boolean caseSensitive = false;
044: private boolean searchInclusive = true; // not just for ranges... used by single date searches
045: private SearchableAttributeValue searchableAttributeValue;
046: private boolean searchable = true;
047: private boolean canHoldMultipleValues = false;
048:
049: // range properties
050: private boolean rangeSearch = false;
051: // this is the field that is saved to the database
052: private String savedKey;
053:
054: /**
055: * @param formKey key value associated with the search form
056: * @param value value the user is searching on
057: * @param savedKey key value associated with the value saved in the database
058: */
059: public SearchAttributeCriteriaComponent(String formKey,
060: String value, boolean rangeSearch) {
061: super ();
062: this .formKey = formKey;
063: this .value = value;
064: this .rangeSearch = rangeSearch;
065: if (!rangeSearch) {
066: this .savedKey = formKey;
067: }
068: }
069:
070: /**
071: * @param formKey key value associated with the search form
072: * @param value value the user is searching on
073: * @param savedKey key value associated with the value saved in the database
074: */
075: public SearchAttributeCriteriaComponent(String formKey,
076: String value, String savedKey) {
077: super ();
078: this .formKey = formKey;
079: this .value = value;
080: this .savedKey = savedKey;
081: }
082:
083: /**
084: * @param formKey key value associated with the search form
085: * @param value value the user is searching on
086: * @param savedKey key value associated with the value saved in the database
087: * @param searchableAttributeValue
088: */
089: public SearchAttributeCriteriaComponent(String formKey,
090: String value, String savedKey,
091: SearchableAttributeValue searchableAttributeValue) {
092: super ();
093: this .formKey = formKey;
094: this .value = value;
095: this .savedKey = savedKey;
096: this .searchableAttributeValue = searchableAttributeValue;
097: }
098:
099: public boolean isComponentLowerBoundValue() {
100: return isComponentGivenBoundValue(SearchableAttribute.RANGE_LOWER_BOUND_PROPERTY_PREFIX);
101: }
102:
103: public boolean isComponentUpperBoundValue() {
104: return isComponentGivenBoundValue(SearchableAttribute.RANGE_UPPER_BOUND_PROPERTY_PREFIX);
105: }
106:
107: private boolean isComponentGivenBoundValue(String boundKeyPrefix) {
108: if (!isRangeSearch()) {
109: String errorMsg = "Criteria Component with formKey value '"
110: + formKey + "' is not part of a range search";
111: LOG.error("isComponentGivenBoundValue() " + errorMsg);
112: throw new RuntimeException(errorMsg);
113: }
114: return formKey.indexOf(boundKeyPrefix) == 0;
115: }
116:
117: public boolean isNonBlankValueGiven() {
118: return ((StringUtils.isNotBlank(getValue())) || (!Utilities
119: .isEmpty(getValues())));
120: }
121:
122: /**
123: * @return the canHoldMultipleValues
124: */
125: public boolean isCanHoldMultipleValues() {
126: return canHoldMultipleValues;
127: }
128:
129: /**
130: * @param canHoldMultipleValues the canHoldMultipleValues to set
131: */
132: public void setCanHoldMultipleValues(boolean canHoldMultipleValues) {
133: this .canHoldMultipleValues = canHoldMultipleValues;
134: }
135:
136: /**
137: * @return the searchable
138: */
139: public boolean isSearchable() {
140: return searchable;
141: }
142:
143: /**
144: * @param searchable the searchable to set
145: */
146: public void setSearchable(boolean searchable) {
147: this .searchable = searchable;
148: }
149:
150: /**
151: * @return the allowWildcards
152: */
153: public boolean isAllowWildcards() {
154: return allowWildcards;
155: }
156:
157: /**
158: * @param allowWildcards the allowWildcards to set
159: */
160: public void setAllowWildcards(boolean allowWildcards) {
161: this .allowWildcards = allowWildcards;
162: }
163:
164: /**
165: * @return the autoWildcardBeginning
166: */
167: public boolean isAutoWildcardBeginning() {
168: return autoWildcardBeginning;
169: }
170:
171: /**
172: * @param autoWildcardBeginning the autoWildcardBeginning to set
173: */
174: public void setAutoWildcardBeginning(boolean autoWildcardBeginning) {
175: this .autoWildcardBeginning = autoWildcardBeginning;
176: }
177:
178: /**
179: * @return the autoWildcardEnd
180: */
181: public boolean isAutoWildcardEnd() {
182: return autoWildcardEnd;
183: }
184:
185: /**
186: * @param autoWildcardEnd the autoWildcardEnd to set
187: */
188: public void setAutoWildcardEnd(boolean autoWildcardEnd) {
189: this .autoWildcardEnd = autoWildcardEnd;
190: }
191:
192: /**
193: * @return the caseSensitive
194: */
195: public boolean isCaseSensitive() {
196: return caseSensitive;
197: }
198:
199: /**
200: * @param caseSensitive the caseSensitive to set
201: */
202: public void setCaseSensitive(boolean caseSensitive) {
203: this .caseSensitive = caseSensitive;
204: }
205:
206: /**
207: * @return the formKey
208: */
209: public String getFormKey() {
210: return formKey;
211: }
212:
213: /**
214: * @param formKey the formKey to set
215: */
216: public void setFormKey(String formKey) {
217: this .formKey = formKey;
218: }
219:
220: /**
221: * @return the rangeSearch
222: */
223: public boolean isRangeSearch() {
224: return rangeSearch;
225: }
226:
227: /**
228: * @param rangeSearch the rangeSearch to set
229: */
230: public void setRangeSearch(boolean rangeSearch) {
231: this .rangeSearch = rangeSearch;
232: }
233:
234: /**
235: * @return the savedKey
236: */
237: public String getSavedKey() {
238: return savedKey;
239: }
240:
241: /**
242: * @param savedKey the savedKey to set
243: */
244: public void setSavedKey(String savedKey) {
245: this .savedKey = savedKey;
246: }
247:
248: /**
249: * @return the searchableAttributeValue
250: */
251: public SearchableAttributeValue getSearchableAttributeValue() {
252: return searchableAttributeValue;
253: }
254:
255: /**
256: * @param searchableAttributeValue the searchableAttributeValue to set
257: */
258: public void setSearchableAttributeValue(
259: SearchableAttributeValue searchableAttributeValue) {
260: this .searchableAttributeValue = searchableAttributeValue;
261: }
262:
263: /**
264: * @return the searchInclusive
265: */
266: public boolean isSearchInclusive() {
267: return searchInclusive;
268: }
269:
270: /**
271: * @param searchInclusive the searchInclusive to set
272: */
273: public void setSearchInclusive(boolean searchInclusive) {
274: this .searchInclusive = searchInclusive;
275: }
276:
277: /**
278: * @return the value
279: */
280: public String getValue() {
281: return value;
282: }
283:
284: /**
285: * @param value the value to set
286: */
287: public void setValue(String value) {
288: this .value = value;
289: }
290:
291: /**
292: * @return the values
293: */
294: public List<String> getValues() {
295: return values;
296: }
297:
298: /**
299: * @param values the values to set
300: */
301: public void setValues(List<String> values) {
302: this .values = values;
303: }
304:
305: /**
306: * @return the lookupableFieldType
307: */
308: public String getLookupableFieldType() {
309: return lookupableFieldType;
310: }
311:
312: /**
313: * @param lookupableFieldType the lookupableFieldType to set
314: */
315: public void setLookupableFieldType(String lookupableFieldType) {
316: this.lookupableFieldType = lookupableFieldType;
317: }
318:
319: }
|