use of org.mifos.accounts.api.TransactionImport in project head by mifos.
the class ImportTransactionsServiceFacadeWebTier method confirmImport.
@Override
public ParseResultDto confirmImport(String importPluginClassname, String tempFileName) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
FileInputStream fileInput = null;
try {
final TransactionImport transactionImport = getInitializedImportPlugin(importPluginClassname, userContext.getId());
fileInput = new FileInputStream(tempFileName);
final ParseResultDto importResult = transactionImport.parse(fileInput);
fileInput.close();
fileInput = new FileInputStream(tempFileName);
if (importPluginClassname.equalsIgnoreCase("org.almajmoua.AudiBankXlsImporter")) {
importResult.setTrxIdsToUndo(transactionImport.storeForUndoImport(fileInput));
} else {
transactionImport.store(fileInput);
}
return importResult;
} catch (Exception e) {
throw new MifosRuntimeException(e);
} finally {
if (fileInput != null) {
try {
fileInput.close();
} catch (Exception e2) {
throw new MifosRuntimeException(e2);
}
}
}
}
use of org.mifos.accounts.api.TransactionImport in project head by mifos.
the class ImportTransactionsServiceFacadeWebTier method parseImportTransactions.
@Override
public ParseResultDto parseImportTransactions(String importPluginClassname, InputStream inputStream) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
final TransactionImport ti = getInitializedImportPlugin(importPluginClassname, userContext.getId());
final ParseResultDto importResult = ti.parse(inputStream);
int numberRowSuccessfullyParsed = ti.getSuccessfullyParsedRows();
importResult.setNumberRowSuccessfullyParsed(numberRowSuccessfullyParsed);
String statusLogFile = generateStatusLogfile(importResult, ti);
importResult.setStatusLogFile(statusLogFile);
return importResult;
}
use of org.mifos.accounts.api.TransactionImport in project head by mifos.
the class ViewOrganizationSettingsServiceFacadeWebTier method getDisplayablePluginsProperties.
@Override
public Map<String, String> getDisplayablePluginsProperties() {
Map<String, String> result = new LinkedHashMap<String, String>();
for (TransactionImport ti : new PluginManager().loadImportPlugins()) {
Map<String, String> properties = ti.getPropertiesForAdminDisplay();
Iterator<String> iterator = properties.keySet().iterator();
while (iterator.hasNext()) {
String key = String.valueOf(iterator.next());
String value = String.valueOf(properties.get(key));
if (key != null && value != null) {
result.put(key, value);
}
}
}
return result;
}
use of org.mifos.accounts.api.TransactionImport in project head by mifos.
the class ImportTransactionsServiceFacadeWebTier method getInitializedImportPlugin.
private TransactionImport getInitializedImportPlugin(String importPluginClassname, Short userId) {
final TransactionImport ti = new PluginManager().getImportPlugin(importPluginClassname);
final UserReferenceDto userReferenceDTO = new UserReferenceDto(userId);
ti.setUserReferenceDto(userReferenceDTO);
return ti;
}
use of org.mifos.accounts.api.TransactionImport in project head by mifos.
the class PluginManager method loadImportPlugins.
/**
* Returns list of import plugins. Note that {@link ServiceLoader} caches
* loads, so multiple invocations should not incur extra overhead.
*/
public List<TransactionImport> loadImportPlugins() {
List<TransactionImport> plugins = new ArrayList<TransactionImport>();
ClassLoader pluginClassLoader = initializePluginClassLoader();
ServiceLoader<TransactionImport> loader = ServiceLoader.load(TransactionImport.class, pluginClassLoader);
for (TransactionImport ti : loader) {
ti.setAccountService(new StandardAccountService(ApplicationContextProvider.getBean(LegacyAccountDao.class), ApplicationContextProvider.getBean(LegacyLoanDao.class), ApplicationContextProvider.getBean(LegacyAcceptedPaymentTypeDao.class), new PersonnelDaoHibernate(new GenericDaoHibernate()), new CustomerDaoHibernate(new GenericDaoHibernate()), ApplicationContextProvider.getBean(LoanBusinessService.class), new HibernateTransactionHelperForStaticHibernateUtil(), ApplicationContextProvider.getBean(LegacyMasterDao.class), ApplicationContextProvider.getBean(MonthClosingServiceFacade.class), ApplicationContextProvider.getBean(SavingsServiceFacade.class), ApplicationContextProvider.getBean(GroupLoanAccountServiceFacade.class)));
ti.setCustomerSearchService(new CustomerSearchServiceImpl(new CustomerDaoHibernate(new GenericDaoHibernate())));
plugins.add(ti);
}
return plugins;
}
Aggregations