use of org.kuali.kfs.sys.businessobject.AccountingLineParser in project cu-kfs by CU-CommunityApps.
the class KualiAccountingDocumentActionBase method uploadAccountingLines.
/**
* This method determines whether we are uploading source or target lines, and then calls uploadAccountingLines
* directly on the document object. This method handles retrieving the actual upload file as an input stream into
* the document.
*
* @param isSource
* @param form
* @throws FileNotFoundException
* @throws IOException
*/
protected void uploadAccountingLines(boolean isSource, ActionForm form) throws FileNotFoundException, IOException {
KualiAccountingDocumentFormBase tmpForm = (KualiAccountingDocumentFormBase) form;
List importedLines = null;
AccountingDocument financialDocument = tmpForm.getFinancialDocument();
AccountingLineParser accountingLineParser = financialDocument.getAccountingLineParser();
// import the lines
String errorPathPrefix = null;
try {
if (isSource) {
errorPathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + "." + KFSConstants.SOURCE_ACCOUNTING_LINE_ERRORS;
FormFile sourceFile = tmpForm.getSourceFile();
checkUploadFile(sourceFile);
importedLines = accountingLineParser.importSourceAccountingLines(sourceFile.getFileName(), sourceFile.getInputStream(), financialDocument);
} else {
errorPathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + "." + KFSConstants.TARGET_ACCOUNTING_LINE_ERRORS;
FormFile targetFile = tmpForm.getTargetFile();
checkUploadFile(targetFile);
importedLines = accountingLineParser.importTargetAccountingLines(targetFile.getFileName(), targetFile.getInputStream(), financialDocument);
}
} catch (AccountingLineParserException e) {
GlobalVariables.getMessageMap().putError(errorPathPrefix, e.getErrorKey(), e.getErrorParameters());
}
// add line to list for those lines which were successfully imported
if (importedLines != null) {
for (Object importedLineObject : importedLines) {
AccountingLine importedLine = (AccountingLine) importedLineObject;
insertAccountingLine(isSource, tmpForm, importedLine);
}
}
}
Aggregations