1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.dataaccess.impl;
17
18 import java.util.ArrayList;
19 import java.util.Collection;
20
21 import org.apache.log4j.Logger;
22 import org.apache.ojb.broker.metadata.MetadataManager;
23 import org.apache.ojb.broker.query.Criteria;
24 import org.apache.ojb.broker.query.Query;
25 import org.apache.ojb.broker.query.QueryByCriteria;
26 import org.apache.ojb.broker.query.QueryFactory;
27 import org.kuali.ole.sys.OLEConstants;
28 import org.kuali.ole.sys.businessobject.AccountingLine;
29 import org.kuali.ole.sys.businessobject.SourceAccountingLine;
30 import org.kuali.ole.sys.businessobject.TargetAccountingLine;
31 import org.kuali.ole.sys.dataaccess.AccountingLineDao;
32 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
33 import org.springframework.dao.DataAccessException;
34
35
36
37
38
39 public class AccountingLineDaoOjb extends PlatformAwareDaoBaseOjb implements AccountingLineDao {
40 private static final Logger LOG = Logger.getLogger(AccountingLineDaoOjb.class);
41
42
43
44
45 public void deleteAccountingLine(AccountingLine line) throws DataAccessException {
46 getPersistenceBrokerTemplate().delete(line);
47 }
48
49
50
51
52
53
54
55
56 public ArrayList findByDocumentHeaderId(Class clazz, String documentHeaderId) throws DataAccessException {
57 Criteria criteria = new Criteria();
58 criteria.addEqualTo("FDOC_NBR", documentHeaderId);
59 if (MetadataManager.getInstance().getRepository().getDescriptorFor(clazz).getFieldDescriptorByName("financialDocumentLineTypeCode") != null) {
60 if (SourceAccountingLine.class.isAssignableFrom(clazz)) {
61 criteria.addEqualTo("FDOC_LN_TYP_CD", OLEConstants.SOURCE_ACCT_LINE_TYPE_CODE);
62 }
63 else if (TargetAccountingLine.class.isAssignableFrom(clazz)) {
64 criteria.addEqualTo("FDOC_LN_TYP_CD", OLEConstants.TARGET_ACCT_LINE_TYPE_CODE);
65 }
66 }
67
68 QueryByCriteria query = QueryFactory.newQuery(clazz, criteria);
69 Collection lines = findCollection(query);
70
71 return new ArrayList(lines);
72 }
73
74
75
76
77
78
79
80 protected Collection findCollection(Query query) throws DataAccessException {
81 return getPersistenceBrokerTemplate().getCollectionByQuery(query);
82 }
83 }