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