Search in sources :

Example 6 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class AdminServiceFacadeWebTier method createProductCategory.

@Override
public void createProductCategory(CreateOrUpdateProductCategory productCategoryDto) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    this.loanProductDao.validateNameIsAvailableForCategory(productCategoryDto.getProductCategoryName(), productCategoryDto.getProductTypeEntityId());
    HibernateTransactionHelper transactionHelper = new HibernateTransactionHelperForStaticHibernateUtil();
    try {
        // FIXME - delegate to globalNumberGenerationStrategy
        StringBuilder globalPrdOfferingNum = new StringBuilder();
        globalPrdOfferingNum.append(userContext.getBranchId());
        globalPrdOfferingNum.append("-");
        Short maxPrdID = legacyProductCategoryDao.getMaxPrdCategoryId();
        globalPrdOfferingNum.append(StringUtils.leftPad(String.valueOf(maxPrdID != null ? maxPrdID + 1 : ProductDefinitionConstants.DEFAULTMAX), 3, '0'));
        String globalNumber = globalPrdOfferingNum.toString();
        ProductTypeEntity productType = new ProductTypeEntity(productCategoryDto.getProductTypeEntityId());
        ProductCategoryBO productCategoryBO = new ProductCategoryBO(productType, productCategoryDto.getProductCategoryName(), productCategoryDto.getProductCategoryDesc(), globalNumber);
        transactionHelper.startTransaction();
        this.loanProductDao.save(productCategoryBO);
        transactionHelper.commitTransaction();
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    } 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) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) 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) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class AdminServiceFacadeWebTier method updateProductConfiguration.

@Override
public void updateProductConfiguration(ProductConfigurationDto productConfiguration) {
    ProductTypeEntity loanProductConfiguration = this.loanProductDao.findLoanProductConfiguration();
    ProductTypeEntity savingsProductConfiguration = this.savingsProductDao.findSavingsProductConfiguration();
    this.productService.updateLatenessAndDormancy(loanProductConfiguration, savingsProductConfiguration, productConfiguration);
}
Also used : ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity)

Example 8 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveProductConfiguration.

@Override
public ProductConfigurationDto retrieveProductConfiguration() {
    ProductTypeEntity loanProductConfiguration = this.loanProductDao.findLoanProductConfiguration();
    ProductTypeEntity savingsProductConfiguration = this.savingsProductDao.findSavingsProductConfiguration();
    return new ProductConfigurationDto(loanProductConfiguration.getLatenessDays().intValue(), savingsProductConfiguration.getDormancyDays().intValue());
}
Also used : ProductConfigurationDto(org.mifos.dto.screen.ProductConfigurationDto) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity)

Example 9 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class CheckListServiceFacadeWebTier method updateAccountChecklist.

@Override
public void updateAccountChecklist(Short checklistId, Short productId, Short stateId, Short checklistStatus, String checklistName, List<String> checklistDetails) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    try {
        ProductTypeEntity productTypeEntity = null;
        for (ProductTypeEntity prdTypeEntity : new ProductCategoryBusinessService().getProductTypes()) {
            if (productId.equals(prdTypeEntity.getProductTypeID())) {
                productTypeEntity = prdTypeEntity;
                break;
            }
        }
        hibernateTransactionHelper.startTransaction();
        AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.fromShort(stateId));
        AccountCheckListBO accountCheckList = (AccountCheckListBO) new CheckListPersistence().getCheckList(checklistId);
        accountCheckList.update(productTypeEntity, accountStateEntity, checklistName, checklistStatus, checklistDetails, userContext.getLocaleId(), userContext.getId());
        customerDao.save(accountCheckList);
        hibernateTransactionHelper.commitTransaction();
    } catch (ServiceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } catch (PersistenceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) BusinessRuleException(org.mifos.service.BusinessRuleException) ServiceException(org.mifos.framework.exceptions.ServiceException) CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 10 with ProductTypeEntity

use of org.mifos.accounts.productdefinition.business.ProductTypeEntity in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveProductCategoryTypes.

@Override
public List<ProductCategoryTypeDto> retrieveProductCategoryTypes() {
    try {
        List<ProductTypeEntity> productCategoryList = new ProductCategoryBusinessService().getProductTypes();
        List<ProductCategoryTypeDto> productCategoryTypeDtoList = new ArrayList<ProductCategoryTypeDto>();
        for (ProductTypeEntity productType : productCategoryList) {
            ProductCategoryTypeDto productCategoryTypeDto = new ProductCategoryTypeDto(productType.getProductTypeID(), productType.getLookUpValue().getLookUpName());
            productCategoryTypeDtoList.add(productCategoryTypeDto);
        }
        return productCategoryTypeDtoList;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) ArrayList(java.util.ArrayList) ProductCategoryTypeDto(org.mifos.dto.screen.ProductCategoryTypeDto) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ProductTypeEntity (org.mifos.accounts.productdefinition.business.ProductTypeEntity)13 Test (org.junit.Test)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 ServiceException (org.mifos.framework.exceptions.ServiceException)4 UserContext (org.mifos.security.util.UserContext)4 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)3 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)3 AccountCheckListBO (org.mifos.customers.checklist.business.AccountCheckListBO)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 MifosUser (org.mifos.security.MifosUser)3 BusinessRuleException (org.mifos.service.BusinessRuleException)3 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)2 ArrayList (java.util.ArrayList)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)1 CheckListPersistence (org.mifos.customers.checklist.persistence.CheckListPersistence)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 ProductCategoryTypeDto (org.mifos.dto.screen.ProductCategoryTypeDto)1 ProductConfigurationDto (org.mifos.dto.screen.ProductConfigurationDto)1