1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.vnd.batch.dataaccess;
17
18 import java.util.List;
19
20 import org.apache.ojb.broker.query.Criteria;
21 import org.apache.ojb.broker.query.QueryByCriteria;
22 import org.apache.ojb.broker.query.QueryFactory;
23 import org.kuali.ole.vnd.businessobject.DebarredVendorMatch;
24 import org.kuali.ole.vnd.businessobject.VendorDetail;
25 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
26
27 public class DebarredVendorMatchDaoOjb extends PlatformAwareDaoBaseOjb implements DebarredVendorMatchDao {
28
29
30
31
32 @Override
33 public DebarredVendorMatch getPreviousVendorExcludeConfirmation(DebarredVendorMatch match) {
34 Criteria criteria = new Criteria();
35
36 criteria.addEqualTo("vendorHeaderGeneratedIdentifier", match.getVendorHeaderGeneratedIdentifier());
37 criteria.addEqualTo("vendorDetailAssignedIdentifier", match.getVendorDetailAssignedIdentifier());
38
39 if (match.getName() != null) {
40 criteria.addEqualTo("upper(name)", match.getName().toUpperCase());
41 } else {
42 criteria.addIsNull("name");
43 }
44 if (match.getAddress1() != null) {
45 criteria.addEqualTo("upper(address1)", match.getAddress1().toUpperCase());
46 } else {
47 criteria.addIsNull("address1");
48 }
49 if (match.getAddress2() != null) {
50 criteria.addEqualTo("upper(address2)", match.getAddress2().toUpperCase());
51 } else {
52 criteria.addIsNull("address2");
53 }
54 if (match.getCity() != null) {
55 criteria.addEqualTo("upper(city)", match.getCity().toUpperCase());
56 } else {
57 criteria.addIsNull("city");
58 }
59 if (match.getState() != null) {
60 criteria.addEqualTo("upper(state)", match.getState().toUpperCase());
61 } else {
62 criteria.addIsNull("state");
63 }
64 if (match.getZip() != null) {
65 criteria.addEqualTo("zip", match.getZip());
66 } else {
67 criteria.addIsNull("zip");
68 }
69 QueryByCriteria query = QueryFactory.newQuery(DebarredVendorMatch.class, criteria);
70 List<DebarredVendorMatch> matches = (List<DebarredVendorMatch>)getPersistenceBrokerTemplate().getCollectionByQuery(query);
71
72 DebarredVendorMatch oldMatch = null;
73 if (matches.size() > 0) {
74 oldMatch = matches.get(0);
75 }
76 return oldMatch;
77 }
78
79
80
81
82 @Override
83 public List<VendorDetail> getDebarredVendorsUnmatched() {
84
85 Criteria subcr = new Criteria();
86 subcr.addEqualToField("vendorHeaderGeneratedIdentifier", Criteria.PARENT_QUERY_PREFIX + "vendorHeaderGeneratedIdentifier");
87 subcr.addEqualToField("vendorDetailAssignedIdentifier", Criteria.PARENT_QUERY_PREFIX + "vendorDetailAssignedIdentifier");
88 Criteria orcr = new Criteria();
89 orcr.addEqualTo("confirmStatusCode", "C");
90 Criteria orcr2 = new Criteria();
91 orcr2.addEqualTo("confirmStatusCode", "U");
92 orcr.addOrCriteria(orcr2);
93 subcr.addAndCriteria(orcr);
94 QueryByCriteria subqr = QueryFactory.newQuery(DebarredVendorMatch.class, subcr);
95
96 Criteria criteria = new Criteria();
97 criteria.addEqualTo("vendorHeader.vendorDebarredIndicator", "Y");
98 criteria.addNotExists(subqr);
99 QueryByCriteria query = QueryFactory.newQuery(VendorDetail.class, criteria);
100 List<VendorDetail> vendors = (List<VendorDetail>) getPersistenceBrokerTemplate().getCollectionByQuery(query);
101
102 return vendors;
103 }
104
105 @Override
106 public DebarredVendorMatch getDebarredVendor(int debarredVendorId) {
107 Criteria criteria = new Criteria();
108 criteria.addEqualTo("debarredVendorId", debarredVendorId);
109 QueryByCriteria query = QueryFactory.newQuery(DebarredVendorMatch.class, criteria);
110 return (DebarredVendorMatch)getPersistenceBrokerTemplate().getObjectByQuery(query);
111 }
112
113 }