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