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 public class SearchableAttributeDAOOjbImpl extends PersistenceBrokerDaoSupport implements SearchableAttributeDAO {
40
41 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 List<Timestamp> lRet = null;
52
53 Criteria crit = new Criteria();
54 crit.addEqualTo("documentId", documentId);
55 crit.addEqualTo("searchableAttributeKey", key);
56 Collection<SearchableAttributeDateTimeValue> collection = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(SearchableAttributeDateTimeValue.class, crit));
57
58 if(collection != null && !collection.isEmpty()){
59 lRet = new ArrayList<Timestamp>();
60 for(SearchableAttributeDateTimeValue value:collection){
61 lRet.add(value.getSearchableAttributeValue());
62 }
63 }
64
65 return lRet;
66 }
67
68
69
70
71
72
73 public List<BigDecimal> getSearchableAttributeFloatValuesByKey(
74 String documentId, String key) {
75 List<BigDecimal> lRet = null;
76
77 Criteria crit = new Criteria();
78 crit.addEqualTo("documentId", documentId);
79 crit.addEqualTo("searchableAttributeKey", key);
80 Collection<SearchableAttributeFloatValue> collection = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(SearchableAttributeFloatValue.class, crit));
81
82 if(collection != null && !collection.isEmpty()){
83 lRet = new ArrayList<BigDecimal>();
84 for(SearchableAttributeFloatValue value:collection){
85 lRet.add(value.getSearchableAttributeValue());
86 }
87 }
88
89 return lRet;
90 }
91
92
93
94
95
96
97 public List<String> getSearchableAttributeStringValuesByKey(
98 String documentId, String key) {
99
100 List<String> lRet = null;
101
102 Criteria crit = new Criteria();
103 crit.addEqualTo("documentId", documentId);
104 crit.addEqualTo("searchableAttributeKey", key);
105 Collection<SearchableAttributeStringValue> collection = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(SearchableAttributeStringValue.class, crit));
106
107 if(collection != null && !collection.isEmpty()){
108 lRet = new ArrayList<String>();
109 for(SearchableAttributeStringValue value:collection){
110 lRet.add(value.getSearchableAttributeValue());
111 }
112 }
113
114 return lRet;
115 }
116
117
118
119
120
121
122 public List<Long> getSearchableAttributeLongValuesByKey(String documentId,
123 String key) {
124 List<Long> lRet = null;
125
126 Criteria crit = new Criteria();
127 crit.addEqualTo("documentId", documentId);
128 crit.addEqualTo("searchableAttributeKey", key);
129 Collection<SearchableAttributeLongValue> collection = getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(SearchableAttributeLongValue.class, crit));
130
131 if(collection != null && !collection.isEmpty()){
132 lRet = new ArrayList<Long>();
133 for(SearchableAttributeLongValue value:collection){
134 lRet.add(value.getSearchableAttributeValue());
135 }
136 }
137
138 return lRet;
139 }
140
141 }