Search in sources :

Example 16 with CustomerStatusEntity

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

the class CustomerPersistence method retrieveAllCustomerStatusList.

public List<CustomerStatusEntity> retrieveAllCustomerStatusList(final Short levelId) throws PersistenceException {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("LEVEL_ID", levelId);
    List<CustomerStatusEntity> queryResult = 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) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity)

Example 17 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 18 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 19 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)

Example 20 with CustomerStatusEntity

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

the class ClientBO method transferToBranch.

public void transferToBranch(final OfficeBO officeToTransfer) throws CustomerException {
    validateBranchTransfer(officeToTransfer);
    logger.debug("In ClientBO::transferToBranch(), transfering customerId: " + getCustomerId() + "to branch : " + officeToTransfer.getOfficeId());
    if (isActive()) {
        setCustomerStatus(new CustomerStatusEntity(CustomerStatus.CLIENT_HOLD));
    }
    makeCustomerMovementEntries(officeToTransfer);
    this.setPersonnel(null);
    logger.debug("In ClientBO::transferToBranch(), successfully transfered, customerId :" + getCustomerId());
}
Also used : 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