1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.kuali.rice.ksb.messaging.dao.impl; |
18 |
|
|
19 |
|
import org.apache.commons.lang.StringUtils; |
20 |
|
import org.apache.ojb.broker.query.Criteria; |
21 |
|
import org.apache.ojb.broker.query.QueryByCriteria; |
22 |
|
import org.kuali.rice.core.api.config.property.ConfigContext; |
23 |
|
import org.kuali.rice.core.util.RiceUtilities; |
24 |
|
import org.kuali.rice.ksb.messaging.PersistedMessageBO; |
25 |
|
import org.kuali.rice.ksb.messaging.PersistedMessagePayload; |
26 |
|
import org.kuali.rice.ksb.messaging.dao.MessageQueueDAO; |
27 |
|
import org.kuali.rice.ksb.util.KSBConstants; |
28 |
|
import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport; |
29 |
|
|
30 |
|
import javax.xml.namespace.QName; |
31 |
|
import java.util.List; |
32 |
|
import java.util.Map; |
33 |
|
|
34 |
|
|
|
|
| 0% |
Uncovered Elements: 92 (92) |
Complexity: 20 |
Complexity Density: 0.32 |
|
35 |
|
public class MessageQueueDAOOjbImpl extends PersistenceBrokerDaoSupport implements MessageQueueDAO { |
36 |
|
|
37 |
|
private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(MessageQueueDAOOjbImpl.class); |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
39 |
0
|
public void remove(PersistedMessageBO routeQueue) {... |
40 |
0
|
if (LOG.isDebugEnabled()) { |
41 |
0
|
LOG.debug("Removing message " + routeQueue); |
42 |
|
} |
43 |
0
|
Criteria crit = new Criteria(); |
44 |
0
|
crit.addEqualTo("routeQueueId", routeQueue.getRouteQueueId()); |
45 |
0
|
getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(PersistedMessageBO.class, crit)); |
46 |
|
|
47 |
0
|
crit = new Criteria(); |
48 |
0
|
crit.addEqualTo("routeQueueId", routeQueue.getPayload().getRouteQueueId()); |
49 |
0
|
getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(PersistedMessagePayload.class, crit)); |
50 |
|
} |
51 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
52 |
0
|
public void save(PersistedMessageBO routeQueue) {... |
53 |
0
|
if (LOG.isDebugEnabled()) { |
54 |
0
|
LOG.debug("Persisting message " + routeQueue); |
55 |
|
} |
56 |
0
|
getPersistenceBrokerTemplate().store(routeQueue); |
57 |
0
|
routeQueue.getPayload().setRouteQueueId(routeQueue.getRouteQueueId()); |
58 |
0
|
getPersistenceBrokerTemplate().store(routeQueue.getPayload()); |
59 |
|
} |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
61 |
0
|
@SuppressWarnings("unchecked")... |
62 |
|
public List<PersistedMessageBO> findAll() { |
63 |
0
|
if (LOG.isDebugEnabled()) { |
64 |
0
|
LOG.debug("Returning all persisted messages"); |
65 |
|
} |
66 |
0
|
return (List<PersistedMessageBO>) getPersistenceBrokerTemplate().getCollectionByQuery( |
67 |
|
new QueryByCriteria(PersistedMessageBO.class)); |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
70 |
0
|
@SuppressWarnings("unchecked")... |
71 |
|
public List<PersistedMessageBO> findAll(int maxRows) { |
72 |
0
|
if (LOG.isDebugEnabled()) { |
73 |
0
|
LOG.debug("Finding next " + maxRows + " messages"); |
74 |
|
} |
75 |
0
|
QueryByCriteria query = new QueryByCriteria(PersistedMessageBO.class); |
76 |
0
|
query.setStartAtIndex(0); |
77 |
0
|
query.setEndAtIndex(maxRows); |
78 |
0
|
return (List<PersistedMessageBO>) getPersistenceBrokerTemplate().getCollectionByQuery(query); |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 6 |
Complexity Density: 0.35 |
|
81 |
0
|
@SuppressWarnings("unchecked")... |
82 |
|
public List<PersistedMessageBO> findByValues(Map<String, String> criteriaValues, int maxRows) { |
83 |
0
|
Criteria crit = new Criteria(); |
84 |
0
|
String value = null; |
85 |
0
|
for (String key : criteriaValues.keySet()) { |
86 |
0
|
value = criteriaValues.get(key); |
87 |
0
|
if (StringUtils.isBlank(key) && StringUtils.isBlank(value)) { |
88 |
0
|
throw new IllegalArgumentException("Either the key or value was blank in criteriaValues (" + key + "=" |
89 |
|
+ value + ")"); |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
0
|
if (!key.equals("routeQueueId")) { |
94 |
0
|
if (value.contains("*")) { |
95 |
0
|
value = value.replace("*", "%"); |
96 |
|
} else { |
97 |
0
|
value = value.concat("%"); |
98 |
|
} |
99 |
|
} |
100 |
0
|
if (!StringUtils.containsOnly(value, "%")) { |
101 |
0
|
crit.addLike(key, value); |
102 |
|
} |
103 |
|
} |
104 |
0
|
QueryByCriteria query = new QueryByCriteria(PersistedMessageBO.class, crit); |
105 |
0
|
query.setFetchSize(maxRows); |
106 |
0
|
query.setStartAtIndex(0); |
107 |
0
|
query.setEndAtIndex(maxRows); |
108 |
0
|
return (List<PersistedMessageBO>) getPersistenceBrokerTemplate().getCollectionByQuery(query); |
109 |
|
} |
110 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
111 |
0
|
public PersistedMessageBO findByRouteQueueId(Long routeQueueId) {... |
112 |
0
|
Criteria criteria = new Criteria(); |
113 |
0
|
criteria.addEqualTo("routeQueueId", routeQueueId); |
114 |
0
|
return (PersistedMessageBO) getPersistenceBrokerTemplate().getObjectByQuery( |
115 |
|
new QueryByCriteria(PersistedMessageBO.class, criteria)); |
116 |
|
} |
117 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
118 |
0
|
public PersistedMessagePayload findByPersistedMessageByRouteQueueId(Long routeQueueId) {... |
119 |
0
|
Criteria criteria = new Criteria(); |
120 |
0
|
criteria.addEqualTo("routeQueueId", routeQueueId); |
121 |
0
|
return (PersistedMessagePayload) getPersistenceBrokerTemplate().getObjectByQuery( |
122 |
|
new QueryByCriteria(PersistedMessagePayload.class, criteria)); |
123 |
|
} |
124 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
125 |
0
|
@SuppressWarnings("unchecked")... |
126 |
|
public List<PersistedMessageBO> getNextDocuments(Integer maxDocuments) { |
127 |
0
|
Criteria crit = new Criteria(); |
128 |
0
|
String serviceNamespace = ConfigContext.getCurrentContextConfig().getServiceNamespace(); |
129 |
0
|
crit.addEqualTo("serviceNamespace", serviceNamespace); |
130 |
0
|
crit.addNotEqualTo("queueStatus", KSBConstants.ROUTE_QUEUE_EXCEPTION); |
131 |
0
|
crit.addEqualTo("ipNumber", RiceUtilities.getIpNumber()); |
132 |
|
|
133 |
0
|
QueryByCriteria query = new QueryByCriteria(PersistedMessageBO.class, crit); |
134 |
0
|
query.addOrderByAscending("queuePriority"); |
135 |
0
|
query.addOrderByAscending("routeQueueId"); |
136 |
0
|
query.addOrderByAscending("queueDate"); |
137 |
0
|
if (maxDocuments != null) |
138 |
0
|
query.setEndAtIndex(maxDocuments.intValue()); |
139 |
0
|
return (List) getPersistenceBrokerTemplate().getCollectionByQuery(query); |
140 |
|
} |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
142 |
0
|
@SuppressWarnings("unchecked")... |
143 |
|
public List<PersistedMessageBO> findByServiceName(QName serviceName, String methodName) { |
144 |
0
|
if (LOG.isDebugEnabled()) { |
145 |
0
|
LOG.debug("Finding messages for service name " + serviceName); |
146 |
|
} |
147 |
0
|
Criteria crit = new Criteria(); |
148 |
0
|
crit.addEqualTo("serviceName", serviceName.toString()); |
149 |
0
|
crit.addEqualTo("methodName", methodName); |
150 |
0
|
return (List<PersistedMessageBO>) getPersistenceBrokerTemplate().getCollectionByQuery( |
151 |
|
new QueryByCriteria(PersistedMessageBO.class, crit)); |
152 |
|
} |
153 |
|
|
154 |
|
} |