Search in sources :

Example 11 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class EditOfficeInformationController method populateForm.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView populateForm(HttpServletRequest request) {
    ModelAndView modelAndView = new ModelAndView();
    Short officeId = officeServiceFacade.retrieveOfficeById(Short.parseShort(request.getParameter("officeLevelId"))).getLevelId();
    OfficeDto officeDto = officeServiceFacade.retrieveOfficeById(Short.parseShort(request.getParameter("officeLevelId")));
    OfficeFormBean formBean = new OfficeFormBean();
    if (officeDto.getAddress() != null) {
        formBean.setCity(officeDto.getAddress().getCity());
        formBean.setCountry(officeDto.getAddress().getCountry());
        formBean.setLine1(officeDto.getAddress().getLine1());
        formBean.setLine2(officeDto.getAddress().getLine2());
        formBean.setLine3(officeDto.getAddress().getLine3());
        formBean.setZip(officeDto.getAddress().getZip());
        formBean.setPhoneNumber(officeDto.getAddress().getPhoneNumber());
        formBean.setState(officeDto.getAddress().getState());
    }
    if (officeDto.getCustomFields() != null) {
        formBean.setCustomFields(officeDto.getCustomFields());
    }
    formBean.setGlobalNum(officeDto.getGlobalNum());
    formBean.setId(officeDto.getId());
    formBean.setLevelId(officeDto.getLevelId().toString());
    formBean.setLookupNameKey(officeDto.getLookupNameKey());
    formBean.setName(officeDto.getName());
    formBean.setOfficeLevelName(officeDto.getOfficeLevelName());
    formBean.setOfficeShortName(officeDto.getOfficeShortName());
    formBean.setOfficeStatusName(officeDto.getOfficeStatusName());
    if (officeDto.getLevelId() != 1) {
        formBean.setParentId(officeDto.getParentId().toString());
        formBean.setParentOfficeName(officeDto.getParentOfficeName());
    }
    formBean.setSearchId(officeDto.getSearchId());
    formBean.setStatusId(officeDto.getStatusId().toString());
    formBean.setVersionNum(officeDto.getVersionNum());
    modelAndView.addObject("officeFormBean", formBean);
    modelAndView.addObject("parentOffices", getParentDetails(officeId.toString()));
    modelAndView.addObject("view", "disable");
    modelAndView.addObject("officeTypes", getOfficeTypes(officeDto.getLevelId().toString()));
    modelAndView.addObject("showError", "false");
    return modelAndView;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class SystemUserController method createUserFormBean.

public UserFormBean createUserFormBean(final Long officeId, final UserFormBean formBean) {
    OfficeDto selectedOffice = this.officeServiceFacade.retrieveOfficeById(officeId.shortValue());
    formBean.setOfficeId(officeId);
    formBean.setOfficeName(selectedOffice.getName());
    MandatoryHiddenFieldsDto dtoFields = this.adminServiceFacade.retrieveHiddenMandatoryFields();
    formBean.getAddress().setAddress1Mandatory(dtoFields.isMandatorySystemAddress1());
    formBean.getAddress().setAddress2Hidden(dtoFields.isHideSystemAddress2());
    formBean.getAddress().setAddress3Hidden(dtoFields.isHideSystemAddress3());
    formBean.getAddress().setCityDistrictHidden(dtoFields.isHideSystemCity());
    formBean.getAddress().setStateHidden(dtoFields.isHideSystemState());
    formBean.getAddress().setCountryHidden(dtoFields.isHideSystemCountry());
    formBean.getAddress().setPostalCodeHidden(dtoFields.isHideSystemPostalCode());
    DefinePersonnelDto userRefData = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId.shortValue());
    Map<String, String> genderOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getGenderList()) {
        genderOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setGenderOptions(genderOptions);
    Map<String, String> maritalStatusOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getMaritalStatusList()) {
        maritalStatusOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setMaritalStatusOptions(maritalStatusOptions);
    Map<String, String> preferredLanguageOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getLanguageList()) {
        preferredLanguageOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setPreferredLanguageOptions(preferredLanguageOptions);
    Map<String, String> userTitleOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getTitleList()) {
        userTitleOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setUserTitleOptions(userTitleOptions);
    Map<String, String> userHierarchyOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getPersonnelLevelList()) {
        userHierarchyOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setUserHierarchyOptions(userHierarchyOptions);
    Map<String, String> availableRolesOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getRolesList()) {
        availableRolesOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setAvailableRolesOptions(availableRolesOptions);
    formBean.setSelectedRolesOptions(new LinkedHashMap<String, String>());
    DateTime today = new DateTime();
    formBean.setMfiJoiningDateDay(today.getDayOfMonth());
    formBean.setMfiJoiningDateMonth(today.getMonthOfYear());
    formBean.setMfiJoiningDateYear(today.getYearOfEra());
    return formBean;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) ListElement(org.mifos.dto.screen.ListElement) MandatoryHiddenFieldsDto(org.mifos.dto.domain.MandatoryHiddenFieldsDto) DefinePersonnelDto(org.mifos.dto.screen.DefinePersonnelDto) DateTime(org.joda.time.DateTime) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class OfficeActionStrutsTest method testGet.

