MAJ V2.0.1
This commit is contained in:
parent
c338ae6995
commit
2decae65f3
3
bin/.gitignore
vendored
3
bin/.gitignore
vendored
@ -10,3 +10,6 @@
|
||||
/accueil_new_version.png
|
||||
/accueill new version.svg
|
||||
/baseEvaluation/
|
||||
/actions/
|
||||
/baseEtudiants/
|
||||
/baseListesEtudiants/
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Set;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.awt.event.ActionEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.text.ParseException;
|
||||
@ -7,7 +7,8 @@ import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import analyseWriter.baseEvaluations.recupeNodeBaseEvaluations;
|
||||
import baseEvaluation.recupeNodeBaseEvaluations;
|
||||
import fenetres.baseDonneesEvaluations;
|
||||
import xml.node;
|
||||
|
||||
public class actOpenBaseEvaluation extends AbstractAction{
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package fenetres.create_act;
|
||||
package actions;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
57
src/baseEvaluation/CreerBaseParDefautEvaluation.java
Normal file
57
src/baseEvaluation/CreerBaseParDefautEvaluation.java
Normal file
@ -0,0 +1,57 @@
|
||||
package baseEvaluation;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Création de la base de données des évaluations.<br>
|
||||
* Et/Ou vérification de la présence de de la base de données.
|
||||
* @author pabr6
|
||||
*
|
||||
*/
|
||||
public class CreerBaseParDefautEvaluation {
|
||||
|
||||
|
||||
public Boolean isExist() throws IOException {
|
||||
File file = null;
|
||||
String directoryName = Paths.get("").toAbsolutePath().toString();
|
||||
|
||||
if(calc.commandes.os.contains("Win")) {
|
||||
System.out.println("OS Win");
|
||||
file = new File(directoryName + "\\" + "base_evaluations_analyseCalc.xml");
|
||||
}else {
|
||||
System.out.println("OS Mac");
|
||||
file = new File(directoryName + "/" + "base_evaluations_analyseCalc.xml");
|
||||
}
|
||||
|
||||
System.out.println("Path vers la base par défaut = " + file.getAbsolutePath());
|
||||
|
||||
if(!file.exists()) {
|
||||
System.out.println("La base des évaluations n'existe pas.");
|
||||
System.out.println("Début de la création de la base.");
|
||||
Date aujourdhui = new Date();
|
||||
Path outputFilePath = file.toPath();
|
||||
BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8);
|
||||
try {
|
||||
fichier.write("<evaluationsCalc date=\""+ calcul.formatDateWriter.DateLibreOffice(aujourdhui) +"\" version=\""+calc.commandes.version +"\"></evaluations>");
|
||||
fichier.close();
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
return new recupeNodeBaseEvaluations().isHasEvaluation();
|
||||
|
||||
}
|
||||
|
||||
}
|
315
src/baseEvaluation/chargeEvaluation.java
Normal file
315
src/baseEvaluation/chargeEvaluation.java
Normal file
@ -0,0 +1,315 @@
|
||||
package baseEvaluation;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import xml.node;
|
||||
|
||||
/**
|
||||
* Charge le node évaluation avec le node sujet.
|
||||
* @author pabr6
|
||||
*
|
||||
*/
|
||||
public class chargeEvaluation {
|
||||
|
||||
/**
|
||||
* Charge en mémoire le node évaluation et le node sujet.<br>
|
||||
* Le node commandes.evaluationChargeEnMemoire en mémoire.<br>
|
||||
* Le node commandes.nameSujet en mémoire.<br>
|
||||
* @param index
|
||||
*/
|
||||
public static void chargeEnMémoireEvaluationSelected(Integer index) {
|
||||
|
||||
String directoryName = "";
|
||||
File file = null;
|
||||
node evaluation = new node();
|
||||
if(calc.commandes.PathBaseEvaluationDefaut) {
|
||||
directoryName = Paths.get("").toAbsolutePath().toString();
|
||||
}else {
|
||||
directoryName = calc.commandes.PathBaseEvaluations;
|
||||
}
|
||||
|
||||
if(calc.commandes.os.contains("Win")) {
|
||||
file = new File(directoryName + "\\" + calc.commandes.NameBaseEvaluations);
|
||||
}else {
|
||||
file = new File(directoryName + "/" + calc.commandes.NameBaseEvaluations);
|
||||
}
|
||||
|
||||
|
||||
if(file!=null) {
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
||||
String line;
|
||||
StringBuilder targetString = new StringBuilder();
|
||||
while ((line = br.readLine()) != null) {
|
||||
targetString.append(line);
|
||||
}
|
||||
evaluation = evaluation.chargeNodeEvaluationIndex(index,targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
||||
}catch (Exception e) {
|
||||
JFrame frame = new JFrame("Erreur");
|
||||
JLabel texte = new JLabel("<html><h1>Erreur</h1><p>L'évaluation n'a pas été trouvé dans la base de données.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
}
|
||||
|
||||
|
||||
//* Charge le node sujet provisoirement
|
||||
calc.commandes.evaluationChargeEnMemoire = evaluation;
|
||||
calc.commandes.hashCodeEvaluationSave = evaluation.hashCode();
|
||||
calc.commandes.NameEvaluationCharger= evaluation.getAttributs().get("name");
|
||||
calc.commandes.path = evaluation.getAttributs().get("path"); //Dossier des fichiers des étudiants
|
||||
|
||||
// Chargement du node sujet depuis la base
|
||||
calc.commandes.nameSujet = evaluation.getAttributs().get("analysis_filename");
|
||||
calc.commandes.sujet = evaluation.retourneFirstEnfant("fichier");
|
||||
calc.commandes.PathFilenameAnalysis = evaluation.getAttributs().get("PathFilenameAnalysis");
|
||||
|
||||
//** Les paramètres de l'évaluation
|
||||
calc.commandes.versionEvaluation = evaluation.getAttributs().get("version");
|
||||
calc.commandes.fichierStudentMoodle = Boolean.valueOf(evaluation.getAttributs().get("fichierStudentMoodle"));
|
||||
calc.commandes.sansFeeback = Boolean.valueOf(evaluation.getAttributs().get("sansFeeback"));
|
||||
calc.commandes.noDetail = Boolean.valueOf(evaluation.getAttributs().get("noDetail"));
|
||||
calc.commandes.noNote = Boolean.valueOf(evaluation.getAttributs().get("noNote"));
|
||||
calc.commandes.noAfficheProgression = Boolean.valueOf(evaluation.getAttributs().get("noAfficheProgression"));
|
||||
calc.commandes.zipfeedback = Boolean.valueOf(evaluation.getAttributs().get("zipfeedback"));
|
||||
calc.commandes.verifHisto2 = Boolean.valueOf(evaluation.getAttributs().get("verifHisto2"));
|
||||
calc.commandes.ecritNoteCSV = Boolean.valueOf(evaluation.getAttributs().get("ecritNoteCSV"));
|
||||
calc.commandes.newLogo = Boolean.valueOf(evaluation.getAttributs().get("newLogo"));
|
||||
calc.commandes.noLogo = Boolean.valueOf(evaluation.getAttributs().get("noLogo"));
|
||||
calc.commandes.fourniCSV = Boolean.valueOf(evaluation.getAttributs().get("fourniCSV"));
|
||||
calc.commandes.nameCSV = evaluation.getAttributs().get("nameCSV");
|
||||
|
||||
|
||||
if(evaluation.getAttributs().get("analyse_nombres_modifications_simultané_maxi")!=null) {
|
||||
calc.commandes.analyse_nombres_modifications_simultané_maxi = Integer.valueOf(evaluation.getAttributs().get("analyse_nombres_modifications_simultané_maxi"));
|
||||
}
|
||||
|
||||
calc.commandes.fourniCSV = Boolean.valueOf(evaluation.getAttributs().get("fourniCSV"));
|
||||
calc.commandes.nameSVG = evaluation.getAttributs().get("nameSVG");
|
||||
|
||||
|
||||
calc.commandes.nodeCSV = evaluation.retourneFirstEnfant("fileCSV");
|
||||
if(!calc.commandes.nodeCSV.isVide()) {
|
||||
if(calc.commandes.nodeCSV.getAttributs().get("nameListStudent")!=null) {
|
||||
String nameListeStudent = calc.commandes.nodeCSV.getAttributs().get("nameListStudent");
|
||||
chargeListeEtudiants.chargeDansLeNodeCSVListeEtudiants(nameListeStudent);
|
||||
}
|
||||
}
|
||||
|
||||
// commandes.contenuFichierSVG = evaluation.retourneFirstEnfantsByName("nodSVG").retourneLesContenusEnfants("");
|
||||
|
||||
calc.commandes.fichierAnalyseValide = true;
|
||||
|
||||
|
||||
try {
|
||||
calc.commandes.sujetSauvegarde = calc.commandes.sujet.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Chargement des paramètres du fichier d'analyse
|
||||
meptl.chargementParametresFichierAnalyse();
|
||||
|
||||
//** Remise à zéro de la base dans la mémoire de l'application
|
||||
calc.commandes.evaluationsBase = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static node retourneLeNodeEvaluation(String date) {
|
||||
|
||||
String directoryName = "";
|
||||
File file = null;
|
||||
node evaluation = new node();
|
||||
if(calc.commandes.PathBaseEvaluationDefaut) {
|
||||
directoryName = Paths.get("").toAbsolutePath().toString();
|
||||
}else {
|
||||
directoryName = calc.commandes.PathBaseEvaluations;
|
||||
}
|
||||
|
||||
if(calc.commandes.os.contains("Win")) {
|
||||
file = new File(directoryName + "\\" + calc.commandes.NameBaseEvaluations);
|
||||
}else {
|
||||
file = new File(directoryName + "/" + calc.commandes.NameBaseEvaluations);
|
||||
}
|
||||
|
||||
|
||||
if(file!=null) {
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
||||
String line;
|
||||
StringBuilder targetString = new StringBuilder();
|
||||
while ((line = br.readLine()) != null) {
|
||||
targetString.append(line);
|
||||
}
|
||||
String CodeTexte = targetString.toString().replace("\t","").replace("\r", "").replace("\n", "");
|
||||
evaluation = evaluation.chargeNodeEvaluationIndex(null, CodeTexte);
|
||||
|
||||
return evaluation;
|
||||
|
||||
}catch (Exception e) {
|
||||
JFrame frame = new JFrame("Erreur");
|
||||
JLabel texte = new JLabel("<html><h1>Erreur</h1><p>L'évaluation n'a pas été trouvé dans la base de données.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne le node évaluation sélectionné.<br>
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
public static node retourneEvaluationSelected(Integer index) {
|
||||
String directoryName = "";
|
||||
File file = null;
|
||||
node evaluation = new node();
|
||||
if(calc.commandes.PathBaseEvaluationDefaut) {
|
||||
directoryName = Paths.get("").toAbsolutePath().toString();
|
||||
}else {
|
||||
directoryName = calc.commandes.PathBaseEvaluations;
|
||||
}
|
||||
|
||||
if(calc.commandes.os.contains("Win")) {
|
||||
file = new File(directoryName + "\\" + calc.commandes.NameBaseEvaluations);
|
||||
}else {
|
||||
file = new File(directoryName + "/" + calc.commandes.NameBaseEvaluations);
|
||||
}
|
||||
|
||||
if(file!=null) {
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
||||
String line;
|
||||
StringBuilder targetString = new StringBuilder();
|
||||
while ((line = br.readLine()) != null) {
|
||||
targetString.append(line);
|
||||
}
|
||||
evaluation = evaluation.chargeNodeEvaluationIndex(index,targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
||||
}catch (Exception e) {
|
||||
JFrame frame = new JFrame("Erreur");
|
||||
JLabel texte = new JLabel("<html><h1>Erreur</h1><p>L'évaluation n'a pas été trouvé dans la base de données.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
}
|
||||
}
|
||||
return evaluation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge le fichier d'analyse de l'évaluation.<br>
|
||||
* @param file
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void chargeLeNodeSujet(File file) {
|
||||
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
||||
String line;
|
||||
StringBuilder targetString = new StringBuilder();
|
||||
while ((line = br.readLine()) != null) {
|
||||
targetString.append(line);
|
||||
}
|
||||
|
||||
//node.node2(targetString);
|
||||
node sujetLoad = new node(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
||||
|
||||
// Vérification de la conformité du fichier d'analyse
|
||||
if(!ChargeFichierXML.fichierSujetValide(sujetLoad)) {
|
||||
JOptionPane.showMessageDialog(null, "Le fichier d'analyse n'est pas valide.");
|
||||
}else {
|
||||
calc.commandes.initialiseParametresSettingsProprietes();
|
||||
calc.commandes.sujet = sujetLoad;
|
||||
calc.commandes.sujetSauvegarde = calc.commandes.sujet.clone();
|
||||
|
||||
//Chargement des paramètres du fichier d'analyse
|
||||
System.out.println( "Chargement des paramètres du fichier d'analyse");
|
||||
meptl.chargementParametresFichierAnalyse();
|
||||
|
||||
// Rechercher des erreurs dans le fichier d'analyse
|
||||
System.out.println( "Vérification du fichier d'analyse" );
|
||||
new verificationFichierAnalyse_node_commandesSujet();
|
||||
}
|
||||
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Récupère la date de modification du fichier d'analyse.
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private Date recupereDateFichierAnalyseSource(File file) {
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
||||
String line;
|
||||
StringBuilder targetString = new StringBuilder();
|
||||
while ((line = br.readLine()) != null) {
|
||||
targetString.append(line);
|
||||
}
|
||||
|
||||
//node.node2(targetString);
|
||||
node sujetLoad = new node(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
||||
|
||||
// Vérification de la conformité du fichier d'analyse
|
||||
if(!ChargeFichierXML.fichierSujetValide(sujetLoad)) {
|
||||
JOptionPane.showMessageDialog(null, "Le fichier d'analyse n'est pas valide.");
|
||||
}else {
|
||||
if(sujetLoad.getAttributs().get("date")!=null) {
|
||||
String dateString = sujetLoad.getAttributs().get("date");
|
||||
return calcul.formatDateWriter.DateLibreOffice(dateString);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (FileNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package baseListesEtudiants;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* Création de la base de données des listes des étudiants.<br>
|
||||
* Et/Ou vérification de la présence de de la base de données.
|
||||
* @author pabr6
|
||||
*
|
||||
*/
|
||||
public class CreerBaseParDefautListesEtudiants {
|
||||
public Boolean isExist() throws IOException {
|
||||
File file = null;
|
||||
String directoryName = Paths.get("").toAbsolutePath().toString();
|
||||
|
||||
if(calc.commandes.os.contains("Win")) {
|
||||
file = new File(directoryName + "\\" + "base_listes_etudiants.xml");
|
||||
}else {
|
||||
file = new File(directoryName + "/" + "base_listes_etudiants.xml");
|
||||
}
|
||||
|
||||
if(!file.exists()) {
|
||||
Date aujourdhui = new Date();
|
||||
Path outputFilePath = file.toPath();
|
||||
BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8);
|
||||
try {
|
||||
fichier.write("<ListesEtudiants date=\""+ calcul.formatDateWriter.DateLibreOffice(aujourdhui) +"\" version=\""+calc.commandes.version +"\"></ListesEtudiants>");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
fichier.close();
|
||||
return false;
|
||||
}
|
||||
return new recupeNodeBaseListesEtudiants().isHasliste();
|
||||
}
|
||||
}
|
196
src/baseListesEtudiants/ecritureBaseListesEtudiants.java
Normal file
196
src/baseListesEtudiants/ecritureBaseListesEtudiants.java
Normal file
@ -0,0 +1,196 @@
|
||||
package baseListesEtudiants;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import xml.node;
|
||||
|
||||
public class ecritureBaseListesEtudiants {
|
||||
|
||||
|
||||
private static boolean erreur = false;
|
||||
|
||||
public ecritureBaseListesEtudiants(node csv) {
|
||||
erreur = false;
|
||||
|
||||
if(csv==null) {
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><h1>L'écriture n'a pas réussi</h1>"
|
||||
+ "<p>Le fichier CSV est null.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
erreur=true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(csv.isVide()) {
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><h1>L'écriture n'a pas réussi</h1>"
|
||||
+ "<p>Le fichier CSV est vide.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
erreur=true;
|
||||
return ;
|
||||
}
|
||||
|
||||
File file = null;
|
||||
String directoryName = Paths.get("").toAbsolutePath().toString();
|
||||
|
||||
if(calc.commandes.os.contains("Win")) {
|
||||
file = new File(directoryName + "\\" + "base_listes_etudiants.xml");
|
||||
}else {
|
||||
file = new File(directoryName + "/" + "base_listes_etudiants.xml");
|
||||
}
|
||||
|
||||
if(!Files.isWritable(file.toPath())) {
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><h1>L'écriture n'a pas réussi</h1>"
|
||||
+ "<p>"+ file.getAbsolutePath() +"</p><p>Vous devez avoir des droits pour écrire dans ce dossier.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
erreur=true;
|
||||
return;
|
||||
}
|
||||
|
||||
String debut="";
|
||||
String fin="";
|
||||
String XMLBase="";
|
||||
|
||||
if(file!=null) {
|
||||
//Lecture de la base de données
|
||||
BufferedReader br;
|
||||
try {
|
||||
br = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(file.getAbsoluteFile()), "UTF-8"));
|
||||
String line;
|
||||
StringBuilder targetString = new StringBuilder();
|
||||
while ((line = br.readLine()) != null) {
|
||||
targetString.append(line);
|
||||
}
|
||||
String baseToString = targetString.toString().replace("\t","").replace("\r", "").replace("\n", "").replaceAll(">/{1,}<","><");
|
||||
|
||||
Pattern p = Pattern.compile("<\\bfileCSV\\b.{1,100}\\bnameListStudent\\b=\\\""+ csv.getAttributs().get("nameListStudent") +"\\\".*?<\\/\\bfileCSV\\b>");
|
||||
Matcher m = p.matcher(baseToString);
|
||||
|
||||
if(m.find()) {
|
||||
//Supprime le node fileCSV pour le remplacer par le nouveau.
|
||||
debut = baseToString.substring(0,m.start());
|
||||
fin = baseToString.substring(m.end());
|
||||
XMLBase = debut + csv.ecritureXML().toString() + fin;
|
||||
}else {
|
||||
//Ajoute une nouvelle liste (fileCSV) au début de la base
|
||||
p = Pattern.compile("<ListesEtudiants.*?>");
|
||||
m = p.matcher(baseToString);
|
||||
if(m.find()) {
|
||||
debut = baseToString.substring(0,m.end());
|
||||
fin = baseToString.substring(m.end());
|
||||
XMLBase = debut + csv.ecritureXML().toString() + fin;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// écriture du node
|
||||
Path outputFilePath = file.toPath();
|
||||
BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8);
|
||||
fichier.write(XMLBase);
|
||||
fichier.close();
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><h1>Enregistrement réussi</h1><p>La liste <b>"+csv.getAttributs().get("nameListStudent")+ "</b> a été enregistrée dans la base de données.</p>"
|
||||
+ "<p>"+ file.getAbsolutePath() +"</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
|
||||
} catch (IOException e) {
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><h1>L'écriture n'a pas réussi</h1>"
|
||||
+ "<p>"+e.getMessage()+"</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
erreur=true;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mise à jour de la base liste des étudiants.
|
||||
*/
|
||||
public static void majBaseListesEtudiant() {
|
||||
erreur=false;
|
||||
|
||||
if(calc.commandes.listesEtudiants==null) {
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><h1>La liste des étudiant est nulle.</h1>"
|
||||
+ "</html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
erreur=true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
File file = null;
|
||||
String directoryName = Paths.get("").toAbsolutePath().toString();
|
||||
|
||||
if(calc.commandes.os.contains("Win")) {
|
||||
file = new File(directoryName + "\\" + "base_listes_etudiants.xml");
|
||||
}else {
|
||||
file = new File(directoryName + "/" + "base_listes_etudiants.xml");
|
||||
}
|
||||
|
||||
if(!Files.isWritable(file.toPath())) {
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><h1>L'écriture n'a pas réussi</h1>"
|
||||
+ "<p>"+ file.getAbsolutePath() +"</p><p>Vous devez avoir des droits pour écrire dans ce dossier.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
erreur=true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// écriture du node
|
||||
|
||||
try {
|
||||
Path outputFilePath = file.toPath();
|
||||
BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8);
|
||||
Date aujourdhui = new Date();
|
||||
calc.commandes.listesEtudiants.getAttributs().put("date", calcul.formatDateWriter.DateLibreOffice(aujourdhui));
|
||||
calc.commandes.listesEtudiants.getAttributs().put("version",calc.commandes.version);
|
||||
fichier.write(calc.commandes.listesEtudiants.ecritureXML().toString());
|
||||
fichier.close();
|
||||
} catch (IOException | ParseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><h1>L'écriture n'a pas réussi</h1>"
|
||||
+ "<p>"+e.getMessage()+"</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
erreur=true;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isErreur() {
|
||||
return erreur;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user