| 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.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 | |
} |