Files
myhealth/1.sources/MyHealth/src/managedbean/common/homeMBean.java
2019-12-09 21:20:46 +01:00

87 lines
1.7 KiB
Java

package managedbean.common;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import common.UserType;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named("home")
@RequestScoped
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<Theme> 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());
}
}