use of org.mifos.customers.business.CustomerLevelEntity 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.business.CustomerLevelEntity 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.business.CustomerLevelEntity in project head by mifos.
the class LoanProductDaoHibernateIntegrationTest method testShouldFindOnlyActiveLoanProductsApplicableToCustomerLevel.
@Test
public void testShouldFindOnlyActiveLoanProductsApplicableToCustomerLevel() {
CustomerLevelEntity groupLevel = new CustomerLevelEntity(CustomerLevel.GROUP);
// exercise test
List<LoanOfferingBO> activeLoanProductsApplicableToGroup = loanProductDao.findActiveLoanProductsApplicableToCustomerLevel(groupLevel);
assertThat("Only active products applicable to groups should be returned", activeLoanProductsApplicableToGroup.size(), is(1));
assertThat(activeLoanProductsApplicableToGroup, hasItem(activeLoanProduct));
}
use of org.mifos.customers.business.CustomerLevelEntity 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.business.CustomerLevelEntity in project head by mifos.
the class IntegrationTestObjectMother method createCustomerChecklist.
public static CustomerCheckListBO createCustomerChecklist(Short customerLevel, Short customerStatus, Short checklistStatus, List<String> details) {
try {
StaticHibernateUtil.startTransaction();
CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.getLevel(customerLevel));
CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.fromInt(customerStatus));
CustomerCheckListBO customerChecklist = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, "productchecklist", checklistStatus, details, Short.valueOf("1"), PersonnelConstants.SYSTEM_USER);
customerDao.save(customerChecklist);
StaticHibernateUtil.commitTransaction();
return customerChecklist;
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new RuntimeException(e);
} finally {
StaticHibernateUtil.closeSession();
}
}
Aggregations