From d16359d71834b22228618a8861ef60b6f85eb8aa Mon Sep 17 00:00:00 2001 From: Manuel Soulier Date: Fri, 6 Oct 2023 12:59:37 +0200 Subject: [PATCH] fix: List and Map types --- .../arc/core/service/global/ApiService.java | 13 +- .../core/service/global/bo/JeuDeRegleDao.java | 19 +- .../arc/core/service/global/bo/RegleDao.java | 5 +- .../service/global/dao/RulesOperations.java | 6 +- .../dbmaintenance/BddPatcher.java | 12 +- .../SynchronizeRulesAndMetadataOperation.java | 4 +- .../dao/SynchronizeRulesAndMetadataDao.java | 11 +- .../pilotage/CleanPilotageOperation.java | 10 +- .../pilotage/dao/CleanPilotageDao.java | 6 +- .../dao/SynchronizeDataByPilotageDao.java | 2 +- .../core/service/p2chargement/bo/Norme.java | 2 +- .../p2chargement/engine/ChargementBrut.java | 4 +- .../engine/ChargeurClefValeur.java | 16 +- .../engine/ChargeurXmlComplexe.java | 392 +++++++++--------- .../xmlhandler/TreeFunctions.java | 14 +- .../xmlhandler/XMLComplexeHandlerCharger.java | 14 - .../xmlhandler/XMLHandlerCharger4.java | 47 +-- .../p3normage/engine/NormageEngine.java | 55 +-- .../engine/NormageEngineRegleDuplication.java | 7 +- .../NormageEngineRegleIndependance.java | 8 +- .../engine/NormageEngineRegleRelation.java | 5 +- .../engine/NormageEngineRegleSupression.java | 13 +- .../engine/NormageEngineRegleUnicite.java | 6 +- .../thread/ThreadNormageService.java | 13 +- .../p4controle/engine/ServiceJeuDeRegle.java | 14 +- .../engine/dao/ServiceRequeteSqlRegle.java | 44 -- .../thread/ThreadControleService.java | 7 +- .../p5mapping/engine/RequeteMapping.java | 13 +- .../src/main/resources/BdD/script_global.sql | 2 +- .../BdD/script_global_phase_controle.sql | 19 +- .../BdD/script_global_phase_normage.sql | 15 + .../class-diagram-services-full.puml | 8 +- .../engine/initialisation/BddPatcherTest.java | 8 +- .../service/global/dao/ServiceDateTest.java | 6 +- .../dao/ServicePilotageOperationTest.java | 4 +- .../insee/arc/utils/dao/AbstractEntity.java | 2 +- .../insee/arc/utils/dao/EntityProvider.java | 8 +- .../dao/GenericPreparedStatementBuilder.java | 4 +- .../fr/insee/arc/utils/dao/UtilitaireDao.java | 18 +- .../utils/exception/ArcExceptionMessage.java | 5 +- .../arc/utils/files/CompressedUtils.java | 7 +- .../fr/insee/arc/utils/format/Format.java | 15 - .../arc/utils/structure/GenericBean.java | 37 +- .../fr/insee/arc/utils/format/FormatTest.java | 14 - .../arc/utils/query/InitializeQueryTest.java | 8 +- .../arc/utils/structure/GenericBeanTest.java | 19 +- .../insee/arc/utils/utils/FormatSQLTest.java | 14 +- .../arc/web/gui/all/dao/ArcWebGenericDao.java | 5 +- .../insee/arc/web/gui/all/model/Sandbox.java | 17 + .../gui/all/service/ArcWebGenericService.java | 2 +- .../arc/web/gui/all/util/ConstanteBD.java | 24 -- .../arc/web/gui/all/util/LineObject.java | 14 +- .../arc/web/gui/all/util/TableObject.java | 13 +- .../insee/arc/web/gui/all/util/VObject.java | 220 +++++----- .../web/gui/all/util/VObjectHelperDao.java | 8 +- .../arc/web/gui/all/util/VObjectService.java | 105 +++-- .../arc/web/gui/export/dao/ExportDao.java | 26 +- .../gui/export/service/InteractorExport.java | 12 +- .../gui/export/service/ServiceViewExport.java | 20 +- .../export/service/ServiceViewFileExport.java | 11 +- .../dao/GererFamilleNormeDao.java | 20 +- .../service/InteractorFamilleNorme.java | 8 +- .../service/ServiceViewFamilleNorme.java | 3 +- .../web/gui/file/service/InteractorFile.java | 33 +- .../gui/file/service/ServiceViewDirIn.java | 4 +- .../gui/file/service/ServiceViewDirOut.java | 4 +- .../service/InteractorNomenclature.java | 6 +- .../service/ServiceViewListNomenclatures.java | 4 +- .../service/ServiceViewSchemaNmcl.java | 6 +- .../arc/web/gui/norme/dao/GererNormeDao.java | 16 +- .../gui/norme/service/InteractorNorme.java | 39 +- .../norme/service/ServiceViewCalendrier.java | 4 +- .../service/ServiceViewJeuxDeRegles.java | 19 +- .../service/ServiceViewJeuxDeReglesCopie.java | 6 +- .../gui/norme/service/ServiceViewNorme.java | 4 +- .../arc/web/gui/pilotage/dao/PilotageDao.java | 28 +- .../pilotage/service/InteractorPilotage.java | 2 +- .../service/ServiceViewFichierBAS.java | 6 +- .../service/ServiceViewPilotageBAS.java | 3 +- .../gui/query/service/ServiceViewTable.java | 6 +- .../service/InteractorWebservice.java | 4 +- .../arc/web/gui/export/dao/ExportDaoTest.java | 8 +- .../dao/GererFamilleNormeDaoTest.java | 8 +- .../dao/GererNomenclatureDaoTest.java | 2 +- .../web/gui/norme/dao/GererNormeDaoTest.java | 6 +- .../fr/insee/arc/web/util/VObjectTest.java | 11 +- ...ortStep1InitializeClientTablesService.java | 2 +- .../ImportStep2GetTableNameService.java | 4 +- .../ws/services/importServlet/ServletArc.java | 2 +- .../services/importServlet/dao/ClientDao.java | 9 +- .../importServlet/dao/ClientDaoImpl.java | 24 +- .../execute/ExecuteEngineController.java | 11 +- .../restServices/execute/ExecuteRulesDao.java | 5 +- 93 files changed, 844 insertions(+), 925 deletions(-) create mode 100644 arc-web/src/main/java/fr/insee/arc/web/gui/all/model/Sandbox.java delete mode 100644 arc-web/src/main/java/fr/insee/arc/web/gui/all/util/ConstanteBD.java diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/global/ApiService.java b/arc-core/src/main/java/fr/insee/arc/core/service/global/ApiService.java index f3e4b216c..fa945d9f5 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/global/ApiService.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/global/ApiService.java @@ -2,8 +2,9 @@ import java.sql.Connection; import java.sql.SQLException; -import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -63,7 +64,7 @@ public abstract class ApiService implements IConstanteNumerique { protected Boolean todo = false; - protected HashMap> tabIdSource; + protected Map> tabIdSource; public ApiService() { super(); @@ -264,7 +265,7 @@ public void finaliser() { * @param etat * @return */ - public HashMap> pilotageListIdsource(String tablePilotage, String aCurrentPhase, + public Map> pilotageListIdsource(String tablePilotage, String aCurrentPhase, String etat) { LoggerHelper.info(LOGGER_APISERVICE, "pilotageListIdsource"); ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); @@ -425,7 +426,7 @@ private void repriseSurErreur(Connection connexion, String phase, String tablePi * @return * @throws ArcException */ - protected HashMap> recuperationIdSource() throws ArcException { + protected Map> recuperationIdSource() throws ArcException { ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.append("SELECT p." + ColumnEnum.ID_SOURCE.getColumnName() + " "); @@ -433,7 +434,7 @@ protected HashMap> recuperationIdSource() throws ArcEx query.append("ORDER BY " + ColumnEnum.ID_SOURCE.getColumnName()); query.append(";"); - HashMap> pil = new GenericBean( + Map> pil = new GenericBean( UtilitaireDao.get(0).executeRequest(this.connexion.getCoordinatorConnection(), query)).mapContent(); return (pil); @@ -444,7 +445,7 @@ public String getEnvExecution() { return envExecution; } - public HashMap> getTabIdSource() { + public Map> getTabIdSource() { return tabIdSource; } diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/global/bo/JeuDeRegleDao.java b/arc-core/src/main/java/fr/insee/arc/core/service/global/bo/JeuDeRegleDao.java index f3f399222..99b3c4abf 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/global/bo/JeuDeRegleDao.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/global/bo/JeuDeRegleDao.java @@ -5,6 +5,8 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,6 +15,7 @@ import fr.insee.arc.core.util.StaticLoggerDispatcher; import fr.insee.arc.utils.dao.UtilitaireDao; import fr.insee.arc.utils.exception.ArcException; +import fr.insee.arc.utils.exception.ArcExceptionMessage; import fr.insee.arc.utils.structure.GenericBean; import fr.insee.arc.utils.utils.LoggerHelper; public class JeuDeRegleDao { @@ -39,7 +42,7 @@ public static ArrayList recupJeuDeRegle(Connection connexion, String requete.append("SELECT a.id_norme, a.periodicite, a.validite_inf, a.validite_sup, a.version"); requete.append("\n FROM " + tableJeuDeRegle + " a "); - HashMap> g=new GenericBean(UtilitaireDao.get(0).executeRequest(connexion, new ArcPreparedStatementBuilder(requete))).mapContent(); + Map> g=new GenericBean(UtilitaireDao.get(0).executeRequest(connexion, new ArcPreparedStatementBuilder(requete))).mapContent(); return extractRuleSetObjects(g); } @@ -67,7 +70,7 @@ public static ArrayList recupJeuDeRegle(Connection connexion, String requete.append("\n AND to_date(b.validite,'"+ArcDateFormat.DATE_FORMAT_CONVERSION.getDatastoreFormat()+"')<=a.validite_sup); "); - HashMap> g=new GenericBean(UtilitaireDao.get(0).executeRequest(connexion, new ArcPreparedStatementBuilder(requete))).mapContent(); + Map> g=new GenericBean(UtilitaireDao.get(0).executeRequest(connexion, new ArcPreparedStatementBuilder(requete))).mapContent(); ArrayList listJdr = extractRuleSetObjects(g); @@ -75,7 +78,7 @@ public static ArrayList recupJeuDeRegle(Connection connexion, String return listJdr; } - private static ArrayList extractRuleSetObjects(HashMap> g) { + private static ArrayList extractRuleSetObjects(Map> g) throws ArcException { SimpleDateFormat formatDate = new SimpleDateFormat(ArcDateFormat.DATE_FORMAT_CONVERSION.getApplicationFormat()); ArrayList listJdr = new ArrayList<>(); if (!g.isEmpty()) @@ -89,9 +92,17 @@ private static ArrayList extractRuleSetObjects(HashMap getRegle(Connection connexion, Stri sb.append(" AND to_date(b.validite,'"+ArcDateFormat.DATE_FORMAT_CONVERSION.getDatastoreFormat()+"')<=a.validite_sup) "); sb.append("; "); - HashMap> g = new GenericBean(UtilitaireDao.get(0).executeRequest(connexion, sb)) + Map> g = new GenericBean(UtilitaireDao.get(0).executeRequest(connexion, sb)) .mapContent(); if (!g.isEmpty()) { diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/global/dao/RulesOperations.java b/arc-core/src/main/java/fr/insee/arc/core/service/global/dao/RulesOperations.java index b90704203..2b4476ef8 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/global/dao/RulesOperations.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/global/dao/RulesOperations.java @@ -1,8 +1,8 @@ package fr.insee.arc.core.service.global.dao; import java.sql.Connection; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder; import fr.insee.arc.core.dataobjects.ColumnEnum; @@ -145,7 +145,7 @@ public static String getNormeAttributes(String idSource, String tablePilotage) { * @return * @throws ArcException */ - public static HashMap> getBean(Connection c, String req) throws ArcException { + public static Map> getBean(Connection c, String req) throws ArcException { GenericBean gb = new GenericBean( UtilitaireDao.get(0).executeRequest(c, new ArcPreparedStatementBuilder(req))); return gb.mapContent(true); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/dbmaintenance/BddPatcher.java b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/dbmaintenance/BddPatcher.java index ba6b4de87..6b562474c 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/dbmaintenance/BddPatcher.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/dbmaintenance/BddPatcher.java @@ -5,6 +5,8 @@ import java.sql.Connection; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.function.Function; import org.apache.commons.io.IOUtils; @@ -273,7 +275,7 @@ public PropertiesHandler getProperties() { * @return * @throws ArcException */ - private static ArrayList retrieveTablesFromSchema(Connection connexion, String envExecution, Function condition) + private static List retrieveTablesFromSchema(Connection connexion, String envExecution, Function condition) throws ArcException { ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); @@ -349,7 +351,7 @@ private static ArcPreparedStatementBuilder conditionToRetrieveRulesTablesInSchem } // return external tables used in rules - public static ArrayList retrieveExternalTablesUsedInRules(Connection connexion, String envExecution) + public static List retrieveExternalTablesUsedInRules(Connection connexion, String envExecution) throws ArcException { // generate a sql expression with relevant the columns concatenation of rules table @@ -371,7 +373,7 @@ public static ArrayList retrieveExternalTablesUsedInRules(Connection con query.build(SQL.AND, ColumnEnum.COLUMN_NAME, "!=", query.quoteText(ColumnEnum.VERSION)); query.build(SQL.GROUP_BY, ColumnEnum.TABLE_SCHEMA, "||'.'||", ColumnEnum.TABLE_NAME); - HashMap> result = new GenericBean( + Map> result = new GenericBean( UtilitaireDao.get(0).executeRequest(connexion, query)).mapContent(); // search if a nomenclature table is quoted in the columns concatenation of rules tables @@ -404,12 +406,12 @@ public static ArrayList retrieveExternalTablesUsedInRules(Connection con * @param envExecution * @throws ArcException */ - public static ArrayList retrieveRulesTablesFromSchema(Connection connexion, String envExecution) + public static List retrieveRulesTablesFromSchema(Connection connexion, String envExecution) throws ArcException { return retrieveTablesFromSchema(connexion, envExecution, BddPatcher::conditionToRetrieveRulesTablesInSchema ); } - public static ArrayList retrieveModelTablesFromSchema(Connection connexion, String envExecution) + public static List retrieveModelTablesFromSchema(Connection connexion, String envExecution) throws ArcException { return retrieveTablesFromSchema(connexion, envExecution, BddPatcher::conditionToRetrieveModelTablesInSchema ); } diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/metadata/SynchronizeRulesAndMetadataOperation.java b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/metadata/SynchronizeRulesAndMetadataOperation.java index bce49cc48..0377e04e5 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/metadata/SynchronizeRulesAndMetadataOperation.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/metadata/SynchronizeRulesAndMetadataOperation.java @@ -3,6 +3,7 @@ import java.sql.Connection; import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Optional; import org.apache.logging.log4j.LogManager; @@ -18,7 +19,6 @@ import fr.insee.arc.core.service.p5mapping.engine.ExpressionService; import fr.insee.arc.utils.consumer.ThrowingConsumer; import fr.insee.arc.utils.dao.CopyObjectsToDatabase; -import fr.insee.arc.utils.dao.UtilitaireDao; import fr.insee.arc.utils.exception.ArcException; import fr.insee.arc.utils.ressourceUtils.PropertiesHandler; import fr.insee.arc.utils.structure.GenericBean; @@ -132,7 +132,7 @@ private static void copyMetaDataToExecutors(Connection coordinatorConnexion, Con // copy tables - ArrayList tablesToCopyIntoExecutor = BddPatcher.retrieveRulesTablesFromSchema(coordinatorConnexion, + List tablesToCopyIntoExecutor = BddPatcher.retrieveRulesTablesFromSchema(coordinatorConnexion, envExecution); tablesToCopyIntoExecutor .addAll(BddPatcher.retrieveExternalTablesUsedInRules(coordinatorConnexion, envExecution)); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/metadata/dao/SynchronizeRulesAndMetadataDao.java b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/metadata/dao/SynchronizeRulesAndMetadataDao.java index 0cbfff075..ccc860f39 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/metadata/dao/SynchronizeRulesAndMetadataDao.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/metadata/dao/SynchronizeRulesAndMetadataDao.java @@ -120,7 +120,7 @@ public void copyRulesTablesToExecution() throws ArcException { + requeteSelectDrop.quoteText(anExecutionEnvironment.toLowerCase()) + " "); requeteSelectDrop.append(" AND tablename SIMILAR TO '%nmcl%|%ext%'"); - ArrayList requetesDeSuppressionTablesNmcl = new GenericBean( + List requetesDeSuppressionTablesNmcl = new GenericBean( UtilitaireDao.get(0).executeRequest(coordinatorConnexion, requeteSelectDrop)).mapContent() .get("requete_drop"); @@ -131,7 +131,7 @@ public void copyRulesTablesToExecution() throws ArcException { } // 2.Préparation des requêtes de création des tables - ArrayList requetesDeCreationTablesNmcl = new GenericBean(UtilitaireDao.get(0) + List requetesDeCreationTablesNmcl = new GenericBean(UtilitaireDao.get(0) .executeRequest(coordinatorConnexion, new ArcPreparedStatementBuilder( "select tablename from pg_tables where (tablename like 'nmcl\\_%' OR tablename like 'ext\\_%') and schemaname='arc'"))) .mapContent().get("tablename"); @@ -174,8 +174,8 @@ public static void mettreAJourSchemaTableMetier(Connection coordinatorOrExecutor + "'||nom_table_metier), lower(nom_variable_metier), lower(type_variable_metier) FROM " + ViewEnum.IHM_MOD_VARIABLE_METIER.getFullName()); - List> relationalViewRef = Format - .patch(UtilitaireDao.get(0).executeRequestWithoutMetadata(coordinatorOrExecutorConnexion, requeteRef)); + List> relationalViewRef = UtilitaireDao.get(0).executeRequestWithoutMetadata(coordinatorOrExecutorConnexion, requeteRef); + HierarchicalView familleToTableToVariableToTypeRef = HierarchicalView.asRelationalToHierarchical( "(Réf) Famille -> Table -> Variable -> Type", Arrays.asList("id_famille", "nom_table_metier", "variable_metier", "type_variable_metier"), @@ -205,8 +205,7 @@ public static void mettreAJourSchemaTableMetier(Connection coordinatorOrExecutor + ManipString.substringAfterFirst(TableNaming.dbEnv(envExecution), ".").toLowerCase() + "mapping\\_'||lower(id_famille)||'\\_%';"); - List> relationalView = Format - .patch(UtilitaireDao.get(0).executeRequestWithoutMetadata(coordinatorOrExecutorConnexion, requete)); + List> relationalView = UtilitaireDao.get(0).executeRequestWithoutMetadata(coordinatorOrExecutorConnexion, requete); HierarchicalView familleToTableToVariableToType = HierarchicalView.asRelationalToHierarchical( "(Phy) Famille -> Table -> Variable -> Type", diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/CleanPilotageOperation.java b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/CleanPilotageOperation.java index b09a8e382..0d688143e 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/CleanPilotageOperation.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/CleanPilotageOperation.java @@ -3,6 +3,8 @@ import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -67,11 +69,11 @@ public void removeDeprecatedFiles() throws ArcException { cleanPilotageDao.execQueryMaterializeFilesToDelete(numberOfDaysToKeepFiles); // initialisation de la liste contenant les archives à déplacer - HashMap> recordedArchives = new HashMap<>(); + Map> recordedArchives = new HashMap<>(); recordedArchives.put(ColumnEnum.ENTREPOT.getColumnName(), new ArrayList<>()); recordedArchives.put(ColumnEnum.NOM_ARCHIVE.getColumnName(), new ArrayList<>()); - HashMap> listOfDeletedArchives; + Map> listOfDeletedArchives; // on selectionne les fichiers éligibles et on limite le nombre de retour // pour que l'update ne soit pas trop massif (perf) @@ -96,7 +98,7 @@ public void removeDeprecatedFiles() throws ArcException { } - private void keepTrackOfDeletedArchives(HashMap> listOfDeletedArchives, HashMap> recordedArchives) + private void keepTrackOfDeletedArchives(Map> listOfDeletedArchives, Map> recordedArchives) { if (listOfDeletedArchives.isEmpty()) { return; @@ -129,7 +131,7 @@ private void keepTrackOfDeletedArchives(HashMap> listO * @param recordedArchives * @throws ArcException */ - private void moveDeletedArchivesToArchivageDirectory(HashMap> recordedArchives) throws ArcException + private void moveDeletedArchivesToArchivageDirectory(Map> recordedArchives) throws ArcException { if (recordedArchives.get(ColumnEnum.ENTREPOT.getColumnName()).isEmpty()) { return; diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/dao/CleanPilotageDao.java b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/dao/CleanPilotageDao.java index d7af11768..87884523a 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/dao/CleanPilotageDao.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/dao/CleanPilotageDao.java @@ -1,7 +1,7 @@ package fr.insee.arc.core.service.p0initialisation.pilotage.dao; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder; import fr.insee.arc.core.dataobjects.ColumnEnum; @@ -68,7 +68,7 @@ public void execQueryMaterializeFilesToDelete(int numberOfDaysToKeepFiles) throw * @return * @throws ArcException */ - public HashMap> execQueryDeleteDeprecatedFilesAndSelectArchives(int numberOfFilesToProceed) throws ArcException { + public Map> execQueryDeleteDeprecatedFilesAndSelectArchives(int numberOfFilesToProceed) throws ArcException { // requete sur laquelle on va itérer : on selectionne un certain nombre de // fichier et on itere ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/dao/SynchronizeDataByPilotageDao.java b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/dao/SynchronizeDataByPilotageDao.java index fe516484c..618adb3fd 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/dao/SynchronizeDataByPilotageDao.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p0initialisation/pilotage/dao/SynchronizeDataByPilotageDao.java @@ -163,7 +163,7 @@ public static void dropUnusedTemporaryTablesOnConnection(Connection targetConnex GenericBean g = new GenericBean( UtilitaireDao.get(0).executeRequest(targetConnexion, SynchronizeDataByPilotageDao.requeteListAllTemporaryTablesInEnv(envExecution))); if (!g.mapContent().isEmpty()) { - ArrayList envTables = g.mapContent().get("table_name"); + List envTables = g.mapContent().get("table_name"); for (String nomTable : envTables) { UtilitaireDao.get(0).executeBlock(targetConnexion, FormatSQL.dropTable(nomTable)); } diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/bo/Norme.java b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/bo/Norme.java index df52a1843..0a3f6dbb1 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/bo/Norme.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/bo/Norme.java @@ -84,7 +84,7 @@ public static List getNormesBase(Connection connexion, String envExecutio List output = new ArrayList() ; // Récupérer les régles de définition de normes - ArrayList> normes = new ArrayList>(); + List> normes = new ArrayList<>(); try { normes = new GenericBean(UtilitaireDao.get(0).executeRequest(connexion, new ArcPreparedStatementBuilder( "select id_norme, periodicite, def_norme, def_validite from " + ViewEnum.NORME.getFullName(envExecution) + ";"))).content; diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargementBrut.java b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargementBrut.java index af0ae48c0..93466aee2 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargementBrut.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargementBrut.java @@ -143,11 +143,11 @@ private void calculerNormeAndValidite(Norme[] normeOk, String[] validiteOk, Stri query.append("\n ) vv "); query.append("\n where norme is not null "); - ArrayList> result =UtilitaireDao.get(0).executeRequestWithoutMetadata(this.connexion, new ArcPreparedStatementBuilder(query)); + List> result =UtilitaireDao.get(0).executeRequestWithoutMetadata(this.connexion, new ArcPreparedStatementBuilder(query)); if (result.size()>1) { StringBuilder normsFound = new StringBuilder(); - for (ArrayList resultLine : result) + for (List resultLine : result) { int index = Integer.parseInt(resultLine.get(0)); normsFound.append("{"); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargeurClefValeur.java b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargeurClefValeur.java index 57841853b..fbdf63258 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargeurClefValeur.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargeurClefValeur.java @@ -9,6 +9,8 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Optional; import org.apache.commons.text.StringEscapeUtils; @@ -118,15 +120,15 @@ private void chargerClefValeur() throws ArcException { * @throws IOException * @throws ArcException */ - private void clefValeurToXml(HashMap arbreFormat, InputStream tmpInx2) throws ArcException { + private void clefValeurToXml(Map arbreFormat, InputStream tmpInx2) throws ArcException { StaticLoggerDispatcher.info(LOGGER, "** Conversion du fichier clef valeur en XML **"); java.util.Date beginDate = new java.util.Date(); // contient la liste des pères pour l'élément précédent - ArrayList listePeresRubriquePrecedante = new ArrayList<>(); + List listePeresRubriquePrecedante = new ArrayList<>(); // contient la liste des rubriques vues au niveau pour chaque balise encore ouverte. // clef : rubrique/ valeur : fils ouvert - HashMap> mapRubriquesFilles = new HashMap<>(); + Map> mapRubriquesFilles = new HashMap<>(); // Lecture du fichier contenant les données et écriture d'un fichier xml InputStreamReader inputStreamReader = new InputStreamReader(tmpInx2, StandardCharsets.ISO_8859_1); @@ -170,7 +172,7 @@ private void clefValeurToXml(HashMap arbreFormat, InputStream tm * @throws IOException * @throws ArcException */ - private ArrayList initialisationOutputStream(HashMap arbreFormat, HashMap> mapRubriquesFilles, + private ArrayList initialisationOutputStream(Map arbreFormat, Map> mapRubriquesFilles, String ligne) throws ArcException { // ecriture de l'entete du fichier @@ -225,8 +227,8 @@ private ArrayList initialisationOutputStream(HashMap arb * @throws IOException * @throws ArcException */ - private ArrayList lectureLigne(HashMap arbreFormat, - ArrayList listePeresRubriquePrecedante, HashMap> mapRubriquesFilles, String ligne) + private ArrayList lectureLigne(Map arbreFormat, + List listePeresRubriquePrecedante, Map> mapRubriquesFilles, String ligne) throws ArcException { String rubrique; @@ -324,7 +326,7 @@ private ArrayList lectureLigne(HashMap arbreFormat, * @param bw * @throws IOException */ - private void finaliserOutputStream(ArrayList listePeresRubriqueCourante) throws ArcException { + private void finaliserOutputStream(List listePeresRubriqueCourante) throws ArcException { String rubriqueCourante; for (int i = 1; i < listePeresRubriqueCourante.size(); i++) { diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargeurXmlComplexe.java b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargeurXmlComplexe.java index 05630728a..cd33d9328 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargeurXmlComplexe.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/engine/ChargeurXmlComplexe.java @@ -5,7 +5,8 @@ import java.sql.Connection; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -33,215 +34,200 @@ import fr.insee.arc.utils.utils.Pair; import fr.insee.arc.utils.utils.SecuredSaxParser; - - - - /** - * Classe chargeant les fichiers Xml. Utiliser l'api SAX pour parser les fichiers + * Classe chargeant les fichiers Xml. Utiliser l'api SAX pour parser les + * fichiers * * @author S4LWO8 * */ -public class ChargeurXmlComplexe implements IChargeur{ - private static final Logger LOGGER = LogManager.getLogger(ChargeurXmlComplexe.class); - private String fileName; - private Connection connexion; - private String tableChargementPilTemp; - private String envExecution; - private String currentPhase; - private Norme norme; - private String validite; - private InputStream f; - - private ArrayList> format; - - // temporary table where data will be loaded by the XML SAX engine - private String tableTempA; - private FastList tempTableAColumnsLongName=new FastList<>(Arrays.asList(ColumnEnum.ID_SOURCE.getColumnName(),"id","date_integration","id_norme","periodicite","validite")); - private FastList tempTableAColumnsShortName=new FastList<>(Arrays.asList("m0","m1","m2","m3","m4","m5")); - private FastList tempTableAColumnsType=new FastList<>(Arrays.asList("text collate \"C\"","int","text collate \"C\"","text collate \"C\"","text collate \"C\"","text collate \"C\"")); - - private String rapport; - private Boolean error = false; - public String jointure; - - public ChargeurXmlComplexe(ThreadChargementService threadChargementService, String fileName) { - this.fileName = fileName; - this.connexion = threadChargementService.getConnexion().getExecutorConnection(); - this.tableTempA = threadChargementService.getTableTempA(); - this.tableChargementPilTemp = threadChargementService.getTableChargementPilTemp(); - this.currentPhase = threadChargementService.getCurrentPhase(); - this.f = threadChargementService.filesInputStreamLoad.getTmpInxChargement(); - this.norme = threadChargementService.normeOk; - this.validite = threadChargementService.validite; - this.envExecution=threadChargementService.getEnvExecution(); - } - - - public ChargeurXmlComplexe(Connection connexion, String fileName, InputStream f, String tableOut, String norme, String periodicite, String validite, String envExecution) { - this.fileName = fileName; - this.connexion = connexion; - this.tableTempA = tableOut; - this.norme=new Norme(norme, periodicite, null, null); - this.validite = validite; - this.f=f; - this.envExecution=envExecution; - } - - - /** - * Autonomous execution with parameters constructor - * @throws ArcException - */ - public void executeEngine() throws ArcException { - initialisation(); - execution(); - } - - - @Override - public void initialisation() { - StaticLoggerDispatcher.info(LOGGER, "** requeteCreateA **"); - - java.util.Date beginDate = new java.util.Date(); - - NormeFichier normeFichier=new NormeFichier(this.norme.getIdNorme(), validite, this.norme.getPeriodicite()); - this.format=new ArrayList<>(); - - // voir avec Pierre comment factoriser ce genre de truc - try { - HashMap> regle = RulesOperations.getBean(this.connexion,RulesOperations.getRegles(ViewEnum.CHARGEMENT_REGLE.getFullName(this.envExecution), normeFichier)); - if (regle.get("format").get(0)!=null) { - for (String rule:regle.get("format").get(0).split("\n")) - { - this.format.add(new Pair<>(rule.split(",")[0].trim(),rule.split(",")[1].trim())); - } +public class ChargeurXmlComplexe implements IChargeur { + private static final Logger LOGGER = LogManager.getLogger(ChargeurXmlComplexe.class); + private String fileName; + private Connection connexion; + private String tableChargementPilTemp; + private String envExecution; + private String currentPhase; + private Norme norme; + private String validite; + private InputStream f; + + private ArrayList> format; + + // temporary table where data will be loaded by the XML SAX engine + private String tableTempA; + private FastList tempTableAColumnsLongName = new FastList<>(Arrays.asList( + ColumnEnum.ID_SOURCE.getColumnName(), "id", "date_integration", "id_norme", "periodicite", "validite")); + private FastList tempTableAColumnsShortName = new FastList<>( + Arrays.asList("m0", "m1", "m2", "m3", "m4", "m5")); + private FastList tempTableAColumnsType = new FastList<>(Arrays.asList("text collate \"C\"", "int", + "text collate \"C\"", "text collate \"C\"", "text collate \"C\"", "text collate \"C\"")); + + private String rapport; + private boolean error = false; + public String jointure; + + public ChargeurXmlComplexe(ThreadChargementService threadChargementService, String fileName) { + this.fileName = fileName; + this.connexion = threadChargementService.getConnexion().getExecutorConnection(); + this.tableTempA = threadChargementService.getTableTempA(); + this.tableChargementPilTemp = threadChargementService.getTableChargementPilTemp(); + this.currentPhase = threadChargementService.getCurrentPhase(); + this.f = threadChargementService.filesInputStreamLoad.getTmpInxChargement(); + this.norme = threadChargementService.normeOk; + this.validite = threadChargementService.validite; + this.envExecution = threadChargementService.getEnvExecution(); + } + + public ChargeurXmlComplexe(Connection connexion, String fileName, InputStream f, String tableOut, String norme, + String periodicite, String validite, String envExecution) { + this.fileName = fileName; + this.connexion = connexion; + this.tableTempA = tableOut; + this.norme = new Norme(norme, periodicite, null, null); + this.validite = validite; + this.f = f; + this.envExecution = envExecution; + } + + /** + * Autonomous execution with parameters constructor + * + * @throws ArcException + */ + public void executeEngine() throws ArcException { + initialisation(); + execution(); + } + + @Override + public void initialisation() throws ArcException { + StaticLoggerDispatcher.info(LOGGER, "** requeteCreateA **"); + + java.util.Date beginDate = new java.util.Date(); + + NormeFichier normeFichier = new NormeFichier(this.norme.getIdNorme(), validite, this.norme.getPeriodicite()); + this.format = new ArrayList<>(); + + Map> regle = RulesOperations.getBean(this.connexion, + RulesOperations.getRegles(ViewEnum.CHARGEMENT_REGLE.getFullName(this.envExecution), normeFichier)); + if (regle.get("format").get(0) != null) { + for (String rule : regle.get("format").get(0).split("\n")) { + this.format.add(new Pair<>(rule.split(",")[0].trim(), rule.split(",")[1].trim())); } - } catch (ArcException e1) { } - - StringBuilder requete = new StringBuilder(); - requete.append(FormatSQL.dropTable(this.tableTempA)); - requete.append("CREATE "); - - if (!this.tableTempA.contains(".")) { - requete.append("TEMPORARY "); - } else { - requete.append(" "); - } - - // la table temporaire A : ids|id|d|data|nombre_colonnes - // data : contiendra les données chargé au format text séparée par des virgules - // nombre_colonnes : contiendra le nombre de colonne contenue dans data, nécessaire pour compléter la ligne avec des virgules - - requete.append(" TABLE " + this.tableTempA + " ("); - boolean noComma=true; - for (int i=0;i fils -> noeud(1) ou feuille(2) -> distance à la racine du + * renvoie un tableau ordonné selon la distance à la racine du pere + * pere -> fils -> noeud(1) ou feuille(2) -> distance à la racine du * pere * * @param tree * @param colDist * @return */ - public static int[][] getTreeArrayByDistance(HashMap tree, HashMap colDist) { + public static int[][] getTreeArrayByDistance(Map tree, Map colDist) { int[][] arr = new int[tree.size()][4]; int i = 0; @@ -50,7 +50,7 @@ public int compare(int[] o1, int[] o2) { } - public static String getLeafs(Integer arr2, int[][] arr, HashMap colData, FastList allCols) { + public static String getLeafs(Integer arr2, int[][] arr, Map colData, FastList allCols) { StringBuilder result = new StringBuilder(); for (int j = 0; j < arr.length; j++) { @@ -65,7 +65,7 @@ public static String getLeafs(Integer arr2, int[][] arr, HashMap colData, FastList allCols) { + public static String getLeafsSpace(Integer arr2, int[][] arr, Map colData, FastList allCols) { StringBuilder result = new StringBuilder(); for (int j = 0; j < arr.length; j++) { @@ -80,7 +80,7 @@ public static String getLeafsSpace(Integer arr2, int[][] arr, HashMap colData, FastList allCols) { + public static String getLeafsMax(Integer arr2, int[][] arr, Map colData, FastList allCols) { StringBuilder result = new StringBuilder(); for (int j = 0; j < arr.length; j++) { diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/XMLComplexeHandlerCharger.java b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/XMLComplexeHandlerCharger.java index de3c46bd3..32fbffc7a 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/XMLComplexeHandlerCharger.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/XMLComplexeHandlerCharger.java @@ -14,8 +14,6 @@ import org.xml.sax.SAXParseException; import fr.insee.arc.core.dataobjects.ColumnEnum; -import fr.insee.arc.core.model.XMLConstant; -import fr.insee.arc.core.service.global.ApiService; import fr.insee.arc.core.service.global.dao.DateConversion; import fr.insee.arc.core.service.p2chargement.bo.Norme; import fr.insee.arc.utils.dao.UtilitaireDao; @@ -92,12 +90,10 @@ public XMLComplexeHandlerCharger() { private List lineValues = new ArrayList<>(); private StringBuilder requete = new StringBuilder(); - private StringBuilder structure = new StringBuilder(); // indique que la balise courante a des données private boolean hasData = false; - public Norme normeCourante; public String validite; @@ -109,8 +105,6 @@ public XMLComplexeHandlerCharger() { // format to rename column with format rules public ArrayList> format; - public static final String JOINXML_QUERY_BLOCK = "\n -- query"; - public static final String JOINXML_STRUCTURE_BLOCK = "\n -- structure\n"; private static final String HEADER = "$h"; // initialize the integration date with current @@ -355,10 +349,6 @@ public void startElement(String uri, String localName, String qName, Attributes this.tree.put(this.allCols.indexOf(this.currentTag), this.allCols.indexOf(this.father)); } - // enregistrement de la structure - structure.append(("," + (this.father.equals(rootFather) ? XMLConstant.ROOT : "i_" + this.father)) + " " - + (this.father.equals(rootFather) ? "1" : this.col.get(this.father)) + " " + "i_" + this.currentTag); - if (this.tree.get(this.allCols.indexOf(this.currentTag)).equals(this.allCols.indexOf(this.father)) // cas des bloc multiples || (this.tree.get(this.allCols.indexOf(this.currentTag + HEADER)) != null @@ -605,10 +595,6 @@ private void requeteJointureXML() { req.append(reqSelect); req.append(reqFrom); - // la compression fait perdre trop de temp - // Mais apres, c'est sur que la table de pilotage devient un peu trop "grosse" - req.append(JOINXML_STRUCTURE_BLOCK); - req.append(structure.substring(1)); this.jointure = this.jointure + req.toString().replace("'", "''"); } diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/XMLHandlerCharger4.java b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/XMLHandlerCharger4.java index d1e95724c..022577459 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/XMLHandlerCharger4.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/XMLHandlerCharger4.java @@ -29,18 +29,17 @@ public class XMLHandlerCharger4 extends org.xml.sax.helpers.DefaultHandler { private static final Logger LOGGER = LogManager.getLogger(XMLHandlerCharger4.class); - - public XMLHandlerCharger4(Connection connexion, String fileName, Norme normeCourante, String validite, - String tempTableA, FastList tempTableAColumnsLongName, FastList tempTableAColumnsShortName) { - super(); - this.connexion = connexion; - this.fileName = fileName; - this.normeCourante = normeCourante; - this.validite = validite; - this.tempTableA = tempTableA; - this.tempTableAColumnsLongName = tempTableAColumnsLongName; - this.tempTableAColumnsShortName = tempTableAColumnsShortName; + String tempTableA, FastList tempTableAColumnsLongName, + FastList tempTableAColumnsShortName) { + super(); + this.connexion = connexion; + this.fileName = fileName; + this.normeCourante = normeCourante; + this.validite = validite; + this.tempTableA = tempTableA; + this.tempTableAColumnsLongName = tempTableAColumnsLongName; + this.tempTableAColumnsShortName = tempTableAColumnsShortName; } // input @@ -51,13 +50,18 @@ public XMLHandlerCharger4(Connection connexion, String fileName, Norme normeCour private String tempTableA; private FastList tempTableAColumnsLongName; private FastList tempTableAColumnsShortName; - + // output private String jointure = ""; - - + + // map le nom des balises trouvé dans le fichier XML avec leur nombre + // d'occurence en cours du traitement private HashMap col = new HashMap<>(); + // on met dans cette map les balises pour lesquels le parser a trouvé de la + // données + // l'integer ne sert à rien -> refactor avec un set private HashMap colData = new HashMap<>(); + private HashMap tree = new HashMap<>(); private HashMap treeNode = new HashMap<>(); @@ -67,14 +71,12 @@ public XMLHandlerCharger4(Connection connexion, String fileName, Norme normeCour private int idLigne = 0; private int distance = 0; - private String currentTag; private String closedTag; private String father = "*"; private StringBuilder currentData = new StringBuilder(); - /* * pour les rubriques recursives (au cas ou...) */ @@ -85,6 +87,7 @@ public XMLHandlerCharger4(Connection connexion, String fileName, Norme normeCour private List treeStackFather = new ArrayList<>(); private List treeStackFatherLag = new ArrayList<>(); + // contient la liste de toutes les balises trouvées dans le XML private FastList allCols = new FastList<>(); private List lineCols = new ArrayList<>(); private List lineCols11 = new ArrayList<>(); @@ -96,8 +99,6 @@ public XMLHandlerCharger4(Connection connexion, String fileName, Norme normeCour private ParallelInsert pi; - - private static final String ALTER = "ALTER"; private HashMap requetes = new HashMap<>(); @@ -106,8 +107,6 @@ public XMLHandlerCharger4(Connection connexion, String fileName, Norme normeCour // initialize the integration date with current private final String integrationDate = DateConversion.queryDateConversion(new Date()); - - /** * Actions à réaliser sur les données */ @@ -459,9 +458,7 @@ private String computeFinalQuery() { } /** - * Permet de générer la requête SQL de normage. C'est une méthode assez - * compliqué car on doit décomposer le fichier en bloc pour ensuite faire les - * jointure. + * Permet de générer la requête SQL de normage */ private void requeteJointureXML() { @@ -469,6 +466,7 @@ private void requeteJointureXML() { StringBuilder req = new StringBuilder(); int[][] arr = TreeFunctions.getTreeArrayByDistance(this.tree, this.colDist); + StringBuilder reqCreate = new StringBuilder(" \n"); StringBuilder reqInsert = new StringBuilder(); @@ -546,7 +544,6 @@ private void requeteJointureXML() { reqFrom.insert(0, "\n FROM "); reqFrom.append("\n WHERE true ) ww "); - // on ne met pas la parenthèse fermante exprées req.append(reqCreate); req.append(reqInsert); req.append(reqSelect); @@ -582,5 +579,5 @@ private void renameColumns(StringBuilder aRequete) { public String getJointure() { return jointure; } - + } diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngine.java b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngine.java index 670282e2e..7cf20b2c6 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngine.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngine.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -17,7 +18,6 @@ import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder; import fr.insee.arc.core.dataobjects.ColumnEnum; import fr.insee.arc.core.service.global.bo.ArcDateFormat; -import fr.insee.arc.core.service.p2chargement.xmlhandler.XMLComplexeHandlerCharger; import fr.insee.arc.core.util.StaticLoggerDispatcher; import fr.insee.arc.utils.dao.Parameter; import fr.insee.arc.utils.dao.ParameterType; @@ -41,7 +41,7 @@ public class NormageEngine { * idSource : nom du fichier jointure : requete de strucutration id_norme : * identifiant de norme validite : validite periodicite : periodicite */ - private HashMap> pilotageIdSource; + private Map> pilotageIdSource; /** * Les regles relatives au fichier (idSource) @@ -50,25 +50,28 @@ public class NormageEngine { * version text, id_classe text, rubrique text, rubrique_nmcl text, id_regle * integer, */ - private HashMap> regleInitiale; + private Map> regleInitiale; /** * liste des rubriques présentes dans le fichier idSource et réutilisées dans * les phase en aval Ces rubriques "var" sont à conserver id_norme, * validite_inf, validite_sup, periodicite, var */ - private HashMap> rubriqueUtiliseeDansRegles; + private Map> rubriqueUtiliseeDansRegles; private String tableSource; private String tableDestination; private String paramBatch; + + + // deprecated but requires patch in clients database + public static final String JOINXML_STRUCTURE_BLOCK = "\n -- structure\n"; - public String structure; - public NormageEngine(Connection connection, HashMap> pil, - HashMap> regle, HashMap> rubriqueUtiliseeDansRegles, + public NormageEngine(Connection connection, Map> pil, + Map> regle, Map> rubriqueUtiliseeDansRegles, String tableSource, String tableDestination, String paramBatch) { super(); this.connection = connection; @@ -169,19 +172,7 @@ private void complexExecutionWithJoinDefined(String jointure) throws ArcExceptio String periodicite = pilotageIdSource.get("periodicite").get(0); String validiteText = pilotageIdSource.get("validite").get(0); - // split structure blocks - String[] ss = jointure.split(XMLComplexeHandlerCharger.JOINXML_STRUCTURE_BLOCK); - - if (ss.length > 1) { - jointure = ss[0]; - this.structure = ss[1]; - } - - // split query blocks - int subJoinNumber = 0; - for (String subJoin : jointure.split(XMLComplexeHandlerCharger.JOINXML_QUERY_BLOCK)) { - - HashMap> regle = new HashMap<>(); + Map> regle = new HashMap<>(); for (String key : regleInitiale.keySet()) { ArrayList al = new ArrayList<>(); @@ -191,7 +182,7 @@ private void complexExecutionWithJoinDefined(String jointure) throws ArcExceptio regle.put(key, al); } - subJoin = subJoin.toLowerCase(); + String subJoin = jointure.split(JOINXML_STRUCTURE_BLOCK)[0].toLowerCase(); // ORDRE IMPORTANT // on supprime les rubriques inutilisées quand le service est invoqué en batch @@ -216,16 +207,13 @@ private void complexExecutionWithJoinDefined(String jointure) throws ArcExceptio subJoin = NormageEngineRegleRelation.appliquerRegleRelation(regle, subJoin); // retravaille de la requete pour éliminer UNION ALL - subJoin = optimisation96(subJoin, subJoinNumber); + subJoin = optimisation96(subJoin); executerJointure(regle, norme, validite, periodicite, subJoin, validiteText, idSource); - subJoinNumber++; - - } } - private String optimisation96(String jointure, int subjoinNumber) { + private String optimisation96(String jointure) { StaticLoggerDispatcher.info(LOGGER, "optimisation96()"); // on enleve l'id @@ -288,17 +276,10 @@ private String optimisation96(String jointure, int subjoinNumber) { + "\n insert into {table_destination}" + ManipString.substringAfterFirst(r, "insert into {table_destination}"); - if (subjoinNumber > 0) { - // on recrée les tables temporaires - r = r.replaceAll("create temporary table ([^ ]+) as ", - "drop table if exists $1; create temporary table $1 as "); - } else { - - // on crée la table destination avec les bonnes colonnes pour la premiere sous - // jointure + // on crée la table destination avec les bonnes colonnes pour la premiere sous + // jointure r = "drop table if exists {table_destination}; create temporary table {table_destination} as SELECT * FROM {table_source} where false; \n " + this.columnToBeAdded + "\n" + r; - } return r; } @@ -332,7 +313,7 @@ private ArcPreparedStatementBuilder applyQueryPlanParametersOnJointure(ArcPrepar * @return * @throws ArcException */ - private void executerJointure(HashMap> regle, String norme, Date validite, + private void executerJointure(Map> regle, String norme, Date validite, String periodicite, String jointure, String validiteText, String idSource) throws ArcException { // only first partition rule is processed @@ -372,7 +353,7 @@ private void executerJointure(HashMap> regle, String n * @param chunkSize * @throws ArcException */ - private void executerJointureWithPartition(HashMap> regle, String norme, Date validite, + private void executerJointureWithPartition(Map> regle, String norme, Date validite, String periodicite, String jointure, String validiteText, String idSource, String element, int minSize, int chunkSize) throws ArcException { /* get the query blocks */ diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleDuplication.java b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleDuplication.java index 69ecbce7b..ba9c19dd4 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleDuplication.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleDuplication.java @@ -2,8 +2,9 @@ import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -31,7 +32,7 @@ public class NormageEngineRegleDuplication { * @param jointure * @throws ArcException */ - protected static void ajouterRegleDuplication(HashMap> regle, String norme, Date validite, + protected static void ajouterRegleDuplication(Map> regle, String norme, Date validite, String periodicite, String jointure) { StaticLoggerDispatcher.info(LOGGER, "ajouterRegleDuplication()"); @@ -94,7 +95,7 @@ protected static void ajouterRegleDuplication(HashMap> } - protected static String appliquerRegleDuplication(HashMap> regle, String norme, Date validite, + protected static String appliquerRegleDuplication(Map> regle, String norme, Date validite, String periodicite, String jointure, StringBuilder columnToBeAdded) { StaticLoggerDispatcher.info(LOGGER, "appliquerRegleDuplication()"); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleIndependance.java b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleIndependance.java index 8c4140ad9..b9f1d69ab 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleIndependance.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleIndependance.java @@ -4,6 +4,8 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -30,7 +32,7 @@ public class NormageEngineRegleIndependance { * @param jointure * @throws ArcException */ - protected static void ajouterRegleIndependance(HashMap> regle, String norme, + protected static void ajouterRegleIndependance(Map> regle, String norme, Date validite, String periodicite, String jointure) { StaticLoggerDispatcher.info(LOGGER, "ajouterRegleIndependance()"); @@ -112,7 +114,7 @@ protected static void ajouterRegleIndependance(HashMap * @return * @throws ArcException */ - protected static String appliquerRegleIndependance(HashMap> regle, String norme, + protected static String appliquerRegleIndependance(Map> regle, String norme, Date validite, String periodicite, String jointure) throws ArcException { StaticLoggerDispatcher.info(LOGGER, "appliquerRegleIndependance()"); @@ -400,7 +402,7 @@ private static boolean calculerTableIndependance(StringBuilder blocRequete, bool * @param exclusion */ private static void addIndependanceToChildren(ArrayList r, String blocCreate, String mRubrique, - HashMap> regle, HashMap rubriquesAvecRegleDIndependance, + Map> regle, HashMap rubriquesAvecRegleDIndependance, String norme, String periodicite, HashSet exclusion) { ArrayList s = NormageEngineGlobal.getChildren(blocCreate, mRubrique); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleRelation.java b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleRelation.java index 2f1ee112b..d92b67d2c 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleRelation.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleRelation.java @@ -1,7 +1,8 @@ package fr.insee.arc.core.service.p3normage.engine; import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,7 +27,7 @@ public class NormageEngineRegleRelation { * @return * @throws ArcException */ - protected static String appliquerRegleRelation(HashMap> regle, String jointure) { + protected static String appliquerRegleRelation(Map> regle, String jointure) { StaticLoggerDispatcher.info(LOGGER, "appliquerRegleRelation()"); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleSupression.java b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleSupression.java index 72035bca3..dfcc5bebc 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleSupression.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleSupression.java @@ -2,7 +2,8 @@ import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -29,8 +30,8 @@ public class NormageEngineRegleSupression { * @throws ArcException */ - protected static void ajouterRegleSuppression(HashMap> regle, String norme, - String periodicite, String jointure, HashMap> rubriqueUtiliseeDansRegles) + protected static void ajouterRegleSuppression(Map> regle, String norme, + String periodicite, String jointure, Map> rubriqueUtiliseeDansRegles) throws ArcException { // on va jouer au "qui enleve-t-on" ?? // on va parcourir les regles de normage, controle, mapping et voir @@ -38,8 +39,8 @@ protected static void ajouterRegleSuppression(HashMap> // op 1 : identifier les blocs inutiles - ArrayList listVarUtilisee = new ArrayList(); - ArrayList lineASupprimer = new ArrayList(); + ArrayList listVarUtilisee = new ArrayList<>(); + ArrayList lineASupprimer = new ArrayList<>(); for (int j = 0; j < rubriqueUtiliseeDansRegles.get("id_norme").size(); j++) { listVarUtilisee.add(rubriqueUtiliseeDansRegles.get("var").get(j)); @@ -187,7 +188,7 @@ protected static void ajouterRegleSuppression(HashMap> * @return * @throws ArcException */ - protected static String appliquerRegleSuppression(HashMap> regle, String norme, + protected static String appliquerRegleSuppression(Map> regle, String norme, Date validite, String periodicite, String jointure) throws ArcException { StaticLoggerDispatcher.info(LOGGER, "appliquerRegleSuppression()"); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleUnicite.java b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleUnicite.java index a612c98ce..81040dbd0 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleUnicite.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineRegleUnicite.java @@ -1,7 +1,7 @@ package fr.insee.arc.core.service.p3normage.engine; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,7 +26,7 @@ public class NormageEngineRegleUnicite { * @return * @throws ArcException */ - protected static String appliquerRegleUnicite(HashMap> regle, String jointure) { + protected static String appliquerRegleUnicite(Map> regle, String jointure) { StaticLoggerDispatcher.info(LOGGER, "appliquerRegleUnicite()"); String returned = jointure; diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/thread/ThreadNormageService.java b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/thread/ThreadNormageService.java index 914aaf077..35f7f6904 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/thread/ThreadNormageService.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/thread/ThreadNormageService.java @@ -1,7 +1,7 @@ package fr.insee.arc.core.service.p3normage.thread; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -172,15 +172,15 @@ private void jointureBlocXML() throws ArcException { // récupérer les caractéristiques du fichier - HashMap> pil = RulesOperations.getBean(this.connexion.getExecutorConnection(),RulesOperations.getNormeAttributes(this.idSource, tableNormagePilTemp)); + Map> pil = RulesOperations.getBean(this.connexion.getExecutorConnection(),RulesOperations.getNormeAttributes(this.idSource, tableNormagePilTemp)); // récupéreration des règles relative au fichier pour la phase courante - HashMap> regle = RulesOperations.getBean(this.connexion.getExecutorConnection(),RulesOperations.getRegles(ViewEnum.NORMAGE_REGLE.getFullName(envExecution), this.tableNormagePilTemp)); + Map> regle = RulesOperations.getBean(this.connexion.getExecutorConnection(),RulesOperations.getRegles(ViewEnum.NORMAGE_REGLE.getFullName(envExecution), this.tableNormagePilTemp)); // récupéreration des rubriques utilisées dans règles relative au fichier pour l'ensemble des phases - HashMap> rubriqueUtiliseeDansRegles=null; + Map> rubriqueUtiliseeDansRegles=null; if (paramBatch!=null) { @@ -200,9 +200,6 @@ private void jointureBlocXML() throws ArcException { NormageEngine n=new NormageEngine(this.connexion.getExecutorConnection() , pil, regle, rubriqueUtiliseeDansRegles, this.tableNormageDataTemp, this.tableNormageOKTemp, this.paramBatch); n.execute(); - - this.structure=n.structure; - } diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/engine/ServiceJeuDeRegle.java b/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/engine/ServiceJeuDeRegle.java index 365cabf85..cb06efca9 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/engine/ServiceJeuDeRegle.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/engine/ServiceJeuDeRegle.java @@ -74,7 +74,7 @@ public void fillRegleControle(Connection connexion, JeuDeRegle jdr, String table * la table de travail dont les enregistrement seront "marqués" * @throws ArcException */ - public void executeJeuDeRegle(Connection connexion, JeuDeRegle jdr, String table, String structure) throws ArcException { + public void executeJeuDeRegle(Connection connexion, JeuDeRegle jdr, String table) throws ArcException { StaticLoggerDispatcher.debug(LOGGER, "executeJeuDeRegle"); java.util.Date date = new java.util.Date(); @@ -86,7 +86,7 @@ public void executeJeuDeRegle(Connection connexion, JeuDeRegle jdr, String table preAction(connexion, jdr, table); // execute the control rules - control(connexion, jdr, table, structure); + control(connexion, jdr, table); StaticLoggerDispatcher.info(LOGGER, "Temps de controle : " + (new java.util.Date().getTime() - date.getTime())); @@ -160,7 +160,7 @@ private void preAction(Connection connexion, JeuDeRegle jdr, String table) throw * @param structure * @throws ArcException */ - private void control(Connection connexion, JeuDeRegle jdr, String table, String structure) throws ArcException { + private void control(Connection connexion, JeuDeRegle jdr, String table) throws ArcException { StringBuilder blocRequete = new StringBuilder(); blocRequete.append(this.servSql.initTemporaryTable(table)); @@ -208,14 +208,6 @@ private void control(Connection connexion, JeuDeRegle jdr, String table, String LOGGER, "la rubrique : " + reg.getRubriquePere() + " n'existe pas dans ce fichier"); } break; - case "STRUCTURE": - { - if (tableControleRegle!=null && structure!=null) - { - blocRequete.append(this.servSql.ctlStructure(reg,structure,tableControleRegle)); - } - } - break; case "CONDITION": blocRequete.append(executeRegleCondition(jdr, reg)); blocRequete.append(System.lineSeparator()); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/engine/dao/ServiceRequeteSqlRegle.java b/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/engine/dao/ServiceRequeteSqlRegle.java index 26de5d6e8..85b45c13b 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/engine/dao/ServiceRequeteSqlRegle.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/engine/dao/ServiceRequeteSqlRegle.java @@ -232,50 +232,6 @@ public String ctlIsAlphanum(RegleControleEntity reg) { } - /** - * Structure control - * check if all the tags found in the file are in the ruleset - * and in the same order as in the ruleset - * @param structure - * @param jdr - * @param tableControleRegle - * @return - */ - public String ctlStructure(RegleControleEntity reg, String structure, String tableControleRegle) { - - StringBuilder requete=new StringBuilder(); - requete.append("\n with"); - requete.append("\n tmp_jointure as ("); - requete.append("\n select split_part(b.e,' ',1) as pere, split_part(b.e,' ',2) as pere_id, split_part(b.e,' ',3) as fils, n from unnest(('{'||'"+structure+"'||'}')::text[]) with ordinality b(e,n)"); - requete.append("\n )"); - requete.append("\n , tmp_num as ("); - requete.append("\n select pere, pere_id, fils, row_number() over (partition by pere, pere_id order by n) as rk from ("); - requete.append("\n select pere, pere_id, fils, coalesce(lag(fils) over (partition by pere, pere_id order by n),'*') as prev_fils, n from tmp_jointure"); - requete.append("\n ) vv where fils!=prev_fils"); - requete.append("\n )"); - requete.append("\n , tmp_regle as ("); - requete.append("\n select rubrique_pere as p, rubrique_fils as f, xsd_ordre from "+tableControleRegle+" a "); - requete.append("\n where xsd_ordre is not null"); - requete.append("\n AND EXISTS (SELECT 1 FROM (SELECT id_norme, periodicite, validite FROM "+this.tableTempData+" LIMIT 1) b "); - requete.append("\n WHERE a.id_norme=b.id_norme "); - requete.append("\n AND a.periodicite=b.periodicite "); - requete.append("\n AND to_date(b.validite,'"+ArcDateFormat.DATE_FORMAT_CONVERSION.getDatastoreFormat()+"')>=a.validite_inf "); - requete.append("\n AND to_date(b.validite,'"+ArcDateFormat.DATE_FORMAT_CONVERSION.getDatastoreFormat()+"')<=a.validite_sup) "); - requete.append("\n )"); - requete.append("\n , tmp_check as ("); - requete.append("\n select pere, pere_id, fils from ("); - requete.append("\n select a.pere, a.pere_id, a.fils, rk, dense_rank() over (partition by p, a.pere_id order by xsd_ordre) as r"); - requete.append("\n from tmp_num a left join tmp_regle b"); - requete.append("\n on a.pere=b.p and a.fils=b.f"); - requete.append("\n ) vv"); - requete.append("\n where rk!=r"); - requete.append("\n )"); - requete.append("\n , ctl as (select id from this.tableTempData WHERE EXISTS (SELECT from tmp_check))"); - requete.append(insertBloc(reg.getBlockingThreshold(),reg.getErrorRowProcessing(),reg.getIdRegle())); - - return requete.toString(); - } - public String ctlCardinalite(RegleControleEntity reg, List listRubriqueExpr, List ListRubriqueTable) { // on retire le pere et le fils de la liste d'expr diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/thread/ThreadControleService.java b/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/thread/ThreadControleService.java index e1f07d74a..b1d28cc78 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/thread/ThreadControleService.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p4controle/thread/ThreadControleService.java @@ -48,8 +48,6 @@ public class ThreadControleService extends ApiControleService implements Runnabl private ServiceJeuDeRegle sjdr; private JeuDeRegle jdr; - - private String structure; private ThreadOperations arcThreadGenericDao; @@ -145,8 +143,6 @@ private void preparation() throws ArcException { // Récupération des Jeux de règles associés this.sjdr.fillRegleControle(this.connexion.getExecutorConnection(), jdr, ViewEnum.CONTROLE_REGLE.getFullName(envExecution), this.tableControleDataTemp); - this.structure = UtilitaireDao.get(0).getString(this.connexion.getExecutorConnection(), - new ArcPreparedStatementBuilder("SELECT jointure FROM " + this.tableControlePilTemp)); } /** @@ -161,8 +157,7 @@ private void preparation() throws ArcException { private void execute() throws ArcException { StaticLoggerDispatcher.info(LOGGER, "** execute CONTROLE sur la table : " + this.tableControleDataTemp + " **"); - this.sjdr.executeJeuDeRegle(this.connexion.getExecutorConnection(), jdr, this.tableControleDataTemp, - this.structure); + this.sjdr.executeJeuDeRegle(this.connexion.getExecutorConnection(), jdr, this.tableControleDataTemp); } diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p5mapping/engine/RequeteMapping.java b/arc-core/src/main/java/fr/insee/arc/core/service/p5mapping/engine/RequeteMapping.java index c003de8c6..eb0bf1278 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p5mapping/engine/RequeteMapping.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p5mapping/engine/RequeteMapping.java @@ -157,12 +157,11 @@ private void attribuerExpressionRegleMapping(Map mapVar .append(this.nomTableRegleMapping).append("\n WHERE ").append(this.jeuDeRegle.getSqlEquals()) .append(";"); - List> resultTemp = Format - .patch(UtilitaireDao.get(0).executeRequest(this.connexion, requete)); + List> resultTemp = UtilitaireDao.get(0).executeRequest(this.connexion, requete); if (resultTemp.size() == 2) { throw new ArcException(ArcExceptionMessage.MAPPING_RULES_NOT_FOUND); } - ArrayList> result = new ArrayList<>(); + List> result = new ArrayList<>(); for (int i = 0; i < resultTemp.size(); i++) { // mise en minuscule des rubriques @@ -289,7 +288,7 @@ private Map construireTablesEtVariablesMapping() throws requete.append(this.nomTableModVariableMetier); requete.append("\n WHERE id_famille = " + requete.quoteText(this.idFamille) + ";"); - List> result = Format.patch(UtilitaireDao.get(0).executeRequest(this.connexion, requete)); + List> result = UtilitaireDao.get(0).executeRequest(this.connexion, requete); for (int i = ARRAY_THIRD_COLUMN_INDEX; i < result.size(); i++) { /* @@ -342,7 +341,7 @@ public String getRequete(String aNomFichier) throws ArcException { Map reglesIdentifiantes = new HashMap<>(); Map nomsVariablesGroupe = new HashMap<>(); - HashMap linkedIds = new HashMap<>(); + Map linkedIds = new HashMap<>(); construireListeIdentifiants(reglesIdentifiantes, nomsVariablesGroupe, linkedIds); construireTableIdentifiantsFichierCourant(requeteGlobale, reglesIdentifiantes, nomsVariablesGroupe, @@ -708,7 +707,7 @@ private StringBuilder construireTablePrecedente(StringBuilder returned) { */ private StringBuilder construireTableIdentifiantsFichierCourant(StringBuilder returned, Map reglesIdentifiantes, Map nomsVariablesGroupe, - HashMap linkedIds) { + Map linkedIds) { this.nomTableFichierCourant = "fichier"; HashSet alreadyAdded = new HashSet<>(); @@ -778,7 +777,7 @@ private StringBuilder construireTableIdentifiantsFichierCourant(StringBuilder re * @param reglesIdentifiantes */ private void construireListeIdentifiants(Map reglesIdentifiantes, - Map nomsVariablesGroupe, HashMap linkedIds) { + Map nomsVariablesGroupe, Map linkedIds) { Set reglesClefs = new HashSet<>(); for (TableMapping table : this.ensembleTableMapping) { diff --git a/arc-core/src/main/resources/BdD/script_global.sql b/arc-core/src/main/resources/BdD/script_global.sql index 5296533cc..9747b700b 100644 --- a/arc-core/src/main/resources/BdD/script_global.sql +++ b/arc-core/src/main/resources/BdD/script_global.sql @@ -495,7 +495,7 @@ end loop; end; $$; - +-- PATCH 03/07/2023 -- 3. suppression et recopie des tables de filtrage de données do $$ declare diff --git a/arc-core/src/main/resources/BdD/script_global_phase_controle.sql b/arc-core/src/main/resources/BdD/script_global_phase_controle.sql index 823e04987..3a99d505d 100644 --- a/arc-core/src/main/resources/BdD/script_global_phase_controle.sql +++ b/arc-core/src/main/resources/BdD/script_global_phase_controle.sql @@ -43,8 +43,25 @@ INSERT INTO arc.ext_type_controle values ('NUM','3') ON CONFLICT DO NOTHING; INSERT INTO arc.ext_type_controle values ('REGEXP', '6') ON CONFLICT DO NOTHING; INSERT INTO arc.ext_type_controle values ('ENUM_BRUTE', '7') ON CONFLICT DO NOTHING; INSERT INTO arc.ext_type_controle values ('ENUM_TABLE', '8') ON CONFLICT DO NOTHING; -INSERT INTO arc.ext_type_controle values ('STRUCTURE', '9') ON CONFLICT DO NOTHING; DROP TRIGGER IF EXISTS doublon ON arc.ihm_controle_regle CASCADE; do $$ begin CREATE TRIGGER tg_insert_controle BEFORE INSERT ON arc.ihm_controle_regle FOR EACH ROW EXECUTE PROCEDURE arc.insert_controle(); exception when others then end; $$; + + + +-- PATCH 06/10/2023 Remove deprecated rules +DELETE FROM arc.ext_type_controle where id='STRUCTURE'; + +do $$ +declare + table_regle_controle text; +BEGIN +for table_regle_controle in (select schemaname||'.'||tablename from pg_tables where (tablename='controle_regle' and schemaname like 'arc_bas%') or (tablename='ihm_controle_regle' and schemaname = 'arc') ) +loop +execute 'DELETE FROM '||table_regle_controle||' WHERE id_classe= ''STRUCTURE'';'; +commit; +end loop; +end; +$$; + diff --git a/arc-core/src/main/resources/BdD/script_global_phase_normage.sql b/arc-core/src/main/resources/BdD/script_global_phase_normage.sql index b9849c488..48757407b 100644 --- a/arc-core/src/main/resources/BdD/script_global_phase_normage.sql +++ b/arc-core/src/main/resources/BdD/script_global_phase_normage.sql @@ -34,3 +34,18 @@ INSERT INTO arc.ext_type_normage values ('independance','8') ON CONFLICT DO NOTH do $$ begin CREATE TRIGGER tg_insert_normage BEFORE INSERT ON arc.ihm_normage_regle FOR EACH ROW EXECUTE PROCEDURE arc.insert_controle(); exception when others then end; $$; +-- PATCH 06/10/2023 Remove deprecated rules +DELETE FROM arc.ext_type_normage where id in ('suppression','exclusion', 'reduction'); + +do $$ +declare + table_regle_normage text; +BEGIN +for table_regle_normage in (select schemaname||'.'||tablename from pg_tables where (tablename='normage_regle' and schemaname like 'arc_bas%') or (tablename='ihm_normage_regle' and schemaname = 'arc') ) +loop +execute 'DELETE FROM '||table_regle_normage||' WHERE id_classe in (''suppression'',''exclusion'', ''reduction'');'; +commit; +end loop; +end; +$$; + diff --git a/arc-core/src/main/resources/documentation/class-diagram-services-full.puml b/arc-core/src/main/resources/documentation/class-diagram-services-full.puml index b4338941e..c0c9c09f3 100644 --- a/arc-core/src/main/resources/documentation/class-diagram-services-full.puml +++ b/arc-core/src/main/resources/documentation/class-diagram-services-full.puml @@ -24,7 +24,7 @@ abstract class AbstractService [[java:fr.insee.arc.core.service.AbstractService] #String idSource +{static}String SEPARATEUR_JOINTURE_XML #Boolean todo - #HashMap> tabIdSource + #Map> tabIdSource #String tableNorme #Integer cptBoucle -String tableOutKo @@ -71,7 +71,7 @@ abstract class AbstractPhaseService [[java:fr.insee.arc.core.service.AbstractPha #String idSource +{static}String SEPARATEUR_JOINTURE_XML #Boolean todo - #HashMap> tabIdSource + #Map> tabIdSource #String tableNorme #Integer cptBoucle #String tableOutKo @@ -130,7 +130,7 @@ abstract class "AbstractThreadRunnerService" as -AbstractThreadService createThread(int currentIndice, Connection connectionThread) +void waitForAbstractServiceThreads(int parallel, List threadList, List connexionList) +{static}ArrayList prepareThreads(int parallel, Connection connexion) - +HashMap> pilotageListIdsource(String tablePilotage, String aCurrentPhase, String etat) + +Map> pilotageListIdsource(String tablePilotage, String aCurrentPhase, String etat) +Connection chooseConnection(Connection connextionThread, List threadList, List connexionList) } @@ -151,7 +151,7 @@ class ApiChargementService [[java:fr.insee.arc.core.service.ApiChargementService +int start #String fileName #List listeNorme - -HashMap> listIdsource + -Map> listIdsource } interface IApiServiceWithoutOutputTablePreviousPhase [[java:fr.insee.arc.core.service.IApiServiceWithoutOutputTablePreviousPhase]] { diff --git a/arc-core/src/test/java/fr/insee/arc/core/service/engine/initialisation/BddPatcherTest.java b/arc-core/src/test/java/fr/insee/arc/core/service/engine/initialisation/BddPatcherTest.java index c2dd606ca..3bbbe92c8 100644 --- a/arc-core/src/test/java/fr/insee/arc/core/service/engine/initialisation/BddPatcherTest.java +++ b/arc-core/src/test/java/fr/insee/arc/core/service/engine/initialisation/BddPatcherTest.java @@ -5,8 +5,8 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.commons.io.IOUtils; import org.junit.Test; @@ -63,7 +63,7 @@ public static void testDatabaseCreation() throws ArcException query.append("select tablename from pg_tables where schemaname=") .append(query.quoteText(testMetaDataSchema)); - HashMap> content; + Map> content; content = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)) .mapContent(); @@ -228,7 +228,7 @@ public void retrieveRulesTablesFromSchemaTest() throws ArcException { initializeDatabaseForRetrieveTablesFromSchemaTest(u); // invocation de la fonction à tester - ArrayList result; + List result; result = BddPatcher.retrieveRulesTablesFromSchema(c, testSandbox3); // test : on enleve tous les éléments à retenir et l'array list devra être au final vide diff --git a/arc-core/src/test/java/fr/insee/arc/core/service/global/dao/ServiceDateTest.java b/arc-core/src/test/java/fr/insee/arc/core/service/global/dao/ServiceDateTest.java index 85420ec83..d82d1a653 100644 --- a/arc-core/src/test/java/fr/insee/arc/core/service/global/dao/ServiceDateTest.java +++ b/arc-core/src/test/java/fr/insee/arc/core/service/global/dao/ServiceDateTest.java @@ -4,9 +4,9 @@ import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.junit.Test; @@ -27,7 +27,7 @@ public void queryDateConversion() throws ArcException, ParseException { GenericPreparedStatementBuilder gb=new GenericPreparedStatementBuilder(); gb.append("SELECT "+DateConversion.queryDateConversion(testDate)+" as test_date"); - HashMap> content= new GenericBean(UtilitaireDao.get(0).executeRequest(c, gb)).mapContent(); + Map> content= new GenericBean(UtilitaireDao.get(0).executeRequest(c, gb)).mapContent(); assertEquals("1975-12-16", content.get("test_date").get(0)); diff --git a/arc-core/src/test/java/fr/insee/arc/core/service/global/dao/ServicePilotageOperationTest.java b/arc-core/src/test/java/fr/insee/arc/core/service/global/dao/ServicePilotageOperationTest.java index 52b400477..1689bfa74 100644 --- a/arc-core/src/test/java/fr/insee/arc/core/service/global/dao/ServicePilotageOperationTest.java +++ b/arc-core/src/test/java/fr/insee/arc/core/service/global/dao/ServicePilotageOperationTest.java @@ -2,7 +2,7 @@ import static org.junit.Assert.assertEquals; -import java.util.ArrayList; +import java.util.List; import org.junit.Test; @@ -24,7 +24,7 @@ public void retrieveIdSourceFromPilotageQueryTest() throws ArcException { u.executeImmediate(c, "INSERT INTO "+tablePil+" select 'f3', 'CHARGEMENT', '{OK}'"); - ArrayList listOfIdSource = new GenericBean(u.executeRequest(c, + List listOfIdSource = new GenericBean(u.executeRequest(c, PilotageOperations.querySelectIdSourceFromPilotage("public", TraitementPhase.MAPPING, TraitementEtat.OK) )).mapContent().get("id_source"); diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/dao/AbstractEntity.java b/arc-utils/src/main/java/fr/insee/arc/utils/dao/AbstractEntity.java index 6e7e778e1..27b16b6c5 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/dao/AbstractEntity.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/dao/AbstractEntity.java @@ -21,7 +21,7 @@ public AbstractEntity() { } - public AbstractEntity(Map> mapInputFields) { + public AbstractEntity(Map> mapInputFields) { this.map = new HashMap<>(); } diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/dao/EntityProvider.java b/arc-utils/src/main/java/fr/insee/arc/utils/dao/EntityProvider.java index eb994d17f..4c26cd125 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/dao/EntityProvider.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/dao/EntityProvider.java @@ -26,9 +26,9 @@ private EntityProvider() super(); } - private static final class ArrayOfArrayProvider extends EntityProvider>> { + private static final class ArrayOfArrayProvider extends EntityProvider>> { @Override - public ArrayList> apply(ResultSet res) { + public List> apply(ResultSet res) { try { return fromResultSetToArray(res); } catch (ArcException ex) { @@ -37,11 +37,11 @@ public ArrayList> apply(ResultSet res) { } } - public static final EntityProvider>> getArrayOfArrayProvider() { + public static final EntityProvider>> getArrayOfArrayProvider() { return new ArrayOfArrayProvider(); } - public static ArrayList> fromResultSetToArray(ResultSet res) throws ArcException { + public static List> fromResultSetToArray(ResultSet res) throws ArcException { return fromResultSetToList(() -> new ArrayList<>(), new ArrayList<>(), res); } diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/dao/GenericPreparedStatementBuilder.java b/arc-utils/src/main/java/fr/insee/arc/utils/dao/GenericPreparedStatementBuilder.java index ccaab163b..ac1bb9631 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/dao/GenericPreparedStatementBuilder.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/dao/GenericPreparedStatementBuilder.java @@ -329,10 +329,10 @@ public GenericPreparedStatementBuilder insertWithGenericBeanByChunk(String table // if chunkstop too high, limit it to the size of generic bean content chunkStop = (chunkStop > gb.getContent().size()) ? gb.getContent().size() : chunkStop; - ArrayList types = gb.getTypes(); + List types = gb.getTypes(); for (int i = chunkStart; i < chunkStop; i++) { - ArrayList line = gb.getContent().get(i); + List line = gb.getContent().get(i); if (firstLine) { firstLine = false; diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/dao/UtilitaireDao.java b/arc-utils/src/main/java/fr/insee/arc/utils/dao/UtilitaireDao.java index 750748447..4676017f4 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/dao/UtilitaireDao.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/dao/UtilitaireDao.java @@ -232,7 +232,7 @@ public void dropTable(Connection connexion, List someTables) { * @throws ArcException */ public String getString(Connection connexion, GenericPreparedStatementBuilder requete) throws ArcException { - ArrayList> returned = executeRequest(connexion, requete, + List> returned = executeRequest(connexion, requete, new ModeRequete[] { ModeRequete.EXTRA_FLOAT_DIGIT }); return (returned.size() <= EXECUTE_REQUEST_DATA_START_INDEX ? null : returned.get(EXECUTE_REQUEST_DATA_START_INDEX).get(0)); @@ -250,7 +250,7 @@ public String getString(Connection connexion, GenericPreparedStatementBuilder re */ public int getInt(Connection connexion, GenericPreparedStatementBuilder sql, ModeRequete... modes) { try { - ArrayList> returned = executeRequest(connexion, sql, modes); + List> returned = executeRequest(connexion, sql, modes); return (returned.size() <= EXECUTE_REQUEST_DATA_START_INDEX ? ZERO : Integer.parseInt(returned.get(EXECUTE_REQUEST_DATA_START_INDEX).get(0))); } catch (Exception ex) { @@ -282,9 +282,9 @@ public boolean isColonneExiste(Connection aConnexion, String aNomTable, String a * @return * @throws ArcException */ - public ArrayList> executeRequestWithoutMetadata(Connection connexion, + public List> executeRequestWithoutMetadata(Connection connexion, GenericPreparedStatementBuilder requete, ModeRequete... modes) throws ArcException { - ArrayList> returned = executeRequest(connexion, requete, modes); + List> returned = executeRequest(connexion, requete, modes); returned.remove(0); returned.remove(0); return returned; @@ -366,13 +366,13 @@ public Boolean testResultRequest(Connection connexion, GenericPreparedStatementB * * */ - public ArrayList> executeRequest(Connection connexion, GenericPreparedStatementBuilder requete, + public List> executeRequest(Connection connexion, GenericPreparedStatementBuilder requete, ModeRequete[] modes) throws ArcException { return executeRequest(connexion, requete, EntityProvider.getArrayOfArrayProvider(), modes); } - public ArrayList> executeRequest(Connection connexion, GenericPreparedStatementBuilder requete) + public List> executeRequest(Connection connexion, GenericPreparedStatementBuilder requete) throws ArcException { return executeRequest(connexion, requete, EntityProvider.getArrayOfArrayProvider(), new ModeRequete[] {}); @@ -387,7 +387,7 @@ public ArrayList> executeRequest(Connection connexion, Generic * @return * @throws ArcException */ - public ArrayList> executeStatement(Connection connexion, GenericPreparedStatementBuilder requete) + public List> executeStatement(Connection connexion, GenericPreparedStatementBuilder requete) throws ArcException { return executeStatement(connexion, requete, EntityProvider.getArrayOfArrayProvider()); @@ -547,7 +547,7 @@ public T executeRequest(Connection connexion, GenericPreparedStatementBuilde * @param l * @return */ - public static boolean hasResults(ArrayList> l) { + public static boolean hasResults(List> l) { return (l.size() > 2); } @@ -653,7 +653,7 @@ public void getFilesDataStreamFromListOfInputDirectories(Connection connexion, List listRepertoireIn) { LoggerHelper.debugDebutMethodeAsComment(getClass(), "copieFichiers()", LOGGER); GenericBean g; - ArrayList listFichier = new ArrayList<>(); + List listFichier = new ArrayList<>(); File fileIn = null; boolean find; String receptionDirectoryRoot = ""; diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/exception/ArcExceptionMessage.java b/arc-utils/src/main/java/fr/insee/arc/utils/exception/ArcExceptionMessage.java index 4b969080b..0bd8ca700 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/exception/ArcExceptionMessage.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/exception/ArcExceptionMessage.java @@ -94,7 +94,10 @@ public enum ArcExceptionMessage { GUI_FAMILLENORME_VARIABLE_NULL("Une variable a un nom null"), GUI_FAMILLENORME_VARIABLE_NO_TARGET_TABLE("Vous avez oublié de spécifier les tables cibles pour votre variable"), GUI_FAMILLENORME_VARIABLE_ALREADY_EXISTS("La variable existe déjà. Pour la modifier, passez par la ligne correspondante du tableau variable*table.\nAucune variable n'a été ajoutée.\n"), - GUI_EXPORT_TABLE_NOT_EXISTS("La table n'existe pas") + GUI_EXPORT_TABLE_NOT_EXISTS("La table n'existe pas"), + + DATE_PARSE_FAILED_VALIDITE_INF("La validité inf %s n'a pu être parsée"), + DATE_PARSE_FAILED_VALIDITE_SUP("La validité sup %s n'a pu être parsée") ; diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/files/CompressedUtils.java b/arc-utils/src/main/java/fr/insee/arc/utils/files/CompressedUtils.java index 7e4ea7e96..78b8113f6 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/files/CompressedUtils.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/files/CompressedUtils.java @@ -9,6 +9,7 @@ import java.io.OutputStream; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.List; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import java.util.zip.ZipEntry; @@ -100,7 +101,7 @@ public static void generateEntryFromFile(String receptionDirectoryRoot, String i * @param listIdSourceContainer */ public static void generateEntryFromZip(String receptionDirectoryRoot, String currentContainer, - ArrayList listIdSourceContainer, TarArchiveOutputStream taos) { + List listIdSourceContainer, TarArchiveOutputStream taos) { File fileIn = Paths.get(receptionDirectoryRoot, currentContainer).toFile(); if (fileIn.exists()) { try { @@ -138,7 +139,7 @@ public static void generateEntryFromZip(String receptionDirectoryRoot, String cu * @param taos */ public static void generateEntryFromTarGz(String receptionDirectoryRoot, String currentContainer, - ArrayList listIdSourceContainer, TarArchiveOutputStream taos) { + List listIdSourceContainer, TarArchiveOutputStream taos) { File fileIn = new File(receptionDirectoryRoot + File.separator + currentContainer); LoggerHelper.traceAsComment(LOGGER, "#generateEntryFromTarGz()", receptionDirectoryRoot, "/", currentContainer); @@ -178,7 +179,7 @@ public static void generateEntryFromTarGz(String receptionDirectoryRoot, String * @param taos */ public static void generateEntryFromGz(String receptionDirectoryRoot, String currentContainer, - ArrayList listIdSourceContainer, TarArchiveOutputStream taos) { + List listIdSourceContainer, TarArchiveOutputStream taos) { File fileIn = new File(receptionDirectoryRoot + "/" + currentContainer); if (fileIn.exists()) { try { diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/format/Format.java b/arc-utils/src/main/java/fr/insee/arc/utils/format/Format.java index 241a7f36e..9ab6d1d50 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/format/Format.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/format/Format.java @@ -14,21 +14,6 @@ public class Format implements IConstanteCaractere { private Format() { throw new IllegalStateException("Utility class"); } - - /** - * Transforme a list of list in list - * @param array - * an ArrayList - * @return a List - */ - public static List> patch(ArrayList> array) { - List> returned = new ArrayList<>(); - for (int i = 0; i < array.size(); i++) { - returned.add(array.get(i)); - } - return returned; - } - /** * tokenize an expression and trim tokens diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/structure/GenericBean.java b/arc-utils/src/main/java/fr/insee/arc/utils/structure/GenericBean.java index e4e0e976d..9fd43c5e3 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/structure/GenericBean.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/structure/GenericBean.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.commons.lang3.ObjectUtils; @@ -24,16 +25,16 @@ */ public class GenericBean { - private ArrayList headers; - private ArrayList types; - public ArrayList> content; + private List headers; + private List types; + public List> content; /** * @param headers * @param types * @param content */ - public GenericBean(ArrayList headers, ArrayList types, ArrayList> content) { + public GenericBean(List headers, List types, List> content) { this.headers = headers; this.types = types; this.content = content; @@ -51,9 +52,9 @@ public GenericBean(String headers, String types, List contentList) { } - protected static ArrayList> reworkListAsContent(List contentList) { + protected static List> reworkListAsContent(List contentList) { - ArrayList> contentReworked =new ArrayList<>(); + List> contentReworked =new ArrayList<>(); for (int i=0; i(Arrays.asList(contentList.get(i)))); @@ -64,7 +65,7 @@ protected static ArrayList> reworkListAsContent(List c /** * @param requestResult */ - public GenericBean(ArrayList> requestResult) { + public GenericBean(List> requestResult) { // refactor de la méthode; faut pas utiliser la commande "remove" sinon on // détruit le requestResult initial this.headers = new ArrayList<>(); @@ -114,12 +115,12 @@ public HashMap mapTypes() { * * @return the HashMap */ - public HashMap> mapContent() { + public Map> mapContent() { if (this.content == null || this.content.isEmpty()) { return new HashMap<>(); } - HashMap> r = new HashMap<>(); + Map> r = new HashMap<>(); // initialisation int jMax = this.content.get(0).size(); @@ -143,8 +144,8 @@ public HashMap> mapContent() { * * @return */ - public HashMap> mapContent(boolean initializeMapWithColumns) { - HashMap> m = this.mapContent(); + public Map> mapContent(boolean initializeMapWithColumns) { + Map> m = this.mapContent(); if (!initializeMapWithColumns) { return m; @@ -194,7 +195,7 @@ public HashMap keyValue() throws ArcException { throw new ArcException(ArcExceptionMessage.GENERIC_BEAN_KEY_VALUE_FAILED); } - for (ArrayList line : this.content) { + for (List line : this.content) { if (r.get(line.get(0)) != null) { throw new ArcException(ArcExceptionMessage.GENERIC_BEAN_DUPLICATE_KEY, line.get(0)); } @@ -214,27 +215,27 @@ public List getColumnValues(String columnName) } - public ArrayList getHeaders() { + public List getHeaders() { return headers; } - public void setHeaders(ArrayList headers) { + public void setHeaders(List headers) { this.headers = headers; } - public ArrayList getTypes() { + public List getTypes() { return types; } - public void setTypes(ArrayList types) { + public void setTypes(List types) { this.types = types; } - public ArrayList> getContent() { + public List> getContent() { return content; } - public void setContent(ArrayList> content) { + public void setContent(List> content) { this.content = content; } diff --git a/arc-utils/src/test/java/fr/insee/arc/utils/format/FormatTest.java b/arc-utils/src/test/java/fr/insee/arc/utils/format/FormatTest.java index 68119567a..87751a0a5 100644 --- a/arc-utils/src/test/java/fr/insee/arc/utils/format/FormatTest.java +++ b/arc-utils/src/test/java/fr/insee/arc/utils/format/FormatTest.java @@ -6,7 +6,6 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import org.junit.Test; @@ -19,19 +18,6 @@ public void testServiceHashFileNameIsUtilityClass() throws NoSuchMethodException PrivateConstructorTest.testConstructorIsPrivate(Format.class); } - @Test - public void patchTest() - { - ArrayList> content=new ArrayList<>(); - content.add(new ArrayList(Arrays.asList("a","b","c"))); - content.add(new ArrayList(Arrays.asList("d","e","f"))); - - List> patchedContent=Format.patch(content); - - // test the content of converted object is the same as the input object - assertEquals(content.toString(), patchedContent.toString()); - - } @Test public void untokenizeTestWithCollection() diff --git a/arc-utils/src/test/java/fr/insee/arc/utils/query/InitializeQueryTest.java b/arc-utils/src/test/java/fr/insee/arc/utils/query/InitializeQueryTest.java index 2a68e4a39..38c2da614 100644 --- a/arc-utils/src/test/java/fr/insee/arc/utils/query/InitializeQueryTest.java +++ b/arc-utils/src/test/java/fr/insee/arc/utils/query/InitializeQueryTest.java @@ -5,8 +5,8 @@ import java.sql.Connection; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.junit.Test; @@ -94,7 +94,7 @@ protected static void testMetadataAndNumberOfRecords(String tableOut, int number { // query the content in tableOut - HashMap> content = new GenericBean( + Map> content = new GenericBean( u.executeRequest(c, new GenericPreparedStatementBuilder("SELECT * FROM "+tableOut))).mapContent(true); // test that there is exactly 2 columns in tableOut @@ -110,7 +110,7 @@ protected static void testMetadataAndNumberOfRecords(String tableOut, int number protected static void testTableExists(String tableOut, int expectedNumber) throws ArcException { - HashMap> content; + Map> content; if (tableOut.contains(".")) { diff --git a/arc-utils/src/test/java/fr/insee/arc/utils/structure/GenericBeanTest.java b/arc-utils/src/test/java/fr/insee/arc/utils/structure/GenericBeanTest.java index 91a3c74d1..671ea8f91 100644 --- a/arc-utils/src/test/java/fr/insee/arc/utils/structure/GenericBeanTest.java +++ b/arc-utils/src/test/java/fr/insee/arc/utils/structure/GenericBeanTest.java @@ -9,6 +9,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.junit.Before; import org.junit.Test; @@ -33,7 +34,7 @@ public void setUp() { @Test public void mapIndexOk() { - genericBean = new GenericBean(headers, types, new ArrayList>()); + genericBean = new GenericBean(headers, types, new ArrayList<>()); HashMap mapIndex = genericBean.mapIndex(); assertEquals(0, mapIndex.get("col1").intValue()); assertEquals(1, mapIndex.get("col2").intValue()); @@ -46,7 +47,7 @@ public void mapTypes() { types.add("text"); types.add("int"); //when - genericBean = new GenericBean(headers, types, new ArrayList>()); + genericBean = new GenericBean(headers, types, new ArrayList<>()); HashMap mapTypes = genericBean.mapTypes(); //then assertEquals("text", mapTypes.get("col1")); @@ -56,7 +57,7 @@ public void mapTypes() { @Test public void mapContentOk() { //with - ArrayList> content = new ArrayList>(); + List> content = new ArrayList<>(); content.add(new ArrayList<>()); content.get(0).add("col1_val1"); content.get(0).add("col2_val1"); @@ -65,7 +66,7 @@ public void mapContentOk() { content.get(1).add("col2_val2"); //when genericBean = new GenericBean(headers, types, content); - HashMap> mapContent = genericBean.mapContent(); + Map> mapContent = genericBean.mapContent(); //then assertEquals("col1_val1", mapContent.get("col1").get(0)); assertEquals("col1_val2", mapContent.get("col1").get(1)); @@ -75,7 +76,7 @@ public void mapContentOk() { @Test public void mapContentEmpty() { - genericBean = new GenericBean(headers, types, new ArrayList>()); + genericBean = new GenericBean(headers, types, new ArrayList<>()); assertTrue(genericBean.mapContent().isEmpty()); assertNull(genericBean.mapContent().get("col")); } @@ -83,7 +84,7 @@ public void mapContentEmpty() { @Test public void empty() { //with - genericBean = new GenericBean(headers, types, new ArrayList>()); + genericBean = new GenericBean(headers, types, new ArrayList<>()); //then assertTrue(genericBean.isEmpty()); } @@ -91,7 +92,7 @@ public void empty() { @Test public void notEmpty() { //with - ArrayList> content = new ArrayList>(); + List> content = new ArrayList<>(); content.add(new ArrayList<>()); content.get(0).add("col1_val1"); content.get(0).add("col2_val1"); @@ -107,7 +108,7 @@ public void reworkListAsContentTest() { List records = new ArrayList(Arrays.asList("1","2","3")); // rework the list as a GenericBean content - ArrayList> content = GenericBean.reworkListAsContent(records); + List> content = GenericBean.reworkListAsContent(records); assertEquals("1", content.get(0).get(0)); assertEquals("2", content.get(1).get(0)); assertEquals("3", content.get(2).get(0)); @@ -121,7 +122,7 @@ public void reworkListAsContentTest() { // a single column GenericBean must be set assertEquals(1, genericBean.mapContent().keySet().size()); - ArrayList gbRecords= genericBean.mapContent().get("id"); + List gbRecords= genericBean.mapContent().get("id"); // we must retrieve exactly the list of records when quering the column name id assertEquals(records.size(), gbRecords.size()); diff --git a/arc-utils/src/test/java/fr/insee/arc/utils/utils/FormatSQLTest.java b/arc-utils/src/test/java/fr/insee/arc/utils/utils/FormatSQLTest.java index 1ad4229dd..ff678a365 100644 --- a/arc-utils/src/test/java/fr/insee/arc/utils/utils/FormatSQLTest.java +++ b/arc-utils/src/test/java/fr/insee/arc/utils/utils/FormatSQLTest.java @@ -1,10 +1,12 @@ package fr.insee.arc.utils.utils; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; +import java.util.Map; import org.junit.Test; @@ -75,7 +77,7 @@ public void changeRole_Test() throws ArcException { // check the current role used GenericPreparedStatementBuilder testQuery = new GenericPreparedStatementBuilder( "SELECT current_user as current_role"); - HashMap> content = new GenericBean(UtilitaireDao.get(0).executeRequest(c, testQuery)).mapContent(true); + Map> content = new GenericBean(UtilitaireDao.get(0).executeRequest(c, testQuery)).mapContent(true); assertEquals(myTestRole, content.get("current_role").get(0)); } @@ -104,7 +106,7 @@ public void hasRecord_TableWithRecords() throws ArcException { // execute the query "hasRecord" GenericPreparedStatementBuilder query = new GenericPreparedStatementBuilder(FormatSQL.hasRecord(tableInTemporary)); - HashMap> content = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(true); + Map> content = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(true); // result must be true ('t' in postgres) assertEquals("t", content.get("has_record").get(0)); @@ -121,7 +123,7 @@ public void hasRecord_TableWithoutRecords() throws ArcException { // execute the query "hasRecord" GenericPreparedStatementBuilder query = new GenericPreparedStatementBuilder(FormatSQL.hasRecord(tableInTemporary)); - HashMap> content = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(true); + Map> content = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(true); // result must be false ('f' in postgres) assertEquals("f", content.get("has_record").get(0)); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/all/dao/ArcWebGenericDao.java b/arc-web/src/main/java/fr/insee/arc/web/gui/all/dao/ArcWebGenericDao.java index 17cff68d3..fbd50f0b8 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/all/dao/ArcWebGenericDao.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/all/dao/ArcWebGenericDao.java @@ -1,8 +1,7 @@ package fr.insee.arc.web.gui.all.dao; -import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import org.apache.logging.log4j.LogManager; @@ -34,7 +33,7 @@ public Map getSandboxList() ArcPreparedStatementBuilder requete= new ArcPreparedStatementBuilder(); requete.append("SELECT replace(id,'.','_') as id, upper(substring(id from '\\.(.*)')) as val FROM arc.ext_etat_jeuderegle where isenv order by nullif(substring(id from '[0123456789]+'),'')::int"); - HashMap> m; + Map> m; try { m = new GenericBean(UtilitaireDao.get(0).executeRequest(null, requete)).mapContent(); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/all/model/Sandbox.java b/arc-web/src/main/java/fr/insee/arc/web/gui/all/model/Sandbox.java new file mode 100644 index 000000000..d51aa72ca --- /dev/null +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/all/model/Sandbox.java @@ -0,0 +1,17 @@ +package fr.insee.arc.web.gui.all.model; + +public enum Sandbox { + ARC_PROD("arc.prod")// + ; + + private String value; + + private Sandbox(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/all/service/ArcWebGenericService.java b/arc-web/src/main/java/fr/insee/arc/web/gui/all/service/ArcWebGenericService.java index 730c045bc..efaec5f91 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/all/service/ArcWebGenericService.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/all/service/ArcWebGenericService.java @@ -325,7 +325,7 @@ protected String addLineVobject(Model model, String successUri, VObject theVObje protected String deleteLineVobject(Model model, String successUri, VObject theVObjectToUpdate) { LoggerHelper.debug(LOGGER, String.join(" ** deleteLineVobject() called by %s **", Thread.currentThread().getStackTrace()[2].getMethodName())); - Map> selection = theVObjectToUpdate.mapContentSelected(); + Map> selection = theVObjectToUpdate.mapContentSelected(); if (!selection.isEmpty()) { vObjectService.delete(theVObjectToUpdate); } else { diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/ConstanteBD.java b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/ConstanteBD.java deleted file mode 100644 index f374b4040..000000000 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/ConstanteBD.java +++ /dev/null @@ -1,24 +0,0 @@ -package fr.insee.arc.web.gui.all.util; - -public enum ConstanteBD { - ARC_PROD("arc.prod")// - , VALIDITE_SUP("validite_sup")// - , VALIDITE_INF("validite_inf")// - , PERIODICITE("periodicite")// - , ID_NORME("id_norme")// - , VERSION("version")// - , ID_FAMILY("id_famille")// - , ID_REGLE("id_regle")// - ; - - private String value; - - private ConstanteBD(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - -} diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/LineObject.java b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/LineObject.java index d945f85a2..a5d26c2bc 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/LineObject.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/LineObject.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Iterator; +import java.util.List; /** Ligne du tableau */ public class LineObject implements Cloneable, Iterable { @@ -11,30 +12,29 @@ public LineObject() { this.d = new ArrayList<>(); } - public static LineObject as(ArrayList someData) { + public static LineObject as(List someData) { return new LineObject(someData); } - private LineObject(ArrayList aData) { + private LineObject(List aData) { super(); this.d = aData; } /** Données de la ligne (par colonnes). */ - public ArrayList d; + public List d; - public ArrayList getD() { + public List getD() { return this.d; } - public void setD(ArrayList aData) { + public void setD(List aData) { this.d = aData; } @Override - @SuppressWarnings("unchecked") public LineObject clone() { - return new LineObject((ArrayList) this.d.clone()); + return new LineObject(new ArrayList<>(this.d)); } @Override diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/TableObject.java b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/TableObject.java index 3b866e2a3..e6133c6af 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/TableObject.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/TableObject.java @@ -2,14 +2,15 @@ import java.util.ArrayList; import java.util.Iterator; +import java.util.List; /** Tableau du contenu de la requete (ligne, colonne) */ public class TableObject implements Cloneable, Iterable { /** Lignes du tableau.*/ - public ArrayList t = new ArrayList<>(); + public List t = new ArrayList<>(); - public static TableObject as(ArrayList> someContent) { + public static TableObject as(List> someContent) { TableObject returned = new TableObject(new ArrayList<>()); for (int i = 0; i < someContent.size(); i++) { returned.add(LineObject.as(someContent.get(i))); @@ -25,15 +26,15 @@ public TableObject() { super(); } - private TableObject(ArrayList someContent) { + private TableObject(List someContent) { this.t = someContent; } - public ArrayList getT() { + public List getT() { return this.t; } - public void setT(ArrayList t) { + public void setT(List t) { this.t = t; } @@ -47,7 +48,7 @@ public LineObject get(int index) { @Override public TableObject clone() { - ArrayList clonedContent = new ArrayList<>(); + List clonedContent = new ArrayList<>(); for (int i = 0; i < this.t.size(); i++) { clonedContent.add(this.t.get(i).clone()); } diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObject.java b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObject.java index cc6102d1f..c5ed4c658 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObject.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObject.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.springframework.web.multipart.MultipartFile; @@ -54,48 +55,48 @@ public class VObject { // nom des colonnes, type en base (D=Database), label dans la vue (V=VUE) , // taille sur la vue /** Noms des colonnes en base. */ - private ArrayList headersDLabel; + private List headersDLabel; /** Types des colonnes en base. */ - private ArrayList headersDType; + private List headersDType; /** Noms des colonnes dans la vue. */ - private ArrayList headersVLabel; + private List headersVLabel; /** Tailles des colonnes dans la vue. */ - private ArrayList headersVSize; + private List headersVSize; /** Types des colonnes dans la vue. */ - private ArrayList headersVType; - private ArrayList> headersVSelect; - private ArrayList headersVisible; - private ArrayList headersUpdatable; - private ArrayList headersRequired; + private List headersVType; + private List> headersVSelect; + private List headersVisible; + private List headersUpdatable; + private List headersRequired; /** Tableau des lignes selectionnées */ - private ArrayList selectedLines; + private List selectedLines; /** Tableau des colonnes selectionnées */ - private ArrayList selectedColumns; + private List selectedColumns; // champs de saisie - private HashMap defaultInputFields; - private ArrayList inputFields; + private Map defaultInputFields; + private List inputFields; // Pagination private Integer nbPages; private String idPage; // Gestion du tri /** Liste des colonnes utilisées pour trier la table */ - private ArrayList headerSortDLabels; + private List headerSortDLabels; /** * Liste des directions de tri (des colonnes nommées dans headerSortDLabels). * true = ascending, false = descending. */ - private ArrayList headerSortDOrders; + private List headerSortDOrders; /** La colonne cliquée par l'utilisateur pour le tri. */ private String headerSortDLabel; - private ArrayList filterFields; + private List filterFields; private String message; private Object[] messageArgs; - private HashMap customValues; + private Map customValues; // pagination and order attribute private boolean noOrder = VObjectService.DEFAULT_NO_ORDER; @@ -106,11 +107,11 @@ public class VObject { private int filterPattern = VObjectService.DEFAULT_FILTER_PATTERN; private String filterFunction = VObjectService.DEFAULT_FILTER_FUNCTION; - public ArrayList> listContent() { + public List> listContent() { if (getSavedContent() == null) { return new ArrayList<>(); } - ArrayList> c = new ArrayList<>(); + List> c = new ArrayList<>(); for (int i = 0; i < getSavedContent().size(); i++) { ArrayList l = new ArrayList<>(); for (int j = 0; j < getSavedContent().get(i).d.size(); j++) { @@ -125,16 +126,16 @@ public ArrayList> listContent() { * Retourne une hash map qui pour chaque entete de colonne (clé), donne la liste * de toutes les valeurs */ - public HashMap> mapContent() { + public Map> mapContent() { return new GenericBean(getHeadersDLabel(), getHeadersDType(), listContent()).mapContent(); } /** Returns the old values for the lines with new content. */ - public ArrayList> listContentBeforeUpdate() { + public List> listContentBeforeUpdate() { if (getSavedContent() == null) { - return new ArrayList>(); + return new ArrayList<>(); } - ArrayList> r = new ArrayList>(); + List> r = new ArrayList<>(); // comparaison des lignes dans la table avant et aprés // toBeUpdated contient l'identifiant des lignes à update for (int i = 0; i < getContent().size(); i++) { @@ -155,22 +156,22 @@ private boolean compareOldAndNew(String newContentValue, String oldContentValue) return newContentValue == null || ManipString.compareStringWithNull(oldContentValue, newContentValue); } - public HashMap> mapContentBeforeUpdate() { + public Map> mapContentBeforeUpdate() { return new GenericBean(getHeadersDLabel(), getHeadersDType(), listContentBeforeUpdate()).mapContent(); } - public HashMap> mapContentBeforeUpdate(int i) { - ArrayList> r = new ArrayList<>(); + public Map> mapContentBeforeUpdate(int i) { + List> r = new ArrayList<>(); r.add(listContentBeforeUpdate().get(i)); return new GenericBean(getHeadersDLabel(), getHeadersDType(), r).mapContent(); } /** Returns the lines with the new content. */ - public ArrayList> listContentAfterUpdate() { + public List> listContentAfterUpdate() { if (getSavedContent() == null) { - return new ArrayList>(); + return new ArrayList<>(); } - ArrayList> r = new ArrayList>(); + List> r = new ArrayList<>(); // comparaison des lignes dans la table avant et aprés // toBeUpdated contient l'identifiant des lignes à update for (int i = 0; i < getContent().size(); i++) { @@ -187,22 +188,22 @@ public ArrayList> listContentAfterUpdate() { return r; } - public HashMap> mapContentAfterUpdate() { + public Map> mapContentAfterUpdate() { return new GenericBean(getHeadersDLabel(), getHeadersDType(), listContentAfterUpdate()).mapContent(); } - public HashMap> mapContentAfterUpdate(int i) { - ArrayList> r = new ArrayList<>(); + public Map> mapContentAfterUpdate(int i) { + List> r = new ArrayList<>(); r.add(listContentAfterUpdate().get(i)); return new GenericBean(getHeadersDLabel(), getHeadersDType(), r).mapContent(); } /** Returns the content as it would be after the update. */ - public ArrayList> listUpdatedContent() { + public List> listUpdatedContent() { if (getSavedContent() == null) { return new ArrayList<>(); } - ArrayList> r = new ArrayList<>(); + List> r = new ArrayList<>(); for (int i = 0; i < getSavedContent().size(); i++) { r.add(new ArrayList<>()); for (int j = 0; j < getSavedContent().get(i).d.size(); j++) { @@ -223,7 +224,7 @@ public ArrayList> listUpdatedContent() { return r; } - public HashMap> mapUpdatedContent() { + public Map> mapUpdatedContent() { return new GenericBean(getHeadersDLabel(), getHeadersDType(), listUpdatedContent()).mapContent(); } @@ -231,11 +232,11 @@ public HashMap> mapUpdatedContent() { * Returns the content as it would be after the update, only on the changed * lines. */ - public ArrayList> listOnlyUpdatedContent() { + public List> listOnlyUpdatedContent() { if (getSavedContent() == null) { return new ArrayList<>(); } - ArrayList> r = new ArrayList<>(); + List> r = new ArrayList<>(); for (int i = 0; i < getContent().size(); i++) { ArrayList line = new ArrayList<>(); boolean changed = false; @@ -257,12 +258,12 @@ public ArrayList> listOnlyUpdatedContent() { return r; } - public HashMap> mapOnlyUpdatedContent() { + public Map> mapOnlyUpdatedContent() { return new GenericBean(getHeadersDLabel(), getHeadersDType(), listOnlyUpdatedContent()).mapContent(); } - public ArrayList> listContentSelected() { - ArrayList> r = new ArrayList<>(); + public List> listContentSelected() { + List> r = new ArrayList<>(); // si rien dans la liste, return null if (getSelectedLines() == null || getSelectedLines().isEmpty()) { return r; @@ -279,18 +280,18 @@ public ArrayList> listContentSelected() { * Retourne une hash map qui pour chaque entete de colonne (clé), donne la liste * de toutes les valeurs selectionnées */ - public HashMap> mapContentSelected() { + public Map> mapContentSelected() { return new GenericBean(getHeadersDLabel(), getHeadersDType(), listContentSelected()).mapContent(); } /** Return the index of headers selected */ - public ArrayList indexHeadersSelected() { + public List indexHeadersSelected() { if (getSavedContent() == null) { return new ArrayList<>(); } - ArrayList listHeadersSelected = listHeadersSelected(); - ArrayList indexHeadersSelected = new ArrayList<>(); + List listHeadersSelected = listHeadersSelected(); + List indexHeadersSelected = new ArrayList<>(); for (Integer i = 0; i < getHeadersDLabel().size(); i++) { if (listHeadersSelected.contains(getHeadersDLabel().get(i))) { indexHeadersSelected.add(i); @@ -303,11 +304,11 @@ public ArrayList indexHeadersSelected() { /** * Retourne la liste des entetes base de donnée selectionnés */ - public ArrayList listHeadersSelected() { + public List listHeadersSelected() { if (getSavedContent() == null) { - return new ArrayList(); + return new ArrayList<>(); } - ArrayList r = new ArrayList(); + ArrayList r = new ArrayList<>(); if (getSelectedColumns() == null || getSelectedColumns().isEmpty()) { return r; } @@ -319,25 +320,25 @@ public ArrayList listHeadersSelected() { return r; } - public HashMap mapHeadersSelected() { - HashMap r = new HashMap<>(); + public Map mapHeadersSelected() { + Map r = new HashMap<>(); for (String s : listHeadersSelected()) { r.put(s, s); } return r; } - public HashMap mapHeadersType() { + public Map mapHeadersType() { return new GenericBean(getHeadersDLabel(), getHeadersDType(), null).mapTypes(); } - public ArrayList> listInputFields() { - ArrayList> r = new ArrayList<>(); + public List> listInputFields() { + List> r = new ArrayList<>(); r.add(getInputFields()); return r; } - public HashMap> mapInputFields() { + public Map> mapInputFields() { return new GenericBean(getHeadersDLabel(), getHeadersDType(), listInputFields()).mapContent(); } @@ -371,27 +372,26 @@ public String getInputFieldFor(String headerDLabel) { return mapInputFields().get(headerDLabel).get(0); } - public ArrayList> listLineContent(int i) { - ArrayList> r = new ArrayList<>(); + public List> listLineContent(int i) { + List> r = new ArrayList<>(); r.add(getContent().get(i).d); return r; } - public HashMap> mapLineContent(int i) { + public Map> mapLineContent(int i) { return new GenericBean(getHeadersDLabel(), getHeadersDType(), listLineContent(i)).mapContent(); } - public HashMap> mapFilterFields() { + public Map> mapFilterFields() { if (getFilterFields() == null) { return new HashMap<>(); } - ArrayList> r = new ArrayList<>(); + List> r = new ArrayList<>(); r.add(getFilterFields()); return new GenericBean(getHeadersDLabel(), getHeadersDType(), r).mapContent(); } - @SuppressWarnings("unchecked") VObject copy() { VObject v0 = new VObject(); v0.setTitle(this.getTitle()); @@ -410,86 +410,86 @@ VObject copy() { v0.setContent(null); } if (this.getHeadersDLabel() != null) { - v0.setHeadersDLabel((ArrayList) this.getHeadersDLabel().clone()); + v0.setHeadersDLabel(new ArrayList<>(this.getHeadersDLabel())); } else { v0.setHeadersDLabel(null); } if (this.getHeadersDType() != null) { - v0.setHeadersDType((ArrayList) this.getHeadersDType().clone()); + v0.setHeadersDType(new ArrayList<>(this.getHeadersDType())); } else { v0.setHeadersDType(null); } if (this.getHeadersVLabel() != null) { - v0.setHeadersVLabel((ArrayList) this.getHeadersVLabel().clone()); + v0.setHeadersVLabel(new ArrayList<>(this.getHeadersVLabel())); } else { v0.setHeadersVLabel(null); } if (this.getHeadersVSize() != null) { - v0.setHeadersVSize((ArrayList) this.getHeadersVSize().clone()); + v0.setHeadersVSize(new ArrayList<>(this.getHeadersVSize())); } else { v0.setHeadersVSize(null); } if (this.getHeadersVType() != null) { - v0.setHeadersVType((ArrayList) this.getHeadersVType().clone()); + v0.setHeadersVType(new ArrayList<>(this.getHeadersVType())); } else { v0.setHeadersVType(null); } if (this.getHeadersVSelect() != null) { - v0.setHeadersVSelect((ArrayList>) this.getHeadersVSelect().clone()); + v0.setHeadersVSelect(new ArrayList<>(this.getHeadersVSelect())); } else { v0.setHeadersVSelect(null); } if (this.getHeadersVisible() != null) { - v0.setHeadersVisible((ArrayList) this.getHeadersVisible().clone()); + v0.setHeadersVisible(new ArrayList<>(this.getHeadersVisible())); } else { v0.setHeadersVisible(null); } if (this.getHeadersUpdatable() != null) { - v0.setHeadersUpdatable((ArrayList) this.getHeadersUpdatable().clone()); + v0.setHeadersUpdatable(new ArrayList<>(this.getHeadersUpdatable())); } else { v0.setHeadersUpdatable(null); } if (this.getHeadersRequired() != null) { - v0.setHeadersRequired((ArrayList) this.getHeadersRequired().clone()); + v0.setHeadersRequired(new ArrayList<>(this.getHeadersRequired())); } else { v0.setHeadersRequired(null); } if (this.getHeaderSortDLabels() != null) { - v0.setHeaderSortDLabels((ArrayList) this.getHeaderSortDLabels().clone()); + v0.setHeaderSortDLabels(new ArrayList<>(this.getHeaderSortDLabels())); } else { v0.setHeaderSortDLabels(null); } if (this.getHeaderSortDOrders() != null) { - v0.setHeaderSortDOrders((ArrayList) this.getHeaderSortDOrders().clone()); + v0.setHeaderSortDOrders( new ArrayList<>(this.getHeaderSortDOrders())); } else { v0.setHeaderSortDOrders(null); } v0.setHeaderSortDLabel(this.getHeaderSortDLabel()); if (this.getSelectedLines() != null) { - v0.setSelectedLines((ArrayList) this.getSelectedLines().clone()); + v0.setSelectedLines(new ArrayList<>(this.getSelectedLines())); } else { v0.setSelectedLines(null); } if (this.getSelectedColumns() != null) { - v0.setSelectedColumns((ArrayList) this.getSelectedColumns().clone()); + v0.setSelectedColumns(new ArrayList<>(this.getSelectedColumns())); } else { v0.setSelectedColumns(null); } v0.setHeaderSortDLabel(this.getHeaderSortDLabel()); if (this.getDefaultInputFields() != null) { - v0.setDefaultInputFields((HashMap) this.getDefaultInputFields().clone()); + v0.setDefaultInputFields(new HashMap<>(this.getDefaultInputFields())); } else { v0.setDefaultInputFields(null); } if (this.getInputFields() != null) { - v0.setInputFields((ArrayList) this.getInputFields().clone()); + v0.setInputFields(new ArrayList<>(this.getInputFields())); } else { v0.setInputFields(null); } v0.setNbPages(this.getNbPages()); v0.setIdPage(this.getIdPage()); if (this.getFilterFields() != null) { - v0.setFilterFields((ArrayList) this.getFilterFields().clone()); + v0.setFilterFields(new ArrayList<>(this.getFilterFields())); } else { v0.setFilterFields(null); } @@ -497,7 +497,7 @@ VObject copy() { v0.setConstantVObject(this.getConstantVObject()); } if (this.getCustomValues() != null) { - v0.setCustomValues((HashMap) this.getCustomValues().clone()); + v0.setCustomValues(new HashMap<>(this.getCustomValues())); } return v0; } @@ -667,107 +667,107 @@ public void setIsActive(boolean isActive) { this.isActive = isActive; } - public ArrayList getHeadersDLabel() { + public List getHeadersDLabel() { return headersDLabel; } - public void setHeadersDLabel(ArrayList headersDLabel) { + public void setHeadersDLabel(List headersDLabel) { this.headersDLabel = headersDLabel; } - public ArrayList getHeadersDType() { + public List getHeadersDType() { return headersDType; } - public void setHeadersDType(ArrayList headersDType) { + public void setHeadersDType(List headersDType) { this.headersDType = headersDType; } - public ArrayList getHeadersVLabel() { + public List getHeadersVLabel() { return headersVLabel; } - public void setHeadersVLabel(ArrayList headersVLabel) { + public void setHeadersVLabel(List headersVLabel) { this.headersVLabel = headersVLabel; } - public ArrayList getHeadersVSize() { + public List getHeadersVSize() { return headersVSize; } - public void setHeadersVSize(ArrayList headersVSize) { + public void setHeadersVSize(List headersVSize) { this.headersVSize = headersVSize; } - public ArrayList getHeadersVType() { + public List getHeadersVType() { return headersVType; } - public void setHeadersVType(ArrayList headersVType) { + public void setHeadersVType(List headersVType) { this.headersVType = headersVType; } - public ArrayList> getHeadersVSelect() { + public List> getHeadersVSelect() { return headersVSelect; } - public void setHeadersVSelect(ArrayList> headersVSelect) { + public void setHeadersVSelect(List> headersVSelect) { this.headersVSelect = headersVSelect; } - public ArrayList getHeadersVisible() { + public List getHeadersVisible() { return headersVisible; } - public void setHeadersVisible(ArrayList headersVisible) { + public void setHeadersVisible(List headersVisible) { this.headersVisible = headersVisible; } - public ArrayList getHeadersUpdatable() { + public List getHeadersUpdatable() { return headersUpdatable; } - public void setHeadersUpdatable(ArrayList headersUpdatable) { + public void setHeadersUpdatable(List headersUpdatable) { this.headersUpdatable = headersUpdatable; } - public ArrayList getHeadersRequired() { + public List getHeadersRequired() { return headersRequired; } - public void setHeadersRequired(ArrayList headersRequired) { + public void setHeadersRequired(List headersRequired) { this.headersRequired = headersRequired; } - public ArrayList getSelectedLines() { + public List getSelectedLines() { return selectedLines; } - public void setSelectedLines(ArrayList selectedLines) { + public void setSelectedLines(List selectedLines) { this.selectedLines = selectedLines; } - public ArrayList getSelectedColumns() { + public List getSelectedColumns() { return selectedColumns; } - public void setSelectedColumns(ArrayList selectedColumns) { + public void setSelectedColumns(List selectedColumns) { this.selectedColumns = selectedColumns; } - public HashMap getDefaultInputFields() { + public Map getDefaultInputFields() { return defaultInputFields; } - public void setDefaultInputFields(HashMap defaultInputFields) { + public void setDefaultInputFields(Map defaultInputFields) { this.defaultInputFields = defaultInputFields; } - public ArrayList getInputFields() { + public List getInputFields() { return inputFields; } - public void setInputFields(ArrayList inputFields) { + public void setInputFields(List inputFields) { this.inputFields = inputFields; } @@ -787,19 +787,19 @@ public void setIdPage(String idPage) { this.idPage = idPage; } - public ArrayList getHeaderSortDLabels() { + public List getHeaderSortDLabels() { return headerSortDLabels; } - public void setHeaderSortDLabels(ArrayList headerSortDLabels) { + public void setHeaderSortDLabels(List headerSortDLabels) { this.headerSortDLabels = headerSortDLabels; } - public ArrayList getHeaderSortDOrders() { + public List getHeaderSortDOrders() { return headerSortDOrders; } - public void setHeaderSortDOrders(ArrayList headerSortDOrders) { + public void setHeaderSortDOrders(List headerSortDOrders) { this.headerSortDOrders = headerSortDOrders; } @@ -811,11 +811,11 @@ public void setHeaderSortDLabel(String headerSortDLabel) { this.headerSortDLabel = headerSortDLabel; } - public ArrayList getFilterFields() { + public List getFilterFields() { return filterFields; } - public void setFilterFields(ArrayList filterFields) { + public void setFilterFields(List filterFields) { this.filterFields = filterFields; } @@ -835,11 +835,11 @@ public void setMessageArgs(Object... messageArgs) { this.messageArgs = messageArgs; } - public HashMap getCustomValues() { + public Map getCustomValues() { return customValues; } - public void setCustomValues(HashMap customValues) { + public void setCustomValues(Map customValues) { this.customValues = customValues; } diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObjectHelperDao.java b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObjectHelperDao.java index a99331b70..c65cfd175 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObjectHelperDao.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObjectHelperDao.java @@ -1,7 +1,7 @@ package fr.insee.arc.web.gui.all.util; -import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.springframework.stereotype.Component; @@ -24,7 +24,7 @@ public void initialize(VObjectService vObjectService, DataObjectService dataObje } - protected Map> selectedRecords; + protected Map> selectedRecords; /** * build the default value taken from selection when adding a record according to what the user clicked on parent view @@ -57,11 +57,11 @@ public ArcPreparedStatementBuilder sqlEqualWithFirstSelectedRecord(ColumnEnum co return query; } - public Map> getSelectedRecords() { + public Map> getSelectedRecords() { return selectedRecords; } - public void setSelectedRecords(Map> selectedRecords) { + public void setSelectedRecords(Map> selectedRecords) { this.selectedRecords = selectedRecords; } diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObjectService.java b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObjectService.java index c71c146af..b869acad7 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObjectService.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/all/util/VObjectService.java @@ -175,7 +175,7 @@ public VObject preInitialize(VObject currentData) { * @param defaultInputFields */ public void initialize(VObject data, ArcPreparedStatementBuilder mainQuery, String table, - HashMap defaultInputFields) { + Map defaultInputFields) { initialize(data, mainQuery, table, defaultInputFields, ((content) -> content)); } @@ -188,8 +188,8 @@ public void initialize(VObject data, ArcPreparedStatementBuilder mainQuery, Stri * @param reworkContent function to rewrite the fetched content */ private void initialize(VObject data, ArcPreparedStatementBuilder mainQuery, String table, - HashMap defaultInputFields, - Function>, ArrayList>> reworkContent) { + Map defaultInputFields, + Function>, List>> reworkContent) { try { LoggerHelper.debugAsComment(LOGGER, "initialize", data.getSessionName()); @@ -199,12 +199,12 @@ private void initialize(VObject data, ArcPreparedStatementBuilder mainQuery, Str // on sauvegarde le contenu des lignes selectionnées avant la nouvelle // execution de la requete - HashMap> selectedContent = data.mapContentSelected(); - ArrayList headersDLabel = new ArrayList<>(); - ArrayList headersDType = new ArrayList<>(); + Map> selectedContent = data.mapContentSelected(); + List headersDLabel = new ArrayList<>(); + List headersDType = new ArrayList<>(); // on sauvegarde les headers des colonnes selectionnées avant la // nouvelle execution de la requete - ArrayList selectedHeaders = data.listHeadersSelected(); + List selectedHeaders = data.listHeadersSelected(); // gestion du nombre de pages Integer indexPage = pageManagement(mainQuery, data); @@ -227,7 +227,7 @@ private void initialize(VObject data, ArcPreparedStatementBuilder mainQuery, Str requete.append(buildLimit(data, indexPage)); } - ArrayList> aContent = new ArrayList<>(); + List> aContent = new ArrayList<>(); try { aContent = reworkContent.apply(UtilitaireDao.get(this.connectionIndex).executeRequest(this.connection, requete, ModeRequeteImpl.arcModeRequeteIHM())); @@ -260,7 +260,7 @@ private void initialize(VObject data, ArcPreparedStatementBuilder mainQuery, Str data.setDefaultInputFields(defaultInputFields); data.setInputFields(eraseInputFields(headersDLabel, defaultInputFields)); // (Re-)determine selectedLines based on content - ArrayList selectedLines = new ArrayList<>(); + List selectedLines = new ArrayList<>(); if (!selectedContent.isEmpty()) { for (int i = 0; i < data.getContent().size(); i++) { int k = 0; @@ -284,7 +284,7 @@ private void initialize(VObject data, ArcPreparedStatementBuilder mainQuery, Str } data.setSelectedLines(selectedLines); // (Re-)determine selectedColums from selectedHeaders - ArrayList selectedColumns = new ArrayList<>(); + List selectedColumns = new ArrayList<>(); for (int i = 0; i < data.getHeadersDLabel().size(); i++) { if (selectedHeaders.contains(data.getHeadersDLabel().get(i))) { selectedColumns.add(true); @@ -323,7 +323,7 @@ public void setPaginationSizeIfNull(VObject currentData) { */ public Integer pageManagement(ArcPreparedStatementBuilder mainQuery, VObject currentData) { - ArrayList> aContent = new ArrayList<>(); + List> aContent = new ArrayList<>(); if (currentData.getIdPage() == null) { currentData.setIdPage("1"); } @@ -384,7 +384,7 @@ public Integer pageManagement(ArcPreparedStatementBuilder mainQuery, VObject cur * @param data * @param headersDLabel */ - public void applyColumnRendering(VObject data, ArrayList headersDLabel) { + public void applyColumnRendering(VObject data, List headersDLabel) { data.setHeadersVLabel(buildHeadersVLabel(data, headersDLabel)); data.setHeadersVSize(buildHeadersVSize(data, headersDLabel)); data.setHeadersVType(buildHeadersVType(data, headersDLabel)); @@ -399,8 +399,8 @@ public void applyColumnRendering(VObject data, ArrayList headersDLabel) * ConstantVObject, on met le label déclaré. Sinon on garde le nom de colonne de * la base de données */ - private ArrayList buildHeadersVLabel(VObject data, ArrayList headers) { - ArrayList headersVLabel = new ArrayList<>(); + private List buildHeadersVLabel(VObject data, List headers) { + List headersVLabel = new ArrayList<>(); for (int i = 0; i < headers.size(); i++) { if (data.getConstantVObject()// .getColumnRender()// @@ -417,8 +417,8 @@ private ArrayList buildHeadersVLabel(VObject data, ArrayList hea * Génére la taille de colonnes. Si une déclaration est faite dans * ConstantVObject, on met la taille déclaré. Sinon on ne met rien. */ - private ArrayList buildHeadersVSize(VObject data, ArrayList headers) { - ArrayList headersVSize = new ArrayList<>(); + private List buildHeadersVSize(VObject data, List headers) { + List headersVSize = new ArrayList<>(); for (int i = 0; i < headers.size(); i++) { if (data.getConstantVObject().getColumnRender().get(headers.get(i)) != null) { headersVSize.add(data.getConstantVObject().getColumnRender().get(headers.get(i)).size); @@ -433,8 +433,8 @@ private ArrayList buildHeadersVSize(VObject data, ArrayList head * Génére le type de colonnes. Si une déclaration est faite dans * ConstantVObject, on met le type déclaré. Sinon on met text. */ - private ArrayList buildHeadersVType(VObject data, ArrayList headers) { - ArrayList headersVType = new ArrayList<>(); + private List buildHeadersVType(VObject data, List headers) { + List headersVType = new ArrayList<>(); for (int i = 0; i < headers.size(); i++) { if (data.getConstantVObject().getColumnRender().get(headers.get(i)) != null) { headersVType.add(data.getConstantVObject().getColumnRender().get(headers.get(i)).type); @@ -450,8 +450,8 @@ private ArrayList buildHeadersVType(VObject data, ArrayList head * ConstantVObject, on met la visibilité déclarée. Sinon on met visible par * défaut. */ - private ArrayList buildHeadersVisible(VObject data, ArrayList headers) { - ArrayList headersVisible = new ArrayList<>(); + private List buildHeadersVisible(VObject data, List headers) { + List headersVisible = new ArrayList<>(); for (int i = 0; i < headers.size(); i++) { if (data.getConstantVObject().getColumnRender().get(headers.get(i)) != null) { headersVisible.add(data.getConstantVObject().getColumnRender().get(headers.get(i)).visible); @@ -467,8 +467,8 @@ private ArrayList buildHeadersVisible(VObject data, ArrayList h * dans ConstantVObject, on met la valeur déclarée. Sinon on met modifiable par * défaut. */ - private ArrayList buildHeadersUpdatable(VObject data, ArrayList headers) { - ArrayList headersUpdatable = new ArrayList<>(); + private List buildHeadersUpdatable(VObject data, List headers) { + List headersUpdatable = new ArrayList<>(); for (int i = 0; i < headers.size(); i++) { if (data.getConstantVObject().getColumnRender().get(headers.get(i)) != null) { headersUpdatable.add(data.getConstantVObject().getColumnRender().get(headers.get(i)).isUpdatable); @@ -484,8 +484,8 @@ private ArrayList buildHeadersUpdatable(VObject data, ArrayList * dans ConstantVObject, on met la valeur déclarée. Sinon on met obligatoire par * défaut. */ - private ArrayList buildHeadersRequired(VObject data, ArrayList headers) { - ArrayList headersRequired = new ArrayList<>(); + private List buildHeadersRequired(VObject data, List headers) { + List headersRequired = new ArrayList<>(); for (int i = 0; i < headers.size(); i++) { if (data.getConstantVObject().getColumnRender().get(headers.get(i)) != null) { headersRequired.add(data.getConstantVObject().getColumnRender().get(headers.get(i)).isRequired); @@ -496,9 +496,10 @@ private ArrayList buildHeadersRequired(VObject data, ArrayList return headersRequired; } - private ArrayList> buildHeadersVSelect(VObject data, ArrayList headers) { - ArrayList> arrayVSelect = new ArrayList<>(); - ArrayList> headerVSelect = new ArrayList<>(); + private List> buildHeadersVSelect(VObject data, List headers) { + List> arrayVSelect = new ArrayList<>(); + List> headerVSelect = new ArrayList<>(); + for (int i = 0; i < headers.size(); i++) { if (data.getConstantVObject().getColumnRender().get(headers.get(i)) != null && data.getConstantVObject().getColumnRender().get(headers.get(i)).query != null) { @@ -537,9 +538,9 @@ public void initialiserColumnRendering(VObject data, Map eraseInputFields(ArrayList headersDLabel, - HashMap defaultInputFields) { - ArrayList inputFields = new ArrayList<>(); + private List eraseInputFields(List headersDLabel, + Map defaultInputFields) { + List inputFields = new ArrayList<>(); for (int i = 0; i < headersDLabel.size(); i++) { if (defaultInputFields.get(headersDLabel.get(i)) != null) { inputFields.add(defaultInputFields.get(headersDLabel.get(i))); @@ -650,7 +651,7 @@ public ArcPreparedStatementBuilder deleteQuery(VObject currentData, String... ta VObject v0 = fetchVObjectData(currentData.getSessionName()); - ArrayList listeColonneNative = (ArrayList) UtilitaireDao.get(this.connectionIndex).getColumns(this.connection, + List listeColonneNative = (ArrayList) UtilitaireDao.get(this.connectionIndex).getColumns(this.connection, new ArrayList<>(), currentData.getTable()); ArcPreparedStatementBuilder reqDelete = new ArcPreparedStatementBuilder(); for (int i = 0; i < currentData.getSelectedLines().size(); i++) { @@ -705,7 +706,7 @@ public void update(VObject currentData) { } try { - ArrayList nativeFieldsList = (ArrayList) UtilitaireDao.get(this.connectionIndex).getColumns(this.connection, + List nativeFieldsList = (ArrayList) UtilitaireDao.get(this.connectionIndex).getColumns(this.connection, new ArrayList<>(), currentData.getTable()); // SQL update query @@ -801,7 +802,7 @@ public void destroy(VObject data) { session.remove(data.getSessionName()); } - public ArcPreparedStatementBuilder buildFilter(ArrayList filterFields, ArrayList headersDLabel) { + public ArcPreparedStatementBuilder buildFilter(List filterFields, List headersDLabel) { return buildFilter(filterFields, headersDLabel, DEFAULT_FILTER_PATTERN, DEFAULT_FILTER_FUNCTION); } @@ -813,7 +814,7 @@ public ArcPreparedStatementBuilder buildFilter(ArrayList filterFields, A * @return */ - private ArcPreparedStatementBuilder buildFilter(ArrayList filterFields, ArrayList headersDLabel, + private ArcPreparedStatementBuilder buildFilter(List filterFields, List headersDLabel, Integer filterPattern, String filterFunction) { Pattern patternMath = Pattern.compile("[<>=]"); @@ -960,8 +961,8 @@ private String patternMather(String aChercher) { * @param headerSortDOrders ordres du tri des colonnes * @return */ - public ArcPreparedStatementBuilder buildOrderBy(ArrayList headerSortLabels, - ArrayList headerSortDOrders) { + public ArcPreparedStatementBuilder buildOrderBy(List headerSortLabels, + List headerSortDOrders) { if (headerSortLabels == null) { return new ArcPreparedStatementBuilder("order by alias_de_table "); } @@ -1140,9 +1141,9 @@ public void zipOutStreamRequeteSelect(Connection connexion, ArcPreparedStatement int k = 0; int fetchSize = 5000; GenericBean g; - ArrayList listIdSource; - ArrayList listIdSourceEtat; - ArrayList listContainer; + List listIdSource; + List listIdSourceEtat; + List listContainer; String repertoire = repertoireIn + anEnvExcecution.toUpperCase().replace(".", "_") + File.separator; String currentContainer; @@ -1154,7 +1155,7 @@ public void zipOutStreamRequeteSelect(Connection connexion, ArcPreparedStatement // Récupération de la liste d'id_source par paquet de fetchSize try { g = new GenericBean(UtilitaireDao.get(this.connectionIndex).executeRequest(this.connection, requeteLimit)); - HashMap> m = g.mapContent(); + Map> m = g.mapContent(); listIdSource = m.get(ColumnEnum.ID_SOURCE.getColumnName()); listContainer = m.get("container"); listIdSourceEtat = m.get("etat_traitement"); @@ -1169,8 +1170,8 @@ public void zipOutStreamRequeteSelect(Connection connexion, ArcPreparedStatement LoggerHelper.traceAsComment(LOGGER, " listIdSource.size() =", listIdSource.size()); - ArrayList listIdSourceContainer = new ArrayList<>(); - ArrayList listIdSourceEtatContainer = new ArrayList<>(); + List listIdSourceContainer = new ArrayList<>(); + List listIdSourceEtatContainer = new ArrayList<>(); // Ajout des fichiers à l'archive int i = 0; @@ -1229,7 +1230,7 @@ else if (listContainer.get(i).endsWith(CompressionExtension.GZ.getFileExtension( * dans l'un de la liste) */ public void downloadEnveloppe(VObject currentData, HttpServletResponse response, - ArcPreparedStatementBuilder requete, String repertoire, ArrayList listRepertoire) { + ArcPreparedStatementBuilder requete, String repertoire, List listRepertoire) { VObject v0 = fetchVObjectData(currentData.getSessionName()); if (currentData.getFilterFields() == null) { @@ -1266,7 +1267,6 @@ public void downloadEnveloppe(VObject currentData, HttpServletResponse response, * @throws ArcException */ public void upload(VObject data, String repertoireCible) throws ArcException { - int nbUploaded = 0; if (data.getFileUpload() != null) { for (MultipartFile uploadedFile : data.getFileUpload()) { String fileName = uploadedFile.getOriginalFilename(); @@ -1298,16 +1298,15 @@ public void upload(VObject data, String repertoireCible) throws ArcException { } } } - nbUploaded++; } } } - public ArrayList getHeaderSortDLabels(VObject currentData) { + public List getHeaderSortDLabels(VObject currentData) { return currentData.getHeaderSortDLabels(); } - public void setHeaderSortDLabels(VObject currentData, ArrayList headerSortLabels) { + public void setHeaderSortDLabels(VObject currentData, List headerSortLabels) { currentData.setHeaderSortDLabels(headerSortLabels); } @@ -1346,16 +1345,16 @@ private VObject fetchVObjectData(String sessionName) { return (VObject) session.get(sessionName); } - public final void setColumnRendering(VObject data, HashMap columnRender) { + public final void setColumnRendering(VObject data, Map columnRender) { data.setConstantVObject(new ConstantVObject(columnRender)); } - public void initializeByList(VObject data, ArrayList> liste, - HashMap defaultInputFields) { + public void initializeByList(VObject data, List> liste, + Map defaultInputFields) { ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); - ArrayList header = liste.get(0); - ArrayList type = liste.get(1); + List header = liste.get(0); + List type = liste.get(1); // cas classique avec des données for (int i = 2; i < liste.size(); i++) { @@ -1391,7 +1390,7 @@ public void initializeByList(VObject data, ArrayList> liste, } // give values to be added to a result row - public static void addRowToVObjectList(ArrayList> result, String... elements) { + public static void addRowToVObjectList(List> result, String... elements) { result.add(new ArrayList<>(Arrays.asList(Arrays.copyOf(elements, elements.length)))); } diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/export/dao/ExportDao.java b/arc-web/src/main/java/fr/insee/arc/web/gui/export/dao/ExportDao.java index cebaf5463..cc550b621 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/export/dao/ExportDao.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/export/dao/ExportDao.java @@ -60,7 +60,7 @@ public void initializeViewExport(VObject viewExport) { * @return A map of all exports to make with their associated rules * @throws ArcException */ - public Map> startExportRetrieve() throws ArcException { + public Map> startExportRetrieve() throws ArcException { ViewEnum dataModelExport = ViewEnum.EXPORT; String nameOfViewExport = dataObjectService.getView(dataModelExport); @@ -102,7 +102,7 @@ public void startExportUpdateState(List fileName, int fileIndex, boolean * @return * @throws ArcException */ - protected HashMap> exportFileRetrieveRules(int n, List howToExport, + protected Map> exportFileRetrieveRules(int n, List howToExport, List tablesToExport, String bacASable) throws ArcException { // if columns,orders table is specified, get the information from database metadata String howToExportReworked; @@ -143,19 +143,19 @@ public ResultSet exportFileFilteredOrdered(Statement stmt, int n, List t * @throws IOException * @throws SQLException */ - public void exportFile(Map> h, int n, BufferedWriter bw, FileOutputStream fw) + public void exportFile(Map> h, int n, BufferedWriter bw, FileOutputStream fw) throws ArcException, IOException, SQLException { - ArrayList tablesToExport = h.get("table_to_export"); - ArrayList headers = h.get("headers"); - ArrayList nulls = h.get("nulls"); - ArrayList filterTable = h.get("filter_table"); - ArrayList orderTable = h.get("order_table"); - ArrayList howToExport = h.get("nomenclature_export"); - ArrayList headersToScan = h.get("columns_array_header"); - ArrayList valuesToScan = h.get("columns_array_value"); + List tablesToExport = h.get("table_to_export"); + List headers = h.get("headers"); + List nulls = h.get("nulls"); + List filterTable = h.get("filter_table"); + List orderTable = h.get("order_table"); + List howToExport = h.get("nomenclature_export"); + List headersToScan = h.get("columns_array_header"); + List valuesToScan = h.get("columns_array_value"); - HashMap pos = new HashMap<>(); - ArrayList headerLine = new ArrayList<>(); + Map pos = new HashMap<>(); + List headerLine = new ArrayList<>(); h = exportFileRetrieveRules(n, howToExport, tablesToExport, this.dataObjectService.getSandboxSchema()); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/InteractorExport.java b/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/InteractorExport.java index 35f70e218..b117242e1 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/InteractorExport.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/InteractorExport.java @@ -5,6 +5,8 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -65,21 +67,21 @@ public String initExportDir() // visual des Files public void initializeFileExport() { - HashMap defaultInputFields = new HashMap(); + Map defaultInputFields = new HashMap<>(); String dirOut = initExportDir(); - ArrayList> listeFichier = getFilesFromDirectory(dirOut, this.views.getViewFileExport().mapFilterFields()); + List> listeFichier = getFilesFromDirectory(dirOut, this.views.getViewFileExport().mapFilterFields()); this.vObjectService.initializeByList(views.getViewFileExport(), listeFichier, defaultInputFields); } - private ArrayList> getFilesFromDirectory(String dir, HashMap> filter2) + private List> getFilesFromDirectory(String dir, Map> filter2) { - HashMap> filter=filter2; - ArrayList> result=new ArrayList<>(); + Map> filter=filter2; + List> result=new ArrayList<>(); ArrayList entete = new ArrayList<>(); entete.add("filename"); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/ServiceViewExport.java b/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/ServiceViewExport.java index 6e4cedce1..82630974a 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/ServiceViewExport.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/ServiceViewExport.java @@ -7,7 +7,7 @@ import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.sql.SQLException; -import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.zip.GZIPOutputStream; import java.util.zip.ZipEntry; @@ -60,11 +60,11 @@ public String startExport(Model model) { return generateDisplay(model, RESULT_SUCCESS); } - Map> rules = dao.startExportRetrieve(); + Map> rules = dao.startExportRetrieve(); - ArrayList fileName = rules.get(ColumnEnum.FILE_NAME.getColumnName()); - ArrayList zip = rules.get(ColumnEnum.ZIP.getColumnName()); + List fileName = rules.get(ColumnEnum.FILE_NAME.getColumnName()); + List zip = rules.get(ColumnEnum.ZIP.getColumnName()); // Initialiser le répertoire de sortie String dirOut = initExportDir(); @@ -97,9 +97,9 @@ public String startExport(Model model) { return generateDisplay(model, RESULT_SUCCESS); } - private void exportPlainText(String dirOut, Map> h, int n) + private void exportPlainText(String dirOut, Map> h, int n) throws IOException, ArcException, SQLException { - ArrayList fileName = h.get("file_name"); + List fileName = h.get("file_name"); File fOut = new File(dirOut + File.separator + fileName.get(n)); @@ -110,9 +110,9 @@ private void exportPlainText(String dirOut, Map> h, in } } - private void exportZip(String dirOut, Map> h, int n) + private void exportZip(String dirOut, Map> h, int n) throws IOException, ArcException, SQLException { - ArrayList fileName = h.get("file_name"); + List fileName = h.get("file_name"); File fOut = new File(dirOut + File.separator + fileName.get(n) + ".zip"); @@ -130,9 +130,9 @@ private void exportZip(String dirOut, Map> h, int n) } } - private void exportGz(String dirOut, Map> h, int n) + private void exportGz(String dirOut, Map> h, int n) throws IOException, ArcException, SQLException { - ArrayList fileName = h.get("file_name"); + List fileName = h.get("file_name"); File fOut = new File(dirOut + File.separator + fileName.get(n) + ".gz"); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/ServiceViewFileExport.java b/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/ServiceViewFileExport.java index e2a784cfe..83570e13a 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/ServiceViewFileExport.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/export/service/ServiceViewFileExport.java @@ -3,7 +3,8 @@ import java.io.File; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import javax.servlet.http.HttpServletResponse; @@ -28,7 +29,7 @@ public String sortFileExport(Model model) { public String deleteFileExport(Model model) { String dirOut = initExportDir(); - HashMap> selection = this.views.getViewFileExport().mapContentSelected(); + Map> selection = this.views.getViewFileExport().mapContentSelected(); if (!selection.isEmpty()) { for (String s : selection.get("filename")) { try { @@ -45,8 +46,8 @@ public String deleteFileExport(Model model) { public String updateFileExport(Model model) { String dirOut = initExportDir(); - HashMap> m = this.views.getViewFileExport().mapContentBeforeUpdate(); - HashMap> n = this.views.getViewFileExport().mapContentAfterUpdate(); + Map> m = this.views.getViewFileExport().mapContentBeforeUpdate(); + Map> n = this.views.getViewFileExport().mapContentAfterUpdate(); if (!m.isEmpty()) { for (int i = 0; i < m.get("filename").size(); i++) { @@ -65,7 +66,7 @@ public String updateFileExport(Model model) { } public String downloadFileExport(Model model, HttpServletResponse response) { - HashMap> selection = this.views.getViewFileExport().mapContentSelected(); + Map> selection = this.views.getViewFileExport().mapContentSelected(); if (!selection.isEmpty()) { ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); boolean first = true; diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/dao/GererFamilleNormeDao.java b/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/dao/GererFamilleNormeDao.java index 881cc3461..a713cb1c1 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/dao/GererFamilleNormeDao.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/dao/GererFamilleNormeDao.java @@ -361,12 +361,12 @@ private static StringBuilder requeteListeAddRegleMapping(String idFamille) { private String queryUpdateRulesAndModelTablesOnVariableNameUpdate(VObject viewVariableMetier, String idFamilleSelected) throws ArcException { StringBuilder requete = new StringBuilder(); - List> lBefore = viewVariableMetier.listContentBeforeUpdate(); + List> lBefore = viewVariableMetier.listContentBeforeUpdate(); - List> lAfter = viewVariableMetier.listContentAfterUpdate(); + List> lAfter = viewVariableMetier.listContentAfterUpdate(); int nameIndex = viewVariableMetier.getHeadersDLabel().indexOf(ColumnEnum.NOM_VARIABLE_METIER.getColumnName()); - for (ArrayList modifiedLine : lAfter) { + for (List modifiedLine : lAfter) { int indexOfVar = nameIndex; modifiedLine.set(indexOfVar, ArcStringUtils.cleanUpVariable(modifiedLine.get(indexOfVar))); } @@ -444,8 +444,8 @@ private String queryAlterColumnNameInModelTables(VObject viewVariableMetier, int new StringBuilder("SELECT distinct replace(id,'.','_') FROM arc.ext_etat_jeuderegle where isenv"), new ArrayList<>()); - HashMap> mBefore = viewVariableMetier.mapContentBeforeUpdate(); - List> lBefore = viewVariableMetier.listContentBeforeUpdate(); + Map> mBefore = viewVariableMetier.mapContentBeforeUpdate(); + List> lBefore = viewVariableMetier.listContentBeforeUpdate(); StringBuilder requete = new StringBuilder(); for (String envName : listeEnvironnement) { @@ -469,7 +469,7 @@ private String queryAlterColumnNameInModelTables(VObject viewVariableMetier, int return requete.toString(); } - private void isAnyNullVariablesDeclared(HashMap> mapContentAfterUpdate) + private void isAnyNullVariablesDeclared(Map> mapContentAfterUpdate) throws ArcException { for (int i = 0; i < mapContentAfterUpdate.get(ColumnEnum.NOM_VARIABLE_METIER.getColumnName()).size(); i++) { String nomVariable = mapContentAfterUpdate.get(ColumnEnum.NOM_VARIABLE_METIER.getColumnName()).get(i); @@ -485,7 +485,7 @@ private void isAnyNullVariablesDeclared(HashMap> mapCo * @param message */ private String addExistingVariableMetierWithoutSync(VObject viewVariableMetier, - List> listContent) { + List> listContent) { StringBuilder requete = new StringBuilder(); /** * Pour chaque ligne à UPDATE @@ -601,7 +601,7 @@ private String mettreAJourInformationsVariables(VObject someViewVariableMetier) requete.append("\n"); } - HashMap> content = someViewVariableMetier.mapOnlyUpdatedContent(); + Map> content = someViewVariableMetier.mapOnlyUpdatedContent(); StringBuilder requeteLocale = new StringBuilder( "UPDATE " + ViewEnum.IHM_MOD_VARIABLE_METIER.getFullName() + " a "); requeteLocale.append("\n SET type_consolidation = "); @@ -618,7 +618,7 @@ private String mettreAJourInformationsVariables(VObject someViewVariableMetier) return requete.toString(); } - private String computeMapcontent(HashMap> content, String columnName, int index) { + private String computeMapcontent(Map> content, String columnName, int index) { if (content.get(columnName) == null || content.get(columnName).get(index) == null) { return columnName; } else { @@ -636,7 +636,7 @@ private String computeMapcontent(HashMap> content, Str */ private String deleteVariableMetierWithoutSync(VObject viewVariableMetier) { - Map> map = viewVariableMetier.mapContentSelected(); + Map> map = viewVariableMetier.mapContentSelected(); StringBuilder delete = new StringBuilder(); /** diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/service/InteractorFamilleNorme.java b/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/service/InteractorFamilleNorme.java index 3f1c4671d..d98a4dbc0 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/service/InteractorFamilleNorme.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/service/InteractorFamilleNorme.java @@ -78,7 +78,7 @@ private void initializeClient(VObject viewClient, VObject viewFamilleNorme) { LoggerHelper.debug(LOGGER, "/* initializeClient */"); try { // get the norm family selected records - Map> selectionFamilleNorme = viewFamilleNorme.mapContentSelected(); + Map> selectionFamilleNorme = viewFamilleNorme.mapContentSelected(); // if norm family selected, trigger call to dao to construct client view if (!selectionFamilleNorme.isEmpty()) { dao.setSelectedRecords(selectionFamilleNorme); @@ -102,7 +102,7 @@ private void initializeHostAllowed(VObject viewHostAllowed, VObject viewClient) LoggerHelper.debug(LOGGER, "/* initializeHostAllowed */"); try { // get the client selected records - Map> selectionClient = viewClient.mapContentSelected(); + Map> selectionClient = viewClient.mapContentSelected(); // if client selected, trigger call to dao to construct host allowed view if (!selectionClient.isEmpty()) { dao.setSelectedRecords(selectionClient); @@ -126,7 +126,7 @@ private void initializeTableMetier(VObject viewTableMetier, VObject viewFamilleN LoggerHelper.debug(LOGGER, "/* initializeTableMetier */"); try { // get the norm family selected records - Map> selectionFamilleNorme = viewFamilleNorme.mapContentSelected(); + Map> selectionFamilleNorme = viewFamilleNorme.mapContentSelected(); // if norm family selected, trigger call to dao to construct business table view if (!selectionFamilleNorme.isEmpty()) { dao.setSelectedRecords(selectionFamilleNorme); @@ -148,7 +148,7 @@ private void initializeTableMetier(VObject viewTableMetier, VObject viewFamilleN */ private void initializeVariableMetier(VObject viewVariableMetier, VObject viewFamilleNorme) { // get the norm family selected records - Map> selectionFamilleNorme = viewFamilleNorme.mapContentSelected(); + Map> selectionFamilleNorme = viewFamilleNorme.mapContentSelected(); // if norm family selected, trigger call to dao to render column if (!selectionFamilleNorme.isEmpty()) { dao.setSelectedRecords(selectionFamilleNorme); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/service/ServiceViewFamilleNorme.java b/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/service/ServiceViewFamilleNorme.java index a02e0b7d4..b52e80292 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/service/ServiceViewFamilleNorme.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/famillenorme/service/ServiceViewFamilleNorme.java @@ -6,6 +6,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -74,7 +75,7 @@ public String sortFamilleNorme(Model model) { public String downloadFamilleNorme(Model model, HttpServletResponse response) { - Map> selection = views.getViewFamilleNorme().mapContentSelected(); + Map> selection = views.getViewFamilleNorme().mapContentSelected(); if (!selection.isEmpty()) { diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/InteractorFile.java b/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/InteractorFile.java index 8bd7dcf35..86f13dab7 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/InteractorFile.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/InteractorFile.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; @@ -88,7 +89,7 @@ public void extraModelAttributes(Model model) { public void initializeDirIn() { loggerDispatcher.debug("/* initializeDirIn */", LOGGER); HashMap defaultInputFields = new HashMap<>(); - ArrayList> listeFichier = getDirFiles(views.getDirIn(), views.getViewDirIn()); + List> listeFichier = getDirFiles(views.getDirIn(), views.getViewDirIn()); this.vObjectService.initializeByList(views.getViewDirIn(), listeFichier, defaultInputFields); } @@ -97,7 +98,7 @@ public void initializeDirOut() { loggerDispatcher.debug("/* initializeDirOut */", LOGGER); HashMap defaultInputFields = new HashMap<>(); - ArrayList> listeFichier = getDirFiles(views.getDirOut(), views.getViewDirOut()); + List> listeFichier = getDirFiles(views.getDirOut(), views.getViewDirOut()); this.vObjectService.initializeByList(views.getViewDirOut(), listeFichier, defaultInputFields); @@ -112,7 +113,7 @@ public void initializeDirOut() { * @param dirTarget */ protected void transfer(VObject viewSource, String dirSource, String dirTarget) { - Map> m = viewSource.mapContentSelected(); + Map> m = viewSource.mapContentSelected(); if (!m.isEmpty()) { for (String f : m.get(VC_FILENAME)) { File fileSource = Paths.get(dirSource, f).toFile(); @@ -152,7 +153,7 @@ protected void transfer(VObject viewSource, String dirSource, String dirTarget) protected boolean delete(VObject viewSource, String dirSource) { // safeguard : only file or directory containing this magic word will be able to // be deleted - Map> m = viewSource.mapContentSelected(); + Map> m = viewSource.mapContentSelected(); if (!m.isEmpty()) { for (String f : m.get(VC_FILENAME)) { File fileSource = new File(dirSource + f); @@ -215,8 +216,8 @@ protected boolean delete(VObject viewSource, String dirSource) { */ protected void rename(VObject viewSource, String dirSource) { - Map> m0 = viewSource.mapContentBeforeUpdate(); - Map> m1 = viewSource.mapContentAfterUpdate(); + Map> m0 = viewSource.mapContentBeforeUpdate(); + Map> m1 = viewSource.mapContentAfterUpdate(); for (int i = 0; i < m0.get(VC_FILENAME).size(); i++) { File fileIn = new File(dirSource + m0.get(VC_FILENAME).get(i)); @@ -239,7 +240,7 @@ protected void rename(VObject viewSource, String dirSource) { * @param dirSource */ protected void download(HttpServletResponse response, VObject viewSource, String dirSource) { - HashMap> selection = viewSource.mapContentSelected(); + Map> selection = viewSource.mapContentSelected(); if (!selection.isEmpty()) { ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); @@ -260,7 +261,7 @@ protected void download(HttpServletResponse response, VObject viewSource, String } protected void copy(VObject viewSource, String dirSource, String dirTarget) { - Map> m = viewSource.mapContentSelected(); + Map> m = viewSource.mapContentSelected(); if (!m.isEmpty()) { for (String f : m.get(VC_FILENAME)) { File fileSource = new File(dirSource + f); @@ -297,7 +298,7 @@ protected void copy(VObject viewSource, String dirSource, String dirTarget) { * @param dirSource */ protected void createDirectory(VObject viewSource, String dirSource) { - HashMap> m = viewSource.mapInputFields(); + Map> m = viewSource.mapInputFields(); if (!m.isEmpty()) { if (m.get(VC_FILENAME).get(0) != null && !m.get(VC_FILENAME).get(0).trim().equals("")) { Path directoryPath = Paths.get(dirSource + m.get(VC_FILENAME).get(0).trim()); @@ -319,9 +320,9 @@ protected void createDirectory(VObject viewSource, String dirSource) { * @param dirVobject * @return */ - private ArrayList> getDirFiles(String dirUri, VObject dirVobject) { + private List> getDirFiles(String dirUri, VObject dirVobject) { File dirFile = Paths.get(dirUri).toFile(); - ArrayList> listeFichier; + List> listeFichier; if (!dirFile.exists() || !dirFile.isDirectory()) { listeFichier = errorFromDirectory(); } else { @@ -330,20 +331,20 @@ private ArrayList> getDirFiles(String dirUri, VObject dirVobje return listeFichier; } - private void initializeArrayForDirVObject(ArrayList> result) { + private void initializeArrayForDirVObject(List> result) { VObjectService.addRowToVObjectList(result, VC_FILENAME, IS_DIRECTORY); VObjectService.addRowToVObjectList(result, "text", "text"); } - private ArrayList> errorFromDirectory() { - ArrayList> result = new ArrayList<>(); + private List> errorFromDirectory() { + List> result = new ArrayList<>(); initializeArrayForDirVObject(result); VObjectService.addRowToVObjectList(result, "", "false"); return result; } - private ArrayList> getFilesFromDirectory(File dir, HashMap> filter) { - ArrayList> result = new ArrayList<>(); + private List> getFilesFromDirectory(File dir, Map> filter) { + List> result = new ArrayList<>(); initializeArrayForDirVObject(result); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/ServiceViewDirIn.java b/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/ServiceViewDirIn.java index 0f98cfb6d..d0563ca26 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/ServiceViewDirIn.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/ServiceViewDirIn.java @@ -2,7 +2,7 @@ import java.io.File; import java.nio.file.Paths; -import java.util.ArrayList; +import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; @@ -15,7 +15,7 @@ public class ServiceViewDirIn extends InteractorFile { public String seeDirIn(Model model) { - Map> m= views.getViewDirIn().mapContentSelected(); + Map> m= views.getViewDirIn().mapContentSelected(); if (!m.isEmpty() && m.get(IS_DIRECTORY).get(0).equals("true")) { views.setDirIn(Paths.get(views.getDirIn(), m.get(VC_FILENAME).get(0)).toString() + File.separator); model.addAttribute(DIR_IN, views.getDirIn()); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/ServiceViewDirOut.java b/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/ServiceViewDirOut.java index e5338efe3..a14922ae7 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/ServiceViewDirOut.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/file/service/ServiceViewDirOut.java @@ -2,7 +2,7 @@ import java.io.File; import java.nio.file.Paths; -import java.util.ArrayList; +import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; @@ -14,7 +14,7 @@ public class ServiceViewDirOut extends InteractorFile { public String seeDirOut(Model model) { - Map> m=views.getViewDirOut().mapContentSelected(); + Map> m=views.getViewDirOut().mapContentSelected(); if (!m.isEmpty()) { if(m.get(IS_DIRECTORY).get(0).equals("true")) { diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/InteractorNomenclature.java b/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/InteractorNomenclature.java index 95d24049f..2146f31e6 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/InteractorNomenclature.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/InteractorNomenclature.java @@ -1,6 +1,6 @@ package fr.insee.arc.web.gui.nomenclature.service; -import java.util.ArrayList; +import java.util.List; import java.util.Map; import org.apache.logging.log4j.LogManager; @@ -75,7 +75,7 @@ public void initializeNomenclature(VObject viewNomenclature, VObject viewListNom LoggerHelper.debug(LOGGER, "/* initializeViewNomenclature */"); try { // get the list nomenclatures selected record - Map> selectionListNomenclatures = viewListNomenclatures.mapContentSelected(); + Map> selectionListNomenclatures = viewListNomenclatures.mapContentSelected(); // if nomenclature selected, trigger call to dao to construct nomenclature view if (!selectionListNomenclatures.isEmpty() && dao .execQueryIsSelectedNomenclatureTableExists(selectionListNomenclatures.get(NOM_TABLE).get(0))) { @@ -101,7 +101,7 @@ public void initializeSchemaNmcl(VObject viewSchemaNmcl, VObject viewListNomencl LoggerHelper.debug(LOGGER, "/* initializeSchemaNmcl */"); try { // get the list nomenclatures selected record - Map> selectionListNomenclatures = viewListNomenclatures.mapContentSelected(); + Map> selectionListNomenclatures = viewListNomenclatures.mapContentSelected(); // if nomenclature selected, trigger call to dao to construct schema if (!selectionListNomenclatures.isEmpty()) { dao.setSelectedRecords(selectionListNomenclatures); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/ServiceViewListNomenclatures.java b/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/ServiceViewListNomenclatures.java index 8ee5bd002..453482766 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/ServiceViewListNomenclatures.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/ServiceViewListNomenclatures.java @@ -1,7 +1,7 @@ package fr.insee.arc.web.gui.nomenclature.service; -import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; @@ -83,7 +83,7 @@ public String deleteListNomenclatures(Model model) { public String downloadListNomenclatures(Model model, HttpServletResponse response) { - Map> selection = views.getViewListNomenclatures().mapContentSelected(); + Map> selection = views.getViewListNomenclatures().mapContentSelected(); if (!selection.isEmpty()) { diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/ServiceViewSchemaNmcl.java b/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/ServiceViewSchemaNmcl.java index 6559a7142..43d0ea3de 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/ServiceViewSchemaNmcl.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/nomenclature/service/ServiceViewSchemaNmcl.java @@ -1,7 +1,7 @@ package fr.insee.arc.web.gui.nomenclature.service; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -32,7 +32,7 @@ && isTypeValide(views.getViewSchemaNmcl().mapInputFields().get(TYPE_COLONNE).get } public String updateSchemaNmcl(Model model) { - HashMap> selection = views.getViewSchemaNmcl().mapContentAfterUpdate(); + Map> selection = views.getViewSchemaNmcl().mapContentAfterUpdate(); if (!selection.isEmpty()) { boolean zeroErreur = true; diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/dao/GererNormeDao.java b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/dao/GererNormeDao.java index 2fe446c91..0eb1731e2 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/dao/GererNormeDao.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/dao/GererNormeDao.java @@ -4,10 +4,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -23,7 +20,6 @@ import fr.insee.arc.core.dataobjects.DataObjectService; import fr.insee.arc.core.dataobjects.ViewEnum; import fr.insee.arc.core.service.global.ApiService; -import fr.insee.arc.core.service.global.bo.ArcDateFormat; import fr.insee.arc.utils.dao.SQL; import fr.insee.arc.utils.dao.UtilitaireDao; import fr.insee.arc.utils.exception.ArcException; @@ -310,11 +306,11 @@ public void execQueryPreGenererRegleMapping(VObject viewNorme, VObject viewJeuxD public void execQueryCopieJeuxDeRegles(VObject viewJeuxDeRegles, VObject viewJeuxDeReglesCopie, String selectedTableOfRegles) throws ArcException { // le jeu de regle à copier - Map> selectionOut = viewJeuxDeRegles.mapContentSelected(); + Map> selectionOut = viewJeuxDeRegles.mapContentSelected(); // le nouveau jeu de regle - Map> selectionIn = viewJeuxDeReglesCopie.mapContentSelected(); + Map> selectionIn = viewJeuxDeReglesCopie.mapContentSelected(); - HashMap type = viewJeuxDeReglesCopie.mapHeadersType(); + Map type = viewJeuxDeReglesCopie.mapHeadersType(); // columns found in all rules tables String inCommonColumns = new StringBuilder().append(ColumnEnum.ID_NORME.getColumnName()) @@ -395,8 +391,8 @@ public void execQueryCopieJeuxDeRegles(VObject viewJeuxDeRegles, VObject viewJeu */ public void emptyRuleTable(VObject viewRulesSet, String table) throws ArcException { - Map> selection = viewRulesSet.mapContentSelected(); - HashMap type = viewRulesSet.mapHeadersType(); + Map> selection = viewRulesSet.mapContentSelected(); + Map type = viewRulesSet.mapHeadersType(); ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); requete.append("DELETE FROM " + table); requete.append(" WHERE id_norme" + requete.sqlEqual(selection.get("id_norme").get(0), type.get("id_norme"))); @@ -469,7 +465,7 @@ public void uploadFileRule(VObject vObjectToUpdate, VObject viewRulesSet, Multip } LoggerHelper.debug(LOGGER, "Insert file in the " + nomTableImage + " table"); - Map> selection = viewRulesSet.mapContentSelected(); + Map> selection = viewRulesSet.mapContentSelected(); ArcPreparedStatementBuilder requete=new ArcPreparedStatementBuilder(); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/InteractorNorme.java b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/InteractorNorme.java index ee67e47e5..a0b41aacf 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/InteractorNorme.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/InteractorNorme.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.apache.logging.log4j.LogManager; @@ -102,7 +103,7 @@ public void initializeViewCalendar(VObject viewCalendar, VObject viewNorme) { LoggerHelper.debug(LOGGER, "/* initializeCalendar */"); // get the norm selected records - Map> viewNormSelectedRecords = viewNorme.mapContentSelected(); + Map> viewNormSelectedRecords = viewNorme.mapContentSelected(); // if a norm is selected, trigger the call to dao to construct calendar view if (!viewNormSelectedRecords.isEmpty()) { @@ -123,7 +124,7 @@ public void initializeViewRulesSet(VObject viewRulesSet, VObject viewCalendar) { loggerDispatcher.info("/* initializeViewRulesSet *", LOGGER); // Get the selected calendar for requesting the rule set - Map> viewCalendarSelectedRecords = viewCalendar.mapContentSelected(); + Map> viewCalendarSelectedRecords = viewCalendar.mapContentSelected(); // if a calendar is selected, trigger the call to dao to construct rulesset view if (!viewCalendarSelectedRecords.isEmpty()) { @@ -143,7 +144,7 @@ public void initializeViewModules(VObject viewModules, VObject viewRulesSet) { loggerDispatcher.info("/* initializeViewRulesSet *", LOGGER); // Get the selected ruleset - Map> viewRulesSetSelectedRecords = viewRulesSet.mapContentSelected(); + Map> viewRulesSetSelectedRecords = viewRulesSet.mapContentSelected(); // if any ruleset selected, display and initialized the modules if (!viewRulesSetSelectedRecords.isEmpty()) { @@ -169,8 +170,8 @@ public void initializeViewModules(VObject viewModules, VObject viewRulesSet) { public void initializeChargement(VObject viewChargement, VObject viewRulesSet, VObject viewModules) { - Map> viewRulesSetSelectedRecords = viewRulesSet.mapContentSelected(); - ArrayList> moduleSelection =viewModules.listContentSelected(); + Map> viewRulesSetSelectedRecords = viewRulesSet.mapContentSelected(); + List> moduleSelection =viewModules.listContentSelected(); if (!viewRulesSetSelectedRecords.isEmpty() && !moduleSelection.isEmpty() && moduleSelection.get(0).get(1).equals(moduleIdentifier(GuiModules.load))) @@ -188,8 +189,8 @@ public void initializeChargement(VObject viewChargement, VObject viewRulesSet, V * get the load rule link to the selected rule set. */ public void initializeNormage(VObject viewNormage, VObject viewRulesSet, VObject viewModules, String theTableName) { - Map> selection = viewRulesSet.mapContentSelected(); - ArrayList> moduleSelection =viewModules.listContentSelected(); + Map> selection = viewRulesSet.mapContentSelected(); + List> moduleSelection =viewModules.listContentSelected(); if (!selection.isEmpty() && !moduleSelection.isEmpty() && moduleSelection.get(0).get(1).equals(moduleIdentifier(GuiModules.structurize))) @@ -206,13 +207,13 @@ public void initializeNormage(VObject viewNormage, VObject viewRulesSet, VObject * get the load rule link to the selected rule set. */ public void initializeControle(VObject moduleView, VObject viewRulesSet, VObject viewModules, String theTableName) { - Map> selection = viewRulesSet.mapContentSelected(); - ArrayList> moduleSelection =viewModules.listContentSelected(); + Map> selection = viewRulesSet.mapContentSelected(); + List> moduleSelection =viewModules.listContentSelected(); if (!selection.isEmpty() && !moduleSelection.isEmpty() && moduleSelection.get(0).get(1).equals(moduleIdentifier(GuiModules.control))) { - HashMap type = viewRulesSet.mapHeadersType(); + Map type = viewRulesSet.mapHeadersType(); ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); requete.append("select id_norme,periodicite,validite_inf,validite_sup,version,id_regle,id_classe,rubrique_pere,rubrique_fils,borne_inf,borne_sup,condition,blocking_threshold,error_row_processing,pre_action,xsd_ordre,xsd_label_fils,xsd_role,commentaire from arc.ihm_controle_regle"); whereRuleSetEquals(requete, selection, type); @@ -228,13 +229,13 @@ public void initializeControle(VObject moduleView, VObject viewRulesSet, VObject * rule link to the selected rule set. */ public void initializeMapping(VObject viewMapping, VObject viewRulesSet, VObject viewModules, String theTableName) { - Map> selection = viewRulesSet.mapContentSelected(); - ArrayList> moduleSelection =viewModules.listContentSelected(); + Map> selection = viewRulesSet.mapContentSelected(); + List> moduleSelection =viewModules.listContentSelected(); if (!selection.isEmpty() && !moduleSelection.isEmpty() && moduleSelection.get(0).get(1).equals(moduleIdentifier(GuiModules.mapmodel))) { - HashMap type = viewRulesSet.mapHeadersType(); + Map type = viewRulesSet.mapHeadersType(); ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder( "SELECT mapping.id_regle, mapping.id_norme, mapping.validite_inf, mapping.validite_sup, mapping.version, mapping.periodicite, mapping.variable_sortie, mapping.expr_regle_col, mapping.commentaire, variables.type_variable_metier type_sortie, variables.nom_table_metier nom_table_metier /*, variables.nom_table_metier nom_table_metier */ "); @@ -262,13 +263,13 @@ public void initializeMapping(VObject viewMapping, VObject viewRulesSet, VObject */ public void initializeExpression(VObject moduleView, VObject viewRulesSet, VObject viewModules, String theTableName) { loggerDispatcher.info(String.format("Initialize view table %s", theTableName), LOGGER); - Map> selection = viewRulesSet.mapContentSelected(); - ArrayList> moduleSelection =viewModules.listContentSelected(); + Map> selection = viewRulesSet.mapContentSelected(); + List> moduleSelection =viewModules.listContentSelected(); if (!selection.isEmpty() && !moduleSelection.isEmpty() && moduleSelection.get(0).get(1).equals(moduleIdentifier(GuiModules.expression))) { - HashMap type = viewRulesSet.mapHeadersType(); + Map type = viewRulesSet.mapHeadersType(); ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder();; requete.append("select id_norme,periodicite,validite_inf,validite_sup,version,id_regle,expr_nom, expr_valeur, commentaire from arc.ihm_expression"); whereRuleSetEquals(requete, selection, type); @@ -301,8 +302,8 @@ public void initializeJeuxDeReglesCopie(VObject viewJeuxDeReglesCopie, VObject v /** Appends a where clause for rulesets. */ - protected void whereRuleSetEquals(ArcPreparedStatementBuilder requete, Map> selection, - HashMap type) { + protected void whereRuleSetEquals(ArcPreparedStatementBuilder requete, Map> selection, + Map type) { requete.append(" where id_norme" + requete.sqlEqual(selection.get("id_norme").get(0), type.get("id_norme"))); requete.append(" and periodicite" + requete.sqlEqual(selection.get("periodicite").get(0), type.get("periodicite"))); requete.append(" and validite_inf" + requete.sqlEqual(selection.get("validite_inf").get(0), type.get("validite_inf"))); @@ -327,7 +328,7 @@ private static String moduleIdentifier(GuiModules moduleName) * @param selection * @return */ - private HashMap defaultRuleInputFields(Map> selection) { + private HashMap defaultRuleInputFields(Map> selection) { HashMap defaultInputFields = new HashMap<>(); defaultInputFields.put("id_norme", selection.get("id_norme").get(0)); defaultInputFields.put("periodicite", selection.get("periodicite").get(0)); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewCalendrier.java b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewCalendrier.java index b4c912452..f97bd2905 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewCalendrier.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewCalendrier.java @@ -1,6 +1,6 @@ package fr.insee.arc.web.gui.norme.service; -import java.util.ArrayList; +import java.util.List; import java.util.Map; import org.springframework.stereotype.Service; @@ -36,7 +36,7 @@ public String addCalendrier(Model model) { */ public String deleteCalendrier(Model model) { // get the selected calendar - Map> selection = views.getViewCalendrier().mapContentSelected(); + Map> selection = views.getViewCalendrier().mapContentSelected(); if (!selection.isEmpty()) { String etat = selection.get("etat").get(0); // Check actived calendar (code 1) diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewJeuxDeRegles.java b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewJeuxDeRegles.java index 65cac0efd..00f4ca428 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewJeuxDeRegles.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewJeuxDeRegles.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; @@ -14,9 +15,7 @@ import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder; import fr.insee.arc.core.dataobjects.ViewEnum; -import fr.insee.arc.utils.exception.ArcException; -import fr.insee.arc.utils.utils.LoggerHelper; -import fr.insee.arc.web.gui.all.util.ConstanteBD; +import fr.insee.arc.web.gui.all.model.Sandbox; import fr.insee.arc.web.gui.all.util.VObject; @Service @@ -41,10 +40,10 @@ public String selectRuleSet(Model model) { * @return success */ public String addRuleSet(Model model) { - HashMap> selection = views.getViewJeuxDeRegles().mapInputFields(); + Map> selection = views.getViewJeuxDeRegles().mapInputFields(); if (!selection.isEmpty()) { String etat = selection.get("etat").get(0); - if (ConstanteBD.ARC_PROD.getValue().equals(etat)) { + if (Sandbox.ARC_PROD.getValue().equals(etat)) { this.views.getViewJeuxDeRegles().setMessage("normManagement.addRuleset.noProduction"); } else { this.vObjectService.insert(views.getViewJeuxDeRegles()); @@ -63,13 +62,13 @@ public String addRuleSet(Model model) { public String deleteRuleSet(Model model) { // Get the selection - Map> selection = views.getViewJeuxDeRegles().mapContentSelected(); + Map> selection = views.getViewJeuxDeRegles().mapContentSelected(); if (!selection.isEmpty()) { String etat = selection.get("etat").get(0); loggerDispatcher.info("State to delete : " + etat, LOGGER); // Check production state. If yes cancel the delete and send a message to the // user - if (ConstanteBD.ARC_PROD.getValue().equals(etat)) { + if (Sandbox.ARC_PROD.getValue().equals(etat)) { this.views.getViewJeuxDeRegles().setMessage("normManagement.deleteRuleset.noProduction"); } else { this.vObjectService.delete(views.getViewJeuxDeRegles()); @@ -106,7 +105,7 @@ public String sortRuleSet(Model model) { * @return */ public String downloadJeuxDeRegles(Model model, HttpServletResponse response) { - Map> selection = views.getViewJeuxDeRegles().mapContentSelected(); + Map> selection = views.getViewJeuxDeRegles().mapContentSelected(); if (!selection.isEmpty()) { ArcPreparedStatementBuilder requeteRegleChargement = new ArcPreparedStatementBuilder(); requeteRegleChargement.append(recupRegle(this.views.getViewJeuxDeRegles(), @@ -161,8 +160,8 @@ public String downloadJeuxDeRegles(Model model, HttpServletResponse response) { */ public ArcPreparedStatementBuilder recupRegle(VObject viewRulesSet, String table) { ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); - Map> selection = viewRulesSet.mapContentSelected(); - HashMap type = viewRulesSet.mapHeadersType(); + Map> selection = viewRulesSet.mapContentSelected(); + Map type = viewRulesSet.mapHeadersType(); requete.append("select * from " + table + " "); whereRuleSetEquals(requete, selection, type); return requete; diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewJeuxDeReglesCopie.java b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewJeuxDeReglesCopie.java index 2854b741d..41c05458b 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewJeuxDeReglesCopie.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewJeuxDeReglesCopie.java @@ -1,6 +1,6 @@ package fr.insee.arc.web.gui.norme.service; -import java.util.ArrayList; +import java.util.List; import java.util.Map; import org.apache.logging.log4j.LogManager; @@ -81,9 +81,9 @@ public String copieJeuxDeRegles(Model model) { loggerDispatcher.info("Mon action pour copier un jeu de règles", LOGGER); // le jeu de regle à copier - Map> selectionOut = views.getViewJeuxDeRegles().mapContentSelected(); + Map> selectionOut = views.getViewJeuxDeRegles().mapContentSelected(); // le nouveau jeu de regle - Map> selectionIn = views.getViewJeuxDeReglesCopie().mapContentSelected(); + Map> selectionIn = views.getViewJeuxDeReglesCopie().mapContentSelected(); if (!selectionOut.isEmpty() && !selectionIn.isEmpty()) { diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewNorme.java b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewNorme.java index d8ac197bf..b67957586 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewNorme.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/norme/service/ServiceViewNorme.java @@ -1,6 +1,6 @@ package fr.insee.arc.web.gui.norme.service; -import java.util.ArrayList; +import java.util.List; import java.util.Map; import org.apache.logging.log4j.LogManager; @@ -39,7 +39,7 @@ public String addNorme(Model model) { public String deleteNorme(Model model) { // Get the gui selection - Map> selection = views.getViewNorme().mapContentSelected(); + Map> selection = views.getViewNorme().mapContentSelected(); if (!selection.isEmpty()) { String etat = selection.get("etat").get(0); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/dao/PilotageDao.java b/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/dao/PilotageDao.java index cf2ce1dbe..05d3944e3 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/dao/PilotageDao.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/dao/PilotageDao.java @@ -150,9 +150,9 @@ public void initializeEntrepotBAS(VObject viewEntrepotBAS) throws ArcException { } public void initializeFichierBAS(VObject viewFichierBAS, VObject viewPilotageBAS, VObject viewRapportBAS) { - Map> selectionLigne = viewPilotageBAS.mapContentSelected(); - ArrayList selectionColonne = viewPilotageBAS.listHeadersSelected(); - Map> selectionLigneRapport = viewRapportBAS.mapContentSelected(); + Map> selectionLigne = viewPilotageBAS.mapContentSelected(); + List selectionColonne = viewPilotageBAS.listHeadersSelected(); + Map> selectionLigneRapport = viewRapportBAS.mapContentSelected(); if (!selectionLigne.isEmpty() && !selectionColonne.isEmpty()) { @@ -173,8 +173,8 @@ public void initializeFichierBAS(VObject viewFichierBAS, VObject viewPilotageBAS this.vObjectService.initialize(viewFichierBAS, requete, null, defaultInputFields); } else if (!selectionLigneRapport.isEmpty()) { - HashMap type = viewRapportBAS.mapHeadersType(); - HashMap defaultInputFields = new HashMap<>(); + Map type = viewRapportBAS.mapHeadersType(); + Map defaultInputFields = new HashMap<>(); ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); requete.append( @@ -239,7 +239,7 @@ public void execQueryDownloadArchive(HttpServletResponse response, VObject viewA public void downloadFichierBAS(VObject viewFichierBAS, HttpServletResponse response, String repertoire, String bacASable) { // récupération de la liste des id_source - Map> selection = viewFichierBAS.mapContentSelected(); + Map> selection = viewFichierBAS.mapContentSelected(); ArcPreparedStatementBuilder query = vObjectService.queryView(viewFichierBAS); // si la selection de fichiers n'est pas vide, on se restreint aux fichiers // sélectionner @@ -255,7 +255,7 @@ public void downloadFichierBAS(VObject viewFichierBAS, HttpServletResponse respo } public ArcPreparedStatementBuilder queryUpdateToDelete(VObject viewFichierBAS, String code) { - Map> selection = viewFichierBAS.mapContentSelected(); + Map> selection = viewFichierBAS.mapContentSelected(); ArcPreparedStatementBuilder querySelection = requestSelectToMark(viewFichierBAS, selection); return requeteUpdateToMark(querySelection, code); } @@ -293,7 +293,7 @@ public void downloadBdBAS(VObject viewFichierBAS, HttpServletResponse response, // Si des fichiers ont été selectionnés, on ajoute a la requete la liste des // fichiers if (!viewFichierBAS.mapContentSelected().isEmpty()) { - ArrayList filesSelected = viewFichierBAS.mapContentSelected().get("id_source"); + List filesSelected = viewFichierBAS.mapContentSelected().get("id_source"); requete.append("AND id_source IN ("); for (int i = 0; i < filesSelected.size(); i++) { if (i > 0) { @@ -304,7 +304,7 @@ public void downloadBdBAS(VObject viewFichierBAS, HttpServletResponse response, requete.append(")"); } - ArrayList idSources = new GenericBean(UtilitaireDao.get(0).executeRequest(null, requete)) + List idSources = new GenericBean(UtilitaireDao.get(0).executeRequest(null, requete)) .mapContent().get("id_source"); // for each files, generate the download query @@ -348,7 +348,7 @@ public void downloadBdBAS(VObject viewFichierBAS, HttpServletResponse response, public void downloadEnvelopeBAS(VObject viewFichierBAS, HttpServletResponse response, String chemin, ArrayList listRepertoire) { // récupération de la liste des noms d'enloppe - Map> selection = viewFichierBAS.mapContentSelected(); + Map> selection = viewFichierBAS.mapContentSelected(); ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.append("select distinct alias_de_table.container as nom_fichier from ("); query.append(viewFichierBAS.getMainQuery()); @@ -366,7 +366,7 @@ public void downloadEnvelopeBAS(VObject viewFichierBAS, HttpServletResponse resp * Prepare a request selecting the line to change when marking files for * deletion/replay. */ - private ArcPreparedStatementBuilder requestSelectToMark(VObject viewFichierBAS, Map> selection) { + private ArcPreparedStatementBuilder requestSelectToMark(VObject viewFichierBAS, Map> selection) { ArcPreparedStatementBuilder querySelection = new ArcPreparedStatementBuilder(); querySelection.append("select distinct container, id_source from ("); querySelection.append(viewFichierBAS.getMainQuery()); @@ -377,9 +377,9 @@ private ArcPreparedStatementBuilder requestSelectToMark(VObject viewFichierBAS, // sélectionné if (!selection.isEmpty()) { // concaténation des informations - ArrayList infoConcatenee = new ArrayList<>(); - ArrayList listContainer = selection.get("container"); - ArrayList listIdSource = selection.get("id_source"); + List infoConcatenee = new ArrayList<>(); + List listContainer = selection.get("container"); + List listIdSource = selection.get("id_source"); for (int i = 0; i < selection.get("id_source").size(); i++) { infoConcatenee.add(listContainer.get(i) + "+" + listIdSource.get(i)); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/InteractorPilotage.java b/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/InteractorPilotage.java index 65e4005f0..48e360a6c 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/InteractorPilotage.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/InteractorPilotage.java @@ -98,7 +98,7 @@ public void initializePilotageBAS(VObject viewPilotageBAS) { dao.initializePilotageBAS(viewPilotageBAS); - ArrayList columns = viewPilotageBAS.getHeadersDLabel(); + List columns = viewPilotageBAS.getHeadersDLabel(); Map columnRendering = viewPilotageBAS.getConstantVObject().columnRender; // for all columns, set rendering visibility to false diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/ServiceViewFichierBAS.java b/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/ServiceViewFichierBAS.java index 7a03e502f..273efb938 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/ServiceViewFichierBAS.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/ServiceViewFichierBAS.java @@ -93,9 +93,9 @@ private String restore(Model model, String code, String messageOk) { } public void downloadBdBAS(HttpServletResponse response) throws ArcException { - Map> selectionLigne = views.getViewPilotageBAS().mapContentSelected(); - ArrayList selectionColonne = views.getViewPilotageBAS().listHeadersSelected(); - ArrayList selectionIndexColonne = views.getViewPilotageBAS().indexHeadersSelected(); + Map> selectionLigne = views.getViewPilotageBAS().mapContentSelected(); + List selectionColonne = views.getViewPilotageBAS().listHeadersSelected(); + List selectionIndexColonne = views.getViewPilotageBAS().indexHeadersSelected(); String phase = TraitementPhase.getPhase(selectionIndexColonne.get(0)).toString(); String etat = selectionColonne.get(0).split("_")[1].toUpperCase(); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/ServiceViewPilotageBAS.java b/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/ServiceViewPilotageBAS.java index c8baf734d..242fb66ca 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/ServiceViewPilotageBAS.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/pilotage/service/ServiceViewPilotageBAS.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -134,7 +135,7 @@ public String undoBatch(Model model, TraitementPhase phaseAExecuter) { * @return */ private List undoFilesSelection() { - HashMap> m = new HashMap<>(views.getViewFichierBAS().mapContentSelected()); + Map> m = new HashMap<>(views.getViewFichierBAS().mapContentSelected()); if (!m.isEmpty() && m.get(ColumnEnum.ID_SOURCE.getColumnName()) != null) { return m.get(ColumnEnum.ID_SOURCE.getColumnName()); } diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/query/service/ServiceViewTable.java b/arc-web/src/main/java/fr/insee/arc/web/gui/query/service/ServiceViewTable.java index 3a984877c..e45d5a5f1 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/query/service/ServiceViewTable.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/query/service/ServiceViewTable.java @@ -1,7 +1,7 @@ package fr.insee.arc.web.gui.query.service; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.springframework.stereotype.Service; import org.springframework.ui.Model; @@ -13,7 +13,7 @@ public class ServiceViewTable extends InteractorQuery { public String seeTable(Model model) { - HashMap> mapContentSelected = views.getViewTable().mapContentSelected(); + Map> mapContentSelected = views.getViewTable().mapContentSelected(); if (!mapContentSelected.isEmpty()) { this.myQuery = QueryDao.queryTableSelected(mySchema, mapContentSelected.get(ColumnEnum.TABLENAME.getColumnName()).get(0)); model.addAttribute("myQuery", myQuery); diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/webservice/service/InteractorWebservice.java b/arc-web/src/main/java/fr/insee/arc/web/gui/webservice/service/InteractorWebservice.java index 488177c9d..29e3aae0e 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/webservice/service/InteractorWebservice.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/webservice/service/InteractorWebservice.java @@ -1,6 +1,6 @@ package fr.insee.arc.web.gui.webservice.service; -import java.util.ArrayList; +import java.util.List; import java.util.Map; import org.apache.logging.log4j.LogManager; @@ -51,7 +51,7 @@ private void initializeWebserviceQuery(VObject viewWsQuery, VObject viewWsContex LoggerHelper.debug(LOGGER, "/* initializeWebserviceQuery */"); // get the webservice selected records - Map> viewWsContextSelectedRecords = viewWsContext.mapContentSelected(); + Map> viewWsContextSelectedRecords = viewWsContext.mapContentSelected(); // if a webservice is selected, trigger the call to dao to construct query view if (!viewWsContextSelectedRecords.isEmpty()) { diff --git a/arc-web/src/test/java/fr/insee/arc/web/gui/export/dao/ExportDaoTest.java b/arc-web/src/test/java/fr/insee/arc/web/gui/export/dao/ExportDaoTest.java index 30871bbf0..4016019ca 100644 --- a/arc-web/src/test/java/fr/insee/arc/web/gui/export/dao/ExportDaoTest.java +++ b/arc-web/src/test/java/fr/insee/arc/web/gui/export/dao/ExportDaoTest.java @@ -74,11 +74,11 @@ public void startExportRetrieve() throws ArcException { // select the first record of viewNorm and set it as the selected record ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, "*", SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.EXPORT), SQL.WHERE, "file_name='test1'"); - Map> viewExportSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewExportSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); pdao.setSelectedRecords(viewExportSelectedRecords); // execute query - Map> retrievedData = pdao.startExportRetrieve(); + Map> retrievedData = pdao.startExportRetrieve(); // test the content of the view List viewColumns = ColumnEnum @@ -101,7 +101,7 @@ public void startExportUpdateStateEncours() throws ArcException { // test the content of the view ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, ColumnEnum.ETAT, SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.EXPORT), SQL.WHERE, "file_name='test1'"); - Map> viewExportUpdatedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewExportUpdatedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); assertEquals(TraitementEtat.ENCOURS.toString(), viewExportUpdatedRecords.get(ColumnEnum.ETAT.toString()).get(0)); } @@ -116,7 +116,7 @@ public void exportFileRetrieve() throws ArcException { tablesToExport.add("export"); // execute query - HashMap> retrievedData = pdao.exportFileRetrieveRules(0, howToExport, tablesToExport, BddPatcherTest.testSandbox1); + Map> retrievedData = pdao.exportFileRetrieveRules(0, howToExport, tablesToExport, BddPatcherTest.testSandbox1); // test the content of the view assertEquals(3, retrievedData.keySet().size()); // 3 columns selected diff --git a/arc-web/src/test/java/fr/insee/arc/web/gui/famillenorme/dao/GererFamilleNormeDaoTest.java b/arc-web/src/test/java/fr/insee/arc/web/gui/famillenorme/dao/GererFamilleNormeDaoTest.java index 836a202dc..0163cc940 100644 --- a/arc-web/src/test/java/fr/insee/arc/web/gui/famillenorme/dao/GererFamilleNormeDaoTest.java +++ b/arc-web/src/test/java/fr/insee/arc/web/gui/famillenorme/dao/GererFamilleNormeDaoTest.java @@ -71,7 +71,7 @@ public void initializeViewClient() throws ArcException { // select the first record of viewNormFamily and set it as the selected record ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, "*", SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.IHM_FAMILLE), SQL.WHERE, "id_famille='DSN'"); - Map> viewNormFamilySelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewNormFamilySelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); pdao.setSelectedRecords(viewNormFamilySelectedRecords); // execute query @@ -93,7 +93,7 @@ public void initializeViewHostAllowed() throws ArcException { // select the first record of viewClient and set it as the selected record ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, "*", SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.IHM_CLIENT), SQL.WHERE, "id_application='ARTEMIS'"); - Map> viewClientSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewClientSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); pdao.setSelectedRecords(viewClientSelectedRecords); @@ -119,7 +119,7 @@ public void initializeViewTableMetier() throws ArcException { // select the first record of viewFamilleNorme and set it as the selected record ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, "*", SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.IHM_FAMILLE), SQL.WHERE, "id_famille='DSN'"); - Map> viewNormFamilySelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewNormFamilySelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); pdao.setSelectedRecords(viewNormFamilySelectedRecords); @@ -148,7 +148,7 @@ public void initializeViewVariableMetier() throws ArcException { // select the first record of viewFamilleNorme and set it as the selected record ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, "*", SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.IHM_FAMILLE), SQL.WHERE, "id_famille='DSN'"); - Map> viewNormFamilySelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewNormFamilySelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); pdao.setSelectedRecords(viewNormFamilySelectedRecords); // select tables of dsn diff --git a/arc-web/src/test/java/fr/insee/arc/web/gui/nomenclature/dao/GererNomenclatureDaoTest.java b/arc-web/src/test/java/fr/insee/arc/web/gui/nomenclature/dao/GererNomenclatureDaoTest.java index 820ea05b1..32e4ddde7 100644 --- a/arc-web/src/test/java/fr/insee/arc/web/gui/nomenclature/dao/GererNomenclatureDaoTest.java +++ b/arc-web/src/test/java/fr/insee/arc/web/gui/nomenclature/dao/GererNomenclatureDaoTest.java @@ -81,7 +81,7 @@ public void initializeViewSchemaNmcl() throws ArcException { // select the first record of viewNorm and set it as the selected record ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, "*", SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.IHM_NMCL), SQL.WHERE, "nom_table='nmcl_evenements_v001'"); - Map> viewNomenclatureSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewNomenclatureSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); pdao.setSelectedRecords(viewNomenclatureSelectedRecords); // execute query diff --git a/arc-web/src/test/java/fr/insee/arc/web/gui/norme/dao/GererNormeDaoTest.java b/arc-web/src/test/java/fr/insee/arc/web/gui/norme/dao/GererNormeDaoTest.java index 48f44fc2e..85ec77701 100644 --- a/arc-web/src/test/java/fr/insee/arc/web/gui/norme/dao/GererNormeDaoTest.java +++ b/arc-web/src/test/java/fr/insee/arc/web/gui/norme/dao/GererNormeDaoTest.java @@ -74,7 +74,7 @@ public void initializeViewCalendar() throws ArcException { // select the first record of viewNorm and set it as the selected record ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, "*", SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.IHM_NORME), SQL.WHERE, "id_norme='v2016-02'"); - Map> viewNormSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewNormSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); pdao.setSelectedRecords(viewNormSelectedRecords); // execute query @@ -101,7 +101,7 @@ public void initializeViewRulesSet() throws ArcException { // select the first record of viewCalendar and set it as the selected record ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, "*", SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.IHM_CALENDRIER), SQL.WHERE, "id_norme='v2008-11'"); - Map> viewCalendarSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewCalendarSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); pdao.setSelectedRecords(viewCalendarSelectedRecords); // execute query @@ -128,7 +128,7 @@ public void initializeViewChargement() throws ArcException { ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); query.build(SQL.SELECT, "*", SQL.FROM, pdao.getDataObjectService().getView(ViewEnum.IHM_JEUDEREGLE)); query.build(SQL.WHERE, "id_norme='v2008-11'", SQL.AND, "version='vConformite'"); - Map> viewRulesSetSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); + Map> viewRulesSetSelectedRecords = new GenericBean(UtilitaireDao.get(0).executeRequest(c, query)).mapContent(); pdao.setSelectedRecords(viewRulesSetSelectedRecords); // execute query diff --git a/arc-web/src/test/java/fr/insee/arc/web/util/VObjectTest.java b/arc-web/src/test/java/fr/insee/arc/web/util/VObjectTest.java index 2a19d14d8..2df47e16a 100644 --- a/arc-web/src/test/java/fr/insee/arc/web/util/VObjectTest.java +++ b/arc-web/src/test/java/fr/insee/arc/web/util/VObjectTest.java @@ -4,6 +4,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import java.util.ArrayList; +import java.util.List; import org.junit.Before; import org.junit.Test; @@ -14,7 +15,7 @@ public class VObjectTest { private VObject defaultTestVobject; - private ArrayList> defaultContent; + private List> defaultContent; @Before public void before() { @@ -52,7 +53,7 @@ public void mapContentOk() { @Test public void listContentBeforeUpdateOk() { - ArrayList> newContent = new ArrayList<>(); + List> newContent = new ArrayList<>(); newContent.add(new ArrayList<>()); newContent.get(0).add("first_field_new"); newContent.get(0).add("second_field_value1"); @@ -66,7 +67,7 @@ public void listContentBeforeUpdateOk() { @Test public void listContentUpdatedContentOk() { - ArrayList> newContent = new ArrayList<>(); + List> newContent = new ArrayList<>(); newContent.add(new ArrayList<>()); newContent.get(0).add(null); newContent.get(0).add(null); @@ -83,7 +84,7 @@ public void listContentUpdatedContentOk() { @Test public void listContentOnlyUpdatedContentOk() { - ArrayList> newContent = new ArrayList<>(); + List> newContent = new ArrayList<>(); newContent.add(new ArrayList<>()); newContent.get(0).add(null); newContent.get(0).add(null); @@ -102,7 +103,7 @@ public void listContentOnlyUpdatedContentOk() { @Test public void listContentUpdatedOk() { - ArrayList> newContent = new ArrayList<>(); + List> newContent = new ArrayList<>(); newContent.add(new ArrayList<>()); newContent.get(0).add(null); newContent.get(0).add(null); diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep1InitializeClientTablesService.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep1InitializeClientTablesService.java index 3d21cb41e..6a3f8d601 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep1InitializeClientTablesService.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep1InitializeClientTablesService.java @@ -41,7 +41,7 @@ public ImportStep1InitializeClientTablesService(JSONObject dsnRequest) { private String famille; - private ArrayList> tablesMetierNames; + private List> tablesMetierNames; private List sources; diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep2GetTableNameService.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep2GetTableNameService.java index ed80d1042..2b16c036e 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep2GetTableNameService.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep2GetTableNameService.java @@ -1,6 +1,6 @@ package fr.insee.arc.ws.services.importServlet; -import java.util.ArrayList; +import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -70,7 +70,7 @@ public void execute(SendResponse resp) throws ArcException { tableName = ""; } else { // récupération du type - ArrayList> l = UtilitaireDao.get(0).executeRequest(null, + List> l = UtilitaireDao.get(0).executeRequest(null, new ArcPreparedStatementBuilder("select * from " + tableName + " where false ")); for (int j = 0; j < l.get(0).size(); j++) { diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ServletArc.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ServletArc.java index 874ecbdc7..88111f0a2 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ServletArc.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ServletArc.java @@ -121,7 +121,7 @@ public boolean securityAccessAndTracing(HttpServletRequest request, HttpServletR query.append("AND id_application=" + query.quoteText(clientRealName) + " "); query.append("AND " + query.quoteText(hostName) + " like host_allowed "); - HashMap> result = new HashMap<>(); + Map> result = new HashMap<>(); try { result = new GenericBean(UtilitaireDao.get(0).executeRequest(null, query)).mapContent(); } catch (ArcException e1) { diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDao.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDao.java index eb209c556..f9cf9c606 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDao.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDao.java @@ -1,6 +1,7 @@ package fr.insee.arc.ws.services.importServlet.dao; import java.util.ArrayList; +import java.util.List; import org.json.JSONObject; @@ -42,7 +43,7 @@ public interface ClientDao { * Périodicité. * @return La liste des noms des tables métiers. */ - ArrayList> getIdSrcTableMetier(long timestamp, String client, boolean reprise, String environnement, String idFamille, + List> getIdSrcTableMetier(long timestamp, String client, boolean reprise, String environnement, String idFamille, String validiteInf, String validiteSup, String periodicite) throws ArcException; /** @@ -55,7 +56,7 @@ ArrayList> getIdSrcTableMetier(long timestamp, String client, * @return La liste des noms des tables métiers. * @throws ArcException */ - ArrayList> getIdSrcTableMetier(long timestamp, JSONObject requeteJSON) throws ArcException; + List> getIdSrcTableMetier(long timestamp, JSONObject requeteJSON) throws ArcException; /** * Créer une image des tables métiers. @@ -72,7 +73,7 @@ ArrayList> getIdSrcTableMetier(long timestamp, String client, * @return liste des noms de tables images crées * @throws ArcException */ - ArrayList createImages(long timestamp, String client, String environnement, ArrayList> tablesMetierNames) throws ArcException; + List createImages(long timestamp, String client, String environnement, List> tablesMetierNames) throws ArcException; /** * Créer une image des tables métiers. @@ -89,7 +90,7 @@ ArrayList> getIdSrcTableMetier(long timestamp, String client, * @return liste des noms de tables images crées * @throws ArcException */ - void addImage(long timestamp, String client, String environnement, ArrayList tableMetier, ArrayList mesTablesImagesCrees) throws ArcException; + void addImage(long timestamp, String client, String environnement, List tableMetier, List mesTablesImagesCrees) throws ArcException; /** * Récupère les tables métiers. diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDaoImpl.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDaoImpl.java index 80a3749d3..9094512d3 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDaoImpl.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/dao/ClientDaoImpl.java @@ -74,12 +74,12 @@ public void verificationClientFamille(long timestamp, String client, String idFa * java.lang.String, java.lang.String, java.lang.String) */ @Override - public ArrayList> getIdSrcTableMetier(long timestamp, String client, boolean reprise, String environnement, String idFamille, + public List> getIdSrcTableMetier(long timestamp, String client, boolean reprise, String environnement, String idFamille, String validiteInf, String validiteSup, String periodicite) throws ArcException { // LoggerHelper.debugAsComment(LOGGER, timestamp, "ClientDaoImpl#getIdSrcTableMetier()"); Connection connection = null; - ArrayList> tablesMetierNames = new ArrayList>(); + List> tablesMetierNames = new ArrayList<>(); StringBuilder request = new StringBuilder("DROP TABLE IF EXISTS " + TableNaming.dbEnv(environnement) + client + "_" + timestamp + "_"+ColumnEnum.ID_SOURCE.getColumnName()+"; "); @@ -125,13 +125,13 @@ public ArrayList> getIdSrcTableMetier(long timestamp, String c } @Override - public ArrayList> getIdSrcTableMetier(long timestamp, JSONObject requeteJSON) throws ArcException { + public List> getIdSrcTableMetier(long timestamp, JSONObject requeteJSON) throws ArcException { LoggerHelper.debugAsComment(LOGGER, timestamp, "ClientDaoImpl#getIdSrcTableMetier()"); // Initialisation des variables Connection connection = null; - ArrayList> tablesMetierNames = new ArrayList>(); + List> tablesMetierNames = new ArrayList<>(); final String env = TableNaming.dbEnv(requeteJSON.getString(JsonKeys.ENVIRONNEMENT.getKey())); final String client = requeteJSON.getString(JsonKeys.CLIENT.getKey()); final String periodicite = requeteJSON.getString(JsonKeys.PERIODICITE.getKey()); @@ -247,12 +247,12 @@ public ArrayList> getIdSrcTableMetier(long timestamp, JSONObje * @see fr.insee.arc_essnet.ws.dao.ClientDarcmage(long, java.lang.String, java.lang.String, java.util.ArrayList) */ @Override - public ArrayList createImages(long timestamp, String client, String environnement, ArrayList> tablesMetierNames) throws ArcException { + public List createImages(long timestamp, String client, String environnement, List> tablesMetierNames) throws ArcException { LoggerHelper.debugAsComment(LOGGER, timestamp, "ClientDaoImpl.createImage()"); - ArrayList mesTablesImagesCrees = new ArrayList(); + List mesTablesImagesCrees = new ArrayList<>(); - for (ArrayList tableMetier : tablesMetierNames) { + for (List tableMetier : tablesMetierNames) { addImage(timestamp, client, environnement, tableMetier, mesTablesImagesCrees); @@ -262,7 +262,7 @@ public ArrayList createImages(long timestamp, String client, String envi } @Override - public void addImage(long timestamp, String client, String environnement, ArrayList tableMetier, ArrayList mesTablesImagesCrees) throws ArcException { + public void addImage(long timestamp, String client, String environnement, List tableMetier, List mesTablesImagesCrees) throws ArcException { Connection connection = null; StringBuilder request = new StringBuilder(); String prefixeNomTableImage = new StringBuilder().append(TableNaming.dbEnv(environnement)).append(client).append("_").append(timestamp) @@ -298,7 +298,7 @@ public void addImage(long timestamp, String client, String environnement, ArrayL public void getResponse(long timestamp, String client, String tableMetierName, String environnement, SendResponse resp) throws ArcException { LoggerHelper.debugAsComment(LOGGER, timestamp, ": ClientDaoImpl.getResponse()"); Connection connection = null; - ArrayList> result = new ArrayList<>(); + List> result = new ArrayList<>(); int nbLines = 0; int blockSize = 10000; @@ -361,7 +361,7 @@ public void updatePilotage(long timestamp, String environnement, String tableSou public void createNmcl(long timestamp, String client, String environnement) throws ArcException { LoggerHelper.debugAsComment(LOGGER, "ClientDaoImpl.createNmcl()"); Connection connection = null; - ArrayList> nmclNames = new ArrayList<>(); + List> nmclNames = new ArrayList<>(); String schema = ManipString.substringBeforeFirst(TableNaming.dbEnv(environnement), "."); try { @@ -378,7 +378,7 @@ public void createNmcl(long timestamp, String client, String environnement) thro String prefixeNomTableImage = new StringBuilder().append(TableNaming.dbEnv(environnement)).append(client).append("_").append(timestamp) .append("_").toString(); - for (ArrayList nmcl : nmclNames) { + for (List nmcl : nmclNames) { String nomTableImage = prefixeNomTableImage + nmcl.get(0); UtilitaireDao.get(0).executeImmediate(connection, @@ -495,7 +495,7 @@ public void createTableMetier(long timestamp, String client, String idFamille, S * @param resp * Flux où écrire la réponse une fois mise en forme. */ - private void mapJsonResponse(ArrayList> result, SendResponse resp) { + private void mapJsonResponse(List> result, SendResponse resp) { List table = new ArrayList<>(); StringBuilder row = new StringBuilder("\""); String cell; diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/restServices/execute/ExecuteEngineController.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/restServices/execute/ExecuteEngineController.java index 34f119fdf..d17f7652b 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/restServices/execute/ExecuteEngineController.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/restServices/execute/ExecuteEngineController.java @@ -9,6 +9,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -85,14 +86,14 @@ public ResponseEntity executeEngineClient( } break; case NORMAGE: - HashMap> pil = new HashMap<>(); + Map> pil = new HashMap<>(); pil.put(ColumnEnum.ID_SOURCE.getColumnName(), new ArrayList<>(Arrays.asList(bodyPojo.fileName))); pil.put("id_norme", new ArrayList<>(Arrays.asList(bodyPojo.norme))); pil.put("validite", new ArrayList<>(Arrays.asList(bodyPojo.validite))); pil.put("periodicite", new ArrayList<>(Arrays.asList(bodyPojo.periodicite))); pil.put("jointure", new ArrayList<>(Arrays.asList(structure))); - HashMap> regle = new HashMap<>(); + Map> regle = new HashMap<>(); regle.put("id_regle", new ArrayList<>()); regle.put("id_norme", new ArrayList<>()); regle.put("periodicite", new ArrayList<>()); @@ -102,14 +103,12 @@ public ResponseEntity executeEngineClient( regle.put("rubrique", new ArrayList<>()); regle.put("rubrique_nmcl", new ArrayList<>()); - HashMap> rubriqueUtiliseeDansRegles = new HashMap<>(); + Map> rubriqueUtiliseeDansRegles = new HashMap<>(); rubriqueUtiliseeDansRegles.put("var", new ArrayList<>()); NormageEngine normage = new NormageEngine(connection, pil, regle, rubriqueUtiliseeDansRegles, previousTemporaryTable(i), currentTemporaryTable(i), null); normage.executeEngine(); - structure = normage.structure; - break; case CONTROLE: requete = new StringBuilder(); @@ -123,7 +122,7 @@ public ResponseEntity executeEngineClient( JeuDeRegle jdr = new JeuDeRegle(); sjdr.fillRegleControle(connection, jdr, env + ".controle_regle", currentTemporaryTable(i)); - sjdr.executeJeuDeRegle(connection, jdr, currentTemporaryTable(i), structure); + sjdr.executeJeuDeRegle(connection, jdr, currentTemporaryTable(i)); break; case MAPPING: UtilitaireDao.get(0).executeImmediate(connection, "CREATE TEMPORARY TABLE "+currentTemporaryTable(i)+" as select * from "+previousTemporaryTable(i)+" WHERE controle IN ('"+ServiceRequeteSqlRegle.RECORD_WITH_NOERROR+"','"+ServiceRequeteSqlRegle.RECORD_WITH_ERROR_TO_KEEP+"');"); diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/restServices/execute/ExecuteRulesDao.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/restServices/execute/ExecuteRulesDao.java index 95eace73f..5e3750827 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/restServices/execute/ExecuteRulesDao.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/restServices/execute/ExecuteRulesDao.java @@ -3,7 +3,8 @@ import java.sql.Connection; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; +import java.util.List; +import java.util.Map; import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder; import fr.insee.arc.utils.dao.UtilitaireDao; @@ -40,7 +41,7 @@ public static void fillRules(Connection c, ExecuteParameterPojo p, String servic // Récupération des parametres gb=new GenericBean(UtilitaireDao.get(0).executeRequest(c, requete)); - HashMap> m=gb.mapContent(); + Map> m=gb.mapContent(); if (!m.isEmpty()) {