Search in sources :

Example 1 with ProductCategoryBusinessService

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

the class CheckListServiceFacadeWebTier method createAccountChecklist.

@Override
public void createAccountChecklist(Short productId, Short stateId, 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 accountCheckListBO = new AccountCheckListBO(productTypeEntity, accountStateEntity, checklistName, CheckListConstants.STATUS_ACTIVE, checklistDetails, userContext.getLocaleId(), userContext.getId());
        customerDao.save(accountCheckListBO);
        hibernateTransactionHelper.commitTransaction();
    } catch (ServiceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ServiceException(org.mifos.framework.exceptions.ServiceException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with ProductCategoryBusinessService

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

the class AdminServiceFacadeWebTier method retrieveAllProductMix.

@Override
public ProductDto retrieveAllProductMix() {
    try {
        List<ProductCategoryBO> productCategoryList = new ProductCategoryBusinessService().getAllCategories();
        List<PrdOfferingBO> prdOfferingList = new ProductMixBusinessService().getPrdOfferingMix();
        List<ProductCategoryTypeDto> pcList = new ArrayList<ProductCategoryTypeDto>();
        for (ProductCategoryBO pcBO : productCategoryList) {
            ProductCategoryTypeDto pcDto = new ProductCategoryTypeDto(pcBO.getProductType().getProductTypeID(), pcBO.getProductType().getLookUpValue().getLookUpName());
            pcList.add(pcDto);
        }
        List<ProductMixDto> pmList = new ArrayList<ProductMixDto>();
        for (PrdOfferingBO poBO : prdOfferingList) {
            ProductMixDto pmDto = new ProductMixDto(poBO.getPrdCategory().getProductType().getProductTypeID(), poBO.getPrdOfferingId(), poBO.getPrdType().getProductTypeID(), poBO.getPrdOfferingName());
            pmList.add(pmDto);
        }
        ProductDto productDto = new ProductDto(pcList, pmList);
        return productDto;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ProductMixBusinessService(org.mifos.accounts.productsmix.business.service.ProductMixBusinessService) ArrayList(java.util.ArrayList) ProductMixDto(org.mifos.dto.screen.ProductMixDto) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) PrdOfferingBO(org.mifos.accounts.productdefinition.business.PrdOfferingBO) ProductCategoryTypeDto(org.mifos.dto.screen.ProductCategoryTypeDto) ProductDto(org.mifos.dto.screen.ProductDto) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with ProductCategoryBusinessService

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

the class AdminServiceFacadeWebTier method retrieveAllProductCategories.

@Override
public ProductCategoryDisplayDto retrieveAllProductCategories() {
    try {
        List<ProductCategoryBO> productCategoryList = new ProductCategoryBusinessService().getAllCategories();
        List<ProductCategoryTypeDto> pcTypeList = new ArrayList<ProductCategoryTypeDto>();
        List<ProductCategoryDto> pcList = new ArrayList<ProductCategoryDto>();
        for (ProductCategoryBO pcBO : productCategoryList) {
            ProductCategoryTypeDto pcTypeDto = new ProductCategoryTypeDto(pcBO.getProductType().getProductTypeID(), pcBO.getProductType().getLookUpValue().getLookUpName());
            pcTypeList.add(pcTypeDto);
            ProductCategoryDto pcDto = new ProductCategoryDto(pcBO.getProductCategoryName(), pcBO.getPrdCategoryStatus().getId(), pcBO.getGlobalPrdCategoryNum());
            pcList.add(pcDto);
        }
        ProductCategoryDisplayDto productCategoryDisplayDto = new ProductCategoryDisplayDto(pcTypeList, pcList);
        return productCategoryDisplayDto;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ProductCategoryDisplayDto(org.mifos.dto.screen.ProductCategoryDisplayDto) ServiceException(org.mifos.framework.exceptions.ServiceException) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ArrayList(java.util.ArrayList) ProductCategoryDto(org.mifos.dto.screen.ProductCategoryDto) ProductCategoryTypeDto(org.mifos.dto.screen.ProductCategoryTypeDto) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with ProductCategoryBusinessService

use of org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService 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 5 with ProductCategoryBusinessService

use of org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService 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

ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 ServiceException (org.mifos.framework.exceptions.ServiceException)6 UserContext (org.mifos.security.util.UserContext)4 ArrayList (java.util.ArrayList)3 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)3 ProductTypeEntity (org.mifos.accounts.productdefinition.business.ProductTypeEntity)3 ProductCategoryTypeDto (org.mifos.dto.screen.ProductCategoryTypeDto)3 Test (org.junit.Test)2 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)2 AccountCheckListBO (org.mifos.customers.checklist.business.AccountCheckListBO)2 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)2 MifosUser (org.mifos.security.MifosUser)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 PrdOfferingBO (org.mifos.accounts.productdefinition.business.PrdOfferingBO)1 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)1 ProductMixBusinessService (org.mifos.accounts.productsmix.business.service.ProductMixBusinessService)1 CheckListPersistence (org.mifos.customers.checklist.persistence.CheckListPersistence)1 SavingsProductDto (org.mifos.dto.domain.SavingsProductDto)1