* 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).
129 lines
2.7 KiB
Java
129 lines
2.7 KiB
Java
package jpa;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.Collection;
|
|
|
|
import javax.persistence.CascadeType;
|
|
import javax.persistence.Entity;
|
|
import javax.persistence.FetchType;
|
|
import javax.persistence.GeneratedValue;
|
|
import javax.persistence.GenerationType;
|
|
import javax.persistence.Id;
|
|
import javax.persistence.JoinColumn;
|
|
import javax.persistence.ManyToOne;
|
|
import javax.persistence.OneToMany;
|
|
import javax.persistence.Table;
|
|
|
|
/**
|
|
*
|
|
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
|
*
|
|
*/
|
|
@Entity
|
|
@Table(name = "MyHealth.FamilyDoctor")
|
|
public class FamilyDoctorJPA implements Serializable {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Id
|
|
private Integer id;
|
|
private String nif;
|
|
private String name;
|
|
private String surname;
|
|
private String password;
|
|
private String email;
|
|
private Collection<PatientJPA> patients;
|
|
private PrimaryHealthCareCenterJPA primaryHealthCareCenter;
|
|
|
|
/**
|
|
* Class constructor methods
|
|
*/
|
|
public FamilyDoctorJPA() {
|
|
super();
|
|
}
|
|
|
|
public FamilyDoctorJPA(Integer id, String nif, String name, String surname, String password, String email) {
|
|
this.id = id;
|
|
this.nif = nif;
|
|
this.name = name;
|
|
this.surname = surname;
|
|
this.password = password;
|
|
this.email = email;
|
|
}
|
|
|
|
@Id
|
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
|
public Integer getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Integer value) {
|
|
this.id = value;
|
|
}
|
|
|
|
public String getNif() {
|
|
return nif;
|
|
}
|
|
|
|
public void setNif(String value) {
|
|
this.nif = value;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String value) {
|
|
this.name = value;
|
|
}
|
|
|
|
public String getSurname() {
|
|
return surname;
|
|
}
|
|
|
|
public void setSurname(String surname) {
|
|
this.surname = surname;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* Metodos para get/set de relaciones (pacientes)
|
|
* @return
|
|
*/
|
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
|
@JoinColumn(name = "FamilyDoctorId")
|
|
public Collection<PatientJPA> getPatients() {
|
|
return patients;
|
|
}
|
|
|
|
public void setPatients(Collection<PatientJPA> patients) {
|
|
this.patients = patients;
|
|
}
|
|
|
|
@ManyToOne
|
|
@JoinColumn (name="PrimaryHealthCareCenterId")
|
|
public PrimaryHealthCareCenterJPA getPrimaryHealthCareCenter() {
|
|
return primaryHealthCareCenter;
|
|
}
|
|
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) {
|
|
this.primaryHealthCareCenter = center;
|
|
}
|
|
}
|
|
|
|
|