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.bam.dao;
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.config.ConfigDAOSupport;
25: import org.kuali.rice.definition.ObjectDefinition;
26: import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
27:
28: import edu.iu.uis.eden.messaging.bam.BAMParam;
29: import edu.iu.uis.eden.messaging.bam.BAMTargetEntry;
30:
31: public class BAMDAOOjbImpl extends PersistenceBrokerDaoSupport
32: implements BAMDAO {
33:
34: ConfigDAOSupport configSupport = new ConfigDAOSupport();
35:
36: public void clearBAMTables() {
37: getPersistenceBrokerTemplate().deleteByQuery(
38: new QueryByCriteria(BAMTargetEntry.class));
39: getPersistenceBrokerTemplate().deleteByQuery(
40: new QueryByCriteria(BAMParam.class));
41: }
42:
43: @SuppressWarnings("unchecked")
44: public List<BAMTargetEntry> getCallsForService(QName serviceName,
45: String methodName) {
46: Criteria crit = new Criteria();
47: crit.addEqualTo("serviceName", serviceName.toString());
48: crit.addEqualTo("methodName", methodName);
49: return (List<BAMTargetEntry>) getPersistenceBrokerTemplate()
50: .getCollectionByQuery(
51: new QueryByCriteria(BAMTargetEntry.class, crit));
52: }
53:
54: public void save(BAMTargetEntry bamEntry) {
55: this .getPersistenceBrokerTemplate().store(bamEntry);
56: }
57:
58: @SuppressWarnings("unchecked")
59: public List<BAMTargetEntry> getCallsForService(QName serviceName) {
60: Criteria crit = new Criteria();
61: crit.addEqualTo("serviceName", serviceName.toString());
62: return (List<BAMTargetEntry>) getPersistenceBrokerTemplate()
63: .getCollectionByQuery(
64: new QueryByCriteria(BAMTargetEntry.class, crit));
65: }
66:
67: @SuppressWarnings("unchecked")
68: public List<BAMTargetEntry> getCallsForRemotedClasses(
69: ObjectDefinition objDef) {
70: Criteria crit = new Criteria();
71: QName qname = new QName(objDef.getMessageEntity(), objDef
72: .getClassName());
73: crit.addLike("serviceName", qname.toString() + "%");
74: return (List<BAMTargetEntry>) getPersistenceBrokerTemplate()
75: .getCollectionByQuery(
76: new QueryByCriteria(BAMTargetEntry.class, crit));
77: }
78:
79: @SuppressWarnings("unchecked")
80: public List<BAMTargetEntry> getCallsForRemotedClasses(
81: ObjectDefinition objDef, String methodName) {
82: Criteria crit = new Criteria();
83: QName qname = new QName(objDef.getMessageEntity(), objDef
84: .getClassName());
85: crit.addLike("serviceName", qname.toString() + "%");
86: crit.addEqualTo("methodName", methodName);
87: return (List<BAMTargetEntry>) getPersistenceBrokerTemplate()
88: .getCollectionByQuery(
89: new QueryByCriteria(BAMTargetEntry.class, crit));
90: }
91: }
|