001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.gl.dao.ojb;
017:
018: import java.util.Collection;
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.core.dao.ojb.PlatformAwareDaoBaseOjb;
024: import org.kuali.kfs.KFSPropertyConstants;
025: import org.kuali.module.gl.bo.SufficientFundRebuild;
026: import org.kuali.module.gl.dao.SufficientFundRebuildDao;
027:
028: /**
029: * An OJB implementation of the SufficientFundRebuildDao
030: */
031: public class SufficientFundRebuildDaoOjb extends
032: PlatformAwareDaoBaseOjb implements SufficientFundRebuildDao {
033: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
034: .getLogger(SufficientFundRebuildDaoOjb.class);
035:
036: /**
037: * Constructs a SufficientFundRebuildDaoOjb instance
038: */
039: public SufficientFundRebuildDaoOjb() {
040: super ();
041: }
042:
043: /**
044: * Returns all sufficient fund rebuild balances in the database
045: *
046: * @return a Collection with all sufficient fund rebuild balances
047: * @see org.kuali.module.gl.dao.SufficientFundRebuildDao#getAll()
048: */
049: public Collection getAll() {
050: QueryByCriteria qbc = QueryFactory.newQuery(
051: SufficientFundRebuild.class, (Criteria) null);
052: qbc
053: .addOrderByAscending(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
054: qbc
055: .addOrderByAscending(KFSPropertyConstants.ACCOUNT_FINANCIAL_OBJECT_TYPE_CODE);
056: qbc
057: .addOrderByAscending(KFSPropertyConstants.ACCOUNT_NUMBER_FINANCIAL_OBJECT_CODE);
058:
059: return getPersistenceBrokerTemplate().getCollectionByQuery(qbc);
060: }
061:
062: /**
063: * Returns all sufficient fund rebuild balances with a given object type code
064: *
065: * @param accountFinancialObjectTypeCode the object type code of sufficient fund balances to return
066: * @return a Collection of qualifying sufficient fund balances
067: * @see org.kuali.module.gl.dao.SufficientFundRebuildDao#getByType(java.lang.String)
068: */
069: public Collection getByType(String accountFinancialObjectTypeCode) {
070: Criteria criteria = new Criteria();
071: criteria
072: .addEqualTo(
073: KFSPropertyConstants.ACCOUNT_FINANCIAL_OBJECT_TYPE_CODE,
074: accountFinancialObjectTypeCode);
075:
076: QueryByCriteria qbc = QueryFactory.newQuery(
077: SufficientFundRebuild.class, criteria);
078: return getPersistenceBrokerTemplate().getCollectionByQuery(qbc);
079: }
080:
081: /**
082: * Returns the sufficient fund rebuild balance by chart and account number/object code
083: *
084: * @param chartOfAccountsCode the chart of the rebuild balance to return
085: * @param accountNumberFinancialObjectCode the account number or object code of the rebuild balance to returnd
086: * @return a qualifying sufficient fund rebuild record if found in the database, or null
087: * @see org.kuali.module.gl.dao.SufficientFundRebuildDao#getByAccount(java.lang.String, java.lang.String)
088: */
089: public SufficientFundRebuild getByAccount(
090: String chartOfAccountsCode,
091: String accountNumberFinancialObjectCode) {
092: Criteria criteria = new Criteria();
093: criteria.addEqualTo(
094: KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE,
095: chartOfAccountsCode);
096: criteria
097: .addEqualTo(
098: KFSPropertyConstants.ACCOUNT_NUMBER_FINANCIAL_OBJECT_CODE,
099: accountNumberFinancialObjectCode);
100:
101: QueryByCriteria qbc = QueryFactory.newQuery(
102: SufficientFundRebuild.class, criteria);
103: return (SufficientFundRebuild) getPersistenceBrokerTemplate()
104: .getObjectByQuery(qbc);
105: }
106:
107: /**
108: * Returns the sufficient fund rebuild balance with the primary key given by the parameters
109: *
110: * @param chartOfAccountsCode the chart of the rebuild balance to return
111: * @param accountFinancialObjectTypeCode the object type code of the rebuild balance to return
112: * @param accountNumberFinancialObjectCode the account number or fiscal object of the rebuild balance to return
113: * @return the qualifying rebuild balance, or null if not found in the database
114: * @see org.kuali.module.gl.dao.SufficientFundRebuildDao#get(java.lang.String, java.lang.String, java.lang.String)
115: */
116: public SufficientFundRebuild get(String chartOfAccountsCode,
117: String accountFinancialObjectTypeCode,
118: String accountNumberFinancialObjectCode) {
119: Criteria criteria = new Criteria();
120: criteria.addEqualTo(
121: KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE,
122: chartOfAccountsCode);
123: criteria
124: .addEqualTo(
125: KFSPropertyConstants.ACCOUNT_FINANCIAL_OBJECT_TYPE_CODE,
126: accountFinancialObjectTypeCode);
127: criteria
128: .addEqualTo(
129: KFSPropertyConstants.ACCOUNT_NUMBER_FINANCIAL_OBJECT_CODE,
130: accountNumberFinancialObjectCode);
131:
132: QueryByCriteria qbc = QueryFactory.newQuery(
133: SufficientFundRebuild.class, criteria);
134: return (SufficientFundRebuild) getPersistenceBrokerTemplate()
135: .getObjectByQuery(qbc);
136: }
137:
138: /**
139: * Saves a sufficient fund rebuild record to the database
140: *
141: * @param sfrb the sufficient fund rebuild balance to save
142: * @see org.kuali.module.gl.dao.SufficientFundRebuildDao#save(org.kuali.module.gl.bo.SufficientFundRebuild)
143: */
144: public void save(SufficientFundRebuild sfrb) {
145: LOG.debug("save() started");
146: getPersistenceBrokerTemplate().store(sfrb);
147: }
148:
149: /**
150: * Deletes a sufficient fund rebuild record from the database
151: * @param sfrb the sufficient fund rebuild balance to delete
152: * @see org.kuali.module.gl.dao.SufficientFundRebuildDao#delete(org.kuali.module.gl.bo.SufficientFundRebuild)
153: */
154: public void delete(SufficientFundRebuild sfrb) {
155: getPersistenceBrokerTemplate().delete(sfrb);
156: }
157:
158: /**
159: * This method should only be used in unit tests. It loads all the gl_sf_rebuild_t rows in memory into a collection. This won't
160: * sace for production.
161: *
162: * Note, though, we're warned not to use this method outside unit tests but running the getAll() method, which
163: * is basically equivalent, is just fine. So you can probably run this one too.
164: *
165: * @return a Collection of all sufficient fund rebuild records currently in the database
166: */
167: public Collection testingGetAllEntries() {
168: LOG.debug("testingGetAllEntries() started");
169:
170: Criteria criteria = new Criteria();
171: QueryByCriteria qbc = QueryFactory.newQuery(
172: SufficientFundRebuild.class, criteria);
173: qbc
174: .addOrderByAscending(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
175: qbc
176: .addOrderByAscending(KFSPropertyConstants.ACCOUNT_FINANCIAL_OBJECT_TYPE_CODE);
177: qbc
178: .addOrderByAscending(KFSPropertyConstants.ACCOUNT_NUMBER_FINANCIAL_OBJECT_CODE);
179: return getPersistenceBrokerTemplate().getCollectionByQuery(qbc);
180: }
181:
182: }
|