Coverage Report - org.kuali.rice.kew.help.dao.impl.HelpDAOOjbImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpDAOOjbImpl
0%
0/24
0%
0/14
2.333
 
 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.help.dao.impl;
 18  
 
 19  
 import java.util.List;
 20  
 
 21  
 import org.apache.commons.lang.StringUtils;
 22  
 import org.apache.ojb.broker.query.Criteria;
 23  
 import org.apache.ojb.broker.query.QueryByCriteria;
 24  
 import org.kuali.rice.kew.help.HelpEntry;
 25  
 import org.kuali.rice.kew.help.dao.HelpDAO;
 26  
 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
 27  
 
 28  
 
 29  
 
 30  0
 public class HelpDAOOjbImpl extends PersistenceBrokerDaoSupport implements HelpDAO {
 31  
         
 32  
     public void save(HelpEntry helpEntry){
 33  0
         this.getPersistenceBrokerTemplate().store(helpEntry);
 34  0
     }
 35  
     
 36  
     public void deleteEntry(HelpEntry helpEntry) {
 37  0
             this.getPersistenceBrokerTemplate().delete(helpEntry);
 38  0
     }
 39  
     
 40  
     public HelpEntry findById(String helpId){
 41  0
         Criteria crit = new Criteria();
 42  0
         crit.addEqualTo("helpId", helpId);
 43  0
                 return (HelpEntry) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(HelpEntry.class, crit)); 
 44  
     }
 45  
     
 46  
     public List search(HelpEntry helpEntry){
 47  0
         Criteria crit = new Criteria();
 48  
 
 49  0
         if (helpEntry.getHelpId() != null && !StringUtils.equals(helpEntry.getHelpId(), "0")) {
 50  0
             crit.addEqualTo("helpId", helpEntry.getHelpId());
 51  
         }
 52  
 
 53  0
         if (!this.isStringEmpty(helpEntry.getHelpName())) {
 54  0
             crit.addLike("UPPER(helpName)", "%" + helpEntry.getHelpName().toUpperCase() + "%");
 55  
         }
 56  
 
 57  0
         if (!this.isStringEmpty(helpEntry.getHelpText())) {
 58  0
             crit.addLike("UPPER(helpText)", "%" + helpEntry.getHelpText().toUpperCase() + "%");
 59  
         }
 60  
         
 61  0
         if (!this.isStringEmpty(helpEntry.getHelpKey())) {
 62  0
             crit.addLike("UPPER(helpKey)", "%" + helpEntry.getHelpKey().toUpperCase() + "%");         
 63  
         }
 64  0
         return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(HelpEntry.class, crit));
 65  
     }
 66  
     
 67  
     private boolean isStringEmpty(String string) {
 68  0
         if ((string == null) || string.trim().equals("")) {
 69  0
             return true;
 70  
         }
 71  
 
 72  0
         return false;
 73  
     }
 74  
     
 75  
     public HelpEntry findByKey(String helpKey){
 76  0
         Criteria crit = new Criteria();
 77  0
         crit.addEqualTo("helpKey", helpKey);
 78  0
                 return  (HelpEntry) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(HelpEntry.class, crit)); 
 79  
     }
 80  
 }