Search in sources :

Example 6 with HibernateTransactionHelperForStaticHibernateUtil

use of org.mifos.framework.hibernate.helper.HibernateTransactionHelperForStaticHibernateUtil in project head by mifos.

the class AdminServiceFacadeWebTier method createSavingsProduct.

@Override
public PrdOfferingDto createSavingsProduct(SavingsProductDto savingsProductRequest) {
    // enforced by integrity constraints on table also.
    this.savingsProductDao.validateProductWithSameNameDoesNotExist(savingsProductRequest.getProductDetails().getName());
    this.savingsProductDao.validateProductWithSameShortNameDoesNotExist(savingsProductRequest.getProductDetails().getShortName());
    // domain rule validation - put on domain entity
    validateStartDateIsNotBeforeToday(savingsProductRequest.getProductDetails().getStartDate());
    validateStartDateIsNotOverOneYearFromToday(savingsProductRequest.getProductDetails().getStartDate());
    validateEndDateIsPastStartDate(savingsProductRequest.getProductDetails().getStartDate(), savingsProductRequest.getProductDetails().getEndDate());
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    SavingsOfferingBO savingsProduct = new SavingsProductAssembler(this.loanProductDao, this.savingsProductDao, this.generalLedgerDao).fromDto(user, savingsProductRequest);
    HibernateTransactionHelper transactionHelper = new HibernateTransactionHelperForStaticHibernateUtil();
    try {
        transactionHelper.startTransaction();
        this.savingsProductDao.save(savingsProduct);
        transactionHelper.commitTransaction();
        return savingsProduct.toDto();
    } catch (Exception e) {
        transactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        transactionHelper.closeSession();
    }
}
Also used : HibernateTransactionHelper(org.mifos.framework.hibernate.helper.HibernateTransactionHelper) HibernateTransactionHelperForStaticHibernateUtil(org.mifos.framework.hibernate.helper.HibernateTransactionHelperForStaticHibernateUtil) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) MifosUser(org.mifos.security.MifosUser) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) BusinessRuleException(org.mifos.service.BusinessRuleException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ServiceException(org.mifos.framework.exceptions.ServiceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with HibernateTransactionHelperForStaticHibernateUtil

use of org.mifos.framework.hibernate.helper.HibernateTransactionHelperForStaticHibernateUtil 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

HibernateTransactionHelperForStaticHibernateUtil (org.mifos.framework.hibernate.helper.HibernateTransactionHelperForStaticHibernateUtil)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 ApplicationException (org.mifos.framework.exceptions.ApplicationException)6 PersistenceException (org.mifos.framework.exceptions.PersistenceException)6 ServiceException (org.mifos.framework.exceptions.ServiceException)6 SystemException (org.mifos.framework.exceptions.SystemException)6 HibernateTransactionHelper (org.mifos.framework.hibernate.helper.HibernateTransactionHelper)6 MifosUser (org.mifos.security.MifosUser)6 BusinessRuleException (org.mifos.service.BusinessRuleException)6 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)4 UserContext (org.mifos.security.util.UserContext)4 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)2 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)2 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 LocalDate (org.joda.time.LocalDate)1 StandardAccountService (org.mifos.accounts.api.StandardAccountService)1 TransactionImport (org.mifos.accounts.api.TransactionImport)1 PrdOfferingMeetingEntity (org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity)1