1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.module.purap.PurapKeyConstants;
20 import org.kuali.ole.sys.document.FinancialSystemMaintainable;
21 import org.kuali.ole.vnd.VendorUtils;
22 import org.kuali.rice.kns.document.MaintenanceDocument;
23 import org.kuali.rice.krad.util.GlobalVariables;
24 import org.kuali.rice.krad.util.KRADConstants;
25
26 import java.util.Map;
27
28
29
30
31
32
33 public class PurchaseOrderQuoteListMaintainableImpl extends FinancialSystemMaintainable {
34 @Override
35 public Map<String, String> populateNewCollectionLines(Map<String, String> fieldValues, MaintenanceDocument maintenanceDocument, String methodToCall) {
36 String collName = "quoteListVendors.vendorDetail.vendorNumber";
37 String vendorNumber = (String) fieldValues.get(collName);
38 if (StringUtils.isNotBlank(vendorNumber)) {
39 if (!VendorUtils.validVendorNumberFormat(vendorNumber)) {
40 GlobalVariables.getMessageMap().putError(KRADConstants.MAINTENANCE_ADD_PREFIX + collName, PurapKeyConstants.ERROR_PURCHASE_ORDER_QUOTE_LIST_NON_EXISTENCE_VENDOR);
41 return fieldValues;
42 } else {
43 Integer headerId = VendorUtils.getVendorHeaderId(vendorNumber);
44 Integer detailId = VendorUtils.getVendorDetailId(vendorNumber);
45 resetPreviousVendorInformationOnAddLine(fieldValues, headerId, detailId);
46 }
47 }
48
49 return super.populateNewCollectionLines(fieldValues, maintenanceDocument, methodToCall);
50 }
51
52 private void resetPreviousVendorInformationOnAddLine(Map fieldValues, Integer headerId, Integer detailId) {
53 if (fieldValues.get("quoteListVendors.vendorHeaderGeneratedIdentifier") != null) {
54 fieldValues.put("quoteListVendors.vendorHeaderGeneratedIdentifier", headerId);
55 }
56
57 if (fieldValues.get("quoteListVendors.vendorDetailAssignedIdentifier") != null) {
58 fieldValues.put("quoteListVendors.vendorDetailAssignedIdentifier", detailId);
59 }
60
61 }
62 }