1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.rule.dao.impl;
17
18 import java.util.List;
19
20 import org.apache.ojb.broker.query.Criteria;
21 import org.apache.ojb.broker.query.QueryByCriteria;
22 import org.kuali.rice.kew.rule.bo.RuleAttribute;
23 import org.kuali.rice.kew.rule.dao.RuleAttributeDAO;
24 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
25
26
27 public class RuleAttributeDAOOjbImpl extends PersistenceBrokerDaoSupport implements RuleAttributeDAO {
28
29 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(RuleAttributeDAOOjbImpl.class);
30
31 public void save(RuleAttribute ruleAttribute) {
32 this.getPersistenceBrokerTemplate().store(ruleAttribute);
33 }
34
35 public void delete(String ruleAttributeId) {
36 this.getPersistenceBrokerTemplate().delete(findByRuleAttributeId(ruleAttributeId));
37 }
38
39 public RuleAttribute findByRuleAttributeId(String ruleAttributeId) {
40 RuleAttribute ruleAttribute = new RuleAttribute();
41 ruleAttribute.setId(ruleAttributeId);
42 return (RuleAttribute) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(ruleAttribute));
43 }
44
45 public List<RuleAttribute> findByRuleAttribute(RuleAttribute ruleAttribute) {
46 Criteria crit = new Criteria();
47 if (ruleAttribute.getName() != null) {
48 crit.addSql("UPPER(RULE_ATTRIB_NM) like '" + ruleAttribute.getName().toUpperCase() + "'");
49 }
50 if (ruleAttribute.getResourceDescriptor() != null) {
51 crit.addSql("UPPER(RULE_ATTRIB_CLS_NM) like '" + ruleAttribute.getResourceDescriptor().toUpperCase() + "'");
52 }
53 if (ruleAttribute.getType() != null) {
54 crit.addSql("UPPER(RULE_ATTRIB_TYP) like '" + ruleAttribute.getType().toUpperCase() + "'");
55 }
56 return (List<RuleAttribute>) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(RuleAttribute.class, crit));
57
58 }
59
60 public List<RuleAttribute> getAllRuleAttributes() {
61 return (List<RuleAttribute>) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(RuleAttribute.class));
62 }
63
64 public RuleAttribute findByName(String name) {
65 LOG.debug("findByName name=" + name);
66 Criteria crit = new Criteria();
67 crit.addEqualTo("name", name);
68 return (RuleAttribute) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(RuleAttribute.class, crit));
69 }
70
71 public RuleAttribute findByClassName(String classname) {
72 Criteria crit = new Criteria();
73 crit.addEqualTo("resourceDescriptor", classname);
74 return (RuleAttribute) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(RuleAttribute.class, crit));
75 }
76
77 }