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();
}
}
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);
}
}
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);
}
}
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();
}
}
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);
}
}
Aggregations