Search in sources :

Example 1 with SitePreferenceType

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);
}
Also used : SitePreferenceType(org.mifos.config.SitePreferenceType) BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) UserContext(org.mifos.security.util.UserContext) UserSettingsDto(org.mifos.dto.screen.UserSettingsDto) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) Date(java.sql.Date) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ValueListElement(org.mifos.dto.domain.ValueListElement)

Example 2 with SitePreferenceType

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);
}
Also used : SitePreferenceType(org.mifos.config.SitePreferenceType)

Aggregations

SitePreferenceType (org.mifos.config.SitePreferenceType)2 Date (java.sql.Date)1 ArrayList (java.util.ArrayList)1 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)1 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1 ValueListElement (org.mifos.dto.domain.ValueListElement)1 UserSettingsDto (org.mifos.dto.screen.UserSettingsDto)1 MifosUser (org.mifos.security.MifosUser)1 UserContext (org.mifos.security.util.UserContext)1