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 ProductCategoryBOIntegrationTest method testCreateProductCategory.
@Test
public void testCreateProductCategory() throws SystemException, ApplicationException {
UserContext userContext = TestUtils.makeUser();
List<ProductTypeEntity> productTypeList = new ProductCategoryBusinessService().getProductTypes();
Assert.assertEquals(2, productTypeList.size());
TestObjectFactory.updateObject(new ProductCategoryBO(userContext, productTypeList.get(0), "product category", null));
ProductCategoryBO productCategoryBO = getProductCategory().get(2);
Assert.assertEquals("1-003", productCategoryBO.getGlobalPrdCategoryNum());
Assert.assertEquals("product category", productCategoryBO.getProductCategoryName());
Assert.assertNull(productCategoryBO.getProductCategoryDesc());
Assert.assertNotNull(productCategoryBO.getProductType());
try {
TestObjectFactory.updateObject(new ProductCategoryBO(userContext, productTypeList.get(0), "product category", null));
Assert.fail();
} catch (ProductDefinitionException expected) {
Assert.assertEquals(ProductDefinitionConstants.DUPLICATE_CATEGORY_NAME, expected.getKey());
}
deleteProductCategory(productCategoryBO);
}
use of org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService in project head by mifos.
the class ProductCategoryBOIntegrationTest method testUpdateProductCategory.
@Test
public void testUpdateProductCategory() throws SystemException, ApplicationException {
UserContext userContext = TestUtils.makeUser();
List<ProductTypeEntity> productTypeList = new ProductCategoryBusinessService().getProductTypes();
Assert.assertEquals(2, productTypeList.size());
TestObjectFactory.updateObject(new ProductCategoryBO(userContext, productTypeList.get(0), "product category", null));
ProductCategoryBO productCategoryBO = getProductCategory().get(2);
PrdCategoryStatusEntity prdCategoryStatusEntity = (PrdCategoryStatusEntity) TestObjectFactory.getObject(PrdCategoryStatusEntity.class, PrdCategoryStatus.INACTIVE.getValue());
productCategoryBO.updateProductCategory("Category", "Name changed", prdCategoryStatusEntity);
TestObjectFactory.updateObject(productCategoryBO);
productCategoryBO = getProductCategory().get(2);
Assert.assertEquals("1-003", productCategoryBO.getGlobalPrdCategoryNum());
Assert.assertEquals("Category", productCategoryBO.getProductCategoryName());
Assert.assertNotNull(productCategoryBO.getProductCategoryDesc());
Assert.assertNotNull(productCategoryBO.getProductType());
Assert.assertNotNull("Name changed", productCategoryBO.getProductCategoryDesc());
productCategoryBO.updateProductCategory("Category", "Name changed", prdCategoryStatusEntity);
// TODO: assert that it got updated.
deleteProductCategory(productCategoryBO);
}
Aggregations