1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.docsearch.dao.impl; |
17 | |
|
18 | |
import java.math.BigDecimal; |
19 | |
import java.sql.Timestamp; |
20 | |
import java.util.ArrayList; |
21 | |
import java.util.Collection; |
22 | |
import java.util.List; |
23 | |
|
24 | |
import org.apache.ojb.broker.query.Criteria; |
25 | |
import org.apache.ojb.broker.query.QueryByCriteria; |
26 | |
import org.kuali.rice.kew.docsearch.SearchableAttributeDateTimeValue; |
27 | |
import org.kuali.rice.kew.docsearch.SearchableAttributeFloatValue; |
28 | |
import org.kuali.rice.kew.docsearch.SearchableAttributeLongValue; |
29 | |
import org.kuali.rice.kew.docsearch.SearchableAttributeStringValue; |
30 | |
import org.kuali.rice.kew.docsearch.dao.SearchableAttributeDAO; |
31 | |
import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class SearchableAttributeDAOOjbImpl extends PersistenceBrokerDaoSupport implements SearchableAttributeDAO { |
40 | |
|
41 | 0 | public static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SearchableAttributeDAOOjbImpl.class); |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public List<Timestamp> getSearchableAttributeDateTimeValuesByKey( |
49 | |
String documentId, String key) { |
50 | |
|
51 | 0 | List<Timestamp> lRet = null; |
52 | |
|
53 | 0 | Criteria crit = new Criteria(); |
54 | 0 | crit.addEqualTo("documentId", documentId); |
55 | 0 | crit.addEqualTo("searchableAttributeKey", key); |
56 | 0 | Collection<SearchableAttributeDateTimeValue> collection = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(SearchableAttributeDateTimeValue.class, crit)); |
57 | |
|
58 | 0 | if(collection != null && !collection.isEmpty()){ |
59 | 0 | lRet = new ArrayList<Timestamp>(); |
60 | 0 | for(SearchableAttributeDateTimeValue value:collection){ |
61 | 0 | lRet.add(value.getSearchableAttributeValue()); |
62 | |
} |
63 | |
} |
64 | |
|
65 | 0 | return lRet; |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
public List<BigDecimal> getSearchableAttributeFloatValuesByKey( |
74 | |
String documentId, String key) { |
75 | 0 | List<BigDecimal> lRet = null; |
76 | |
|
77 | 0 | Criteria crit = new Criteria(); |
78 | 0 | crit.addEqualTo("documentId", documentId); |
79 | 0 | crit.addEqualTo("searchableAttributeKey", key); |
80 | 0 | Collection<SearchableAttributeFloatValue> collection = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(SearchableAttributeFloatValue.class, crit)); |
81 | |
|
82 | 0 | if(collection != null && !collection.isEmpty()){ |
83 | 0 | lRet = new ArrayList<BigDecimal>(); |
84 | 0 | for(SearchableAttributeFloatValue value:collection){ |
85 | 0 | lRet.add(value.getSearchableAttributeValue()); |
86 | |
} |
87 | |
} |
88 | |
|
89 | 0 | return lRet; |
90 | |
} |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
public List<String> getSearchableAttributeStringValuesByKey( |
98 | |
String documentId, String key) { |
99 | |
|
100 | 0 | List<String> lRet = null; |
101 | |
|
102 | 0 | Criteria crit = new Criteria(); |
103 | 0 | crit.addEqualTo("documentId", documentId); |
104 | 0 | crit.addEqualTo("searchableAttributeKey", key); |
105 | 0 | Collection<SearchableAttributeStringValue> collection = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(SearchableAttributeStringValue.class, crit)); |
106 | |
|
107 | 0 | if(collection != null && !collection.isEmpty()){ |
108 | 0 | lRet = new ArrayList<String>(); |
109 | 0 | for(SearchableAttributeStringValue value:collection){ |
110 | 0 | lRet.add(value.getSearchableAttributeValue()); |
111 | |
} |
112 | |
} |
113 | |
|
114 | 0 | return lRet; |
115 | |
} |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public List<Long> getSearchableAttributeLongValuesByKey(String documentId, |
123 | |
String key) { |
124 | 0 | List<Long> lRet = null; |
125 | |
|
126 | 0 | Criteria crit = new Criteria(); |
127 | 0 | crit.addEqualTo("documentId", documentId); |
128 | 0 | crit.addEqualTo("searchableAttributeKey", key); |
129 | 0 | Collection<SearchableAttributeLongValue> collection = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(SearchableAttributeLongValue.class, crit)); |
130 | |
|
131 | 0 | if(collection != null && !collection.isEmpty()){ |
132 | 0 | lRet = new ArrayList<Long>(); |
133 | 0 | for(SearchableAttributeLongValue value:collection){ |
134 | 0 | lRet.add(value.getSearchableAttributeValue()); |
135 | |
} |
136 | |
} |
137 | |
|
138 | 0 | return lRet; |
139 | |
} |
140 | |
|
141 | |
} |