Bug fixes
This commit is contained in:
@@ -9,8 +9,10 @@ import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.core.config.Configurator;
|
||||
|
||||
import config.Config;
|
||||
import csv.GenerateCSV;
|
||||
@@ -35,7 +37,7 @@ import ocr.GestionnaireCopies;
|
||||
|
||||
public class Read implements Callable <Void> {
|
||||
|
||||
private static Logger logger;
|
||||
private static Logger logger = LogManager.getLogger(Read.class);
|
||||
|
||||
@Spec
|
||||
Model.CommandSpec spec;
|
||||
@@ -47,7 +49,7 @@ public class Read implements Callable <Void> {
|
||||
int step;
|
||||
|
||||
@Option(names= {"-v"}, arity = "0..*", order = 3, defaultValue = "1", description ="verbose mode")
|
||||
int vb_level;
|
||||
public int vb_level;
|
||||
|
||||
@Option(names= {"-d"}, arity = "1", order = 4, defaultValue = "copies", description ="directory")
|
||||
String directory_name;
|
||||
@@ -76,19 +78,19 @@ public class Read implements Callable <Void> {
|
||||
// Niveau de debug selon verbosite
|
||||
|
||||
if (vb_level >= 0 && vb_level <=2) {
|
||||
logger = LogManager.getFormatterLogger("fatalLogger");
|
||||
Configurator.setLevel("commands", Level.FATAL);
|
||||
}
|
||||
else if (vb_level >= 3 && vb_level <=4) {
|
||||
logger = LogManager.getFormatterLogger("errorLogger");
|
||||
Configurator.setLevel("commands", Level.ERROR);
|
||||
}
|
||||
else if (vb_level >= 5 && vb_level <=6) {
|
||||
logger = LogManager.getFormatterLogger("warnLogger");
|
||||
Configurator.setLevel("commands", Level.WARN);
|
||||
}
|
||||
else if (vb_level >= 7 && vb_level <=8) {
|
||||
logger = LogManager.getFormatterLogger("infoLogger");
|
||||
Configurator.setLevel("commands", Level.INFO);
|
||||
}
|
||||
else {
|
||||
logger = LogManager.getFormatterLogger("debugLogger");
|
||||
Configurator.setLevel("commands", Level.DEBUG);
|
||||
}
|
||||
|
||||
// Help genere de la commande
|
||||
@@ -141,11 +143,11 @@ public class Read implements Callable <Void> {
|
||||
String filePath = new File("").getAbsolutePath();
|
||||
|
||||
|
||||
GestionnaireCopies ocr = new GestionnaireCopies("..\\"+directory_name+"\\");
|
||||
GestionnaireCopies ocr = new GestionnaireCopies("../"+directory_name);
|
||||
// Instantie l'ocr
|
||||
|
||||
|
||||
GenerateCSV csv = new GenerateCSV(ocr.createHashMapforCSV(),config.getParam().get("Code"), result_name, logger);
|
||||
GenerateCSV csv = new GenerateCSV(ocr.createHashMapforCSV(),config.getParam().get("Code"), result_name);
|
||||
|
||||
csv.createFile(); //Génère le fichier csv à partir de la HMap retournée par l'OCR
|
||||
|
||||
|
@@ -6,6 +6,7 @@ import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class GenerateCSV {
|
||||
@@ -13,13 +14,12 @@ public class GenerateCSV {
|
||||
Map<String, String> etudiants;
|
||||
int numLength;
|
||||
String path = "../export";
|
||||
Logger logger;
|
||||
Logger logger = LogManager.getLogger(GenerateCSV.class);
|
||||
|
||||
public GenerateCSV(Map<String, String> map, String length, String pth, Logger lg) {
|
||||
public GenerateCSV(Map<String, String> map, String length, String pth) {
|
||||
this.etudiants = map;
|
||||
this.numLength = Integer.parseInt(length);
|
||||
this.path = path + "/" + pth;
|
||||
this.logger = lg;
|
||||
}
|
||||
|
||||
// Teste validité du numero etudiant (selon param de la config passé :
|
||||
@@ -50,7 +50,7 @@ public class GenerateCSV {
|
||||
}
|
||||
|
||||
public void createFile() {
|
||||
try (PrintWriter writer = new PrintWriter(new File("pdf"))) {
|
||||
try (PrintWriter writer = new PrintWriter(new File(this.path))) {
|
||||
|
||||
logger.info("Creating csv file");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -68,9 +68,12 @@ public class GenerateCSV {
|
||||
// Si etudiant HashMap est null, pas ecrit
|
||||
if (etud != null) {
|
||||
|
||||
if (this.isValid(etud)) {
|
||||
//if (this.isValid(etud)) {
|
||||
writer.write(etud + ";" + etudiants.get(etud) + System.getProperty("line.separator"));
|
||||
}
|
||||
//}
|
||||
// else {
|
||||
// logger.debug("Invalid not added to csv");
|
||||
// }
|
||||
|
||||
} else {
|
||||
|
||||
|
Reference in New Issue
Block a user