use of org.mifos.customers.checklist.exceptions.CheckListException in project head by mifos.
the class CheckListServiceFacadeWebTier method createCustomerChecklist.
@Override
public void createCustomerChecklist(Short levelId, Short stateId, String checklistName, List<String> checklistDetails) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
CustomerLevel level = CustomerLevel.getLevel(levelId);
CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(level);
CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(stateId);
try {
hibernateTransactionHelper.startTransaction();
CustomerCheckListBO customerCheckListBO = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, checklistName, CheckListConstants.STATUS_ACTIVE, checklistDetails, userContext.getLocaleId(), userContext.getId());
customerDao.save(customerCheckListBO);
hibernateTransactionHelper.commitTransaction();
} 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 updateCustomerChecklist.
@Override
public void updateCustomerChecklist(Short checklistId, Short levelId, Short stateId, Short checklistStatus, String checklistName, List<String> details) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.getLevel(levelId));
CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(stateId);
try {
hibernateTransactionHelper.startTransaction();
CustomerCheckListBO customerCheckList = (CustomerCheckListBO) new CheckListPersistence().getCheckList(checklistId);
customerCheckList.update(customerLevelEntity, customerStatusEntity, checklistName, checklistStatus, details, userContext.getLocaleId(), userContext.getId());
customerDao.save(customerCheckList);
hibernateTransactionHelper.commitTransaction();
} 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 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 CheckListBOIntegrationTest method testCreateCheckListExceptionForCustomer.
@Test
public void testCreateCheckListExceptionForCustomer() 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, getCheckListDetails(), (short) 1, (short) 1);
Assert.fail();
} catch (CheckListException ce) {
Assert.assertTrue(true);
}
}
use of org.mifos.customers.checklist.exceptions.CheckListException in project head by mifos.
the class CheckListBOIntegrationTest method testUpdateCustomerCheckListInvalidState.
@Test
public void testUpdateCustomerCheckListInvalidState() throws Exception {
CustomerCheckListBO customerCheckList1 = TestObjectFactory.createCustomerChecklist(CustomerLevel.CENTER.getValue(), CustomerStatus.CENTER_INACTIVE.getValue(), CheckListConstants.STATUS_ACTIVE);
customerCheckList = TestObjectFactory.createCustomerChecklist(CustomerLevel.CENTER.getValue(), CustomerStatus.CENTER_ACTIVE.getValue(), CheckListConstants.STATUS_ACTIVE);
CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.fromInt(CustomerStatus.CENTER_INACTIVE.getValue()));
StaticHibernateUtil.flushSession();
customerCheckList = (CustomerCheckListBO) TestObjectFactory.getObject(CustomerCheckListBO.class, customerCheckList.getChecklistId());
try {
customerCheckList.update(customerCheckList.getCustomerLevel(), customerStatusEntity, "Customer CheckList", CheckListConstants.STATUS_INACTIVE, getCheckListDetails(), (short) 1, (short) 1);
Assert.fail();
} catch (CheckListException ce) {
Assert.assertTrue(true);
} finally {
TestObjectFactory.deleteChecklist(customerCheckList1);
StaticHibernateUtil.flushSession();
}
}
Aggregations