Merge branch 'master' of
http://pdp-pds.eimt.uoc.edu/pds19-grupo2/myhealth.git Conflicts: 1.sources/MyHealth/src/jpa/VisitJPA.java
This commit is contained in:
67
1.sources/MyHealth/src/TO/LoggedUserTO.java
Normal file
67
1.sources/MyHealth/src/TO/LoggedUserTO.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package TO;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import common.UserType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "LoggedUser")
|
||||
public class LoggedUserTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
private String password;
|
||||
private String name;
|
||||
private UserType userType;
|
||||
|
||||
public LoggedUserTO() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LoggedUserTO(String usrId, String usrName, String usrPwd, UserType usrType) {
|
||||
id = usrId;
|
||||
name = usrName;
|
||||
password = usrPwd;
|
||||
userType = usrType;
|
||||
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public UserType getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(UserType userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,4 +41,10 @@ public class MedicalSpecialtyTO implements Serializable {
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s[name=%s]", getClass().getSimpleName(), getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,16 +15,16 @@ public class PrimaryHealthCareCenterTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String location;
|
||||
|
||||
|
||||
public PrimaryHealthCareCenterTO() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterTO(String name, String description) {
|
||||
public PrimaryHealthCareCenterTO(String name, String location) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -35,12 +35,16 @@ public class PrimaryHealthCareCenterTO implements Serializable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
public void setLocation(String description) {
|
||||
this.location = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s[name=%s]", getClass().getSimpleName(), getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
24
1.sources/MyHealth/src/common/HashUtils.java
Normal file
24
1.sources/MyHealth/src/common/HashUtils.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package common;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
public class HashUtils {
|
||||
|
||||
public static String hashMD5(String stringValue) {
|
||||
byte[] digest = null;
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(stringValue.getBytes());
|
||||
digest = md.digest();
|
||||
} catch (Exception ex) {
|
||||
// TODO: Register exception to log.
|
||||
}
|
||||
|
||||
return (DatatypeConverter.printHexBinary(digest).toUpperCase());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package managedbean.common;
|
||||
package common;
|
||||
|
||||
public enum UserType {
|
||||
PATIENT("Paciente"),
|
||||
@@ -15,4 +15,8 @@ public enum UserType {
|
||||
public String getUserTypename() {
|
||||
return userTypename;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import TO.MedicalSpecialtyTO;
|
||||
import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.HashUtils;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
import jpa.PatientJPA;
|
||||
@@ -44,8 +45,11 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
|
||||
public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email) {
|
||||
PatientTO paTO = null;
|
||||
|
||||
if (id == null)
|
||||
id = 1;
|
||||
|
||||
PatientJPA ms = new PatientJPA(id, nif, name, surname, password, email);
|
||||
PatientJPA ms = new PatientJPA(nif, name, surname, HashUtils.hashMD5(password), email);
|
||||
entman.persist(ms);
|
||||
paTO = new PatientTO(ms.getId(), ms.getNif(), ms.getName(), ms.getSurname(), ms.getPassword(), ms.getEmail());
|
||||
|
||||
@@ -59,25 +63,24 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
|
||||
// TODO: Lanzar error si no se encuentra la especialidad.
|
||||
if (ms != null) {
|
||||
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(id, nif, name, surname, password, email);
|
||||
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, ms);
|
||||
entman.persist(sd);
|
||||
|
||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail());
|
||||
}
|
||||
|
||||
return sdTO;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, String cap) {
|
||||
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap) {
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap);
|
||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap.getName());
|
||||
|
||||
// TODO: Lanzar error si no encontramos el cap!!!!!
|
||||
if (phcC != null) {
|
||||
|
||||
FamilyDoctorJPA fd = new FamilyDoctorJPA(id, nif, name, surname, password, email);
|
||||
fd.setPrimaryHealthCareCenter(phcC);
|
||||
|
||||
FamilyDoctorJPA fd = new FamilyDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, phcC);
|
||||
entman.persist(fd);
|
||||
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail());
|
||||
@@ -94,7 +97,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
fd.setNif(nif);
|
||||
fd.setName(name);
|
||||
fd.setSurname(surname);
|
||||
fd.setPassword(password);
|
||||
fd.setPassword(HashUtils.hashMD5(password));
|
||||
fd.setEmail(email);
|
||||
|
||||
entman.persist(fd);
|
||||
@@ -117,7 +120,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
sd.setNif(nif);
|
||||
sd.setName(name);
|
||||
sd.setSurname(surname);
|
||||
sd.setPassword(password);
|
||||
sd.setPassword(HashUtils.hashMD5(password));
|
||||
sd.setEmail(email);
|
||||
sd.setMedicalSpecialty(ms);
|
||||
|
||||
@@ -137,7 +140,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
fd.setNif(nif);
|
||||
fd.setName(name);
|
||||
fd.setSurname(surname);
|
||||
fd.setPassword(password);
|
||||
fd.setPassword(HashUtils.hashMD5(password));
|
||||
fd.setEmail(email);
|
||||
|
||||
// TODO: Es posible actualizar el cap? ¿No debería utilizar el método
|
||||
|
||||
@@ -20,15 +20,13 @@ public interface ProfileFacadeRemote {
|
||||
|
||||
public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email);
|
||||
|
||||
public SpecialistDoctorTO registerSpecialistDoctor(Integer id, String nif, String name, String surname, String password, String email,
|
||||
MedicalSpecialtyTO specialty);
|
||||
public SpecialistDoctorTO registerSpecialistDoctor(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty);
|
||||
|
||||
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, String cap);
|
||||
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap);
|
||||
|
||||
public PatientTO updatePacientData(Integer id, String nif, String name, String surname, String password, String email);
|
||||
|
||||
public SpecialistDoctorTO updateSpecialistDoctorData(Integer id, String nif, String name, String surname, String password, String email,
|
||||
MedicalSpecialtyTO specialty);
|
||||
public SpecialistDoctorTO updateSpecialistDoctorData(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty);
|
||||
|
||||
public FamilyDoctorTO updateFamilyDoctorData(Integer id, String nif, String name, String surname, String password, String email, String cap);
|
||||
|
||||
|
||||
@@ -8,15 +8,21 @@ import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import TO.LoggedUserTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import common.HashUtils;
|
||||
import common.UserType;
|
||||
import jpa.AdministratorJPA;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
import jpa.PatientJPA;
|
||||
import jpa.PrimaryHealthCareCenterJPA;
|
||||
import jpa.SpecialistDoctorJPA;
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
* métodos de la capa de negocio que implementan la logica de negocio y la
|
||||
* interacción con la capa de persistencia.
|
||||
*
|
||||
* @author mark
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Stateless
|
||||
@@ -59,4 +65,76 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return allSpecialities;
|
||||
}
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listAllCAPs() {
|
||||
return this.listPagedAllCAPs(0, 0);
|
||||
}
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize) {
|
||||
Query query = entman.createQuery("from PrimaryHealthCareCenterJPA order by name");
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
|
||||
Collection<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
|
||||
|
||||
for (PrimaryHealthCareCenterJPA cap : allJPA) {
|
||||
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation()));
|
||||
}
|
||||
|
||||
return allCAPs;
|
||||
}
|
||||
|
||||
public LoggedUserTO login(String id, String pwd) {
|
||||
LoggedUserTO usr = null;
|
||||
|
||||
// First try to login as Admin
|
||||
AdministratorJPA adm = entman.find(AdministratorJPA.class, id);
|
||||
if (adm != null) {
|
||||
usr = new LoggedUserTO(adm.getEmail(), adm.getEmail(), adm.getPassword(), UserType.ADMINISTRADOR);
|
||||
} else {
|
||||
try {
|
||||
int iId = Integer.parseInt(id);
|
||||
|
||||
// Try to login Patient, FamilyDoctor or SpecialistDoctor
|
||||
// TODO: Si Patient, FamilyDoctor o Specialist Doctor tienen el mismo id, solo
|
||||
// el paciente se puede logear. ¿Deberíamos cambiar esto permitiendo seleccionar
|
||||
// el perfil a logearse?
|
||||
PatientJPA pat = entman.find(PatientJPA.class, iId);
|
||||
|
||||
if (pat != null) {
|
||||
usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT);
|
||||
} else {
|
||||
FamilyDoctorJPA fdoc = entman.find(FamilyDoctorJPA.class, iId);
|
||||
|
||||
if (fdoc != null) {
|
||||
usr = new LoggedUserTO(String.valueOf(fdoc.getId()), fdoc.getName(), fdoc.getPassword(), UserType.FAMILY_DOCTOR);
|
||||
} else {
|
||||
SpecialistDoctorJPA sdoc = entman.find(SpecialistDoctorJPA.class, iId);
|
||||
|
||||
if (sdoc != null) {
|
||||
usr = new LoggedUserTO(String.valueOf(sdoc.getId()), sdoc.getName(), sdoc.getPassword(), UserType.SPECIALIST_DOCTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException nf) {
|
||||
// id is not an intenger, so, login fails
|
||||
usr = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (usr != null) {
|
||||
// Comprobamos el password
|
||||
if (usr.getPassword().equals(HashUtils.hashMD5(pwd)) == false) {
|
||||
// Bad Password, devolvemos null!
|
||||
usr = null;
|
||||
}
|
||||
}
|
||||
|
||||
return usr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ import java.util.Collection;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import TO.LoggedUserTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
* los clientes del EJB
|
||||
*
|
||||
* @author mark
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Remote
|
||||
@@ -19,4 +19,8 @@ public interface SystemAdminFacadeRemote {
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
|
||||
|
||||
public LoggedUserTO login(String id, String pwd);
|
||||
}
|
||||
52
1.sources/MyHealth/src/jpa/AdministratorJPA.java
Normal file
52
1.sources/MyHealth/src/jpa/AdministratorJPA.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "MyHealth.Administrator")
|
||||
public class AdministratorJPA implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private String email;
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Class constructor methods
|
||||
*/
|
||||
public AdministratorJPA() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AdministratorJPA(String email, String password) {
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class FamilyDoctorJPA implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
private int id;
|
||||
private String nif;
|
||||
private String name;
|
||||
private String surname;
|
||||
@@ -42,22 +42,22 @@ public class FamilyDoctorJPA implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public FamilyDoctorJPA(Integer id, String nif, String name, String surname, String password, String email) {
|
||||
this.id = id;
|
||||
public FamilyDoctorJPA(String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterJPA phc) {
|
||||
this.nif = nif;
|
||||
this.name = name;
|
||||
this.surname = surname;
|
||||
this.password = password;
|
||||
this.email = email;
|
||||
this.primaryHealthCareCenter = phc;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
public Integer getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer value) {
|
||||
public void setId(int value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
@@ -123,6 +123,4 @@ public class FamilyDoctorJPA implements Serializable {
|
||||
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) {
|
||||
this.primaryHealthCareCenter = center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class PatientJPA implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
private int id;
|
||||
private String nif;
|
||||
private String name;
|
||||
private String surname;
|
||||
@@ -40,8 +40,7 @@ public class PatientJPA implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public PatientJPA(Integer id, String nif, String name, String surname, String password, String email) {
|
||||
this.id = id;
|
||||
public PatientJPA(String nif, String name, String surname, String password, String email) {
|
||||
this.nif = nif;
|
||||
this.name = name;
|
||||
this.surname = surname;
|
||||
@@ -49,11 +48,11 @@ public class PatientJPA implements Serializable {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer value) {
|
||||
public void setId(int value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
|
||||
|
||||
@Id
|
||||
private String name;
|
||||
private String description;
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* Class constructor methods
|
||||
@@ -28,9 +28,9 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterJPA(String name, String description) {
|
||||
public PrimaryHealthCareCenterJPA(String name, String location) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -41,11 +41,11 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
public void setLocation(String description) {
|
||||
this.location = description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SpecialistDoctorJPA implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
private int id;
|
||||
private String nif;
|
||||
private String name;
|
||||
private String surname;
|
||||
@@ -37,22 +37,22 @@ public class SpecialistDoctorJPA implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public SpecialistDoctorJPA(Integer id, String nif, String name, String surname, String password, String email) {
|
||||
this.id = id;
|
||||
public SpecialistDoctorJPA(String nif, String name, String surname, String password, String email, MedicalSpecialtyJPA ms) {
|
||||
this.nif = nif;
|
||||
this.name = name;
|
||||
this.surname = surname;
|
||||
this.password = password;
|
||||
this.email = email;
|
||||
this.medicalSpecialty = ms;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
public Integer getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer value) {
|
||||
public void setId(int value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class SpecialistDoctorJPA implements Serializable {
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "MedicalSpecialtyName")
|
||||
@JoinColumn(name = "MedicalSpecialtyId")
|
||||
public MedicalSpecialtyJPA getMedicalSpecialty() {
|
||||
return medicalSpecialty;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
package jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -103,3 +104,85 @@ public class VisitJPA implements Serializable {
|
||||
this.patient=pat;
|
||||
}
|
||||
}
|
||||
=======
|
||||
package jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Time;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "MyHealth.Visit")
|
||||
public class VisitJPA implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
private Date date;
|
||||
private Time time;
|
||||
private String observations;
|
||||
private String result;
|
||||
|
||||
/**
|
||||
* Class constructor methods
|
||||
*/
|
||||
public VisitJPA() {
|
||||
super();
|
||||
}
|
||||
|
||||
public VisitJPA(Integer id, Date date, Time time, String observations, String result) {
|
||||
this.id = id;
|
||||
this.date=date;
|
||||
this.time = time;
|
||||
this.observations = observations;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer value) {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date value) {
|
||||
this.date = value;
|
||||
}
|
||||
|
||||
public Time getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Time value) {
|
||||
this.time = value;
|
||||
}
|
||||
|
||||
public String getObservations() {
|
||||
return observations;
|
||||
}
|
||||
|
||||
public void setObservations(String observation) {
|
||||
this.observations = observations;
|
||||
}
|
||||
|
||||
}
|
||||
>>>>>>> branch 'master' of http://pdp-pds.eimt.uoc.edu/pds19-grupo2/myhealth.git
|
||||
|
||||
@@ -26,20 +26,19 @@ public class AuthorizationFilter implements Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
try {
|
||||
|
||||
HttpServletRequest reqt = (HttpServletRequest) request;
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse resp = (HttpServletResponse) response;
|
||||
HttpSession ses = reqt.getSession(false);
|
||||
HttpSession ses = req.getSession(false);
|
||||
|
||||
String reqURI = reqt.getRequestURI();
|
||||
if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/RegisterUser.xhtml") >= 0 || (ses != null && ses.getAttribute("username") != null)
|
||||
|| reqURI.indexOf("/public/") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.contains("javax.faces.resource"))
|
||||
String reqURI = req.getRequestURI();
|
||||
if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/RegisterUser.xhtml") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.indexOf("/public/") >= 0
|
||||
|| reqURI.contains("javax.faces.resource") || SessionUtils.isLogedIn(ses) == true)
|
||||
chain.doFilter(request, response);
|
||||
else
|
||||
resp.sendRedirect(reqt.getContextPath() + "/login.xhtml");
|
||||
resp.sendRedirect(req.getContextPath() + "/login.xhtml");
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
103
1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java
Normal file
103
1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package managedbean.common;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import ejb.medicalTest.MedicalTestFacadeRemote;
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||
import ejb.visit.VisitFacadeRemote;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
public class ManagedBeanBase {
|
||||
@EJB
|
||||
protected ProfileFacadeRemote remoteManagerProfile;
|
||||
@EJB
|
||||
protected SystemAdminFacadeRemote remoteManagerSystemAdmin;
|
||||
@EJB
|
||||
protected VisitFacadeRemote remoteManagerVisit;
|
||||
@EJB
|
||||
protected MedicalTestFacadeRemote remoteManagerMedicalTest;
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private <T> T getContext(String name, Class<T> type) {
|
||||
T retObj = null;
|
||||
|
||||
try {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
retObj = type.cast(ctx.lookup(name));
|
||||
} catch (NamingException e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
return retObj;
|
||||
}
|
||||
|
||||
protected ProfileFacadeRemote getRemoteManagerProfile() {
|
||||
if (remoteManagerProfile == null) {
|
||||
remoteManagerProfile = this.getContext("java:app/MyHealth.jar/ProfileFacadeBean!ejb.profile.ProfileFacadeRemote", ProfileFacadeRemote.class);
|
||||
}
|
||||
|
||||
return remoteManagerProfile;
|
||||
}
|
||||
|
||||
protected SystemAdminFacadeRemote getRemoteManagerSystemAdmin() {
|
||||
if (remoteManagerSystemAdmin == null) {
|
||||
remoteManagerSystemAdmin = this.getContext("java:app/MyHealth.jar/SystemAdminFacadeBean!ejb.systemAdmin.SystemAdminFacadeRemote", SystemAdminFacadeRemote.class);
|
||||
}
|
||||
|
||||
return remoteManagerSystemAdmin;
|
||||
}
|
||||
|
||||
protected VisitFacadeRemote getRemoteManagerVisit() {
|
||||
if (remoteManagerVisit == null) {
|
||||
remoteManagerVisit = this.getContext("java:app/MyHealth.jar/VisitFacadeBean!ejb.systemAdmin.VisitFacadeRemote", VisitFacadeRemote.class);
|
||||
}
|
||||
|
||||
return remoteManagerVisit;
|
||||
}
|
||||
|
||||
protected MedicalTestFacadeRemote getRemoteManagerMedicalTest() {
|
||||
if (remoteManagerMedicalTest == null) {
|
||||
remoteManagerMedicalTest = this.getContext("java:app/MyHealth.jar/MedicalTestFacadeBean!ejb.systemAdmin.MedicalTestFacadeRemote", MedicalTestFacadeRemote.class);
|
||||
}
|
||||
|
||||
return remoteManagerMedicalTest;
|
||||
}
|
||||
|
||||
protected void addFacesMessageKeep(FacesMessage.Severity severity, String summary, String detail) {
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
|
||||
this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail);
|
||||
|
||||
context.getExternalContext().getFlash().setKeepMessages(true);
|
||||
}
|
||||
|
||||
protected void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
|
||||
this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail);
|
||||
}
|
||||
|
||||
protected void addFacesMessage(FacesContext context, FacesMessage.Severity severity, String summary, String detail) {
|
||||
context.addMessage(null, new FacesMessage(severity, summary, detail));
|
||||
}
|
||||
|
||||
protected void manageException(Exception ex) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Se ha producido un error inesperado", "Descripción del error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package managedbean.common;
|
||||
|
||||
import java.awt.MenuItem;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -10,49 +11,115 @@ import javax.inject.Named;
|
||||
|
||||
import org.primefaces.model.menu.DefaultMenuItem;
|
||||
import org.primefaces.model.menu.DefaultMenuModel;
|
||||
import org.primefaces.model.menu.DefaultSeparator;
|
||||
import org.primefaces.model.menu.DefaultSubMenu;
|
||||
import org.primefaces.model.menu.MenuModel;
|
||||
import org.primefaces.model.menu.Submenu;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named("menuView")
|
||||
@RequestScoped
|
||||
public class MenuMBean implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private MenuModel model;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
model = new DefaultMenuModel();
|
||||
DefaultMenuItem item;
|
||||
DefaultSubMenu subMenu;
|
||||
|
||||
// First submenu
|
||||
DefaultSubMenu firstSubmenu = new DefaultSubMenu("Dynamic submenu");
|
||||
DefaultMenuItem item = new DefaultMenuItem("External", "", "www.google.com");
|
||||
// item.setUrl("www.google.com");
|
||||
firstSubmenu.getElements().add(item);
|
||||
model.addElement(createMenuItem("Home", "pi pi-home", "/home", null));
|
||||
|
||||
model.getElements().add(firstSubmenu);
|
||||
if (SessionUtils.isLogedIn() == true) {
|
||||
|
||||
// Second submenu
|
||||
DefaultSubMenu secondSubmenu = new DefaultSubMenu("Dynamic Actions");
|
||||
// Administracion Sistema
|
||||
// TODO: mostrar este menú solo si el usuario es administrador
|
||||
if (1 == 1) {
|
||||
subMenu = new DefaultSubMenu("Administración del sistema", "pi pi-cog");
|
||||
subMenu.addElement(createMenuItem("Esp. médicas", "pi pi-calendar", "/systemAdmin/ManageSpecialties", null));
|
||||
subMenu.addElement(createMenuItem("Centros At. Primaria", "pi pi-briefcase", "/systemAdmin/ManageSpecialties", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
subMenu.addElement(createMenuItem("Añadir usuario Admin", "pi pi-calendar", "/systemAdmin/ManageSpecialties", null));
|
||||
model.addElement(subMenu);
|
||||
}
|
||||
|
||||
item = new DefaultMenuItem("Save", "pi pi-save");
|
||||
item.setCommand("#{menuView.save}");
|
||||
item.setUpdate("messages");
|
||||
secondSubmenu.getElements().add(item);
|
||||
// Visitas
|
||||
// TODO: mostrar este menú solo si el usuario es paciente
|
||||
if (1 == 1) {
|
||||
subMenu = new DefaultSubMenu("Visitas", "pi pi-calendar");
|
||||
subMenu.addElement(createMenuItem("Agendar", "pi pi-calendar", "/visit/VisitView", null));
|
||||
subMenu.addElement(createMenuItem("Consultar", "pi pi-briefcase", "/visit/VisitView", null));
|
||||
model.addElement(subMenu);
|
||||
}
|
||||
|
||||
item = new DefaultMenuItem("Delete", "pi pi-times");
|
||||
item.setCommand("#{menuView.delete}");
|
||||
item.setAjax(false);
|
||||
secondSubmenu.getElements().add(item);
|
||||
// Pruebas médicas
|
||||
// TODO: mostrar este menú solo si el usuario es medico // etc...
|
||||
if (1 == 1) {
|
||||
|
||||
item = new DefaultMenuItem("Redirect", "pi pi-search");
|
||||
item.setCommand("#{menuView.redirect}");
|
||||
secondSubmenu.getElements().add(item);
|
||||
subMenu = new DefaultSubMenu("Pruebas Medicas", "pi pi-clone");
|
||||
subMenu.addElement(createMenuItem("Añadir", "pi pi-clone", "/medicaltest/MedicalTests", null));
|
||||
subMenu.addElement(createMenuItem("Gestionar", "pi pi-briefcase", "/medicaltest/MedicalTests", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
subMenu.addElement(createMenuItem("Consultar médicos pro esp.", "pi pi-search", "/medicaltest/MedicalTests", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
subMenu.addElement(createMenuItem("Listar médicos", "pi pi-list", "/medicaltest/MedicalTests", null));
|
||||
model.addElement(subMenu);
|
||||
}
|
||||
|
||||
model.getElements().add(secondSubmenu);
|
||||
// Preguntas
|
||||
// TODO: mostrar este menú solo si el usuario es paciente o medico
|
||||
if (1 == 1) {
|
||||
subMenu = new DefaultSubMenu("Preguntas", "pi pi-clone");
|
||||
// TODO: Si es paciente puede preguntar
|
||||
if (true == true)
|
||||
subMenu.addElement(createMenuItem("Añadir pregunta", "pi pi-clone", "/medicaltest/MedicalTests", null));
|
||||
// TODO: Si es medico de familia puede responder
|
||||
if (true == true)
|
||||
subMenu.addElement(createMenuItem("Responder pregunta", "pi pi-question", "/medicaltest/MedicalTests", null));
|
||||
|
||||
model.addElement(subMenu);
|
||||
}
|
||||
}
|
||||
|
||||
// Perfil
|
||||
subMenu = new DefaultSubMenu("Gestionar perfil", "pi pi-id-card");
|
||||
if (SessionUtils.isLogedIn() == false) {
|
||||
subMenu.addElement(createMenuItem("Registro de usuario", "pi pi-users", "/profile/RegisterUser", null));
|
||||
subMenu.addElement(createMenuItem("Registro de paciente", "pi pi-user-plus", "/profile/AddPatient", null));
|
||||
subMenu.addElement(createMenuItem("Registro de médico", "pi pi-user-plus", "/profile/AddFamilyDoctor", null));
|
||||
subMenu.addElement(createMenuItem("Registro de especialista", "pi pi-user-plus", "/profile/AddFamilyDoctor", null));
|
||||
subMenu.addElement(createMenuItem("Registro de médico", "pi pi-user-plus", "/profile/AddSpecialistDoctor", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
} else {
|
||||
|
||||
subMenu.addElement(createMenuItem("Actualizar mi perfil", "pi pi-user-edit", "/profile/UpdateProfile", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
// TODO: mostrar este menú solo si el usuario es paciente
|
||||
if (true == true) {
|
||||
subMenu.addElement(createMenuItem("Cambiar médico de familia", "pi pi-chevron-circle-right", "/profile/ChangeFamilyDoctor", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
}
|
||||
// TODO: mostrar este menú solo si el usuario es médico de familia
|
||||
if (true == true)
|
||||
subMenu.addElement(createMenuItem("Cambiar CAP", "fa fa-h-square", "/profile/ChangePrimaryHealthCareCenter", null));
|
||||
}
|
||||
model.addElement(subMenu);
|
||||
}
|
||||
|
||||
private DefaultMenuItem createMenuItem(String name, String icon, String outcome, String command) {
|
||||
DefaultMenuItem item = new DefaultMenuItem(name, icon);
|
||||
if (outcome != null)
|
||||
item.setOutcome(outcome);
|
||||
if (command != null)
|
||||
item.setCommand(command);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public MenuModel getModel() {
|
||||
|
||||
@@ -2,39 +2,70 @@
|
||||
package managedbean.common;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import TO.LoggedUserTO;
|
||||
|
||||
public class SessionUtils {
|
||||
public static final String SESSION_VAR_USERNAME = "userName";
|
||||
public static final String SESSION_VAR_USERID = "userId";
|
||||
public static final String SESSION_VAR_USERTYPE = "userType";
|
||||
public static final String SESSION_VAR_USER = "loggedInUser";
|
||||
|
||||
public static HttpSession getSession() {
|
||||
return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
if (ctx != null)
|
||||
return (HttpSession) ctx.getExternalContext().getSession(false);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static HttpServletRequest getRequest() {
|
||||
return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
|
||||
}
|
||||
|
||||
public static HttpSession getSession(ServletRequest request) {
|
||||
return ((HttpServletRequest) request).getSession(false);
|
||||
}
|
||||
|
||||
public static void CreateSession(LoggedUserTO usr) {
|
||||
HttpSession ses = getSession();
|
||||
ses.setAttribute(SessionUtils.SESSION_VAR_USERNAME, usr.getName());
|
||||
ses.setAttribute(SessionUtils.SESSION_VAR_USERID, usr.getId());
|
||||
ses.setAttribute(SessionUtils.SESSION_VAR_USERTYPE, usr.getUserType());
|
||||
ses.setAttribute(SessionUtils.SESSION_VAR_USER, usr);
|
||||
}
|
||||
|
||||
public static void DestroySession() {
|
||||
HttpSession ses = getSession();
|
||||
ses.invalidate();
|
||||
}
|
||||
|
||||
public static boolean isLogedIn() {
|
||||
if (getUserId() == "")
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return isLogedIn(getSession());
|
||||
}
|
||||
|
||||
public static boolean isLogedIn(HttpSession session) {
|
||||
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERID) != null)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getUserName() {
|
||||
HttpSession session = getSession();
|
||||
if (session != null && session.getAttribute("username") != null)
|
||||
return session.getAttribute("username").toString();
|
||||
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERNAME) != null)
|
||||
return session.getAttribute(SessionUtils.SESSION_VAR_USERNAME).toString();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getUserId() {
|
||||
HttpSession session = getSession();
|
||||
if (session != null && session.getAttribute("userid") != null)
|
||||
return session.getAttribute("userid").toString();
|
||||
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERID) != null)
|
||||
return session.getAttribute(SessionUtils.SESSION_VAR_USERID).toString();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.io.Serializable;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
@@ -12,7 +14,7 @@ import javax.inject.Named;
|
||||
*/
|
||||
@Named("AddFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class AddFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class AddFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -21,8 +23,7 @@ public class AddFamilyDoctorMBean extends ProfileMBeanBase implements Serializab
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public AddFamilyDoctorMBean() throws Exception {
|
||||
super.initializeProfileFacadeRemote();
|
||||
public AddFamilyDoctorMBean() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/**
|
||||
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||
* médica.
|
||||
@@ -16,7 +18,7 @@ import javax.inject.Named;
|
||||
*/
|
||||
@Named("addPatientMBean")
|
||||
@RequestScoped
|
||||
public class AddPatientMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class AddPatientMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -35,8 +37,7 @@ public class AddPatientMBean extends ProfileMBeanBase implements Serializable {
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public AddPatientMBean() throws Exception {
|
||||
super.initializeProfileFacadeRemote();
|
||||
public AddPatientMBean() {
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
|
||||
@@ -7,6 +7,7 @@ import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -15,7 +16,7 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
*/
|
||||
@Named( "AddSpecialistDoctorMBean")
|
||||
@RequestScoped
|
||||
public class AddSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class AddSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -27,8 +28,7 @@ public class AddSpecialistDoctorMBean extends ProfileMBeanBase implements Serial
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public AddSpecialistDoctorMBean() throws Exception {
|
||||
super.initializeProfileFacadeRemote();
|
||||
public AddSpecialistDoctorMBean() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
*/
|
||||
@Named( "ChangeFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class ChangeFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
*/
|
||||
@Named( "ChangePrimaryHealthCareCenterMBean")
|
||||
@RequestScoped
|
||||
public class ChangePrimaryHealthCareCenterMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named("profileMBean")
|
||||
public class ProfileMBeanBase {
|
||||
@EJB
|
||||
protected ProfileFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void initializeProfileFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/MyHealth.jar/ProfileFacadeBean!ejb.profile.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
protected void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
|
||||
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail));
|
||||
}
|
||||
|
||||
protected void manageException(Exception ex) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Se ha producido un error inesperado", "Descripción del error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,18 @@ package managedbean.profile;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.resource.NotSupportedException;
|
||||
|
||||
import org.primefaces.PrimeFaces;
|
||||
@@ -21,57 +24,65 @@ import TO.MedicalSpecialtyTO;
|
||||
import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.UserType;
|
||||
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||
import managedbean.common.UserType;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.ValidationUtils;
|
||||
|
||||
/**
|
||||
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||
* médica.
|
||||
* ManagedBEan que gestiona el registro de usuarios: Usuarios de tipo "Paciente"
|
||||
* Usuarios de tipo "Médico de Familia" usuarios de tipo "Médico especialista"
|
||||
*
|
||||
* @author mark
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named("registerUser")
|
||||
@RequestScoped
|
||||
public class RegisterUserMBean extends ProfileMBeanBase implements Serializable {
|
||||
@Named("RegisterUser")
|
||||
@ViewScoped
|
||||
public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private int id;
|
||||
private String nif;
|
||||
private String name;
|
||||
private String surname;
|
||||
private String password;
|
||||
private String passwordRepeat;
|
||||
private String email;
|
||||
private HashMap<String, String> userTypes;
|
||||
private boolean registered;
|
||||
|
||||
// private HashMap<String, String> userTypes;
|
||||
private List<UserType> userTypes;
|
||||
private String userType;
|
||||
private String primaryHealthCareCenter;
|
||||
private String medicalSpecialty;
|
||||
private Collection<MedicalSpecialtyTO> medicalSpecialities;
|
||||
private Collection<PrimaryHealthCareCenterTO> healthcareCenters;
|
||||
private PrimaryHealthCareCenterTO primaryHealthCareCenter;
|
||||
private MedicalSpecialtyTO medicalSpecialty;
|
||||
private Collection<MedicalSpecialtyTO> medicalSpecialitiesList;
|
||||
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public RegisterUserMBean() throws Exception {
|
||||
super.initializeProfileFacadeRemote();
|
||||
public RegisterUserMBean() {
|
||||
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.userTypes = new HashMap<String, String>();
|
||||
this.userTypes.put(UserType.PATIENT.getUserTypename(), UserType.PATIENT.name());
|
||||
this.userTypes.put(UserType.FAMILY_DOCTOR.getUserTypename(), UserType.FAMILY_DOCTOR.name());
|
||||
this.userTypes.put(UserType.SPECIALIST_DOCTOR.getUserTypename(), UserType.SPECIALIST_DOCTOR.name());
|
||||
this.userType = UserType.PATIENT.getUserTypename();
|
||||
this.userTypes = new ArrayList<UserType>();
|
||||
this.userTypes.add(UserType.PATIENT);
|
||||
this.userTypes.add(UserType.FAMILY_DOCTOR);
|
||||
this.userTypes.add(UserType.SPECIALIST_DOCTOR);
|
||||
this.registered = false;
|
||||
|
||||
this.userType = UserType.PATIENT.name();
|
||||
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerSystemAdmin().listAllMedicalSpecialities();
|
||||
this.primaryHealthCareCentersList = this.getRemoteManagerSystemAdmin().listAllCAPs();
|
||||
}
|
||||
|
||||
public HashMap<String, String> getUserTypes() {
|
||||
public List<UserType> getUserTypes() {
|
||||
return userTypes;
|
||||
}
|
||||
|
||||
@@ -79,12 +90,6 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
switch (UserType.valueOf(this.userType)) {
|
||||
case SPECIALIST_DOCTOR:
|
||||
try {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
SystemAdminFacadeRemote rman = (SystemAdminFacadeRemote) ctx.lookup("java:app/MyHealth.jar/SystemAdminFacadeBean!ejb.systemAdmin.SystemAdminFacadeRemote");
|
||||
|
||||
this.medicalSpecialities = rman.listAllMedicalSpecialities();
|
||||
|
||||
PrimeFaces.current().ajax().addCallbackParam("specs", true);
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
@@ -92,11 +97,6 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
try {
|
||||
// TODO: Load Primary Healthcare Centers from remote EJB
|
||||
this.healthcareCenters = new ArrayList<PrimaryHealthCareCenterTO>();
|
||||
this.healthcareCenters.add(new PrimaryHealthCareCenterTO("Prueba", "Descripción prueba"));
|
||||
this.healthcareCenters.add(new PrimaryHealthCareCenterTO("Centro 2", "Centro 2"));
|
||||
|
||||
PrimeFaces.current().ajax().addCallbackParam("caps", true);
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
@@ -104,12 +104,32 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
break;
|
||||
case ADMINISTRADOR:
|
||||
case PATIENT:
|
||||
PrimeFaces.current().ajax().addCallbackParam("pats", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<MedicalSpecialtyTO> getMedicalSpecialties() {
|
||||
return medicalSpecialities;
|
||||
public Collection<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
|
||||
return medicalSpecialitiesList;
|
||||
}
|
||||
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
|
||||
return primaryHealthCareCentersList;
|
||||
}
|
||||
|
||||
public boolean isPatient() {
|
||||
return (UserType.valueOf(this.userType) == UserType.PATIENT);
|
||||
}
|
||||
|
||||
public boolean isFamilyDoctor() {
|
||||
return (UserType.valueOf(this.userType) == UserType.FAMILY_DOCTOR);
|
||||
}
|
||||
|
||||
public boolean isSpecialistDoctor() {
|
||||
return (UserType.valueOf(this.userType) == UserType.SPECIALIST_DOCTOR);
|
||||
}
|
||||
|
||||
public boolean isDoctor() {
|
||||
return (isFamilyDoctor() || isSpecialistDoctor());
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
@@ -152,44 +172,59 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
this.nif = nif;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void addNewUser() {
|
||||
int error = 0;
|
||||
|
||||
if (this.isFamilyDoctor() && this.primaryHealthCareCenter == null) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Centro de atención primaria no seleccionado", "Por favor, especifique un centro de atención primaria.");
|
||||
error++;
|
||||
}
|
||||
if (this.isSpecialistDoctor() && this.medicalSpecialty == null) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Especialidad médica no seleccionada", "Por favor, especifique una especialidad médica.");
|
||||
error++;
|
||||
}
|
||||
if (ValidationUtils.isValid(nif) == false) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido.");
|
||||
} else {
|
||||
error++;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
switch (UserType.valueOf(this.userType)) {
|
||||
case PATIENT:
|
||||
PatientTO pat = this.remoteManager.registerPatient(id, nif, name, surname, password, email);
|
||||
PatientTO pat = this.getRemoteManagerProfile().registerPatient(id, nif, name, surname, password, email);
|
||||
this.id = pat.getId();
|
||||
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
FamilyDoctorTO fd = this.remoteManager.registerFamilyDoctor1(id, nif, name, surname, password, email, null);
|
||||
FamilyDoctorTO fd = this.getRemoteManagerProfile().registerFamilyDoctor1(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
||||
this.id = fd.getId();
|
||||
|
||||
break;
|
||||
case SPECIALIST_DOCTOR:
|
||||
SpecialistDoctorTO sd = this.remoteManager.registerSpecialistDoctor(id, nif, name, surname, password, email, null);
|
||||
SpecialistDoctorTO sd = this.getRemoteManagerProfile().registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty);
|
||||
this.id = sd.getId();
|
||||
|
||||
break;
|
||||
case ADMINISTRADOR:
|
||||
throw new NotSupportedException("No se soporta el registro directo de administradores.");
|
||||
}
|
||||
|
||||
this.registered = true;
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Registro realizado", "El usuario " + name + " " + surname + " se ha registrado correctamente.");
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Alta realizada",
|
||||
"El usuario " + name + " " + surname + " se ha registrado correctamente. Por favor, comprueba su correo electrónico para verificar su cuenta.");
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||
}
|
||||
|
||||
public String getPasswordRepeat() {
|
||||
@@ -207,21 +242,25 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public String getMedicalSpecialty() {
|
||||
|
||||
public MedicalSpecialtyTO getMedicalSpecialty() {
|
||||
return medicalSpecialty;
|
||||
}
|
||||
|
||||
public void setMedicalSpecialty(String medicalSpecialty) {
|
||||
public void setMedicalSpecialty(MedicalSpecialtyTO medicalSpecialty) {
|
||||
this.medicalSpecialty = medicalSpecialty;
|
||||
}
|
||||
|
||||
public String getPrimaryHealthCareCenter() {
|
||||
public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {
|
||||
return primaryHealthCareCenter;
|
||||
}
|
||||
|
||||
public void setPrimaryHealthCareCenter(String primaryHealthCareCenter) {
|
||||
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterTO primaryHealthCareCenter) {
|
||||
this.primaryHealthCareCenter = primaryHealthCareCenter;
|
||||
}
|
||||
|
||||
|
||||
public boolean isRegistered() {
|
||||
return registered;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
*/
|
||||
@Named( "ShowFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class ShowFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class ShowFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
*/
|
||||
@Named("ShowPatientMBean")
|
||||
@RequestScoped
|
||||
public class ShowPatientMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class ShowPatientMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
*/
|
||||
@Named( "ShowSpecialistDoctorMBean")
|
||||
@RequestScoped
|
||||
public class ShowSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class ShowSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
*/
|
||||
@Named("UpdateFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class UpdateFamilyDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class UpdateFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
*/
|
||||
@Named("UpdatePatientMBean")
|
||||
@RequestScoped
|
||||
public class UpdatePatientMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class UpdatePatientMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
|
||||
*/
|
||||
@Named("UpdateSpecialistDoctorMBean")
|
||||
@RequestScoped
|
||||
public class UpdateSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable {
|
||||
public class UpdateSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
package managedbean.systemAdmin;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
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.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.primefaces.PrimeFaces;
|
||||
|
||||
import TO.LoggedUserTO;
|
||||
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
@Named("loginView")
|
||||
@RequestScoped
|
||||
public class LoginMBean {
|
||||
|
||||
public class LoginMBean extends ManagedBeanBase {
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
@@ -35,29 +40,42 @@ public class LoginMBean {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void login() {
|
||||
FacesMessage message = null;
|
||||
public String login() {
|
||||
boolean loggedIn = false;
|
||||
|
||||
if (username != null && username.equals("admin") && password != null && password.equals("admin")) {
|
||||
loggedIn = true;
|
||||
HttpSession session = SessionUtils.getSession();
|
||||
session.setAttribute("username", username);
|
||||
session.setAttribute("userid", "1");
|
||||
message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido", username);
|
||||
} else {
|
||||
loggedIn = false;
|
||||
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
||||
}
|
||||
LoggedUserTO usr = null;
|
||||
|
||||
if (username != null && password != null) {
|
||||
try {
|
||||
usr = this.getRemoteManagerSystemAdmin().login(username, password);
|
||||
|
||||
if (usr != null) {
|
||||
loggedIn = true;
|
||||
SessionUtils.CreateSession(usr);
|
||||
|
||||
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Login correcto", "Bienvenido " + usr.getName());
|
||||
|
||||
return ("/home?faces-redirect=true");
|
||||
} else
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
||||
} catch (Exception ex) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_FATAL, "Error fatal", ex.getMessage());
|
||||
}
|
||||
|
||||
} else
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
||||
|
||||
FacesContext.getCurrentInstance().addMessage(null, message);
|
||||
PrimeFaces.current().ajax().addCallbackParam("loggedIn", loggedIn);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
// logout event, invalidate session
|
||||
public String logout() {
|
||||
HttpSession session = SessionUtils.getSession();
|
||||
session.invalidate();
|
||||
return "home?refresh=1&faces-redirect=true";
|
||||
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su ssesión. Hasta la vista");
|
||||
|
||||
SessionUtils.DestroySession();
|
||||
|
||||
return "/home?faces-redirect=true";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user