1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.dataaccess.impl;
17
18 import org.apache.log4j.Logger;
19 import org.apache.ojb.broker.query.Criteria;
20 import org.apache.ojb.broker.query.Query;
21 import org.apache.ojb.broker.query.QueryByCriteria;
22 import org.kuali.ole.module.purap.PurapPropertyConstants;
23 import org.kuali.ole.module.purap.businessobject.ReceivingAddress;
24 import org.kuali.ole.module.purap.document.dataaccess.ReceivingAddressDao;
25 import org.kuali.ole.sys.OLEPropertyConstants;
26 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
27 import org.springframework.transaction.annotation.Transactional;
28
29 import java.util.Collection;
30
31
32
33
34 @Transactional
35 public class ReceivingAddressDaoOjb extends PlatformAwareDaoBaseOjb implements ReceivingAddressDao {
36 private static Logger LOG = Logger.getLogger(ReceivingAddressDaoOjb.class);
37
38
39
40
41 public Collection<ReceivingAddress> findActiveByChartOrg(String chartCode, String orgCode) {
42 LOG.debug("Entering findActiveByChartOrg(String,String)");
43
44 Criteria criteria = new Criteria();
45 criteria.addEqualTo(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
46 if (orgCode == null)
47 criteria.addIsNull(OLEPropertyConstants.ORGANIZATION_CODE);
48 else
49 criteria.addEqualTo(OLEPropertyConstants.ORGANIZATION_CODE, orgCode);
50 criteria.addEqualTo(PurapPropertyConstants.BO_ACTIVE, true);
51 Query query = new QueryByCriteria(ReceivingAddress.class, criteria);
52
53 LOG.debug("Leaving findActiveByChartOrg(String,String)");
54 return getPersistenceBrokerTemplate().getCollectionByQuery(query);
55 }
56
57
58
59
60 public Collection<ReceivingAddress> findDefaultByChartOrg(String chartCode, String orgCode) {
61 LOG.debug("Entering findDefaultByChartOrg(String,String)");
62
63 Criteria criteria = new Criteria();
64 criteria.addEqualTo(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
65 if (orgCode == null)
66 criteria.addIsNull(OLEPropertyConstants.ORGANIZATION_CODE);
67 else
68 criteria.addEqualTo(OLEPropertyConstants.ORGANIZATION_CODE, orgCode);
69 criteria.addEqualTo(PurapPropertyConstants.RECEIVING_ADDRESS_DEFAULT_INDICATOR, true);
70 criteria.addEqualTo(PurapPropertyConstants.BO_ACTIVE, true);
71 Query query = new QueryByCriteria(ReceivingAddress.class, criteria);
72
73 LOG.debug("Leaving findDefaultByChartOrg(String,String)");
74 return getPersistenceBrokerTemplate().getCollectionByQuery(query);
75 }
76
77
78
79
80 public int countActiveByChartOrg(String chartCode, String orgCode) {
81 LOG.debug("Entering countActiveByChartOrg(String,String)");
82
83 Criteria criteria = new Criteria();
84 criteria.addEqualTo(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, chartCode);
85 if (orgCode == null)
86 criteria.addIsNull(OLEPropertyConstants.ORGANIZATION_CODE);
87 else
88 criteria.addEqualTo(OLEPropertyConstants.ORGANIZATION_CODE, orgCode);
89 criteria.addEqualTo(PurapPropertyConstants.BO_ACTIVE, true);
90 Query query = new QueryByCriteria(ReceivingAddress.class, criteria);
91
92 LOG.debug("Leaving countActiveByChartOrg(String,String)");
93 return getPersistenceBrokerTemplate().getCount(query);
94 }
95
96 }