Search in sources :

Example 1 with LookupOptionsActionForm

use of org.mifos.config.struts.actionform.LookupOptionsActionForm in project head by mifos.

the class LookupOptionsAction method update.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("Inside update method");
    // setHiddenFields(request);
    LookupOptionsActionForm lookupOptionsActionForm = (LookupOptionsActionForm) form;
    LookupOptionData data = (LookupOptionData) SessionUtils.getAttribute(ConfigurationConstants.LOOKUP_OPTION_DATA, request);
    data.setLookupValue(lookupOptionsActionForm.getLookupValue());
    String entity = request.getParameter(ConfigurationConstants.ENTITY);
    if (data.getLookupId() > 0) {
        legacyMasterDao.updateValueListElementForLocale(data.getLookupId(), data.getLookupValue());
    } else {
        LookUpValueEntity newLookupValue = legacyMasterDao.addValueListElementForLocale(DynamicLookUpValueCreationTypes.LookUpOption, data.getValueListId(), data.getLookupValue());
        /*
             * Add a special case for payment types since we not only need to create a new
             * lookup value but also a new PaymentTypeEntity when adding an entry
             */
        if (entity.equals(ConfigurationConstants.CONFIG_PAYMENT_TYPE)) {
            PaymentTypeEntity newPaymentType = new PaymentTypeEntity(newLookupValue);
            legacyMasterDao.createOrUpdate(newPaymentType);
            StaticHibernateUtil.commitTransaction();
        }
    }
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) LookupOptionsActionForm(org.mifos.config.struts.actionform.LookupOptionsActionForm) LookupOptionData(org.mifos.config.util.helpers.LookupOptionData) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with LookupOptionsActionForm

use of org.mifos.config.struts.actionform.LookupOptionsActionForm in project head by mifos.

the class LookupOptionsAction method load.

@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("Inside load method");
    LookupOptionsActionForm lookupOptionsActionForm = (LookupOptionsActionForm) form;
    lookupOptionsActionForm.clear();
    setHiddenFields(request);
    Short localeId = getUserContext(request).getLocaleId();
    setSpecialLables(getUserContext(request), lookupOptionsActionForm);
    populateConfigurationListBox(MasterConstants.SALUTATION, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_SALUTATION);
    populateConfigurationListBox(MasterConstants.PERSONNEL_TITLE, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_PERSONNEL_TITLE);
    populateConfigurationListBox(MasterConstants.MARITAL_STATUS, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_MARITAL_STATUS);
    populateConfigurationListBox(MasterConstants.ETHNICITY, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_ETHNICITY);
    populateConfigurationListBox(MasterConstants.EDUCATION_LEVEL, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_EDUCATION_LEVEL);
    populateConfigurationListBox(MasterConstants.CITIZENSHIP, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_CITIZENSHIP);
    populateConfigurationListBox(MasterConstants.BUSINESS_ACTIVITIES, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_BUSINESS_ACTIVITY);
    populateConfigurationListBox(MasterConstants.LOAN_PURPOSES, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_LOAN_PURPOSE);
    populateConfigurationListBox(MasterConstants.COLLATERAL_TYPES, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_COLLATERAL_TYPE);
    populateConfigurationListBox(MasterConstants.HANDICAPPED, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_HANDICAPPED);
    populateConfigurationListBox(MasterConstants.OFFICER_TITLES, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_OFFICER_TITLE);
    populateConfigurationListBox(MasterConstants.PAYMENT_TYPE, legacyMasterDao, localeId, request, lookupOptionsActionForm, ConfigurationConstants.CONFIG_PAYMENT_TYPE);
    logger.debug("Outside load method");
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : LookupOptionsActionForm(org.mifos.config.struts.actionform.LookupOptionsActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with LookupOptionsActionForm

use of org.mifos.config.struts.actionform.LookupOptionsActionForm in project head by mifos.

the class LookupOptionsActionStrutsTest method testLoad.

@Test
public void testLoad() throws Exception {
    setRequestPathInfo("/lookupOptionsAction.do");
    addRequestParameter("method", "load");
    performNoErrors();
    verifyForward(ActionForwards.load_success.toString());
    LookupOptionsActionForm lookupOptionsActionForm = (LookupOptionsActionForm) request.getSession().getAttribute("lookupoptionsactionform");
    String[] EXPECTED_SALUTATIONS = { "Mr", "Mrs", "Ms" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getSalutations(), EXPECTED_SALUTATIONS, 3));
    String[] EXPECTED_PERSONNEL_TITLES = { "Cashier", "Center Manager", "Branch Manager" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getUserTitles(), EXPECTED_PERSONNEL_TITLES, 9));
    String[] EXPECTED_MARITAL_STATUS = { "Married", "UnMarried", "Widowed" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getMaritalStatuses(), EXPECTED_MARITAL_STATUS, 3));
    String[] EXPECTED_ETHNICITY = { "SC", "BC", "ST" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getEthnicities(), EXPECTED_ETHNICITY, 5));
    String[] EXPECTED_EDUCATION_LEVEL = { "Only Client", "Only Husband", "Both Literate" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getEducationLevels(), EXPECTED_EDUCATION_LEVEL, 4));
    String[] EXPECTED_CITIZENSHIP = { "Hindu", "Muslim", "Christian" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getCitizenships(), EXPECTED_CITIZENSHIP, 3));
    String[] EXPECTED_BUSINESS_ACTIVITIES = { "Daily Labour", "Agriculture", "Animal Husbandry", "Micro Enterprise", "Production", "Trading" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getBusinessActivities(), EXPECTED_BUSINESS_ACTIVITIES, 6));
    String[] EXPECTED_LOAN_PURPOSES = { "0000-Animal Husbandry", "0001-Cow Purchase", "0002-Buffalo Purchase" };
    // if the empty lookup name are not removed this will go up to 131
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getPurposesOfLoan(), EXPECTED_LOAN_PURPOSES, 131));
    String[] EXPECTED_COLLATERAL_TYPES = { "Type 1", "Type 2" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getCollateralTypes(), EXPECTED_COLLATERAL_TYPES, 2));
    String[] EXPECTED_HANDICAPPED = { "Yes", "No" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getHandicappeds(), EXPECTED_HANDICAPPED, 2));
    String[] EXPECTED_OFFICER_TITLES = { "President", "Vice President" };
    Assert.assertTrue(compareLists(lookupOptionsActionForm.getOfficerTitles(), EXPECTED_OFFICER_TITLES, 2));
}
Also used : LookupOptionsActionForm(org.mifos.config.struts.actionform.LookupOptionsActionForm) Test(org.junit.Test)

