001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.fp.dataaccess.impl;
017
018 import java.util.ArrayList;
019 import java.util.Collection;
020 import java.util.List;
021
022 import org.apache.log4j.Logger;
023 import org.apache.ojb.broker.query.Criteria;
024 import org.apache.ojb.broker.query.QueryByCriteria;
025 import org.apache.ojb.broker.query.QueryFactory;
026 import org.kuali.kfs.coa.dataaccess.impl.ChartDaoOjb;
027 import org.kuali.kfs.fp.businessobject.Check;
028 import org.kuali.kfs.fp.businessobject.CheckBase;
029 import org.kuali.kfs.fp.dataaccess.CheckDao;
030 import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
031 import org.springframework.dao.DataAccessException;
032
033 /**
034 * This class is the OJB implementation of the AccountingLineDao interface.
035 */
036
037 public class CheckDaoOjb extends PlatformAwareDaoBaseOjb implements CheckDao {
038 private static Logger LOG = Logger.getLogger(ChartDaoOjb.class);
039
040 /**
041 * Default constructor.
042 */
043 public CheckDaoOjb() {
044 super();
045 }
046
047 /**
048 * @see org.kuali.rice.kns.dao.CheckDao#save(org.kuali.kfs.fp.businessobject.Check)
049 */
050 public Check save(Check check) throws DataAccessException {
051 getPersistenceBrokerTemplate().store(check);
052
053 return check;
054 }
055
056 /**
057 * @param line
058 * @throws DataAccessException
059 */
060 public void deleteCheck(Check check) throws DataAccessException {
061 getPersistenceBrokerTemplate().delete(check);
062 }
063
064 /**
065 * Retrieves accounting lines associate with a given document header ID using OJB.
066 *
067 * @param classname
068 * @param id
069 * @return
070 */
071 public List findByDocumentHeaderId(String documentHeaderId) throws DataAccessException {
072 Criteria criteria = new Criteria();
073 criteria.addEqualTo("FDOC_NBR", documentHeaderId);
074
075 QueryByCriteria query = QueryFactory.newQuery(CheckBase.class, criteria);
076
077 Collection lines = getPersistenceBrokerTemplate().getCollectionByQuery(query);
078
079 return new ArrayList(lines);
080 }
081 }