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.krad.dao.impl; 017 018 import java.sql.Timestamp; 019 020 import javax.persistence.EntityManager; 021 import javax.persistence.PersistenceContext; 022 023 import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria; 024 import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria; 025 import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria.QueryByCriteriaType; 026 import org.kuali.rice.krad.bo.LookupResults; 027 import org.kuali.rice.krad.bo.SelectedObjectIds; 028 import org.kuali.rice.krad.dao.PersistedLookupMetadataDao; 029 import org.kuali.rice.krad.util.KRADPropertyConstants; 030 031 public class PersistedLookupMetadataDaoJpa implements PersistedLookupMetadataDao { 032 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PersistedLookupMetadataDaoJpa.class); 033 034 @PersistenceContext 035 private EntityManager entityManager; 036 037 /** 038 * @see org.kuali.rice.krad.dao.PersistedLookupMetadataDao#deleteOldLookupResults(java.sql.Timestamp) 039 */ 040 public void deleteOldLookupResults(Timestamp expirationDate) { 041 Criteria criteria = new Criteria(LookupResults.class.getName()); 042 criteria.lt(KRADPropertyConstants.LOOKUP_DATE, expirationDate); 043 new QueryByCriteria(entityManager, criteria, QueryByCriteriaType.DELETE).toQuery().executeUpdate(); 044 } 045 046 /** 047 * @see org.kuali.rice.krad.dao.PersistedLookupMetadataDao#deleteOldSelectedObjectIds(java.sql.Timestamp) 048 */ 049 public void deleteOldSelectedObjectIds(Timestamp expirationDate) { 050 Criteria criteria = new Criteria(SelectedObjectIds.class.getName()); 051 criteria.lt(KRADPropertyConstants.LOOKUP_DATE, expirationDate); 052 new QueryByCriteria(entityManager, criteria, QueryByCriteriaType.DELETE).toQuery().executeUpdate(); 053 } 054 055 /** 056 * @return the entityManager 057 */ 058 public EntityManager getEntityManager() { 059 return this.entityManager; 060 } 061 062 /** 063 * @param entityManager the entityManager to set 064 */ 065 public void setEntityManager(EntityManager entityManager) { 066 this.entityManager = entityManager; 067 } 068 }