Search in sources :

Example 1 with UserSettingsDto

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());
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserSettingsDto(org.mifos.dto.screen.UserSettingsDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with UserSettingsDto

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());
}
Also used : UserSettingsDto(org.mifos.dto.screen.UserSettingsDto) PersonnelSettingsActionForm(org.mifos.customers.personnel.struts.actionforms.PersonnelSettingsActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with UserSettingsDto

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

Aggregations

UserSettingsDto (org.mifos.dto.screen.UserSettingsDto)3 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)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 SitePreferenceType (org.mifos.config.SitePreferenceType)1 PersonnelSettingsActionForm (org.mifos.customers.personnel.struts.actionforms.PersonnelSettingsActionForm)1 ValueListElement (org.mifos.dto.domain.ValueListElement)1 MifosUser (org.mifos.security.MifosUser)1 UserContext (org.mifos.security.util.UserContext)1