Skip to content

Commit

Permalink
corrections champs nom et prenom
Browse files Browse the repository at this point in the history
  • Loading branch information
khergalant committed Nov 13, 2024
1 parent ba653a2 commit 0590761
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 38 deletions.
45 changes: 35 additions & 10 deletions src/main/java/fr/univlorraine/ecandidat/config/LaunchAppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
import fr.univlorraine.ecandidat.controllers.LockCandidatController;
import fr.univlorraine.ecandidat.controllers.NomenclatureController;
import fr.univlorraine.ecandidat.entities.ecandidat.Adresse;
import fr.univlorraine.ecandidat.entities.ecandidat.Adresse_;
import fr.univlorraine.ecandidat.entities.ecandidat.Candidat;
import fr.univlorraine.ecandidat.entities.ecandidat.Candidat_;
import fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima;
import fr.univlorraine.ecandidat.entities.ecandidat.CompteMinima_;
import fr.univlorraine.ecandidat.services.siscol.SiScolGenericService;
import fr.univlorraine.ecandidat.utils.ConstanteUtils;
import fr.univlorraine.ecandidat.utils.MethodUtils;
Expand Down Expand Up @@ -157,27 +162,47 @@ public void preprocessTemplate() {
/** Modifie la valeur de certaines annotations */
public void preprocessAnnotations() {
try {
final int size = siScolService.getSizeFieldAdresse();
if (size != ConstanteUtils.SIZE_FIELD_ADRESSE_DEFAULT) {
logger.info("Modification des annotations adresse, size = " + size);
changeAnnotationAdresse(Adresse.FIELD_ADR1, size);
changeAnnotationAdresse(Adresse.FIELD_ADR2, size);
changeAnnotationAdresse(Adresse.FIELD_ADR3, size);
changeAnnotationAdresse(Adresse.FIELD_LIB_COM_ETR, size);
/* Adresse */
final int sizeChampsAdr = siScolService.getSizeFieldAdresse();
if (sizeChampsAdr != ConstanteUtils.SIZE_FIELD_ADRESSE_DEFAULT) {
logger.info("Modification des annotations adresse, size = " + sizeChampsAdr);
changeAnnotation(Adresse.class, Adresse_.ADR1_ADR, sizeChampsAdr);
changeAnnotation(Adresse.class, Adresse_.ADR2_ADR, sizeChampsAdr);
changeAnnotation(Adresse.class, Adresse_.ADR3_ADR, sizeChampsAdr);
changeAnnotation(Adresse.class, Adresse_.LIB_COM_ETR_ADR, sizeChampsAdr);
}

/* Noms */
final int sizeChampsNom = siScolService.getSizeFieldNom();
if (sizeChampsNom != ConstanteUtils.SIZE_FIELD_NOM_DEFAULT) {
logger.info("Modification des annotations noms, size = " + sizeChampsNom);
changeAnnotation(CompteMinima.class, CompteMinima_.NOM_CPT_MIN, sizeChampsNom);
changeAnnotation(Candidat.class, Candidat_.NOM_PAT_CANDIDAT, sizeChampsNom);
changeAnnotation(Candidat.class, Candidat_.NOM_USU_CANDIDAT, sizeChampsNom);
}

/* Prenoms */
final int sizeChampsPrenom = siScolService.getSizeFieldPrenom();
if (sizeChampsPrenom != ConstanteUtils.SIZE_FIELD_PRENOM_DEFAULT) {
logger.info("Modification des annotations prenom, size = " + sizeChampsPrenom);
changeAnnotation(CompteMinima.class, CompteMinima_.PRENOM_CPT_MIN, sizeChampsPrenom);
changeAnnotation(Candidat.class, Candidat_.PRENOM_CANDIDAT, sizeChampsPrenom);
changeAnnotation(Candidat.class, Candidat_.AUTRE_PREN_CANDIDAT, sizeChampsPrenom);
}

} catch (final Exception e) {
logger.warn("Erreur a la modification des annotations", e);
}
}

/**
* Modifie la taille des champs d'adresse
* Modifie la taille des champs
* @param fieldName
* @throws Exception
*/
private void changeAnnotationAdresse(final String fieldName, final int size) throws Exception {
private void changeAnnotation(final Class<?> clazz, final String fieldName, final int size) throws Exception {
try {
final Field field = Adresse.class.getDeclaredField(fieldName);
final Field field = clazz.getDeclaredField(fieldName);

final Column fieldAnnotationColumn = field.getAnnotation(Column.class);
MethodUtils.changeAnnotationValue(fieldAnnotationColumn, "length", size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
@SuppressWarnings("serial")
public class Adresse implements Serializable {

public static final String FIELD_ADR1 = "adr1Adr";
public static final String FIELD_ADR2 = "adr2Adr";
public static final String FIELD_ADR3 = "adr3Adr";
public static final String FIELD_LIB_COM_ETR = "libComEtrAdr";

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_adr", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public class Candidat implements Serializable {
@NotNull
private String typSiScol;

@Column(name = "autre_pren_candidat", length = 100)
@Size(max = 100)
@Column(name = "autre_pren_candidat", length = 20)
@Size(max = 20)
private String autrePrenCandidat;

@Convert(converter = LocalDatePersistenceConverter.class)
Expand All @@ -83,17 +83,17 @@ public class Candidat implements Serializable {
@Size(max = 30)
private String libVilleNaissCandidat;

@Column(name = "nom_pat_candidat", nullable = false, length = 100)
@Size(max = 100)
@Column(name = "nom_pat_candidat", nullable = false, length = 30)
@Size(max = 30)
@NotNull
private String nomPatCandidat;

@Column(name = "nom_usu_candidat", length = 100)
@Size(max = 100)
@Column(name = "nom_usu_candidat", length = 30)
@Size(max = 30)
private String nomUsuCandidat;

@Column(name = "prenom_candidat", nullable = false, length = 100)
@Size(max = 100)
@Column(name = "prenom_candidat", nullable = false, length = 20)
@Size(max = 20)
@NotNull
private String prenomCandidat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public class CompteMinima implements Serializable {
@NotNull
private String mailPersoCptMin;

@Column(name = "nom_cpt_min", nullable = false, length = 100)
@Size(max = 100)
@Column(name = "nom_cpt_min", nullable = false, length = 30)
@Size(max = 30)
@NotNull
private String nomCptMin;

Expand All @@ -85,8 +85,8 @@ public class CompteMinima implements Serializable {
@NotNull
private String numDossierOpiCptMin;

@Column(name = "prenom_cpt_min", nullable = false, length = 100)
@Size(max = 100)
@Column(name = "prenom_cpt_min", nullable = false, length = 20)
@Size(max = 20)
@NotNull
private String prenomCptMin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1906,9 +1906,4 @@ public Boolean hasCheckStudentINES() {
public Boolean hasRegStu() {
return parametreController.getIsUtiliseRegStu();
}

@Override
public int getSizeFieldAdresse() {
return ConstanteUtils.SIZE_FIELD_ADRESSE_DEFAULT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,4 @@ public String checkBacSpecialiteOption(final CandidatBacOuEqu bac) {
public Boolean hasSpecialiteRequired() {
return false;
}

@Override
public int getSizeFieldAdresse() {
return ConstanteUtils.SIZE_FIELD_ADRESSE_DEFAULT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import fr.univlorraine.ecandidat.entities.siscol.apogee.Diplome;
import fr.univlorraine.ecandidat.entities.siscol.apogee.Vet;
import fr.univlorraine.ecandidat.entities.siscol.pegase.FormationPegase;
import fr.univlorraine.ecandidat.utils.ConstanteUtils;
import fr.univlorraine.ecandidat.utils.NomenclatureUtils;
import fr.univlorraine.ecandidat.utils.bean.presentation.FileOpi;

Expand Down Expand Up @@ -354,12 +355,29 @@ default void deleteFileOpi(final List<FileOpi> listFileOpi) {
/**
* @return la taille des champs d'adresse
*/
int getSizeFieldAdresse();
default int getSizeFieldAdresse() {
return ConstanteUtils.SIZE_FIELD_ADRESSE_DEFAULT;
}

/**
* @return la taille des champs nom
*/
default int getSizeFieldNom() {
return ConstanteUtils.SIZE_FIELD_NOM_DEFAULT;
}

/**
* @return la taille des champs prenom
*/
default int getSizeFieldPrenom() {
return ConstanteUtils.SIZE_FIELD_PRENOM_DEFAULT;
}

/**
* @return true si a un bac à sable (si oui la synchro de l'étudiant est activée)
*/
default Boolean hasBacASable() {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1108,4 +1108,14 @@ public List<SiScolStatut> getListStatut() throws SiScolException {
public int getSizeFieldAdresse() {
return ConstanteUtils.SIZE_FIELD_ADRESSE_PEGASE;
}

@Override
public int getSizeFieldNom() {
return ConstanteUtils.SIZE_FIELD_NOM_PRENOM_PEGASE;
}

@Override
public int getSizeFieldPrenom() {
return ConstanteUtils.SIZE_FIELD_NOM_PRENOM_PEGASE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public class ConstanteUtils {
public static final int SIZE_FIELD_ADRESSE_DEFAULT = 32;
public static final int SIZE_FIELD_ADRESSE_PEGASE = 38;

/* Taille des champs nom-prenom par défaut */
public static final int SIZE_FIELD_NOM_DEFAULT = 30;
public static final int SIZE_FIELD_PRENOM_DEFAULT = 20;
public static final int SIZE_FIELD_NOM_PRENOM_PEGASE = 100;

/* Taille max du param de la taille max d'une PJ */
public static final Integer SIZE_MAX_PARAM_MAX_FILE_PJ = 10;

Expand Down

0 comments on commit 0590761

Please sign in to comment.