Skip to content

Commit

Permalink
remove unused import. Fix deprecated loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolife999 committed Jan 27, 2020
1 parent 2127c59 commit 3d33d5d
Show file tree
Hide file tree
Showing 55 changed files with 141 additions and 422 deletions.
3 changes: 0 additions & 3 deletions arc-batch/src/main/java/fr/insee/arc/batch/ARCLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
import fr.insee.arc.core.model.TraitementState;
import fr.insee.arc.core.model.TypeTraitementPhase;
import fr.insee.arc.core.service.AbstractPhaseService;
import fr.insee.arc.core.service.ApiInitialisationService;
import fr.insee.arc.utils.batch.IReturnCode;
import fr.insee.arc.utils.dao.UtilitaireDao;
import fr.insee.arc.utils.ressourceUtils.PropertiesHandler;
import fr.insee.arc.utils.structure.GenericBean;
import fr.insee.arc.utils.utils.LoggerDispatcher;
import fr.insee.arc.utils.utils.LoggerHelper;
import fr.insee.arc.utils.utils.ManipString;

/**
Expand Down Expand Up @@ -309,7 +307,6 @@ public static void main(String[] args) {

DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd:HH");
DateFormat dateFormat2 = new SimpleDateFormat("yyyyMMddHH");
DateFormat dateFormatHour = new SimpleDateFormat("HH");

String lastInitialize = null;
lastInitialize = UtilitaireDao.get("arc").getString(null,
Expand Down
10 changes: 6 additions & 4 deletions arc-core/src/main/java/fr/insee/arc/core/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

public class Main {

public static void main(String[] args) {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("applicationContext.xml");
@SuppressWarnings("resource")
public static void main(String[] args) {

GenericXmlApplicationContext ctx = new GenericXmlApplicationContext("applicationContext.xml");

@SuppressWarnings("unused")
PropertiesHandler propertitiesHandler = (PropertiesHandler) ctx.getBean("properties");

System.out.println(propertitiesHandler.getLdapDirectoryIdent());


}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package fr.insee.arc.core.archive_loader;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;

import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.log4j.Logger;

import fr.insee.arc.core.service.SizeLimiterInputStream;
import fr.insee.arc.utils.ressourceUtils.PropertiesHandler;
import fr.insee.arc.utils.utils.LoggerDispatcher;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import org.apache.log4j.Logger;

import fr.insee.arc.utils.ressourceUtils.PropertiesHandler;
import fr.insee.arc.utils.utils.LoggerDispatcher;
import fr.insee.arc.utils.utils.ManipString;

Expand Down Expand Up @@ -38,15 +37,16 @@ public FilesInputStreamLoad loadArchive(FilesInputStreamLoadKeys[] streamNames)

}

@Override
@SuppressWarnings("resource")
@Override
public FilesInputStreamLoad readFileWithoutExtracting(FilesInputStreamLoadKeys[] streamNames) throws IOException {
LoggerDispatcher.info("begin readFileWithoutExtracting() ", LOGGER);
this.filesInputStreamLoad = new FilesInputStreamLoad();

for (FilesInputStreamLoadKeys aStreamName : streamNames) {
// Need to be keep open because if the resource is closed, all stream are closed
// too !
@SuppressWarnings({ "resource", "squid:S2095" })
// @SuppressWarnings({ "resource", "squid:S2095" })
ZipFile zipInput = new ZipFile(this.archiveToLoad);
/*
* Looking for the file in the archive. idSourceInArchive is like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.function.Function;

import fr.insee.arc.core.model.Calendar;
import fr.insee.arc.core.model.Norme;
import fr.insee.arc.utils.dao.AbstractDAO;
import fr.insee.arc.utils.dao.IQueryHandler;
import fr.insee.arc.utils.sqlengine.ContextName;
Expand Down
2 changes: 0 additions & 2 deletions arc-core/src/main/java/fr/insee/arc/core/dao/PilotageDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.apache.log4j.Logger;

import fr.insee.arc.core.model.PilotageEntity;
import fr.insee.arc.core.model.TraitementPhaseEntity;
import fr.insee.arc.core.model.TraitementState;
import fr.insee.arc.core.model.TypeTraitementPhase;
import fr.insee.arc.core.service.AbstractPhaseService;
import fr.insee.arc.utils.dao.AbstractDAO;
Expand Down
6 changes: 3 additions & 3 deletions arc-core/src/main/java/fr/insee/arc/core/model/BatchEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.apache.log4j.Logger;

import fr.insee.arc.utils.ressourceUtils.PropertiesHandler;
import fr.insee.arc.utils.utils.LoggerHelper;
import fr.insee.arc.utils.utils.LoggerDispatcher;

/**
* FIXME make abstract Classe des variables d'environnement liées au batch
Expand Down Expand Up @@ -45,9 +45,9 @@ public BatchEnv() {
this.connexion = DriverManager.getConnection(properties.getDatabaseUrl(),
properties.getDatabaseUsername(), properties.getDatabasePassword());
} catch (SQLException ex) {
LoggerHelper.errorGenTextAsComment(getClass(), "BatchEnv()", LOGGER, ex);
LoggerDispatcher.error(ex, LOGGER);
} catch (ClassNotFoundException ex) {
LoggerHelper.errorGenTextAsComment(getClass(), "BatchEnv()", LOGGER, ex);
LoggerDispatcher.error(ex, LOGGER);
}

this.databaseSchema = properties.getDatabaseSchema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import fr.insee.arc.utils.queryhandler.BatchQueryHandler;
import fr.insee.arc.utils.utils.LoggerDispatcher;
import fr.insee.arc.utils.utils.LoggerHelper;
import lombok.Getter;
import lombok.Setter;

/**
* Abstract class that all the phaseService class need to extends. Provide a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import fr.insee.arc.core.model.RuleSets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class ApiFiltrageService extends AbstractThreadRunnerService<ThreadFiltra
// maximum number of workers allocated to the service processing
private static int MAX_PARALLEL_WORKERS=4;

private static final Logger LOGGER = Logger.getLogger(ApiFiltrageService.class);
@SuppressWarnings("unused")
private static final Logger LOGGER = Logger.getLogger(ApiFiltrageService.class);
protected String seuilExclusion;
protected HierarchicalView normeToPeriodiciteToValiditeInfToValiditeSupToRegle;
private static final Class<ThreadFiltrageService> THREAD_TYPE = ThreadFiltrageService.class ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import fr.insee.arc.core.model.BddTable;
import fr.insee.arc.core.model.DbConstant;
import fr.insee.arc.core.model.TraitementPhaseEntity;
import fr.insee.arc.core.model.TraitementRapport;
import fr.insee.arc.core.model.TraitementState;
import fr.insee.arc.core.model.TraitementTableExecution;
import fr.insee.arc.core.model.TraitementTableParametre;
Expand Down Expand Up @@ -69,20 +67,15 @@ public ApiInitialisationService() {
private static final int TIME_TO_KEEP = 365;

private static final Logger LOGGER = Logger.getLogger(ApiInitialisationService.class);
private String tablePilTemp2;

public ApiInitialisationService(String aCurrentPhase, String anParametersEnvironment, String aexecutionEnv,
String aDirectoryRoot, Integer aNbEnr, String... paramBatch) {
super(aCurrentPhase, anParametersEnvironment, aexecutionEnv, aDirectoryRoot, aNbEnr, paramBatch);
this.tablePilTemp2 = FormatSQL
.temporaryTableName(dbEnv(aexecutionEnv) + TraitementTableExecution.PILOTAGE_FICHIER, "2");
}

public ApiInitialisationService(Connection connexion, String aCurrentPhase, String anParametersEnvironment,
String aexecutionEnv, String aDirectoryRoot, Integer aNbEnr, String... paramBatch) {
super(connexion, aCurrentPhase, anParametersEnvironment, aexecutionEnv, aDirectoryRoot, aNbEnr, paramBatch);
this.tablePilTemp2 = FormatSQL
.temporaryTableName(dbEnv(aexecutionEnv) + TraitementTableExecution.PILOTAGE_FICHIER, "2");
}

@Override
Expand Down Expand Up @@ -881,7 +874,8 @@ public static void copyTablesToExecutionThrow(Connection connexion, String anPar
TraitementTableParametre[] listeTableParamettre = TraitementTableParametre.values();
StringBuilder condition = new StringBuilder();
String modaliteEtat = anExecutionEnvironment.replace("_", ".");
String tablePil = AbstractPhaseService.dbEnv(anExecutionEnvironment)
@SuppressWarnings("unused")
String tablePil = AbstractPhaseService.dbEnv(anExecutionEnvironment)
+ TraitementTableExecution.PILOTAGE_FICHIER;
String tableImage;
String tableCurrent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class ApiNormageService extends AbstractThreadRunnerService<ThreadStructu
// maximum number of workers allocated to the service processing
private static int MAX_PARALLEL_WORKERS=4;

private static final Logger LOGGER = Logger.getLogger(ApiNormageService.class);
@SuppressWarnings("unused")
private static final Logger LOGGER = Logger.getLogger(ApiNormageService.class);
protected String separator = ",";
private static final Class<ThreadStructurizeService> THREAD_TYPE = ThreadStructurizeService.class;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import fr.insee.arc.core.dao.RegleControleDao;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ else if (line.startsWith("/*"))
*
*/

