1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
30
31 public class SearchAttributeCriteriaComponent implements Serializable {
32 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;
37 private String value;
38 private List<String> values;
39 private String lookupableFieldType;
40 private boolean caseSensitive = false;
41 private boolean searchInclusive = true;
42 private SearchableAttributeValue searchableAttributeValue;
43 private boolean searchable = true;
44 private boolean canHoldMultipleValues = false;
45
46
47 private boolean rangeSearch = false;
48 private boolean allowInlineRange = false;
49
50 private String savedKey;
51
52
53
54
55
56
57 public SearchAttributeCriteriaComponent(String formKey, String value, boolean rangeSearch) {
58 super();
59 this.formKey = formKey;
60 this.value = value;
61 this.rangeSearch = rangeSearch;
62 if (!rangeSearch) {
63 this.savedKey = formKey;
64 }
65 }
66
67
68
69
70
71
72 public SearchAttributeCriteriaComponent(String formKey, String value, String savedKey) {
73 super();
74 this.formKey = formKey;
75 this.value = value;
76 this.savedKey = savedKey;
77 }
78
79
80
81
82
83
84
85 public SearchAttributeCriteriaComponent(String formKey, String value, String savedKey, SearchableAttributeValue searchableAttributeValue) {
86 super();
87 this.formKey = formKey;
88 this.value = value;
89 this.savedKey = savedKey;
90 this.searchableAttributeValue = searchableAttributeValue;
91 }
92
93 public boolean isComponentLowerBoundValue() {
94 return isComponentGivenBoundValue(KEWConstants.SearchableAttributeConstants.RANGE_LOWER_BOUND_PROPERTY_PREFIX);
95 }
96
97 public boolean isComponentUpperBoundValue() {
98 return isComponentGivenBoundValue(KEWConstants.SearchableAttributeConstants.RANGE_UPPER_BOUND_PROPERTY_PREFIX);
99 }
100
101 private boolean isComponentGivenBoundValue(String boundKeyPrefix) {
102 if (!isRangeSearch()) {
103 String errorMsg = "Criteria Component with formKey value '" + formKey + "' is not part of a range search";
104 LOG.error("isComponentGivenBoundValue() " + errorMsg);
105 throw new RuntimeException(errorMsg);
106 }
107 return formKey.indexOf(boundKeyPrefix) == 0;
108 }
109
110 public boolean isNonBlankValueGiven() {
111 return ( (StringUtils.isNotBlank(getValue())) || (!CollectionUtils.isEmpty(getValues())) );
112 }
113
114
115
116
117 public boolean isCanHoldMultipleValues() {
118 return canHoldMultipleValues;
119 }
120
121
122
123
124 public void setCanHoldMultipleValues(boolean canHoldMultipleValues) {
125 this.canHoldMultipleValues = canHoldMultipleValues;
126 }
127
128
129
130
131 public boolean isSearchable() {
132 return searchable;
133 }
134
135
136
137
138 public void setSearchable(boolean searchable) {
139 this.searchable = searchable;
140 }
141
142
143
144
145 public boolean isCaseSensitive() {
146 return caseSensitive;
147 }
148
149
150
151
152 public void setCaseSensitive(boolean caseSensitive) {
153 this.caseSensitive = caseSensitive;
154 }
155
156
157
158
159 public String getFormKey() {
160 return formKey;
161 }
162
163
164
165
166 public void setFormKey(String formKey) {
167 this.formKey = formKey;
168 }
169
170
171
172
173 public boolean isRangeSearch() {
174 return rangeSearch;
175 }
176
177
178
179
180 public void setRangeSearch(boolean rangeSearch) {
181 this.rangeSearch = rangeSearch;
182 }
183
184
185
186
187 public String getSavedKey() {
188 return savedKey;
189 }
190
191
192
193
194 public void setSavedKey(String savedKey) {
195 this.savedKey = savedKey;
196 }
197
198
199
200
201 public SearchableAttributeValue getSearchableAttributeValue() {
202 return searchableAttributeValue;
203 }
204
205
206
207
208 public void setSearchableAttributeValue(
209 SearchableAttributeValue searchableAttributeValue) {
210 this.searchableAttributeValue = searchableAttributeValue;
211 }
212
213
214
215
216 public boolean isSearchInclusive() {
217 return searchInclusive;
218 }
219
220
221
222
223 public void setSearchInclusive(boolean searchInclusive) {
224 this.searchInclusive = searchInclusive;
225 }
226
227
228
229
230 public String getValue() {
231 return value;
232 }
233
234
235
236
237 public void setValue(String value) {
238 this.value = value;
239 }
240
241
242
243
244 public List<String> getValues() {
245 return values;
246 }
247
248
249
250
251 public void setValues(List<String> values) {
252 this.values = values;
253 }
254
255
256
257
258 public String getLookupableFieldType() {
259 return lookupableFieldType;
260 }
261
262
263
264
265 public void setLookupableFieldType(String lookupableFieldType) {
266 this.lookupableFieldType = lookupableFieldType;
267 }
268
269
270
271
272 public boolean isAllowInlineRange() {
273 return this.allowInlineRange;
274 }
275
276
277
278
279 public void setAllowInlineRange(boolean allowInlineRange) {
280 this.allowInlineRange = allowInlineRange;
281 }
282
283 }