use of edu.cornell.kfs.vnd.businessobject.VendorBatchDetail in project cu-kfs by CU-CommunityApps.
the class VendorBatchServiceImpl method maintainVendors.
/*
* process each parsed data record and add/update vendor accordingly
*/
private boolean maintainVendors(String fileName, BatchInputFileType batchInputFileType, StringBuilder processResults) {
boolean result = true;
// load up the file into a byte array
byte[] fileByteContent = safelyLoadFileBytes(fileName);
LOG.info("Attempting to parse the file");
Object parsedObject = null;
try {
parsedObject = batchInputFileService.parse(batchInputFileType, fileByteContent);
} catch (ParseException e) {
String errorMessage = "Error parsing batch file: " + e.getMessage();
LOG.error(errorMessage, e);
throw new RuntimeException(errorMessage);
}
// make sure we got the type we expected, then cast it
if (!(parsedObject instanceof List)) {
String errorMessage = "Parsed file was not of the expected type. Expected [" + List.class + "] but got [" + parsedObject.getClass() + "].";
criticalError(errorMessage);
}
List<VendorBatchDetail> vendors = (List<VendorBatchDetail>) parsedObject;
for (VendorBatchDetail vendorBatch : vendors) {
// process each line to add/update vendor accordingly
String returnVal = KFSConstants.EMPTY_STRING;
if (StringUtils.isBlank(vendorBatch.getVendorNumber())) {
processResults.append("add vendor : " + vendorBatch.getLogData() + NEW_LINE);
returnVal = addVendor(vendorBatch);
} else {
processResults.append("update vendor : " + vendorBatch.getLogData() + NEW_LINE);
returnVal = updateVendor(vendorBatch);
}
if (StringUtils.startsWith(returnVal, "Failed request")) {
// TODO : there is error. need to handle here or before exit
LOG.error(returnVal);
result = false;
processResults.append(returnVal + NEW_LINE);
} else {
LOG.info("Document " + returnVal + " routed.");
processResults.append("Document " + returnVal + " routed." + NEW_LINE);
}
}
return result;
}
use of edu.cornell.kfs.vnd.businessobject.VendorBatchDetail in project cu-kfs by CU-CommunityApps.
the class VendorBatchCsvBuilder method buildVendorsFromDataMap.
/**
* build the VendorBatch BO from the data row
*
* @param rowDataMap
* @return
*/
private static VendorBatchDetail buildVendorsFromDataMap(Map<String, String> rowDataMap) {
VendorBatchDetail vendor = new VendorBatchDetail();
vendor.setVendorNumber(rowDataMap.get(VendorBatchCsv.vendorNumber.name()));
vendor.setVendorName((rowDataMap.get(VendorBatchCsv.vendorName.name())));
vendor.setLegalFirstName(rowDataMap.get(VendorBatchCsv.legalFirstName.name()));
vendor.setLegalLastName(rowDataMap.get(VendorBatchCsv.legalLastName.name()));
vendor.setVendorTypeCode(rowDataMap.get(VendorBatchCsv.vendorTypeCode.name()));
vendor.setForeignVendor(rowDataMap.get(VendorBatchCsv.foreignVendor.name()));
vendor.setTaxNumber(rowDataMap.get(VendorBatchCsv.taxNumber.name()));
vendor.setTaxNumberType(rowDataMap.get(VendorBatchCsv.taxNumberType.name()));
vendor.setOwnershipTypeCode(rowDataMap.get(VendorBatchCsv.ownershipTypeCode.name()));
vendor.setDefaultB2BPaymentMethodCode(rowDataMap.get(VendorBatchCsv.defaultB2BPaymentMethodCode.name()));
vendor.setTaxable(rowDataMap.get(VendorBatchCsv.taxable.name()));
vendor.seteInvoice(rowDataMap.get(VendorBatchCsv.eInvoice.name()));
vendor.setW9ReceivedIndicator(rowDataMap.get(VendorBatchCsv.w9ReceivedIndicator.name()));
vendor.setW9ReceivedDate(rowDataMap.get(VendorBatchCsv.w9ReceivedDate.name()));
vendor.setAddresses(filterQuote(rowDataMap.get(VendorBatchCsv.addresses.name())));
vendor.setContacts(filterQuote(rowDataMap.get(VendorBatchCsv.contacts.name())));
vendor.setPhoneNumbers(filterQuote(rowDataMap.get(VendorBatchCsv.phoneNumbers.name())));
vendor.setSupplierDiversities(filterQuote(rowDataMap.get(VendorBatchCsv.supplierDiversities.name())));
vendor.setInsuranceTracking(filterQuote(rowDataMap.get(VendorBatchCsv.insuranceTracking.name())));
vendor.setNotes(filterQuote(rowDataMap.get(VendorBatchCsv.notes.name())));
vendor.setAttachmentFiles(filterQuote(rowDataMap.get(VendorBatchCsv.attachmentFiles.name())));
return vendor;
}
Aggregations