First commit
This commit is contained in:
commit
f39518709e
23
.classpath
Normal file
23
.classpath
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-19">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/org.eclipse.jgit-6.5.0.202303070854-r.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/xerces-2_12_2/xercesImpl.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/log4j/org.apache.logging.log4j.core-2.17.1.LIFERAY-PATCHED-1.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/commons-codec-1.10.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/commons-collections4-4.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/commons-compress-1.18.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/curvesapi-1.04.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/poi-4.0.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/poi-ooxml-4.0.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/poi-ooxml-schemas-4.0.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/xmlbeans-3.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.tika with dependances/commons-io-2.11.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/juniversalchardet-2.4.0.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/bin/
|
17
.project
Normal file
17
.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>baseStudentUFRHG</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
14
.settings/org.eclipse.jdt.core.prefs
Normal file
14
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,14 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=19
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=19
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=19
|
BIN
fichier.xlsx
Normal file
BIN
fichier.xlsx
Normal file
Binary file not shown.
187
src/baseUFRHG/CreateCalcWorkbookExample.java
Normal file
187
src/baseUFRHG/CreateCalcWorkbookExample.java
Normal file
@ -0,0 +1,187 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
public class CreateCalcWorkbookExample {
|
||||
|
||||
|
||||
public CreateCalcWorkbookExample(Object[][] data){
|
||||
String filePath = Paths.get("").toAbsolutePath().toString()+ "/fichier.xlsx";
|
||||
|
||||
|
||||
|
||||
try (Workbook workbook = new XSSFWorkbook()) {
|
||||
int rows = data.length; // Nombre de lignes
|
||||
int columns = data[0].length;
|
||||
|
||||
// Créer un style de cellule avec des bordures
|
||||
CellStyle cellStyle = workbook.createCellStyle();
|
||||
cellStyle.setBorderTop(BorderStyle.THIN);
|
||||
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
cellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||
cellStyle.setAlignment(HorizontalAlignment.LEFT);
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < rows; i++) {
|
||||
String nameFormation = (String) data[i][0];
|
||||
String[][] data1 = (String[][]) data[i][columns-1];
|
||||
|
||||
Sheet sheet = workbook.createSheet(nameFormation);
|
||||
|
||||
//Entête de la première ligne
|
||||
Row row1 = sheet.createRow(0);
|
||||
Cell cell1 = row1.createCell(0);
|
||||
int tailleHead = columns - 2 ;
|
||||
for(int j = 0 ; j < tailleHead; j++) {
|
||||
cell1 = row1.createCell(j);
|
||||
cell1.setCellValue((String) data[i][j+1]);
|
||||
cell1.setCellStyle(cellStyle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Boucle pour insérer les données dans les colonnes
|
||||
int rowNum = 1;
|
||||
for (Object[] rowData : data1) {
|
||||
Row row = sheet.createRow(rowNum++);
|
||||
int colNum = 0;
|
||||
for (Object cellData : rowData) {
|
||||
Cell cell = row.createCell(colNum++);
|
||||
if (cellData instanceof String) {
|
||||
cell.setCellValue((String) cellData);
|
||||
} else if (cellData instanceof Integer) {
|
||||
cell.setCellValue((Integer) cellData);
|
||||
}
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
|
||||
for(int j = 0 ; j < tailleHead; j++) {
|
||||
sheet.autoSizeColumn(j);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Enregistrer le classeur dans un fichier
|
||||
FileOutputStream fileOut = new FileOutputStream(filePath);
|
||||
workbook.write(fileOut);
|
||||
fileOut.close();
|
||||
|
||||
System.out.println("Le classeur a été créé avec succès.");
|
||||
JOptionPane.showMessageDialog(null, "Le classeur a été créé avec succès.");
|
||||
}catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// try (Workbook workbook = new XSSFWorkbook()) {
|
||||
// Sheet sheet = workbook.createSheet(nomFeuille);
|
||||
//
|
||||
// // Créer un style de cellule avec des bordures
|
||||
// CellStyle cellStyle = workbook.createCellStyle();
|
||||
// cellStyle.setBorderTop(BorderStyle.THIN);
|
||||
// cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
// cellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
// cellStyle.setBorderRight(BorderStyle.THIN);
|
||||
// cellStyle.setAlignment(HorizontalAlignment.LEFT);
|
||||
// cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
//
|
||||
// // Créer un style de cellule avec des bordures et alignement centré
|
||||
// CellStyle cellStyle2 = workbook.createCellStyle();
|
||||
// cellStyle2.setBorderTop(BorderStyle.THIN);
|
||||
// cellStyle2.setBorderBottom(BorderStyle.THIN);
|
||||
// cellStyle2.setBorderLeft(BorderStyle.THIN);
|
||||
// cellStyle2.setBorderRight(BorderStyle.THIN);
|
||||
// cellStyle2.setAlignment(HorizontalAlignment.CENTER);
|
||||
// cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
//
|
||||
// // Fusionner les six premières cellules de la première ligne
|
||||
// CellRangeAddress mergedRegion = new CellRangeAddress(0, 0, 0, 5);
|
||||
// sheet.addMergedRegion(mergedRegion);
|
||||
//
|
||||
// // Vérifier si la première ligne existe
|
||||
// Row titleRow = sheet.getRow(0);
|
||||
// if (titleRow == null) {
|
||||
// titleRow = sheet.createRow(0);
|
||||
// }
|
||||
//
|
||||
// // Créer une cellule pour le titre
|
||||
// Cell titleCell = titleRow.createCell(0);
|
||||
// titleCell.setCellValue("Titre de la feuille");
|
||||
//
|
||||
//
|
||||
// // Mise en forme de la cellule du titre
|
||||
// CellStyle titleCellStyle = workbook.createCellStyle();
|
||||
// titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
// titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
// titleCellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
|
||||
// titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
// titleCellStyle.setBorderTop(BorderStyle.THIN);
|
||||
// titleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
// titleCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
// titleCellStyle.setBorderRight(BorderStyle.THIN);
|
||||
//
|
||||
// // Créer une police avec la taille et la police spécifiées
|
||||
// Font titleFont = workbook.createFont();
|
||||
// titleFont.setFontHeightInPoints((short) 14);
|
||||
// titleFont.setFontName("Arial");
|
||||
// titleCellStyle.setFont(titleFont);
|
||||
//
|
||||
// titleCell.setCellStyle(titleCellStyle);
|
||||
//
|
||||
// // Ajuster la largeur de la sixième colonne en fonction du contenu
|
||||
// sheet.autoSizeColumn(5);
|
||||
//
|
||||
// // Boucle pour insérer les données dans les colonnes
|
||||
// int rowNum = 1;
|
||||
// for (Object[] rowData : data) {
|
||||
// Row row = sheet.createRow(rowNum++);
|
||||
// int colNum = 0;
|
||||
// for (Object cellData : rowData) {
|
||||
// Cell cell = row.createCell(colNum++);
|
||||
// if (cellData instanceof String) {
|
||||
// cell.setCellValue((String) cellData);
|
||||
// } else if (cellData instanceof Integer) {
|
||||
// cell.setCellValue((Integer) cellData);
|
||||
// }
|
||||
// // Appliquer le style de cellule avec les bordures
|
||||
// cell.setCellStyle(cellStyle);
|
||||
// // Appliquer le style de cellule avec les bordures et l'alignement centré à la colonne 4
|
||||
// if (colNum == 4) {
|
||||
// cell.setCellStyle(cellStyle2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Enregistrer le classeur dans un fichier
|
||||
// FileOutputStream fileOut = new FileOutputStream(filePath);
|
||||
// workbook.write(fileOut);
|
||||
// fileOut.close();
|
||||
//
|
||||
// System.out.println("Le classeur a été créé avec succès.");
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
34
src/baseUFRHG/FileChooserCSV.java
Normal file
34
src/baseUFRHG/FileChooserCSV.java
Normal file
@ -0,0 +1,34 @@
|
||||
package baseUFRHG;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
public class FileChooserCSV {
|
||||
|
||||
public static File retourneFileCSV() {
|
||||
// Créer une boîte de dialogue de sélection de fichiers
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
// Filtrer les fichiers pour n'afficher que les fichiers XML
|
||||
fileChooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
return file.getName().toLowerCase().endsWith(".csv") || file.isDirectory();
|
||||
}
|
||||
public String getDescription() {
|
||||
return "Fichiers (*.csv)";
|
||||
}
|
||||
});
|
||||
// Ouvrir la boîte de dialogue de sélection de fichiers
|
||||
int returnValue = fileChooser.showOpenDialog(null);
|
||||
// Si l'utilisateur a sélectionné un fichier
|
||||
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
||||
File selectedFile = fileChooser.getSelectedFile();
|
||||
System.out.println("Fichier sélectionné : " + selectedFile.getAbsolutePath());
|
||||
return selectedFile;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
34
src/baseUFRHG/FileChooserXLSX.java
Normal file
34
src/baseUFRHG/FileChooserXLSX.java
Normal file
@ -0,0 +1,34 @@
|
||||
package baseUFRHG;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
public class FileChooserXLSX {
|
||||
|
||||
public static File retourneFileXLSX() {
|
||||
// Créer une boîte de dialogue de sélection de fichiers
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
// Filtrer les fichiers pour n'afficher que les fichiers XML
|
||||
fileChooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
return file.getName().toLowerCase().endsWith(".xlsx") || file.isDirectory();
|
||||
}
|
||||
public String getDescription() {
|
||||
return "Fichiers (*.xlsx)";
|
||||
}
|
||||
});
|
||||
// Ouvrir la boîte de dialogue de sélection de fichiers
|
||||
int returnValue = fileChooser.showOpenDialog(null);
|
||||
// Si l'utilisateur a sélectionné un fichier
|
||||
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
||||
File selectedFile = fileChooser.getSelectedFile();
|
||||
System.out.println("Fichier sélectionné : " + selectedFile.getAbsolutePath());
|
||||
return selectedFile;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
34
src/baseUFRHG/FileChooserXML.java
Normal file
34
src/baseUFRHG/FileChooserXML.java
Normal file
@ -0,0 +1,34 @@
|
||||
package baseUFRHG;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
public class FileChooserXML {
|
||||
|
||||
public static File retourneFileXML() {
|
||||
// Créer une boîte de dialogue de sélection de fichiers
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
// Filtrer les fichiers pour n'afficher que les fichiers XML
|
||||
fileChooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
return file.getName().toLowerCase().endsWith(".xml") || file.isDirectory();
|
||||
}
|
||||
public String getDescription() {
|
||||
return "Fichiers (*.xml)";
|
||||
}
|
||||
});
|
||||
// Ouvrir la boîte de dialogue de sélection de fichiers
|
||||
int returnValue = fileChooser.showOpenDialog(null);
|
||||
// Si l'utilisateur a sélectionné un fichier
|
||||
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
||||
File selectedFile = fileChooser.getSelectedFile();
|
||||
System.out.println("Fichier sélectionné : " + selectedFile.getAbsolutePath());
|
||||
return selectedFile;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
48
src/baseUFRHG/FileEncodingDetector.java
Normal file
48
src/baseUFRHG/FileEncodingDetector.java
Normal file
@ -0,0 +1,48 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.mozilla.universalchardet.UniversalDetector;
|
||||
|
||||
|
||||
public class FileEncodingDetector {
|
||||
|
||||
public static String EncodingFile(String filePath) {
|
||||
|
||||
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
byte[] data = new byte[4096];
|
||||
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
int bytesRead;
|
||||
UniversalDetector detector = new UniversalDetector(null);
|
||||
|
||||
while ((bytesRead = fis.read(data)) > 0 && !detector.isDone()) {
|
||||
detector.handleData(data, 0, bytesRead);
|
||||
}
|
||||
|
||||
detector.dataEnd();
|
||||
fis.close();
|
||||
|
||||
String encoding = detector.getDetectedCharset();
|
||||
detector.reset();
|
||||
|
||||
if (encoding != null) {
|
||||
System.out.println("Encodage du fichier : " + encoding);
|
||||
// Charset charset = Charset.forName(encoding);
|
||||
|
||||
return encoding;
|
||||
// Utilisez le charset pour lire le fichier avec l'encodage détecté
|
||||
} else {
|
||||
System.out.println("Impossible de détecter l'encodage du fichier.");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
37
src/baseUFRHG/TextComparator.java
Normal file
37
src/baseUFRHG/TextComparator.java
Normal file
@ -0,0 +1,37 @@
|
||||
package baseUFRHG;
|
||||
|
||||
|
||||
public class TextComparator {
|
||||
|
||||
public static boolean areVerySimilar(String s1, String s2) {
|
||||
// Calculer la distance de Levenshtein entre les deux chaînes de texte
|
||||
int distance = computeLevenshteinDistance(s1, s2);
|
||||
|
||||
// Déterminer si les chaînes sont très proches en fonction de la distance de Levenshtein
|
||||
// Vous pouvez ajuster le seuil de distance en fonction de vos besoins
|
||||
return distance <= 3; // retourne vrai si la distance de Levenshtein est de 3 ou moins
|
||||
}
|
||||
|
||||
private static int computeLevenshteinDistance(String s1, String s2) {
|
||||
int[][] distance = new int[s1.length() + 1][s2.length() + 1];
|
||||
|
||||
for (int i = 0; i <= s1.length(); i++) {
|
||||
distance[i][0] = i;
|
||||
}
|
||||
|
||||
for (int j = 0; j <= s2.length(); j++) {
|
||||
distance[0][j] = j;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= s1.length(); i++) {
|
||||
for (int j = 1; j <= s2.length(); j++) {
|
||||
int cost = (s1.charAt(i - 1) == s2.charAt(j - 1)) ? 0 : 1;
|
||||
distance[i][j] = Math.min(Math.min(distance[i - 1][j] + 1, distance[i][j - 1] + 1),
|
||||
distance[i - 1][j - 1] + cost);
|
||||
}
|
||||
}
|
||||
|
||||
return distance[s1.length()][s2.length()];
|
||||
}
|
||||
}
|
||||
|
48
src/baseUFRHG/XMLParser.java
Normal file
48
src/baseUFRHG/XMLParser.java
Normal file
@ -0,0 +1,48 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
|
||||
public class XMLParser {
|
||||
|
||||
public static noeud parse(Document doc) {
|
||||
noeud root = new noeud(doc.getDocumentElement().getNodeName());
|
||||
createNoeud(root,null, doc.getDocumentElement());
|
||||
return root;
|
||||
}
|
||||
|
||||
private static void createNoeud(noeud Noeud, noeud Parent, Node node) {
|
||||
if (node.hasChildNodes()) {
|
||||
Node child = node.getFirstChild();
|
||||
while (child != null) {
|
||||
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE) {
|
||||
noeud childNoeudObject = new noeud(child.getNodeName(),Parent);
|
||||
createNoeud(childNoeudObject, Noeud , child);
|
||||
Noeud.addChild(childNoeudObject);
|
||||
} else if (child.getNodeType() == Node.TEXT_NODE) {
|
||||
String content = child.getNodeValue().trim();
|
||||
if (!content.isEmpty()) Noeud.setContent(content);
|
||||
}
|
||||
// else if (child.getNodeType() == Node.COMMENT_NODE) {
|
||||
//
|
||||
// }
|
||||
// Noeud.setParent(Parent);
|
||||
child = child.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
if (node.hasAttributes()) {
|
||||
for (int i = 0; i < node.getAttributes().getLength(); i++) {
|
||||
Noeud.addAttribute(node.getAttributes().item(i).getNodeName(), node.getAttributes().item(i).getNodeValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
47
src/baseUFRHG/XmlLoader.java
Normal file
47
src/baseUFRHG/XmlLoader.java
Normal file
@ -0,0 +1,47 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
public class XmlLoader {
|
||||
|
||||
public XmlLoader() {
|
||||
try {
|
||||
// Créer un objet JFileChooser pour permettre à l'utilisateur de sélectionner le fichier XML à charger
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
chooser.setDialogTitle("Sélectionnez un fichier XML");
|
||||
|
||||
// Afficher la boîte de dialogue de sélection de fichier et attendre que l'utilisateur sélectionne un fichier
|
||||
int returnValue = chooser.showOpenDialog(null);
|
||||
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
||||
// Récupérer le fichier sélectionné par l'utilisateur
|
||||
File xmlFile = chooser.getSelectedFile();
|
||||
|
||||
// Créer un objet DocumentBuilderFactory
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
|
||||
// Créer un objet DocumentBuilder à partir de DocumentBuilderFactory
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
|
||||
// Charger le fichier XML dans un objet Document
|
||||
Document document = dBuilder.parse(xmlFile);
|
||||
|
||||
// Facultatif: normaliser le document XML pour éliminer les espaces blancs inutiles
|
||||
document.getDocumentElement().normalize();
|
||||
|
||||
// Utiliser l'objet Document pour accéder aux nœuds XML et extraire les données
|
||||
// Par exemple:
|
||||
// String rootNodeName = document.getDocumentElement().getNodeName();
|
||||
String nodeTextuel = XMLParser.parse(document).toString();
|
||||
System.out.println(nodeTextuel);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
112
src/baseUFRHG/XmlWriter.java
Normal file
112
src/baseUFRHG/XmlWriter.java
Normal file
@ -0,0 +1,112 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
public class XmlWriter {
|
||||
public static void writeXmlFromString(noeud myNoeud, String filePath) throws Exception {
|
||||
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
dbFactory.setNamespaceAware(true);
|
||||
DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
|
||||
|
||||
|
||||
// Création des éléments racine
|
||||
|
||||
Document doc = docBuilder.newDocument();
|
||||
|
||||
Element racine = doc.createElement(myNoeud.getName());
|
||||
racine.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "");
|
||||
|
||||
doc.appendChild(racine);
|
||||
|
||||
|
||||
Attr attr;
|
||||
for (Map.Entry<String, String> entry : myNoeud.getAttributes().entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
attr = doc.createAttribute(key);
|
||||
attr.setValue(value);
|
||||
racine.setAttributeNode(attr);
|
||||
}
|
||||
|
||||
|
||||
if(myNoeud.getContent()!=null) {
|
||||
racine.setTextContent(myNoeud.getContent());
|
||||
}
|
||||
|
||||
// Création des childs
|
||||
for (noeud child : myNoeud.getChildren()) {
|
||||
racine.appendChild(createElements(child, doc));
|
||||
}
|
||||
|
||||
try {
|
||||
Transformer tr = TransformerFactory.newInstance().newTransformer();
|
||||
tr.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
tr.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||
tr.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
tr.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||
|
||||
FileOutputStream o = new FileOutputStream("C:\\Users\\pabr6\\ouput.xml");
|
||||
tr.transform(new DOMSource(doc), new StreamResult(o));
|
||||
|
||||
o.close();
|
||||
} catch (TransformerException te) {
|
||||
System.err.println(te.getMessage());
|
||||
} catch (IOException ioe) {
|
||||
System.err.println(ioe.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
System.out.println("Fichier sauvegardé avec succès!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static Element createElements(noeud myNoeud, Document doc) {
|
||||
|
||||
Element e;
|
||||
Attr attr;
|
||||
|
||||
e = doc.createElement(myNoeud.getName());
|
||||
for (Map.Entry<String, String> entry : myNoeud.getAttributes().entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
attr = doc.createAttribute(key);
|
||||
attr.setValue(value);
|
||||
e.setAttributeNode(attr);
|
||||
}
|
||||
|
||||
|
||||
if(myNoeud.getContent()!=null) {
|
||||
e.setTextContent(myNoeud.getContent());
|
||||
}
|
||||
|
||||
// Création des childs
|
||||
for (noeud child : myNoeud.getChildren()) {
|
||||
e.appendChild(createElements(child, doc));
|
||||
}
|
||||
|
||||
|
||||
return e;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
94
src/baseUFRHG/ZipExtractorGraphic.java
Normal file
94
src/baseUFRHG/ZipExtractorGraphic.java
Normal file
@ -0,0 +1,94 @@
|
||||
package baseUFRHG;
|
||||
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.StringReader;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
|
||||
public class ZipExtractorGraphic {
|
||||
|
||||
public noeud extractFolderContentToXMLFile(String zipPath) throws Exception {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document doc = builder.newDocument();
|
||||
Element root = doc.createElement("root");
|
||||
doc.appendChild(root);
|
||||
|
||||
noeud graphics = new noeud("graphics");
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipPath));
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
|
||||
Pattern pattern = Pattern.compile("^Object\\s\\d+/content.xml$");
|
||||
|
||||
|
||||
while (zipEntry != null) {
|
||||
|
||||
Matcher matcher = pattern.matcher(zipEntry.getName());
|
||||
|
||||
if (!zipEntry.isDirectory() && matcher.matches()) { //zipEntry.getName().startsWith("Object " + "/")
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
int len;
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, len);
|
||||
}
|
||||
|
||||
String fileContent = IOUtils.toString(outputStream.toByteArray(),"UTF-8");
|
||||
|
||||
Element fileElement = doc.createElement("file");
|
||||
fileElement.setAttribute("name", zipEntry.getName());
|
||||
|
||||
XMLParser.parse(doc);
|
||||
|
||||
// Création d'un nouveau DocumentBuilder
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
|
||||
// Parsing de la chaîne XML contenue dans fileContent
|
||||
Document fileDoc = dBuilder.parse(new InputSource(new StringReader(fileContent)));
|
||||
|
||||
// Ajout de tous les nœuds du document parsé dans le nouveau document
|
||||
NodeList nodes = fileDoc.getDocumentElement().getChildNodes();
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Node importedNode = doc.importNode(nodes.item(i), true);
|
||||
fileElement.appendChild(importedNode);
|
||||
}
|
||||
|
||||
root.appendChild(fileElement);
|
||||
|
||||
}
|
||||
zipEntry = zis.getNextEntry();
|
||||
}
|
||||
|
||||
zis.closeEntry();
|
||||
zis.close();
|
||||
|
||||
noeud A = XMLParser.parse(doc);
|
||||
// Suppression des nodes qui sont en doublon et qui sont présents dans file.
|
||||
A.removeChild("office:styles");
|
||||
A.removeChild("office:automatic-styles");
|
||||
A.removeChild("office:body");
|
||||
|
||||
graphics.addAllChild(A.getChildren());
|
||||
|
||||
return graphics;
|
||||
|
||||
}
|
||||
}
|
77
src/baseUFRHG/base.java
Normal file
77
src/baseUFRHG/base.java
Normal file
@ -0,0 +1,77 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
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.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class base {
|
||||
|
||||
/**
|
||||
* Création d'une nouvelle base de données.
|
||||
* Enregistrement de la base de données dans le dossier de l'application.
|
||||
* @throws IOException
|
||||
*/
|
||||
public static noeud createBase() {
|
||||
noeud nBase = new noeud("base");
|
||||
|
||||
Date aujourdhui = new Date();
|
||||
nBase.setAttribut("date_creation",DateEnClairFR(aujourdhui));
|
||||
nBase.setAttribut("date_derniere_modification",DateEnClairFR(aujourdhui));
|
||||
|
||||
String defaultValue = "2022-2023";
|
||||
String userInput = JOptionPane.showInputDialog("Quelle est l'année universitaire ? ",defaultValue);
|
||||
|
||||
userInput = "Years_" + supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(userInput);
|
||||
|
||||
if(!userInput.isBlank()) {
|
||||
nBase.addChild(new noeud(userInput));
|
||||
nBase.setAttribut("defaut_Year", userInput);
|
||||
|
||||
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";
|
||||
Path outputFilePath = Paths.get(directoryName);
|
||||
try {
|
||||
BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8);
|
||||
fichier.write(nBase.toWrite());
|
||||
fichier.close();
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><p>La base de données a été créée.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return nBase;
|
||||
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(null, "Erreur détectée !", "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* La date sous forme de String en claire.
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static String DateEnClairFR(Date date) {
|
||||
SimpleDateFormat simpledateformat = new SimpleDateFormat("EEEE dd MMM yyy' à 'hh:mm:ss");
|
||||
String d1 = simpledateformat.format(date);
|
||||
|
||||
return d1;
|
||||
}
|
||||
|
||||
}
|
52
src/baseUFRHG/createEvaluation.java
Normal file
52
src/baseUFRHG/createEvaluation.java
Normal file
@ -0,0 +1,52 @@
|
||||
package baseUFRHG;
|
||||
|
||||
/**
|
||||
* Cette class permet de créer le noeud évaluation.
|
||||
* @author pabr6
|
||||
*
|
||||
*/
|
||||
public class createEvaluation {
|
||||
|
||||
noeud analyseCalc;
|
||||
|
||||
public noeud getAnalyseCalc() {
|
||||
return analyseCalc;
|
||||
}
|
||||
|
||||
public void setAnalyseCalc(noeud evaluation) {
|
||||
this.analyseCalc = evaluation;
|
||||
}
|
||||
|
||||
public createEvaluation(noeud rootContent, noeud rootStyles, noeud rootMeta, noeud graphics, String filenameFichier){
|
||||
|
||||
// création du premier noeud contenant tous les espaces de nom.
|
||||
// analyseCalc = createNoeudAnalyseCalc.entete();
|
||||
|
||||
// création et ajoute le noeud analyseCalc au premier noeud.
|
||||
// noeud evaluation = new createNoeudEvaluation().getEvaluation();
|
||||
|
||||
// Ajoute le noeud evaluation au noeud analyseCalc
|
||||
// analyseCalc.addChild(evaluation);
|
||||
|
||||
// création et assemblage du noeud fichier.
|
||||
// assemblageEtCreationNoeudFichier createFichier = new assemblageEtCreationNoeudFichier(rootContent, rootStyles, rootMeta, graphics, use, filenameFichier);
|
||||
|
||||
// Création du noeud csv
|
||||
// noeud csv = new noeud("csv");
|
||||
// csv.setAttribut("encoding", "UTF-8");
|
||||
// csv.setAttribut("separator", ";");
|
||||
// csv.setAttribut("nom", "nom");
|
||||
// csv.setAttribut("prenom", "prenom");
|
||||
// csv.setAttribut("identifiant", "identifiant");
|
||||
// csv.setAttribut("email", "email");
|
||||
|
||||
|
||||
// Assemblage du noeud evaluation
|
||||
// evaluation.addChild(createFichier.getFichier());
|
||||
// evaluation.addChild(csv);
|
||||
//
|
||||
// commandes.initialise();
|
||||
|
||||
}
|
||||
|
||||
}
|
132
src/baseUFRHG/demarre.java
Normal file
132
src/baseUFRHG/demarre.java
Normal file
@ -0,0 +1,132 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.SystemColor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
public class demarre extends JFrame {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JFrame frmEvalwriter;
|
||||
JButton btnCreate;
|
||||
JButton actCharge;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
demarre window = new demarre();
|
||||
window.frmEvalwriter.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public demarre() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
/**
|
||||
* Initialize the contents of the frame.
|
||||
*/
|
||||
private void initialize() {
|
||||
frmEvalwriter = new JFrame();
|
||||
frmEvalwriter.setResizable(false);
|
||||
frmEvalwriter.setTitle("Gestion des inscriptions et des groupes - langues - informatique - stage - rentrée");
|
||||
frmEvalwriter.setBounds(100, 100, 607, 438);
|
||||
int screenWidth = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth();
|
||||
int screenHeight = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight();
|
||||
frmEvalwriter.setLocation(( (screenWidth) - frmEvalwriter.getWidth()) / 2, (screenHeight - frmEvalwriter.getHeight()) / 2);
|
||||
|
||||
frmEvalwriter.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frmEvalwriter.getContentPane().setLayout(null);
|
||||
// ImageIcon img = new ImageIcon(demarre.class.getResource("/resources/evalcalc.png"));
|
||||
// frmEvalwriter.setIconImage(img.getImage());
|
||||
|
||||
btnCreate = new JButton("Exporter base dans classeur MS Excel");
|
||||
btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/renommeEvaluaton.png")));
|
||||
btnCreate.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
noeud nBase = recupeBases.recupeLaBase();
|
||||
//Exporte la base dans un classeur Excel.
|
||||
exportBaseToExcel.export(nBase);
|
||||
}
|
||||
});
|
||||
btnCreate.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
btnCreate.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
// btnCreate.addActionListener(this);
|
||||
|
||||
btnCreate.setBounds(10, 180, 571, 60);
|
||||
frmEvalwriter.getContentPane().add(btnCreate);
|
||||
|
||||
actCharge = new JButton("Importer des inscriptions depuis CSV (UTF-8, point-virgule)");
|
||||
actCharge.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
lecture.lect();
|
||||
}
|
||||
});
|
||||
actCharge.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
actCharge.setIcon(new ImageIcon(demarre.class.getResource("/resources/chargehistoriqueevaluation.png")));
|
||||
actCharge.setBackground(SystemColor.inactiveCaption);
|
||||
// actCharge.addActionListener(this);
|
||||
actCharge.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
actCharge.setBounds(10, 109, 571, 60);
|
||||
frmEvalwriter.getContentPane().add(actCharge);
|
||||
|
||||
JLabel lblNewLabel = new JLabel();
|
||||
// lblNewLabel.setIcon(new ImageIcon(demarre.class.getResource("/resources/accueilanalysecalc.png")));
|
||||
lblNewLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
lblNewLabel.setFont(new Font("Pacifico", Font.PLAIN, 26));
|
||||
lblNewLabel.setBounds(10, 25, 571, 74);
|
||||
frmEvalwriter.getContentPane().add(lblNewLabel);
|
||||
|
||||
JButton btnNewButton = new JButton("Modifier la base depuis classeur MS Excel");
|
||||
btnNewButton.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
btnNewButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
btnNewButton.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
// btnNewButton.setIcon(new ImageIcon(demarre.class.getResource("/resources/apropos.png")));
|
||||
btnNewButton.setBounds(10, 258, 571, 60);
|
||||
frmEvalwriter.getContentPane().add(btnNewButton);
|
||||
|
||||
JButton btnTutoriels = new JButton("Modifier la base depuis le gestionnaire");
|
||||
btnTutoriels.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
String url = "https://www.youtube.com/channel/UCG3tJWp_oZvOumH5kWUJ55g";
|
||||
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
|
||||
}
|
||||
catch (java.io.IOException e1) {
|
||||
System.out.println(e1.getMessage());
|
||||
}
|
||||
System.out.println( "Affiche les tutoriels." );
|
||||
}
|
||||
});
|
||||
// btnTutoriels.setIcon(new ImageIcon(demarre.class.getResource("/resources/tutoriel.png")));
|
||||
btnTutoriels.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
btnTutoriels.setFont(new Font("Arial", Font.BOLD, 16));
|
||||
btnTutoriels.setBounds(10, 328, 571, 60);
|
||||
frmEvalwriter.getContentPane().add(btnTutoriels);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
87
src/baseUFRHG/exportBaseToExcel.java
Normal file
87
src/baseUFRHG/exportBaseToExcel.java
Normal file
@ -0,0 +1,87 @@
|
||||
package baseUFRHG;
|
||||
|
||||
public class exportBaseToExcel {
|
||||
|
||||
|
||||
public static void export(noeud nBase) {
|
||||
|
||||
// Données pour les colonnes A et B
|
||||
Object[][] data = new Object[nBase.getChild(nBase.getAttributes("defaut_Year")).getNumberChildren()][28];
|
||||
|
||||
int indexFormation = 0 ;
|
||||
for(noeud formation : nBase.getChild(nBase.getAttributes("defaut_Year")).getChildren()) {
|
||||
data[indexFormation][0] = formation.getName();
|
||||
data[indexFormation][1] = "Individu_-_Code_Etudiant";
|
||||
data[indexFormation][2] = "Individu_-_Prenom";
|
||||
data[indexFormation][3] = "Individu_-_Nom";
|
||||
data[indexFormation][4] = "Profil_etudiant_lib.";
|
||||
data[indexFormation][5] = "Individu_-_Tel._portable";
|
||||
data[indexFormation][6] = "Individu_-_Email_personnel";
|
||||
data[indexFormation][7] = "Individu_-_Email";
|
||||
data[indexFormation][8] = "Groupe";
|
||||
data[indexFormation][9] = "Groupe_Principal";
|
||||
data[indexFormation][10] = "Groupe_TD";
|
||||
data[indexFormation][11] = "Groupe_Langue";
|
||||
data[indexFormation][12] = "LV1";
|
||||
data[indexFormation][13] = "LV2";
|
||||
data[indexFormation][14] = "Groupe_Informatique";
|
||||
data[indexFormation][15] = "Atelier-rentree_horaire";
|
||||
data[indexFormation][16] = "Atelier_pre-rentree_enseignant";
|
||||
data[indexFormation][17] = "Atelier_pre-rentree_salle";
|
||||
data[indexFormation][18] = "UE_Libre";
|
||||
data[indexFormation][19] = "Covoiturage";
|
||||
data[indexFormation][20] = "Etudiant_Covoiturage";
|
||||
data[indexFormation][21] = "Stage_1";
|
||||
data[indexFormation][22] = "Num_convention_1";
|
||||
data[indexFormation][23] = "Periode_1";
|
||||
data[indexFormation][24] = "Stage_2";
|
||||
data[indexFormation][25] = "Num_convention_2";
|
||||
data[indexFormation][26] = "Periode_2";
|
||||
|
||||
|
||||
String[][] data1 = new String[formation.getNumberChildren()][26];
|
||||
|
||||
int indexStudent = 0;
|
||||
for(noeud nStudent : formation.getChildren()) {
|
||||
data1[indexStudent][0] = nStudent.getAttributes("Individu_-_Code_Etudiant");
|
||||
data1[indexStudent][1] = nStudent.getAttributes("Individu_-_Prenom");
|
||||
data1[indexStudent][2] = nStudent.getAttributes("Individu_-_Nom");
|
||||
data1[indexStudent][3] = nStudent.getAttributes("Profil_etudiant_lib.");
|
||||
data1[indexStudent][4] = nStudent.getAttributes("Individu_-_Tel._portable");
|
||||
data1[indexStudent][5] = nStudent.getAttributes("Individu_-_Email_personnel");
|
||||
data1[indexStudent][6] = nStudent.getAttributes("Individu_-_Email");
|
||||
data1[indexStudent][7] = nStudent.getAttributes("Groupe");
|
||||
data1[indexStudent][8] = nStudent.getAttributes("Groupe_Principal");
|
||||
data1[indexStudent][9] = nStudent.getAttributes("Groupe_TD");
|
||||
data1[indexStudent][10] = nStudent.getAttributes("Groupe_Langue");
|
||||
data1[indexStudent][11] = nStudent.getAttributes("LV1");
|
||||
data1[indexStudent][12] = nStudent.getAttributes("LV2");
|
||||
data1[indexStudent][13] = nStudent.getAttributes("Groupe_Informatique");
|
||||
data1[indexStudent][14] = nStudent.getAttributes("Atelier-rentree_horaire");
|
||||
data1[indexStudent][15] = nStudent.getAttributes("Atelier_pre-rentree_enseignant");
|
||||
data1[indexStudent][16] = nStudent.getAttributes("Atelier_pre-rentree_salle");
|
||||
data1[indexStudent][17] = nStudent.getAttributes("UE_Libre");
|
||||
data1[indexStudent][18] = nStudent.getAttributes("Covoiturage");
|
||||
data1[indexStudent][19] = nStudent.getAttributes("Etudiant_Covoiturage");
|
||||
data1[indexStudent][20] = nStudent.getAttributes("Stage_1");
|
||||
data1[indexStudent][21] = nStudent.getAttributes("Num_convention_1");
|
||||
data1[indexStudent][22] = nStudent.getAttributes("Periode_1");
|
||||
data1[indexStudent][23] = nStudent.getAttributes("Stage_2");
|
||||
data1[indexStudent][24] = nStudent.getAttributes("Num_convention_2");
|
||||
data1[indexStudent][25] = nStudent.getAttributes("Periode_2");
|
||||
|
||||
|
||||
data[indexFormation][27] = data1;
|
||||
indexStudent++;
|
||||
}
|
||||
|
||||
indexFormation++;
|
||||
}
|
||||
|
||||
new CreateCalcWorkbookExample(data);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
74
src/baseUFRHG/lecture.java
Normal file
74
src/baseUFRHG/lecture.java
Normal file
@ -0,0 +1,74 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class lecture {
|
||||
|
||||
|
||||
public static void lect() {
|
||||
|
||||
|
||||
noeud noeudCSV = null;
|
||||
|
||||
noeud nBase = recupeBases.recupeLaBase();
|
||||
|
||||
|
||||
|
||||
// lecture et création d'un noeud à partir d'un fichier CSV
|
||||
try {
|
||||
File fileData = FileChooserCSV.retourneFileCSV();
|
||||
if(fileData!=null) {
|
||||
String filePath = fileData.getAbsolutePath();
|
||||
noeudCSV = lectureCSV.noeudCSV(filePath);
|
||||
|
||||
// try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
||||
// new FileOutputStream("C:\\Users\\pabr6\\OneDrive\\Documents\\corrine rapicault - inscriptions\\fichier.xml"), StandardCharsets.UTF_8))) {
|
||||
// writer.write(noeudCSV.toWrite());
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// ajoute les étudiants qui n'existent pas, dans la base.
|
||||
nBase = majBase.addStudents(nBase,noeudCSV);
|
||||
|
||||
// //Exporte la base dans un classeur Excel.
|
||||
// exportBaseToExcel.export(nBase);
|
||||
|
||||
// String directoryName = Paths.get("").toAbsolutePath().toString() + "/base.xml";
|
||||
// try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
||||
// new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
|
||||
// writer.write(nBase.toWrite());
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// System.out.println(nBase.toWrite());
|
||||
//
|
||||
//
|
||||
// // lecture et création d'un noeud à partir d'un fichier XML
|
||||
// try {
|
||||
// File fileData = FileChooserXML.retourneFileXML();
|
||||
//
|
||||
// if(fileData!=null) {
|
||||
// String filePath = fileData.getAbsolutePath();
|
||||
// String xmlString = lectureFileToString.lecture(filePath);
|
||||
// noeud noeud1 = lectureXML.lectureStringToNoeud(xmlString);
|
||||
// System.out.println(noeud1.toWrite());
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
79
src/baseUFRHG/lectureCSV.java
Normal file
79
src/baseUFRHG/lectureCSV.java
Normal file
@ -0,0 +1,79 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class lectureCSV {
|
||||
|
||||
|
||||
public static noeud noeudCSV(String path){
|
||||
String line;
|
||||
String csvSplitBy = ";";
|
||||
noeud donne = new noeud("data");
|
||||
|
||||
// try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(path),"UTF-8"))) {
|
||||
|
||||
String encoding = FileEncodingDetector.EncodingFile(path);
|
||||
if(encoding!=null) {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(path), encoding))) {
|
||||
|
||||
noeud Head = new noeud("head");
|
||||
|
||||
|
||||
boolean entete = true;
|
||||
int compteurLine = 1 ;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] data = line.split(csvSplitBy);
|
||||
if(entete) {
|
||||
entete = false;
|
||||
int compteur = 0 ;
|
||||
for (String value : data) {
|
||||
value = supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(value);
|
||||
Head.setAttribut("C"+String.valueOf(compteur), value);
|
||||
compteur++;
|
||||
}
|
||||
donne.addChild(Head);
|
||||
}else {
|
||||
int compteur = 0 ;
|
||||
noeud d = new noeud("ligne_" + compteurLine);
|
||||
for (String value : data) {
|
||||
// value = supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(value);
|
||||
d.setAttribut(Head.getAttributes("C"+String.valueOf(compteur)), value);
|
||||
compteur++;
|
||||
}
|
||||
donne.addChild(d);
|
||||
}
|
||||
compteurLine++;
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel(e.toString());
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
JFrame frame = new JFrame();
|
||||
JLabel texte = new JLabel("<html><p>L'encodage du fichier n'est pas correct.</p>"
|
||||
+ "<p>Encoder votre fichier en UTF-8.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
return null;
|
||||
}
|
||||
|
||||
return donne;
|
||||
}
|
||||
|
||||
|
||||
}
|
28
src/baseUFRHG/lectureFileToString.java
Normal file
28
src/baseUFRHG/lectureFileToString.java
Normal file
@ -0,0 +1,28 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class lectureFileToString {
|
||||
|
||||
public static String lecture(String filePath) {
|
||||
String xmlString = "";
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"))) {
|
||||
StringBuilder content = new StringBuilder();
|
||||
String line;
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
content.append(line).append("\n");
|
||||
}
|
||||
|
||||
xmlString = content.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return xmlString;
|
||||
}
|
||||
|
||||
}
|
90
src/baseUFRHG/lectureXML.java
Normal file
90
src/baseUFRHG/lectureXML.java
Normal file
@ -0,0 +1,90 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringReader;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class lectureXML {
|
||||
|
||||
|
||||
public static noeud lectureFileXMLToNoeud(File fileData) {
|
||||
String filePath = fileData.getAbsolutePath();
|
||||
|
||||
String xmlString = "";
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"))) {
|
||||
StringBuilder content = new StringBuilder();
|
||||
String line;
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
content.append(line).append("\n");
|
||||
}
|
||||
|
||||
xmlString = content.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder;
|
||||
noeud noeud1 = null;
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
|
||||
// Créer un objet InputSource à partir de la chaîne XML
|
||||
InputSource inputSource = new InputSource(new StringReader(xmlString));
|
||||
|
||||
// Parser la chaîne XML pour obtenir un objet Document
|
||||
Document document;
|
||||
|
||||
document = builder.parse(inputSource);
|
||||
|
||||
noeud1 = XMLParser.parse(document);
|
||||
|
||||
|
||||
} catch (ParserConfigurationException | SAXException | IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return noeud1;
|
||||
}
|
||||
|
||||
public static noeud lectureStringToNoeud(String xmlString) {
|
||||
|
||||
noeud noeud1 = null;
|
||||
try {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
// Créer un objet InputSource à partir de la chaîne XML
|
||||
InputSource inputSource = new InputSource(new StringReader(xmlString));
|
||||
|
||||
// Parser la chaîne XML pour obtenir un objet Document
|
||||
Document document = builder.parse(inputSource);
|
||||
|
||||
//création du noeud
|
||||
noeud1 = XMLParser.parse(document);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return noeud1;
|
||||
}
|
||||
}
|
126
src/baseUFRHG/majBase.java
Normal file
126
src/baseUFRHG/majBase.java
Normal file
@ -0,0 +1,126 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class majBase {
|
||||
|
||||
static int compteurAddStudent = 0 ;
|
||||
static String defaut_Year = null;
|
||||
|
||||
public static noeud addStudents(noeud nBase, noeud nCSV) {
|
||||
compteurAddStudent = 0;
|
||||
defaut_Year = nBase.getAttributes("defaut_Year");
|
||||
|
||||
for(int i = 0 ; i < nCSV.getChildren().size();i++) {
|
||||
|
||||
if(nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib.")!=null) {
|
||||
if(!nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib.").isBlank()) {
|
||||
if(!isExisteFormationIntoBase(nBase, nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib."))) {
|
||||
nBase.getChild(defaut_Year).addChild(new noeud( supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nCSV.getChildren().get(i).getAttributes("IAE_-_Etape_lib."))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nBase = majStudentIntoBase(nBase,nCSV.getChildren().get(i));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Sauvegarde de la base
|
||||
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";
|
||||
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
|
||||
writer.write(nBase.toWrite());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Affiche le nombre d'étudiant ajouté à la base.
|
||||
JOptionPane.showMessageDialog(null, "Nombre d'étudiant ajouté à la base : " + String.valueOf(compteurAddStudent));
|
||||
|
||||
return nBase;
|
||||
}
|
||||
|
||||
private static boolean isExisteFormationIntoBase(noeud nBase , String attribut) {
|
||||
if(defaut_Year!=null) {
|
||||
if(nBase.getChild(defaut_Year).getChild(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(attribut))!=null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isValidEightDigits(String input) {
|
||||
return input.matches("\\d{8}");
|
||||
}
|
||||
|
||||
|
||||
private static noeud majStudentIntoBase(noeud nBase, noeud nStudent) {
|
||||
if (nStudent.getAttributes("IAE_-_Etape_lib.")!=null && nStudent.getAttributes("Individu_-_Code_Etudiant")!=null){
|
||||
|
||||
if(isValidEightDigits(nStudent.getAttributes("Individu_-_Code_Etudiant")) && !nStudent.getAttributes("IAE_-_Etape_lib.").isBlank() ) {
|
||||
if(isExisteFormationIntoBase(nBase, nStudent.getAttributes("IAE_-_Etape_lib."))) {
|
||||
|
||||
noeud nBF = nBase.getChild(defaut_Year).getChild(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nStudent.getAttributes("IAE_-_Etape_lib.")));
|
||||
|
||||
if(nBF.getChild("n"+nStudent.getAttributes("Individu_-_Code_Etudiant"))==null) {
|
||||
|
||||
noeud n = new noeud("n" + nStudent.getAttributes("Individu_-_Code_Etudiant"));
|
||||
|
||||
if(nStudent.getAttributes("Individu_-_Nom")!=null) n.setAttribut("Individu_-_Nom", nStudent.getAttributes("Individu_-_Nom"));
|
||||
if(nStudent.getAttributes("Individu_-_Prenom")!=null) n.setAttribut("Individu_-_Prenom", nStudent.getAttributes("Individu_-_Prenom"));
|
||||
if(nStudent.getAttributes("Individu_-_Email_personnel")!=null) n.setAttribut("Individu_-_Email_personnel", nStudent.getAttributes("Individu_-_Email_personnel"));
|
||||
if(nStudent.getAttributes("Individu_-_Tel._portable")!=null) n.setAttribut("Individu_-_Tel._portable", nStudent.getAttributes("Individu_-_Tel._portable"));
|
||||
if(nStudent.getAttributes("Profil_etudiant_lib.")!=null) n.setAttribut("Profil_etudiant_lib.", nStudent.getAttributes("Profil_etudiant_lib."));
|
||||
if(nStudent.getAttributes("Individu_-_Email")!=null) n.setAttribut("Individu_-_Email", nStudent.getAttributes("Individu_-_Email"));
|
||||
if(nStudent.getAttributes("Bac_ou_quivalence_lib.")!=null) n.setAttribut("Bac_ou_quivalence_lib.", nStudent.getAttributes("Bac_ou_quivalence_lib."));
|
||||
if(nStudent.getAttributes("Bac_-_Anne_dobtention")!=null) n.setAttribut("Bac_-_Anne_dobtention", nStudent.getAttributes("Bac_-_Anne_dobtention"));
|
||||
|
||||
|
||||
n.setAttribut("Individu_-_Code_Etudiant",nStudent.getAttributes("Individu_-_Code_Etudiant"));
|
||||
n.setAttribut("IAE_-_Etape_lib.",nStudent.getAttributes("IAE_-_Etape_lib."));
|
||||
|
||||
n.setAttribut("Groupe_Principal","");
|
||||
n.setAttribut("Groupe_Informatique","");
|
||||
n.setAttribut("Groupe_TD","");
|
||||
n.setAttribut("Groupe_Langue","");
|
||||
n.setAttribut("Groupe_Doc","");
|
||||
n.setAttribut("Groupe_Projet","");
|
||||
n.setAttribut("Covoiturage","non");
|
||||
n.setAttribut("Etudiant_Covoiturage","");
|
||||
n.setAttribut("LV1","");
|
||||
n.setAttribut("LV2","");
|
||||
n.setAttribut("UE_Libre","");
|
||||
n.setAttribut("Option","");
|
||||
n.setAttribut("Stage_1","");
|
||||
n.setAttribut("Num_convention_1","");
|
||||
n.setAttribut("Periode_1","");
|
||||
n.setAttribut("Stage_2","");
|
||||
n.setAttribut("Num_convention_2","");
|
||||
n.setAttribut("Periode_2","");
|
||||
n.setAttribut("Information","");
|
||||
n.setAttribut("Atelier-rentree_horaire","");
|
||||
n.setAttribut("Atelier_pre-rentree_enseignant","");
|
||||
n.setAttribut("Atelier_pre-rentree_salle","");
|
||||
|
||||
// nBase.getChild(defaut_Year).getChild(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(nStudent.getAttributes("IAE_-_Etape_lib."))).addChild(n);
|
||||
nBF.addChild(n);
|
||||
nBF.setAttribut("number_Student",String.valueOf(nBF.getNumberChildren()));
|
||||
compteurAddStudent++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return nBase;
|
||||
}
|
||||
|
||||
}
|
1143
src/baseUFRHG/noeud.java
Normal file
1143
src/baseUFRHG/noeud.java
Normal file
File diff suppressed because it is too large
Load Diff
46
src/baseUFRHG/recupeBases.java
Normal file
46
src/baseUFRHG/recupeBases.java
Normal file
@ -0,0 +1,46 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class recupeBases {
|
||||
|
||||
/**
|
||||
* Récupère la base des évaluations qui se trouve indiqué par commandes.PathBaseEvaluationDefaut ou commandes.PathBaseEvaluations.
|
||||
*/
|
||||
public static noeud recupeLaBase() {
|
||||
String filePath = "base.xml";
|
||||
File file = new File(filePath);
|
||||
noeud nBase = null;
|
||||
|
||||
|
||||
if (file.exists()) {
|
||||
//lecture du fichier base.xml
|
||||
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";
|
||||
String xmlString = lectureFileToString.lecture(directoryName);
|
||||
nBase = lectureXML.lectureStringToNoeud(xmlString);
|
||||
|
||||
} else {
|
||||
|
||||
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>Une nouvelle base de données a été créée dans le dossier de l'application.</p>"
|
||||
+ "<p>La base de données se trouve dans le fichier \"base.xml\".</p>"
|
||||
+ "<p></p>"
|
||||
+ "<p>Vous allez devoir saisir l'année universitaire pour débuter et créer la base.</p></html>");
|
||||
JOptionPane.showMessageDialog(frame, texte);
|
||||
|
||||
// création d'une nouvelle base
|
||||
nBase = base.createBase();
|
||||
}
|
||||
|
||||
return nBase;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
21
src/baseUFRHG/supprimeCaracatresSpeciaux.java
Normal file
21
src/baseUFRHG/supprimeCaracatresSpeciaux.java
Normal file
@ -0,0 +1,21 @@
|
||||
package baseUFRHG;
|
||||
|
||||
import java.text.Normalizer;
|
||||
|
||||
public class supprimeCaracatresSpeciaux {
|
||||
|
||||
static String TousLesCaracatresSpeciaux(String str) {
|
||||
// Supprimer les accents
|
||||
String normalizedStr = Normalizer.normalize(str, Normalizer.Form.NFD);
|
||||
String accentRemovedStr = normalizedStr.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
|
||||
|
||||
// Supprimer les caractères spéciaux
|
||||
String specialCharRemovedStr = accentRemovedStr.replaceAll("[^a-zA-Z0-9@\\_\\-\\. ]", "");
|
||||
|
||||
//Replace tous les espaces par des underscore
|
||||
String replaceSpace = specialCharRemovedStr.replaceAll(" ","_");
|
||||
|
||||
return replaceSpace;
|
||||
}
|
||||
|
||||
}
|
BIN
src/resources/chargehistoriqueevaluation.png
Normal file
BIN
src/resources/chargehistoriqueevaluation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
src/resources/fichierAnalyseModif.png
Normal file
BIN
src/resources/fichierAnalyseModif.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
src/resources/renommeEvaluaton.png
Normal file
BIN
src/resources/renommeEvaluaton.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
Loading…
Reference in New Issue
Block a user