Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Numero7 committed Jan 6, 2025
1 parent 9cef57f commit 7c05393
Show file tree
Hide file tree
Showing 39 changed files with 71 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Constants {
public static final String FRANCE_TRAVAIL_FICHE_METIER_PREFIX = "https://candidat.francetravail.fr/metierscope/fiche-metier/";
public static final int MAX_NB_LIENS_IDEO_SUR_FICHE_FORMATION = 3;
public static final int MAX_NB_LIENS_PSUP_SUR_FICHE_FORMATION = 3;
public static String PSUP_FORMATION_FICHE = "https://dossier.parcoursup.fr/Candidats/public/fiches/afficherFicheFormation?g_ta_cod=";
public static final String PSUP_FORMATION_FICHE = "https://dossier.parcoursup.fr/Candidats/public/fiches/afficherFicheFormation?g_ta_cod=";

public static final String DIAGNOSTICS_OUTPUT_DIR = "diagnostics/";
/* constant added to the las gFlCod indexes */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,45 +36,12 @@ public static Map<String, String> getLabelsMap() {
CEN_INT_FIELD, "Engagements, activités et centres d’intérêt, réalisations péri ou extra-scolaires"
);
}
public static List<Pair<String, String>> labelsFront = List.of(
public static final List<Pair<String, String>> labelsFront = List.of(
Pair.of(RES_ACA_FIELD, "Résultats académiques"),
Pair.of(COM_ACA_FIELD, "Compétences académiques"),
Pair.of(SAV_ETR_FIELD, "Savoir-être"),
Pair.of(MOT_CON_FIELD, "Motivation, connaissance"),
Pair.of(CEN_INT_FIELD, "Engagements, activités et centres d’intérêt, réalisations péri ou extra-scolaires")
);

/*
{
"TABLE_NAME": "C_JUR_ADM",
"COLUMN_NAME": "C_JA_CGV_RES_ACA_PRC",
"COMMENTS": "Pourcentage (en valeur entière) de prise en compte du criètres, saisi par l\u0027utilisateur en charge du paramétrage et cela au niveau de chaque jury",
"ORIGIN_CON_ID": "0"
},
{
"TABLE_NAME": "C_JUR_ADM",
"COLUMN_NAME": "C_JA_CGV_COM_ACA_PRC",
"COMMENTS": "Pourcentage (en valeur entière) de prise en compte du criètres, saisi par l\u0027utilisateur en charge du paramétrage et cela au niveau de chaque jury",
"ORIGIN_CON_ID": "0"
},
{
"TABLE_NAME": "C_JUR_ADM",
"COLUMN_NAME": "C_JA_CGV_SAV_ETR_PRC",
"COMMENTS": "Pourcentage (en valeur entière) de prise en compte du criètres, saisi par l\u0027utilisateur en charge du paramétrage et cela au niveau de chaque jury",
"ORIGIN_CON_ID": "0"
},
{
"TABLE_NAME": "C_JUR_ADM",
"COLUMN_NAME": "C_JA_CGV_MOT_CON_PRC",
"COMMENTS": "Pourcentage (en valeur entière) de prise en compte du criètres, saisi par l\u0027utilisateur en charge du paramétrage et cela au niveau de chaque jury",
"ORIGIN_CON_ID": "0"
},
{
"TABLE_NAME": "C_JUR_ADM",
"COLUMN_NAME": "C_JA_CGV_ACT_CEN_INT_PRC",
"COMMENTS": "Pourcentage (en valeur entière) de prise en compte du criètres, saisi par l\u0027utilisateur en charge du paramétrage et cela au niveau de chaque jury",
"ORIGIN_CON_ID": "0"
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ public DescriptifFormation get(String key) {
public String getDescriptifGeneralFront(@NotNull String flCod) {
val desc = keyToDescriptifs.get(flCod);
if(desc == null) return null;
return Helpers.removeHtml(desc.getDescriptifGeneralFront()).trim();
val html = Helpers.removeHtml(desc.getDescriptifGeneralFront());
if(html == null) return null;
return html.trim();
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ public Collection<Filiere> getFilieres() {


public void ajouterSiInconnu(Formations o) {
o.formations.forEach((key, value) -> {
this.formations.putIfAbsent(key, value);
});
o.formations.forEach(this.formations::putIfAbsent);
o.filieres.forEach(this.filieres::putIfAbsent);
o.typesMacros.forEach(this.typesMacros::putIfAbsent);
_groupesToFilieres.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ public Edges(Edges edges) {
}

public Edges(Map<String, Collection<String>> medges, double weight, boolean reverse) {
medges.forEach((s, strings) -> {
strings.forEach(s1 -> {
this.put(s, s1, reverse, weight);
});
});
medges.forEach((s, strings) -> strings.forEach(s1 -> this.put(s, s1, reverse, weight)));
}

public void put(String a, Collection<String> bs) {
Expand Down Expand Up @@ -120,7 +116,7 @@ private Set<Path> computePathesFromInternal(String node, int maxDistance) {
}

/**
* @param node
* @param node the node to compute the in degree
* @return the number of edges going to node
*/
private int inDegree(String node) {
Expand All @@ -131,9 +127,9 @@ private int inDegree(String node) {
/**
* add some edges with initial weight
*
* @param o
* @param reverse
* @param weight
* @param o the edges to add
* @param reverse if true, add the reverse edges
* @param weight the weight to apply to the edges
*/
public void putAll(@Nullable Edges o, boolean reverse, double weight) {
if (o != null) putAll(o.edges(), reverse, weight);
Expand Down Expand Up @@ -234,11 +230,10 @@ public void createLabelledGraphFrom(Edges edgesKeys, Map<String, String> globalD
String label = globalDict.get(k);
if (label == null) label = k;
String finalKey = label;
m.entrySet().forEach(e -> {
String s = e.getKey();
m.forEach((s, value) -> {
String val = globalDict.get(s);
if (val == null) val = s;
put(finalKey, val, false, e.getValue());
put(finalKey, val, false, value);
});
});

Expand All @@ -247,8 +242,8 @@ public void createLabelledGraphFrom(Edges edgesKeys, Map<String, String> globalD
/**
* the specifics inherit from the generics
*
* @param specificToGeneric
* @param coef
* @param specificToGeneric the map of specific to generic
* @param coef the coefficient to apply to the weights
*/
public void addEdgesFromMoreGenericItem(Map<String, String> specificToGeneric, double coef) {

Expand All @@ -263,11 +258,6 @@ public void addEdgesFromMoreGenericItem(Map<String, String> specificToGeneric, d
backEdges.forEach((origin, weight) -> put(origin, specific, false, weight * coef));
}
});
/*
Set<String> toErase = specificToGeneric.entrySet().stream().filter(e -> !e.getValue().equals(e.getKey()))
.map(e -> e.getKey())
.collect(Collectors.toSet());
*/
}

public void addTransitiveClosure(String theme, Set<String> transitiveClosureOfTheme) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public int size() {

@Override
public String toString() {
return nodes.stream().collect(Collectors.joining(" -- ")) + " [sc" + (int) (10000 * weight) + "]";
return String.join(" -- ", nodes) + " [sc" + (int) (10000 * weight) + "]";
}

public String toString(Map<String, String> keyToLabel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ public static String capitalizeFirstLetter(String sentence) {
}

private static String getLabel(@NotNull Map<String, String> labels, String cleanedupKey, String url) {
String label = labels.getOrDefault(cleanedupKey, url);
return label;
return labels.getOrDefault(cleanedupKey, url);
}

private UrlsUpdater() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public record SousDomaineWeb(
* ""information-communication, audiovisuel/communication| commerce, marketing, vente/marketing, vente"
*
* @param domaines the field to extract keys from
* @param domainesPro
* @param sousDomainesWeb the map of all domaines
* @return the keys
*/
public static Set<SousDomaineWeb> extractDomaines(@NotNull String domaines, Map<String, SousDomaineWeb> sousDomainesWeb) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public boolean estFormationDuSup() {
);
}

@SuppressWarnings("ExtractMethodRecommender")
public List<String> getMotsCles() {
List<String> result = new ArrayList<>();
if (codeNsf != null) result.add("codeNsf" + codeNsf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public FormationsSimilaires() {
public void add(String gFlCodOri, String gFlCodSim, int gFsSco, int iTcCod) {
parFiliereOrigine.computeIfAbsent(gFlCodOri, z -> new FormationsSimilairesParBac())
.parBac().computeIfAbsent(iTcCod, z -> new HashMap<>())
.put(gFlCodSim, Long.valueOf(gFsSco));
.put(gFlCodSim, (long) gFsSco);
}

public void normalize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public record Middle50(

/**
*
* @param frequencesCumulees
* @param frequencesCumulees the cumulative frequencies
*
*/
public Middle50(int[] frequencesCumulees) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void close() throws IOException {
public void appendHeaders(List<String> headers) throws IOException {
append(headers);
}
public void append(List<String> items) throws IOException {
public void append(List<String> items) {
csvWriter.writeNext(items.toArray(new String[0]));
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ public class Serialisation {
}

public static InputStream getRemoteFile(String urlString, String dataDir) throws IOException, InterruptedException {
String dirName = dataDir;
int i = urlString.lastIndexOf('/') + 1;
String cacheName = dirName + "/" + urlString.substring(i);
String cacheName = dataDir + "/" + urlString.substring(i);
if (dataDir != null && Files.exists(Path.of(cacheName))) {
LOGGER.warning("Utilisation du cache pour " + urlString + " depuis " + cacheName);
return new FileInputStream(cacheName);
Expand All @@ -56,13 +55,13 @@ public static InputStream getRemoteFile(String urlString, String dataDir) throws
.header("Content-Type", "application/json")
.GET() // or use .POST(), .PUT(), etc.
.build();
HttpClient client = HttpClient.newHttpClient();
final HttpClient client = HttpClient.newHttpClient();
HttpResponse<InputStream> response = client.send(request, HttpResponse.BodyHandlers.ofInputStream());
if (response.statusCode() == HTTP_OK) {
val stream = response.body();
if (dataDir != null) {
LOGGER.warning("Sauvegarde de " + urlString + " dans le cache " + cacheName);
if(!Files.exists(Path.of(dirName))) Files.createDirectories(Path.of(dirName));
if (!Files.exists(Path.of(dataDir))) Files.createDirectories(Path.of(dataDir));
try (OutputStream out = new FileOutputStream(cacheName)) {
stream.transferTo(out);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package fr.gouv.monprojetsup.data.formationmetier.entity

import jakarta.persistence.*
import java.io.Serializable
import jakarta.persistence.Column
import jakarta.persistence.Embeddable
import jakarta.persistence.EmbeddedId
import jakarta.persistence.Entity
import jakarta.persistence.Table

@Entity
@Table(name = "ref_join_formation_metier")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public static TagsSources recupererSources(AlgoCarteEntree carte, Set<Integer> f


//group bac mat
Map<String, Map<String, Map<String, int[] >>> percCounters = new HashMap<>();
final Map<String, Map<String, Map<String, int[] >>> percCounters = new HashMap<>();

void incremente(String bac, String group, String matCod, double note) {
int[] c = percCounters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
import fr.gouv.monprojetsup.data.model.psup.Filiere;
import fr.gouv.monprojetsup.data.psup.exceptions.AccesDonneesException;
import fr.gouv.monprojetsup.data.psup.exceptions.AccesDonneesExceptionMessage;
import fr.gouv.monprojetsup.data.psup.exceptions.VerificationException;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import static fr.gouv.monprojetsup.data.Constants.LAS_CONSTANT;
import static fr.gouv.monprojetsup.data.psup.AlgoCarteConfig.FILIERE;
import static fr.gouv.monprojetsup.data.psup.AlgoCarteConfig.TYPE_FORMATION;
import static fr.gouv.monprojetsup.data.Constants.LAS_CONSTANT;
import static fr.gouv.monprojetsup.data.psup.Scores.cleanAndSplit;
import static fr.gouv.monprojetsup.data.psup.exceptions.AccesDonneesExceptionMessage.CONNECTEUR_ORACLE_CONNEXION_NULL;

Expand Down Expand Up @@ -46,7 +50,7 @@ public AlgoCarteEntree recupererDonneesJSONCarte(AlgoCarteConfig config) throws
recuperationDesFilieres(entree);
recuperationDomainesOnisep(entree);
recuperationFormationsTagguees(entree, config);
} catch (SQLException | VerificationException ex) {
} catch (SQLException ex) {
throw new AccesDonneesException(AccesDonneesExceptionMessage.MESSAGE, ex, String.format(ex.getMessage()), ex);
}
return entree;
Expand All @@ -55,7 +59,7 @@ public AlgoCarteEntree recupererDonneesJSONCarte(AlgoCarteConfig config) throws
public static final String G_TA_COD = "g_ta_cod";
public static final String G_TF_MOT_CLE_MDR = "g_tf_mot_cle_mdr";

public void recuperationDomainesOnisep(AlgoCarteEntree entree) throws VerificationException, SQLException {
public void recuperationDomainesOnisep(AlgoCarteEntree entree) throws SQLException {

try (Statement stmt = connection.createStatement()) {
LOGGER.info("Récupération des secteursActivite onisep v2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ Hugo Gimbert ([email protected])

public class AccesDonneesException extends Exception {

private static final long serialVersionUID = 1L;

public AccesDonneesException(AccesDonneesExceptionMessage exceptionMessage, Object... arguments) {
super(String.format(exceptionMessage.getMessage(), arguments));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package fr.gouv.monprojetsup.data.psup.exceptions;

@SuppressWarnings("unused")
import lombok.Getter;

@Getter
public enum AccesDonneesExceptionMessage {
MESSAGE("%s"),

CONNECTEUR_ORACLE_CONNEXION_NULL("Impossible de créer un ConnecteurOracle à partir d'une connexion null"),
CONNECTEUR_ORACLE_CREATION("Echec de création du connecteur"),

CONNECTEUR_DONNEES_APPEL_ORACLE_ERREUR_SQL_RECUPERATION("Erreur SQL lors de la récupération des données d'appel");

Expand All @@ -15,7 +16,4 @@ public enum AccesDonneesExceptionMessage {
this.message = message;
}

public String getMessage(){
return this.message;
}
}
Loading

0 comments on commit 7c05393

Please sign in to comment.