|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  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 |     | 
   }  |