1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.vnd.dataaccess.impl;
17
18 import java.sql.Date;
19
20 import org.apache.ojb.broker.query.Criteria;
21 import org.apache.ojb.broker.query.QueryByCriteria;
22 import org.kuali.ole.vnd.businessobject.VendorContract;
23 import org.kuali.ole.vnd.businessobject.VendorDetail;
24 import org.kuali.ole.vnd.dataaccess.VendorDao;
25 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
26
27
28
29
30 public class VendorDaoOjb extends PlatformAwareDaoBaseOjb implements VendorDao {
31 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(VendorDaoOjb.class);
32
33 public VendorContract getVendorB2BContract(VendorDetail vendorDetail, String campus, Date currentSqlDate) {
34
35 Criteria header = new Criteria();
36 Criteria detail = new Criteria();
37 Criteria campusCode = new Criteria();
38 Criteria beginDate = new Criteria();
39 Criteria endDate = new Criteria();
40 Criteria b2b = new Criteria();
41
42 header.addEqualTo("VNDR_HDR_GNRTD_ID", vendorDetail.getVendorHeaderGeneratedIdentifier());
43 detail.addEqualTo("VNDR_DTL_ASND_ID", vendorDetail.getVendorDetailAssignedIdentifier());
44 campusCode.addEqualTo("VNDR_CMP_CD", campus);
45 beginDate.addLessOrEqualThan("VNDR_CONTR_BEG_DT", currentSqlDate);
46 endDate.addGreaterOrEqualThan("VNDR_CONTR_END_DT", currentSqlDate);
47 b2b.addEqualTo("VNDR_B2B_IND", "Y");
48
49 header.addAndCriteria(detail);
50 header.addAndCriteria(campusCode);
51 header.addAndCriteria(beginDate);
52 header.addAndCriteria(endDate);
53 header.addAndCriteria(b2b);
54
55 VendorContract contract = (VendorContract) getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(VendorContract.class, header));
56 return contract;
57 }
58
59 }