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