Organización de controles en la pantalla de alta de administradores.
Conversión a minusculas de la dirección de email de los administradores.
This commit is contained in:
@@ -10,41 +10,53 @@
|
||||
<p:growl id="mesgsAdd" showDetail="true" closable="true" autoupdate="true" />
|
||||
<p:panel id="PanelNewAdmin" header="Alta de administradores">
|
||||
<div class="ui-g ui-fluid">
|
||||
<div class="ui-g-1 ui-md-1">
|
||||
<div class="ui-g-2">
|
||||
<p:outputLabel value="Correo electrónico: " for="email" />
|
||||
</div>
|
||||
<div class="ui-g-3 ui-md-3">
|
||||
<p:inputText id="email" value="#{AddAdmin.email}" required="true" maxlength="120" validator="emailValidator"
|
||||
validatorMessage="La dirección de correo electrónico #{AddAdmin.email} no es válida" requiredMessage="Por favor, especifique su correo electrónico">
|
||||
<div class="ui-g-4">
|
||||
<p:inputText id="email" value="#{AddAdmin.email}" required="true" maxlength="120" validator="emailValidator" requiredMessage="Por favor, especifique su correo electrónico">
|
||||
<f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
|
||||
<f:validator validatorId="emailValidator" for="email">
|
||||
<f:attribute name="managedBean" value="#{AddAdmin}" />
|
||||
</f:validator>
|
||||
</p:inputText>
|
||||
</div>
|
||||
<div class="ui-g-1 ui-md-1">
|
||||
<div class="ui-g-6">
|
||||
<p:message for="email" />
|
||||
</div>
|
||||
|
||||
<div class="ui-g-2">
|
||||
<p:outputLabel value="Contraseña: " for="password" />
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<div class="ui-g-4">
|
||||
<p:password id="password" value="#{AddAdmin.password}" match="passwordRepeat" required="true" maxlength="100" requiredMessage="Por favor, especifique una contraseña"
|
||||
feedback="true" promptLabel="Especifique una contraseña segura" weakLabel="La contraseña es débil" goodLabel="La contraseña es buena" strongLabel="La contraseña es segura"
|
||||
validatorMessage="La contraseña y su verificación deben ser iguales" />
|
||||
</div>
|
||||
<div class="ui-g-1 ui-md-1">
|
||||
<p:outputLabel value="Verificación de contraseña: " for="passwordRepeat" />
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:password id="passwordRepeat" value="#{AddAdmin.password}" required="true" maxlength="100" requiredMessage="Por favor, escriba la verificación de su contraseña" />
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2 ">
|
||||
<p:commandButton validateClient="true" value="Crear" update="frmAddAdmin" action="#{AddAdmin.insertData}" icon="pi pi-check" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:message for="email" />
|
||||
</div>
|
||||
<div class="ui-g-3 ui-md-3">
|
||||
<div class="ui-g-6">
|
||||
<p:message for="password" />
|
||||
</div>
|
||||
<div class="ui-g-3 ui-md-3">
|
||||
|
||||
<div class="ui-g-2">
|
||||
<p:outputLabel value="Verificación de contraseña: " for="passwordRepeat" />
|
||||
</div>
|
||||
<div class="ui-g-4">
|
||||
<p:password id="passwordRepeat" value="#{AddAdmin.password}" required="true" maxlength="100" requiredMessage="Por favor, escriba la verificación de su contraseña" />
|
||||
</div>
|
||||
<div class="ui-g-6">
|
||||
<p:message for="passwordRepeat" />
|
||||
</div>
|
||||
|
||||
<div class="ui-g-12 ui-g-nopad">
|
||||
<div class="ui-g-4 ui-md-4"></div>
|
||||
<div class="ui-g-2 ui-md-2 ">
|
||||
<p:commandButton validateClient="true" value="Crear" update="frmAddAdmin" action="#{AddAdmin.insertData}" icon="pi pi-check" />
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4"></div>
|
||||
</div>
|
||||
</div>
|
||||
</p:panel>
|
||||
</h:form>
|
||||
|
||||
@@ -112,7 +112,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return usr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MedicalSpecialtyTO updateSpecialty(int id, String name, String description) throws Exception {
|
||||
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, id);
|
||||
|
||||
@@ -140,7 +139,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSpecialty(int id) throws Exception {
|
||||
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, id);
|
||||
|
||||
@@ -151,7 +149,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
entman.remove(ms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MedicalSpecialtyTO insertSpecialty(String name, String description) throws Exception {
|
||||
MedicalSpecialtyJPA ms = new MedicalSpecialtyJPA(name, description);
|
||||
entman.persist(ms);
|
||||
@@ -159,7 +156,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return this.commonServices.getPOJOforMedicalSpecialtyJPA(ms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryHealthCareCenterTO updateHealthCareCenter(int id, String name, String location) throws Exception {
|
||||
PrimaryHealthCareCenterJPA ms = entman.find(PrimaryHealthCareCenterJPA.class, id);
|
||||
|
||||
@@ -175,7 +171,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return this.commonServices.getPOJOforPrimaryHealthCareCenterJPA(ms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryHealthCareCenterTO findHealthCareCenterByName(String searchedName) {
|
||||
TypedQuery<PrimaryHealthCareCenterJPA> query = entman.createQuery("from PrimaryHealthCareCenterJPA cap where cap.name=:name", PrimaryHealthCareCenterJPA.class);
|
||||
query.setMaxResults(1);
|
||||
@@ -188,7 +183,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteHealthCareCenter(int id) throws Exception {
|
||||
PrimaryHealthCareCenterJPA cap = entman.find(PrimaryHealthCareCenterJPA.class, id);
|
||||
|
||||
@@ -199,7 +193,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
entman.remove(cap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryHealthCareCenterTO insertHealthCareCenter(String name, String location) throws Exception {
|
||||
PrimaryHealthCareCenterJPA cap = new PrimaryHealthCareCenterJPA(name, location);
|
||||
entman.persist(cap);
|
||||
@@ -207,14 +200,12 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return this.commonServices.getPOJOforPrimaryHealthCareCenterJPA(cap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCAPCount() {
|
||||
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from PrimaryHealthCareCenterJPA", Long.class);
|
||||
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize) {
|
||||
TypedQuery<PrimaryHealthCareCenterJPA> query = entman.createQuery("SELECT c from PrimaryHealthCareCenterJPA c order by c.name", PrimaryHealthCareCenterJPA.class);
|
||||
|
||||
@@ -233,7 +224,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return caps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FamilyDoctorTO> listAllFamilyDoctorsByCAPPaged(int primaryHealthCareCenterId, int pageNumber, int pageSize) {
|
||||
List<FamilyDoctorTO> familyDoctorsByCAP = new ArrayList<FamilyDoctorTO>();
|
||||
|
||||
@@ -254,8 +244,7 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
|
||||
return familyDoctorsByCAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Long getPatientCount(int familyDoctorId) {
|
||||
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from PatientJPA p where p.familyDoctor.id=:familyDoctorId", Long.class);
|
||||
query.setParameter("familyDoctorId", familyDoctorId);
|
||||
@@ -263,7 +252,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemAdminTO findAdminByEmail(String email) {
|
||||
TypedQuery<SystemAdminJPA> query = entman.createQuery("from SystemAdminJPA a where a.email=:email", SystemAdminJPA.class);
|
||||
query.setMaxResults(1);
|
||||
@@ -276,7 +264,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemAdminTO insertAdmin(String email, String password) throws Exception {
|
||||
SystemAdminJPA admin = new SystemAdminJPA(email, password);
|
||||
entman.persist(admin);
|
||||
|
||||
@@ -56,17 +56,24 @@ public class AddAdminMBean extends ManagedBeanBase implements Serializable {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public boolean emailAlreadyRegistered(String email) {
|
||||
return this.getRemoteManagerSystemAdmin().findAdminByEmail(email) != null;
|
||||
}
|
||||
|
||||
public void insertData() {
|
||||
int error = 0;
|
||||
|
||||
if (this.getRemoteManagerSystemAdmin().findAdminByEmail(email) != null) {
|
||||
if (this.emailAlreadyRegistered(email) == true) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Administrador ya existente", "El administrador ya se encuentra dado de alta");
|
||||
error++;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
this.getRemoteManagerSystemAdmin().insertAdmin(email, HashUtils.hashMD5(password));
|
||||
this.getRemoteManagerSystemAdmin().insertAdmin(email.toLowerCase(), HashUtils.hashMD5(password));
|
||||
|
||||
this.email = "";
|
||||
this.password = "";
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "El administrador se ha dado de alta", "Los datos del administrador se han guardado correctamente.");
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user