Search in sources :

Example 1 with AccountingXmlDocumentListWrapper

use of edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentListWrapper in project cu-kfs by CU-CommunityApps.

the class CreateAccountingDocumentServiceImpl method processAccountingDocumentFromXml.

protected void processAccountingDocumentFromXml(String fileName) {
    CreateAccountingDocumentReportItem reportItem = new CreateAccountingDocumentReportItem(fileName);
    try {
        LOG.info("processAccountingDocumentFromXml: Started processing accounting document XML file: " + fileName);
        byte[] fileData = safelyLoadFileBytes(fileName);
        AccountingXmlDocumentListWrapper accountingXmlDocuments = (AccountingXmlDocumentListWrapper) batchInputFileService.parse(accountingDocumentBatchInputFileType, fileData);
        int documentCount = accountingXmlDocuments.getDocuments().size();
        LOG.info("processAccountingDocumentFromXml: Found " + documentCount + " documents to process from file: " + fileName);
        reportItem.setXmlSuccessfullyLoaded(true);
        reportItem.setNumberOfDocumentInFile(documentCount);
        reportItem.setReportEmailAddress(accountingXmlDocuments.getReportEmail());
        reportItem.setFileOverview(accountingXmlDocuments.getOverview());
        accountingXmlDocuments.getDocuments().stream().forEach(xmlDocument -> processAccountingDocumentEntryFromXml(xmlDocument, reportItem));
        LOG.info("processAccountingDocumentFromXml: Finished processing accounting document XML file: " + fileName);
    } catch (Exception e) {
        reportItem.setXmlSuccessfullyLoaded(false);
        String reportErrorMessage = configurationService.getPropertyValueAsString(CuFPKeyConstants.REPORT_CREATE_ACCOUNTING_DOCUMENT_XML_PROCESSING_ERROR) + KFSConstants.BLANK_SPACE + e.getMessage();
        reportItem.setReportItemMessage(reportErrorMessage);
        LOG.error("processAccountingDocumentFromXml: Error processing accounting document XML file", e);
    } finally {
        removeDoneFileQuietly(fileName);
        createAndEmailReport(reportItem);
    }
}
Also used : AccountingXmlDocumentListWrapper(edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentListWrapper) CreateAccountingDocumentReportItem(edu.cornell.kfs.fp.batch.CreateAccountingDocumentReportItem) ValidationException(org.kuali.kfs.krad.exception.ValidationException) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) IOException(java.io.IOException)

Aggregations

CreateAccountingDocumentReportItem (edu.cornell.kfs.fp.batch.CreateAccountingDocumentReportItem)1 AccountingXmlDocumentListWrapper (edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentListWrapper)1 IOException (java.io.IOException)1 ValidationException (org.kuali.kfs.krad.exception.ValidationException)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1