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.criteria.QueryByCriteria;
20  import org.kuali.rice.ken.bo.NotificationBo;
21  import org.kuali.rice.ken.dao.NotificationDao;
22  import org.kuali.rice.ken.util.NotificationConstants;
23  import org.kuali.rice.krad.data.DataObjectService;
24  
25  import java.sql.Timestamp;
26  import java.util.Collection;
27  
28  import static org.kuali.rice.core.api.criteria.PredicateFactory.and;
29  import static org.kuali.rice.core.api.criteria.PredicateFactory.lessThanOrEqual;
30  import static org.kuali.rice.core.api.criteria.PredicateFactory.equal;
31  import static org.kuali.rice.core.api.criteria.PredicateFactory.isNull;
32  
33  /**
34   * This is a description of what this class does - g1zhang don't forget to fill this in. 
35   * 
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   *
38   */
39  public class NotificationDaoJpa implements NotificationDao{
40  
41  	private static final Logger LOG = Logger.getLogger(NotificationDaoJpa.class);
42  
43  	/**
44  	 * This overridden method ...
45  	 * 
46  	 * @see NotificationDao#findMatchedNotificationsForResolution(java.sql.Timestamp, org.kuali.rice.krad.data.DataObjectService)
47  	 */
48  	@Override
49  	public Collection findMatchedNotificationsForResolution(Timestamp tm, DataObjectService dataObjectService) {
50  
51  		//LOG.info("************************calling JPANotificationDao.findMatchedNotificationsForResolution(************************ ");
52  
53          QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
54          criteria.setPredicates(
55              and(
56                  equal(NotificationConstants.BO_PROPERTY_NAMES.PROCESSING_FLAG, NotificationConstants.PROCESSING_FLAGS.UNRESOLVED),
57                  lessThanOrEqual(NotificationConstants.BO_PROPERTY_NAMES.SEND_DATE_TIME, new Timestamp(System.currentTimeMillis())),
58                  isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE)
59              )
60          );
61  
62          return dataObjectService.findMatching(NotificationBo.class, criteria.build()).getResults();
63  	}
64  
65  	/**
66  	 * This overridden method ...
67  	 * 
68  	 * @see NotificationDao#findMatchedNotificationsForUnlock(org.kuali.rice.ken.bo.NotificationBo, org.kuali.rice.krad.data.DataObjectService)
69  	 */
70  	@Override
71  	public Collection findMatchedNotificationsForUnlock(NotificationBo not, DataObjectService dataObjectService) {
72  
73  		//LOG.info("************************calling JPANotificationDao.findMatchedNotificationsForForUnlock************************ ");
74  
75  		QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
76          criteria.setPredicates(equal(NotificationConstants.BO_PROPERTY_NAMES.ID, not.getId()));
77  
78          Collection<NotificationBo> notifications = dataObjectService.findMatching(NotificationBo.class, criteria.build()).getResults();
79  
80  		return notifications;
81  	}
82  }
83