001 /* 002 * Copyright 2011 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.kfs.module.endow.dataaccess.impl; 017 018 import java.util.List; 019 020 import org.apache.ojb.broker.query.Criteria; 021 import org.apache.ojb.broker.query.QueryByCriteria; 022 import org.apache.ojb.broker.query.QueryFactory; 023 import org.kuali.kfs.module.endow.EndowPropertyConstants; 024 import org.kuali.kfs.module.endow.businessobject.PooledFundValue; 025 import org.kuali.kfs.module.endow.dataaccess.PooledFundValueDao; 026 import org.kuali.kfs.module.endow.document.service.KEMService; 027 import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb; 028 029 public class PooledFundValueDaoOjb extends PlatformAwareDaoBaseOjb implements PooledFundValueDao { 030 031 private KEMService kemService; 032 033 /** 034 * @see org.kuali.kfs.module.endow.dataaccess.PooledFundValueDao#getPooledFundValueWhereSTProcessOnDateIsCurrentDate() 035 */ 036 public List<PooledFundValue> getPooledFundValueWhereSTProcessOnDateIsCurrentDate() { 037 Criteria criteria = new Criteria(); 038 039 criteria.addEqualTo(EndowPropertyConstants.DISTRIBUTE_SHORT_TERM_GAIN_LOSS_ON_DATE, kemService.getCurrentDate()); 040 criteria.addEqualTo(EndowPropertyConstants.ST_GAIN_LOSS_DISTR_COMPL, false); 041 042 QueryByCriteria qbc = QueryFactory.newQuery(PooledFundValue.class, criteria); 043 qbc.addOrderByAscending(EndowPropertyConstants.POOL_SECURITY_ID); 044 qbc.addOrderByDescending(EndowPropertyConstants.VALUE_EFFECTIVE_DATE); 045 046 return (List<PooledFundValue>) getPersistenceBrokerTemplate().getCollectionByQuery(qbc); 047 } 048 049 050 /** 051 * @see org.kuali.kfs.module.endow.dataaccess.PooledFundValueDao#getPooledFundValueWhereLTProcessOnDateIsCurrentDate() 052 */ 053 public List<PooledFundValue> getPooledFundValueWhereLTProcessOnDateIsCurrentDate() { 054 Criteria criteria = new Criteria(); 055 criteria.addEqualTo(EndowPropertyConstants.DISTRIBUTE_LONG_TERM_GAIN_LOSS_ON_DATE, kemService.getCurrentDate()); 056 criteria.addEqualTo(EndowPropertyConstants.LT_GAIN_LOSS_DISTR_COMPL, false); 057 058 QueryByCriteria qbc = QueryFactory.newQuery(PooledFundValue.class, criteria); 059 qbc.addOrderByAscending(EndowPropertyConstants.POOL_SECURITY_ID); 060 qbc.addOrderByDescending(EndowPropertyConstants.VALUE_EFFECTIVE_DATE); 061 062 return (List<PooledFundValue>) getPersistenceBrokerTemplate().getCollectionByQuery(qbc); 063 } 064 065 /** 066 * @see org.kuali.kfs.module.endow.dataaccess.PooledFundValueDao#getPooledFundValueWhereLTProcessOnDateIsCurrentDate() 067 */ 068 public List<PooledFundValue> getPooledFundValueWhereDistributionIncomeOnDateIsCurrentDate() { 069 Criteria criteria = new Criteria(); 070 criteria.addEqualTo(EndowPropertyConstants.DISTRIBUTE_INCOME_ON_DATE, kemService.getCurrentDate()); 071 criteria.addEqualTo(EndowPropertyConstants.INCOME_DISTRIBUTION_COMPLETE, false); 072 return (List<PooledFundValue>) getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(PooledFundValue.class, criteria)); 073 } 074 075 /** 076 * @see org.kuali.kfs.module.endow.dataaccess.PooledFundValueDao#setIncomeDistributionCompleted(java.util.List, boolean) 077 */ 078 public void setIncomeDistributionCompleted(List<PooledFundValue> pooledFundValueList, boolean completed) { 079 for (PooledFundValue pooledFundValue : pooledFundValueList) { 080 pooledFundValue.setIncomeDistributionComplete(completed); 081 getPersistenceBrokerTemplate().store(pooledFundValue); 082 } 083 } 084 085 /** 086 * Sets the kemService. 087 * 088 * @param kemService 089 */ 090 public void setKemService(KEMService kemService) { 091 this.kemService = kemService; 092 } 093 094 }