Search in sources :

Example 1 with VendorInactivateConvertBatch

use of edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch in project cu-kfs by CU-CommunityApps.

the class VendorInactivateConvertBatchCsvBuilder method buildVendorUpdatesFromDataMap.

/**
 * build the ReceiptProcessing BO from the data row
 *
 * @param rowDataMap
 * @return
 */
private static VendorInactivateConvertBatch buildVendorUpdatesFromDataMap(Map<String, String> rowDataMap) {
    VendorInactivateConvertBatch vendorUpdate = new VendorInactivateConvertBatch();
    vendorUpdate.setVendorId(rowDataMap.get(VendorInactivateConvertBatchCsv.vendorID.name()));
    vendorUpdate.setAction(rowDataMap.get(VendorInactivateConvertBatchCsv.action.name()));
    vendorUpdate.setNote(rowDataMap.get(VendorInactivateConvertBatchCsv.note.name()));
    vendorUpdate.setReason(rowDataMap.get(VendorInactivateConvertBatchCsv.reason.name()));
    vendorUpdate.setConvertType(rowDataMap.get(VendorInactivateConvertBatchCsv.convertType.name()));
    return vendorUpdate;
}
Also used : VendorInactivateConvertBatch(edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch)

Example 2 with VendorInactivateConvertBatch

use of edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch in project cu-kfs by CU-CommunityApps.

the class VendorInactivateConvertBatchServiceImpl method inactivateConvert.

/**
 */
public boolean inactivateConvert(String fileName, BatchInputFileType batchInputFileType) {
    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<VendorInactivateConvertBatch> vendors = ((List<VendorInactivateConvertBatch>) parsedObject);
    for (VendorInactivateConvertBatch vendor : vendors) {
        String[] vendorId = vendor.getVendorId().split("-");
        Collection<VendorDetail> vendorDets = businessObjectService.findMatching(VendorDetail.class, Collections.singletonMap("vendorHeaderGeneratedIdentifier", vendorId[0]));
        GlobalVariables.setUserSession(new UserSession("kfs"));
        VendorDetail vnd = cuVendorService.getByVendorNumber(vendor.getVendorId());
        if (ObjectUtils.isNull(vnd)) {
            LOG.info("Vendor with id: " + vendor.getVendorId() + " does not exist in the database.");
        }
        if ((ObjectUtils.isNotNull(vnd))) {
            VendorHeader vHead = businessObjectService.findBySinglePrimaryKey(VendorHeader.class, vnd.getVendorHeaderGeneratedIdentifier());
            if (vendor.getAction().equalsIgnoreCase("inactivate") && ((vendorDets.size() == 1) || !(vendorId[1].equalsIgnoreCase("0")))) {
                inactivateVendor(vnd, vendor.getNote(), vendor.getReason());
            } else if (vendor.getAction().equalsIgnoreCase("activate") && ((vendorDets.size() == 1) || !(vendorId[1].equalsIgnoreCase("0")))) {
                activateVendor(vnd, vendor.getNote(), vendor.getReason());
            } else if (vendor.getAction().equalsIgnoreCase("convert") && ((vendorDets.size() == 1) || !(vendorId[1].equalsIgnoreCase("0")))) {
                convertVendor(vHead, vnd, vendor.getNote(), vendor.getConvertType());
            } else if (vendorDets.size() > 1) {
                LOG.info("failed to process for " + vnd.getVendorNumber() + ", This vendor has child records. These must be processed through the application");
            } else {
                String errorMessage = "Failed to parse vendor action expected inactivate or convert but recevied " + vendor.getAction();
                criticalError(errorMessage);
            }
        }
    }
    return result;
}
Also used : VendorHeader(org.kuali.kfs.vnd.businessobject.VendorHeader) VendorInactivateConvertBatch(edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) UserSession(org.kuali.kfs.krad.UserSession) ArrayList(java.util.ArrayList) List(java.util.List) ParseException(org.kuali.kfs.sys.exception.ParseException)

Example 3 with VendorInactivateConvertBatch

use of edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch in project cu-kfs by CU-CommunityApps.

the class VendorInactivateConvertBatchCsvBuilder method buildVendorUpdates.

/**
 * Convert the parseData object into ReceiptProcessing BO
 *
 * @param parseDataList
 * @return
 */
public static List<VendorInactivateConvertBatch> buildVendorUpdates(List<Map<String, String>> parseDataList) {
    List<VendorInactivateConvertBatch> vendorUpdates = new ArrayList<VendorInactivateConvertBatch>();
    VendorInactivateConvertBatch vendorUpdate = null, dataVendorUpdate;
    for (Map<String, String> rowDataMap : parseDataList) {
        dataVendorUpdate = buildVendorUpdatesFromDataMap(rowDataMap);
        vendorUpdate = dataVendorUpdate;
        vendorUpdates.add(vendorUpdate);
    }
    return vendorUpdates;
}
Also used : VendorInactivateConvertBatch(edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch) ArrayList(java.util.ArrayList)

Aggregations

VendorInactivateConvertBatch (edu.cornell.kfs.vnd.businessobject.VendorInactivateConvertBatch)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1 UserSession (org.kuali.kfs.krad.UserSession)1 ParseException (org.kuali.kfs.sys.exception.ParseException)1 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)1 VendorHeader (org.kuali.kfs.vnd.businessobject.VendorHeader)1