01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.chart.dao.ojb;
17:
18: import org.apache.ojb.broker.query.Criteria;
19: import org.apache.ojb.broker.query.QueryFactory;
20: import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
21: import org.kuali.module.chart.bo.ProjectCode;
22: import org.kuali.module.chart.dao.ProjectCodeDao;
23:
24: /**
25: * This class is the OJB implementation of the ProjectCodeDao interface.
26: */
27: public class ProjectCodeDaoOjb extends PlatformAwareDaoBaseOjb
28: implements ProjectCodeDao {
29: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
30: .getLogger(ProjectCodeDaoOjb.class);
31:
32: /**
33: * Retrieves project code business object by primary key
34: *
35: * @param projectCode - part of composite key
36: * @return Project
37: * @see ProjectCodeDao#getByPrimaryId(String)
38: */
39: public ProjectCode getByPrimaryId(String projectCode) {
40: Criteria criteria = new Criteria();
41: criteria.addEqualTo("code", projectCode);
42:
43: return (ProjectCode) getPersistenceBrokerTemplate()
44: .getObjectByQuery(
45: QueryFactory.newQuery(ProjectCode.class,
46: criteria));
47: }
48:
49: /**
50: * Retrieves project code business object by project name
51: *
52: * @param name - part of composite key
53: * @return Project
54: * @see ProjectCodeDao#getByName(String)
55: */
56: public ProjectCode getByName(String name) {
57: Criteria criteria = new Criteria();
58: criteria.addEqualTo("name", name);
59:
60: return (ProjectCode) getPersistenceBrokerTemplate()
61: .getObjectByQuery(
62: QueryFactory.newQuery(ProjectCode.class,
63: criteria));
64: }
65:
66: /**
67: * @param projectCode - a populated ProjectCode object to be saved
68: * @throws IllegalObjectStateException
69: * @throws ValidationErrorList
70: * @see ProjectCodeDaoOjb#save(ProjectCode)
71: */
72: public void save(ProjectCode projectCode) {
73: getPersistenceBrokerTemplate().store(projectCode);
74: }
75:
76: }
|