Search in sources :

Example 6 with CustomValueDto

use of org.mifos.application.master.business.CustomValueDto in project head by mifos.

the class LookupOptionsActionStrutsTest method setupAddOrEditForOneList.

private String setupAddOrEditForOneList(String masterConstant, String configurationConstant, String listName, String addOrEdit) throws SystemException, ApplicationException {
    CustomValueDto valueList = legacyMasterDao.getLookUpEntity(masterConstant);
    Short valueListId = valueList.getEntityId();
    CustomValueListElementDto valueListElement = valueList.getCustomValueListElements().get(0);
    addRequestParameter(ConfigurationConstants.ENTITY, configurationConstant);
    addRequestParameter(ConfigurationConstants.ADD_OR_EDIT, addOrEdit);
    SessionUtils.setAttribute(configurationConstant, valueListId, request);
    String originalName = "";
    if (addOrEdit.equals(ADD)) {
        CustomValueListElementDto newValueListElement = new CustomValueListElementDto();
        newValueListElement.setLookupValue(NEW_ELEMENT_NAME);
        String[] changesList = { MifosValueList.mapAddedCustomValueListElementToString(newValueListElement) };
        addRequestParameter(listName, changesList);
    } else {
        // edit
        originalName = valueListElement.getLookUpValue();
        valueListElement.setLookupValue(UPDATE_NAME);
        String[] changesList = { MifosValueList.mapUpdatedCustomValueListElementToString(valueListElement) };
        addRequestParameter(listName, changesList);
    }
    return originalName;
}
Also used : CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) CustomValueDto(org.mifos.application.master.business.CustomValueDto)

Example 7 with CustomValueDto

use of org.mifos.application.master.business.CustomValueDto in project head by mifos.

the class LegacyMasterDao method getLookUpEntity.

/**
     * Only two non-test usages, one that may never be called and one for getting labels.
     */
@Transactional
public CustomValueDto getLookUpEntity(final String entityName) throws SystemException {
    Session session = getSession();
    Query queryEntity = session.getNamedQuery("masterdata.entityvalue");
    queryEntity.setString("entityType", entityName);
    CustomValueDto entity = (CustomValueDto) queryEntity.uniqueResult();
    entity.setCustomValueListElements(lookUpValue(entityName, session));
    return entity;
}
Also used : Query(org.hibernate.Query) CustomValueDto(org.mifos.application.master.business.CustomValueDto) Session(org.hibernate.Session) Transactional(org.mifos.framework.hibernate.helper.Transactional)

Example 8 with CustomValueDto

use of org.mifos.application.master.business.CustomValueDto in project head by mifos.

the class LookupOptionsAction method populateConfigurationListBox.

private void populateConfigurationListBox(String configurationEntity, LegacyMasterDao legacyMasterDao, Short localeId, HttpServletRequest request, LookupOptionsActionForm lookupOptionsActionForm, String configurationEntityConst) throws Exception {
    CustomValueDto valueList = legacyMasterDao.getLookUpEntity(configurationEntity);
    Short valueListId = valueList.getEntityId();
    // save this value and will be retrieved when update the data to db
    SessionUtils.setAttribute(configurationEntityConst, valueListId, request);
    if (configurationEntity.equals(MasterConstants.SALUTATION)) {
        lookupOptionsActionForm.setSalutations(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.PERSONNEL_TITLE)) {
        lookupOptionsActionForm.setUserTitles(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.MARITAL_STATUS)) {
        lookupOptionsActionForm.setMaritalStatuses(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.ETHNICITY)) {
        lookupOptionsActionForm.setEthnicities(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.EDUCATION_LEVEL)) {
        lookupOptionsActionForm.setEducationLevels(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.CITIZENSHIP)) {
        lookupOptionsActionForm.setCitizenships(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.BUSINESS_ACTIVITIES)) {
        lookupOptionsActionForm.setBusinessActivities(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.LOAN_PURPOSES)) {
        lookupOptionsActionForm.setPurposesOfLoan(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.COLLATERAL_TYPES)) {
        lookupOptionsActionForm.setCollateralTypes(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.HANDICAPPED)) {
        lookupOptionsActionForm.setHandicappeds(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.OFFICER_TITLES)) {
        lookupOptionsActionForm.setOfficerTitles(valueList.getCustomValueListElements());
    } else if (configurationEntity.equals(MasterConstants.PAYMENT_TYPE)) {
        lookupOptionsActionForm.setPaymentTypes(valueList.getCustomValueListElements());
    } else {
        throw new Exception("Invalid configuration type in LookupOptionAction. Type is " + configurationEntity);
    }
}
Also used : CustomValueDto(org.mifos.application.master.business.CustomValueDto)

Example 9 with CustomValueDto

use of org.mifos.application.master.business.CustomValueDto in project head by mifos.

the class LegacyMasterDao method getCustomValueList.

/**
     * Used once in getMasterData, otherwise, test usage and one other method
     * MifosPropertyMessageResources.getCustomValueListElements (and that method may never be called)
     */
public CustomValueDto getCustomValueList(final String entityName, final String classPath, final String column) throws SystemException {
    Session session = null;
    session = getSession();
    Query queryEntity = session.getNamedQuery("masterdata.entityvalue");
    queryEntity.setString("entityType", entityName);
    CustomValueDto entity = (CustomValueDto) queryEntity.uniqueResult();
    List<CustomValueListElementDto> listElements = getCustomValueListElements(entityName, classPath, column, session);
    entity.setCustomValueListElements(listElements);
    return entity;
}
Also used : Query(org.hibernate.Query) CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) CustomValueDto(org.mifos.application.master.business.CustomValueDto) Session(org.hibernate.Session)

Example 10 with CustomValueDto

use of org.mifos.application.master.business.CustomValueDto in project head by mifos.

the class LookupOptionsActionStrutsTest method setupNoSelectionForOneList.

private void setupNoSelectionForOneList(String masterConstant, String configurationConstant, String listName) throws SystemException, ApplicationException {
    CustomValueDto valueList = legacyMasterDao.getLookUpEntity(masterConstant);
    Short valueListId = valueList.getEntityId();
    addRequestParameter(ConfigurationConstants.ENTITY, configurationConstant);
    addRequestParameter(ConfigurationConstants.ADD_OR_EDIT, EDIT);
    SessionUtils.setAttribute(configurationConstant, valueListId, request);
    addRequestParameter(listName, "");
}
Also used : CustomValueDto(org.mifos.application.master.business.CustomValueDto)

Aggregations

CustomValueDto (org.mifos.application.master.business.CustomValueDto)13 CustomValueListElementDto (org.mifos.application.master.business.CustomValueListElementDto)9 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 AccountException (org.mifos.accounts.exceptions.AccountException)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 HashSet (java.util.HashSet)2 Query (org.hibernate.Query)2 Session (org.hibernate.Session)2 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)2 AccountNotesEntity (org.mifos.accounts.business.AccountNotesEntity)2 AccountPenaltiesEntity (org.mifos.accounts.business.AccountPenaltiesEntity)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 LoanPerformanceHistoryEntity (org.mifos.accounts.loan.business.LoanPerformanceHistoryEntity)2 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)2 CustomerNoteDto (org.mifos.dto.domain.CustomerNoteDto)2 SurveyDto (org.mifos.dto.domain.SurveyDto)2 AccountFeesDto (org.mifos.dto.screen.AccountFeesDto)2 AccountPenaltiesDto (org.mifos.dto.screen.AccountPenaltiesDto)2 LoanInformationDto (org.mifos.dto.screen.LoanInformationDto)2