1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.dataaccess.impl;
17
18 import java.sql.Date;
19 import java.util.Collection;
20
21 import org.apache.ojb.broker.query.Criteria;
22 import org.apache.ojb.broker.query.QueryByCriteria;
23 import org.apache.ojb.broker.query.QueryFactory;
24 import org.apache.ojb.broker.query.ReportQueryByCriteria;
25 import org.kuali.ole.sys.OLEPropertyConstants;
26 import org.kuali.ole.sys.businessobject.UniversityDate;
27 import org.kuali.ole.sys.dataaccess.UniversityDateDao;
28 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
29
30
31
32
33 public class UniversityDateDaoOjb extends PlatformAwareDaoBaseOjb implements UniversityDateDao {
34 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UniversityDateDaoOjb.class);
35
36
37
38
39
40
41
42 protected java.sql.Date convertDate(java.util.Date date) {
43 return new Date(date.getTime());
44 }
45
46
47
48
49
50
51
52
53 @Override
54 public UniversityDate getLastFiscalYearDate(Integer fiscalYear) {
55 ReportQueryByCriteria subQuery;
56 Criteria subCrit = new Criteria();
57 Criteria crit = new Criteria();
58
59 subCrit.addEqualTo(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear);
60 subQuery = QueryFactory.newReportQuery(UniversityDate.class, subCrit);
61 subQuery.setAttributes(new String[] { "max(univ_dt)" });
62
63 crit.addGreaterOrEqualThan(OLEPropertyConstants.UNIVERSITY_DATE, subQuery);
64
65 QueryByCriteria qbc = QueryFactory.newQuery(UniversityDate.class, crit);
66
67 return (UniversityDate) getPersistenceBrokerTemplate().getObjectByQuery(qbc);
68 }
69
70
71
72
73
74
75
76
77 @Override
78 public UniversityDate getFirstFiscalYearDate(Integer fiscalYear) {
79 ReportQueryByCriteria subQuery;
80 Criteria subCrit = new Criteria();
81 Criteria crit = new Criteria();
82
83 subCrit.addEqualTo(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear);
84 subQuery = QueryFactory.newReportQuery(UniversityDate.class, subCrit);
85 subQuery.setAttributes(new String[] { "min(univ_dt)" });
86
87 crit.addGreaterOrEqualThan(OLEPropertyConstants.UNIVERSITY_DATE, subQuery);
88
89 QueryByCriteria qbc = QueryFactory.newQuery(UniversityDate.class, crit);
90
91 return (UniversityDate) getPersistenceBrokerTemplate().getObjectByQuery(qbc);
92 }
93
94 }