Ejemplo de paginación (Listado de preguntas pendientes) con primefaces
utilizando LazyDataModel, con recarga automática de la página solicitada.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
@@ -28,7 +28,7 @@ public class FamilyDoctorJPA implements Serializable {
|
||||
|
||||
@Id
|
||||
@Column(updatable = false)
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
@Column(nullable = false, unique = true)
|
||||
private String professionalNumber;
|
||||
@@ -39,9 +39,9 @@ public class FamilyDoctorJPA implements Serializable {
|
||||
private String email;
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "FamilyDoctorId")
|
||||
private Collection<PatientJPA> patients;
|
||||
private List<PatientJPA> patients;
|
||||
@ManyToOne
|
||||
@JoinColumn (name="PrimaryHealthCareCenterId")
|
||||
@JoinColumn(name = "PrimaryHealthCareCenterId")
|
||||
private PrimaryHealthCareCenterJPA primaryHealthCareCenter;
|
||||
|
||||
/**
|
||||
@@ -111,20 +111,22 @@ public class FamilyDoctorJPA implements Serializable {
|
||||
|
||||
/**
|
||||
* Metodos para get/set de relaciones (pacientes)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<PatientJPA> getPatients() {
|
||||
public List<PatientJPA> getPatients() {
|
||||
return patients;
|
||||
}
|
||||
|
||||
public void setPatients(Collection<PatientJPA> patients) {
|
||||
public void setPatients(List<PatientJPA> patients) {
|
||||
this.patients = patients;
|
||||
}
|
||||
|
||||
|
||||
public PrimaryHealthCareCenterJPA getPrimaryHealthCareCenter() {
|
||||
return primaryHealthCareCenter;
|
||||
}
|
||||
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) {
|
||||
|
||||
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) {
|
||||
this.primaryHealthCareCenter = center;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
@@ -12,11 +14,12 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import common.TestType;
|
||||
|
||||
/**
|
||||
* Los nombres de los decortadores relacionados con la BBDD pueden estar
|
||||
* en camelCase, snakeCase o como se quiera, puesto que en persistence.xml
|
||||
* se tiene dicho que se convierta a minúsculas.
|
||||
* Los nombres de los decortadores relacionados con la BBDD pueden estar en
|
||||
* camelCase, snakeCase o como se quiera, puesto que en persistence.xml se tiene
|
||||
* dicho que se convierta a minúsculas.
|
||||
*
|
||||
* Lo uso en minúsculas para mejorar la trazabilidad de los campos.
|
||||
*
|
||||
@@ -30,29 +33,30 @@ public class MedicalTestJPA implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
private Date date;
|
||||
private long time;
|
||||
private String observations;
|
||||
private String highresimage;
|
||||
@Column(name = "type") // Con esto podríamos cambiar los nombres de las propiedades de la clase y mantener la relación con la BBDD a través de JPA
|
||||
private int type;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "type") // Con esto podríamos cambiar los nombres de las propiedades de la clase y
|
||||
// mantener la relación con la BBDD a través de JPA
|
||||
private TestType type;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn (name="patientid")
|
||||
@JoinColumn(name = "patientid")
|
||||
private PatientJPA patient;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn (name="specialistdoctorid")
|
||||
@JoinColumn(name = "specialistdoctorid")
|
||||
private SpecialistDoctorJPA specialistDoctor;
|
||||
|
||||
public MedicalTestJPA() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MedicalTestJPA(int id, Date date, long time, String observations, String highresimage, int type,
|
||||
PatientJPA patient, SpecialistDoctorJPA specialistDoctor) {
|
||||
|
||||
public MedicalTestJPA(int id, Date date, long time, String observations, String highresimage, TestType type, PatientJPA patient, SpecialistDoctorJPA specialistDoctor) {
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
this.time = time;
|
||||
@@ -103,11 +107,11 @@ public class MedicalTestJPA implements Serializable {
|
||||
this.highresimage = highresimage;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
public TestType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
public void setType(TestType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -127,6 +131,4 @@ public class MedicalTestJPA implements Serializable {
|
||||
this.specialistDoctor = specialistDoctor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package jpa;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
@@ -29,28 +31,28 @@ public class QuestionJPA implements Serializable {
|
||||
private int id;
|
||||
private String title;
|
||||
private String message;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private QuestionStatus status;
|
||||
private String response;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "patientid")
|
||||
private PatientJPA patient;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "familydoctorid")
|
||||
private FamilyDoctorJPA familydoctor;
|
||||
private FamilyDoctorJPA familyDoctor;
|
||||
|
||||
public QuestionJPA() {
|
||||
}
|
||||
|
||||
public QuestionJPA(int id, String title, String message, QuestionStatus status, PatientJPA patient,
|
||||
FamilyDoctorJPA familydoctor, String response) {
|
||||
public QuestionJPA(int id, String title, String message, QuestionStatus status, PatientJPA patient, FamilyDoctorJPA familydoctor, String response) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
this.status = status;
|
||||
this.patient = patient;
|
||||
this.familydoctor = familydoctor;
|
||||
this.familyDoctor = familydoctor;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
@@ -94,12 +96,12 @@ public class QuestionJPA implements Serializable {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public FamilyDoctorJPA getDoctor() {
|
||||
return familydoctor;
|
||||
public FamilyDoctorJPA getFamilyDoctor() {
|
||||
return familyDoctor;
|
||||
}
|
||||
|
||||
public void setDoctor(FamilyDoctorJPA familydoctor) {
|
||||
this.familydoctor = familydoctor;
|
||||
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
|
||||
this.familyDoctor = familyDoc;
|
||||
}
|
||||
|
||||
public String getResponse() {
|
||||
|
||||
Reference in New Issue
Block a user