Cambiadas todas las listas deplegables fijas, a listas con búsqueda AJAX
integrada (Estilo typeahead). Permite búsquedas en tiempo real. * Se muestra información organizada por columnas de datos. * Identificadores basados en Ids autogenerados. * Nuevos métodos en EJB común para poder realizar búsquedas de datos con filtro y paginadas (para los comboBox). * Varias correcciones de interfaz de usuario. * Nueva clase de utilidades.
This commit is contained in:
@@ -2,17 +2,20 @@ package ejb.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import TO.FamilyDoctorTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.Utils;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
import jpa.PatientJPA;
|
||||
@@ -28,8 +31,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
/**
|
||||
* Metodo que devuelve todas las especialidades medicas
|
||||
*/
|
||||
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities() {
|
||||
return this.listPagedMedicalSpecialities(0, 0);
|
||||
public List<MedicalSpecialtyTO> listAllMedicalSpecialities() {
|
||||
return this.listMedicalSpecialitiesPaged(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,54 +42,106 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
* cada página
|
||||
*
|
||||
*/
|
||||
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize) {
|
||||
Query query = entman.createQuery("from MedicalSpecialtyJPA order by name");
|
||||
public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize) {
|
||||
return listMedicalSpecialitiesFiltered(null, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
public List<MedicalSpecialtyTO> listMedicalSpecialitiesFiltered(String searchTerm, int pageNumber, int pageSize) {
|
||||
String strQuery = "SELECT ms from MedicalSpecialtyJPA ms %s order by ms.name, ms.description";
|
||||
String strFilter = "";
|
||||
if (searchTerm == null)
|
||||
searchTerm = "";
|
||||
else
|
||||
searchTerm = Utils.stripAccents(searchTerm).toLowerCase();
|
||||
|
||||
if (searchTerm.length() > 0) {
|
||||
strFilter = "WHERE lower(ms.name) LIKE :searchTerm OR lower(ms.description) LIKE :searchTerm";
|
||||
}
|
||||
|
||||
TypedQuery<MedicalSpecialtyJPA> query = entman.createQuery(String.format(strQuery, strFilter), MedicalSpecialtyJPA.class);
|
||||
|
||||
if (searchTerm.length() > 0)
|
||||
query.setParameter("searchTerm", "%" + searchTerm + "%");
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<MedicalSpecialtyJPA> allJPA = query.getResultList();
|
||||
Collection<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
|
||||
List<MedicalSpecialtyJPA> allJPA = query.getResultList();
|
||||
List<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
|
||||
|
||||
for (MedicalSpecialtyJPA ms : allJPA) {
|
||||
allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription()));
|
||||
for (MedicalSpecialtyJPA cap : allJPA) {
|
||||
allSpecialities.add(new MedicalSpecialtyTO(cap.getId(), cap.getName(), cap.getDescription()));
|
||||
}
|
||||
|
||||
return allSpecialities;
|
||||
}
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listAllCAPs() {
|
||||
return this.listPagedAllCAPs(0, 0);
|
||||
public List<PrimaryHealthCareCenterTO> listAllCAPs() {
|
||||
return this.listCAPsPaged(0, 0);
|
||||
}
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize) {
|
||||
Query query = entman.createQuery("from PrimaryHealthCareCenterJPA order by name");
|
||||
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize) {
|
||||
return this.listCAPsFiltered(null, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
public List<PrimaryHealthCareCenterTO> listCAPsFiltered(String searchTerm, int pageNumber, int pageSize) {
|
||||
String strQuery = "SELECT phc from PrimaryHealthCareCenterJPA phc %s order by phc.name, phc.location";
|
||||
String strFilter = "";
|
||||
if (searchTerm == null)
|
||||
searchTerm = "";
|
||||
else
|
||||
searchTerm = Utils.stripAccents(searchTerm).toLowerCase();
|
||||
|
||||
if (searchTerm.length() > 0) {
|
||||
strFilter = "WHERE lower(phc.name) LIKE :searchTerm OR lower(phc.location) LIKE :searchTerm";
|
||||
}
|
||||
|
||||
TypedQuery<PrimaryHealthCareCenterJPA> query = entman.createQuery(String.format(strQuery, strFilter), PrimaryHealthCareCenterJPA.class);
|
||||
|
||||
if (searchTerm.length() > 0)
|
||||
query.setParameter("searchTerm", "%" + searchTerm + "%");
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
|
||||
Collection<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
|
||||
List<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
|
||||
List<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
|
||||
|
||||
for (PrimaryHealthCareCenterJPA cap : allJPA) {
|
||||
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation()));
|
||||
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getId(), cap.getName(), cap.getLocation()));
|
||||
}
|
||||
|
||||
return allCAPs;
|
||||
}
|
||||
|
||||
public Collection<FamilyDoctorTO> listAllFamilyDoctors() {
|
||||
return this.listAllFamilyDoctors(0, 0);
|
||||
public List<FamilyDoctorTO> listAllFamilyDoctors() {
|
||||
return this.listFamilyDoctorsPaged(0, 0);
|
||||
}
|
||||
|
||||
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize) {
|
||||
Query query = entman.createQuery("from FamilyDoctorJPA order by name, surname");
|
||||
public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize) {
|
||||
return this.listFamilyDoctorsFiltered(null, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize) {
|
||||
String strQuery = "SELECT fd FROM FamilyDoctorJPA fd %s order by fd.name, fd.surname";
|
||||
String strFilter = "";
|
||||
if (searchTerm == null)
|
||||
searchTerm = "";
|
||||
else
|
||||
searchTerm = Utils.stripAccents(searchTerm).toLowerCase();
|
||||
|
||||
if (searchTerm.length() > 0) {
|
||||
strFilter = "WHERE lower(fd.name) LIKE :searchTerm OR lower(fd.surname) LIKE :searchTerm";
|
||||
}
|
||||
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery(String.format(strQuery, strFilter), FamilyDoctorJPA.class);
|
||||
|
||||
if (searchTerm.length() > 0)
|
||||
query.setParameter("searchTerm", "%" + searchTerm + "%");
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
@@ -94,14 +149,14 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<FamilyDoctorJPA> allFDsJPA = query.getResultList();
|
||||
Collection<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
|
||||
List<FamilyDoctorJPA> allFDsJPA = query.getResultList();
|
||||
List<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
|
||||
|
||||
for (FamilyDoctorJPA item : allFDsJPA) {
|
||||
allFDTOs.add(new FamilyDoctorTO(item.getId(), item.getNif(), item.getName(), item.getSurname(), item.getPassword(), item.getEmail(), null));
|
||||
}
|
||||
|
||||
return allFDTOs;
|
||||
return allFDTOs;
|
||||
}
|
||||
|
||||
public PatientTO retrievePatient(int patientId) throws Exception {
|
||||
@@ -129,7 +184,7 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
|
||||
PrimaryHealthCareCenterTO phc = null;
|
||||
if (fd.getPrimaryHealthCareCenter() != null)
|
||||
phc = new PrimaryHealthCareCenterTO(fd.getPrimaryHealthCareCenter().getName(), fd.getPrimaryHealthCareCenter().getLocation());
|
||||
phc = new PrimaryHealthCareCenterTO(fd.getPrimaryHealthCareCenter().getId(), fd.getPrimaryHealthCareCenter().getName(), fd.getPrimaryHealthCareCenter().getLocation());
|
||||
|
||||
FamilyDoctorTO fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phc);
|
||||
return fdTO;
|
||||
@@ -144,7 +199,7 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
|
||||
MedicalSpecialtyTO ms = null;
|
||||
if (sd.getMedicalSpecialty() != null)
|
||||
ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription());
|
||||
ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getId(), sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription());
|
||||
|
||||
SpecialistDoctorTO sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), ms);
|
||||
return sdTO;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ejb.common;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
@@ -18,18 +19,24 @@ import TO.SpecialistDoctorTO;
|
||||
@Local
|
||||
public interface CommonFacadeLocal {
|
||||
|
||||
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
|
||||
public List<MedicalSpecialtyTO> listAllMedicalSpecialities();
|
||||
|
||||
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize);
|
||||
public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize);
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize);
|
||||
public List<MedicalSpecialtyTO> listMedicalSpecialitiesFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public List<PrimaryHealthCareCenterTO> listAllCAPs();
|
||||
|
||||
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize);
|
||||
|
||||
public List<PrimaryHealthCareCenterTO> listCAPsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public List<FamilyDoctorTO> listAllFamilyDoctors();
|
||||
|
||||
public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize);
|
||||
|
||||
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public Collection<FamilyDoctorTO> listAllFamilyDoctors();
|
||||
|
||||
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize);
|
||||
|
||||
public PatientTO retrievePatient(int patientId) throws Exception;
|
||||
|
||||
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ejb.common;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
@@ -18,18 +19,24 @@ import TO.SpecialistDoctorTO;
|
||||
@Remote
|
||||
public interface CommonFacadeRemote {
|
||||
|
||||
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
|
||||
public List<MedicalSpecialtyTO> listAllMedicalSpecialities();
|
||||
|
||||
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize);
|
||||
public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize);
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
|
||||
|
||||
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize);
|
||||
public List<MedicalSpecialtyTO> listMedicalSpecialitiesFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public List<PrimaryHealthCareCenterTO> listAllCAPs();
|
||||
|
||||
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize);
|
||||
|
||||
public List<PrimaryHealthCareCenterTO> listCAPsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public List<FamilyDoctorTO> listAllFamilyDoctors();
|
||||
|
||||
public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize);
|
||||
|
||||
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public Collection<FamilyDoctorTO> listAllFamilyDoctors();
|
||||
|
||||
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize);
|
||||
|
||||
public PatientTO retrievePatient(int patientId) throws Exception;
|
||||
|
||||
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception;
|
||||
|
||||
Reference in New Issue
Block a user