1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.dataaccess.impl;
17
18 import org.apache.ojb.broker.query.Criteria;
19 import org.apache.ojb.broker.query.QueryByCriteria;
20 import org.apache.ojb.broker.query.QueryFactory;
21 import org.kuali.ole.module.purap.PurapPropertyConstants;
22 import org.kuali.ole.module.purap.businessobject.AccountsPayableSummaryAccount;
23 import org.kuali.ole.module.purap.businessobject.PurApItem;
24 import org.kuali.ole.module.purap.businessobject.PurchaseOrderItem;
25 import org.kuali.ole.module.purap.dataaccess.PurApAccountingDao;
26 import org.kuali.ole.select.businessobject.OleInvoiceAccountsPayableSummaryAccount;
27 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
28
29 import java.util.ArrayList;
30 import java.util.Collection;
31 import java.util.List;
32
33
34
35
36 public class PurApAccountingDaoOjb extends PlatformAwareDaoBaseOjb implements PurApAccountingDao {
37
38
39
40
41 public List getAccountingLinesForItem(PurApItem item) {
42 Class clazz = item.getAccountingLineClass();
43 Criteria criteria = new Criteria();
44 criteria.addEqualTo("itemIdentifier", item.getItemIdentifier());
45
46
47 if (item instanceof PurchaseOrderItem) {
48 criteria.addEqualTo("documentNumber", ((PurchaseOrderItem) item).getDocumentNumber());
49 }
50
51 QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
52 Collection lines = getPersistenceBrokerTemplate().getCollectionByQuery(query);
53
54 return new ArrayList(lines);
55
56 }
57
58
59
60
61 public void deleteSummaryAccountsbyPaymentRequestIdentifier(Integer paymentRequestIdentifier) {
62 if (paymentRequestIdentifier != null) {
63 Criteria criteria = new Criteria();
64 criteria.addEqualTo(PurapPropertyConstants.PAYMENT_REQUEST_ID, paymentRequestIdentifier);
65
66 getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(AccountsPayableSummaryAccount.class, criteria));
67 getPersistenceBrokerTemplate().clearCache();
68 }
69 }
70
71
72
73
74 public void deleteSummaryAccountsbyInvoiceIdentifier(Integer invoiceIdentifier) {
75 if (invoiceIdentifier != null) {
76 Criteria criteria = new Criteria();
77 criteria.addEqualTo(PurapPropertyConstants.INVOICE_ID, invoiceIdentifier);
78
79 getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(OleInvoiceAccountsPayableSummaryAccount.class, criteria));
80 getPersistenceBrokerTemplate().clearCache();
81 }
82 }
83
84
85
86
87 public void deleteSummaryAccountsbyCreditMemoIdentifier(Integer creditMemoIdentifier) {
88 if (creditMemoIdentifier != null) {
89 Criteria criteria = new Criteria();
90 criteria.addEqualTo(PurapPropertyConstants.CREDIT_MEMO_ID, creditMemoIdentifier);
91
92 getPersistenceBrokerTemplate().deleteByQuery(QueryFactory.newQuery(AccountsPayableSummaryAccount.class, criteria));
93 getPersistenceBrokerTemplate().clearCache();
94 }
95 }
96
97 }