1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation;
17
18 import org.kuali.rice.core.framework.persistence.jdbc.sql.SQLUtils;
19 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
20 import org.kuali.rice.krad.util.DataTypeUtil;
21
22 import java.sql.Timestamp;
23 import java.text.SimpleDateFormat;
24 import java.util.Date;
25 import java.util.List;
26
27
28
29
30
31
32
33
34 public abstract class BaseAttributeValueReader implements AttributeValueReader {
35
36 protected String entryName;
37 protected String attributeName;
38
39 @Override
40 public List<String> getCleanSearchableValues(String attributeKey) throws AttributeValidationException {
41 Class<?> attributeType = getType(attributeKey);
42 Object rawValue = getValue(attributeKey);
43 String attributeInValue = "";
44
45 if (rawValue != null) {
46
47 if (rawValue instanceof Date && !(rawValue instanceof Timestamp)) {
48 attributeInValue = new SimpleDateFormat("MM-dd-yyyy").format(rawValue);
49 } else {
50 attributeInValue = rawValue.toString();
51 }
52 }
53
54 String attributeDataType = DataTypeUtil.determineDataType(attributeType);
55 return SQLUtils.getCleanedSearchableValues(attributeInValue, attributeDataType);
56 }
57
58
59
60
61 @Override
62 public String getAttributeName() {
63 return this.attributeName;
64 }
65
66
67
68
69 @Override
70 public void setAttributeName(String currentName) {
71 this.attributeName = currentName;
72 }
73
74
75
76
77 @Override
78 public String getEntryName() {
79 return this.entryName;
80 }
81
82 @Override
83 public abstract AttributeValueReader clone();
84
85 }