Search in sources :

Example 1 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity 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 CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity 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 CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class CustomerSearchServiceFacadeWebTier method getAvailibleCustomerStates.

@Override
public Map<String, ArrayList<CustomerStatusDetailDto>> getAvailibleCustomerStates() throws PersistenceException {
    HashMap<String, ArrayList<CustomerStatusDetailDto>> customerStates = new HashMap<String, ArrayList<CustomerStatusDetailDto>>();
    for (CustomerLevel customerLevel : CustomerLevel.values()) {
        List<CustomerStatusEntity> states = new CustomerPersistence().retrieveAllCustomerStatusList(customerLevel.getValue());
        ArrayList<CustomerStatusDetailDto> statesDtos = new ArrayList<CustomerStatusDetailDto>();
        for (CustomerStatusEntity customerStatusEntity : states) {
            CustomerStatusDetailDto customerStatusDetailDto = new CustomerStatusDetailDto(customerStatusEntity.getId().toString(), customerStatusEntity.getName(), null);
            statesDtos.add(customerStatusDetailDto);
        }
        customerStates.put(customerLevel.toString(), statesDtos);
    }
    return customerStates;
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity)

Example 4 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class ApplicationConfigurationDaoHibernate method findAllCustomerStatuses.

@SuppressWarnings("unchecked")
@Override
public List<CustomerStatusEntity> findAllCustomerStatuses() {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("LEVEL_ID", CustomerLevel.CLIENT.getValue());
    List<CustomerStatusEntity> queryResult = (List<CustomerStatusEntity>) this.genericDao.executeNamedQuery(NamedQueryConstants.GET_CUSTOMER_STATUS_LIST, queryParameters);
    for (CustomerStatusEntity customerStatus : queryResult) {
        for (CustomerStatusFlagEntity customerStatusFlagEntity : customerStatus.getFlagSet()) {
            Hibernate.initialize(customerStatusFlagEntity);
            Hibernate.initialize(customerStatusFlagEntity.getNames());
        }
        Hibernate.initialize(customerStatus.getLookUpValue());
    }
    return queryResult;
}
Also used : HashMap(java.util.HashMap) CustomerStatusFlagEntity(org.mifos.customers.business.CustomerStatusFlagEntity) ArrayList(java.util.ArrayList) List(java.util.List) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity)

Example 5 with CustomerStatusEntity

use of org.mifos.customers.business.CustomerStatusEntity in project head by mifos.

the class AccountStateMachines method retrieveNextPossibleCustomerStateForClient.

private List<CustomerStatusEntity> retrieveNextPossibleCustomerStateForClient(StateEntity customerStateEntityObj) throws ApplicationException {
    logger.debug("In AccountStateMachines::retrieveNextPossibleCustomerStateForClient()");
    List<CustomerStatusEntity> stateEntityList = new ArrayList<CustomerStatusEntity>();
    try {
        List<StateEntity> stateList = statesMapForClient.get(customerStateEntityObj);
        if (null != stateList) {
            for (StateEntity customerStateEntity : stateList) {
                for (CustomerStatusEntity customerStatusEntry : customerStatusListForClient) {
                    if (customerStatusEntry.sameId(customerStateEntity)) {
                        stateEntityList.add(customerStatusEntry);
                        break;
                    }
                }
            }
        }
        return stateEntityList;
    } catch (Exception e) {
        throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
    }
}
Also used : ArrayList(java.util.ArrayList) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) StateEntity(org.mifos.application.master.business.StateEntity)

Aggregations

CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)30 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 PersistenceException (org.mifos.framework.exceptions.PersistenceException)6 StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)6 CustomerLevelEntity (org.mifos.customers.business.CustomerLevelEntity)5 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)5 HashMap (java.util.HashMap)4 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 UserContext (org.mifos.security.util.UserContext)4 StateEntity (org.mifos.application.master.business.StateEntity)3 CustomerStatusFlagEntity (org.mifos.customers.business.CustomerStatusFlagEntity)3 CustomerCheckListBO (org.mifos.customers.checklist.business.CustomerCheckListBO)3 ClientBO (org.mifos.customers.client.business.ClientBO)3 CustomerException (org.mifos.customers.exceptions.CustomerException)3 OfficeBO (org.mifos.customers.office.business.OfficeBO)3 CustomerDao (org.mifos.customers.persistence.CustomerDao)3 ListElement (org.mifos.dto.screen.ListElement)3 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2