01: /*
02: * Copyright 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.purap.dao.ojb;
17:
18: import java.util.ArrayList;
19: import java.util.Collection;
20: import java.util.List;
21:
22: import org.apache.ojb.broker.query.Criteria;
23: import org.apache.ojb.broker.query.QueryByCriteria;
24: import org.apache.ojb.broker.query.QueryFactory;
25: import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
26: import org.kuali.module.purap.bo.PurApItem;
27: import org.kuali.module.purap.bo.PurchaseOrderItem;
28: import org.kuali.module.purap.dao.PurApAccountingDao;
29:
30: /**
31: * OJB Implementation of PurApAccountingDao.
32: */
33: public class PurApAccountingDaoOjb extends PlatformAwareDaoBaseOjb
34: implements PurApAccountingDao {
35:
36: /**
37: * @see org.kuali.module.purap.dao.PurApAccountingDao#getAccountingLinesForItem(org.kuali.module.purap.bo.PurApItem)
38: */
39: public List getAccountingLinesForItem(PurApItem item) {
40: String itemIdentifier = Integer.toString(item
41: .getItemIdentifier());
42: Class clazz = item.getAccountingLineClass();
43: Criteria criteria = new Criteria();
44: criteria.addEqualTo("itemIdentifier", itemIdentifier);
45: // if it's a purchaseOrderItem, we need to make sure we're getting for the right doc number
46: if (item instanceof PurchaseOrderItem) {
47: criteria.addEqualTo("documentNumber",
48: ((PurchaseOrderItem) item).getDocumentNumber());
49: }
50:
51: QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
52: Collection lines = getPersistenceBrokerTemplate()
53: .getCollectionByQuery(query);
54:
55: return new ArrayList(lines);
56:
57: }
58:
59: }
|