001/**
002 * Copyright 2005-2016 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 */
016package org.kuali.rice.krad.dao.impl;
017
018import org.apache.ojb.broker.query.Criteria;
019import org.apache.ojb.broker.query.QueryFactory;
020import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
021import org.kuali.rice.krad.bo.DocumentHeader;
022import org.kuali.rice.krad.dao.DocumentHeaderDao;
023import org.kuali.rice.krad.util.KRADPropertyConstants;
024
025/**
026 * This class is the OJB implementation of the DocumentHeaderDao interface.
027 * 
028 */
029public class DocumentHeaderDaoOjb extends PlatformAwareDaoBaseOjb implements DocumentHeaderDao {
030        private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentHeaderDaoOjb.class);
031
032        private Class documentHeaderBaseClass = DocumentHeader.class;
033
034        /**
035         * Default constructor
036         */
037        public DocumentHeaderDaoOjb() {
038                super();
039        }
040
041        /**
042         * @see org.kuali.rice.krad.dao.DocumentHeaderDao#getByDocumentHeaderId(java.lang.String)
043         */
044        public DocumentHeader getByDocumentHeaderId(String id) {
045                Criteria criteria = new Criteria();
046                criteria.addEqualTo(KRADPropertyConstants.DOCUMENT_NUMBER, id);
047
048                return (DocumentHeader) getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(getDocumentHeaderBaseClass(), criteria));
049        }
050
051        /**
052         * Method used to define the {@link DocumentHeader} object to use in case clients need to override the class.  Default value is {@link DocumentHeader}.
053         * 
054         * @see org.kuali.rice.krad.dao.DocumentHeaderDao#getDocumentHeaderBaseClass()
055         */
056        public Class getDocumentHeaderBaseClass() {
057                return this.documentHeaderBaseClass;
058        }
059
060        /**
061         * @param documentHeaderBaseClass the documentHeaderBaseClass to set
062         */
063        public void setDocumentHeaderBaseClass(Class documentHeaderBaseClass) {
064                this.documentHeaderBaseClass = documentHeaderBaseClass;
065        }
066
067}