Search in sources :

Example 6 with StatesInitializationException

use of org.mifos.framework.exceptions.StatesInitializationException in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveAccountStatuses.

@Override
public AccountStatusDto retrieveAccountStatuses(Long savingsId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    SavingsBO savingsAccount = this.savingsDao.findById(savingsId);
    try {
        List<ListElement> savingsStatesList = new ArrayList<ListElement>();
        AccountStateMachines.getInstance().initializeSavingsStates();
        List<AccountStateEntity> statusList = AccountStateMachines.getInstance().getSavingsStatusList(savingsAccount.getAccountState());
        for (AccountStateEntity accountState : statusList) {
            savingsStatesList.add(new ListElement(accountState.getId().intValue(), accountState.getName()));
        }
        return new AccountStatusDto(savingsStatesList);
    } catch (StatesInitializationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AccountStatusDto(org.mifos.dto.domain.AccountStatusDto) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with StatesInitializationException

use of org.mifos.framework.exceptions.StatesInitializationException in project head by mifos.

the class AccountStateMachines method initializeCenterStates.

public void initializeCenterStates() throws StatesInitializationException {
    AccountTypes accountType = AccountTypes.CUSTOMER_ACCOUNT;
    CustomerLevel level = CustomerLevel.CENTER;
    String configName = getConfigurationName(accountType, level);
    try {
        statesMapForCenter = loadMap(CustomerConstants.TRANSITION_CONFIG_FILE_PATH_CENTER, configName);
        customerStatusListForCenter = retrieveAllCustomerStatusList(level);
        populateCenterStatesViewMap();
    } catch (Exception e) {
        throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
    }
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) AccountTypes(org.mifos.accounts.util.helpers.AccountTypes) ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) ApplicationException(org.mifos.framework.exceptions.ApplicationException)

Example 8 with StatesInitializationException

use of org.mifos.framework.exceptions.StatesInitializationException in project head by mifos.

the class AccountStateMachines method retrieveNextPossibleAccountStateObjectsForSavings.

private List<AccountStateEntity> retrieveNextPossibleAccountStateObjectsForSavings(StateEntity accountStateEntityObj) throws ApplicationException {
    logger.debug("In AccountStateMachines::retrieveNextPossibleAccountStateObjectsForSavings()");
    List<AccountStateEntity> stateEntityList = new ArrayList<AccountStateEntity>();
    try {
        List<StateEntity> stateList = statesMapForSavings.get(accountStateEntityObj);
        if (null != stateList) {
            for (StateEntity accountStateEntity : stateList) {
                for (AccountStateEntity accountStateEnty : accountStateEntityListForSavings) {
                    if (accountStateEntity.sameId(accountStateEnty)) {
                        stateEntityList.add(accountStateEnty);
                        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) 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 9 with StatesInitializationException

use of org.mifos.framework.exceptions.StatesInitializationException in project head by mifos.

the class AccountStateMachines method initializeGroupStates.

public void initializeGroupStates() throws StatesInitializationException {
    AccountTypes accountType = AccountTypes.CUSTOMER_ACCOUNT;
    CustomerLevel level = CustomerLevel.GROUP;
    String configName = getConfigurationName(accountType, level);
    try {
        statesMapForGroup = loadMap(CustomerConstants.TRANSITION_CONFIG_FILE_PATH_GROUP, configName);
        customerStatusListForGroup = retrieveAllCustomerStatusList(level);
        populateGroupStatesViewMap();
    } catch (Exception e) {
        throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
    }
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) AccountTypes(org.mifos.accounts.util.helpers.AccountTypes) ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) ApplicationException(org.mifos.framework.exceptions.ApplicationException)

Example 10 with StatesInitializationException

use of org.mifos.framework.exceptions.StatesInitializationException in project head by mifos.

the class LoanAccountServiceFacadeWebTier method retrieveAccountStatuses.

@Override
public AccountStatusDto retrieveAccountStatuses(Long loanAccountId) {
    LoanBO loanAccount = this.loanDao.findById(loanAccountId.intValue());
    try {
        List<ListElement> loanStatesList = new ArrayList<ListElement>();
        AccountStateMachines.getInstance().initializeLoanStates();
        List<AccountStateEntity> statusList = AccountStateMachines.getInstance().getLoanStatusList(loanAccount.getAccountState());
        for (AccountStateEntity accountState : statusList) {
            loanStatesList.add(new ListElement(accountState.getId().intValue(), accountState.getName()));
        }
        return new AccountStatusDto(loanStatesList);
    } catch (StatesInitializationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AccountStatusDto(org.mifos.dto.domain.AccountStatusDto) ChangeAccountStatusDto(org.mifos.dto.screen.ChangeAccountStatusDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

StatesInitializationException (org.mifos.framework.exceptions.StatesInitializationException)16 ApplicationException (org.mifos.framework.exceptions.ApplicationException)11 PersistenceException (org.mifos.framework.exceptions.PersistenceException)11 ServiceException (org.mifos.framework.exceptions.ServiceException)11 ArrayList (java.util.ArrayList)10 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)6 AccountTypes (org.mifos.accounts.util.helpers.AccountTypes)5 StateEntity (org.mifos.application.master.business.StateEntity)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 CustomerLevel (org.mifos.customers.api.CustomerLevel)5 ListElement (org.mifos.dto.screen.ListElement)5 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)2 AccountStatusDto (org.mifos.dto.domain.AccountStatusDto)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)1 CenterBO (org.mifos.customers.center.business.CenterBO)1 ClientBO (org.mifos.customers.client.business.ClientBO)1 GroupBO (org.mifos.customers.group.business.GroupBO)1 ValueListElement (org.mifos.dto.domain.ValueListElement)1 ChangeAccountStatusDto (org.mifos.dto.screen.ChangeAccountStatusDto)1