use of org.mifos.config.SitePreferenceType 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);
}
use of org.mifos.config.SitePreferenceType in project head by mifos.
the class SitePreferenceHelper method setSitePreferenceCookie.
public void setSitePreferenceCookie(Integer userId, HttpServletResponse response) {
SitePreferenceType sitePreferenceType = personnelServiceFacade.retrieveSitePreference(userId);
setSitePreferenceCookie(sitePreferenceType, response);
}
Aggregations