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.hibernate.annotations.GenericGenerator; |
20 | |
import org.hibernate.annotations.Parameter; |
21 | |
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
22 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
23 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
24 | |
import org.kuali.rice.kew.util.KEWConstants; |
25 | |
|
26 | |
import javax.persistence.*; |
27 | |
import java.io.Serializable; |
28 | |
import java.sql.ResultSet; |
29 | |
import java.sql.SQLException; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | @Entity |
37 | |
@Table(name="KREW_DOC_HDR_EXT_T") |
38 | |
|
39 | |
@NamedQueries({ |
40 | |
@NamedQuery(name="SearchableAttributeStringValue.FindByDocumentId", query="select s from SearchableAttributeStringValue as s where s.documentId = :documentId"), |
41 | |
@NamedQuery(name="SearchableAttributeStringValue.FindByKey", query="select s from SearchableAttributeStringValue as s where s.documentId = :documentId and s.searchableAttributeKey = :searchableAttributeKey") |
42 | |
}) |
43 | |
public class SearchableAttributeStringValue implements SearchableAttributeValue, Serializable { |
44 | |
|
45 | |
private static final long serialVersionUID = 8696089933682052078L; |
46 | |
|
47 | |
private static final String ATTRIBUTE_DATABASE_TABLE_NAME = "KREW_DOC_HDR_EXT_T"; |
48 | |
private static final boolean DEFAULT_WILDCARD_ALLOWANCE_POLICY = true; |
49 | |
private static final boolean ALLOWS_RANGE_SEARCH = true; |
50 | |
private static final boolean ALLOWS_CASE_INSENSITIVE_SEARCH = true; |
51 | |
private static final String ATTRIBUTE_XML_REPRESENTATION = KEWConstants.SearchableAttributeConstants.DATA_TYPE_STRING; |
52 | |
private static final int STRING_MAX_LENGTH = 2000; |
53 | |
|
54 | |
@Id |
55 | |
@GeneratedValue(generator="KREW_SRCH_ATTR_S") |
56 | |
@GenericGenerator(name="KREW_SRCH_ATTR_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
57 | |
@Parameter(name="sequence_name",value="KREW_SRCH_ATTR_S"), |
58 | |
@Parameter(name="value_column",value="id") |
59 | |
}) |
60 | |
@Column(name="DOC_HDR_EXT_ID") |
61 | |
private String searchableAttributeValueId; |
62 | |
@Column(name="KEY_CD") |
63 | |
private String searchableAttributeKey; |
64 | |
@Column(name="VAL") |
65 | |
private String searchableAttributeValue; |
66 | |
@Transient |
67 | |
protected String ojbConcreteClass; |
68 | |
|
69 | |
@Column(name="DOC_HDR_ID") |
70 | |
private String documentId; |
71 | |
@ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST}) |
72 | |
@JoinColumn(name="DOC_HDR_ID", insertable=false, updatable=false) |
73 | |
private DocumentRouteHeaderValue routeHeader; |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
public SearchableAttributeStringValue() { |
79 | 0 | super(); |
80 | 0 | this.ojbConcreteClass = this.getClass().getName(); |
81 | 0 | } |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
public void setupAttributeValue(String value) { |
87 | 0 | this.setSearchableAttributeValue(value); |
88 | 0 | } |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
public void setupAttributeValue(ResultSet resultSet, String columnName) throws SQLException { |
94 | 0 | this.setSearchableAttributeValue(resultSet.getString(columnName)); |
95 | 0 | } |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
public String getSearchableAttributeDisplayValue() { |
101 | 0 | return getSearchableAttributeValue(); |
102 | |
} |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public String getAttributeDataType() { |
108 | 0 | return ATTRIBUTE_XML_REPRESENTATION; |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
public String getAttributeTableName() { |
115 | 0 | return ATTRIBUTE_DATABASE_TABLE_NAME; |
116 | |
} |
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
public boolean allowsWildcards() { |
122 | 0 | return DEFAULT_WILDCARD_ALLOWANCE_POLICY; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
public boolean allowsCaseInsensitivity() { |
129 | 0 | return ALLOWS_CASE_INSENSITIVE_SEARCH; |
130 | |
} |
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
public boolean allowsRangeSearches() { |
136 | 0 | return ALLOWS_RANGE_SEARCH; |
137 | |
} |
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
public boolean isPassesDefaultValidation(String valueEntered) { |
146 | 0 | if (valueEntered != null && (valueEntered.length() > STRING_MAX_LENGTH)) { |
147 | 0 | return false; |
148 | |
} |
149 | 0 | return true; |
150 | |
} |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
public Boolean isRangeValid(String lowerValue, String upperValue) { |
156 | 0 | if (allowsRangeSearches()) { |
157 | 0 | return true; |
158 | |
} |
159 | 0 | return null; |
160 | |
} |
161 | |
|
162 | |
public String getOjbConcreteClass() { |
163 | 0 | return ojbConcreteClass; |
164 | |
} |
165 | |
|
166 | |
public void setOjbConcreteClass(String ojbConcreteClass) { |
167 | 0 | this.ojbConcreteClass = ojbConcreteClass; |
168 | 0 | } |
169 | |
|
170 | |
public DocumentRouteHeaderValue getRouteHeader() { |
171 | 0 | return routeHeader; |
172 | |
} |
173 | |
|
174 | |
public void setRouteHeader(DocumentRouteHeaderValue routeHeader) { |
175 | 0 | this.routeHeader = routeHeader; |
176 | 0 | } |
177 | |
|
178 | |
public String getDocumentId() { |
179 | 0 | return documentId; |
180 | |
} |
181 | |
|
182 | |
public void setDocumentId(String documentId) { |
183 | 0 | this.documentId = documentId; |
184 | 0 | } |
185 | |
|
186 | |
public String getSearchableAttributeKey() { |
187 | 0 | return searchableAttributeKey; |
188 | |
} |
189 | |
|
190 | |
public void setSearchableAttributeKey(String searchableAttributeKey) { |
191 | 0 | this.searchableAttributeKey = searchableAttributeKey; |
192 | 0 | } |
193 | |
|
194 | |
public String getSearchableAttributeValue() { |
195 | 0 | return searchableAttributeValue; |
196 | |
} |
197 | |
|
198 | |
public void setSearchableAttributeValue(String searchableAttributeValue) { |
199 | 0 | this.searchableAttributeValue = searchableAttributeValue; |
200 | 0 | } |
201 | |
|
202 | |
public String getSearchableAttributeValueId() { |
203 | 0 | return searchableAttributeValueId; |
204 | |
} |
205 | |
|
206 | |
public void setSearchableAttributeValueId(String searchableAttributeValueId) { |
207 | 0 | this.searchableAttributeValueId = searchableAttributeValueId; |
208 | 0 | } |
209 | |
|
210 | |
|
211 | |
public void beforeInsert(){ |
212 | 0 | OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager()); |
213 | 0 | } |
214 | |
} |
215 | |
|