001 /**
002 * Copyright 2005-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.ksb.messaging.bam.dao.impl;
017
018 import org.apache.ojb.broker.query.Criteria;
019 import org.apache.ojb.broker.query.QueryByCriteria;
020 import org.kuali.rice.core.api.reflect.ObjectDefinition;
021 import org.kuali.rice.ksb.messaging.bam.BAMParam;
022 import org.kuali.rice.ksb.messaging.bam.BAMTargetEntry;
023 import org.kuali.rice.ksb.messaging.bam.dao.BAMDAO;
024 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
025
026 import javax.xml.namespace.QName;
027 import java.util.List;
028
029
030 public class BAMDAOOjbImpl extends PersistenceBrokerDaoSupport implements BAMDAO {
031
032 public void clearBAMTables() {
033 getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(BAMTargetEntry.class));
034 getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(BAMParam.class));
035 }
036
037 @SuppressWarnings("unchecked")
038 public List<BAMTargetEntry> getCallsForService(QName serviceName, String methodName) {
039 Criteria crit = new Criteria();
040 crit.addEqualTo("serviceName", serviceName.toString());
041 crit.addEqualTo("methodName", methodName);
042 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
043 }
044
045 public void save(BAMTargetEntry bamEntry) {
046 this.getPersistenceBrokerTemplate().store(bamEntry);
047 }
048
049 @SuppressWarnings("unchecked")
050 public List<BAMTargetEntry> getCallsForService(QName serviceName) {
051 Criteria crit = new Criteria();
052 crit.addEqualTo("serviceName", serviceName.toString());
053 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
054 }
055
056 @SuppressWarnings("unchecked")
057 public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef) {
058 Criteria crit = new Criteria();
059 QName qname = new QName(objDef.getApplicationId(), objDef.getClassName());
060 crit.addLike("serviceName", qname.toString() + "%");
061 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
062 }
063
064 @SuppressWarnings("unchecked")
065 public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef, String methodName) {
066 Criteria crit = new Criteria();
067 QName qname = new QName(objDef.getApplicationId(), objDef.getClassName());
068 crit.addLike("serviceName", qname.toString() + "%");
069 crit.addEqualTo("methodName", methodName);
070 return (List<BAMTargetEntry>)getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(BAMTargetEntry.class, crit));
071 }
072 }