diff --git a/1.sources/MyHealth/src/managedbean/common/homeMBean.java b/1.sources/MyHealth/src/managedbean/common/homeMBean.java index 7ddc665..4d1dcdc 100644 --- a/1.sources/MyHealth/src/managedbean/common/homeMBean.java +++ b/1.sources/MyHealth/src/managedbean/common/homeMBean.java @@ -5,11 +5,10 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; -import javax.faces.application.FacesMessage; -import javax.faces.context.FacesContext; -import javax.inject.Inject; import javax.inject.Named; +import common.UserType; + /*** * * @author Marcos García Núñez (mgarcianun@uoc.edu) @@ -21,11 +20,17 @@ public class homeMBean 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(); } public List getThemes() { @@ -40,15 +45,15 @@ public class homeMBean implements Serializable { if (this.isLogedIn == false) return "Invitado"; else - return SessionUtils.getUserName(); + return this.userName; } public String getUserId() { - return SessionUtils.getUserId(); + return this.userId; } public String getUserType() { - return SessionUtils.getUserType().getUserTypename(); + return this.userType.getUserTypename(); } public int getRefresh() { @@ -59,4 +64,23 @@ public class homeMBean implements Serializable { 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()); + } }