1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.messaging.bam.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.core.reflect.ObjectDefinition;
25 import org.kuali.rice.ksb.messaging.bam.BAMParam;
26 import org.kuali.rice.ksb.messaging.bam.BAMTargetEntry;
27 import org.kuali.rice.ksb.messaging.bam.dao.BAMDAO;
28 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
29
30
31 public class BAMDAOOjbImpl extends PersistenceBrokerDaoSupport implements BAMDAO {
32
33 public void clearBAMTables() {
34 getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(BAMTargetEntry.class));
35 getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(BAMParam.class));
36 }
37
38 @SuppressWarnings("unchecked")
39 public List<BAMTargetEntry> getCallsForService(QName serviceName, String methodName) {
40 Criteria crit = new Criteria();
41 crit.addEqualTo("serviceName", serviceName.toString());
42 crit.addEqualTo("methodName", methodName);
43 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
44 }
45
46 public void save(BAMTargetEntry bamEntry) {
47 this.getPersistenceBrokerTemplate().store(bamEntry);
48 }
49
50 @SuppressWarnings("unchecked")
51 public List<BAMTargetEntry> getCallsForService(QName serviceName) {
52 Criteria crit = new Criteria();
53 crit.addEqualTo("serviceName", serviceName.toString());
54 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
55 }
56
57 @SuppressWarnings("unchecked")
58 public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef) {
59 Criteria crit = new Criteria();
60 QName qname = new QName(objDef.getServiceNamespace(), objDef.getClassName());
61 crit.addLike("serviceName", qname.toString() + "%");
62 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
63 }
64
65 @SuppressWarnings("unchecked")
66 public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef, String methodName) {
67 Criteria crit = new Criteria();
68 QName qname = new QName(objDef.getServiceNamespace(), objDef.getClassName());
69 crit.addLike("serviceName", qname.toString() + "%");
70 crit.addEqualTo("methodName", methodName);
71 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
72 }
73 }