1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.kfs.vnd.businessobject.lookup;
20
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Properties;
25
26 import org.kuali.kfs.sys.KFSConstants;
27 import org.kuali.kfs.vnd.VendorConstants;
28 import org.kuali.kfs.vnd.VendorPropertyConstants;
29 import org.kuali.kfs.vnd.batch.service.VendorExcludeService;
30 import org.kuali.kfs.vnd.businessobject.DebarredVendorMatch;
31 import org.kuali.kfs.vnd.businessobject.VendorDetail;
32 import org.kuali.kfs.vnd.document.service.VendorService;
33 import org.kuali.rice.core.api.config.property.ConfigurationService;
34 import org.kuali.rice.kns.lookup.HtmlData;
35 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
36 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
37 import org.kuali.rice.krad.bo.BusinessObject;
38 import org.kuali.rice.krad.util.KRADConstants;
39 import org.kuali.rice.krad.util.UrlFactory;
40
41 public class VendorExclusionLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl{
42 VendorExcludeService vendorExcludeService;
43 VendorService vendorService;
44 ConfigurationService kualiConfigurationService;
45
46 private String confirmStatusFieldValue="";
47
48
49
50
51
52
53
54 @Override
55 public List<HtmlData> getCustomActionUrls(BusinessObject bo, List pkNames) {
56 List<HtmlData> anchorHtmlDataList = super.getCustomActionUrls(bo, pkNames);
57 anchorHtmlDataList.add(getInquiryUrl(bo));
58 anchorHtmlDataList.add(getEditUrl(bo));
59 anchorHtmlDataList.add(getConfirmUrl(bo));
60 anchorHtmlDataList.add(getDenyUrl(bo));
61 return anchorHtmlDataList;
62 }
63
64 protected String getVendorInquiryUrl(DebarredVendorMatch match) {
65 Properties properties = new Properties();
66 properties.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.START_METHOD);
67 properties.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, VendorDetail.class.getName());
68 properties.put("vendorDetailAssignedIdentifier", new Integer(match.getVendorDetailAssignedIdentifier()).toString());
69 properties.put("vendorHeaderGeneratedIdentifier", new Integer(match.getVendorHeaderGeneratedIdentifier()).toString());
70
71 return UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, properties);
72 }
73
74 protected HtmlData getInquiryUrl(BusinessObject bo){
75 Properties properties = new Properties();
76 properties.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.START_METHOD);
77 properties.put("debarredVendorId", new Integer(((DebarredVendorMatch)bo).getDebarredVendorId()).toString());
78 properties.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, DebarredVendorMatch.class.getName());
79
80 String href = UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, properties);
81 AnchorHtmlData anchorHtmlData = new AnchorHtmlData(href, KRADConstants.START_METHOD, "Inquiry");
82 anchorHtmlData.setTarget(KFSConstants.NEW_WINDOW_URL_TARGET);
83 return anchorHtmlData;
84 }
85
86 protected HtmlData getEditUrl(BusinessObject bo){
87 String label = "edit";
88 Integer vendorDetailAssignedIdentifier = ((DebarredVendorMatch)bo).getVendorDetailAssignedIdentifier();
89 Integer vendorHeaderGeneratedIdentifier = ((DebarredVendorMatch)bo).getVendorHeaderGeneratedIdentifier();
90 VendorDetail vendor = vendorService.getVendorDetail(vendorHeaderGeneratedIdentifier, vendorDetailAssignedIdentifier);
91 VendorDetail parent;
92 if (!vendor.isVendorParentIndicator()) {
93 label = "edit parent";
94 parent = vendorService.getParentVendor(vendorHeaderGeneratedIdentifier);
95 vendorDetailAssignedIdentifier = parent.getVendorDetailAssignedIdentifier();
96 vendorHeaderGeneratedIdentifier = parent.getVendorHeaderGeneratedIdentifier();
97 }
98
99 Properties properties = new Properties();
100 properties.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_EDIT_METHOD_TO_CALL);
101 properties.put(VendorPropertyConstants.VENDOR_HEADER_GENERATED_ID, vendorHeaderGeneratedIdentifier.toString());
102 properties.put(VendorPropertyConstants.VENDOR_DETAIL_ASSIGNED_ID, vendorDetailAssignedIdentifier.toString());
103 properties.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, VendorDetail.class.getName());
104 String href = UrlFactory.parameterizeUrl(KRADConstants.MAINTENANCE_ACTION, properties);
105 AnchorHtmlData anchorHtmlData = new AnchorHtmlData(href, KRADConstants.MAINTENANCE_EDIT_METHOD_TO_CALL, label);
106 anchorHtmlData.setTarget(KFSConstants.NEW_WINDOW_URL_TARGET);
107 return anchorHtmlData;
108 }
109
110 protected HtmlData getConfirmUrl(BusinessObject bo){
111 Properties properties = new Properties();
112 properties.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "confirmDebarredVendor");
113 properties.put(DebarredVendorMatch.CONFIRM_STATUS, confirmStatusFieldValue);
114 properties.put(DebarredVendorMatch.DEBARRED_VENDOR_ID, String.valueOf(((DebarredVendorMatch)bo).getDebarredVendorId()));
115 properties.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, DebarredVendorMatch.class.getName());
116 properties.put("returnLocation", kualiConfigurationService.getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY)+ "/kr/lookup.do");
117 properties.put(DebarredVendorMatch.EXCLUSION_STATUS, ((DebarredVendorMatch)bo).getVendorExclusionStatus());
118
119 String href = UrlFactory.parameterizeUrl("vendorExclusion.do", properties);
120 href = kualiConfigurationService.getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY)+"/"+ href;
121 AnchorHtmlData anchorHtmlData = new AnchorHtmlData(href, KRADConstants.START_METHOD, "confirm");
122 return anchorHtmlData;
123 }
124
125 protected HtmlData getDenyUrl(BusinessObject bo){
126 Properties properties = new Properties();
127 properties.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "denyDebarredVendor");
128 properties.put(DebarredVendorMatch.CONFIRM_STATUS, confirmStatusFieldValue);
129 properties.put(DebarredVendorMatch.DEBARRED_VENDOR_ID, String.valueOf(((DebarredVendorMatch)bo).getDebarredVendorId()));
130 properties.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, DebarredVendorMatch.class.getName());
131 properties.put("returnLocation", kualiConfigurationService.getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY)+ "/kr/lookup.do");
132 properties.put("formKey", "88888888");
133
134 String href = UrlFactory.parameterizeUrl("vendorExclusion.do", properties);
135 href = kualiConfigurationService.getPropertyValueAsString(KRADConstants.APPLICATION_URL_KEY)+"/"+ href;
136 AnchorHtmlData anchorHtmlData = new AnchorHtmlData(href, KRADConstants.START_METHOD, "deny");
137 return anchorHtmlData;
138 }
139
140 @Override
141 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
142 return getDebarredVendorSearchResults(fieldValues);
143 }
144
145 @Override
146 public List<? extends BusinessObject> getSearchResultsUnbounded(Map<String, String> fieldValues) {
147 return getDebarredVendorSearchResults(fieldValues);
148 }
149
150 protected List<? extends BusinessObject> getDebarredVendorSearchResults(Map<String, String> fieldValues) {
151 List<DebarredVendorMatch> vendorResultList = new ArrayList<DebarredVendorMatch>();
152 String exclusionStatus = fieldValues.get(DebarredVendorMatch.EXCLUSION_STATUS);
153 confirmStatusFieldValue = fieldValues.get(DebarredVendorMatch.CONFIRM_STATUS);
154 fieldValues.remove(DebarredVendorMatch.EXCLUSION_STATUS);
155 List<DebarredVendorMatch> searchResults = (List<DebarredVendorMatch>) super.getSearchResults(fieldValues);
156 boolean status = exclusionStatus.equals(VendorConstants.EXCLUDED_MATCHED_VENDOR_STATUS) ? true : false;
157 boolean debarred;
158 for (DebarredVendorMatch match : searchResults) {
159 debarred = match.getVendorHeader().getVendorDebarredIndicator() == null ? false : match.getVendorHeader().getVendorDebarredIndicator();
160 if ((status && debarred) || (!status && !debarred)) {
161 match.setConcatenatedId("<a href=\"" + getVendorInquiryUrl(match) + "\">" + match.getVendorDetail().getVendorNumber() + "</a> / " +
162 "<a href=\"http://www.epls.gov/epls/search.do?ssn=true&ssn_name=" + match.getName() + "&ssn_tin=" +
163 match.getVendorHeader().getVendorTaxNumber() + "\">" + match.getDebarredVendorId() + "</a>");
164 match.setName(match.getVendorDetail().getVendorName() + " / " + match.getName());
165 match.setCity(match.getVendorAddress().getVendorCityName() + " / " + match.getCity());
166 match.setState(match.getVendorAddress().getVendorStateCode() == null ? match.getVendorAddress().getVendorCountryCode() : match.getVendorAddress().getVendorStateCode() + " / " + match.getState());
167 match.setVendorExclusionStatus(exclusionStatus);
168 vendorResultList.add(match);
169 }
170 }
171 return vendorResultList;
172 }
173
174
175
176
177
178 public VendorExcludeService getVendorExcludeService() {
179 return vendorExcludeService;
180 }
181
182
183
184
185
186 public void setVendorExcludeService(VendorExcludeService vendorExcludeService) {
187 this.vendorExcludeService = vendorExcludeService;
188 }
189
190
191
192
193
194 public VendorService getVendorService() {
195 return vendorService;
196 }
197
198
199
200
201
202 public void setVendorService(VendorService vendorService) {
203 this.vendorService = vendorService;
204 }
205
206
207
208
209
210 @Override
211 public ConfigurationService getKualiConfigurationService() {
212 return kualiConfigurationService;
213 }
214
215
216
217
218
219 public void setKualiConfigurationService(ConfigurationService kualiConfigurationService) {
220 this.kualiConfigurationService = kualiConfigurationService;
221 }
222 }