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