01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.chart.dao.ojb;
17:
18: import java.util.ArrayList;
19: import java.util.Collection;
20: import java.util.Iterator;
21: import java.util.List;
22:
23: import org.apache.ojb.broker.query.Criteria;
24: import org.apache.ojb.broker.query.QueryFactory;
25: import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
26: import org.kuali.module.chart.bo.ObjectCode;
27: import org.kuali.module.chart.dao.ObjectCodeDao;
28:
29: /**
30: * This class is the OJB implementation of the ObjectCodeDao interface.
31: */
32: public class ObjectCodeDaoOjb extends PlatformAwareDaoBaseOjb implements
33: ObjectCodeDao {
34: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
35: .getLogger(ObjectCodeDaoOjb.class);
36:
37: /**
38: * Retrieves object code business object by primary key
39: *
40: * @see org.kuali.module.chart.dao.ObjectCodeDao#getByPrimaryId(Integer, String, String)
41: */
42: public ObjectCode getByPrimaryId(Integer universityFiscalYear,
43: String chartOfAccountsCode, String financialObjectCode) {
44: Criteria criteria = new Criteria();
45: criteria.addEqualTo("universityFiscalYear",
46: universityFiscalYear);
47: criteria.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
48: criteria.addEqualTo("financialObjectCode", financialObjectCode);
49:
50: return (ObjectCode) getPersistenceBrokerTemplate()
51: .getObjectByQuery(
52: QueryFactory.newQuery(ObjectCode.class,
53: criteria));
54: }
55:
56: /**
57: * @see org.kuali.module.chart.dao.ObjectCodeDao#getYearList(java.lang.String, java.lang.String)
58: */
59: public List getYearList(String chartOfAccountsCode,
60: String financialObjectCode) {
61:
62: List returnList = new ArrayList();
63: Criteria criteria = new Criteria();
64: criteria.addEqualTo("chartOfAccountsCode", chartOfAccountsCode);
65: criteria.addEqualTo("financialObjectCode", financialObjectCode);
66: Collection years = getPersistenceBrokerTemplate()
67: .getCollectionByQuery(
68: QueryFactory.newQuery(ObjectCode.class,
69: criteria));
70: for (Iterator iter = years.iterator(); iter.hasNext();) {
71: ObjectCode o = (ObjectCode) iter.next();
72: if (o != null) {
73: returnList.add(o.getUniversityFiscalYear());
74: }
75: }
76: return returnList;
77:
78: }
79: }
|