View Javadoc
1   /*
2    * Copyright 2007-2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
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.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   * OJB implementation of VendorDao.
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  }