01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package edu.iu.uis.eden.messaging.dao;
17:
18: import java.util.List;
19:
20: import org.apache.ojb.broker.query.Criteria;
21: import org.apache.ojb.broker.query.QueryByCriteria;
22: import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
23:
24: import edu.iu.uis.eden.messaging.ServiceInfo;
25:
26: public class ServiceInfoDAOOjbImpl extends PersistenceBrokerDaoSupport
27: implements ServiceInfoDAO {
28:
29: public void addEntry(ServiceInfo entry) {
30: getPersistenceBrokerTemplate().store(entry);
31: }
32:
33: @SuppressWarnings("unchecked")
34: public List<ServiceInfo> fetchAll() {
35: return (List<ServiceInfo>) getPersistenceBrokerTemplate()
36: .getCollectionByQuery(
37: new QueryByCriteria(ServiceInfo.class));
38: }
39:
40: @SuppressWarnings("unchecked")
41: public List<ServiceInfo> fetchAllActive() {
42: Criteria crit = new Criteria();
43: crit.addEqualTo("alive", Boolean.TRUE);
44: return (List<ServiceInfo>) getPersistenceBrokerTemplate()
45: .getCollectionByQuery(
46: new QueryByCriteria(ServiceInfo.class, crit));
47: }
48:
49: @SuppressWarnings("unchecked")
50: public List<ServiceInfo> findLocallyPublishedServices(
51: String ipNumber, String messageEntity) {
52: Criteria crit = new Criteria();
53: crit.addEqualTo("serverIp", ipNumber);
54: crit.addEqualTo("messageEntity", messageEntity);
55: return (List<ServiceInfo>) getPersistenceBrokerTemplate()
56: .getCollectionByQuery(
57: new QueryByCriteria(ServiceInfo.class, crit));
58: }
59:
60: public void removeEntry(ServiceInfo entry) {
61: Criteria crit = new Criteria();
62: crit.addEqualTo("messageEntryId", entry.getMessageEntryId());
63: getPersistenceBrokerTemplate().deleteByQuery(
64: new QueryByCriteria(ServiceInfo.class, crit));
65: }
66:
67: public ServiceInfo findServiceInfo(Long serviceInfoId) {
68: return (ServiceInfo) getPersistenceBrokerTemplate()
69: .getObjectById(ServiceInfo.class, serviceInfoId);
70: }
71:
72: public void removeLocallyPublishedServices(String ipNumber,
73: String messageEntity) {
74: Criteria crit = new Criteria();
75: crit.addEqualTo("serverIp", ipNumber);
76: crit.addEqualTo("messageEntity", messageEntity);
77: getPersistenceBrokerTemplate().deleteByQuery(
78: new QueryByCriteria(ServiceInfo.class, crit));
79: }
80:
81: }
|