Avances en la pantalla de registro de usuarios nuevos (pacientes).
* Actualización de script para crear tablas (Todo a minusculas, no case sensitive) * Script de datos de pruebas de especialides médicas. * Nuevo bean para registro de usuarios (Quidato de filtro de seguridad de login, acceso sin login). * Actualización de entidades JPA con campos Identity. * Enumerado para gestionar tipos de usuarios (Paciente, Medico Familia, Especialista y Administrador) * Clase común para realizar validaciones (función para validar nif).
This commit is contained in:
@@ -27,7 +27,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
@PersistenceContext(unitName = "MyHealth")
|
||||
private EntityManager entman;
|
||||
|
||||
public PatientTO changeFamilyDoctor(String id, String ProfessionalNumberId) {
|
||||
public PatientTO changeFamilyDoctor(Integer id, Integer ProfessionalNumberId) {
|
||||
PatientTO paTO = null;
|
||||
|
||||
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, ProfessionalNumberId);
|
||||
@@ -42,7 +42,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
return paTO;
|
||||
}
|
||||
|
||||
public PatientTO registerPacient(String id, String nif, String name, String surname, String password, String email) {
|
||||
public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email) {
|
||||
PatientTO paTO = null;
|
||||
|
||||
PatientJPA ms = new PatientJPA(id, nif, name, surname, password, email);
|
||||
@@ -52,7 +52,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
return paTO;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO registerSpecialistDoctor(String 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) {
|
||||
SpecialistDoctorTO sdTO = null;
|
||||
|
||||
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName());
|
||||
@@ -67,7 +67,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
return sdTO;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO registerFamilyDoctor1(String 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, String cap) {
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap);
|
||||
@@ -86,7 +86,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
return fdTO;
|
||||
}
|
||||
|
||||
public PatientTO updatePacientData(String id, String nif, String name, String surname, String password, String email) {
|
||||
public PatientTO updatePacientData(Integer id, String nif, String name, String surname, String password, String email) {
|
||||
PatientJPA fd = entman.find(PatientJPA.class, id);
|
||||
PatientTO ptTO = null;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
return ptTO;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO updateSpecialistDoctorData(String 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) {
|
||||
SpecialistDoctorTO sdTO = null;
|
||||
|
||||
SpecialistDoctorJPA sd = entman.find(SpecialistDoctorJPA.class, id);
|
||||
@@ -129,7 +129,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
return sdTO;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO updateFamilyDoctorData(String id, String nif, String name, String surname, String password, String email, String cap) {
|
||||
public FamilyDoctorTO updateFamilyDoctorData(Integer id, String nif, String name, String surname, String password, String email, String cap) {
|
||||
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, id);
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
@@ -153,7 +153,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
return fdTO;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO changePrimaryHealthCareCenter(String FamilyDoctorId, PrimaryHealthCareCenterTO newCenter) {
|
||||
public FamilyDoctorTO changePrimaryHealthCareCenter(Integer FamilyDoctorId, PrimaryHealthCareCenterTO newCenter) {
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, newCenter);
|
||||
|
||||
@@ -16,21 +16,21 @@ import TO.SpecialistDoctorTO;
|
||||
@Remote
|
||||
public interface ProfileFacadeRemote {
|
||||
|
||||
public PatientTO changeFamilyDoctor(String id, String ProfessionalNumberId);
|
||||
public PatientTO changeFamilyDoctor(Integer id, Integer ProfessionalNumberId);
|
||||
|
||||
public PatientTO registerPacient(String id, String nif, String name, String surname, String password, String email);
|
||||
public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email);
|
||||
|
||||
public SpecialistDoctorTO registerSpecialistDoctor(String 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 FamilyDoctorTO registerFamilyDoctor1(String 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, String cap);
|
||||
|
||||
public PatientTO updatePacientData(String id, String nif, String name, String surname, String password, String email);
|
||||
public PatientTO updatePacientData(Integer id, String nif, String name, String surname, String password, String email);
|
||||
|
||||
public SpecialistDoctorTO updateSpecialistDoctorData(String 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 FamilyDoctorTO updateFamilyDoctorData(String id, String nif, String name, String surname, String password, String email, String cap);
|
||||
public FamilyDoctorTO updateFamilyDoctorData(Integer id, String nif, String name, String surname, String password, String email, String cap);
|
||||
|
||||
public FamilyDoctorTO changePrimaryHealthCareCenter(String id, PrimaryHealthCareCenterTO newCenter);
|
||||
public FamilyDoctorTO changePrimaryHealthCareCenter(Integer id, PrimaryHealthCareCenterTO newCenter);
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
package ejb.systemAdmin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
@@ -20,9 +26,37 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
@PersistenceContext(unitName = "MyHealth")
|
||||
private EntityManager entman;
|
||||
|
||||
public void ejbMethod(String parameter)
|
||||
{
|
||||
|
||||
/**
|
||||
* Metodo que devuelve todas las especialidades medicas
|
||||
*/
|
||||
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities() {
|
||||
return this.listPagedMedicalSpecialities(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo que devuelve las especialidades médicas de forma paginada
|
||||
*
|
||||
* Acepta como parametro la página (comenzando en 0) y el número de elementos de
|
||||
* cada página
|
||||
*
|
||||
*/
|
||||
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize) {
|
||||
Query query = entman.createQuery("from MedicalSpecialtyJPA order by name");
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<MedicalSpecialtyJPA> allJPA = query.getResultList();
|
||||
Collection<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
|
||||
|
||||
for (MedicalSpecialtyJPA ms : allJPA) {
|
||||
allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription()));
|
||||
}
|
||||
|
||||
return allSpecialities;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package ejb.systemAdmin;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import TO.MedicalSpecialtyTO;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
* los clientes del EJB
|
||||
@@ -14,5 +18,5 @@ public interface SystemAdminFacadeRemote {
|
||||
/**
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
public void ejbMethod(String parameter);
|
||||
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
|
||||
}
|
||||
Reference in New Issue
Block a user