use of org.mifos.application.importexport.struts.actionforms.ImportTransactionsActionForm in project head by mifos.
the class ImportTransactionsAction method load.
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
final ImportTransactionsActionForm importTransactionsForm = (ImportTransactionsActionForm) form;
importTransactionsForm.clear();
clearOurSessionVariables(request.getSession());
final List<ListItem<String>> importPlugins = this.importTransactionsServiceFacade.retrieveImportPlugins();
request.setAttribute("importPlugins", importPlugins);
return mapping.findForward("import_load");
}
use of org.mifos.application.importexport.struts.actionforms.ImportTransactionsActionForm in project head by mifos.
the class ImportTransactionsAction method confirm.
public ActionForward confirm(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
final String tempFilename = (String) request.getSession().getAttribute(IMPORT_TEMPORARY_FILENAME);
final String importPluginClassname = (String) request.getSession().getAttribute(IMPORT_PLUGIN_CLASSNAME);
final ImportTransactionsActionForm importTransactionsForm = (ImportTransactionsActionForm) form;
final String importTransactionsFileName = importTransactionsForm.getImportTransactionsFile().getFileName();
final ParseResultDto importResult = this.importTransactionsServiceFacade.confirmImport(importPluginClassname, tempFilename);
if (null != importResult.getParseErrors() && !importResult.getParseErrors().isEmpty()) {
for (String error : importResult.getParseErrors()) {
logger.warn(importTransactionsFileName + ": " + error);
}
}
this.importTransactionsServiceFacade.saveImportedFileName(importTransactionsFileName, importPluginClassname, importResult.getTrxIdsToUndo());
logger.info(importResult.getNumberRowSuccessfullyParsed() + " transaction(s) imported from " + importTransactionsFileName + ".");
return mapping.findForward("import_confirm");
}
use of org.mifos.application.importexport.struts.actionforms.ImportTransactionsActionForm in project head by mifos.
the class ImportTransactionsAction method upload.
public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
final ImportTransactionsActionForm importTransactionsForm = (ImportTransactionsActionForm) form;
final FormFile importTransactionsFile = importTransactionsForm.getImportTransactionsFile();
final String importPluginClassname = importTransactionsForm.getImportPluginName();
request.getSession().setAttribute(IMPORT_PLUGIN_CLASSNAME, importPluginClassname);
final InputStream stream = importTransactionsFile.getInputStream();
final String tempFilename = saveImportAsTemporaryFile(importTransactionsFile.getInputStream());
request.getSession().setAttribute(IMPORT_TEMPORARY_FILENAME, tempFilename);
final ParseResultDto importResult = this.importTransactionsServiceFacade.parseImportTransactions(importPluginClassname, importTransactionsFile.getInputStream());
final List<String> errorsForDisplay = new ArrayList<String>();
if (!importResult.getParseErrors().isEmpty()) {
errorsForDisplay.addAll(importResult.getParseErrors());
}
int numberRowSuccessfullyParsed = importResult.getNumberRowSuccessfullyParsed();
if (numberRowSuccessfullyParsed == -1) {
numberRowSuccessfullyParsed = importResult.getSuccessfullyParsedPayments().size();
}
boolean submitButtonDisabled = false;
if (numberRowSuccessfullyParsed == 0) {
submitButtonDisabled = true;
}
if (importResult.isAmountInformationFilled() && importResult.isExtraRowInformationFilled()) {
request.setAttribute("isExtraInformationFilled", true);
request.setAttribute("numberOfErrorRows", importResult.getNumberOfErrorRows());
request.setAttribute("numberOfIgnoredRows", importResult.getNumberOfIgnoredRows());
request.setAttribute("numberOfReadRows", importResult.getNumberOfReadRows());
request.setAttribute("totalAmountOfTransactionsImported", new Money(Money.getDefaultCurrency(), importResult.getTotalAmountOfTransactionsImported()).toString());
request.setAttribute("totalAmountOfTransactionsWithError", new Money(Money.getDefaultCurrency(), importResult.getTotalAmountOfTransactionsWithError()).toString());
request.setAttribute("totalAmountOfDisbursementsTransactionsImported", new Money(Money.getDefaultCurrency(), importResult.getTotalAmountOfDisbursementsImported().toString()));
request.getSession().setAttribute(SESSION_ATTRIBUTE_LOG, importResult.getStatusLogFile().getBytes());
request.getSession().setAttribute(SESSION_ATTRIBUTE_LOG_FILENAME, statusLogfileName(importTransactionsFile.getFileName()));
} else {
request.setAttribute("isExtraInformationFilled", false);
}
request.setAttribute("importTransactionsErrors", errorsForDisplay);
request.setAttribute("numSuccessfulRows", numberRowSuccessfullyParsed);
request.setAttribute("submitButtonDisabled", submitButtonDisabled);
request.setAttribute("numberOfOverpayments", importResult.getNumberOfOverpayments());
stream.close();
importTransactionsFile.destroy();
return mapping.findForward("import_results");
}
Aggregations