Merge branch 'master' into rorden
This commit is contained in:
@@ -86,7 +86,7 @@ public class FamilyDoctorTO implements Serializable {
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return String.format("[%d] %s %s", this.id, this.name, this.surname);
|
||||
return String.format("[%s] %s %s", this.professionalNumber, this.name, this.surname);
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {
|
||||
|
||||
@@ -90,6 +90,10 @@ public class PatientTO implements Serializable {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return String.format("[%s] %s %s", this.personalIdentificationCode, this.name, this.surname);
|
||||
}
|
||||
|
||||
public FamilyDoctorTO getFamilyDoctor() {
|
||||
return familyDoctor;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,10 @@ public class SpecialistDoctorTO implements Serializable {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return String.format("[%s] %s %s", this.professionalNumber, this.name, this.surname);
|
||||
}
|
||||
|
||||
public MedicalSpecialtyTO getMedicalSpecialty() {
|
||||
return medicalSpecialty;
|
||||
}
|
||||
|
||||
@@ -161,114 +161,153 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
|
||||
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms) {
|
||||
MedicalSpecialtyTO msTO = null;
|
||||
|
||||
|
||||
if (ms != null) {
|
||||
msTO = new MedicalSpecialtyTO(ms.getId(), ms.getName(), ms.getDescription());
|
||||
}
|
||||
|
||||
|
||||
return msTO;
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterTO getPOJOforPrimaryHealthCareCenterJPA(PrimaryHealthCareCenterJPA phc) {
|
||||
PrimaryHealthCareCenterTO phcTO = null;
|
||||
|
||||
|
||||
if (phc != null) {
|
||||
phcTO = new PrimaryHealthCareCenterTO(phc.getId(), phc.getName(), phc.getLocation());
|
||||
}
|
||||
|
||||
|
||||
return phcTO;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO getPOJOforSpecialistDoctorJPA(SpecialistDoctorJPA sd, int nestedProps) {
|
||||
SpecialistDoctorTO sdTO = null;
|
||||
|
||||
|
||||
if (sd != null) {
|
||||
MedicalSpecialtyJPA ms = null;
|
||||
if (nestedProps > 0)
|
||||
ms = sd.getMedicalSpecialty();
|
||||
|
||||
nestedProps--;
|
||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), this.getPOJOforMedicalSpecialtyJPA(ms));
|
||||
|
||||
nestedProps--;
|
||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(),
|
||||
this.getPOJOforMedicalSpecialtyJPA(ms));
|
||||
}
|
||||
|
||||
|
||||
return sdTO;
|
||||
}
|
||||
|
||||
|
||||
public FamilyDoctorTO getPOJOforFamilyDoctorJPA(FamilyDoctorJPA fd, int nestedProps) {
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
|
||||
if (fd != null) {
|
||||
PrimaryHealthCareCenterJPA phc = null;
|
||||
if (nestedProps > 0)
|
||||
phc = fd.getPrimaryHealthCareCenter();
|
||||
|
||||
|
||||
nestedProps--;
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), this.getPOJOforPrimaryHealthCareCenterJPA(phc));
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(),
|
||||
this.getPOJOforPrimaryHealthCareCenterJPA(phc));
|
||||
}
|
||||
|
||||
|
||||
return fdTO;
|
||||
}
|
||||
|
||||
|
||||
public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps) {
|
||||
PatientTO paTO = null;
|
||||
|
||||
|
||||
if (pat != null) {
|
||||
FamilyDoctorJPA fd = null;
|
||||
if (nestedProps > 0)
|
||||
fd = pat.getFamilyDoctor();
|
||||
|
||||
|
||||
nestedProps--;
|
||||
paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), this.getPOJOforFamilyDoctorJPA(fd, nestedProps));
|
||||
paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(),
|
||||
this.getPOJOforFamilyDoctorJPA(fd, nestedProps));
|
||||
}
|
||||
|
||||
|
||||
return paTO;
|
||||
}
|
||||
|
||||
|
||||
public PatientTO findPatientById(int patientId) {
|
||||
// Recuperamos propiedades anidadas 1 nivel!
|
||||
return this.getPOJOforPatientJPA(entman.find(PatientJPA.class, patientId), 1);
|
||||
}
|
||||
|
||||
|
||||
public PatientJPA findPatientByCode(String code) {
|
||||
public PatientTO findPatientByCode(String code) {
|
||||
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.personalIdentificationCode=:code", PatientJPA.class);
|
||||
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("code", code);
|
||||
|
||||
|
||||
List<PatientJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return results.get(0);
|
||||
return this.getPOJOforPatientJPA(results.get(0), 1);
|
||||
else
|
||||
return null; }
|
||||
return null;
|
||||
}
|
||||
|
||||
public PatientTO findPatientByNif(String searchValue) {
|
||||
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.nif=:nif", PatientJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("nif", searchValue);
|
||||
|
||||
List<PatientJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return this.getPOJOforPatientJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId) {
|
||||
return this.getPOJOforFamilyDoctorJPA(entman.find(FamilyDoctorJPA.class, ProfessionalNumberId), 1);
|
||||
}
|
||||
|
||||
public FamilyDoctorJPA findFamilyDoctorByCode(String code) {
|
||||
public FamilyDoctorTO findFamilyDoctorByCode(String code) {
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.professionalNumber=:code", FamilyDoctorJPA.class);
|
||||
|
||||
|
||||
query.setParameter("code", code);
|
||||
|
||||
|
||||
List<FamilyDoctorJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return results.get(0);
|
||||
return this.getPOJOforFamilyDoctorJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue) {
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.nif=:nif", FamilyDoctorJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("nif", searchValue);
|
||||
|
||||
List<FamilyDoctorJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return this.getPOJOforFamilyDoctorJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId) {
|
||||
return this.getPOJOforSpecialistDoctorJPA(entman.find(SpecialistDoctorJPA.class, ProfessionalNumberId), 1);
|
||||
}
|
||||
|
||||
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code) {
|
||||
public SpecialistDoctorTO findSpecialistDoctorByCode(String code) {
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.professionalNumber=:code", SpecialistDoctorJPA.class);
|
||||
|
||||
|
||||
query.setParameter("code", code);
|
||||
|
||||
|
||||
List<SpecialistDoctorJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return results.get(0);
|
||||
return this.getPOJOforSpecialistDoctorJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue) {
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.nif=:nif", SpecialistDoctorJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("nif", searchValue);
|
||||
|
||||
List<SpecialistDoctorJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return this.getPOJOforSpecialistDoctorJPA(results.get(0), 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -44,15 +44,21 @@ public interface CommonFacadeLocal {
|
||||
|
||||
public PatientTO findPatientById(int patientId);
|
||||
|
||||
public PatientJPA findPatientByCode(String code);
|
||||
public PatientTO findPatientByCode(String code);
|
||||
|
||||
public PatientTO findPatientByNif(String searchValue);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
|
||||
public FamilyDoctorTO findFamilyDoctorByCode(String code);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
|
||||
public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
|
||||
|
||||
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms);
|
||||
|
||||
|
||||
@@ -42,14 +42,20 @@ public interface CommonFacadeRemote {
|
||||
|
||||
public PatientTO findPatientById(int patientId);
|
||||
|
||||
public PatientJPA findPatientByCode(String code);
|
||||
public PatientTO findPatientByCode(String code);
|
||||
|
||||
public PatientTO findPatientByNif(String searchValue);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
|
||||
public FamilyDoctorTO findFamilyDoctorByCode(String code);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
|
||||
public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
}
|
||||
|
||||
private String getNextPersonalIdentificationCode() {
|
||||
Query q = entman.createNativeQuery("select nextval('myhealth.profesionalnumber')");
|
||||
Query q = entman.createNativeQuery("select nextval('myhealth.codigoidentificacionpaciente')");
|
||||
return Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX.concat(String.valueOf(q.getSingleResult()));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,15 @@ import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import TO.FamilyDoctorTO;
|
||||
import TO.LoggedUserTO;
|
||||
import TO.PatientTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.Constants;
|
||||
import common.HashUtils;
|
||||
import common.UserType;
|
||||
import ejb.common.CommonFacadeLocal;
|
||||
import jpa.AdministratorJPA;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.PatientJPA;
|
||||
import jpa.SpecialistDoctorJPA;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,7 +29,7 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
|
||||
@EJB
|
||||
CommonFacadeLocal commonServices;
|
||||
|
||||
|
||||
/**
|
||||
* Si la autenticación no es correcgta devuelve null, sino devuelve un POJO con
|
||||
* datos del usuario logeado.
|
||||
@@ -61,20 +61,20 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
if (userCode.startsWith(Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX)) {
|
||||
// Si el identificador de usuario es de tipo paciente, intentamos realizar el
|
||||
// login.
|
||||
PatientJPA pat = this.commonServices.findPatientByCode(userCode);
|
||||
PatientTO pat = this.commonServices.findPatientByCode(userCode);
|
||||
if (pat != null) {
|
||||
usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT);
|
||||
}
|
||||
} else if (userCode.startsWith(Constants.PROFESSIONAL_NUMBER_PREFIX)) {
|
||||
// Si el identificador de usuario es de tipo profesional, intentamos realizar el
|
||||
// login, primero como médico de familia, después como especialista
|
||||
FamilyDoctorJPA fd = this.commonServices.findFamilyDoctorByCode(userCode);
|
||||
FamilyDoctorTO fd = this.commonServices.findFamilyDoctorByCode(userCode);
|
||||
|
||||
if (fd != null) {
|
||||
usr = new LoggedUserTO(String.valueOf(fd.getId()), fd.getName(), fd.getPassword(), UserType.FAMILY_DOCTOR);
|
||||
} else {
|
||||
// No era un código de médico de familia, intenamos logearlo como especialista
|
||||
SpecialistDoctorJPA sd = this.commonServices.findSpecialistDoctorByCode(userCode);
|
||||
SpecialistDoctorTO sd = this.commonServices.findSpecialistDoctorByCode(userCode);
|
||||
|
||||
if (sd != null) {
|
||||
usr = new LoggedUserTO(String.valueOf(sd.getId()), sd.getName(), sd.getPassword(), UserType.SPECIALIST_DOCTOR);
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
package managedbean.common;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Dictionary;
|
||||
import java.util.List;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
@@ -14,6 +18,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.primefaces.model.menu.DefaultSeparator;
|
||||
import org.primefaces.model.menu.DefaultSubMenu;
|
||||
|
||||
import common.UserType;
|
||||
|
||||
@WebFilter(filterName = "AuthFilter", urlPatterns = { "*.xhtml" })
|
||||
public class AuthorizationFilter implements Filter {
|
||||
|
||||
@@ -34,11 +43,101 @@ public class AuthorizationFilter implements Filter {
|
||||
HttpSession ses = req.getSession(false);
|
||||
|
||||
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)
|
||||
|
||||
// Para recursos publicos permitimos el acceso
|
||||
if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/profile/RegisterUser.xhtml") >= 0 || reqURI.indexOf("/home.xhtml") >= 0
|
||||
|| reqURI.indexOf("/error.xhtml") >= 0 || reqURI.indexOf("/public/") >= 0 || reqURI.contains("javax.faces.resource")) {
|
||||
chain.doFilter(request, response);
|
||||
else
|
||||
resp.sendRedirect(req.getContextPath() + "/login.xhtml");
|
||||
return;
|
||||
}
|
||||
|
||||
// Si el usuario está logeado comprobamos si está autorizado a ver la página
|
||||
// solicitada.
|
||||
if (SessionUtils.isLogedIn(ses) == true) {
|
||||
UserType tipoUsuario = SessionUtils.getUserType(ses);
|
||||
boolean authorized = false;
|
||||
|
||||
switch (tipoUsuario) {
|
||||
case ADMINISTRATOR:
|
||||
if (reqURI.indexOf("/systemAdmin/ManageSpecialties") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/systemAdmin/ManageHealthCareCenters") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/systemAdmin/ListDoctorsByCenter") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/VisitView") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/UpdateVisit") > 0)
|
||||
authorized = true;
|
||||
break;
|
||||
case PATIENT:
|
||||
if (reqURI.indexOf("/visit/VisitView") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/AddVisit") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/UpdateVisit") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/CancelVisit") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/AddQuestion") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/SearchSpecialistBySpecialty") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/profile/UpdateProfile") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/profile/ChangeFamilyDoctor") > 0)
|
||||
authorized = true;
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
if (reqURI.indexOf("/visit/VisitView") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/VisitAddResult") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/VisitViewSchedules") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/AnswerQuestion") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/PendingQuestions") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/profile/UpdateProfile") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/profile/ChangePrimaryHealthCareCenter") > 0)
|
||||
authorized = true;
|
||||
break;
|
||||
case SPECIALIST_DOCTOR:
|
||||
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/AddMedicalTest") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/AddImageToMedicalTest") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/profile/UpdateProfile") > 0)
|
||||
authorized = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (authorized == true) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
} else {
|
||||
SessionUtils.addMessage(ses, FacesMessage.SEVERITY_ERROR, "No está autorizado a acceder a la página solicitada. Por favor, utilice el menú principal de la aplicación.", String.format("Se ha producido una expción de autorización, su usuario no está autorizado a acceder a la página: (%s).", reqURI));
|
||||
resp.sendRedirect(req.getContextPath() + "/error.xhtml?type=auth");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
resp.sendRedirect(req.getContextPath() + "/login.xhtml");
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -95,17 +95,29 @@ public class ManagedBeanBase {
|
||||
protected void addFacesMessageKeep(FacesMessage.Severity severity, String summary, String detail) {
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
|
||||
this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail);
|
||||
this.addFacesMessage(FacesContext.getCurrentInstance(), null, 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);
|
||||
this.addFacesMessage(FacesContext.getCurrentInstance(), null, severity, summary, detail);
|
||||
}
|
||||
|
||||
protected void addFacesMessage(String clientId, FacesMessage.Severity severity, String summary, String detail) {
|
||||
this.addFacesMessage(FacesContext.getCurrentInstance(), clientId, 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 addFacesMessage(FacesContext context, String clientId, FacesMessage.Severity severity, String summary, String detail) {
|
||||
this.addFacesMessage(context, clientId, new FacesMessage(severity, summary, detail));
|
||||
}
|
||||
|
||||
protected void addFacesMessage(FacesMessage facesMsg, String clientId) {
|
||||
this.addFacesMessage(FacesContext.getCurrentInstance(), clientId, facesMsg);
|
||||
}
|
||||
|
||||
protected void addFacesMessage(FacesContext context, String clientId, FacesMessage facesMsg) {
|
||||
context.addMessage(clientId, facesMsg);
|
||||
}
|
||||
|
||||
protected void manageException(Exception ex) {
|
||||
|
||||
@@ -114,9 +114,9 @@ public class MenuMBean implements Serializable {
|
||||
subMenu = new DefaultSubMenu("Gestionar perfil", "fa fa-gears");
|
||||
if (SessionUtils.isLogedIn() == false) {
|
||||
subMenu.addElement(createMenuItem("Registro de usuario", "fa fa-user-plus", "/profile/RegisterUser", null));
|
||||
subMenu.addElement(createMenuItem("Registro de paciente", "fa fa-user-plus", "/profile/AddPatient", null));
|
||||
subMenu.addElement(createMenuItem("Registro de médico", "fa fa-user-md", "/profile/AddFamilyDoctor", null));
|
||||
subMenu.addElement(createMenuItem("Registro de especialista", "fa fa-user-md", "/profile/AddSpecialistDoctor", null));
|
||||
// subMenu.addElement(createMenuItem("Registro de paciente", "fa fa-user-plus", "/profile/AddPatient", null));
|
||||
// subMenu.addElement(createMenuItem("Registro de médico", "fa fa-user-md", "/profile/AddFamilyDoctor", null));
|
||||
// subMenu.addElement(createMenuItem("Registro de especialista", "fa fa-user-md", "/profile/AddSpecialistDoctor", null));
|
||||
|
||||
model.addElement(subMenu);
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
package managedbean.common;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -14,6 +15,7 @@ public class SessionUtils {
|
||||
public static final String SESSION_VAR_USERID = "userId";
|
||||
public static final String SESSION_VAR_USERTYPE = "userType";
|
||||
public static final String SESSION_VAR_USER = "loggedOnUser";
|
||||
public static final String SESSION_VAR_MESSAGE = "facesMessage";
|
||||
|
||||
public static HttpSession getSession() {
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
@@ -47,7 +49,7 @@ public class SessionUtils {
|
||||
public static boolean isLogedIn() {
|
||||
return isLogedIn(getSession());
|
||||
}
|
||||
|
||||
|
||||
public static boolean isLogedIn(HttpSession session) {
|
||||
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERID) != null)
|
||||
return true;
|
||||
@@ -70,15 +72,18 @@ public class SessionUtils {
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static UserType getUserType() {
|
||||
HttpSession session = getSession();
|
||||
return getUserType(getSession());
|
||||
}
|
||||
|
||||
public static UserType getUserType(HttpSession session) {
|
||||
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERTYPE) != null)
|
||||
return UserType.class.cast(session.getAttribute(SessionUtils.SESSION_VAR_USERTYPE));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static LoggedUserTO getloggedOnUser() {
|
||||
HttpSession session = getSession();
|
||||
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USER) != null)
|
||||
@@ -86,4 +91,24 @@ public class SessionUtils {
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FacesMessage getMessage() {
|
||||
HttpSession session = getSession();
|
||||
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_MESSAGE) != null) {
|
||||
FacesMessage msg = FacesMessage.class.cast(session.getAttribute(SessionUtils.SESSION_VAR_MESSAGE));
|
||||
session.removeAttribute(SessionUtils.SESSION_VAR_MESSAGE);
|
||||
return msg;
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addMessage(FacesMessage.Severity severity, String summary, String detail) {
|
||||
addMessage(getSession(), severity, summary, detail);
|
||||
}
|
||||
|
||||
public static void addMessage(HttpSession session, FacesMessage.Severity severity, String summary, String detail) {
|
||||
if (session != null)
|
||||
session.setAttribute(SessionUtils.SESSION_VAR_MESSAGE, new FacesMessage(severity, summary, detail));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package managedbean.common;
|
||||
|
||||
import TO.FamilyDoctorTO;
|
||||
import TO.PatientTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.UserType;
|
||||
import ejb.common.CommonFacadeRemote;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
@@ -47,4 +53,51 @@ public class ValidationUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comprueba si un NIF existe para un tipo de usuario. * No se permite que el
|
||||
* mismo NIF esté registrado como médico de familia y como especialista. * Se
|
||||
* permite que el mismo NIF esté registrado como paciente y como médico (de
|
||||
* familia o especialista)
|
||||
*
|
||||
* @param remoteSvc Servicio Remoto para recuperar datos.
|
||||
* @param userType Tipo de usuario a comprobar
|
||||
* @param nif NIF a comprobar.
|
||||
* @param id Parámetro opcional, id del usuario actual (si encuentra el
|
||||
* mismo nif y el usuario coincide no se devuelve la
|
||||
* coincidencia)
|
||||
* @return true si el NIF ya estaba registrado para un usuario diferente.
|
||||
*/
|
||||
public static boolean checkIfNifAlreadyRegistered(CommonFacadeRemote remoteSvc, UserType userType, String nif, Integer id) {
|
||||
boolean nifExists = false;
|
||||
|
||||
switch (userType) {
|
||||
case ADMINISTRATOR:
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
case SPECIALIST_DOCTOR:
|
||||
FamilyDoctorTO fd = remoteSvc.findFamilyDoctorByNif(nif);
|
||||
|
||||
if (fd == null) {
|
||||
// Si el nif no está en uso para un médico de familia, reivsamos si está en uso
|
||||
// para los especialistas
|
||||
SpecialistDoctorTO sd = remoteSvc.findSpecialistDoctorByNif(nif);
|
||||
|
||||
if (sd != null && (id == null || fd.getId() != id))
|
||||
nifExists = true;
|
||||
} else if (id == null || fd.getId() != id)
|
||||
// Si se trata de un usuario diferente, entonces está repetido
|
||||
nifExists = true;
|
||||
|
||||
break;
|
||||
case PATIENT:
|
||||
PatientTO pat = remoteSvc.findPatientByNif(nif);
|
||||
|
||||
// Si se trata de un usuario diferente, entonces está repetido
|
||||
if (pat != null && (id == null || pat.getId() != id))
|
||||
nifExists = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return nifExists;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ 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;
|
||||
@@ -16,7 +17,7 @@ import common.UserType;
|
||||
*/
|
||||
@Named("home")
|
||||
@RequestScoped
|
||||
public class homeMBean implements Serializable {
|
||||
public class homeMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean isLogedIn;
|
||||
@@ -31,6 +32,12 @@ public class homeMBean implements Serializable {
|
||||
userName = SessionUtils.getUserName();
|
||||
userId = SessionUtils.getUserId();
|
||||
userType = SessionUtils.getUserType();
|
||||
|
||||
FacesMessage message = SessionUtils.getMessage();
|
||||
|
||||
if (message != null) {
|
||||
this.addFacesMessage(message, null);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Theme> getThemes() {
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
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)
|
||||
*
|
||||
*/
|
||||
@Named("AddFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class AddFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public AddFamilyDoctorMBean() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
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.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
*/
|
||||
@Named("addPatientMBean")
|
||||
@RequestScoped
|
||||
public class AddPatientMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
private String nif;
|
||||
private String name;
|
||||
private String surname;
|
||||
private String password;
|
||||
private String passwordRepeat;
|
||||
private String email;
|
||||
private String primaryHealthCareCenter;
|
||||
private String medicalSpecialty;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public AddPatientMBean() {
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public void setSurname(String surname) {
|
||||
this.surname = surname;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNif() {
|
||||
return nif;
|
||||
}
|
||||
|
||||
public void setNif(String nif) {
|
||||
this.nif = nif;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
FacesMessage msg;
|
||||
|
||||
try {
|
||||
|
||||
|
||||
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Alta realizada", "El usuario " + name + " " + surname + " se ha registrado correctamente.");
|
||||
} catch (Exception e) {
|
||||
msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Se ha producido un error inesperado: " + e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||
}
|
||||
|
||||
public String getPasswordRepeat() {
|
||||
return passwordRepeat;
|
||||
}
|
||||
|
||||
public void setPasswordRepeat(String passwordRepeat) {
|
||||
this.passwordRepeat = passwordRepeat;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named( "AddSpecialistDoctorMBean")
|
||||
@RequestScoped
|
||||
public class AddSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private ProfileFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public AddSpecialistDoctorMBean() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,6 +127,11 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
}
|
||||
return this.medicalSpecialitiesList;
|
||||
}
|
||||
|
||||
public void hadleNIFValueChange() {
|
||||
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, null) == true)
|
||||
this.addFacesMessage("frmRegisterUser:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
|
||||
}
|
||||
|
||||
public boolean isPatient() {
|
||||
return (this.userType == UserType.PATIENT);
|
||||
@@ -199,6 +204,10 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido.");
|
||||
error++;
|
||||
}
|
||||
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, null) == true) {
|
||||
this.addFacesMessage("frmRegisterUser:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
|
||||
error++;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named( "ShowFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class ShowFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private ProfileFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public ShowFamilyDoctorMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named("ShowPatientMBean")
|
||||
@RequestScoped
|
||||
public class ShowPatientMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private ProfileFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public ShowPatientMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named( "ShowSpecialistDoctorMBean")
|
||||
@RequestScoped
|
||||
public class ShowSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private ProfileFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public ShowSpecialistDoctorMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx
|
||||
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named("UpdateFamilyDoctorMBean")
|
||||
@RequestScoped
|
||||
public class UpdateFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private ProfileFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public UpdateFamilyDoctorMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named("UpdatePatientMBean")
|
||||
@RequestScoped
|
||||
public class UpdatePatientMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private ProfileFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public UpdatePatientMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -172,6 +172,11 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
return this.medicalSpecialitiesList;
|
||||
}
|
||||
|
||||
public void hadleNIFValueChange() {
|
||||
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true)
|
||||
this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
|
||||
}
|
||||
|
||||
public List<FamilyDoctorTO> getFamilyDoctorList() {
|
||||
return familyDoctorList;
|
||||
}
|
||||
@@ -261,6 +266,10 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido.");
|
||||
error++;
|
||||
}
|
||||
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true) {
|
||||
this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
|
||||
error++;
|
||||
}
|
||||
if (changePassword == true) {
|
||||
// el usuario queire cambiar el password Comprobamos que el password
|
||||
// especificado coincide con el guardado
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package managedbean.profile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import ejb.profile.ProfileFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
/***
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
*/
|
||||
@Named("UpdateSpecialistDoctorMBean")
|
||||
@RequestScoped
|
||||
public class UpdateSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EJB
|
||||
private ProfileFacadeRemote remoteManager;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public UpdateSpecialistDoctorMBean() throws Exception {
|
||||
initializeAdminFacadeRemote();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private void initializeAdminFacadeRemote() throws Exception {
|
||||
Properties props = System.getProperties();
|
||||
Context ctx = new InitialContext(props);
|
||||
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user