Coverage Report - org.kuali.rice.core.impl.style.StyleDaoOjb
 
Classes in this File Line Coverage Branch Coverage Complexity
StyleDaoOjb
0%
0/18
0%
0/6
2.667
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.core.impl.style;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import org.apache.ojb.broker.query.Criteria;
 22  
 import org.apache.ojb.broker.query.QueryByCriteria;
 23  
 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
 24  
 
 25  
 /**
 26  
  * An OJB implementation of the {@link StyleDao}.
 27  
  * 
 28  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 29  
  *
 30  
  */
 31  0
 public class StyleDaoOjb extends PersistenceBrokerDaoSupport implements StyleDao {
 32  
 
 33  
         @Override
 34  
     public void saveStyle(StyleBo styleData) {
 35  0
                 if (styleData == null) {
 36  0
                         return;
 37  
                 }
 38  0
         this.getPersistenceBrokerTemplate().store(styleData);
 39  0
     }
 40  
 
 41  
         @Override
 42  
     public StyleBo getStyle(String styleName) {
 43  0
                 if (styleName == null) {
 44  0
                         return null;
 45  
                 }
 46  0
         Criteria criteria = new Criteria();
 47  0
         criteria.addEqualTo("name", styleName);
 48  0
         criteria.addEqualTo("active", Boolean.TRUE);
 49  0
         return (StyleBo) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(StyleBo.class, criteria));
 50  
     }
 51  
         
 52  
         @Override
 53  
         public List<String> getAllStyleNames() {
 54  0
                 Criteria criteria = new Criteria();
 55  0
         criteria.addEqualTo("active", Boolean.TRUE);
 56  0
         List<StyleBo> styles = (List<StyleBo>)this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(StyleBo.class, criteria));
 57  0
         List<String> styleNames = new ArrayList<String>();
 58  0
         for (StyleBo style : styles) {
 59  0
                 styleNames.add(style.getName());
 60  
         }
 61  0
         return styleNames;
 62  
     }
 63  
 
 64  
 }