use of org.mifos.customers.checklist.exceptions.CheckListException 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.customers.checklist.exceptions.CheckListException 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.customers.checklist.exceptions.CheckListException in project head by mifos.
the class CheckListBOIntegrationTest method testCreateCheckListExceptionForCustomerZeroDetails.
@Test
public void testCreateCheckListExceptionForCustomerZeroDetails() throws Exception {
CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.CENTER);
CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.CENTER_ACTIVE);
try {
customerCheckList = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, null, CheckListConstants.STATUS_ACTIVE, new ArrayList<String>(), (short) 1, (short) 1);
Assert.fail();
} catch (CheckListException ce) {
Assert.assertTrue(true);
}
}
Aggregations