001    /**
002     * Copyright 2005-2012 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.kew.engine.node.dao.impl;
017    
018    import java.util.Iterator;
019    import java.util.List;
020    
021    import org.apache.ojb.broker.query.Criteria;
022    import org.apache.ojb.broker.query.QueryByCriteria;
023    import org.kuali.rice.kew.engine.node.Branch;
024    import org.kuali.rice.kew.engine.node.BranchState;
025    import org.kuali.rice.kew.engine.node.dao.BranchDAO;
026    import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
027    
028    
029    
030    public class BranchDAOOjbImpl extends PersistenceBrokerDaoSupport implements BranchDAO {
031            
032        
033        public void save(Branch branch){
034            getPersistenceBrokerTemplate().store(branch);
035        }
036        
037        public void deleteBranchStates(List statesToBeDeleted){
038            for(Iterator stateToBeDeletedIter=statesToBeDeleted.iterator();stateToBeDeletedIter.hasNext();){
039                    Long stateId=(Long) stateToBeDeletedIter.next();
040                    deleteBranchStatesById(stateId);                
041            }
042        }
043        
044        public void deleteBranchStatesById(Long stateId){
045            Criteria criteria = new Criteria();
046            criteria.addEqualTo("branchStateId", stateId);
047            BranchState branchState=(BranchState)getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(BranchState.class, criteria));
048            getPersistenceBrokerTemplate().delete(branchState);
049        }
050        
051    }