Coverage Report - org.kuali.rice.ksb.messaging.dao.impl.ServiceInfoDAOOjbImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceInfoDAOOjbImpl
0%
0/35
0%
0/4
1.182
 
 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.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.kns.util.ObjectUtils;
 25  
 import org.kuali.rice.ksb.messaging.FlattenedServiceDefinition;
 26  
 import org.kuali.rice.ksb.messaging.ServiceInfo;
 27  
 import org.kuali.rice.ksb.messaging.dao.ServiceInfoDAO;
 28  
 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
 29  
 
 30  
 
 31  
 
 32  0
 public class ServiceInfoDAOOjbImpl extends PersistenceBrokerDaoSupport implements ServiceInfoDAO {
 33  
 
 34  
     public void addEntry(ServiceInfo entry) {
 35  0
             if (ObjectUtils.isNotNull(entry.getSerializedServiceNamespace())) {
 36  0
                     getPersistenceBrokerTemplate().store(entry.getSerializedServiceNamespace());
 37  
             }
 38  0
             getPersistenceBrokerTemplate().store(entry);
 39  0
     }
 40  
 
 41  
     @SuppressWarnings("unchecked")
 42  
     public List<ServiceInfo> fetchAll() {
 43  0
             return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery(
 44  
                             new QueryByCriteria(ServiceInfo.class));
 45  
     }
 46  
 
 47  
     @SuppressWarnings("unchecked")
 48  
     public List<ServiceInfo> fetchAllActive() {
 49  0
                 Criteria crit = new Criteria();
 50  0
                 crit.addEqualTo("alive", Boolean.TRUE);
 51  0
                 return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery(
 52  
                                 new QueryByCriteria(ServiceInfo.class, crit));
 53  
     }
 54  
 
 55  
     @SuppressWarnings("unchecked")
 56  
             public List<ServiceInfo> fetchActiveByNameLocalPart(String localPart) {
 57  0
                 Criteria crit = new Criteria();
 58  0
                 crit.addEqualTo("alive", Boolean.TRUE);
 59  0
                 crit.addLike("serviceName", "{%}"+localPart);
 60  0
                 return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery(
 61  
                                 new QueryByCriteria(ServiceInfo.class, crit));
 62  
     }
 63  
     
 64  
     @SuppressWarnings("unchecked")
 65  
     public List<ServiceInfo> fetchActiveByName(QName serviceName) {
 66  0
                 Criteria crit = new Criteria();
 67  0
                 crit.addEqualTo("alive", Boolean.TRUE);
 68  0
                 crit.addEqualTo("serviceName", serviceName.toString());
 69  0
                 return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery(
 70  
                                 new QueryByCriteria(ServiceInfo.class, crit));
 71  
     }
 72  
     
 73  
     @SuppressWarnings("unchecked")
 74  
     public List<ServiceInfo> fetchActiveByNamespace(String serviceNamespace) {
 75  0
             Criteria crit = new Criteria();
 76  0
             crit.addEqualTo("alive", Boolean.TRUE);
 77  0
             crit.addEqualTo("serviceNamespace", "{"+serviceNamespace+"}%");        
 78  0
             return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery(
 79  
                             new QueryByCriteria(ServiceInfo.class, crit));
 80  
     }
 81  
     
 82  
     @SuppressWarnings("unchecked")
 83  
     public List<ServiceInfo> findLocallyPublishedServices(String ipNumber, String serviceNamespace) {
 84  0
             Criteria crit = new Criteria();
 85  0
             crit.addEqualTo("serverIp", ipNumber);
 86  0
             crit.addEqualTo("serviceNamespace", serviceNamespace);
 87  0
             return (List<ServiceInfo>) getPersistenceBrokerTemplate().getCollectionByQuery(
 88  
                             new QueryByCriteria(ServiceInfo.class, crit));
 89  
     }
 90  
 
 91  
     public void removeEntry(ServiceInfo entry) {
 92  0
             getPersistenceBrokerTemplate().delete(entry);
 93  
             /*Criteria crit = new Criteria();
 94  
                 crit.addEqualTo("messageEntryId", entry.getMessageEntryId());
 95  
                 getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(ServiceInfo.class, crit));*/
 96  0
     }
 97  
 
 98  
     public ServiceInfo findServiceInfo(Long serviceInfoId) {
 99  0
             return (ServiceInfo) getPersistenceBrokerTemplate().getObjectById(ServiceInfo.class, serviceInfoId);
 100  
     }
 101  
 
 102  
         public FlattenedServiceDefinition findFlattenedServiceDefinition(Long flattenedServiceDefinitionId) {
 103  0
                 Criteria crit = new Criteria();
 104  0
             crit.addEqualTo("flattenedServiceDefinitionId", flattenedServiceDefinitionId);
 105  0
             return (FlattenedServiceDefinition) getPersistenceBrokerTemplate().getObjectByQuery(
 106  
                             new QueryByCriteria(FlattenedServiceDefinition.class, crit));
 107  
 
 108  
         }
 109  
 
 110  
     public void removeLocallyPublishedServices(String ipNumber, String serviceNamespace) {
 111  0
             List<ServiceInfo> localServices = findLocallyPublishedServices(ipNumber, serviceNamespace);
 112  0
             for (ServiceInfo serviceInfo : localServices) {
 113  0
                     getPersistenceBrokerTemplate().delete(serviceInfo);
 114  
             }
 115  
             /*Criteria crit = new Criteria();
 116  
             crit.addEqualTo("serverIp", ipNumber);
 117  
             crit.addEqualTo("serviceNamespace", serviceNamespace);
 118  
             getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(ServiceInfo.class, crit));*/
 119  0
     }
 120  
 
 121  
 }