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.sys.document.dataaccess.impl;
017
018 import java.sql.Date;
019 import java.util.Collection;
020 import java.util.List;
021
022 import org.apache.ojb.broker.query.Criteria;
023 import org.apache.ojb.broker.query.QueryFactory;
024 import org.kuali.kfs.sys.KFSConstants;
025 import org.kuali.kfs.sys.KFSPropertyConstants;
026 import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader;
027 import org.kuali.kfs.sys.document.dataaccess.FinancialSystemDocumentHeaderDao;
028 import org.kuali.rice.kns.bo.DocumentHeader;
029 import org.kuali.rice.kns.dao.impl.DocumentHeaderDaoOjb;
030
031 /**
032 * This class is the financial system document header dao ojb implementation
033 */
034 public class FinancialSystemDocumentHeaderDaoOjb extends DocumentHeaderDaoOjb implements FinancialSystemDocumentHeaderDao {
035 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(FinancialSystemDocumentHeaderDaoOjb.class);
036
037 /**
038 * Constructs a FinancialSystemDocumentHeaderDaoOjb.java.
039 */
040 public FinancialSystemDocumentHeaderDaoOjb() {
041 super();
042 }
043
044 /*
045 * (non-Javadoc)
046 *
047 * @see org.kuali.dao.DocumentHeaderDao#getCorrectingDocumentHeader(java.lang.Long)
048 */
049 public DocumentHeader getCorrectingDocumentHeader(String documentId) {
050 Criteria correctedByCriteria = new Criteria();
051 correctedByCriteria.addEqualTo("financialDocumentInErrorNumber", documentId);
052
053 return (DocumentHeader) getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(getDocumentHeaderBaseClass(), correctedByCriteria));
054 }
055
056 /**
057 * @see org.kuali.rice.kns.dao.DocumentHeaderDao#getByDocumentFinalDate(Date documentFinalDate)
058 */
059 public Collection getByDocumentFinalDate(Date documentFinalDate) {
060 Criteria criteria = new Criteria();
061 criteria.addEqualTo(KFSPropertyConstants.DOCUMENT_FINAL_DATE, documentFinalDate);
062 return getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(getDocumentHeaderBaseClass(), criteria));
063 }
064
065 public Class getDocumentHeaderBaseClass() {
066 LOG.debug("Method getDocumentHeaderBaseClass() returning class " + FinancialSystemDocumentHeader.class.getName());
067 return FinancialSystemDocumentHeader.class;
068 }
069
070 public Collection getByDocumentNumbers(List documentNumbers) {
071 Criteria criteria = new Criteria();
072 criteria.addIn(KFSConstants.CustomerOpenItemReport.DOCUMENT_NUMBER, documentNumbers);
073
074 return getPersistenceBrokerTemplate().getCollectionByQuery(QueryFactory.newQuery(getDocumentHeaderBaseClass(), criteria));
075 }
076 }