Subida incial del esqueleto del componente profile:
* Clases de ejb FacadeBean y FacadeRemote con implementación incial. * Clases de persistencia JPA necesarias para el componente con algunas relaciones configuradas (Necesaria revisión). * ClasesTO (Transfer Object) iniciales (Necesitan revisión profunda). * Cambio de estrategia sobre paquetes para clases TO, es necesario ubicarlas en el mismo paquete, ya que se comparten por varios componentes. Se sigue la misma estrategia que con las clases JPA. * Si alguien necesita utilizar alguna clase JPA debe revisarla (Seguro que faltan relaciones). * Creadas clases esqueleto (Dummy) para MBean del componente perfil. * Se ha eliminado paquetes no necesarios (clases TO). * En principio el proyecto debería compilar. * Se asume que el equema de base de datos se llamará "MyHealth" (Ver anotación en clases JPA.
This commit is contained in:
@@ -4,13 +4,20 @@ import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import TO.FamilyDoctorTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
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
|
||||
@@ -20,9 +27,145 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
||||
@PersistenceContext(unitName = "MyHealth")
|
||||
private EntityManager entman;
|
||||
|
||||
public void ejbMethod(String parameter)
|
||||
{
|
||||
public PatientTO changeFamilyDoctor(String id, String ProfessionalNumberId) {
|
||||
PatientTO paTO = null;
|
||||
|
||||
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, ProfessionalNumberId);
|
||||
PatientJPA pa = entman.find(PatientJPA.class, id);
|
||||
|
||||
if (fd != null && pa != null) {
|
||||
pa.setFamilyDoctor(fd);
|
||||
paTO = new PatientTO();
|
||||
|
||||
}
|
||||
|
||||
return paTO;
|
||||
}
|
||||
|
||||
public PatientTO registerPacient(String id, String nif, String name, String surname, String password, String email) {
|
||||
PatientTO paTO = null;
|
||||
|
||||
PatientJPA ms = new PatientJPA(id, nif, name, surname, password, email);
|
||||
entman.persist(ms);
|
||||
paTO = new PatientTO(ms.getId(), ms.getNif(), ms.getName(), ms.getSurname(), ms.getPassword(), ms.getEmail());
|
||||
|
||||
return paTO;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO registerSpecialistDoctor(String id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty) {
|
||||
SpecialistDoctorTO sdTO = null;
|
||||
|
||||
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName());
|
||||
|
||||
// TODO: Lanzar error si no se encuentra la especialidad.
|
||||
if (ms != null) {
|
||||
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(id, nif, name, surname, password, email);
|
||||
entman.persist(sd);
|
||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail());
|
||||
}
|
||||
|
||||
return sdTO;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO registerFamilyDoctor1(String id, String nif, String name, String surname, String password, String email, String cap) {
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap);
|
||||
|
||||
// TODO: Lanzar error si no encontramos el cap!!!!!
|
||||
if (phcC != null) {
|
||||
|
||||
FamilyDoctorJPA fd = new FamilyDoctorJPA(id, nif, name, surname, password, email);
|
||||
fd.setPrimaryHealthCareCenter(phcC);
|
||||
|
||||
entman.persist(fd);
|
||||
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail());
|
||||
}
|
||||
|
||||
return fdTO;
|
||||
}
|
||||
|
||||
public PatientTO updatePacientData(String id, String nif, String name, String surname, String password, String email) {
|
||||
PatientJPA fd = entman.find(PatientJPA.class, id);
|
||||
PatientTO ptTO = null;
|
||||
|
||||
if (fd != null) {
|
||||
fd.setNif(nif);
|
||||
fd.setName(name);
|
||||
fd.setSurname(surname);
|
||||
fd.setPassword(password);
|
||||
fd.setEmail(email);
|
||||
|
||||
entman.persist(fd);
|
||||
|
||||
ptTO = new PatientTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail());
|
||||
}
|
||||
|
||||
return ptTO;
|
||||
}
|
||||
|
||||
public SpecialistDoctorTO updateSpecialistDoctorData(String id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty) {
|
||||
SpecialistDoctorTO sdTO = null;
|
||||
|
||||
SpecialistDoctorJPA sd = entman.find(SpecialistDoctorJPA.class, id);
|
||||
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName());
|
||||
|
||||
// TODO: Lanzar error al no encontrar la especialidad indicada ?????
|
||||
|
||||
if (sd != null && ms != null) {
|
||||
sd.setNif(nif);
|
||||
sd.setName(name);
|
||||
sd.setSurname(surname);
|
||||
sd.setPassword(password);
|
||||
sd.setEmail(email);
|
||||
sd.setMedicalSpecialty(ms);
|
||||
|
||||
entman.persist(sd);
|
||||
|
||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail());
|
||||
}
|
||||
|
||||
return sdTO;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO updateFamilyDoctorData(String id, String nif, String name, String surname, String password, String email, String cap) {
|
||||
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, id);
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
if (fd != null) {
|
||||
fd.setNif(nif);
|
||||
fd.setName(name);
|
||||
fd.setSurname(surname);
|
||||
fd.setPassword(password);
|
||||
fd.setEmail(email);
|
||||
|
||||
// TODO: Es posible actualizar el cap? ¿No debería utilizar el método
|
||||
// changePrimaryHealthCareCenter?
|
||||
// cap debería ser PrimaryHealthCareCenterTO newCenter
|
||||
// fd.setPrimaryHealthCareCenter(cap);
|
||||
|
||||
entman.persist(fd);
|
||||
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail());
|
||||
}
|
||||
|
||||
return fdTO;
|
||||
}
|
||||
|
||||
public FamilyDoctorTO changePrimaryHealthCareCenter(String FamilyDoctorId, PrimaryHealthCareCenterTO newCenter) {
|
||||
FamilyDoctorTO fdTO = null;
|
||||
|
||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, newCenter);
|
||||
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, FamilyDoctorId);
|
||||
|
||||
if (phcC != null && fd != null) {
|
||||
fd.setPrimaryHealthCareCenter(phcC);
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail());
|
||||
|
||||
}
|
||||
|
||||
return fdTO;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,17 +2,35 @@ package ejb.profile;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import TO.FamilyDoctorTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
|
||||
/**
|
||||
* 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
|
||||
public interface ProfileFacadeRemote {
|
||||
/**
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
public void ejbMethod(String parameter);
|
||||
|
||||
public PatientTO changeFamilyDoctor(String id, String ProfessionalNumberId);
|
||||
|
||||
public PatientTO registerPacient(String 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,
|
||||
MedicalSpecialtyTO specialty);
|
||||
|
||||
public FamilyDoctorTO registerFamilyDoctor1(String 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 SpecialistDoctorTO updateSpecialistDoctorData(String 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 changePrimaryHealthCareCenter(String id, PrimaryHealthCareCenterTO newCenter);
|
||||
}
|
||||
Reference in New Issue
Block a user