use of org.mifos.dto.screen.UserSettingsDto in project head by mifos.
the class PersonnelSettingsAction method get.
@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
Short userId = getUserContext(request).getId();
PersonnelBO personnel = this.personnelDao.findPersonnelById(userId);
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, personnel, request);
UserSettingsDto userSettings = this.personnelServiceFacade.retrieveUserSettings();
SessionUtils.setAttribute(PersonnelConstants.GENDER, userSettings.getGender(), request);
SessionUtils.setAttribute(PersonnelConstants.MARITALSTATUS, userSettings.getMartialStatus(), request);
SessionUtils.setAttribute(MasterConstants.LANGUAGE, userSettings.getLanguage(), request);
SessionUtils.setAttribute(PersonnelConstants.SITE_TYPE_PREFERRED, userSettings.getSitePreference(), request);
SessionUtils.setCollectionAttribute(PersonnelConstants.GENDER_LIST, userSettings.getGenders(), request);
SessionUtils.setCollectionAttribute(PersonnelConstants.MARITAL_STATUS_LIST, userSettings.getMartialStatuses(), request);
SessionUtils.setCollectionAttribute(PersonnelConstants.LANGUAGE_LIST, userSettings.getLanguages(), request);
SessionUtils.setCollectionAttribute(PersonnelConstants.SITE_TYPES_LIST, userSettings.getSitePreferenceTypes(), request);
SessionUtils.removeAttribute(PersonnelConstants.PERSONNEL_AGE, request);
SessionUtils.setAttribute(PersonnelConstants.PERSONNEL_AGE, userSettings.getAge(), request);
return mapping.findForward(ActionForwards.get_success.toString());
}
use of org.mifos.dto.screen.UserSettingsDto in project head by mifos.
the class PersonnelSettingsAction method preview.
@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
PersonnelSettingsActionForm personnelactionForm = (PersonnelSettingsActionForm) form;
Integer prefeeredLocaleId = null;
if (personnelactionForm.getPreferredLocaleValue() != null) {
prefeeredLocaleId = personnelactionForm.getPreferredLocaleValue().intValue();
}
UserSettingsDto userSettings = this.personnelServiceFacade.retrieveUserSettings(personnelactionForm.getGenderValue(), personnelactionForm.getMaritalStatusValue(), prefeeredLocaleId, personnelactionForm.getPreferredSiteTypeId());
SessionUtils.setAttribute(PersonnelConstants.GENDER, userSettings.getGender(), request);
SessionUtils.setAttribute(PersonnelConstants.MARITALSTATUS, userSettings.getMartialStatus(), request);
SessionUtils.setAttribute(MasterConstants.LANGUAGE, userSettings.getLanguage(), request);
SessionUtils.setAttribute(PersonnelConstants.SITE_TYPE_PREFERRED, userSettings.getSitePreference(), request);
return mapping.findForward(ActionForwards.preview_success.toString());
}
use of org.mifos.dto.screen.UserSettingsDto in project head by mifos.
the class PersonnelServiceFacadeWebTier method retrieveUserSettings.
@Override
public UserSettingsDto retrieveUserSettings() {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
PersonnelBO personnel = this.personnelDao.findPersonnelById(userContext.getId());
String gender = getNameForBusinessActivityEntity(personnel.getPersonnelDetails().getGender());
String martialStatus = getNameForBusinessActivityEntity(personnel.getPersonnelDetails().getMaritalStatus());
String language = Localization.getInstance().getDisplayName(personnel.getPreferredLocale());
String sitePreference = SitePreferenceType.getSitePreference(personnel.getSitePreference()).name();
List<ValueListElement> genders = this.customerDao.retrieveGenders();
List<ValueListElement> martialStatuses = this.customerDao.retrieveMaritalStatuses();
List<ValueListElement> languages = Localization.getInstance().getLocaleForUI();
List<ValueListElement> sitePreferenceTypes = new ArrayList<ValueListElement>();
for (short i = 0; i < SitePreferenceType.values().length; i++) {
SitePreferenceType sitePreferenceType = SitePreferenceType.values()[i];
ValueListElement valueListElement = new BusinessActivityEntity(sitePreferenceType.getValue().intValue(), sitePreferenceType.name(), sitePreferenceType.name());
sitePreferenceTypes.add(valueListElement);
}
int age = DateUtils.DateDiffInYears(((Date) personnel.getPersonnelDetails().getDob()));
if (age < 0) {
age = 0;
}
return new UserSettingsDto(gender, martialStatus, language, age, sitePreference, genders, martialStatuses, languages, sitePreferenceTypes);
}
Aggregations