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.ojb.broker.query.Criteria;
19 import org.apache.ojb.broker.query.ReportQueryByCriteria;
20 import org.kuali.ole.module.purap.PurapPropertyConstants;
21 import org.kuali.ole.module.purap.document.BulkReceivingDocument;
22 import org.kuali.ole.module.purap.document.dataaccess.BulkReceivingDao;
23 import org.kuali.ole.sys.OLEPropertyConstants;
24 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
25 import org.springframework.transaction.annotation.Transactional;
26
27 import java.sql.Date;
28 import java.util.ArrayList;
29 import java.util.List;
30
31 @Transactional
32 public class BulkReceivingDaoOjb extends PlatformAwareDaoBaseOjb implements BulkReceivingDao {
33
34 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BulkReceivingDaoOjb.class);
35
36 public List<String> getDocumentNumbersByPurchaseOrderId(Integer id) {
37
38 List<String> returnList = new ArrayList<String>();
39 Criteria criteria = new Criteria();
40 criteria.addEqualTo(PurapPropertyConstants.PURCHASE_ORDER_IDENTIFIER, id);
41 returnList = getDocumentNumbersOfBulkReceivingByCriteria(criteria, false);
42
43 return returnList;
44 }
45
46 public List<String> duplicateBillOfLadingNumber(Integer poId, String billOfLadingNumber) {
47 List<String> returnList = new ArrayList<String>();
48 Criteria criteria = new Criteria();
49 criteria.addEqualTo(PurapPropertyConstants.PURCHASE_ORDER_IDENTIFIER, poId);
50 criteria.addEqualTo(PurapPropertyConstants.SHIPMENT_BILL_OF_LADING_NUMBER, billOfLadingNumber);
51 returnList = getDocumentNumbersOfBulkReceivingByCriteria(criteria, false);
52
53 return returnList;
54 }
55
56 public List<String> duplicatePackingSlipNumber(Integer poId, String packingSlipNumber) {
57 List<String> returnList = new ArrayList<String>();
58 Criteria criteria = new Criteria();
59 criteria.addEqualTo(PurapPropertyConstants.PURCHASE_ORDER_IDENTIFIER, poId);
60 criteria.addEqualTo(PurapPropertyConstants.SHIPMENT_PACKING_SLIP_NUMBER, packingSlipNumber);
61 returnList = getDocumentNumbersOfBulkReceivingByCriteria(criteria, false);
62
63 return returnList;
64 }
65
66 public List<String> duplicateVendorDate(Integer poId, Date vendorDate) {
67 List<String> returnList = new ArrayList<String>();
68 Criteria criteria = new Criteria();
69 criteria.addEqualTo(PurapPropertyConstants.PURCHASE_ORDER_IDENTIFIER, poId);
70 criteria.addEqualTo(PurapPropertyConstants.SHIPMENT_RECEIVED_DATE, vendorDate);
71 returnList = getDocumentNumbersOfBulkReceivingByCriteria(criteria, false);
72
73 return returnList;
74 }
75
76 protected List<String> getDocumentNumbersOfBulkReceivingByCriteria(Criteria criteria, boolean orderByAscending) {
77 List<String> returnList = new ArrayList<String>();
78
79 ReportQueryByCriteria rqbc = new ReportQueryByCriteria(BulkReceivingDocument.class, criteria);
80 if (orderByAscending) {
81 rqbc.addOrderByAscending(OLEPropertyConstants.DOCUMENT_NUMBER);
82 } else {
83 rqbc.addOrderByDescending(OLEPropertyConstants.DOCUMENT_NUMBER);
84 }
85
86 List<BulkReceivingDocument> bulkReceivingDocs = (List<BulkReceivingDocument>) getPersistenceBrokerTemplate().getCollectionByQuery(rqbc);
87
88 for (BulkReceivingDocument bulkReceivingDoc : bulkReceivingDocs) {
89 returnList.add(bulkReceivingDoc.getDocumentNumber());
90 }
91
92 return returnList;
93 }
94 }