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