Coverage Report - org.kuali.rice.kew.rule.dao.impl.RuleTemplateDAOOjbImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
RuleTemplateDAOOjbImpl
0%
0/27
0%
0/6
1.444
RuleTemplateDAOOjbImpl$1
0%
0/2
N/A
1.444
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.rule.dao.impl;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.Iterator;
 21  
 import java.util.List;
 22  
 
 23  
 import org.apache.ojb.broker.PersistenceBroker;
 24  
 import org.apache.ojb.broker.query.Criteria;
 25  
 import org.apache.ojb.broker.query.QueryByCriteria;
 26  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 27  
 import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform;
 28  
 import org.kuali.rice.core.util.RiceConstants;
 29  
 import org.kuali.rice.kew.rule.bo.RuleTemplate;
 30  
 import org.kuali.rice.kew.rule.dao.RuleTemplateDAO;
 31  
 import org.springmodules.orm.ojb.PersistenceBrokerCallback;
 32  
 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
 33  
 
 34  
 
 35  0
 public class RuleTemplateDAOOjbImpl extends PersistenceBrokerDaoSupport implements RuleTemplateDAO {
 36  
 
 37  
 
 38  
     public List<RuleTemplate> findAll() {
 39  0
         QueryByCriteria query = new QueryByCriteria(RuleTemplate.class);
 40  0
         query.addOrderByAscending("name");
 41  0
         return (List)this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
 42  
     }
 43  
 
 44  
     public RuleTemplate findByRuleTemplateName(String ruleTemplateName) {
 45  0
         Criteria crit = new Criteria();
 46  0
         crit.addEqualTo("name", ruleTemplateName);
 47  0
         QueryByCriteria query = new QueryByCriteria(RuleTemplate.class, crit);
 48  0
         query.addOrderByDescending("ruleTemplateId");
 49  
 
 50  0
         Iterator ruleTemplates = this.getPersistenceBrokerTemplate().getCollectionByQuery(query).iterator();
 51  0
         while(ruleTemplates.hasNext()) {
 52  0
             return (RuleTemplate) ruleTemplates.next();
 53  
         }
 54  0
         return null;
 55  
     }
 56  
 
 57  
     public List<RuleTemplate> findByRuleTemplate(RuleTemplate ruleTemplate) {
 58  0
         Criteria crit = new Criteria();
 59  0
         if (ruleTemplate.getName() != null) {
 60  0
           crit.addSql("UPPER(RULE_TMPL_NM) like '"+ ruleTemplate.getName().toUpperCase() +"'");
 61  
         }
 62  0
         if (ruleTemplate.getDescription() != null) {
 63  0
           crit.addSql("UPPER(RULE_TMPL_DESC) like '"+ ruleTemplate.getDescription().toUpperCase()+"'");
 64  
         }
 65  0
         return new ArrayList<RuleTemplate>(this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(RuleTemplate.class, crit)));
 66  
     }
 67  
 
 68  
     public void delete(String ruleTemplateId) {
 69  0
             this.getPersistenceBrokerTemplate().delete(findByRuleTemplateId(ruleTemplateId));
 70  0
     }
 71  
 
 72  
     public RuleTemplate findByRuleTemplateId(String ruleTemplateId) {
 73  0
         Criteria crit = new Criteria();
 74  0
         crit.addEqualTo("ruleTemplateId", ruleTemplateId);
 75  0
         return (RuleTemplate) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(RuleTemplate.class, crit));
 76  
     }
 77  
 
 78  
     public void save(RuleTemplate ruleTemplate) {
 79  0
             this.getPersistenceBrokerTemplate().store(ruleTemplate);
 80  0
     }
 81  
 
 82  
     public String getNextRuleTemplateId() {
 83  0
         return (String)this.getPersistenceBrokerTemplate().execute(new PersistenceBrokerCallback() {
 84  
             public Object doInPersistenceBroker(PersistenceBroker broker) {
 85  0
                       return String.valueOf(getPlatform().getNextValSQL("KREW_RTE_TMPL_S", broker));
 86  
             }
 87  
         });
 88  
     }
 89  
 
 90  
     protected DatabasePlatform getPlatform() {
 91  0
             return (DatabasePlatform)GlobalResourceLoader.getService(RiceConstants.DB_PLATFORM);
 92  
     }
 93  
 
 94  
 
 95  
 }