001 /**
002 * Copyright 2005-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.ken.dao.impl;
017
018 import org.apache.log4j.Logger;
019 import org.kuali.rice.core.api.util.RiceConstants;
020 import org.kuali.rice.core.framework.persistence.dao.GenericDao;
021 import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria;
022 import org.kuali.rice.ken.bo.NotificationBo;
023 import org.kuali.rice.ken.dao.NotificationDao;
024 import org.kuali.rice.ken.util.NotificationConstants;
025
026 import java.sql.Timestamp;
027 import java.util.Collection;
028
029 /**
030 * This is a description of what this class does - g1zhang don't forget to fill this in.
031 *
032 * @author Kuali Rice Team (rice.collab@kuali.org)
033 *
034 */
035 public class NotificationDaoJpa implements NotificationDao{
036
037 private static final Logger LOG = Logger.getLogger(NotificationDaoJpa.class);
038 /**
039 * This overridden method ...
040 *
041 * @see org.kuali.rice.ken.dao.NotificationDao#findMatchedNotifications(java.sql.Timestamp, org.kuali.rice.core.framework.persistence.dao.GenericDao)
042 */
043 @Override
044 public Collection findMatchedNotificationsForResolution(Timestamp tm, GenericDao dao) {
045
046 //LOG.info("************************calling OJBNotificationDao.findMatchedNotificationsForResolution(************************ ");
047
048 Criteria criteria = new Criteria(NotificationBo.class.getName());
049 criteria.eq(NotificationConstants.BO_PROPERTY_NAMES.PROCESSING_FLAG, NotificationConstants.PROCESSING_FLAGS.UNRESOLVED);
050 criteria.lte(NotificationConstants.BO_PROPERTY_NAMES.SEND_DATE_TIME, new Timestamp(System.currentTimeMillis()));
051 criteria.isNull(NotificationConstants.BO_PROPERTY_NAMES.LOCKED_DATE);
052
053 Collection<NotificationBo> available_notifications = dao.findMatching(NotificationBo.class, criteria, true, RiceConstants.NO_WAIT);
054
055 return available_notifications;
056 }
057
058 /**
059 * This overridden method ...
060 *
061 * @see org.kuali.rice.ken.dao.NotificationDao#findMatchedNotificationsForUnlock(java.sql.Timestamp, org.kuali.rice.core.framework.persistence.dao.GenericDao)
062 */
063 @Override
064 public Collection findMatchedNotificationsForUnlock(NotificationBo not, GenericDao dao) {
065
066 //LOG.info("************************calling OJBNotificationDao.findMatchedNotificationsForForUnlock************************ ");
067
068 Criteria criteria = new Criteria(NotificationBo.class.getName());
069 criteria.eq(NotificationConstants.BO_PROPERTY_NAMES.ID, not.getId());
070
071 Collection<NotificationBo> notifications = dao.findMatching(NotificationBo.class, criteria, true, RiceConstants.NO_WAIT);
072
073 return notifications;
074 }
075
076 }
077