View Javadoc

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.Notification;
24  import org.kuali.rice.ken.dao.NotificationDao;
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  public class NotificationDaoJpa implements NotificationDao{
37  
38  	private static final Logger LOG = Logger.getLogger(NotificationDaoJpa.class);
39  	/**
40  	 * This overridden method ...
41  	 * 
42  	 * @see org.kuali.rice.ken.dao.NotificationDao#findMatchedNotifications(java.sql.Timestamp, org.kuali.rice.core.framework.persistence.dao.GenericDao)
43  	 */
44  	@Override
45  	public Collection findMatchedNotificationsForResolution(Timestamp tm, GenericDao dao) {
46  
47  		//LOG.info("************************calling OJBNotificationDao.findMatchedNotificationsForResolution(************************ ");
48  
49  		Criteria criteria = new Criteria(Notification.class.getName());
50  		criteria.eq(NotificationConstants.BO_PROPERTY_NAMES.PROCESSING_FLAG, NotificationConstants.PROCESSING_FLAGS.UNRESOLVED);
51  		criteria.lte(NotificationConstants.BO_PROPERTY_NAMES.SEND_DATE_TIME, new Timestamp(System.currentTimeMillis()));
52  		criteria.isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
53  
54  		Collection<Notification> available_notifications = dao.findMatching(Notification.class, criteria, true, RiceConstants.NO_WAIT);
55  
56  		return available_notifications;
57  	}
58  
59  	/**
60  	 * This overridden method ...
61  	 * 
62  	 * @see org.kuali.rice.ken.dao.NotificationDao#findMatchedNotificationsForUnlock(java.sql.Timestamp, org.kuali.rice.core.framework.persistence.dao.GenericDao)
63  	 */
64  	@Override
65  	public Collection findMatchedNotificationsForUnlock(Notification not, GenericDao dao) {
66  
67  		//LOG.info("************************calling OJBNotificationDao.findMatchedNotificationsForForUnlock************************ ");
68  
69  		Criteria criteria = new Criteria(Notification.class.getName());
70  		criteria.eq(NotificationConstants.BO_PROPERTY_NAMES.ID, not.getId());
71  
72  		Collection<Notification> notifications = dao.findMatching(Notification.class, criteria, true, RiceConstants.NO_WAIT);
73  
74  		return notifications;
75  	}
76  
77  }
78