use of edu.cornell.kfs.fp.batch.CreateAccountingDocumentReportItemDetail in project cu-kfs by CU-CommunityApps.
the class CreateAccountingDocumentServiceImpl method processAccountingDocumentEntryFromXml.
protected void processAccountingDocumentEntryFromXml(AccountingXmlDocumentEntry accountingXmlDocument, CreateAccountingDocumentReportItem reportItem) {
GlobalVariables.getMessageMap().clearErrorMessages();
CreateAccountingDocumentReportItemDetail detail = new CreateAccountingDocumentReportItemDetail();
detail.setIndexNumber(accountingXmlDocument.getIndex().intValue());
detail.setDocumentType(accountingXmlDocument.getDocumentTypeCode());
detail.setDocumentDescription(accountingXmlDocument.getDescription());
detail.setDocumentExplanation(accountingXmlDocument.getExplanation());
try {
LOG.info("processAccountingDocumentEntryFromXml: Started processing accounting document of type: " + accountingXmlDocument.getDocumentTypeCode());
String documentGeneratorBeanName = CuFPConstants.ACCOUNTING_DOCUMENT_GENERATOR_BEAN_PREFIX + accountingXmlDocument.getDocumentTypeCode();
AccountingDocumentGenerator<? extends AccountingDocument> documentGenerator = findDocumentGenerator(documentGeneratorBeanName);
AccountingDocument document = documentGenerator.createDocument(this::getNewDocument, accountingXmlDocument);
document = (AccountingDocument) documentService.routeDocument(document, CuFPConstants.ACCOUNTING_DOCUMENT_XML_ROUTE_ANNOTATION, getAllAdHocRecipients(document));
LOG.info("processAccountingDocumentEntryFromXml: Finished processing and routing accounting document " + document.getDocumentNumber() + " of type: " + accountingXmlDocument.getDocumentTypeCode());
detail.setSuccessfullyRouted(true);
detail.setDocumentNumber(document.getDocumentNumber());
reportItem.getDocumentsSuccessfullyRouted().add(detail);
} catch (Exception e) {
detail.setSuccessfullyRouted(false);
if (e instanceof ValidationException) {
String errorMessage = buildValidationErrorMessage((ValidationException) e);
LOG.error("processAccountingDocumentEntryFromXml: Could not route accounting document - " + errorMessage);
detail.setErrorMessage(errorMessage);
} else {
LOG.error("processAccountingDocumentEntryFromXml: Error processing accounting XML document", e);
detail.setErrorMessage("Non validation error: " + e.getMessage());
}
reportItem.getDocumentsInError().add(detail);
} finally {
GlobalVariables.getMessageMap().clearErrorMessages();
}
}
Aggregations