01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.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 edu.iu.uis.eden.routetemplate.dao;
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.springmodules.orm.ojb.PersistenceBrokerTemplate;
24: import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
25:
26: import edu.iu.uis.eden.routetemplate.RuleAttribute;
27:
28: public class RuleAttributeDAOOjbImpl extends
29: PersistenceBrokerDaoSupport implements RuleAttributeDAO {
30:
31: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
32: .getLogger(RuleAttributeDAOOjbImpl.class);
33:
34: public void save(RuleAttribute ruleAttribute) {
35: this .getPersistenceBrokerTemplate().store(ruleAttribute);
36: }
37:
38: public void delete(Long ruleAttributeId) {
39: this .getPersistenceBrokerTemplate().delete(
40: findByRuleAttributeId(ruleAttributeId));
41: }
42:
43: public RuleAttribute findByRuleAttributeId(Long ruleAttributeId) {
44: RuleAttribute ruleAttribute = new RuleAttribute();
45: ruleAttribute.setRuleAttributeId(ruleAttributeId);
46: return (RuleAttribute) this .getPersistenceBrokerTemplate()
47: .getObjectByQuery(new QueryByCriteria(ruleAttribute));
48: }
49:
50: public List findByRuleAttribute(RuleAttribute ruleAttribute) {
51: Criteria crit = new Criteria();
52: if (ruleAttribute.getName() != null) {
53: crit.addSql("UPPER(RULE_ATTRIB_NM) like '"
54: + ruleAttribute.getName().toUpperCase() + "'");
55: }
56: if (ruleAttribute.getClassName() != null) {
57: crit.addSql("UPPER(RULE_ATTRIB_CLS_NM) like '"
58: + ruleAttribute.getClassName().toUpperCase() + "'");
59: }
60: if (ruleAttribute.getType() != null) {
61: crit.addSql("UPPER(RULE_ATTRIB_TYP) like '"
62: + ruleAttribute.getType().toUpperCase() + "'");
63: }
64: return (List) this .getPersistenceBrokerTemplate()
65: .getCollectionByQuery(
66: new QueryByCriteria(RuleAttribute.class, crit));
67:
68: }
69:
70: public List getAllRuleAttributes() {
71: return (List) this .getPersistenceBrokerTemplate()
72: .getCollectionByQuery(
73: new QueryByCriteria(RuleAttribute.class));
74: }
75:
76: public RuleAttribute findByName(String name) {
77: LOG.debug("findByName name=" + name);
78: Criteria crit = new Criteria();
79: crit.addEqualTo("name", name);
80: return (RuleAttribute) this .getPersistenceBrokerTemplate()
81: .getObjectByQuery(
82: new QueryByCriteria(RuleAttribute.class, crit));
83: }
84:
85: public RuleAttribute findByClassName(String classname) {
86: Criteria crit = new Criteria();
87: crit.addEqualTo("className", classname);
88: return (RuleAttribute) this .getPersistenceBrokerTemplate()
89: .getObjectByQuery(
90: new QueryByCriteria(RuleAttribute.class, crit));
91: }
92:
93: }
|