View Javadoc
1   /*
2    * Copyright 2005-2009 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.ole.gl.dataaccess.impl;
17  
18  import java.util.ArrayList;
19  import java.util.Iterator;
20  import java.util.List;
21  
22  import org.apache.ojb.broker.query.Criteria;
23  import org.apache.ojb.broker.query.QueryFactory;
24  import org.apache.ojb.broker.query.ReportQueryByCriteria;
25  import org.kuali.ole.gl.businessobject.BalanceHistory;
26  import org.kuali.ole.gl.dataaccess.LedgerBalanceHistoryBalancingDao;
27  import org.kuali.ole.sys.OLEPropertyConstants;
28  import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
29  
30  /**
31   * An OJB implementation of EntryHistoryDao
32   */
33  public class BalanceHistoryDaoOjb extends PlatformAwareDaoBaseOjb implements LedgerBalanceHistoryBalancingDao {
34      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BalanceHistoryDaoOjb.class);
35      
36      /**
37       * @see org.kuali.ole.gl.dataaccess.LedgerBalanceHistoryBalancingDao#findDistinctFiscalYears()
38       */
39      public List<Integer> findDistinctFiscalYears() {
40          Criteria crit = new Criteria();
41          ReportQueryByCriteria q = QueryFactory.newReportQuery(BalanceHistory.class, crit);
42          q.setAttributes(new String[] { OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR });
43          q.setDistinct(true);
44  
45          Iterator<Object[]> years = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(q);
46          List<Integer> yearList = new ArrayList<Integer>();
47          
48          while (years != null && years.hasNext()) {
49              Object[] year = years.next();
50              yearList.add(new Integer(year[0].toString()));
51          }
52          
53          return yearList;
54      }
55  }