View Javadoc

1   /**
2    * Copyright 2005-2015 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 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  }