Search in sources :

Example 1 with VendorMaintainableImpl

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);
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) VendorMaintainableImpl(org.kuali.kfs.vnd.document.VendorMaintainableImpl) MessageMap(org.kuali.kfs.krad.util.MessageMap) ValidationException(org.kuali.kfs.krad.exception.ValidationException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ParseException(org.kuali.kfs.sys.exception.ParseException)

Example 2 with VendorMaintainableImpl

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);
    }
}
Also used : VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) MaintenanceDocument(org.kuali.kfs.krad.maintenance.MaintenanceDocument) VendorMaintainableImpl(org.kuali.kfs.vnd.document.VendorMaintainableImpl) MessageMap(org.kuali.kfs.krad.util.MessageMap) ValidationException(org.kuali.kfs.krad.exception.ValidationException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ParseException(org.kuali.kfs.sys.exception.ParseException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ValidationException (org.kuali.kfs.krad.exception.ValidationException)2 MaintenanceDocument (org.kuali.kfs.krad.maintenance.MaintenanceDocument)2 MessageMap (org.kuali.kfs.krad.util.MessageMap)2 ParseException (org.kuali.kfs.sys.exception.ParseException)2 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)2 VendorMaintainableImpl (org.kuali.kfs.vnd.document.VendorMaintainableImpl)2 VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)1