package managedbean.common; import java.io.Serializable; import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.inject.Named; import common.UserType; /*** * * @author Marcos García Núñez (mgarcianun@uoc.edu) * */ @Named("home") @RequestScoped public class homeMBean extends ManagedBeanBase implements Serializable { private static final long serialVersionUID = 1L; private boolean isLogedIn; private String userId; private String userName; private UserType userType; private int refresh; @PostConstruct public void init() { isLogedIn = SessionUtils.isLogedIn(); userName = SessionUtils.getUserName(); userId = SessionUtils.getUserId(); userType = SessionUtils.getUserType(); FacesMessage message = SessionUtils.getMessage(); if (message != null) { this.addFacesMessage(message, null); } } public List getThemes() { return ThemeService.THEMES; } public boolean isLogedIn() { return this.isLogedIn; } public String getUserName() { if (this.isLogedIn == false) return "Invitado"; else return this.userName; } public String getUserId() { return this.userId; } public String getUserType() { return this.userType.getUserTypename(); } public int getRefresh() { return refresh; } public void setRefresh(int refresh) { this.refresh = refresh; } public boolean isPatient() { return (this.userType == UserType.PATIENT); } public boolean isFamilyDoctor() { return (this.userType == UserType.FAMILY_DOCTOR); } public boolean isSpecialistDoctor() { return (this.userType == UserType.SPECIALIST_DOCTOR); } public boolean isAdministrator() { return (this.userType == UserType.ADMINISTRATOR); } public boolean isDoctor() { return (isFamilyDoctor() || isSpecialistDoctor()); } }