Search in sources :

Example 1 with PhysicalFlatFileInformation

use of org.kuali.kfs.sys.batch.PhysicalFlatFileInformation in project cu-kfs by CU-CommunityApps.

the class AdvanceDepositServiceImpl method loadFile.

/**
 * @see AdvanceDepositService#loadFile()
 */
public void loadFile() {
    List<PhysicalFlatFileInformation> flatFileInformationList = new ArrayList<>();
    PhysicalFlatFileInformation physicalflatFileInformation;
    List<String> fileNamesToLoad = getListOfFilesToProcess();
    if (LOG.isInfoEnabled()) {
        LOG.info("Found " + fileNamesToLoad.size() + " file(s) to process.");
    }
    for (String inputFileName : fileNamesToLoad) {
        try {
            if (LOG.isInfoEnabled()) {
                LOG.info("Beginning processing of filename: " + inputFileName + ".");
            }
            physicalflatFileInformation = new PhysicalFlatFileInformation(inputFileName);
            flatFileInformationList.add(physicalflatFileInformation);
            if (loadFile(inputFileName, physicalflatFileInformation)) {
                physicalflatFileInformation.addFileInfoMessage("File successfully completed processing.");
            } else {
                physicalflatFileInformation.addFileErrorMessage("Unable to process file.");
            }
        } catch (RuntimeException e) {
            LOG.error("Caught exception trying to load: " + inputFileName, e);
            throw new RuntimeException("Caught exception trying to load: " + inputFileName, e);
        } finally {
            removeDoneFile(inputFileName);
        }
    }
    sendEmailSummary(flatFileInformationList);
}
Also used : ArrayList(java.util.ArrayList) PhysicalFlatFileInformation(org.kuali.kfs.sys.batch.PhysicalFlatFileInformation)

Example 2 with PhysicalFlatFileInformation

use of org.kuali.kfs.sys.batch.PhysicalFlatFileInformation in project cu-kfs by CU-CommunityApps.

the class AdvanceDepositServiceImpl method copyAllMessage.

private void copyAllMessage(Object parsedObject, PhysicalFlatFileInformation physicalFlatFileInformation) {
    List<AchIncomeFile> achIncomeFiles = (List<AchIncomeFile>) parsedObject;
    for (AchIncomeFile achIncomeFile : achIncomeFiles) {
        FlatFileInformation fileInformation = new FlatFileInformation();
        FlatFileTransactionInformation information = achIncomeFile.getFlatFileTransactionInformation();
        fileInformation.getOrAddFlatFileData(achIncomeFile.getInterchangeControlNumber(), information);
        fileInformation.addFileInfoMessage(achIncomeFile.getEmailMessageText());
        physicalFlatFileInformation.getFlatFileInfomationList().add(fileInformation);
    }
}
Also used : AchIncomeFile(edu.cornell.kfs.fp.businessobject.AchIncomeFile) List(java.util.List) ArrayList(java.util.ArrayList) PhysicalFlatFileInformation(org.kuali.kfs.sys.batch.PhysicalFlatFileInformation) FlatFileInformation(org.kuali.kfs.sys.batch.FlatFileInformation) FlatFileTransactionInformation(org.kuali.kfs.sys.batch.FlatFileTransactionInformation)

Example 3 with PhysicalFlatFileInformation

use of org.kuali.kfs.sys.batch.PhysicalFlatFileInformation in project cu-kfs by CU-CommunityApps.

the class AdvanceDepositServiceImpl method loadFile.

public boolean loadFile(String fileName, PhysicalFlatFileInformation physicalFlatFileInformation) {
    boolean valid = true;
    byte[] fileByteContent = safelyLoadFileBytes(fileName);
    if (LOG.isInfoEnabled()) {
        LOG.info("Attempting to parse the file ");
    }
    Object parsedObject;
    try {
        parsedObject = batchInputFileService.parse(batchInputFileType, fileByteContent);
    } catch (org.kuali.kfs.sys.exception.ParseException e) {
        LOG.error("Error parsing batch file: " + e.getMessage());
        FlatFileInformation fileInformation = new FlatFileInformation();
        fileInformation.addFileInfoMessage("Unable to process file" + StringUtils.substringAfterLast(fileName, "\\") + "." + e.getMessage());
        physicalFlatFileInformation.getFlatFileInfomationList().add(fileInformation);
        return false;
    }
    if (parsedObject != null) {
        valid = validate(parsedObject);
        copyAllMessage(parsedObject, physicalFlatFileInformation);
        if (valid) {
            loadAchIncomeTransactions(parsedObject);
        }
    }
    return valid;
}
Also used : PhysicalFlatFileInformation(org.kuali.kfs.sys.batch.PhysicalFlatFileInformation) FlatFileInformation(org.kuali.kfs.sys.batch.FlatFileInformation)

Aggregations

PhysicalFlatFileInformation (org.kuali.kfs.sys.batch.PhysicalFlatFileInformation)3 ArrayList (java.util.ArrayList)2 FlatFileInformation (org.kuali.kfs.sys.batch.FlatFileInformation)2 AchIncomeFile (edu.cornell.kfs.fp.businessobject.AchIncomeFile)1 List (java.util.List)1 FlatFileTransactionInformation (org.kuali.kfs.sys.batch.FlatFileTransactionInformation)1