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