Mostrar tipo de usuario en la cabecera.

This commit is contained in:
Marcos Garcia Nuñez
2019-12-09 21:20:46 +01:00
parent 2c91f70a9b
commit d918526b28

View File

@@ -5,11 +5,10 @@ import java.util.List;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import common.UserType;
/*** /***
* *
* @author Marcos García Núñez (mgarcianun@uoc.edu) * @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 static final long serialVersionUID = 1L;
private boolean isLogedIn; private boolean isLogedIn;
private String userId;
private String userName;
private UserType userType;
private int refresh; private int refresh;
@PostConstruct @PostConstruct
public void init() { public void init() {
isLogedIn = SessionUtils.isLogedIn(); isLogedIn = SessionUtils.isLogedIn();
userName = SessionUtils.getUserName();
userId = SessionUtils.getUserId();
userType = SessionUtils.getUserType();
} }
public List<Theme> getThemes() { public List<Theme> getThemes() {
@@ -40,15 +45,15 @@ public class homeMBean implements Serializable {
if (this.isLogedIn == false) if (this.isLogedIn == false)
return "Invitado"; return "Invitado";
else else
return SessionUtils.getUserName(); return this.userName;
} }
public String getUserId() { public String getUserId() {
return SessionUtils.getUserId(); return this.userId;
} }
public String getUserType() { public String getUserType() {
return SessionUtils.getUserType().getUserTypename(); return this.userType.getUserTypename();
} }
public int getRefresh() { public int getRefresh() {
@@ -59,4 +64,23 @@ public class homeMBean implements Serializable {
this.refresh = 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());
}
} }