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 org.kuali.workflow.workgroup.dao;
18:
19: import java.util.Collection;
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.workflow.workgroup.WorkgroupType;
25: import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
26:
27: /**
28: * OJB implementation of the WorkgroupTypeDAO. Allows for simple access and persistence of
29: * WorkgroupTypes.
30: *
31: * @author ewestfal
32: */
33: public class WorkgroupTypeDAOOjbImpl extends
34: PersistenceBrokerDaoSupport implements WorkgroupTypeDAO {
35:
36: public WorkgroupType findById(Long workgroupTypeId) {
37: Criteria crit = new Criteria();
38: crit.addEqualTo("workgroupTypeId", workgroupTypeId);
39: return (WorkgroupType) getPersistenceBrokerTemplate()
40: .getObjectByQuery(
41: new QueryByCriteria(WorkgroupType.class, crit));
42: }
43:
44: public WorkgroupType findByName(String name) {
45: Criteria crit = new Criteria();
46: crit.addEqualTo("name", name);
47: return (WorkgroupType) getPersistenceBrokerTemplate()
48: .getObjectByQuery(
49: new QueryByCriteria(WorkgroupType.class, crit));
50: }
51:
52: public Collection findAll(boolean activeOnly) {
53: Criteria crit = new Criteria();
54: if (activeOnly) {
55: crit.addEqualTo("active", Boolean.TRUE);
56: }
57: return getPersistenceBrokerTemplate().getCollectionByQuery(
58: new QueryByCriteria(WorkgroupType.class, crit));
59: }
60:
61: public void save(WorkgroupType workgroupType) {
62: getPersistenceBrokerTemplate().store(workgroupType);
63: }
64:
65: public Collection search(Long id, String name, String label,
66: String description, Boolean active) {
67: Criteria crit = new Criteria();
68: if (id != null) {
69: crit.addEqualTo("workgroupTypeId", id);
70: }
71: if (!StringUtils.isBlank(name)) {
72: crit.addEqualTo("name", name);
73: }
74: if (!StringUtils.isBlank(label)) {
75: crit.addEqualTo("label", label);
76: }
77: if (!StringUtils.isBlank(description)) {
78: crit.addEqualTo("description", description);
79: }
80: if (active != null) {
81: crit.addEqualTo("active", active);
82: }
83: return getPersistenceBrokerTemplate().getCollectionByQuery(
84: new QueryByCriteria(WorkgroupType.class, crit));
85: }
86:
87: }
|