View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
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 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  }