Search in sources :

Example 11 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 12 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 13 with CustomerStatusEntity

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

the class AccountStateMachines method retrieveNextPossibleCustomerStateForCenter.

private List<CustomerStatusEntity> retrieveNextPossibleCustomerStateForCenter(StateEntity customerStateEntityObj) throws ApplicationException {
    logger.debug("In AccountStateMachines::retrieveNextPossibleCustomerStateForCenter()");
    List<CustomerStatusEntity> stateEntityList = new ArrayList<CustomerStatusEntity>();
    try {
        List<StateEntity> stateList = statesMapForCenter.get(customerStateEntityObj);
        if (null != stateList) {
            for (StateEntity customerStateEntity : stateList) {
                for (CustomerStatusEntity customerStatusEntry : customerStatusListForCenter) {
                    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)

Example 14 with CustomerStatusEntity

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

the class CustomerServiceImpl method transferGroupTo.

@Override
public final String transferGroupTo(GroupBO group, OfficeBO transferToOffice) throws CustomerException {
    group.validateNewOffice(transferToOffice);
    group.validateNoActiveAccountsExist();
    customerDao.validateGroupNameIsNotTakenForOffice(group.getDisplayName(), transferToOffice.getOfficeId());
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(group);
        group.makeCustomerMovementEntries(transferToOffice);
        group.setPersonnel(null);
        if (group.isActive()) {
            group.setCustomerStatus(new CustomerStatusEntity(CustomerStatus.GROUP_HOLD));
        }
        CustomerBO oldParentOfGroup = group.getParentCustomer();
        if (oldParentOfGroup != null) {
            oldParentOfGroup.incrementChildCount();
            customerDao.save(oldParentOfGroup);
        }
        this.hibernateTransactionHelper.flushSession();
        group.generateSearchId();
        group.setUpdateDetails();
        customerDao.save(group);
        Set<CustomerBO> clients = group.getChildren();
        if (clients != null) {
            for (CustomerBO client : clients) {
                client.setUserContext(group.getUserContext());
                ((ClientBO) client).handleGroupTransfer();
                client.setUpdateDetails();
                customerDao.save(client);
            }
        }
        hibernateTransactionHelper.commitTransaction();
        return group.getGlobalCustNum();
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 15 with CustomerStatusEntity

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

the class CheckListPersistence method retrieveAllCustomerStatusList.

@SuppressWarnings("unchecked")
public List<CheckListStatesView> retrieveAllCustomerStatusList(Short levelId, Short localeId) throws PersistenceException {
    List<CheckListStatesView> checkListStatesView = new ArrayList<CheckListStatesView>();
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("LEVEL_ID", levelId);
    List<CustomerStatusEntity> queryResult = executeNamedQuery(NamedQueryConstants.CHECKLIST_GET_VALID_CUSTOMER_STATES, queryParameters);
    for (CustomerStatusEntity customerStatus : queryResult) {
        checkListStatesView.add(new CheckListStatesView(customerStatus.getId(), customerStatus.getName(), customerStatus.getCustomerLevel().getId()));
    }
    return checkListStatesView;
}
Also used : CheckListStatesView(org.mifos.dto.screen.CheckListStatesView) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity)

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