diff --git a/arc-batch/src/main/java/fr/insee/arc/batch/BatchARC.java b/arc-batch/src/main/java/fr/insee/arc/batch/BatchARC.java index 0295f329f..f2c1c7fe7 100644 --- a/arc-batch/src/main/java/fr/insee/arc/batch/BatchARC.java +++ b/arc-batch/src/main/java/fr/insee/arc/batch/BatchARC.java @@ -86,9 +86,9 @@ class BatchARC implements IReturnCode { private boolean dejaEnCours; // Array of phases - private ArrayList phases = new ArrayList<>(); + private List phases = new ArrayList<>(); // Map of thread by phase - private HashMap> pool = new HashMap<>(); + private Map> pool = new HashMap<>(); // delay between phase start private int delay; @@ -457,8 +457,8 @@ private void resetWorkDirectory() throws ArcException, IOException { * @param pool * @return */ - private void initializeBatchLoop(ArrayList phases, - HashMap> pool) { + private void initializeBatchLoop(List phases, + Map> pool) { int stepNumber = (TraitementPhase.MAPPING.getOrdre() - TraitementPhase.CHARGEMENT.getOrdre()) + 2; this.delay = poolingDelay / stepNumber; @@ -535,7 +535,7 @@ private void updateProductionOn() throws ArcException { // updtate the thread pool by phase by deleting the dead and finished thread private void updateThreadPoolStatus() { // delete dead thread i.e. keep only living thread in the pool - HashMap> poolToKeep = new HashMap<>(); + Map> poolToKeep = new HashMap<>(); for (TraitementPhase phase : phases) { poolToKeep.put(phase, new ArrayList<>()); if (!pool.get(phase).isEmpty()) { diff --git a/arc-core/src/main/java/fr/insee/arc/core/model/TraitementPhase.java b/arc-core/src/main/java/fr/insee/arc/core/model/TraitementPhase.java index c968e34b4..5f2c75474 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/model/TraitementPhase.java +++ b/arc-core/src/main/java/fr/insee/arc/core/model/TraitementPhase.java @@ -58,8 +58,8 @@ public static TraitementPhase getPhase(String s) * * @return */ - public ArrayList nextPhases() { - ArrayList listPhase = new ArrayList<>(); + public List nextPhases() { + List listPhase = new ArrayList<>(); for (TraitementPhase phase : TraitementPhase.values()) { if (phase.getOrdre() > ordre) { listPhase.add(phase); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/global/bo/JeuDeRegle.java b/arc-core/src/main/java/fr/insee/arc/core/service/global/bo/JeuDeRegle.java index ba435cbe1..bb577d835 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/global/bo/JeuDeRegle.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/global/bo/JeuDeRegle.java @@ -4,6 +4,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; +import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -23,7 +24,7 @@ public class JeuDeRegle { private Date validiteSup; private String version; - private ArrayList listRegleControle; + private List listRegleControle; private String etat; @@ -106,11 +107,11 @@ public void setValiditeSupString(String validiteSup, String format) { } } - public ArrayList getListRegleControle() { + public List getListRegleControle() { return this.listRegleControle; } - public void setListRegleControle(ArrayList listRegleControle) { + public void setListRegleControle(List listRegleControle) { this.listRegleControle = listRegleControle; } 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 99b3c4abf..c99b90c91 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 @@ -4,7 +4,6 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -17,7 +16,6 @@ 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 { private static final Logger LOGGER = LogManager.getLogger(JeuDeRegleDao.class); @@ -35,7 +33,7 @@ private JeuDeRegleDao() { * @return * @throws ArcException */ - public static ArrayList recupJeuDeRegle(Connection connexion, String tableJeuDeRegle) throws ArcException { + public static List recupJeuDeRegle(Connection connexion, String tableJeuDeRegle) throws ArcException { StaticLoggerDispatcher.info(LOGGER, "Recherche des jeux de règles à appliquer"); StringBuilder requete = new StringBuilder(); @@ -56,7 +54,7 @@ public static ArrayList recupJeuDeRegle(Connection connexion, String * @return * @throws ArcException */ - public static ArrayList recupJeuDeRegle(Connection connexion, String nomTableATraiter, String tableJeuDeRegle) throws ArcException { + public static List recupJeuDeRegle(Connection connexion, String nomTableATraiter, String tableJeuDeRegle) throws ArcException { StaticLoggerDispatcher.info(LOGGER, "Recherche des jeux de règles à appliquer"); StringBuilder requete = new StringBuilder(); @@ -72,15 +70,15 @@ public static ArrayList recupJeuDeRegle(Connection connexion, String Map> g=new GenericBean(UtilitaireDao.get(0).executeRequest(connexion, new ArcPreparedStatementBuilder(requete))).mapContent(); - ArrayList listJdr = extractRuleSetObjects(g); + List listJdr = extractRuleSetObjects(g); StaticLoggerDispatcher.info(LOGGER, "J'ai trouvé " + listJdr.size() + " jeux de règle, utiles pour controler"); return listJdr; } - private static ArrayList extractRuleSetObjects(Map> g) throws ArcException { + private static List extractRuleSetObjects(Map> g) throws ArcException { SimpleDateFormat formatDate = new SimpleDateFormat(ArcDateFormat.DATE_FORMAT_CONVERSION.getApplicationFormat()); - ArrayList listJdr = new ArrayList<>(); + List listJdr = new ArrayList<>(); if (!g.isEmpty()) { for (int i=0;i getRegle(Connection connexion, String tableRegle, String tableIn) + public static List getRegle(Connection connexion, String tableRegle, String tableIn) throws ArcException { StaticLoggerDispatcher.debug(logger, "getRegle"); - ArrayList listRegle = new ArrayList<>(); + List listRegle = new ArrayList<>(); ArcPreparedStatementBuilder sb = new ArcPreparedStatementBuilder(); sb.append("SELECT id_regle, id_classe, "); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/global/thread/MultiThreading.java b/arc-core/src/main/java/fr/insee/arc/core/service/global/thread/MultiThreading.java index 9e03513a4..50323dd2b 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/global/thread/MultiThreading.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/global/thread/MultiThreading.java @@ -231,7 +231,7 @@ protected static Map> dispatchFilesByNodId(List l */ private static List prepareThreads(int executorNodTarget, int parallelDegree, String anEnvExecution, String restrictedUsername) { - ArrayList connexionList = new ArrayList<>(); + List connexionList = new ArrayList<>(); try { // add thread connexions 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 0377e04e5..9f160014d 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 @@ -160,7 +160,7 @@ private void applyExpressions() throws ArcException { // Checks expression validity ExpressionService expressionService = new ExpressionService(); - ArrayList allRuleSets = JeuDeRegleDao.recupJeuDeRegle(connexion, ViewEnum.JEUDEREGLE.getFullName(anExecutionEnvironment)); + List allRuleSets = JeuDeRegleDao.recupJeuDeRegle(connexion, ViewEnum.JEUDEREGLE.getFullName(anExecutionEnvironment)); for (JeuDeRegle ruleSet : allRuleSets) { // Check GenericBean expressions = expressionService.fetchExpressions(connexion, anExecutionEnvironment, ruleSet); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p1reception/registerfiles/FileRegistration.java b/arc-core/src/main/java/fr/insee/arc/core/service/p1reception/registerfiles/FileRegistration.java index aa2782529..b16bf7979 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p1reception/registerfiles/FileRegistration.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p1reception/registerfiles/FileRegistration.java @@ -108,7 +108,7 @@ private FilesDescriber findDuplicates(FilesDescriber fileList) throws ArcExcepti dao.execQueryInsertCorruptedArchiveInPilotage(content); List listContainerDoublons = new ArrayList<>(); - ArrayList listVersionContainerDoublons = new ArrayList<>(); + List listVersionContainerDoublons = new ArrayList<>(); dao.execQueryVersionDuplicateArchives(listContainerDoublons, listVersionContainerDoublons); @@ -118,7 +118,7 @@ private FilesDescriber findDuplicates(FilesDescriber fileList) throws ArcExcepti } private void markArchivesVersion(FilesDescriber content, List listContainerDoublons, - ArrayList listVersionContainerDoublons) { + List listVersionContainerDoublons) { // set the num 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 fbdf63258..2c5c3da98 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 @@ -172,7 +172,7 @@ private void clefValeurToXml(Map arbreFormat, InputStream tmpInx * @throws IOException * @throws ArcException */ - private ArrayList initialisationOutputStream(Map arbreFormat, Map> mapRubriquesFilles, + private List initialisationOutputStream(Map arbreFormat, Map> mapRubriquesFilles, String ligne) throws ArcException { // ecriture de l'entete du fichier @@ -190,7 +190,7 @@ private ArrayList initialisationOutputStream(Map arbreFo if (!arbreFormat.containsKey(rubrique)) { throw new ArcException(ArcExceptionMessage.LOAD_KEYVALUE_VAR_NOT_EXISTS_IN_FORMAT_RULES, rubrique); } - ArrayList listePeresRubriqueCourante = new ArrayList<>(); + List listePeresRubriqueCourante = new ArrayList<>(); // On remonte dans l'arbre des pères jusqu'à la racine while (rubrique != null) { listePeresRubriqueCourante.add(rubrique); @@ -227,7 +227,7 @@ private ArrayList initialisationOutputStream(Map arbreFo * @throws IOException * @throws ArcException */ - private ArrayList lectureLigne(Map arbreFormat, + private List lectureLigne(Map arbreFormat, List listePeresRubriquePrecedante, Map> mapRubriquesFilles, String ligne) throws ArcException { @@ -252,7 +252,7 @@ private ArrayList lectureLigne(Map arbreFormat, if (!arbreFormat.containsKey(pere)) { throw new ArcException(ArcExceptionMessage.LOAD_KEYVALUE_VAR_NOT_EXISTS_IN_FORMAT_RULES, rubrique); } - ArrayList listePeresRubriqueCourante = new ArrayList<>(); + List listePeresRubriqueCourante = new ArrayList<>(); while (pere != null) { listePeresRubriqueCourante.add(pere); pere = arbreFormat.get(pere); 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 d2662e1ca..6f56e461f 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 @@ -168,16 +168,8 @@ public void execution() throws ArcException { java.util.Date beginDate = new java.util.Date(); // Création de la table de stockage - XMLComplexeHandlerCharger handler = new XMLComplexeHandlerCharger(); - handler.fileName = fileName; - handler.connexion = connexion; - handler.tempTableA = this.tableTempA; - handler.normeCourante = norme; - handler.validite = validite; - handler.tempTableAColumnsLongName = this.tempTableAColumnsLongName; - handler.tempTableAColumnsShortName = this.tempTableAColumnsShortName; - handler.format = this.format; - + XMLComplexeHandlerCharger handler = new XMLComplexeHandlerCharger(connexion, fileName, norme, validite, this.tableTempA, + this.tempTableAColumnsLongName, this.tempTableAColumnsShortName, format); // appel du parser et gestion d'erreur try { SAXParser saxParser = SecuredSaxParser.buildSecuredSaxParser(); @@ -189,7 +181,7 @@ public void execution() throws ArcException { throw businessException; } - this.jointure = handler.jointure; + this.jointure = handler.getJointure(); java.util.Date endDate = new java.util.Date(); StaticLoggerDispatcher.info(LOGGER, "** execution temps" + (endDate.getTime() - beginDate.getTime()) + " ms"); diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/ArbreFormat.java b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/ArbreFormat.java index 4d0c35aac..25048ec20 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/ArbreFormat.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/ArbreFormat.java @@ -4,6 +4,7 @@ import java.io.StringReader; import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Map; import javax.xml.parsers.ParserConfigurationException; @@ -35,10 +36,10 @@ public class ArbreFormat { private Map arbreHierachieDuFichier; //éléments terminaux - private ArrayList feuilles = new ArrayList<>(); + private List feuilles = new ArrayList<>(); //éléments intermédiaire - private ArrayList branches = new ArrayList<>(); + private List branches = new ArrayList<>(); public ArbreFormat(Norme aNorme) throws ArcException { super(); @@ -81,8 +82,8 @@ private void calculerFeuilles(){ /* * Retourne la liste des pères d'un élément */ - public ArrayList getPeres (String fils){ - ArrayList listePere = new ArrayList(); + public List getPeres (String fils){ + List listePere = new ArrayList<>(); listePere.add(fils); String pere = this.arbreHierachieDuFichier.get(fils); @@ -112,28 +113,28 @@ public void setArbreFormat(Map arbreFormat) { /** * @return the feuilles */ - public ArrayList getFeuilles() { + public List getFeuilles() { return feuilles; } /** * @param feuilles the feuilles to set */ - public void setFeuilles(ArrayList feuilles) { + public void setFeuilles(List feuilles) { this.feuilles = feuilles; } /** * @return the branches */ - public ArrayList getBranches() { + public List getBranches() { return branches; } /** * @param feuilles the feuilles to set */ - public void setBranches(ArrayList branches) { + public void setBranches(List branches) { this.branches = branches; } diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/FormatFichierHandler.java b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/FormatFichierHandler.java index ab5d07386..df0117020 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/FormatFichierHandler.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p2chargement/xmlhandler/FormatFichierHandler.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.xml.sax.Attributes; @@ -27,7 +28,7 @@ public class FormatFichierHandler extends DefaultHandler { private Map arbre = new HashMap<>(); //la liste des pères de l'éléments courant - private ArrayList listePere = new ArrayList<>(); + private List listePere = new ArrayList<>(); @Override public void startDocument() throws SAXException { 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 7b4329e93..cb9e6e45f 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 @@ -16,7 +16,6 @@ import fr.insee.arc.core.dataobjects.ColumnEnum; 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; import fr.insee.arc.utils.dataobjects.TypeEnum; import fr.insee.arc.utils.exception.ArcException; import fr.insee.arc.utils.format.Format; @@ -32,38 +31,63 @@ public class XMLComplexeHandlerCharger extends org.xml.sax.helpers.DefaultHandler { private static final Logger LOGGER = LogManager.getLogger(XMLHandlerCharger4.class); - public XMLComplexeHandlerCharger() { + public XMLComplexeHandlerCharger(Connection connexion, String fileName, Norme normeCourante, String validite, + String tempTableA, FastList tempTableAColumnsLongName, + FastList tempTableAColumnsShortName, ArrayList> format) { super(); + this.connexion = connexion; + this.fileName = fileName; + this.normeCourante = normeCourante; + this.validite = validite; + this.tempTableA = tempTableA; + this.tempTableAColumnsLongName = tempTableAColumnsLongName; + this.tempTableAColumnsShortName = tempTableAColumnsShortName; + this.format=format; } + + + + + // input + private Connection connexion; + private String fileName; + private Norme normeCourante; + private String validite; + 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 Map 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 Map colData = new HashMap<>(); - private HashMap tree = new HashMap<>(); - private HashMap treeNode = new HashMap<>(); - private HashMap colDist = new HashMap<>(); - private HashMap keepLast = new HashMap<>(); + private Map tree = new HashMap<>(); + private Map treeNode = new HashMap<>(); + + private Map colDist = new HashMap<>(); + private Map keepLast = new HashMap<>(); - private int start = 0; private int idLigne = 0; private int distance = 0; - public Connection connexion; - - public String fileName; - public String jointure = ""; private String currentTag; private String closedTag; private String closedTag1; - private String closedTag2; // this handler will keep the father reference to handle elements which have the // same name but not the same parent private String rootFather = "*"; - private String father = rootFather; private StringBuilder currentData = new StringBuilder(); @@ -73,42 +97,39 @@ public XMLComplexeHandlerCharger() { private boolean leafPossible = false; private boolean leafStatus = false; - /* stacks of ancestors */ - /* ancestors with raw xml name */ - private Map treeStackQName = new HashMap<>(); - private Integer orderTreeStackQName = 0; - - /* ancestors with database name */ private List treeStack = new ArrayList<>(); 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<>(); private List lineIds = new ArrayList<>(); private List lineValues = new ArrayList<>(); - private StringBuilder requete = new StringBuilder(); - // indique que la balise courante a des données private boolean hasData = false; - public Norme normeCourante; - public String validite; + private ParallelInsert pi; - // column of the load table A - public String tempTableA; - public FastList tempTableAColumnsLongName; - public FastList tempTableAColumnsShortName; + private static final String ALTER = "ALTER"; + + private Map requetes = new HashMap<>(); + private int requetesLength = 0; + + // initialize the integration date with current + private final String integrationDate = DateConversion.queryDateConversion(new Date()); // format to rename column with format rules public ArrayList> format; private static final String HEADER = "$h"; + /* stacks of ancestors */ + /* ancestors with raw xml name */ + private Map treeStackQName = new HashMap<>(); + private Integer orderTreeStackQName = 0; - // initialize the integration date with current - private final String integrationDate = DateConversion.queryDateConversion(new Date()); /** * Actions à réaliser sur les données @@ -131,22 +152,17 @@ public void characters(char[] caracteres, int debut, int longueur) { */ @Override public void endDocument() throws SAXParseException { - insertQueryBuilder(this.requete, this.tempTableA, this.fileName, this.lineCols, this.lineIds, this.lineValues); - this.start = this.requete.length(); + insertQueryBuilder(this.tempTableA, this.fileName, this.lineCols, this.lineIds, this.lineValues); - renameColumns(); + StringBuilder requete = new StringBuilder(computeFinalQuery()); + renameColumns(requete); + multiLeafUpdate(requete); - multiLeafUpdate(); + waitForParallelInsertAndReport(); - try { - UtilitaireDao.get(0).executeImmediate(this.connexion, this.requete); - } catch (ArcException ex) { - LoggerHelper.errorGenTextAsComment(getClass(), "XMLComplexeHandlerCharger.startElement()", LOGGER, ex); - throw new SAXParseException("Fichier XML : erreur de requete insertion : " + ex.getMessage(), "", "", 0, - 0); - } - this.requete.setLength(0); - this.start = 0; + pi = new ParallelInsert(this.connexion, requete.toString()); + pi.start(); + waitForParallelInsertAndReport(); // construction de la requete de jointure requeteJointureXML(); @@ -160,7 +176,8 @@ public void endDocument() throws SAXParseException { */ @Override public void endElement(String uri, String localName, String qName) throws SAXParseException { - this.closedTag2 = this.closedTag1; + + String closedTag2 = this.closedTag1; this.closedTag1 = this.closedTag; this.closedTag = Format.toBdRaw(renameColumn(qName)); @@ -168,10 +185,9 @@ public void endElement(String uri, String localName, String qName) throws SAXPar // on doit arriver à la fin du stream de l'element et concaténer toutes // les données trouvées jusqu'a ce qu'on en trouve plus if (this.closedTag.equals(this.currentTag) && this.hasData) { - if (this.colData.get(this.currentTag) == null) { this.colData.put(this.currentTag, 1); - this.requete.append("alter table " + this.tempTableA + " add v" + this.allCols.indexOf(this.currentTag) + addQuery(ALTER, "alter table " + this.tempTableA + " add v" + this.allCols.indexOf(this.currentTag) + " " + TypeEnum.TEXT.getTypeName() + ";"); } @@ -189,7 +205,7 @@ public void endElement(String uri, String localName, String qName) throws SAXPar * balise a été fermée 2 fois de suite */ boolean multipleLeaf = (this.closedTag1 != null && this.closedTag1.equals(this.closedTag)) - || (this.closedTag2 != null && this.closedTag2.equals(this.closedTag1)); + || (closedTag2 != null && closedTag2.equals(this.closedTag1)); if (multipleLeaf) { String closedTagHeader1 = this.closedTag1 + HEADER; @@ -198,8 +214,8 @@ public void endElement(String uri, String localName, String qName) throws SAXPar // créer et enregistrer la colonne si elle n'existe pas if (o == null) { this.allCols.add(closedTagHeader1); - this.requete.append("alter table " + this.tempTableA + " add i" + this.allCols.indexOf(closedTagHeader1) - + " " + TypeEnum.INTEGER.getTypeName() + ";"); + addQuery(ALTER, "alter table " + this.tempTableA + " add i" + this.allCols.indexOf(closedTagHeader1) + + " " + TypeEnum.INTEGER.getTypeName() + ";"); } String fatherOfTheBlock = this.treeStackFatherLag.get(this.treeStackFatherLag.size() - 1); @@ -238,9 +254,9 @@ public void endElement(String uri, String localName, String qName) throws SAXPar // mise à jour des listes treeStackQName.remove(qName); orderTreeStackQName--; + this.treeStackFatherLag = new ArrayList<>(this.treeStackFather); this.treeStack.remove(this.treeStack.size() - 1); - this.treeStackFatherLag = new ArrayList<>(this.treeStackFather); this.father = this.treeStackFather.get(this.treeStackFather.size() - 1); this.treeStackFather.remove(this.treeStackFather.size() - 1); @@ -250,13 +266,11 @@ public void endElement(String uri, String localName, String qName) throws SAXPar if (this.lineCols.indexOf(this.allCols.indexOf(this.closedTag)) < this.lineCols.size() - 1) { // réalisation de l'insertion - - insertQueryBuilder(this.requete, this.tempTableA, this.fileName, - this.lineCols.subList(0, this.lineCols.size() - 1), + insertQueryBuilder(this.tempTableA, this.fileName, this.lineCols.subList(0, this.lineCols.size() - 1), this.lineIds.subList(0, this.lineCols.size() - 1), this.lineValues.subList(0, this.lineCols.size() - 1)); - int i = 0; + int i; if (multipleLeaf) { String closedTagHeader1 = this.closedTag1 + HEADER; i = this.lineCols.indexOf(this.allCols.indexOf(closedTagHeader1)); @@ -290,6 +304,7 @@ public void endElement(String uri, String localName, String qName) throws SAXPar this.lineCols11.add(this.lineCols11.get(this.lineCols11.size() - 1)); } + } /** @@ -297,6 +312,10 @@ public void endElement(String uri, String localName, String qName) throws SAXPar */ @Override public void startDocument() { + // intialisation de la connexion + // creation de la table + this.pi = new ParallelInsert(this.connexion, null); + try { this.colDist.put(-1, 0); } catch (Exception ex) { @@ -313,30 +332,26 @@ public void startDocument() { @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXParseException { - this.treeStackQName.put(qName, orderTreeStackQName); orderTreeStackQName++; - + this.currentTag = Format.toBdRaw(renameColumn(qName)); - this.currentData.setLength(0); this.hasData = false; // on ajoute les colonnes si besoin // on met à jour le numéro d'index - Object o = this.col.get(this.currentTag); + Integer o = this.col.get(this.currentTag); // créer et enregistrer la colonne si elle n'existe pas if (o == null) { this.col.put(this.currentTag, 1); this.allCols.add(this.currentTag); - - this.requete.append("alter table " + this.tempTableA + " add i" + this.allCols.indexOf(this.currentTag) - + " " + TypeEnum.INTEGER.getTypeName() + ";"); - + addQuery(ALTER, "alter table " + this.tempTableA + " add i" + this.allCols.indexOf(this.currentTag) + " " + + TypeEnum.INTEGER.getTypeName() + ";"); } else { // ajouter 1 a son index si la colonne existe dejà - this.col.put(this.currentTag, (Integer) (o) + 1); + this.col.put(this.currentTag, o + 1); } this.distance++; @@ -372,29 +387,32 @@ public void startElement(String uri, String localName, String qName, Attributes if (this.treeStackFatherLag.indexOf(this.father) >= 0 && this.leafStatus == false) { - insertQueryBuilder(this.requete, this.tempTableA, this.fileName, this.lineCols, this.lineIds, - this.lineValues); + insertQueryBuilder(this.tempTableA, this.fileName, this.lineCols, this.lineIds, this.lineValues); + + if (this.requetesLength > FormatSQL.TAILLE_MAXIMAL_BLOC_SQL) { + + String query = computeFinalQuery(); + + waitForParallelInsertAndReport(); + + pi = new ParallelInsert(this.connexion, query); + pi.start(); - if (this.requete.length() > FormatSQL.TAILLE_MAXIMAL_BLOC_SQL) { - try { - UtilitaireDao.get(0).executeImmediate(this.connexion, this.requete); - } catch (ArcException ex) { - LoggerHelper.errorGenTextAsComment(getClass(), "startElement()", LOGGER, ex); - throw new SAXParseException("Fichier XML : erreur de requete insertion : " + ex.getMessage(), "", - "", 0, 0); - } - this.requete.setLength(0); - this.start = 0; } + // On va alors dépiler ligneCols, lineIds, lineValues jusqu'au père + // de la rubrique int fatherIndex = this.lineCols11.lastIndexOf(this.allCols.indexOf(this.father)) + 1; + Format.removeToIndexInt(this.lineCols11, fatherIndex); Format.removeToIndexInt(this.lineCols, fatherIndex); Format.removeToIndexInt(this.lineIds, fatherIndex); Format.removeToIndex(this.lineValues, fatherIndex); + } this.treeStackFather.add(this.father); + this.treeStack.add(this.currentTag); this.father = this.currentTag; @@ -406,10 +424,24 @@ public void startElement(String uri, String localName, String qName, Attributes } + /** + * Wait for the parallel insert to be done and report a sax exception if an + * error occured + * + * @throws SAXParseException + */ + private void waitForParallelInsertAndReport() throws SAXParseException { + try { + pi.waitAndReport(); + } catch (ArcException e) { + throw new SAXParseException(e.getMessage(), "", "", idLigne, 0); + } + } + /** * Requete d'insertion des données parsées C'est assez diffcile : on souhaite * profiter au mieux de la commande insert multi value : INSERT into (cols) - * values (data1) values (data2) ... ; faut bien reperer ou on met les nouvelles + * values (data1), (data2) ... ; faut bien reperer ou on met les nouvelles * données et si c'est possible * * @@ -421,28 +453,30 @@ public void startElement(String uri, String localName, String qName, Attributes * @param lineValues * @throws SAXParseException */ - private void insertQueryBuilder(StringBuilder aRequete, String tempTableI, String fileName, List lineCols, - List lineIds, List lineValues) { + private void insertQueryBuilder(String tempTableI, String fileName, List lineCols, List lineIds, + List lineValues) { - HashMap keep = new HashMap<>(); + Map keep = new HashMap<>(); - String s; + // enregistre la liste des colonnes/valeurs relatives à un noeud de l'arbre xml + StringBuilder s = new StringBuilder(); for (int i = 0; i < lineCols.size(); i++) { - s = "{" + lineIds.get(i) + "}"; + s.setLength(0); + s.append("{").append(lineIds.get(i)).append("}"); if (lineValues.get(i) != null) { - s = s + "[" + lineValues.get(i) + "]"; + s.append("[").append(lineValues.get(i)).append("]"); } if (keep.get(this.tree.get(lineCols.get(i))) == null) { - keep.put(this.tree.get(lineCols.get(i)), s); + keep.put(this.tree.get(lineCols.get(i)), s.toString()); } else { - s = s + keep.get(this.tree.get(lineCols.get(i))); - keep.put(this.tree.get(lineCols.get(i)), s); + s.append(keep.get(this.tree.get(lineCols.get(i)))); + keep.put(this.tree.get(lineCols.get(i)), s.toString()); } } - HashMap doNotinsert = new HashMap<>(); + Map doNotinsert = new HashMap<>(); for (Map.Entry entry : this.keepLast.entrySet()) { if (entry.getValue().equals(keep.get(entry.getKey()))) { @@ -456,57 +490,76 @@ private void insertQueryBuilder(StringBuilder aRequete, String tempTableI, Strin StringBuilder req2 = new StringBuilder(); this.idLigne++; - req.append("insert into " + tempTableI + "(" - + tempTableAColumnsShortName - .get(tempTableAColumnsLongName.indexOf(ColumnEnum.ID_SOURCE.getColumnName())) - + "," + tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("id")) + "," - + tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("date_integration")) + "," - + tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("id_norme")) + "," - + tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("periodicite")) + "," - + tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("validite"))); + req.append("insert into ").append(tempTableI).append("(") + .append(tempTableAColumnsShortName + .get(tempTableAColumnsLongName.indexOf(ColumnEnum.ID_SOURCE.getColumnName()))) + .append(",").append(tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("id"))).append(",") + .append(tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("date_integration"))) + .append(",").append(tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("id_norme"))) + .append(",").append(tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("periodicite"))) + .append(",").append(tempTableAColumnsShortName.get(tempTableAColumnsLongName.indexOf("validite"))); - req2.append("('" + fileName + "'," + this.idLigne + "," + integrationDate + ",'" + normeCourante.getIdNorme() - + "','" + normeCourante.getPeriodicite() + "','" + validite + "'"); - - int z = 0; + req2.append("('").append(fileName).append("',").append(this.idLigne).append(",").append(integrationDate) + .append(",'").append(normeCourante.getIdNorme()).append("','").append(normeCourante.getPeriodicite()) + .append("','").append(validite).append("'"); for (int i = 0; i < lineCols.size(); i++) { // si le bloc est a reinséré (le pere n'est pas retrouvé dans doNotInsert // ou si la colonne est un noeud, on procède à l'insertion + if (doNotinsert.get(this.tree.get(lineCols.get(i))) == null || this.treeNode.get(lineCols.get(i)) != null) { - req.append(",i" + this.allCols.indexOf(this.allCols.get(lineCols.get(i)))); - req2.append("," + lineIds.get(i)); + req.append(",i").append(this.allCols.indexOf(this.allCols.get(lineCols.get(i)))); + req2.append(",").append(lineIds.get(i)); if (lineValues.get(i) != null) { - req.append(",v" + this.allCols.indexOf(this.allCols.get(lineCols.get(i)))); - req2.append(",'" + lineValues.get(i) + "'"); + req.append(",v").append(this.allCols.indexOf(this.allCols.get(lineCols.get(i)))); + req2.append(",'").append(lineValues.get(i)).append("'"); } } - } req.append(")values"); req2.append(")"); - // attention : on doit insérer au bon endroit - z = aRequete.indexOf(req.toString(), this.start); + String reqString = req.toString(); + addQuery(reqString, req2); + } + + private void addQuery(String key, String value) { + addQuery(key, new StringBuilder(value)); + } - if (z > -1) { - req2.append(","); - aRequete.insert(z + req.length(), req2); + private void addQuery(String key, StringBuilder value) { + if (requetes.get(key) != null) { + requetes.get(key).append(key.equals(ALTER) ? "" : ",").append(value); } else { - req2.append(";"); - aRequete.append(req); - aRequete.append(req2); + requetes.put(key, value); + } + requetesLength = requetesLength + value.length(); + } + + private String computeFinalQuery() { + + StringBuilder result = new StringBuilder(); + result.append((requetes.get(ALTER) != null) ? requetes.get(ALTER) : ""); + + for (String s : requetes.keySet()) { + if (!s.equals(ALTER)) { + result.append(s).append(requetes.get(s)).append(";"); + } } + + this.requetes = new HashMap<>(); + this.requetesLength = 0; + + return result.toString(); + } /** - * 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() { @@ -530,11 +583,13 @@ private void requeteJointureXML() { for (int i = 0; i < arr.length; i++) { + // pour chaque noeud + if (arr[i][2] == 1) { String leaf = TreeFunctions.getLeafs(arr[i][1], arr, this.colData, this.allCols); - // Version sans fonctions d'aggregation + // créer les vues String leafMax = TreeFunctions.getLeafsMax(arr[i][1], arr, this.colData, this.allCols); reqCreate.append("CREATE TEMPORARY TABLE t_" + this.allCols.get(arr[i][1]) + " as (select i_" + this.allCols.get(arr[i][1]) + " as m_" + this.allCols.get(arr[i][1]) + " "); @@ -589,13 +644,12 @@ 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); req.append(reqFrom); - this.jointure = this.jointure + req.toString().replace("'", "''"); + this.jointure = req.toString().replace("'", "''"); } @@ -605,31 +659,31 @@ private void requeteJointureXML() { * * @param aRequete */ - private void renameColumns() { + private void renameColumns(StringBuilder aRequete) { for (int i = 0; i < this.tempTableAColumnsShortName.size(); i++) { - this.requete.append("\n ALTER TABLE " + this.tempTableA + " RENAME " - + this.tempTableAColumnsShortName.get(i) + " TO " + this.tempTableAColumnsLongName.get(i) + ";"); + aRequete.append("\n ALTER TABLE " + this.tempTableA + " RENAME " + this.tempTableAColumnsShortName.get(i) + + " TO " + this.tempTableAColumnsLongName.get(i) + ";"); } for (int i = 0; i < this.allCols.size(); i++) { - this.requete.append( + aRequete.append( "\n ALTER TABLE " + this.tempTableA + " RENAME i" + i + " TO i_" + this.allCols.get(i) + ";"); if (colData.get(this.allCols.get(i)) != null) { - this.requete.append( + aRequete.append( "\n ALTER TABLE " + this.tempTableA + " RENAME v" + i + " TO v_" + this.allCols.get(i) + ";"); } } } - private void multiLeafUpdate() { + private void multiLeafUpdate(StringBuilder aRequete) { // gestion des rubriques multiple for (int i = 0; i < this.allCols.size(); i++) { if (this.allCols.get(i).endsWith(HEADER)) { String headerCol = this.allCols.get(i); String col = this.allCols.get(i).replace(HEADER, ""); - this.requete.append("\n UPDATE " + this.tempTableA + " SET i_" + headerCol + "=i_" + col + " WHERE i_" + aRequete.append("\n UPDATE " + this.tempTableA + " SET i_" + headerCol + "=i_" + col + " WHERE i_" + headerCol + " IS NULL and i_" + col + " IS NOT NULL;"); } } @@ -661,4 +715,9 @@ private String renameColumn(String qName) { return qName; } + public String getJointure() { + return jointure; + } + + } 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 ff5ac4312..e8dde2fba 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 @@ -62,11 +62,11 @@ public XMLHandlerCharger4(Connection connexion, String fileName, Norme normeCour // l'integer ne sert à rien -> refactor avec un set private Map colData = new HashMap<>(); - private HashMap tree = new HashMap<>(); - private HashMap treeNode = new HashMap<>(); + private Map tree = new HashMap<>(); + private Map treeNode = new HashMap<>(); - private HashMap colDist = new HashMap<>(); - private HashMap keepLast = new HashMap<>(); + private Map colDist = new HashMap<>(); + private Map keepLast = new HashMap<>(); private int idLigne = 0; private int distance = 0; @@ -182,6 +182,7 @@ public void endElement(String uri, String localName, String qName) throws SAXPar // vérifier qu'une feuille n'existe pas déjà if (this.lineCols.indexOf(this.allCols.indexOf(this.closedTag)) < this.lineCols.size() - 1) { + // réalisation de l'insertion insertQueryBuilder(this.tempTableA, this.fileName, this.lineCols.subList(0, this.lineCols.size() - 1), this.lineIds.subList(0, this.lineCols.size() - 1), this.lineValues.subList(0, this.lineCols.size() - 1)); @@ -228,7 +229,6 @@ public void startDocument() { try { this.colDist.put(-1, 0); - } catch (Exception ex) { LoggerHelper.errorGenTextAsComment(getClass(), "instartDocumentdex()", LOGGER, ex); } @@ -257,7 +257,6 @@ public void startElement(String uri, String localName, String qName, Attributes this.allCols.add(this.currentTag); addQuery(ALTER, "alter table " + this.tempTableA + " add i" + this.allCols.indexOf(this.currentTag) + " " + TypeEnum.INTEGER.getTypeName() + ";"); - } else { // ajouter 1 a son index si la colonne existe dejà this.col.put(this.currentTag, o + 1); @@ -354,7 +353,7 @@ private void waitForParallelInsertAndReport() throws SAXParseException { private void insertQueryBuilder(String tempTableI, String fileName, List lineCols, List lineIds, List lineValues) { - HashMap keep = new HashMap<>(); + Map keep = new HashMap<>(); // enregistre la liste des colonnes/valeurs relatives à un noeud de l'arbre xml StringBuilder s = new StringBuilder(); @@ -374,12 +373,11 @@ private void insertQueryBuilder(String tempTableI, String fileName, List doNotinsert = new HashMap<>(); + Map doNotinsert = new HashMap<>(); for (Map.Entry entry : this.keepLast.entrySet()) { if (entry.getValue().equals(keep.get(entry.getKey()))) { doNotinsert.put(entry.getKey(), true); - } } @@ -466,7 +464,6 @@ private void requeteJointureXML() { StringBuilder req = new StringBuilder(); int[][] arr = TreeFunctions.getTreeArrayByDistance(this.tree, this.colDist); - StringBuilder reqCreate = new StringBuilder(" \n"); StringBuilder reqInsert = new StringBuilder(); 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 7cf20b2c6..9a00b8f45 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 @@ -9,6 +9,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -112,7 +113,7 @@ private void simpleExecutionWithNoJoinDefined() throws ArcException { List listeRubriqueSource = new ArrayList<>(); UtilitaireDao.get(0).getColumns(connection, listeRubriqueSource, tableSource); - HashSet alreadyAdded = new HashSet<>(); + Set alreadyAdded = new HashSet<>(); for (String variable : listeRubriqueSource) { // pour toutes les variables du fichier commencant par i ou v et qui n'ont pas @@ -175,7 +176,7 @@ private void complexExecutionWithJoinDefined(String jointure) throws ArcExceptio Map> regle = new HashMap<>(); for (String key : regleInitiale.keySet()) { - ArrayList al = new ArrayList<>(); + List al = new ArrayList<>(); for (String val : regleInitiale.get(key)) { al.add(val); } diff --git a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineGlobal.java b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineGlobal.java index 60e1eb269..c71ac4940 100644 --- a/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineGlobal.java +++ b/arc-core/src/main/java/fr/insee/arc/core/service/p3normage/engine/NormageEngineGlobal.java @@ -1,6 +1,7 @@ package fr.insee.arc.core.service.p3normage.engine; import java.util.ArrayList; +import java.util.List; import fr.insee.arc.utils.utils.ManipString; @@ -16,8 +17,8 @@ public class NormageEngineGlobal { * @param mRubrique */ - private static void getChildrenTree(ArrayList r, String blocCreate, String mRubrique) { - ArrayList s = getChildren(blocCreate, mRubrique); + private static void getChildrenTree(List r, String blocCreate, String mRubrique) { + List s = getChildren(blocCreate, mRubrique); if (s.isEmpty()) { return; @@ -39,8 +40,8 @@ private static void getChildrenTree(ArrayList r, String blocCreate, Stri * @param mRubrique * @return */ - protected static ArrayList getChildren(String blocCreate, String mRubrique) { - ArrayList r = new ArrayList<>(); + protected static List getChildren(String blocCreate, String mRubrique) { + List r = new ArrayList<>(); if (mRubrique == null) { return r; @@ -225,8 +226,8 @@ protected static boolean testRubriqueInCreate(String bloc, String rubrique) { */ protected static String pppc(String blocCreate, String rubriqueM, String rubriqueNmclM) { - ArrayList rubriqueParents = getParentsTree(blocCreate, rubriqueM, true); - ArrayList rubriqueNmclParents = getParentsTree(blocCreate, rubriqueNmclM, true); + List rubriqueParents = getParentsTree(blocCreate, rubriqueM, true); + List rubriqueNmclParents = getParentsTree(blocCreate, rubriqueNmclM, true); for (int k = 0; k < rubriqueNmclParents.size(); k++) { for (int l = 0; l < rubriqueParents.size(); l++) { @@ -284,8 +285,8 @@ protected static String getFatherM(String bloc, String rubrique) { * @param mRubrique * @return */ - protected static ArrayList getParentsTree(String blocCreate, String mRubrique, boolean... keep) { - ArrayList r = new ArrayList<>(); + protected static List getParentsTree(String blocCreate, String mRubrique, boolean... keep) { + List r = new ArrayList<>(); r.add(mRubrique); String s; @@ -309,8 +310,8 @@ protected static ArrayList getParentsTree(String blocCreate, String mRub * @param mRubrique * @return */ - protected static ArrayList getChildrenTree(String blocCreate, String mRubrique) { - ArrayList s = new ArrayList<>(); + protected static List getChildrenTree(String blocCreate, String mRubrique) { + List s = new ArrayList<>(); getChildrenTree(s, blocCreate, mRubrique); return s; } 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 ba9c19dd4..bbbc10288 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 @@ -1,10 +1,10 @@ package fr.insee.arc.core.service.p3normage.engine; -import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -119,12 +119,12 @@ protected static String appliquerRegleDuplication(Map> regl // si on trouve une rubrique mère if (rubriqueM != null) { - ArrayList aTraiter = NormageEngineGlobal.getChildrenTree(blocCreate, rubriqueM); + List aTraiter = NormageEngineGlobal.getChildrenTree(blocCreate, rubriqueM); aTraiter.add(0, rubriqueM); StringBuilder blocCreateNew = new StringBuilder(); StringBuilder blocInsertNew = new StringBuilder(); - HashSet colonnesAAjouter = new HashSet<>(); + Set colonnesAAjouter = new HashSet<>(); String[] lines = blocCreate.split("\n"); for (int i = 0; i < lines.length; i++) { 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 1ba0d4a22..accc9e99d 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 @@ -6,6 +6,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -37,7 +38,7 @@ protected static void ajouterRegleIndependance(Map> regle, StaticLoggerDispatcher.info(LOGGER, "ajouterRegleIndependance()"); String blocCreate = ManipString.substringBeforeFirst(jointure, "insert into {table_destination}"); - HashSet rubriqueExclusion = new HashSet(); + Set rubriqueExclusion = new HashSet<>(); Map rubriquesAvecRegleDIndependance = new HashMap<>(); // pour toutes les règles de relation, @@ -56,8 +57,8 @@ protected static void ajouterRegleIndependance(Map> regle, String rubriqueNmclM = NormageEngineGlobal.getM(blocCreate, rubriqueNmcl); if (rubriqueM != null && rubriqueNmclM != null) { - ArrayList parentM = NormageEngineGlobal.getParentsTree(blocCreate, rubriqueM, true); - ArrayList parentNmclM = NormageEngineGlobal.getParentsTree(blocCreate, rubriqueNmclM, true); + List parentM = NormageEngineGlobal.getParentsTree(blocCreate, rubriqueM, true); + List parentNmclM = NormageEngineGlobal.getParentsTree(blocCreate, rubriqueNmclM, true); // on exclus tout les blocs présent dans les listes jusqu'a ce qu'on trouve // l'élément en commun @@ -97,7 +98,7 @@ protected static void ajouterRegleIndependance(Map> regle, } // ARC compute which rubriques are independant and set the independance rules - ArrayList r = new ArrayList<>(); + List r = new ArrayList<>(); addIndependanceToChildren(r, blocCreate, NormageEngineGlobal.getM(blocCreate), regle, rubriquesAvecRegleDIndependance, norme, periodicite, rubriqueExclusion); @@ -134,7 +135,7 @@ protected static String appliquerRegleIndependance(Map> reg String[] rubriqueNmclRegle = regle.get("rubrique_nmcl").get(j).replace(" ", "").toLowerCase() .split(","); - ArrayList rubrique = new ArrayList<>(); + List rubrique = new ArrayList<>(); Map rubriqueNmcl = new HashMap<>(); // ne garder que les rubriques qui existent dans la requete @@ -269,7 +270,7 @@ protected static String appliquerRegleIndependance(Map> reg * @return */ private static boolean calculerTableIndependance(StringBuilder blocRequete, boolean nullTableRequired, - ArrayList rubrique, Map rubriqueNmcl, Map table, + List rubrique, Map rubriqueNmcl, Map table, Map pere, Map autreCol) { boolean isThereAnyValue = false; @@ -401,10 +402,10 @@ private static boolean calculerTableIndependance(StringBuilder blocRequete, bool * @param periodicite * @param exclusion */ - private static void addIndependanceToChildren(ArrayList r, String blocCreate, String mRubrique, + private static void addIndependanceToChildren(List r, String blocCreate, String mRubrique, Map> regle, Map rubriquesAvecRegleDIndependance, - String norme, String periodicite, HashSet exclusion) { - ArrayList s = NormageEngineGlobal.getChildren(blocCreate, mRubrique); + String norme, String periodicite, Set exclusion) { + List s = NormageEngineGlobal.getChildren(blocCreate, mRubrique); if (!s.isEmpty()) { r.addAll(s); 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 d92b67d2c..503ddd6f3 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 @@ -43,9 +43,9 @@ protected static String appliquerRegleRelation(Map> regle, int max = lines.length - 1; // on parcourt maintenant les regles de relation - ArrayList listRubrique = new ArrayList(); - ArrayList listRubriqueNmcl = new ArrayList(); - ArrayList listTableNmcl = new ArrayList(); + List listRubrique = new ArrayList<>(); + List listRubriqueNmcl = new ArrayList<>(); + List listTableNmcl = new ArrayList<>(); for (int j = 0; j < regle.get("id_regle").size(); j++) { String type = regle.get("id_classe").get(j); 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 dfcc5bebc..352e05e9e 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 @@ -39,8 +39,8 @@ protected static void ajouterRegleSuppression(Map> regle, S // op 1 : identifier les blocs inutiles - ArrayList listVarUtilisee = new ArrayList<>(); - ArrayList lineASupprimer = new ArrayList<>(); + List listVarUtilisee = new ArrayList<>(); + List lineASupprimer = new ArrayList<>(); for (int j = 0; j < rubriqueUtiliseeDansRegles.get("id_norme").size(); j++) { listVarUtilisee.add(rubriqueUtiliseeDansRegles.get("var").get(j)); @@ -220,9 +220,9 @@ protected static String appliquerRegleSuppression(Map> regl private static String appliquerRegleSuppressionCore(String returned, String rubrique) { String[] lines = returned.split("\n"); - ArrayList grpAEnlever = new ArrayList<>(); - ArrayList ligneAEnlever = new ArrayList<>(); - ArrayList rubriqueAEnlever = new ArrayList(); + List grpAEnlever = new ArrayList<>(); + List ligneAEnlever = new ArrayList<>(); + List rubriqueAEnlever = new ArrayList(); // identifier les groupes a enlever de la requete identifierGroupeAEnlever(lines, rubrique, grpAEnlever, ligneAEnlever); @@ -234,8 +234,8 @@ private static String appliquerRegleSuppressionCore(String returned, String rubr return calculerRequeteSupression(lines, ligneAEnlever, rubriqueAEnlever); } - private static String calculerRequeteSupression(String[] lines, ArrayList ligneAEnlever, - ArrayList rubriqueAEnlever) { + private static String calculerRequeteSupression(String[] lines, List ligneAEnlever, + List rubriqueAEnlever) { StringBuilder f = new StringBuilder(); int max = lines.length - 1; @@ -265,8 +265,8 @@ private static String calculerRequeteSupression(String[] lines, ArrayList grpAEnlever, - ArrayList ligneAEnlever, ArrayList rubriqueAEnlever) { + private static void identifierRubriqueAEnlever(String[] lines, String rubrique, List grpAEnlever, + List ligneAEnlever, List rubriqueAEnlever) { int max = lines.length - 1; int k = 1; @@ -328,8 +328,8 @@ private static void identifierRubriqueAEnlever(String[] lines, String rubrique, * @param grpAEnlever * @param ligneAEnlever */ - private static void identifierGroupeAEnlever(String[] lines, String rubrique, ArrayList grpAEnlever, - ArrayList ligneAEnlever) { + private static void identifierGroupeAEnlever(String[] lines, String rubrique, List grpAEnlever, + List ligneAEnlever) { int max = lines.length - 1; // on va iterer sur les lignes pour identifier les groupes à enlever 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 cb06efca9..f0c19fcf3 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 @@ -34,17 +34,10 @@ public class ServiceJeuDeRegle { * Liste des rubriques de la table de données DSN */ private List listRubTable = new ArrayList<>(); - private String tableControleRegle; public ServiceJeuDeRegle(){ this.servSql = new ServiceRequeteSqlRegle(); } - - public ServiceJeuDeRegle(String tableControleRegle){ - this.servSql = new ServiceRequeteSqlRegle(); - this.tableControleRegle=tableControleRegle; - } - /** * pour remplir un jeu de règle avec les règles y afférant @@ -59,7 +52,7 @@ public ServiceJeuDeRegle(String tableControleRegle){ */ public void fillRegleControle(Connection connexion, JeuDeRegle jdr, String tableRegle, String tableIn) throws ArcException { StaticLoggerDispatcher.info(LOGGER,"recherche de regle dans la table : " + tableRegle); - ArrayList listRegleC = RegleDao.getRegle(connexion, tableRegle, tableIn); + List listRegleC = RegleDao.getRegle(connexion, tableRegle, tableIn); jdr.setListRegleControle(listRegleC); } @@ -118,7 +111,7 @@ private void preAction(Connection connexion, JeuDeRegle jdr, String table) throw // exécuter les préactions StaticLoggerDispatcher.info(LOGGER, "Debut Pré-actions"); - ArrayList p=new ArrayList<>(); + List p=new ArrayList<>(); // récupérer les préactions du jeu de regle /** @@ -199,7 +192,7 @@ private void control(Connection connexion, JeuDeRegle jdr, String table) throws // rules to set tree root and father label are ignored && !(reg.getRubriquePere().equalsIgnoreCase(XMLConstant.ROOT))) { - blocRequete.append(executeRegleCardinalite(jdr, reg)); + blocRequete.append(executeRegleCardinalite(reg)); blocRequete.append(System.lineSeparator()); } else @@ -275,7 +268,7 @@ private String executeRegleCondition(JeuDeRegle jdr, RegleControleEntity reg) { StaticLoggerDispatcher.info(LOGGER,"Je lance executeRegleCondition()"); String requete = ""; - ArrayList listRubrique = ManipString.extractRubriques(reg.getCondition()); + List listRubrique = ManipString.extractRubriques(reg.getCondition()); listRubrique.replaceAll(String::toUpperCase); if (this.listRubTable.containsAll(listRubrique)) { @@ -303,11 +296,11 @@ private String executeRegleCondition(JeuDeRegle jdr, RegleControleEntity reg) { * @param table * @throws ArcException */ - private String executeRegleCardinalite(JeuDeRegle jdr, RegleControleEntity reg) { + private String executeRegleCardinalite(RegleControleEntity reg) { StaticLoggerDispatcher.info(LOGGER,"Je lance executeRegleCardinalite()"); String requete = ""; - ArrayList listRubrique = ManipString.extractRubriques(reg.getCondition()); + List listRubrique = ManipString.extractRubriques(reg.getCondition()); listRubrique.replaceAll(String::toUpperCase); requete = this.servSql.ctlCardinalite(reg, listRubrique, listRubTable); 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 b1d28cc78..177abcb40 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 @@ -65,7 +65,7 @@ public void configThread(ScalableConnection connexion, int currentIndice, ApiCon this.tabIdSource=theApi.getTabIdSource(); this.paramBatch=theApi.getParamBatch(); - this.sjdr = new ServiceJeuDeRegle(ViewEnum.CONTROLE_REGLE.getFullName(envExecution)); + this.sjdr = new ServiceJeuDeRegle(); this.jdr = new JeuDeRegle(); // Nom des tables temporaires 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 eb0bf1278..5213aa4da 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 @@ -72,7 +72,7 @@ public class RequeteMapping implements IConstanteCaractere, IConstanteNumerique private Set ensembleVariableMapping; private SortedSet ensembleGroupes; - private HashMap> ensembleRubriqueIdentifianteTable; + private Map> ensembleRubriqueIdentifianteTable; /* * LA REQUÊTE TEXTUELLE */ @@ -165,7 +165,7 @@ private void attribuerExpressionRegleMapping(Map mapVar for (int i = 0; i < resultTemp.size(); i++) { // mise en minuscule des rubriques - ArrayList temp = new ArrayList<>(); + List temp = new ArrayList<>(); temp.add(resultTemp.get(i).get(0).toLowerCase()); String exprCol = resultTemp.get(i).get(1); @@ -250,7 +250,7 @@ private void construireListeRubriqueParTable() { for (TableMapping table : this.ensembleTableMapping) { - HashSet s = new HashSet<>(); + Set s = new HashSet<>(); for (VariableMapping var : this.ensembleVariableMapping) { @@ -346,7 +346,7 @@ public String getRequete(String aNomFichier) throws ArcException { construireListeIdentifiants(reglesIdentifiantes, nomsVariablesGroupe, linkedIds); construireTableIdentifiantsFichierCourant(requeteGlobale, reglesIdentifiantes, nomsVariablesGroupe, linkedIds); - HashMap> tablesFilles = ordonnerTraitementTable(); + Map> tablesFilles = ordonnerTraitementTable(); for (TableMapping table : this.ensembleTableMapping) { this.nomTableTemporairePrepUnion = "prep_union"; @@ -421,8 +421,8 @@ private StringBuilder insererTablePrepUnion(StringBuilder returned, TableMapping return returned; } - private int computeTableNumber(HashMap order, - HashMap> tableTree, TableMapping table) { + private int computeTableNumber(Map order, + Map> tableTree, TableMapping table) { if (order.get(table) != null) { return order.get(table); @@ -464,7 +464,7 @@ private int computeTableNumber(HashMap order, * @param tableAncestor * @param tableChild */ - private void addTableInTreeHierarchy(HashMap> tableTree, + private void addTableInTreeHierarchy(Map> tableTree, TableMapping tableAncestor, TableMapping tableChild) { // create the tree entry if it doesn't exist if (tableTree.get(tableAncestor) == null) { @@ -482,15 +482,15 @@ private void addTableInTreeHierarchy(HashMap> ordonnerTraitementTable() { + public Map> ordonnerTraitementTable() { // Correctif modèle métier à une seule table if (this.ensembleTableMapping.size() == 1) { return new HashMap<>(); } // initialisation - HashMap order = new HashMap<>(); - HashMap> tableTree = new HashMap<>(); + Map order = new HashMap<>(); + Map> tableTree = new HashMap<>(); // compute the index of every table for (TableMapping table : this.ensembleTableMapping) { @@ -517,7 +517,7 @@ public HashMap> ordonnerTraitementTable() * @param order : the order index computed for table * @return */ - private Set buildTheOrderedTablesListForProcess(HashMap order) { + private Set buildTheOrderedTablesListForProcess(Map order) { // get the maximum index of ordered tables int k = 0; @@ -709,7 +709,7 @@ private StringBuilder construireTableIdentifiantsFichierCourant(StringBuilder re Map reglesIdentifiantes, Map nomsVariablesGroupe, Map linkedIds) { this.nomTableFichierCourant = "fichier"; - HashSet alreadyAdded = new HashSet<>(); + Set alreadyAdded = new HashSet<>(); returned.append("\n DROP TABLE IF EXISTS " + nomTableFichierCourant + " CASCADE;"); returned.append( @@ -846,7 +846,7 @@ private static StringBuilder listeVariablesTypesPrepUnion(StringBuilder returned } private StringBuilder calculerRequeteArrayAggGroup(StringBuilder returned, TableMapping table, - HashMap> tablesFilles) { + Map> tablesFilles) { StringBuilder select = new StringBuilder(); StringBuilder groupBy = new StringBuilder(); diff --git a/arc-core/src/test/java/fr/insee/arc/core/service/engine/mapping/RequeteMappingTest.java b/arc-core/src/test/java/fr/insee/arc/core/service/engine/mapping/RequeteMappingTest.java index 9ba884282..75979532b 100644 --- a/arc-core/src/test/java/fr/insee/arc/core/service/engine/mapping/RequeteMappingTest.java +++ b/arc-core/src/test/java/fr/insee/arc/core/service/engine/mapping/RequeteMappingTest.java @@ -4,9 +4,9 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.Set; import org.junit.Before; @@ -37,7 +37,7 @@ public void mappingOrderOneTable() { tables.add(new TableMapping("", "table1")); mappingRequest.setEnsembleTableMapping(tables); - HashMap> result = mappingRequest.ordonnerTraitementTable(); + Map> result = mappingRequest.ordonnerTraitementTable(); assertTrue(result.isEmpty()); } @@ -65,7 +65,7 @@ public void mappingOrderParentAndChild() { mappingRequest.setEnsembleTableMapping(tables); - HashMap> result = mappingRequest.ordonnerTraitementTable(); + Map> result = mappingRequest.ordonnerTraitementTable(); assertEquals(1, result.size()); assertEquals(1, result.get(parent).size()); 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 4676017f4..5ac55ca29 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 @@ -831,8 +831,8 @@ public void fastUpdate(Connection aConnexion, String tableName, String keys, // récupérer la liste des colonnes // liste de toutes les colonnes // liste des colonnes à mettre à jour - ArrayList colSetList = new ArrayList<>(); - ArrayList setList = new ArrayList<>(); + List colSetList = new ArrayList<>(); + List setList = new ArrayList<>(); for (int i = 0; i < set.length; i++) { // extraire la colonne à mettre à jour; la garder ssi elle existe // dans le modèle de la table à mettre à @@ -844,7 +844,7 @@ public void fastUpdate(Connection aConnexion, String tableName, String keys, } } // liste des colonnes de la jointure (clé primaire de la table initiale) - ArrayList colKeyList = new ArrayList<>(); + List colKeyList = new ArrayList<>(); for (int i = 0; i < keys.split(",").length; i++) { colKeyList.add(keys.split(",")[i].trim().toUpperCase()); } diff --git a/arc-utils/src/main/java/fr/insee/arc/utils/utils/ManipString.java b/arc-utils/src/main/java/fr/insee/arc/utils/utils/ManipString.java index 70e47c369..e925f962d 100644 --- a/arc-utils/src/main/java/fr/insee/arc/utils/utils/ManipString.java +++ b/arc-utils/src/main/java/fr/insee/arc/utils/utils/ManipString.java @@ -141,10 +141,10 @@ public static String extractFirst(String regex, String value){ * , la chaine de caractère à lire * @return une liste de rubrique */ - public static ArrayList extractRubriques(final String cond) { + public static List extractRubriques(final String cond) { - ArrayList listRubrique = new ArrayList<>(); + List listRubrique = new ArrayList<>(); boolean isTrue = true; if (StringUtils.isBlank(cond)){ return listRubrique; 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 c5ed4c658..df460fcb6 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 @@ -113,7 +113,7 @@ public List> listContent() { } List> c = new ArrayList<>(); for (int i = 0; i < getSavedContent().size(); i++) { - ArrayList l = new ArrayList<>(); + List l = new ArrayList<>(); for (int j = 0; j < getSavedContent().get(i).d.size(); j++) { l.add(getSavedContent().get(i).d.get(j)); } @@ -238,7 +238,7 @@ public List> listOnlyUpdatedContent() { } List> r = new ArrayList<>(); for (int i = 0; i < getContent().size(); i++) { - ArrayList line = new ArrayList<>(); + List line = new ArrayList<>(); boolean changed = false; for (int j = 0; j < getContent().get(i).d.size(); j++) { String oldContentValue = getSavedContent().get(i).d.get(j); @@ -308,7 +308,7 @@ public List listHeadersSelected() { if (getSavedContent() == null) { return new ArrayList<>(); } - ArrayList r = new ArrayList<>(); + List r = new ArrayList<>(); if (getSelectedColumns() == null || getSelectedColumns().isEmpty()) { return r; } @@ -502,8 +502,8 @@ VObject copy() { return v0; } - public ArrayList getV(int j, TableObject content) { - ArrayList h = new ArrayList<>(); + public List getV(int j, TableObject content) { + List h = new ArrayList<>(); if (content == null) { return h; } 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 c6ec7a096..de2c607de 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 @@ -691,7 +691,7 @@ public void update(VObject currentData) { VObject v0 = fetchVObjectData(currentData.getSessionName()); // Compares new and old values line by line // Stocks the modified line number in toBeUpdated - ArrayList toBeUpdated = new ArrayList<>(); + List toBeUpdated = new ArrayList<>(); for (int i = 0; i < currentData.getContent().size(); i++) { LineObject line = currentData.getContent().get(i); if (line != null) { diff --git a/arc-web/src/main/java/fr/insee/arc/web/gui/export/model/ViewFileExport.java b/arc-web/src/main/java/fr/insee/arc/web/gui/export/model/ViewFileExport.java index 7ce72fbcb..c2396f6cc 100644 --- a/arc-web/src/main/java/fr/insee/arc/web/gui/export/model/ViewFileExport.java +++ b/arc-web/src/main/java/fr/insee/arc/web/gui/export/model/ViewFileExport.java @@ -24,8 +24,8 @@ public ViewFileExport() { private static final long serialVersionUID = -3124381932840827423L; { - put("filename", new ColumnRendering(true, "Nom du fichier", "100%", "text", null, true)); - put("isdirectory", new ColumnRendering(false, "Répertoire", "47%", "text", null, false)); + put("filename", new ColumnRendering(true, "Nom du fichier", "90%", "text", null, true)); + put("isdirectory", new ColumnRendering(true, "Répertoire", "10%", "text", null, false)); } })); } 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 b117242e1..6d18f5183 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 @@ -83,12 +83,12 @@ private List> getFilesFromDirectory(String dir, Map> filter=filter2; List> result=new ArrayList<>(); - ArrayList entete = new ArrayList<>(); + List entete = new ArrayList<>(); entete.add("filename"); entete.add("isdirectory"); result.add(entete); - ArrayList format = new ArrayList<>(); + List format = new ArrayList<>(); format.add("text"); format.add("text"); result.add(format); @@ -160,20 +160,12 @@ private List> getFilesFromDirectory(String dir, Map fileAttribute = new ArrayList(); + List fileAttribute = new ArrayList<>(); fileAttribute.add(f.getName()); fileAttribute.add(""+f.isDirectory()); result.add(fileAttribute); - nb++; - if (nb>50) - { - break; - } } } - - - return result; } 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 83570e13a..4cb234418 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 @@ -83,7 +83,7 @@ public String downloadFileExport(Model model, HttpServletResponse response) { String envDir = getBacASable().replace(".", "_").toUpperCase(); String dirOut = repertoire + envDir; - ArrayList r = new ArrayList<>(Arrays.asList("EXPORT")); + List r = new ArrayList<>(Arrays.asList("EXPORT")); this.vObjectService.downloadEnveloppe(views.getViewFileExport(), response, requete, dirOut, r); 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 b52e80292..17da0aced 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 @@ -93,11 +93,11 @@ public String downloadFamilleNorme(Model model, HttpServletResponse response) { requeteVariableMetier.append("WHERE " + ColumnEnum.ID_FAMILLE.getColumnName() + "="); requeteVariableMetier.appendQuoteText(selectedFamille); - ArrayList queries = new ArrayList<>(); + List queries = new ArrayList<>(); queries.add(requeteTableMetier); queries.add(requeteVariableMetier); - ArrayList fileNames = new ArrayList<>(); + List fileNames = new ArrayList<>(); fileNames.add("modelTables"); fileNames.add("modelVariables"); 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 64ae4fe9b..cefedfeb4 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 @@ -24,6 +24,7 @@ import fr.insee.arc.core.dataobjects.ArcPreparedStatementBuilder; import fr.insee.arc.utils.exception.ArcException; +import fr.insee.arc.utils.exception.ArcExceptionMessage; import fr.insee.arc.utils.files.FileUtilsArc; import fr.insee.arc.web.gui.all.service.ArcWebGenericService; import fr.insee.arc.web.gui.all.util.VObject; @@ -254,7 +255,7 @@ protected void download(HttpServletResponse response, VObject viewSource, String requete.append("SELECT " + requete.quoteText(s) + " as nom_fichier "); } - ArrayList r = new ArrayList<>(Arrays.asList("/")); + List r = new ArrayList<>(Arrays.asList("/")); this.vObjectService.downloadEnveloppe(viewSource, response, requete, dirSource, r); } @@ -269,7 +270,7 @@ protected void copy(VObject viewSource, String dirSource, String dirTarget) { try { Files.copy(fileSource.toPath(), fileTarget.toPath()); } catch (IOException e) { - loggerDispatcher.error("fileManagement.copy.error" + fileSource, e, LOGGER); + new ArcException(e, ArcExceptionMessage.FILE_COPY_FAILED).logFullException(); viewSource.setMessage("fileManagement.copy.error"); viewSource.setMessageArgs(fileSource); } 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 00f4ca428..b7041669d 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 @@ -124,7 +124,7 @@ public String downloadJeuxDeRegles(Model model, HttpServletResponse response) { requeteRegleExpression.append(recupRegle(this.views.getViewJeuxDeRegles(), dataObjectService.getView(ViewEnum.IHM_EXPRESSION))); - ArrayList fileNames = new ArrayList<>(); + List fileNames = new ArrayList<>(); fileNames.add("Rules_load"); fileNames.add("Rules_structurize"); fileNames.add("Rules_control"); 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 3996dc998..c898ee54f 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 @@ -219,7 +219,7 @@ public void execQueryDownloadArchive(HttpServletResponse response, VObject viewA querySelection.append(" AND nom_archive IN " + Format.sqlListe(selection) + " "); } - ArrayList listRepertoire = new ArrayList<>(); + List listRepertoire = new ArrayList<>(); ArcPreparedStatementBuilder requete = new ArcPreparedStatementBuilder(); requete.append("SELECT DISTINCT entrepot FROM ("); @@ -265,7 +265,7 @@ public void execQueryUpdateToDelete(ArcPreparedStatementBuilder updateToDelete) } public void downloadBdBAS(VObject viewFichierBAS, HttpServletResponse response, - ArrayList tableDownload, String phase, String etatBdd, String date) throws ArcException { + List tableDownload, String phase, String etatBdd, String date) throws ArcException { // List of queries that will be executed to download List tableauRequete = new ArrayList<>(); @@ -346,7 +346,7 @@ public void downloadBdBAS(VObject viewFichierBAS, HttpServletResponse response, } public void downloadEnvelopeBAS(VObject viewFichierBAS, HttpServletResponse response, - String chemin, ArrayList listRepertoire) { + String chemin, List listRepertoire) { // récupération de la liste des noms d'enloppe Map> selection = viewFichierBAS.mapContentSelected(); ArcPreparedStatementBuilder query = new ArcPreparedStatementBuilder(); 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 273efb938..0bdb6acb2 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 @@ -106,7 +106,7 @@ public void downloadBdBAS(HttpServletResponse response) throws ArcException { // Sélection des table métiers en fonction de la phase sélectionner (5 pour // mapping 1 sinon) - ArrayList tableDownload = new ArrayList<>(); + List tableDownload = new ArrayList<>(); try { List dataTables = PhaseOperations.selectPhaseDataTablesFoundInEnv(null, getBacASable()); @@ -139,7 +139,7 @@ public String downloadEnveloppeBAS(HttpServletResponse response) { initializeFichierBAS(views.getViewFichierBAS(), views.getViewPilotageBAS(), views.getViewRapportBAS()); - ArrayList listRepertoire = new ArrayList<>(); + List listRepertoire = new ArrayList<>(); listRepertoire.add(TraitementPhase.RECEPTION + "_" + TraitementEtat.OK); listRepertoire.add(TraitementPhase.RECEPTION + "_" + TraitementEtat.KO); String chemin = Paths.get(this.repertoire, getBacASable().toUpperCase()).toString(); 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 2df47e16a..40c2d5998 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 @@ -20,11 +20,11 @@ public class VObjectTest { @Before public void before() { this.defaultTestVobject = new VObject(); - ArrayList headersDLabel = new ArrayList<>(); + List headersDLabel = new ArrayList<>(); headersDLabel.add("first_field"); headersDLabel.add("second_field"); this.defaultTestVobject.setHeadersDLabel(headersDLabel); - ArrayList headersDType = new ArrayList<>(); + List headersDType = new ArrayList<>(); headersDType.add("text"); headersDType.add("date"); this.defaultTestVobject.setHeadersDType(headersDType); @@ -117,7 +117,7 @@ public void listContentUpdatedOk() { @Test public void listContentSelectedOk() { - ArrayList selectedLines = new ArrayList<>(); + List selectedLines = new ArrayList<>(); selectedLines.add(null); selectedLines.add(true); this.defaultTestVobject.setSelectedLines(selectedLines); @@ -127,7 +127,7 @@ public void listContentSelectedOk() { @Test public void listHeadersSelectedOk() { - ArrayList selectedColumns = new ArrayList<>(); + List selectedColumns = new ArrayList<>(); selectedColumns.add(null); selectedColumns.add(true); this.defaultTestVobject.setSelectedColumns(selectedColumns); 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 d17f7652b..f834df291 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 @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RestController; import fr.insee.arc.core.dataobjects.ColumnEnum; +import fr.insee.arc.core.dataobjects.ViewEnum; import fr.insee.arc.core.model.TraitementPhase; import fr.insee.arc.core.service.global.bo.JeuDeRegle; import fr.insee.arc.core.service.global.bo.JeuDeRegleDao; @@ -116,12 +117,12 @@ public ResponseEntity executeEngineClient( "CREATE TEMPORARY TABLE "+currentTemporaryTable(i)+" as select *, '0'::text collate \"C\" as controle, null::text[] collate \"C\" as brokenrules from "+previousTemporaryTable(i)+";"); UtilitaireDao.get(0).executeImmediate(connection, requete); - ServiceJeuDeRegle sjdr = new ServiceJeuDeRegle(env + ".controle_regle"); + ServiceJeuDeRegle sjdr = new ServiceJeuDeRegle(); // Récupération des règles de controles associées aux jeux de règle JeuDeRegle jdr = new JeuDeRegle(); - sjdr.fillRegleControle(connection, jdr, env + ".controle_regle", currentTemporaryTable(i)); + sjdr.fillRegleControle(connection, jdr, ViewEnum.CONTROLE_REGLE.getFullName(env), currentTemporaryTable(i)); sjdr.executeJeuDeRegle(connection, jdr, currentTemporaryTable(i)); break; case MAPPING: