diff --git a/src/API.java b/src/API.java deleted file mode 100644 index 5292aee..0000000 --- a/src/API.java +++ /dev/null @@ -1,195 +0,0 @@ -/* -* [Proposition d'API.] -* Auteur : Bilal Boudjemline. -* Description : Proposition d'API pour le projet FIProjetIHM2022 dirigée par Florent Madelaine et Luc Hernandez. -* Fait le : 7 oct. 2022 a 22:20 -* */ - -/* -* Pourquoi est-elle efficace? -* -* Car elle est fonctionnelle dans tous les cas et les eleves n'auront besoin que de creer l'objet: -* API api = new API(); -* Puis utiliser les methodes fourni par cette derniere. EX : -* String prenom = api.getPrenom(2); -* System.out.println("->" + prenom); -* out: -> Prenom Selectionné. -* */ - -import java.util.ArrayList; - -public class API { - private final BDatabase sharedObject; - private final String TableDesComptes = "Comptes"; - private final String TableDesGroupes = "Groupes"; - private final String TableDesMembres = "Membres"; - private final String TableDesGrades = "Grades"; - private final String TableDesDemandes = "Demandes"; - - public API() { - BDatabase db = new BDatabase(); - this.sharedObject = db; - } - - // Retourne le nom de l'id entree - public String getNom(int id) { - return this.sharedObject.fetchAll( - "SELECT nom FROM " + this.TableDesMembres + " WHERE idCompte=" + id - ).get(0); - } - - // Retourne le prenom de l'id entree - public String getPrenom(int id) { - return this.sharedObject.fetchAll( - "SELECT prenom FROM " + this.TableDesMembres + " WHERE idCompte=" + id - ).get(0); - } - - // Retourne l'adresse du telephone de l'id entree - public String getAdresse(int id) { - return this.sharedObject.fetchAll( - "SELECT adresse FROM " + this.TableDesMembres + " WHERE idCompte=" + id - ).get(0); - } - - // Retourne le numero du telephone de l'id entree - public String getPhone(int id) { - return this.sharedObject.fetchAll( - "SELECT phone FROM " + this.TableDesMembres + " WHERE idCompte=" + id - ).get(0); - } - - // Schema de retour : - // Liste des demandes = { - // {ListeDesId-1, ListeDesType-1, ListeDesMessage-1}, - // {ListeDesId-2, ListeDesType-2, ListeDesMessage-2}, - // {ListeDesId-3, ListeDesType-3, ListeDesMessage-3}, - // etc... - // } - // Retourne toutes les requetes qu'ils y a dans la bdd - public ArrayList> getAllRequest() { - ArrayList> toReturn = new ArrayList<>(); - ArrayList tmp = new ArrayList<>(); - - ArrayList listId = this.sharedObject.fetchAll( - "SELECT idCompte FROM " + this.TableDesDemandes - ); - - ArrayList listType = this.sharedObject.fetchAll( - "SELECT type FROM " + this.TableDesDemandes - ); - - ArrayList listContent = this.sharedObject.fetchAll( - "SELECT contenu FROM " + this.TableDesDemandes - ); - - if(listId.size() == listContent.size() && listType.size() == listContent.size()) { - for(int i = 0; i <= listId.size()-1; i++) { - tmp.add(listId.get(i)); - tmp.add(listType.get(i)); - tmp.add(listContent.get(i)); - - toReturn.add(tmp); - } - } else { - System.out.println("Erreur."); - } - - return toReturn; - } - - // Retourne les requetes faites par un eleve en particulier - public ArrayList> getRequest(int id) { - ArrayList> toReturn = new ArrayList<>(); - ArrayList tmp = new ArrayList<>(); - - ArrayList listId = this.sharedObject.fetchAll( - "SELECT idCompte FROM " + this.TableDesDemandes - ); - - ArrayList listType = this.sharedObject.fetchAll( - "SELECT type FROM " + this.TableDesDemandes - ); - - ArrayList listContent = this.sharedObject.fetchAll( - "SELECT contenu FROM " + this.TableDesDemandes - ); - - if(listId.size() == listContent.size() && listType.size() == listContent.size()) { - for(int i = 0; i <= listId.size()-1; i++) { - tmp.add(listId.get(i)); - tmp.add(listType.get(i)); - tmp.add(listContent.get(i)); - - toReturn.add(tmp); - } - } else { - System.out.println("Erreur."); - } - - return toReturn; - } - - // Retourne tous les groupes existant - public ArrayList> getAllGrups(){ - ArrayList> toReturn = new ArrayList<>(); - ArrayList tmp = new ArrayList<>(); - - ArrayList listGrups = this.sharedObject.fetchAll( - "SELECT intitule FROM " + this.TableDesGroupes - ); - - ArrayList listIdGrups = this.sharedObject.fetchAll( - "SELECT idRequete FROM " + this.TableDesGroupes - ); - - for(int i = 0; i <= listGrups.size(); i++) { - tmp.add(listIdGrups.get(i)); - tmp.add(listGrups.get(i)); - - toReturn.add(tmp); - } - - return toReturn; - } - - // Retourne en String par son id - public String getGrup(int id) { - return this.sharedObject.fetchAll( - "SELECT intitule FROM " + this.TableDesGroupes + " WHERE idGroupe=" + id - ).get(0); - } - - // Retourne l'id d'un groupe - public int getGrup(String intitule) { - return Integer.parseInt( - this.sharedObject.fetchAll( - "SELECT idGroupe FROM " + this.TableDesGroupes + " WHERE intitule=" + intitule - ).get(0), 10 - ); - } - - // Retourne le grade par son id - public String getGrade(int id) { - return this.sharedObject.fetchAll( - "SELECT GR.intitule FROM " - + this.TableDesComptes + " TC," + this.TableDesGrades + " GR" + - " WHERE idCompte=" + id - ).get(0); - } - - // Retourne l'id du grade mis en parametre - public int getGrade(String intitule) { - return Integer.parseInt( - this.sharedObject.fetchAll( - "SELECT idGrade FROM " + this.TableDesGrades + " WHERE intitule = " + intitule - ).get(0) - , 10); - } - - public void setGrups(int id, int where) { - this.sharedObject.updatRow( - "UPDATE " + this.TableDesGroupes + " SET idGrups=" + where - ) - } -} \ No newline at end of file diff --git a/src/BInput.java b/src/BInput.java deleted file mode 100644 index 136f8e2..0000000 --- a/src/BInput.java +++ /dev/null @@ -1,46 +0,0 @@ -/* [BInput] - * Desc: To create Operationnal JTextfield fast :) - * GitHub: https://github.com/lalBi94 - * Created by: Bilal Boudjemline - * 28/09/2022 at 20:35 - * */ - -import javax.swing.JTextField; -import java.awt.*; - -public class BInput extends JTextField { - public int width = 100; - public int height = 50; - public String inner; - public Color color = Color.BLACK; - - public BInput(String in) { - this.inner = in; - this.setText(in); - } - - public BInput(int w, int h) { - this.width = w; - this.height = h; - this.setPreferredSize(new Dimension(w, h)); - } - - public BInput(int w, int h, Color c) { - this.width = w; - this.height = h; - this.color = c; - this.setPreferredSize(new Dimension(w, h)); - this.setBackground(this.color); - } - - public void setSize(int w, int h) { - this.width = w; - this.height = h; - this.setPreferredSize(new Dimension(w, h)); - } - - @Override - public String toString() { - return this.width + "\n" + this.height; - } -}