1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.ksb.messaging.dao.impl; |
17 | |
|
18 | |
import java.util.List; |
19 | |
|
20 | |
import javax.xml.namespace.QName; |
21 | |
|
22 | |
import org.apache.ojb.broker.query.Criteria; |
23 | |
import org.apache.ojb.broker.query.QueryByCriteria; |
24 | |
import org.kuali.rice.kns.util.ObjectUtils; |
25 | |
import org.kuali.rice.ksb.messaging.FlattenedServiceDefinition; |
26 | |
import org.kuali.rice.ksb.messaging.ServiceInfo; |
27 | |
import org.kuali.rice.ksb.messaging.dao.ServiceInfoDAO; |
28 | |
import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport; |
29 | |
|
30 | |
|
31 | |
|
32 | 0 | public class ServiceInfoDAOOjbImpl extends PersistenceBrokerDaoSupport implements ServiceInfoDAO { |
33 | |
|
34 | |
public void addEntry(ServiceInfo entry) { |
35 | 0 | if (ObjectUtils.isNotNull(entry.getSerializedServiceNamespace())) { |
36 | 0 | getPersistenceBrokerTemplate().store(entry.getSerializedServiceNamespace()); |
37 | |
} |
38 | 0 | getPersistenceBrokerTemplate().store(entry); |
39 | 0 | } |
40 | |
|
41 | |
@SuppressWarnings("unchecked") |
42 | |
public List<ServiceInfo> fetchAll() { |
43 | 0 | return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery( |
44 | |
new QueryByCriteria(ServiceInfo.class)); |
45 | |
} |
46 | |
|
47 | |
@SuppressWarnings("unchecked") |
48 | |
public List<ServiceInfo> fetchAllActive() { |
49 | 0 | Criteria crit = new Criteria(); |
50 | 0 | crit.addEqualTo("alive", Boolean.TRUE); |
51 | 0 | return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery( |
52 | |
new QueryByCriteria(ServiceInfo.class, crit)); |
53 | |
} |
54 | |
|
55 | |
@SuppressWarnings("unchecked") |
56 | |
public List<ServiceInfo> fetchActiveByNameLocalPart(String localPart) { |
57 | 0 | Criteria crit = new Criteria(); |
58 | 0 | crit.addEqualTo("alive", Boolean.TRUE); |
59 | 0 | crit.addLike("serviceName", "{%}"+localPart); |
60 | 0 | return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery( |
61 | |
new QueryByCriteria(ServiceInfo.class, crit)); |
62 | |
} |
63 | |
|
64 | |
@SuppressWarnings("unchecked") |
65 | |
public List<ServiceInfo> fetchActiveByName(QName serviceName) { |
66 | 0 | Criteria crit = new Criteria(); |
67 | 0 | crit.addEqualTo("alive", Boolean.TRUE); |
68 | 0 | crit.addEqualTo("serviceName", serviceName.toString()); |
69 | 0 | return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery( |
70 | |
new QueryByCriteria(ServiceInfo.class, crit)); |
71 | |
} |
72 | |
|
73 | |
@SuppressWarnings("unchecked") |
74 | |
public List<ServiceInfo> fetchActiveByNamespace(String serviceNamespace) { |
75 | 0 | Criteria crit = new Criteria(); |
76 | 0 | crit.addEqualTo("alive", Boolean.TRUE); |
77 | 0 | crit.addEqualTo("serviceNamespace", "{"+serviceNamespace+"}%"); |
78 | 0 | return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery( |
79 | |
new QueryByCriteria(ServiceInfo.class, crit)); |
80 | |
} |
81 | |
|
82 | |
@SuppressWarnings("unchecked") |
83 | |
public List<ServiceInfo> findLocallyPublishedServices(String ipNumber, String serviceNamespace) { |
84 | 0 | Criteria crit = new Criteria(); |
85 | 0 | crit.addEqualTo("serverIp", ipNumber); |
86 | 0 | crit.addEqualTo("serviceNamespace", serviceNamespace); |
87 | 0 | return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery( |
88 | |
new QueryByCriteria(ServiceInfo.class, crit)); |
89 | |
} |
90 | |
|
91 | |
public void removeEntry(ServiceInfo entry) { |
92 | 0 | getPersistenceBrokerTemplate().delete(entry); |
93 | |
|
94 | |
|
95 | |
|
96 | 0 | } |
97 | |
|
98 | |
public ServiceInfo findServiceInfo(Long serviceInfoId) { |
99 | 0 | return (ServiceInfo) getPersistenceBrokerTemplate().getObjectById(ServiceInfo.class, serviceInfoId); |
100 | |
} |
101 | |
|
102 | |
public FlattenedServiceDefinition findFlattenedServiceDefinition(Long flattenedServiceDefinitionId) { |
103 | 0 | Criteria crit = new Criteria(); |
104 | 0 | crit.addEqualTo("flattenedServiceDefinitionId", flattenedServiceDefinitionId); |
105 | 0 | return (FlattenedServiceDefinition) getPersistenceBrokerTemplate().getObjectByQuery( |
106 | |
new QueryByCriteria(FlattenedServiceDefinition.class, crit)); |
107 | |
|
108 | |
} |
109 | |
|
110 | |
public void removeLocallyPublishedServices(String ipNumber, String serviceNamespace) { |
111 | 0 | List<ServiceInfo> localServices = findLocallyPublishedServices(ipNumber, serviceNamespace); |
112 | 0 | for (ServiceInfo serviceInfo : localServices) { |
113 | 0 | getPersistenceBrokerTemplate().delete(serviceInfo); |
114 | |
} |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | 0 | } |
120 | |
|
121 | |
} |