001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: /*
017: * Created on Aug 12, 2004
018: *
019: */
020: package org.kuali.module.pdp.dao.ojb;
021:
022: import java.util.Iterator;
023: import java.util.List;
024:
025: import org.apache.ojb.broker.query.Criteria;
026: import org.apache.ojb.broker.query.QueryByCriteria;
027: import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
028: import org.kuali.core.exceptions.UserNotFoundException;
029: import org.kuali.core.service.UniversalUserService;
030: import org.kuali.module.pdp.bo.DisbursementNumberRange;
031: import org.kuali.module.pdp.bo.UserRequired;
032: import org.kuali.module.pdp.dao.DisbursementNumberRangeDao;
033:
034: /**
035: * @author jsissom
036: */
037: public class DisbursementNumberRangeDaoOjb extends
038: PlatformAwareDaoBaseOjb implements DisbursementNumberRangeDao {
039: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
040: .getLogger(DisbursementNumberRangeDaoOjb.class);
041:
042: private UniversalUserService userService;
043:
044: public DisbursementNumberRangeDaoOjb() {
045: super ();
046: }
047:
048: // Inject
049: public void setUniversalUserService(UniversalUserService us) {
050: userService = us;
051: }
052:
053: private void updateUser(List l) {
054: for (Iterator iter = l.iterator(); iter.hasNext();) {
055: updateUser((DisbursementNumberRange) iter.next());
056: }
057: }
058:
059: private void updateUser(DisbursementNumberRange b) {
060: UserRequired ur = (UserRequired) b;
061: try {
062: ur.updateUser(userService);
063: } catch (UserNotFoundException e) {
064: b.setLastUpdateUser(null);
065: }
066: }
067:
068: public List getAll() {
069: LOG.debug("getAll() started");
070:
071: QueryByCriteria qbc = new QueryByCriteria(
072: DisbursementNumberRange.class);
073: qbc.addOrderBy("physCampusProcCode", true);
074: qbc.addOrderBy("bank.disbursementType.code", true);
075:
076: List l = (List) getPersistenceBrokerTemplate()
077: .getCollectionByQuery(qbc);
078: updateUser(l);
079: return l;
080: }
081:
082: public DisbursementNumberRange get(Integer id) {
083: LOG.debug("get() started");
084:
085: Criteria criteria = new Criteria();
086: criteria.addEqualTo("id", id);
087:
088: DisbursementNumberRange d = (DisbursementNumberRange) getPersistenceBrokerTemplate()
089: .getObjectByQuery(
090: new QueryByCriteria(
091: DisbursementNumberRange.class, criteria));
092: if (d != null) {
093: updateUser(d);
094: }
095: return d;
096: }
097:
098: public void save(DisbursementNumberRange dnr) {
099: LOG.debug("save() started");
100:
101: try {
102: getPersistenceBrokerTemplate().store(dnr);
103: } catch (Exception e) {
104: LOG.debug("save() Exception Occurred: " + e);
105: }
106: }
107:
108: }
|