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