StringBuilder addId=new StringBuilder();
StringBuilder req;

if (!joinTable.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public class MappingService extends AbstractThreadRunnerService<ThreadMappingSer
// maximum number of workers allocated to the service processing
private static int MAX_PARALLEL_WORKERS=4;

private static final Logger LOGGER = Logger.getLogger(MappingService.class);
@SuppressWarnings("unused")
private static final Logger LOGGER = Logger.getLogger(MappingService.class);
private static final String prefixIdentifiantRubrique = "i_";

protected RequeteMappingCalibree requeteSQLCalibree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,15 +834,6 @@ private static final String nomIdentifiantSuffixeGroupe(String nomVariable, int
return new StringBuilder(nomVariable + UNDERSCORE + groupe).toString();
}

/**
*
* @return {@code true} si et seulement si l'ensemble des groupes est non vide.
*/
private boolean isRequeteAGroupes() {
return !this.ensembleGroupes.isEmpty();
}


/**
*
* @param returned
Expand All @@ -860,21 +851,6 @@ private StringBuilder calculerRequeteFinale(StringBuilder returned, TableMapping
return returned;
}

/**
*
* @param returned
* @param table
* @return
*/
private static StringBuilder calculerRequeteFinale(StringBuilder returned, TableMapping table, StringBuilder requeteArrayAggGroup) {
returned.append("\n INSERT INTO " + table.getNomTableTemporaire() + " (" + sqlListeVariablesOrdonnee(table)
+ ")");
returned.append("\n SELECT " + sqlListeVariablesOrdonnee(table));
returned.append("\n FROM ");
returned.append(requeteArrayAggGroup);
returned.append(";\n");
return returned;
}

/**
*
Expand All @@ -887,10 +863,6 @@ private static final StringBuilder sqlListeVariablesOrdonnee(TableMapping table)
.append(Format.untokenize(table.getEnsembleVariableNonClef(), ", "));
}

private static StringBuilder listeVariablesPrepUnion(StringBuilder returned, TableMapping table) {
table.sqlListeVariables(returned);
return returned;
}

private static StringBuilder listeVariablesTypesPrepUnion(StringBuilder returned, TableMapping table,
String separateur, boolean removeArrayTypeForGroupe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public class ThreadLoadService extends AbstractThreadService {

private static final String RECEPTION = TypeTraitementPhase.REGISTER.name();

public ThreadLoadService( int currentIndice, ApiLoadService aApi, Connection connexion) throws Exception {
@SuppressWarnings("resource")
public ThreadLoadService( int currentIndice, ApiLoadService aApi, Connection connexion) throws Exception {
super(currentIndice, aApi, connexion);

this.fileToLoad = aApi.getFilesToProcess().get(currentIndice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;

import org.apache.log4j.Logger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,9 @@ private String optimisation96(String jointure) {
r = " \n " + r;

boolean blocInsert = false;
boolean fieldsToBeInsertedFound = false;

String[] lines = r.split("\n");
String insert = null;
String fieldsToBeInserted = "";

r = "";
for (int i = 0; i < lines.length; i++) {
Expand All @@ -326,11 +324,6 @@ private String optimisation96(String jointure) {
if (!lines[i].contains(")")) {
insert = insert + ")";
}
if (!fieldsToBeInsertedFound) {
fieldsToBeInserted = ManipString.substringBeforeLast(
ManipString.substringAfterFirst(insert, "insert into {table_destination} ("), ")");
fieldsToBeInsertedFound = true;
}
}

if (insert != null && lines[i].contains("UNION ALL")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package fr.insee.arc.core.util;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

import fr.insee.arc.core.model.Norme;
import fr.insee.arc.utils.dao.UtilitaireDao;
import fr.insee.arc.utils.utils.FormatSQL;
import fr.insee.arc.utils.utils.LoggerDispatcher;
import fr.insee.arc.utils.utils.ManipString;


/**
Expand Down Expand Up @@ -73,55 +69,6 @@ public void requeteCreateTableChargementBrutal(int nbBoucle) throws Exception {

}

/**
* Méthode de gros bourrin, on prend le fichier et on le charge ligne par ligne en base. On utilise le COPY pour aller plus vite
*
* @param idSource
* @param br
* @throws Exception
*/
private boolean chargerFichierBrutalement(String idSource, BufferedReader br, int nb_boucle) throws Exception {
LoggerDispatcher.info("** chargerFichierBrutalement **", LOGGER);
java.util.Date beginDate = new java.util.Date();
String delimiter = Character.toString((char) 1);
String quote = Character.toString((char) 2);

boolean output = false;

String header = "id_source" + delimiter + "id_ligne" + delimiter + "ligne\n";
int idLigne = nb_boucle * LIMIT_CHARGEMENT_BRUTAL;
StringBuilder requete = new StringBuilder();

String line = br.readLine();
if (line == null) {
output = true;
}

while (line != null && idLigne < (nb_boucle + 1) * LIMIT_CHARGEMENT_BRUTAL) {
requete.append(idSource + delimiter + idLigne + delimiter + line + "\n");
idLigne++;

if (idLigne < (nb_boucle + 1) * LIMIT_CHARGEMENT_BRUTAL) {
line = br.readLine();
}

}
requete.insert(0, header);
byte[] bytes = requete.toString().getBytes(StandardCharsets.UTF_8);
InputStream is = new ByteArrayInputStream(bytes);
// UtilitaireDao.get("arc").importing(this.connexion, TABLE_CHARGEMENT_BRUTAL, is, true, delimiter);
UtilitaireDao.get("arc").importing(this.connexion, TABLE_CHARGEMENT_BRUTAL, null, is, true, true, delimiter, quote, null);

is.close();

java.util.Date endDate = new java.util.Date();
LoggerDispatcher.info("** chargerFichierBrutalement temps : " + (endDate.getTime() - beginDate.getTime()) + " ms **", LOGGER);

return output;

}


private String requeteFichierBrutalement(String idSource, BufferedReader br, int nb_boucle) throws Exception {
LoggerDispatcher.info("** chargerFichierBrutalement **", LOGGER);

Expand Down
Loading

0 comments on commit 3d33d5d

Please sign in to comment.