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