Merge branch 'main' into Nico_Creation_Methodes_vides

This commit is contained in:
name 2021-02-01 18:45:11 +01:00
commit 2809852a87
76 changed files with 1776 additions and 162 deletions

View file

@ -1,19 +1,93 @@
package fr.myny.data;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* Classe d'extraction de fichier Zip
*/
public class DataCsv {
protected String destination;
/**
* Le constructeur de DataCsv
* Constructeur par defaut
* @throws IOException
*/
public DataCsv(){
public DataCsv() throws IOException {
this.destination = "src/main/resources/Download";
ImportData imp = new ImportData("https://www.fdj.fr/jeux-de-tirage/loto/statistiques", this.destination);
}
/**
* Constructeur avec parametre
* @param s repertoire de destination
* @throws IOException
*/
public DataCsv(String s) throws IOException {
this.destination = s;
ImportData imp = new ImportData("https://www.fdj.fr/jeux-de-tirage/loto/statistiques", this.destination);
for (String name : imp.tabNameZip) {
name = this.destination.concat(name);
getCsv(name);
}
}
/**
* La methode de recuperation dun fichier csv
* @param fileZip : nom suivit du chemin du fichier zip
*/
public void getCsv(){
private void getCsv(String fileZip) throws IOException{
File desDir = new File(destination);
byte[] buffer = new byte[1024];
ZipInputStream zis = new ZipInputStream(new FileInputStream(fileZip));
ZipEntry zipEntry = zis.getNextEntry();
while (zipEntry != null){
File newFile = newFile(desDir, zipEntry);
if (zipEntry.isDirectory()){
if (!newFile.isDirectory() && !newFile.mkdirs()){
throw new IOException("Failed to create directory " + newFile);
}
} else{
File parent = newFile.getParentFile();
if (!parent.isDirectory() && !parent.mkdirs()) {
throw new IOException("Failed to create directory " + parent);
}
FileOutputStream fos = new FileOutputStream(newFile);
int len;
while ((len = zis.read(buffer)) > 0){
fos.write(buffer, 0, len);
}
fos.close();
}
zipEntry = zis.getNextEntry();
}
zis.closeEntry();
zis.close();
}
/**
* Methode verifiant si l extraction a bien ete faite
* @param destinationDir : chemin de destination
* @param zipEntry : zip cible
*/
public File newFile(File destinationDir, ZipEntry zipEntry) throws IOException{
File destFile = new File(destinationDir, zipEntry.getName());
String destDirPath = destinationDir.getCanonicalPath();
String destFilePath = destFile.getCanonicalPath();
if (!destFilePath.startsWith(destDirPath + File.separator)){
throw new IOException("Entry is outside of the target dir: " + zipEntry.getName());
}
return destFile;
}
}

View file

@ -1,25 +1,103 @@
package fr.myny.data;
import java.io.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.ArrayList;
public class ImportData {
String url;
protected String url;
protected String repDes;
public ArrayList<String> tabNameZip;
/**
* Le constructeur de ImportData
* Constructeur par defaut
*/
public ImportData(){
ImportData(){
this.url = "https://www.fdj.fr/jeux-de-tirage/loto/statistiques";
this.repDes = "src/main/resources/Download/";
tabNameZip = new ArrayList<>();
DownloadCsvZip();
}
/**
* Le constructeur de ImportData
* @param url string contenant l URL dou recuperer les fichiers csv
* Constructeur avec parametres
* @param url contient l'URL dou recuperer les fichiers csv
* @param des respertoire de destination
*/
public ImportData(String url){
public ImportData(String url, String des){
this.url=url;
this.repDes = des;
tabNameZip = new ArrayList<>();
DownloadCsvZip();
}
/**
* La methode de recuperation de l URL
* Méthode permettant de tester si l'URL est valide
* @return true si l'URL est valide si non false
*/
public void getUrl(){
private boolean UrlExist() {
try {
URL site = new URL(url);
try {
site.openStream();
return true;
} catch (IOException e) {
return false;
}
} catch (MalformedURLException e) {
return false;
}
}
/**
* Méthode permettant de télécharger un fichier à partir d'un URL
*/
public void DownloadCsvZip() {
if (UrlExist()) {
BufferedReader in = null;
try {
URL site = new URL(url);
in = new BufferedReader(new InputStreamReader(site.openStream()));
String test = "loto_";
String nameZip;
String urlZipLink;
while ((urlZipLink = in.readLine()) != null) {
if (urlZipLink.length() > 128) {
if (test.equals(urlZipLink.substring(50, 55))) {
nameZip = urlZipLink.substring(50,65);
tabNameZip.add(nameZip);
urlZipLink = urlZipLink.substring(13,65);
try (BufferedInputStream bis = new BufferedInputStream(new URL(urlZipLink).openStream());
FileOutputStream fos = new FileOutputStream(repDes + nameZip)) {
byte data[] = new byte[1024];
int byteContent;
while ((byteContent = bis.read(data, 0, 1024)) != -1) {
fos.write(data, 0, byteContent);
}
} catch (IOException e) {
e.printStackTrace(System.out);
}
}
}
}
in.close();
} catch (IOException e) {
System.out.println("Error URL can't open : " + e);
}
finally {
try {
in.close();
} catch (IOException e) {
System.out.println("Error close buffer : " + e);
}
}
}
else
System.out.println("Web sit don't exist");
}
}

View file

@ -1,24 +0,0 @@
package fr.myny.grid;
public class BuildGrid {
/**
* Le constructeur de BuildGrid
*/
public BuildGrid(){
}
/**
* La methode de recuperation de la grille
*/
public void getGrid(){
}
/**
* La methode de demande du systeme reducteur
*/
public void ReductorSys(){
}
}

View file

@ -0,0 +1,74 @@
package fr.myny.gui;
import javafx.fxml.FXML;
import java.io.IOException;
/**
* Classe permettant l'execution des fonctionnalités de l'application via les autres packages data, database, grid et stats.
*/
public class ButtonController {
/**
* Execution de la méthode de téléchargement de toutes les données automatiquement et met à jour la base de données
* @throws IOException
*/
@FXML
private void controllerAutoTirage() throws IOException {
}
/**
* Execution de la méthode de téléchargement des dernières données automatiquement et met à jour la base de données
* @throws IOException
*/
@FXML
private void controllerAutoDernierTirage() throws IOException {
}
/**
* Demande à l'utilisateur de sélectionner un fichier CSV via l'explorateur des fichiers et met à jour la base de données
* @throws IOException
*/
@FXML
private void controllerGetCSVFile() throws IOException {
}
/**
* Appelle la méthode d'affichage des statistiques des fréquences d'apparitions d'un nombre
* @throws IOException
*/
@FXML
private void checkBoxNumeros() throws IOException {
}
/**
* Appelle la méthode d'affichage des statistiques des fréquences d'apparitions de combinaison de 2 chiffres
* @throws IOException
*/
@FXML
private void checkBox2Numeros() throws IOException {
}
/**
* Appelle la méthode d'affichage des statistiques des fréquences d'apparitions de combinaison de 3 chiffres
* @throws IOException
*/
@FXML
private void checkBox3Numeros() throws IOException {
}
/**
* Appelle la méthode d'affichage des statistiques des fréquences d'apparitions d'un nombre bonus
* @throws IOException
*/
@FXML
private void checkBoxNumerosBonus() throws IOException {
}
}

View file

@ -0,0 +1,80 @@
package fr.myny.gui;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ChoiceBox;
import java.net.URL;
import java.util.ResourceBundle;
/**
* Classe permettant d'initialiser et d'écouter le changement des ChoiceBox
*/
public class DocumentController implements Initializable {
/**
* ChoiceBox créé grâce à FXML
*/
private ChoiceBox<Integer> integerChoiceBox;
/**
*
* ChoiceBox créé grâce à FXML
*/
private ChoiceBox<String> stringChoiceBox;
/**
* Liste d'entier observable grâce à FX
*/
private ObservableList observableIntegerList;
/**
* Liste de chaîne de caractère observable grâce à FX
*/
private ObservableList observableStringList;
/**
* Initialisation de la première ChoiceBox du nombre de numéros voulu
* @param url Paramètre non utilisé mais obligatoire en argument
* @param resourceBundle Paramètre non utilisé mais obligatoire en argument
*/
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
}
/**
* Action lors d'un évenement concernant la garantie du système
* @param event Action de l'évenement
*/
@FXML
private void numberGuarantee(ActionEvent event){
}
/**
* Action lors d'un évenement concernant le nombre de numéros à jouer
* @param event Action de l'évenement
*/
@FXML
private void numberPlay(ActionEvent event){
}
/**
* Chargement de toutes les options garantie du systeme
*/
private void loadDataGuarantee(){
}
/**
* Chargement de toutes les options liés au nombre de numéro voulu
*/
private void loadDataNumbers(){
}
}

View file

@ -0,0 +1,498 @@
package fr.myny.gui;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
/**
* Classe permettant d'initaliser la grille de choix des nombres et d'écouter si l'un d'entre eux est sélectionné
*/
public class GridController implements Initializable {
/**
* Liste des nombres bonus sélectionnés
*/
ArrayList<Integer> bonusNumbersChecked;
/**
* Liste des nombres sélectionnés
*/
ArrayList<Integer> numbersChecked;
/**
* @param url
* @param resourceBundle
*/
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
}
/**
* Contrôleur du numéro bonus 1
*/
@FXML
private void numberBonusController1() throws IOException{
}
/**
* Contrôleur du numéro bonus 2
*/
@FXML
private void numberBonusController2() throws IOException{
}
/**
* Contrôleur du numéro bonus 3
*/
@FXML
private void numberBonusController3() throws IOException{
}
/**
* Contrôleur du numéro bonus 4
*/
@FXML
private void numberBonusController4() throws IOException{
}
/**
* Contrôleur du numéro bonus 5
*/
@FXML
private void numberBonusController5() throws IOException{
}
/**
* Contrôleur du numéro bonus 6
*/
@FXML
private void numberBonusController6() throws IOException{
}
/**
* Contrôleur du numéro bonus 7
*/
@FXML
private void numberBonusController7() throws IOException{
}
/**
* Contrôleur du numéro bonus 8
*/
@FXML
private void numberBonusController8() throws IOException{
}
/**
* Contrôleur du numéro bonus 9
*/
@FXML
private void numberBonusController9() throws IOException{
}
/**
* Contrôleur du numéro bonus 10
*/
@FXML
private void numberBonusController10() throws IOException {
}
/**
* Contrôleur du numéro 1
*/
@FXML
private void numberController1() throws IOException {
}
/**
* Contrôleur du numéro 2
*/
@FXML
private void numberController2() throws IOException {
}
/**
* Contrôleur du numéro 3
*/
@FXML
private void numberController3() throws IOException {
}
/**
* Contrôleur du numéro 4
*/
@FXML
private void numberController4() throws IOException {
}
/**
* Contrôleur du numéro 5
*/
@FXML
private void numberController5() throws IOException {
}
/**
* Contrôleur du numéro 6
*/
@FXML
private void numberController6() throws IOException {
}
/**
* Contrôleur du numéro 7
*/
@FXML
private void numberController8() throws IOException {
}
/**
* Contrôleur du numéro 9
*/
@FXML
private void numberController9() throws IOException {
}
/**
* Contrôleur du numéro 10
*/
@FXML
private void numberController10() throws IOException {
}
/**
* Contrôleur du numéro 11
*/
@FXML
private void numberController11() throws IOException {
}
/**
* Contrôleur du numéro 12
*/
@FXML
private void numberController12() throws IOException {
}
/**
* Contrôleur du numéro 13
*/
@FXML
private void numberController13() throws IOException {
}
/**
* Contrôleur du numéro 14
*/
@FXML
private void numberController14() throws IOException {
}
/**
* Contrôleur du numéro 15
*/
@FXML
private void numberController15() throws IOException {
}
/**
* Contrôleur du numéro 16
*/
@FXML
private void numberController16() throws IOException {
}
/**
* Contrôleur du numéro 17
*/
@FXML
private void numberController17() throws IOException {
}
/**
* Contrôleur du numéro 18
*/
@FXML
private void numberController18() throws IOException {
}
/**
* Contrôleur du numéro 19
*/
@FXML
private void numberController19() throws IOException {
}
/**
* Contrôleur du numéro 20
*/
@FXML
private void numberController20() throws IOException {
}
/**
* Contrôleur du numéro 21
*/
@FXML
private void numberController21() throws IOException {
}
/**
* Contrôleur du numéro 22
*/
@FXML
private void numberController22() throws IOException {
}
/**
* Contrôleur du numéro 23
*/
@FXML
private void numberController23() throws IOException {
}
/**
* Contrôleur du numéro 24
*/
@FXML
private void numberController24() throws IOException {
}
/**
* Contrôleur du numéro 25
*/
@FXML
private void numberController25() throws IOException {
}
/**
* Contrôleur du numéro 26
*/
@FXML
private void numberController26() throws IOException {
}
/**
* Contrôleur du numéro 27
*/
@FXML
private void numberController27() throws IOException {
}
/**
* Contrôleur du numéro 28
*/
@FXML
private void numberController28() throws IOException {
}
/**
* Contrôleur du numéro 29
*/
@FXML
private void numberController29() throws IOException {
}
/**
* Contrôleur du numéro 30
*/
@FXML
private void numberController30() throws IOException {
}
/**
* Contrôleur du numéro 31
*/
@FXML
private void numberController31() throws IOException {
}
/**
* Contrôleur du numéro 32
*/
@FXML
private void numberController32() throws IOException {
}
/**
* Contrôleur du numéro 33
*/
@FXML
private void numberController33() throws IOException {
}
/**
* Contrôleur du numéro 34
*/
@FXML
private void numberController34() throws IOException {
}
/**
* Contrôleur du numéro 35
*/
@FXML
private void numberController35() throws IOException {
}
/**
* Contrôleur du numéro 36
*/
@FXML
private void numberController36() throws IOException {
}
/**
* Contrôleur du numéro 37
*/
@FXML
private void numberController37() throws IOException {
}
/**
* Contrôleur du numéro 38
*/
@FXML
private void numberController38() throws IOException {
}
/**
* Contrôleur du numéro 39
*/
@FXML
private void numberController39() throws IOException {
}
/**
* Contrôleur du numéro 40
*/
@FXML
private void numberController40() throws IOException {
}
/**
* Contrôleur du numéro 41
*/
@FXML
private void numberController41() throws IOException {
}
/**
* Contrôleur du numéro 42
*/
@FXML
private void numberController42() throws IOException {
}
/**
* Contrôleur du numéro 43
*/
@FXML
private void numberController43() throws IOException {
}
/**
* Contrôleur du numéro 44
*/
@FXML
private void numberController44() throws IOException {
}
/**
* Contrôleur du numéro 45
*/
@FXML
private void numberController45() throws IOException {
}
/**
* Contrôleur du numéro 46
*/
@FXML
private void numberController46() throws IOException {
}
/**
* Contrôleur du numéro 47
*/
@FXML
private void numberController47() throws IOException {
}
/**
* Contrôleur du numéro 48
*/
@FXML
private void numberController48() throws IOException {
}
/**
* Contrôleur du numéro 49
*/
@FXML
private void numberController49() throws IOException {
}
}

View file

@ -0,0 +1,33 @@
package fr.myny.gui;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class Gui extends Application {
private static Scene scene;
@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("primary"));
stage.setScene(scene);
stage.show();
}
static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}
private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(Gui.class.getResource(fxml + ".fxml"));
return fxmlLoader.load();
}
public static void main(String[] args) {
launch();
}
}

View file

@ -1,56 +0,0 @@
package fr.myny.gui;
public class Ihm {
/**
* Le constructeur de Ihm
*/
public Ihm(){
}
/**
* La methode de demande de mise a jour de la base de donnees
*/
public void update(){
}
/**
* La methode de demande de recuperation d'URL ???
*/
public void getUrl(){
}
/**
* La methode de demande de telechargement de donnees
*/
public void downloadData(){
}
/**
* La methode de demande daffichage de donness
*/
public void printStatistics(){
}
/**
* La methode de demande de generation dun fichier pdf avec des grilles proposees
*/
public void printGrid(){
}
/**
* La methode de demande daffichage de la table
*/
public void generateTable(){
}
}

View file

@ -0,0 +1,13 @@
package fr.myny.gui;
import javafx.fxml.FXML;
import java.io.IOException;
public class PrimaryController {
@FXML
private void switchToSecondary() throws IOException {
Gui.setRoot("secondary");
}
}

View file

@ -0,0 +1,13 @@
package fr.myny.gui;
import javafx.fxml.FXML;
import java.io.IOException;
public class SecondaryController {
@FXML
private void switchToPrimary() throws IOException {
Gui.setRoot("primary");
}
}