@Test
public void testGet() throws Exception {
    setRequestPathInfo("/offAction.do");
    addRequestParameter("method", Methods.get.toString());
    addRequestParameter("officeId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    OfficeDto office = (OfficeDto) SessionUtils.getAttribute("officeDto", request);
    Assert.assertNotNull(office);
    Assert.assertEquals(1, office.getId().intValue());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) Test(org.junit.Test)

Example 14 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class OffAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm actionForm = (OffActionForm) form;
    if (StringUtils.isBlank(actionForm.getOfficeId())) {
        throw new OfficeException(OfficeConstants.KEYGETFAILED);
    }
    OfficeDto officeDto = this.officeServiceFacade.retrieveOfficeById(Short.valueOf(actionForm.getOfficeId()));
    actionForm.clear();
    List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    actionForm.populate(officeDto);
    SessionUtils.setAttribute(OfficeConstants.OFFICE_DTO, officeDto, request);
    setCurrentPageUrl(request, officeDto);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : OfficeException(org.mifos.customers.office.exceptions.OfficeException) OfficeDto(org.mifos.dto.domain.OfficeDto) ArrayList(java.util.ArrayList) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 15 with OfficeDto

use of org.mifos.dto.domain.OfficeDto in project head by mifos.

the class OffAction method loadParent.

@TransactionDemarcate(joinToken = true)
public ActionForward loadParent(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm offActionForm = (OffActionForm) form;
    String officeLevel = request.getParameter("officeLevel");
    if (StringUtils.isNotBlank(officeLevel)) {
        offActionForm.setOfficeLevel(officeLevel);
        List<OfficeDetailsDto> parents = this.officeServiceFacade.retrieveActiveParentOffices(Short.valueOf(officeLevel));
        OfficeDto office = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
        if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit") && office != null) {
            for (int i = 0; i < parents.size(); i++) {
                OfficeDetailsDto view = parents.get(i);
                if (view.getOfficeId().equals(office.getOfficeId())) {
                    parents.remove(view);
                }
            }
        }
        SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, parents, request);
    }
    if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit")) {
        return mapping.findForward(ActionForwards.edit_success.toString());
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

OfficeDto (org.mifos.dto.domain.OfficeDto)27 ArrayList (java.util.ArrayList)14 OffActionForm (org.mifos.customers.office.struts.actionforms.OffActionForm)6 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)6 MifosUser (org.mifos.security.MifosUser)6 OfficeBO (org.mifos.customers.office.business.OfficeBO)5 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)5 HashMap (java.util.HashMap)3 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)3 OfficeHierarchyDto (org.mifos.dto.domain.OfficeHierarchyDto)3 ValueListElement (org.mifos.dto.domain.ValueListElement)3 ListElement (org.mifos.dto.screen.ListElement)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 LinkedHashMap (java.util.LinkedHashMap)2 Test (org.junit.Test)2 MessageLookup (org.mifos.application.master.MessageLookup)2 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)2