use of org.kuali.kfs.vnd.document.VendorMaintainableImpl in project cu-kfs by CU-CommunityApps.
the class VendorBatchServiceImpl method addVendor.
/*
* create vendor document and route
*/
private String addVendor(VendorBatchDetail vendorBatch) {
GlobalVariables.setMessageMap(new MessageMap());
// create and route doc as system user
// GlobalVariables.setUserSession(new UserSession("kfs"));
LOG.info("addVendor " + vendorBatch.getLogData());
try {
MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService.getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);
vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, true));
VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();
vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_NEW_ACTION);
VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();
setupVendorDetailFields(vDetail, vendorBatch);
setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);
vDetail.setVendorAddresses(getVendorAddresses(vendorBatch.getVendorAddresses(), vDetail));
vDetail.setVendorContacts(getVendorContacts(vendorBatch.getVendorContacts()));
VendorHeader vHeader = vDetail.getVendorHeader();
setupVendorHeaderFields(vHeader, vendorBatch);
vHeader.setVendorSupplierDiversities(getVendorSupplierDiversities(vendorBatch.getVendorSupplierDiversities()));
vDetail.setVendorHeader(vHeader);
vImpl.setBusinessObject(vDetail);
vendorDoc.setNewMaintainableObject(vImpl);
addNotes(vendorDoc, vendorBatch);
if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
loadDocumentAttachments(vendorDoc, Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
}
documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);
return vendorDoc.getDocumentNumber();
} catch (Exception e) {
LOG.info("addVendor STE " + e.getStackTrace() + e.toString());
return getFailRequestMessage(e);
}
}
use of org.kuali.kfs.vnd.document.VendorMaintainableImpl in project cu-kfs by CU-CommunityApps.
the class VendorBatchServiceImpl method updateVendor.
/*
* update vendor record. vendor number must be valid.
*/
private String updateVendor(VendorBatchDetail vendorBatch) {
GlobalVariables.setMessageMap(new MessageMap());
try {
MaintenanceDocument vendorDoc = (MaintenanceDocument) documentService.getNewDocument(VENDOR_DOCUMENT_TYPE_NAME);
vendorDoc.getDocumentHeader().setDocumentDescription(getDocumentDescription(vendorBatch, false));
LOG.info("updateVendor " + vendorBatch.getLogData());
VendorDetail vendor = cuVendorService.getByVendorNumber(vendorBatch.getVendorNumber());
if (vendor != null) {
// Vendor does not eist
VendorMaintainableImpl oldVendorImpl = (VendorMaintainableImpl) vendorDoc.getOldMaintainableObject();
oldVendorImpl.setBusinessObject(vendor);
} else {
// Vendor does not eist
return "Failed request : Vendor " + vendorBatch.getVendorNumber() + " Not Found.";
}
VendorMaintainableImpl vImpl = (VendorMaintainableImpl) vendorDoc.getNewMaintainableObject();
vImpl.setMaintenanceAction(KFSConstants.MAINTENANCE_EDIT_ACTION);
vendorDoc.getNewMaintainableObject().setDocumentNumber(vendorDoc.getDocumentNumber());
vImpl.setBusinessObject((VendorDetail) ObjectUtils.deepCopy(vendor));
VendorDetail vDetail = (VendorDetail) vImpl.getBusinessObject();
setupVendorDetailFields(vDetail, vendorBatch);
setupInsuranceTracking((VendorDetailExtension) vDetail.getExtension(), vendorBatch);
updateVendorAddresses(vendorBatch.getVendorAddresses(), vendor, vDetail);
updateVendorContacts(vendorBatch.getVendorContacts(), vendor, vDetail);
updateVendorSupplierDiversitys(vendorBatch.getVendorSupplierDiversities(), vendor, vDetail);
setupVendorHeaderFields(vDetail.getVendorHeader(), vendorBatch);
vImpl.setBusinessObject(vDetail);
vendorDoc.setNewMaintainableObject(vImpl);
addNotes(vendorDoc, vendorBatch);
// attachment
if (StringUtils.isNotBlank(vendorBatch.getAttachmentFiles())) {
loadDocumentAttachments(vendorDoc, Arrays.asList(vendorBatch.getAttachmentFiles().split(COLLECTION_FIELD_DELIMITER)));
}
// end attachment
documentService.routeDocument(vendorDoc, KFSConstants.EMPTY_STRING, null);
return vendorDoc.getDocumentNumber();
} catch (Exception e) {
LOG.info("updateVendor STE " + e.getStackTrace() + e.toString());
return getFailRequestMessage(e);
}
}
Aggregations