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.List;
22
23 import javax.persistence.EntityManager;
24 import javax.persistence.PersistenceContext;
25 import javax.persistence.Query;
26
27 import org.kuali.rice.kew.docsearch.SearchableAttributeDateTimeValue;
28 import org.kuali.rice.kew.docsearch.SearchableAttributeFloatValue;
29 import org.kuali.rice.kew.docsearch.SearchableAttributeLongValue;
30 import org.kuali.rice.kew.docsearch.SearchableAttributeStringValue;
31 import org.kuali.rice.kew.docsearch.dao.SearchableAttributeDAO;
32
33
34
35
36
37
38
39 public class SearchableAttributeDAOJpaImpl implements SearchableAttributeDAO {
40
41 @PersistenceContext(unitName = "kew-unit")
42 private EntityManager entityManager;
43
44
45
46
47
48
49
50 public List<Timestamp> getSearchableAttributeDateTimeValuesByKey(
51 Long documentId, String key) {
52
53 List<Timestamp> lRet = null;
54 Query query = entityManager.createNamedQuery("SearchableAttributeDateTimeValue.FindByKey");
55 query.setParameter("routeHeaderId", documentId);
56 query.setParameter("searchableAttributeKey", key);
57 List<SearchableAttributeDateTimeValue> results = query.getResultList();
58 if (!results.isEmpty()) {
59 lRet = new ArrayList<Timestamp>();
60 for (SearchableAttributeDateTimeValue attribute: results) {
61 lRet.add(attribute.getSearchableAttributeValue());
62 }
63 }
64 return lRet;
65 }
66
67
68
69
70
71
72
73 public List<BigDecimal> getSearchableAttributeFloatValuesByKey(
74 Long documentId, String key) {
75 List<BigDecimal> lRet = null;
76 Query query = entityManager.createNamedQuery("SearchableAttributeFloatValue.FindByKey");
77 query.setParameter("routeHeaderId", documentId);
78 query.setParameter("searchableAttributeKey", key);
79 List<SearchableAttributeFloatValue> results = query.getResultList();
80 if (!results.isEmpty()) {
81 lRet = new ArrayList<BigDecimal>();
82 for (SearchableAttributeFloatValue attribute: results) {
83 lRet.add(attribute.getSearchableAttributeValue());
84 }
85 }
86 return lRet;
87 }
88
89
90
91
92
93
94
95 public List<Long> getSearchableAttributeLongValuesByKey(Long documentId,
96 String key) {
97 List<Long> lRet = null;
98 Query query = entityManager.createNamedQuery("SearchableAttributeLongValue.FindByKey");
99 query.setParameter("routeHeaderId", documentId);
100 query.setParameter("searchableAttributeKey", key);
101 List<SearchableAttributeLongValue> results = query.getResultList();
102 if (!results.isEmpty()) {
103 lRet = new ArrayList<Long>();
104 for (SearchableAttributeLongValue attribute: results) {
105 lRet.add(attribute.getSearchableAttributeValue());
106 }
107 }
108 return lRet;
109 }
110
111
112
113
114
115
116
117 public List<String> getSearchableAttributeStringValuesByKey(
118 Long documentId, String key) {
119 List<String> lRet = null;
120 Query query = entityManager.createNamedQuery("SearchableAttributeStringValue.FindByKey");
121 query.setParameter("routeHeaderId", documentId);
122 query.setParameter("searchableAttributeKey", key);
123 List<SearchableAttributeStringValue> results = query.getResultList();
124 if (!results.isEmpty()) {
125 lRet = new ArrayList<String>();
126 for (SearchableAttributeStringValue attribute: results) {
127 lRet.add(attribute.getSearchableAttributeValue());
128 }
129 }
130 return lRet;
131 }
132
133 public EntityManager getEntityManager() {
134 return this.entityManager;
135 }
136
137 public void setEntityManager(EntityManager entityManager) {
138 this.entityManager = entityManager;
139 }
140
141 }