Skip to content

Commit

Permalink
ajout des spé 2I2D
Browse files Browse the repository at this point in the history
  • Loading branch information
Numero7 committed Nov 19, 2024
1 parent c9f6a18 commit 9ae2abd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ public record Specialites(
public static final String SPEC_AMC_MPS_KEY = idPsupMatToIdMps(20001076);
public static final String SPEC_AMC_MPS_LABEL = "Anglais Monde Contemporain (AMC)";

public static final int SPEC_2I2D_CODE_PSUP = 1096;
//SIN, AC, ITEC, EE
public static final String SPEC_2I2D_SIN_MPS_KEY = "sp340";
public static final String SPEC_2I2D_SIN_MPS_LABEL = "2I2D - SIN - Systèmes d'information et numérique - en terminale";
public static final String SPEC_2I2D_AC_MPS_KEY = "sp337";
public static final String SPEC_2I2D_AC_MPS_LABEL = "2I2D - AC - Architecture et construction - en terminale";
public static final String SPEC_2I2D_ITEC_MPS_KEY = "sp339";
public static final String SPEC_2I2D_ITEC_MPS_LABEL = "2I2D - ITEC - Innovation, Technologique et Eco-Conception - en terminale";
public static final String SPEC_2I2D_EE_MPS_KEY = "sp338";
public static final String SPEC_2I2D_EE_MPS_LABEL = "2I2D - EE - Energie et environnement- en terminale";

public Specialites() {
this("", new HashMap<>(), new HashMap<>(), new HashMap<>(),new HashMap<>());
}
Expand Down Expand Up @@ -71,6 +82,11 @@ private void extendSpecialiteBac() {
if (specPsupIdStr.equals(idPsupMatToIdMps(SPEC_ANGLAIS_CODE_PSUP))) {
set.add(SPEC_LLCER_MPS_KEY);
set.add(SPEC_AMC_MPS_KEY);
} else if (specPsupIdStr.equals(idPsupMatToIdMps(SPEC_2I2D_CODE_PSUP))) {
set.add(SPEC_2I2D_AC_MPS_KEY);
set.add(SPEC_2I2D_SIN_MPS_KEY);
set.add(SPEC_2I2D_ITEC_MPS_KEY);
set.add(SPEC_2I2D_EE_MPS_KEY);
} else {
set.add(specPsupIdStr);
}
Expand All @@ -87,20 +103,27 @@ private void extendSpecialiteBac() {
public List<Specialite> toSpecialites() {
val result = new ArrayList<Specialite>();

//speBacs en premier, car écrasées par certaines eds
spesBacs().forEach((key, label) -> {
String mpsKey = idSpeBacPsupToIdMps(key);
result.add(new Specialite(mpsKey, key, label, true, getBacs(mpsKey)));
});

eds().forEach((key, value) -> {
if(key != SPEC_ANGLAIS_CODE_PSUP) {
val keyMps = idPsupMatToIdMps(key);
result.add(new Specialite(keyMps, key, value, true, getBacs(keyMps)));
} else {
if(key == SPEC_ANGLAIS_CODE_PSUP) {
result.add(new Specialite(SPEC_LLCER_MPS_KEY, key, SPEC_LLCER_MPS_LABEL, true, getBacs(SPEC_LLCER_MPS_KEY)));
result.add(new Specialite(SPEC_AMC_MPS_KEY, key, SPEC_AMC_MPS_LABEL, true, getBacs(SPEC_AMC_MPS_KEY)));
} else if(key == SPEC_2I2D_CODE_PSUP) {
result.add(new Specialite(SPEC_2I2D_AC_MPS_KEY, key, SPEC_2I2D_AC_MPS_LABEL, true, getBacs(SPEC_2I2D_AC_MPS_KEY)));
result.add(new Specialite(SPEC_2I2D_SIN_MPS_KEY, key, SPEC_2I2D_SIN_MPS_LABEL, true, getBacs(SPEC_2I2D_SIN_MPS_KEY)));
result.add(new Specialite(SPEC_2I2D_ITEC_MPS_KEY, key, SPEC_2I2D_ITEC_MPS_LABEL, true, getBacs(SPEC_2I2D_ITEC_MPS_KEY)));
result.add(new Specialite(SPEC_2I2D_EE_MPS_KEY, key, SPEC_2I2D_EE_MPS_LABEL, true, getBacs(SPEC_2I2D_EE_MPS_KEY)));
} else {
val keyMps = idPsupMatToIdMps(key);
result.add(new Specialite(keyMps, key, value, true, getBacs(keyMps)));
}
});

spesBacs().forEach((key, label) -> {
String mpsKey = idSpeBacPsupToIdMps(key);
result.add(new Specialite(mpsKey, key, label, true, getBacs(mpsKey)));
});

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import jakarta.persistence.Table
@Table(name = "ref_join_formation_voeu")
class FormationVoeuEntity {

constructor() {
this.idFormation = ""
this.idVoeu = ""
this.id = FormationVoeuEntityId("", "")
}

constructor(idFormation: String, idVoeu: String) {
this.idFormation = idFormation
this.idVoeu = idVoeu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ open class Runner(
logger.info("Mise à jour des liens formations metiers")
updateFormationsMetiersDbs.update()//after formations ert metiers

val voeuxOntChange = updateFormationDbs.checkVoeuxOuFormationsOntChange()
val voeuxOntChange = updateFormationDbs.checkForcedUpdate()
logger.info("Mise à jour des suggestions")
updateSuggestionsDbs.updateSuggestionDbs(voeuxOntChange)
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ interface VoeuxDb :
@Repository
interface FormationDb : JpaRepository<FormationEntity, String>

@Repository
interface FormationVoeuDb : JpaRepository<FormationVoeuEntity, String>

@Repository
interface JoinFormationMetierDb : JpaRepository<FormationMetierEntity, String>

Expand All @@ -52,40 +55,30 @@ class UpdateFormationDbs(
private val villesVoeuxDb: VillesVoeuxDb,
private val voeuxDb: VoeuxDb,
private val formationDb: FormationDb,
private val formationVoeuxDb: FormationVoeuDb,
private val parametreDb: UpdateParametreDb
) {

private val logger: Logger = Logger.getLogger(UpdateFormationDbs::class.java.simpleName)

internal fun update() {
val voeuxOntChange = checkVoeuxOuFormationsOntChange()
if(voeuxOntChange) {
logger.info("Mise à jour de la table des formations")
updateFormationsDb()
logger.info("Mise à jour de la table des voeux et des correspondances villes voeux")
updateVoeuxDb()
logger.info("Mise à jour de la table des formations")
updateFormationsDb()
logger.info("Mise à jour de la table des voeux et des correspondances villes voeux")
val nbPairesVoeuxFormationsAChange = updateVoeuxDb()
if(nbPairesVoeuxFormationsAChange || checkForcedUpdate()) {
logger.info("Mise à jour de la table de correspondance ville voeux")
updateVillesVoeuxDb()
} else {
logger.info("Mise à jour de la table des formations")
updateFormationsDb()
}

logger.info("Mise à jour de la table des critères d'admission")
updateCriteresDb()
logger.info("Mise à jour de la table des moyennes générales des admis")
updateMoyennesGeneralesAdmisDb()
}

fun checkVoeuxOuFormationsOntChange(): Boolean {
if(parametreDb.getFormationUpdateForcedFlag()) {
logger.warning("Forçage de la mise à jour des voeux et formations")
return true
}
val anciensVoeux = formationDb.findAll().flatMap { it.voeux.map { itt -> Pair(it.id, itt.id) } }.toSet()
val nouveauxVoeux = mpsDataPort.getVoeux().entries
.flatMap { e -> e.value.map { Pair(e.key, it.id) } }
.toSet()
return anciensVoeux != nouveauxVoeux
fun checkForcedUpdate(): Boolean {
return parametreDb.getFormationUpdateForcedFlag()
}


Expand All @@ -102,10 +95,10 @@ class UpdateFormationDbs(
moyennesGeneralesAdmisDb.saveAll(entities)
}

fun updateVoeuxDb() {
fun updateVoeuxDb(): Boolean {
val formationsMpsIds = mpsDataPort.getFormationsMpsIds()
val voeux = mpsDataPort.getVoeux()
val voeuxEntities = HashMap<String,VoeuEntity>()
val voeuxEntities = HashMap<String, VoeuEntity>()
val formationsVoeuxEntities = ArrayList<FormationVoeuEntity>()
formationsMpsIds.forEach { id ->
val voeuxFormation = voeux.getOrDefault(id, listOf()).sortedBy { it.libelle }
Expand All @@ -119,9 +112,13 @@ class UpdateFormationDbs(

val voeuxIds = voeuxEntities.keys

val nbFormationsVoeuxBefore = formationVoeuxDb.findAll().count()
val nbFormationsVoeuxAfter = formationsVoeuxEntities.count()
val changementNbVoeux = nbFormationsVoeuxBefore != nbFormationsVoeuxAfter

val voeuxObsoletes = HashSet(voeuxDb.findAll())
voeuxObsoletes.removeIf { voeuxIds.contains(it.id) }
if(voeuxObsoletes.isNotEmpty()) {
if (voeuxObsoletes.isNotEmpty()) {
logger.warning("Marquage de ${voeuxObsoletes.count()} voeux obsoletes")
voeuxObsoletes.forEach { it.obsolete = true }
batchUpdate.upsertEntities(voeuxObsoletes)
Expand All @@ -135,6 +132,8 @@ class UpdateFormationDbs(
logger.warning("Insertion et mise à jour de ${formationsVoeuxEntities.count()} paires formations voeux")
batchUpdate.setEntities(FormationVoeuEntity::class.simpleName!!, formationsVoeuxEntities)

return changementNbVoeux

}

fun updateFormationsDb() {
Expand Down

0 comments on commit 9ae2abd

Please sign in to comment.