1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.dataaccess.impl;
17
18 import java.math.BigDecimal;
19 import java.util.Iterator;
20
21 import org.apache.ojb.broker.query.Criteria;
22 import org.apache.ojb.broker.query.QueryFactory;
23 import org.apache.ojb.broker.query.ReportQueryByCriteria;
24 import org.kuali.ole.gl.businessobject.EntryHistory;
25 import org.kuali.ole.gl.dataaccess.LedgerEntryHistoryBalancingDao;
26 import org.kuali.ole.sys.OLEPropertyConstants;
27 import org.kuali.ole.sys.util.TransactionalServiceUtils;
28 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
29 import org.kuali.rice.krad.util.ObjectUtils;
30
31
32
33
34 public class EntryHistoryDaoOjb extends PlatformAwareDaoBaseOjb implements LedgerEntryHistoryBalancingDao {
35 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(EntryHistoryDaoOjb.class);
36
37
38
39
40 public Integer findSumRowCountGreaterOrEqualThan(Integer year) {
41 Criteria criteria = new Criteria();
42 criteria.addGreaterOrEqualThan(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, year);
43
44 ReportQueryByCriteria reportQuery = QueryFactory.newReportQuery(EntryHistory.class, criteria);
45 reportQuery.setAttributes(new String[] { "sum(" + OLEPropertyConstants.ROW_COUNT + ")"});
46
47 Iterator<Object[]> iterator = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(reportQuery);
48 Object[] returnResult = TransactionalServiceUtils.retrieveFirstAndExhaustIterator(iterator);
49
50 return ObjectUtils.isNull(returnResult[0]) ? 0 : ((BigDecimal) returnResult[0]).intValue();
51 }
52 }