2023-04-01 09:54:28 +02:00
|
|
|
package baseEvaluations;
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
|
|
|
import MEPTL.commandes;
|
|
|
|
import cXML.node;
|
|
|
|
|
|
|
|
public class recupeNodeBaseEvaluations {
|
|
|
|
|
|
|
|
/**
|
2023-06-22 13:51:14 +02:00
|
|
|
* Récupère la base des évaluations qui se trouve indiqué par commandes.PathBaseEvaluationDefaut ou commandes.PathBaseEvaluations.
|
2023-04-01 09:54:28 +02:00
|
|
|
*/
|
|
|
|
public recupeNodeBaseEvaluations() {
|
|
|
|
String directoryName = "";
|
|
|
|
File file = null;
|
|
|
|
if(commandes.PathBaseEvaluationDefaut) {
|
|
|
|
directoryName = Paths.get("").toAbsolutePath().toString();
|
|
|
|
}else {
|
|
|
|
directoryName = commandes.PathBaseEvaluations;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(commandes.os.contains("Win")) {
|
|
|
|
file = new File(directoryName + "\\" + commandes.NameBaseEvaluations);
|
|
|
|
}else {
|
|
|
|
file = new File(directoryName + "/" + commandes.NameBaseEvaluations);
|
|
|
|
}
|
2024-04-09 14:50:03 +02:00
|
|
|
|
2023-04-01 09:54:28 +02:00
|
|
|
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);
|
|
|
|
}
|
2024-04-07 19:18:49 +02:00
|
|
|
|
|
|
|
node evaluations = new node();
|
2024-04-08 10:29:34 +02:00
|
|
|
evaluations = evaluations.allFirstNodesEvaluationFichierOnly(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
2024-04-07 19:18:49 +02:00
|
|
|
|
2024-04-09 14:50:03 +02:00
|
|
|
|
2023-04-01 09:54:28 +02:00
|
|
|
if(evaluations!=null) {
|
|
|
|
if(evaluations.getNodes().size()>0) {
|
|
|
|
if(evaluations.getNomElt().equals("evaluations")) {
|
|
|
|
commandes.evaluationsBase = evaluations;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-07 19:18:49 +02:00
|
|
|
|
2023-04-01 09:54:28 +02:00
|
|
|
}catch (Exception e) {
|
|
|
|
JFrame frame = new JFrame();
|
|
|
|
JLabel texte = new JLabel("<html><p>La base de données ne se trouve pas dans le même dossier que celui de l'application.</p><br>"
|
|
|
|
+"<p>Vous pouvez charger la base de données depuis la fenêtre \"<b>base de données d'évaluation</b>\" de l'application.</p>"
|
|
|
|
+ "<p>Sinon, une nouvelle base de données sera créé dans le dossier de l'application.</p></html>");
|
|
|
|
JOptionPane.showMessageDialog(frame, texte);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-08 20:46:40 +02:00
|
|
|
public recupeNodeBaseEvaluations(String directoryName, String NameNewBase) {
|
|
|
|
|
|
|
|
File file = null;
|
|
|
|
|
|
|
|
if(commandes.os.contains("Win")) {
|
|
|
|
file = new File(directoryName + "\\" + NameNewBase);
|
|
|
|
}else {
|
|
|
|
file = new File(directoryName + "/" + NameNewBase);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
node evaluations = new node();
|
2024-04-09 14:50:03 +02:00
|
|
|
|
2024-04-08 20:46:40 +02:00
|
|
|
evaluations = evaluations.allFirstNodesEvaluationFichierOnly(targetString.toString().replace("\t","").replace("\r", "").replace("\n", ""));
|
2024-04-09 14:50:03 +02:00
|
|
|
|
2024-04-08 20:46:40 +02:00
|
|
|
if(evaluations!=null) {
|
|
|
|
if(evaluations.getNodes().size()>0) {
|
|
|
|
if(evaluations.getNomElt().equals("evaluations")) {
|
|
|
|
commandes.evaluationsBase = evaluations;
|
|
|
|
commandes.PathBaseEvaluations = (directoryName);
|
|
|
|
commandes.NameBaseEvaluations = NameNewBase;
|
|
|
|
commandes.PathBaseEvaluationDefaut = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-09 14:50:03 +02:00
|
|
|
|
2024-04-08 20:46:40 +02:00
|
|
|
}catch (Exception e) {
|
|
|
|
JFrame frame = new JFrame();
|
|
|
|
JLabel texte = new JLabel("<html><p>La base de données ne se trouve pas dans le même dossier que celui de l'application.</p><br>"
|
|
|
|
+"<p>Vous pouvez charger la base de données depuis la fenêtre \"<b>base de données d'évaluation</b>\" de l'application.</p>"
|
|
|
|
+ "<p>Sinon, une nouvelle base de données sera créé dans le dossier de l'application.</p></html>");
|
|
|
|
JOptionPane.showMessageDialog(frame, texte);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-01 09:54:28 +02:00
|
|
|
|
|
|
|
}
|