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;
}
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;
}
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());
}
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());
}
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());
}
Aggregations