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.lookupable;
018:
019: import java.util.HashMap;
020: import java.util.HashSet;
021: import java.util.List;
022: import java.util.Map;
023: import java.util.Set;
024:
025: import org.apache.commons.lang.StringUtils;
026:
027: import edu.iu.uis.eden.docsearch.SearchableAttribute;
028: import edu.iu.uis.eden.plugin.attributes.WorkflowLookupable;
029:
030: /**
031: * A field of data used by {@link WorkflowLookupable} implementations. The field is typed according to
032: * the type of field it is and how it should be rendered on the Lookupable.
033: *
034: * @see WorkflowLookupable
035: *
036: * @author jhopf
037: * @author rkirkend
038: */
039: public class Field implements java.io.Serializable {
040:
041: private static final long serialVersionUID = 8497421452176749283L;
042:
043: public static final String HIDDEN = "hidden";
044: public static final String TEXT = "text";
045: public static final String DROPDOWN = "dropdown";
046: public static final String RADIO = "radio";
047: public static final String QUICKFINDER = "quickFinder";
048: public static final String DATEPICKER = "datePicker";
049: public static final String LOOKUP_RESULT_ONLY = "lookupresultonly";
050: public static final String DROPDOWN_REFRESH = "dropdown_refresh";
051: public static final String MULTIBOX = "multibox";
052: public static final String CHECKBOX_YES_NO = "checkbox_yes_no";
053: public static final String CHECKBOX_PRESENT = "checkbox_present";
054:
055: public static final Set SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES;
056: public static final Set MULTI_VALUE_FIELD_TYPES = new HashSet();
057: static {
058: SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES = new HashSet();
059: SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES.add(HIDDEN);
060: SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES.add(TEXT);
061: SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES.add(DROPDOWN);
062: SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES.add(RADIO);
063: SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES.add(DROPDOWN_REFRESH);
064: SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES.add(MULTIBOX);
065: SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES.add(CHECKBOX_YES_NO);
066: SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES.add(CHECKBOX_PRESENT);
067:
068: MULTI_VALUE_FIELD_TYPES.add(MULTIBOX);
069: }
070:
071: private static final Boolean DEFAULT_ALLOW_WILDCARD_VALUE = Boolean.TRUE;
072: private static final Boolean DEFAULT_AUTO_WILDCARD_BEGINNING_VALUE = Boolean.FALSE;
073: private static final Boolean DEFAULT_AUTO_WILDCARD_ENDING_VALUE = Boolean.FALSE;
074: private static final Boolean DEFAULT_CASE_SENSITIVE_VALUE = Boolean.TRUE;
075: private static final Boolean DEFAULT_RANGE_FIELD_INCLUSIVE_VALUE = Boolean.TRUE;
076: public static final String CHECKBOX_VALUE_CHECKED = "Yes";
077: public static final String CHECKBOX_VALUE_UNCHECKED = "No";
078:
079: // fields for display
080: private String fieldType;
081: private boolean hasLookupable;
082: private Boolean hasDatePicker = null;//
083: private String fieldLabel;
084: private String fieldHelpUrl;
085: private String propertyName;
086: private String propertyValue;
087: private String[] propertyValues;
088: private String defaultLookupableName;
089: private List fieldValidValues;
090: private String quickFinderClassNameImpl;
091: private Map<String, String> displayParameters = new HashMap<String, String>();
092:
093: // this field is currently a hack to allow us to indicate whether or not the column of data associated
094: // with a particular field will be visible in the result set of a search or not
095: private boolean isColumnVisible = true;
096:
097: // fields for behind the scenes
098: private String fieldDataType = SearchableAttribute.DEFAULT_SEARCHABLE_ATTRIBUTE_TYPE_NAME;//
099: private Boolean allowWildcards;//
100: private Boolean autoWildcardBeginning;//
101: private Boolean autoWildcardEnding;//
102: private Boolean caseSensitive;//
103:
104: private boolean searchable = true;
105:
106: // following values used in ranged searches
107: private String mainFieldLabel; // the fieldLabel holds things like "From" and "Ending" and this field holds things like "Total Amount"
108: private Boolean rangeFieldInclusive;//
109: private String savablePropertyName = null;//
110: private boolean memberOfRange = false;//
111:
112: public Field() {
113: }
114:
115: public Field(String fieldLabel, String fieldHelpUrl,
116: String fieldType, boolean hasLookupable,
117: String propertyName, String propertyValue,
118: List fieldValidValues, String quickFinderClassNameImpl) {
119: this (fieldLabel, fieldHelpUrl, fieldType, hasLookupable,
120: propertyName, propertyValue, fieldValidValues,
121: quickFinderClassNameImpl, null);
122: }
123:
124: public Field(String fieldLabel, String fieldHelpUrl,
125: String fieldType, boolean hasLookupable,
126: String propertyName, String[] propertyValues,
127: List fieldValidValues, String quickFinderClassNameImpl) {
128: this (fieldLabel, fieldHelpUrl, fieldType, hasLookupable,
129: propertyName, propertyValues, fieldValidValues,
130: quickFinderClassNameImpl, null);
131: }
132:
133: public Field(String fieldLabel, String fieldHelpUrl,
134: String fieldType, boolean hasLookupable,
135: String propertyName, String propertyValue,
136: List fieldValidValues, String quickFinderClassNameImpl,
137: String defaultLookupableName) {
138: setupField(fieldLabel, fieldHelpUrl, fieldType, hasLookupable,
139: propertyName, fieldValidValues,
140: quickFinderClassNameImpl, defaultLookupableName);
141: this .propertyValue = propertyValue;
142: }
143:
144: public Field(String fieldLabel, String fieldHelpUrl,
145: String fieldType, boolean hasLookupable,
146: String propertyName, String[] propertyValues,
147: List fieldValidValues, String quickFinderClassNameImpl,
148: String defaultLookupableName) {
149: setupField(fieldLabel, fieldHelpUrl, fieldType, hasLookupable,
150: propertyName, fieldValidValues,
151: quickFinderClassNameImpl, defaultLookupableName);
152: this .propertyValues = propertyValues;
153: }
154:
155: private void setupField(String fieldLabel, String fieldHelpUrl,
156: String fieldType, boolean hasLookupable,
157: String propertyName, List fieldValidValues,
158: String quickFinderClassNameImpl,
159: String defaultLookupableName) {
160: this .fieldLabel = fieldLabel;
161: this .fieldHelpUrl = fieldHelpUrl;
162: this .fieldType = fieldType;
163: this .hasLookupable = hasLookupable;
164: this .propertyName = propertyName;
165: this .savablePropertyName = propertyName;
166: this .fieldValidValues = fieldValidValues;
167: this .quickFinderClassNameImpl = quickFinderClassNameImpl;
168: this .defaultLookupableName = defaultLookupableName;
169: }
170:
171: public void populateFieldFromExistingField(Field existingField) {
172: setColumnVisible(existingField.isColumnVisible());
173: setFieldDataType(existingField.getFieldDataType());
174: setFieldHelpUrl(existingField.getFieldHelpUrl());
175: setFieldType(existingField.getFieldType());
176: setMainFieldLabel(existingField.getFieldLabel());
177: setFieldValidValues(existingField.getFieldValidValues());
178: setSavablePropertyName(existingField.getPropertyName());
179: setQuickFinderClassNameImpl(existingField
180: .getQuickFinderClassNameImpl());
181: setHasLookupable(existingField.isHasLookupable());
182: setDefaultLookupableName(existingField
183: .getDefaultLookupableName());
184: setDisplayParameters(existingField.getDisplayParameters());
185: }
186:
187: public boolean isInclusive() {
188: return getPolicyBooleanValue(
189: DEFAULT_RANGE_FIELD_INCLUSIVE_VALUE,
190: rangeFieldInclusive);
191: }
192:
193: public boolean isAllowingWildcards() {
194: return getPolicyBooleanValue(DEFAULT_ALLOW_WILDCARD_VALUE,
195: allowWildcards);
196: }
197:
198: public boolean isCaseSensitive() {
199: return getPolicyBooleanValue(DEFAULT_CASE_SENSITIVE_VALUE,
200: caseSensitive);
201: }
202:
203: public boolean isAutoWildcardAtBeginning() {
204: return getPolicyBooleanValue(
205: DEFAULT_AUTO_WILDCARD_BEGINNING_VALUE,
206: autoWildcardBeginning);
207: }
208:
209: public boolean isAutoWildcardAtEnding() {
210: return getPolicyBooleanValue(
211: DEFAULT_AUTO_WILDCARD_ENDING_VALUE, autoWildcardEnding);
212: }
213:
214: public boolean isUsingDatePicker() {
215: return getPolicyBooleanValue(Boolean
216: .valueOf(SearchableAttribute.DATA_TYPE_DATE
217: .equalsIgnoreCase(this .fieldDataType)),
218: hasDatePicker);
219: }
220:
221: private boolean getPolicyBooleanValue(Boolean defaultValue,
222: Boolean valueSet) {
223: if (valueSet != null) {
224: return valueSet.booleanValue();
225: }
226: return defaultValue.booleanValue();
227: }
228:
229: /**
230: * Helper method to determine if this is a field that collects data.
231: *
232: * @param fieldType
233: */
234: public boolean isInputField() {
235: if (StringUtils.isBlank(fieldType)) {
236: return false;
237: }
238: if (fieldType.equals(Field.DROPDOWN)
239: || fieldType.equals(Field.DROPDOWN_REFRESH)
240: || fieldType.equals(Field.TEXT)
241: || fieldType.equals(Field.RADIO)
242: || fieldType.equals(Field.HIDDEN)) {
243: return true;
244: } else {
245: return false;
246: }
247:
248: }
249:
250: public String getDisplayParameterValue(String key) {
251: return displayParameters.get(key);
252: }
253:
254: public void addDisplayParameter(String key, String value) {
255: displayParameters.put(key, value);
256: }
257:
258: /**
259: * @return the displayParameters
260: */
261: public Map<String, String> getDisplayParameters() {
262: return displayParameters;
263: }
264:
265: /**
266: * @param displayParameters the displayParameters to set
267: */
268: public void setDisplayParameters(
269: Map<String, String> displayParameters) {
270: this .displayParameters = displayParameters;
271: }
272:
273: /**
274: * @return the allowWildcards
275: */
276: public Boolean getAllowWildcards() {
277: return allowWildcards;
278: }
279:
280: /**
281: * @param allowWildcards the allowWildcards to set
282: */
283: public void setAllowWildcards(Boolean allowWildcards) {
284: this .allowWildcards = allowWildcards;
285: }
286:
287: /**
288: * @return the autoWildcardBeginning
289: */
290: public Boolean getAutoWildcardBeginning() {
291: return autoWildcardBeginning;
292: }
293:
294: /**
295: * @param autoWildcardBeginning the autoWildcardBeginning to set
296: */
297: public void setAutoWildcardBeginning(Boolean autoWildcardBeginning) {
298: this .autoWildcardBeginning = autoWildcardBeginning;
299: }
300:
301: /**
302: * @return the autoWildcardEnding
303: */
304: public Boolean getAutoWildcardEnding() {
305: return autoWildcardEnding;
306: }
307:
308: /**
309: * @param autoWildcardEnding the autoWildcardEnding to set
310: */
311: public void setAutoWildcardEnding(Boolean autoWildcardEnding) {
312: this .autoWildcardEnding = autoWildcardEnding;
313: }
314:
315: /**
316: * @return the caseSensitive
317: */
318: public Boolean getCaseSensitive() {
319: return caseSensitive;
320: }
321:
322: /**
323: * @param caseSensitive the caseSensitive to set
324: */
325: public void setCaseSensitive(Boolean caseSensitive) {
326: this .caseSensitive = caseSensitive;
327: }
328:
329: /**
330: * @return the defaultLookupableName
331: */
332: public String getDefaultLookupableName() {
333: return defaultLookupableName;
334: }
335:
336: /**
337: * @param defaultLookupableName the defaultLookupableName to set
338: */
339: public void setDefaultLookupableName(String defaultLookupableName) {
340: this .defaultLookupableName = defaultLookupableName;
341: }
342:
343: /**
344: * @return the fieldDataType
345: */
346: public String getFieldDataType() {
347: return fieldDataType;
348: }
349:
350: /**
351: * @param fieldDataType the fieldDataType to set
352: */
353: public void setFieldDataType(String fieldDataType) {
354: this .fieldDataType = fieldDataType;
355: }
356:
357: /**
358: * @return the fieldHelpUrl
359: */
360: public String getFieldHelpUrl() {
361: return fieldHelpUrl;
362: }
363:
364: /**
365: * @param fieldHelpUrl the fieldHelpUrl to set
366: */
367: public void setFieldHelpUrl(String fieldHelpUrl) {
368: this .fieldHelpUrl = fieldHelpUrl;
369: }
370:
371: /**
372: * @return the fieldLabel
373: */
374: public String getFieldLabel() {
375: return fieldLabel;
376: }
377:
378: /**
379: * @param fieldLabel the fieldLabel to set
380: */
381: public void setFieldLabel(String fieldLabel) {
382: this .fieldLabel = fieldLabel;
383: }
384:
385: /**
386: * @return the fieldType
387: */
388: public String getFieldType() {
389: return fieldType;
390: }
391:
392: /**
393: * @param fieldType the fieldType to set
394: */
395: public void setFieldType(String fieldType) {
396: this .fieldType = fieldType;
397: }
398:
399: /**
400: * @return the fieldValidValues
401: */
402: public List getFieldValidValues() {
403: return fieldValidValues;
404: }
405:
406: /**
407: * @param fieldValidValues the fieldValidValues to set
408: */
409: public void setFieldValidValues(List fieldValidValues) {
410: this .fieldValidValues = fieldValidValues;
411: }
412:
413: /**
414: * @return the hasDatePicker
415: */
416: public Boolean getHasDatePicker() {
417: return hasDatePicker;
418: }
419:
420: /**
421: * @param hasDatePicker the hasDatePicker to set
422: */
423: public void setHasDatePicker(Boolean hasDatePicker) {
424: this .hasDatePicker = hasDatePicker;
425: }
426:
427: /**
428: * @return the hasLookupable
429: */
430: public boolean isHasLookupable() {
431: return hasLookupable;
432: }
433:
434: /**
435: * @param hasLookupable the hasLookupable to set
436: */
437: public void setHasLookupable(boolean hasLookupable) {
438: this .hasLookupable = hasLookupable;
439: }
440:
441: /**
442: * @return the isColumnVisible
443: */
444: public boolean isColumnVisible() {
445: return isColumnVisible;
446: }
447:
448: /**
449: * @param isColumnVisible the isColumnVisible to set
450: */
451: public void setColumnVisible(boolean isColumnVisible) {
452: this .isColumnVisible = isColumnVisible;
453: }
454:
455: /**
456: * @return the memberOfRange
457: */
458: public boolean isMemberOfRange() {
459: return memberOfRange;
460: }
461:
462: /**
463: * @param memberOfRange the memberOfRange to set
464: */
465: public void setMemberOfRange(boolean memberOfRange) {
466: this .memberOfRange = memberOfRange;
467: }
468:
469: /**
470: * @return the propertyName
471: */
472: public String getPropertyName() {
473: return propertyName;
474: }
475:
476: /**
477: * @param propertyName the propertyName to set
478: */
479: public void setPropertyName(String propertyName) {
480: this .propertyName = propertyName;
481: }
482:
483: /**
484: * @return the propertyValue
485: */
486: public String getPropertyValue() {
487: return propertyValue;
488: }
489:
490: /**
491: * @param propertyValue the propertyValue to set
492: */
493: public void setPropertyValue(String propertyValue) {
494: this .propertyValue = propertyValue;
495: }
496:
497: /**
498: * @return the quickFinderClassNameImpl
499: */
500: public String getQuickFinderClassNameImpl() {
501: return quickFinderClassNameImpl;
502: }
503:
504: /**
505: * @param quickFinderClassNameImpl the quickFinderClassNameImpl to set
506: */
507: public void setQuickFinderClassNameImpl(
508: String quickFinderClassNameImpl) {
509: this .quickFinderClassNameImpl = quickFinderClassNameImpl;
510: }
511:
512: /**
513: * @return the rangeFieldInclusive
514: */
515: public Boolean getRangeFieldInclusive() {
516: return rangeFieldInclusive;
517: }
518:
519: /**
520: * @param rangeFieldInclusive the rangeFieldInclusive to set
521: */
522: public void setRangeFieldInclusive(Boolean rangeFieldInclusive) {
523: this .rangeFieldInclusive = rangeFieldInclusive;
524: }
525:
526: /**
527: * @return the savablePropertyName
528: */
529: public String getSavablePropertyName() {
530: return savablePropertyName;
531: }
532:
533: /**
534: * @param savablePropertyName the savablePropertyName to set
535: */
536: public void setSavablePropertyName(String savablePropertyName) {
537: this .savablePropertyName = savablePropertyName;
538: }
539:
540: /**
541: * @return the mainFieldLabel
542: */
543: public String getMainFieldLabel() {
544: return mainFieldLabel;
545: }
546:
547: /**
548: * @param mainFieldLabel the mainFieldLabel to set
549: */
550: public void setMainFieldLabel(String mainFieldLabel) {
551: this .mainFieldLabel = mainFieldLabel;
552: }
553:
554: /**
555: * @return the propertyValues
556: */
557: public String[] getPropertyValues() {
558: return propertyValues;
559: }
560:
561: /**
562: * @param propertyValues the propertyValues to set
563: */
564: public void setPropertyValues(String[] propertyValues) {
565: this .propertyValues = propertyValues;
566: }
567:
568: /**
569: * @return the searchable
570: */
571: public boolean isSearchable() {
572: return searchable;
573: }
574:
575: /**
576: * @param searchable the searchable to set
577: */
578: public void setSearchable(boolean searchable) {
579: this .searchable = searchable;
580: }
581:
582: /**
583: * @return the cHECKBOX_PRESENT
584: */
585: public String getCHECKBOX_PRESENT() {
586: return CHECKBOX_PRESENT;
587: }
588:
589: /**
590: * @return the cHECKBOX_YES_NO
591: */
592: public String getCHECKBOX_YES_NO() {
593: return CHECKBOX_YES_NO;
594: }
595:
596: /**
597: * @return the dATEPICKER
598: */
599: public String getDATEPICKER() {
600: return DATEPICKER;
601: }
602:
603: /**
604: * @return the dROPDOWN
605: */
606: public String getDROPDOWN() {
607: return DROPDOWN;
608: }
609:
610: /**
611: * @return the dROPDOWN_REFRESH
612: */
613: public String getDROPDOWN_REFRESH() {
614: return DROPDOWN_REFRESH;
615: }
616:
617: /**
618: * @return the hIDDEN
619: */
620: public String getHIDDEN() {
621: return HIDDEN;
622: }
623:
624: /**
625: * @return the lOOKUP_RESULT_ONLY
626: */
627: public String getLOOKUP_RESULT_ONLY() {
628: return LOOKUP_RESULT_ONLY;
629: }
630:
631: /**
632: * @return the mULTIBOX
633: */
634: public String getMULTIBOX() {
635: return MULTIBOX;
636: }
637:
638: /**
639: * @return the qUICKFINDER
640: */
641: public String getQUICKFINDER() {
642: return QUICKFINDER;
643: }
644:
645: /**
646: * @return the rADIO
647: */
648: public String getRADIO() {
649: return RADIO;
650: }
651:
652: /**
653: * @return the tEXT
654: */
655: public String getTEXT() {
656: return TEXT;
657: }
658:
659: /**
660: * @return the cHECKBOX_VALUE_CHECKED
661: */
662: public String getCHECKBOX_VALUE_CHECKED() {
663: return CHECKBOX_VALUE_CHECKED;
664: }
665:
666: /**
667: * @return the cHECKBOX_VALUE_UNCHECKED
668: */
669: public String getCHECKBOX_VALUE_UNCHECKED() {
670: return CHECKBOX_VALUE_UNCHECKED;
671: }
672:
673: }
|