Search in sources :

Example 1 with TransactionImport

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);
            }
        }
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) ParseResultDto(org.mifos.dto.domain.ParseResultDto) FileInputStream(java.io.FileInputStream) TransactionImport(org.mifos.accounts.api.TransactionImport) BusinessRuleException(org.mifos.service.BusinessRuleException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with TransactionImport

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;
}
Also used : UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) ParseResultDto(org.mifos.dto.domain.ParseResultDto) TransactionImport(org.mifos.accounts.api.TransactionImport)

Example 3 with TransactionImport

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;
}
Also used : PluginManager(org.mifos.framework.plugin.PluginManager) TransactionImport(org.mifos.accounts.api.TransactionImport) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with TransactionImport

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;
}
Also used : PluginManager(org.mifos.framework.plugin.PluginManager) UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) TransactionImport(org.mifos.accounts.api.TransactionImport)

Example 5 with TransactionImport

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;
}
Also used : PersonnelDaoHibernate(org.mifos.customers.personnel.persistence.PersonnelDaoHibernate) GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) HibernateTransactionHelperForStaticHibernateUtil(org.mifos.framework.hibernate.helper.HibernateTransactionHelperForStaticHibernateUtil) ArrayList(java.util.ArrayList) URLClassLoader(java.net.URLClassLoader) StandardAccountService(org.mifos.accounts.api.StandardAccountService) CustomerSearchServiceImpl(org.mifos.customers.business.service.CustomerSearchServiceImpl) TransactionImport(org.mifos.accounts.api.TransactionImport) CustomerDaoHibernate(org.mifos.customers.persistence.CustomerDaoHibernate)

Aggregations

TransactionImport (org.mifos.accounts.api.TransactionImport)6 ArrayList (java.util.ArrayList)2 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)2 ParseResultDto (org.mifos.dto.domain.ParseResultDto)2 PluginManager (org.mifos.framework.plugin.PluginManager)2 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 FileInputStream (java.io.FileInputStream)1 URLClassLoader (java.net.URLClassLoader)1 LinkedHashMap (java.util.LinkedHashMap)1 StandardAccountService (org.mifos.accounts.api.StandardAccountService)1 GenericDaoHibernate (org.mifos.accounts.savings.persistence.GenericDaoHibernate)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 CustomerSearchServiceImpl (org.mifos.customers.business.service.CustomerSearchServiceImpl)1 CustomerDaoHibernate (org.mifos.customers.persistence.CustomerDaoHibernate)1 PersonnelDaoHibernate (org.mifos.customers.personnel.persistence.PersonnelDaoHibernate)1 UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)1 HibernateTransactionHelperForStaticHibernateUtil (org.mifos.framework.hibernate.helper.HibernateTransactionHelperForStaticHibernateUtil)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1