Coverage Report - org.kuali.rice.ken.dao.impl.NotificationMessegeDeliveryDaoJpa
 
Classes in this File Line Coverage Branch Coverage Complexity
NotificationMessegeDeliveryDaoJpa
0%
0/22
N/A
1
 
 1  
 /*
 2  
  * Copyright 2006-2011 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  
 
 17  
 package org.kuali.rice.ken.dao.impl;
 18  
 
 19  
 import org.apache.log4j.Logger;
 20  
 import org.kuali.rice.core.framework.persistence.dao.GenericDao;
 21  
 import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria;
 22  
 import org.kuali.rice.core.util.RiceConstants;
 23  
 import org.kuali.rice.ken.bo.NotificationMessageDelivery;
 24  
 import org.kuali.rice.ken.dao.NotificationMessegeDeliveryDao;
 25  
 import org.kuali.rice.ken.util.NotificationConstants;
 26  
 
 27  
 import java.sql.Timestamp;
 28  
 import java.util.Collection;
 29  
 
 30  
 /**
 31  
  * This is a description of what this class does - g1zhang don't forget to fill this in. 
 32  
  * 
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  *
 35  
  */
 36  0
 public class NotificationMessegeDeliveryDaoJpa implements NotificationMessegeDeliveryDao{
 37  
 
 38  0
         private static final Logger LOG = Logger.getLogger(NotificationDaoJpa.class);
 39  
 
 40  
         /**
 41  
          * This overridden method ...
 42  
          * 
 43  
          * @see org.kuali.rice.ken.dao.NotificationMessegeDeliveryDao#getUndeliveredMessageDelivers()
 44  
          */
 45  
         @Override
 46  
         public Collection getUndeliveredMessageDelivers(GenericDao businessObjectDao) {
 47  
 
 48  
                 //LOG.info("************************calling OJBNotificationMessegeDeliveryDao.getUndeliveredMessageDelivers************************ ");
 49  
 
 50  0
                 Criteria criteria = new Criteria(NotificationMessageDelivery.class.getName());
 51  0
                 criteria.eq(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED);
 52  0
                 criteria.isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
 53  0
                 Collection<NotificationMessageDelivery> messageDeliveries = businessObjectDao.findMatching(NotificationMessageDelivery.class, criteria, true, RiceConstants.NO_WAIT);
 54  
 
 55  0
                 return messageDeliveries;
 56  
         }
 57  
 
 58  
         /**
 59  
          * This overridden method ...
 60  
          * 
 61  
          * @see org.kuali.rice.ken.dao.NotificationMessegeDeliveryDao#getMessageDeliveriesForAutoRemoval(org.kuali.rice.core.framework.persistence.dao.GenericDao)
 62  
          */
 63  
         @Override
 64  
         public Collection<NotificationMessageDelivery> getMessageDeliveriesForAutoRemoval(Timestamp tm, GenericDao businessObjectDao) {
 65  
 
 66  
                 //LOG.info("************************calling OJBNotificationMessegeDeliveryDao.getMessageDeliveriesForAutoRemoval************************ ");
 67  
 
 68  
                 // get all UNDELIVERED/DELIVERED notification notification message delivery records with associated notifications that have and autoRemovalDateTime <= current
 69  
 
 70  0
                 Criteria criteria_STATUS = new Criteria(NotificationMessageDelivery.class.getName());
 71  0
                 criteria_STATUS.eq(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.DELIVERED);
 72  
 
 73  0
                 Criteria criteria_UNDELIVERED = new Criteria(NotificationMessageDelivery.class.getName());
 74  0
                 criteria_UNDELIVERED.eq(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED);
 75  
 
 76  
                 // now OR the above two together
 77  0
                 criteria_STATUS.or(criteria_UNDELIVERED);
 78  
 
 79  0
                 Criteria fullQueryCriteria = new Criteria(NotificationMessageDelivery.class.getName());
 80  0
                 fullQueryCriteria.isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
 81  
 
 82  0
                 fullQueryCriteria.lte(NotificationConstants.BO_PROPERTY_NAMES.NOTIFICATION_AUTO_REMOVE_DATE_TIME, new Timestamp(System.currentTimeMillis()));
 83  
 
 84  0
                 fullQueryCriteria.and(criteria_STATUS);
 85  
 
 86  0
                 Collection<NotificationMessageDelivery> messageDeliveries = businessObjectDao.findMatching(NotificationMessageDelivery.class, fullQueryCriteria, true, RiceConstants.NO_WAIT);
 87  
 
 88  0
                 return messageDeliveries;
 89  
         }
 90  
 
 91  
         /**
 92  
          * This overridden method ...
 93  
          * 
 94  
          * @see org.kuali.rice.ken.dao.NotificationMessegeDeliveryDao#getLockedDeliveries(java.lang.Class, org.kuali.rice.core.framework.persistence.dao.GenericDao)
 95  
          */
 96  
         @Override
 97  
         public Collection<NotificationMessageDelivery> getLockedDeliveries(
 98  
                         Class clazz, GenericDao dao) {
 99  0
             Criteria criteria = new Criteria(clazz.getName());
 100  0
             criteria.notNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
 101  0
         Collection<NotificationMessageDelivery> lockedDeliveries = dao.findMatching(clazz, criteria);
 102  0
                 return null;
 103  
         }
 104  
 
 105  
 
 106  
 }