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 org.apache.ojb.broker.query.Criteria;
19 import org.apache.ojb.broker.query.QueryByCriteria;
20 import org.kuali.rice.core.api.reflect.ObjectDefinition;
21 import org.kuali.rice.ksb.messaging.bam.BAMParam;
22 import org.kuali.rice.ksb.messaging.bam.BAMTargetEntry;
23 import org.kuali.rice.ksb.messaging.bam.dao.BAMDAO;
24 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
25
26 import javax.xml.namespace.QName;
27 import java.util.List;
28
29
30 public class BAMDAOOjbImpl extends PersistenceBrokerDaoSupport implements BAMDAO {
31
32 public void clearBAMTables() {
33 getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(BAMTargetEntry.class));
34 getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(BAMParam.class));
35 }
36
37 @SuppressWarnings("unchecked")
38 public List<BAMTargetEntry> getCallsForService(QName serviceName, String methodName) {
39 Criteria crit = new Criteria();
40 crit.addEqualTo("serviceName", serviceName.toString());
41 crit.addEqualTo("methodName", methodName);
42 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
43 }
44
45 public void save(BAMTargetEntry bamEntry) {
46 this.getPersistenceBrokerTemplate().store(bamEntry);
47 }
48
49 @SuppressWarnings("unchecked")
50 public List<BAMTargetEntry> getCallsForService(QName serviceName) {
51 Criteria crit = new Criteria();
52 crit.addEqualTo("serviceName", serviceName.toString());
53 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
54 }
55
56 @SuppressWarnings("unchecked")
57 public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef) {
58 Criteria crit = new Criteria();
59 QName qname = new QName(objDef.getApplicationId(), objDef.getClassName());
60 crit.addLike("serviceName", qname.toString() + "%");
61 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
62 }
63
64 @SuppressWarnings("unchecked")
65 public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef, String methodName) {
66 Criteria crit = new Criteria();
67 QName qname = new QName(objDef.getApplicationId(), objDef.getClassName());
68 crit.addLike("serviceName", qname.toString() + "%");
69 crit.addEqualTo("methodName", methodName);
70 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
71 }
72 }