Example 4 with LookupOptionsActionForm

use of org.mifos.config.struts.actionform.LookupOptionsActionForm in project head by mifos.

the class LookupOptionsAction method addEditLookupOption.

@TransactionDemarcate(joinToken = true)
public ActionForward addEditLookupOption(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    LookupOptionsActionForm lookupOptionsActionForm = (LookupOptionsActionForm) form;
    String entity = request.getParameter(ConfigurationConstants.ENTITY);
    String addOrEdit = request.getParameter(ConfigurationConstants.ADD_OR_EDIT);
    LookupOptionData data = new LookupOptionData();
    boolean setLookupData = setLookupOptionData(entity, data, request, addOrEdit, lookupOptionsActionForm);
    if (setLookupData) {
        SessionUtils.setAttribute(ConfigurationConstants.LOOKUP_OPTION_DATA, data, request);
        return mapping.findForward(ActionForwards.addEditLookupOption_success.toString());
    }
    return mapping.findForward(ActionForwards.addEditLookupOption_failure.toString());
}
Also used : LookupOptionsActionForm(org.mifos.config.struts.actionform.LookupOptionsActionForm) LookupOptionData(org.mifos.config.util.helpers.LookupOptionData) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 5 with LookupOptionsActionForm

use of org.mifos.config.struts.actionform.LookupOptionsActionForm in project head by mifos.

the class LookupOptionsActionStrutsTest method prepareForUpdate.

private String prepareForUpdate(String masterConstant, String configurationConstant, String listName, String addOrEdit, LookupOptionData data, String nameString) throws SystemException, ApplicationException {
    CustomValueDto valueList = legacyMasterDao.getLookUpEntity(masterConstant);
    Short valueListId = valueList.getEntityId();
    CustomValueListElementDto valueListElement = valueList.getCustomValueListElements().get(0);
    CustomValueListElementDto valueListElement1 = valueList.getCustomValueListElements().get(1);
    data.setValueListId(valueListId);
    String originalName = "";
    if (addOrEdit.equals(ADD)) {
        data.setLookupId(0);
    } else {
        // edit
        data.setLookupId(valueListElement.getLookUpId());
        originalName = valueListElement.getLookUpValue();
    }
    LookupOptionsActionForm form = new LookupOptionsActionForm();
    // error
    if (nameString.equals(DUPLICATE) && valueListElement1 != null) {
        form.setLookupValue(valueListElement1.getLookUpValue());
    } else {
        form.setLookupValue(nameString);
    }
    form.setOneList(configurationConstant, valueList.getCustomValueListElements());
    setActionForm(form);
    return originalName;
}
Also used : LookupOptionsActionForm(org.mifos.config.struts.actionform.LookupOptionsActionForm) CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) CustomValueDto(org.mifos.application.master.business.CustomValueDto)

Aggregations

LookupOptionsActionForm (org.mifos.config.struts.actionform.LookupOptionsActionForm)5 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)3 LookupOptionData (org.mifos.config.util.helpers.LookupOptionData)2 Test (org.junit.Test)1 CustomValueDto (org.mifos.application.master.business.CustomValueDto)1 CustomValueListElementDto (org.mifos.application.master.business.CustomValueListElementDto)1 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)1 PaymentTypeEntity (org.mifos.application.master.business.PaymentTypeEntity)1