Search in sources :

Example 1 with CustomerLevelEntity

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();
    }
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException)

Example 2 with CustomerLevelEntity

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();
    }
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with CustomerLevelEntity

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));
}
Also used : CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 4 with CustomerLevelEntity

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);
    }
}
Also used : CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) Test(org.junit.Test)

Example 5 with CustomerLevelEntity

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();
    }
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException) CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException)

Aggregations

CustomerLevelEntity (org.mifos.customers.business.CustomerLevelEntity)7 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)5 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)4 Test (org.junit.Test)3 CustomerCheckListBO (org.mifos.customers.checklist.business.CustomerCheckListBO)3 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)2 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 ArrayList (java.util.ArrayList)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 MultipleLoanAccountsCreationActionForm (org.mifos.accounts.loan.struts.actionforms.MultipleLoanAccountsCreationActionForm)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 CustomerLevel (org.mifos.customers.api.CustomerLevel)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 CheckListPersistence (org.mifos.customers.checklist.persistence.CheckListPersistence)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1