View Javadoc

1   /**
2    * Copyright 2005-2013 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  public class NotificationMessegeDeliveryDaoJpa implements NotificationMessegeDeliveryDao{
36  
37  	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  		Criteria criteria = new Criteria(NotificationMessageDelivery.class.getName());
50  		criteria.eq(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED);
51  		criteria.isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
52  		Collection<NotificationMessageDelivery> messageDeliveries = businessObjectDao.findMatching(NotificationMessageDelivery.class, criteria, true, RiceConstants.NO_WAIT);
53  
54  		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  		Criteria criteria_STATUS = new Criteria(NotificationMessageDelivery.class.getName());
70  		criteria_STATUS.eq(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.DELIVERED);
71  
72  		Criteria criteria_UNDELIVERED = new Criteria(NotificationMessageDelivery.class.getName());
73  		criteria_UNDELIVERED.eq(NotificationConstants.BO_PROPERTY_NAMES.MESSAGE_DELIVERY_STATUS, NotificationConstants.MESSAGE_DELIVERY_STATUS.UNDELIVERED);
74  
75  		// now OR the above two together
76  		criteria_STATUS.or(criteria_UNDELIVERED);
77  
78  		Criteria fullQueryCriteria = new Criteria(NotificationMessageDelivery.class.getName());
79  		fullQueryCriteria.isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
80  
81  		fullQueryCriteria.lte(NotificationConstants.BO_PROPERTY_NAMES.NOTIFICATION_AUTO_REMOVE_DATE_TIME, new Timestamp(System.currentTimeMillis()));
82  
83  		fullQueryCriteria.and(criteria_STATUS);
84  
85  		Collection<NotificationMessageDelivery> messageDeliveries = businessObjectDao.findMatching(NotificationMessageDelivery.class, fullQueryCriteria, true, RiceConstants.NO_WAIT);
86  
87  		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      	Criteria criteria = new Criteria(clazz.getName());
99      	criteria.notNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
100         Collection<NotificationMessageDelivery> lockedDeliveries = dao.findMatching(clazz, criteria);
101 		return null;
102 	}
103 
104 
105 }