001    /**
002     * Copyright 2004-2013 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.hr.lm.leaverequest.dao;
017    
018    
019    import org.apache.ojb.broker.query.Criteria;
020    import org.apache.ojb.broker.query.Query;
021    import org.apache.ojb.broker.query.QueryFactory;
022    import org.kuali.hr.lm.workflow.LeaveRequestDocument;
023    import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
024    
025    import java.util.ArrayList;
026    import java.util.List;
027    
028    public class LeaveRequestDocumentDaoOjbImpl extends PlatformAwareDaoBaseOjb implements LeaveRequestDocumentDao{
029        @Override
030        public LeaveRequestDocument getLeaveRequestDocument(String documentNumber) {
031            LeaveRequestDocument lrd = null;
032    
033            Criteria root = new Criteria();
034            root.addEqualTo("documentNumber", documentNumber);
035            Query query = QueryFactory.newQuery(LeaveRequestDocument.class, root);
036            lrd = (LeaveRequestDocument)this.getPersistenceBrokerTemplate().getObjectByQuery(query);
037    
038            return lrd;
039        }
040    
041        @Override
042        public List<LeaveRequestDocument> getLeaveRequestDocumentsByLeaveBlockId(String leaveBlockId) {
043            List<LeaveRequestDocument> lrd = null;
044    
045            Criteria root = new Criteria();
046            root.addEqualTo("lmLeaveBlockId", leaveBlockId);
047            Query query = QueryFactory.newQuery(LeaveRequestDocument.class, root);
048            lrd = new ArrayList<LeaveRequestDocument>(this.getPersistenceBrokerTemplate().getCollectionByQuery(query));
049    
050            return lrd;
051        }
052    }