This commit is contained in:
Bilou 2022-12-08 03:58:56 +01:00
parent 37eec841b8
commit dd088c00a2
38 changed files with 53533 additions and 53544 deletions

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.

View File

@ -17,7 +17,9 @@ import java.util.Iterator;
import org.mariadb.jdbc.*; import org.mariadb.jdbc.*;
/** /**
* <p>Methodes pour les interaction avec une base de donnees</p> * <p>
* Methodes pour les interaction avec une base de donnees
* </p>
* *
* @author <a href="https://github.com/lalBi94">Bilal Boudjemline</a> * @author <a href="https://github.com/lalBi94">Bilal Boudjemline</a>
*/ */
@ -38,12 +40,13 @@ public class BDatabase {
try { try {
Class.forName("org.mariadb.jdbc.Driver"); Class.forName("org.mariadb.jdbc.Driver");
} catch(ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
this.sharedObject = DriverManager.getConnection(this.db_host + this.db_name, this.db_user, this.db_password); this.sharedObject = DriverManager.getConnection(this.db_host + this.db_name, this.db_user,
this.db_password);
this.status = true; this.status = true;
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("Erreur de liaison avec la base de donnees."); System.out.println("Erreur de liaison avec la base de donnees.");
@ -61,12 +64,12 @@ public class BDatabase {
ArrayList<String> toReturn = new ArrayList<String>(); ArrayList<String> toReturn = new ArrayList<String>();
ResultSet rs = this.sharedObject.prepareStatement(request).executeQuery(); ResultSet rs = this.sharedObject.prepareStatement(request).executeQuery();
for(int i = 0; rs.next(); i++) { for (int i = 0; rs.next(); i++) {
toReturn.add(i, String.valueOf(rs.getString(1))); toReturn.add(i, String.valueOf(rs.getString(1)));
} }
return toReturn; return toReturn;
} catch(SQLException e) { } catch (SQLException e) {
System.out.println("Erreur de la requete : " + e); System.out.println("Erreur de la requete : " + e);
return null; return null;
} }
@ -87,17 +90,17 @@ public class BDatabase {
Iterator<String> iteVal = Arrays.stream(value).iterator(); Iterator<String> iteVal = Arrays.stream(value).iterator();
collumns.append("("); collumns.append("(");
while(iteCol.hasNext()) { while (iteCol.hasNext()) {
collumns.append(iteCol.next()).append(", "); collumns.append(iteCol.next()).append(", ");
} }
collumns.setLength(collumns.length()-2); collumns.setLength(collumns.length() - 2);
collumns.append(")"); collumns.append(")");
values.append("("); values.append("(");
while(iteVal.hasNext()) { while (iteVal.hasNext()) {
values.append("\"").append(iteVal.next()).append("\"").append(", "); values.append("\"").append(iteVal.next()).append("\"").append(", ");
} }
values.setLength(values.length()-2); values.setLength(values.length() - 2);
values.append(")"); values.append(")");
String request = "INSERT INTO " + table + collumns + " VALUES" + values + ";"; String request = "INSERT INTO " + table + collumns + " VALUES" + values + ";";
@ -107,13 +110,14 @@ public class BDatabase {
this.sharedObject.prepareStatement(request).executeQuery(); this.sharedObject.prepareStatement(request).executeQuery();
System.out.println("Succes: " + request); System.out.println("Succes: " + request);
return true; return true;
} catch(SQLException e) { } catch (SQLException e) {
return false; return false;
} }
} }
/** /**
* Faire des requetes de type UPDATE SET (il y aura plus d'argument prochainement). * Faire des requetes de type UPDATE SET (il y aura plus d'argument
* prochainement).
* *
* @param request La requete * @param request La requete
* @return Si oui ou non ca a fonctionne * @return Si oui ou non ca a fonctionne
@ -121,8 +125,9 @@ public class BDatabase {
public boolean updateRow(String request) { public boolean updateRow(String request) {
try { try {
this.sharedObject.prepareStatement(request).executeQuery(); this.sharedObject.prepareStatement(request).executeQuery();
System.out.println("Succes:" + request);
return true; return true;
} catch(SQLException e) { } catch (SQLException e) {
return false; return false;
} }
} }
@ -149,31 +154,27 @@ public class BDatabase {
* Recuperer la liste des etudiants (FIProjet Contexte) * Recuperer la liste des etudiants (FIProjet Contexte)
* *
* @return La liste des etudiants * @return La liste des etudiants
* */ */
public ArrayList<Etudiant> getEtuList() { public ArrayList<Etudiant> getEtuList() {
ArrayList<Etudiant> listEtu = new ArrayList<>(); ArrayList<Etudiant> listEtu = new ArrayList<>();
ArrayList<String> studPrenom = this.fetchAll("SELECT prenom FROM fi_eleves"); ArrayList<String> studPrenom = this.fetchAll("SELECT prenom FROM fi_eleves");
ArrayList<String> studNom = this.fetchAll("SELECT nom FROM fi_eleves"); ArrayList<String> studNom = this.fetchAll("SELECT nom FROM fi_eleves");
ArrayList<String> studGroupe = this.fetchAll("SELECT groupe FROM fi_eleves"); ArrayList<String> studGroupe = this.fetchAll("SELECT groupe FROM fi_eleves");
for(int i = 0; i <= studPrenom.size()-1; i++) { for (int i = 0; i <= studPrenom.size() - 1; i++) {
if(studPrenom.get(i) != null && studNom.get(i) != null && studGroupe.get(i) != null) { if (studPrenom.get(i) != null && studNom.get(i) != null && studGroupe.get(i) != null) {
try { try {
listEtu.add( listEtu.add(
new EtudiantNP( new EtudiantNP(
studNom.get(i), studNom.get(i),
studPrenom.get(i), studPrenom.get(i),
Integer.parseInt(studGroupe.get(i), 10) Integer.parseInt(studGroupe.get(i), 10)));
) } catch (NumberFormatException ignore) {
);
} catch(NumberFormatException ignore) {
listEtu.add( listEtu.add(
new EtudiantNP( new EtudiantNP(
studNom.get(i), studNom.get(i),
studPrenom.get(i), studPrenom.get(i),
-1 -1));
)
);
} }
} else { } else {
System.out.println("[!] Erreur lors du chargement de la liste des etudiants."); System.out.println("[!] Erreur lors du chargement de la liste des etudiants.");
@ -190,32 +191,28 @@ public class BDatabase {
* Recuperer la liste des groupes (FIProjet contexte) * Recuperer la liste des groupes (FIProjet contexte)
* *
* @return La liste des groupes * @return La liste des groupes
* */ */
public ArrayList<Groupe> getGroupeList() { public ArrayList<Groupe> getGroupeList() {
ArrayList<Groupe> listGroupe = new ArrayList<>(); ArrayList<Groupe> listGroupe = new ArrayList<>();
ArrayList<String> groupeId = this.fetchAll("SELECT id FROM fi_groupe"); ArrayList<String> groupeId = this.fetchAll("SELECT id FROM fi_groupe");
ArrayList<String> groupeNom = this.fetchAll("SELECT nom FROM fi_groupe"); ArrayList<String> groupeNom = this.fetchAll("SELECT nom FROM fi_groupe");
ArrayList<String> groupeMin = this.fetchAll("SELECT min FROM fi_groupe"); ArrayList<String> groupeMin = this.fetchAll("SELECT min FROM fi_groupe");
ArrayList<String> groupeMax = this.fetchAll("SELECT max FROM fi_groupe"); ArrayList<String> groupeMax = this.fetchAll("SELECT max FROM fi_groupe");
for (int i = 0; i <= groupeNom.size() - 1; i++) {
for(int i = 0; i <= groupeNom.size()-1; i++) { if (groupeId.get(i) != null && groupeNom.get(i) != null && groupeMin.get(i) != null
if(groupeId.get(i) != null && groupeNom.get(i) != null && groupeMin.get(i) != null && groupeMax.get(i) != null) { && groupeMax.get(i) != null) {
listGroupe.add( listGroupe.add(
new GroupeNP( new GroupeNP(
Integer.parseInt(groupeId.get(i), 10), Integer.parseInt(groupeId.get(i), 10),
groupeNom.get(i), groupeNom.get(i),
Integer.parseInt(groupeMin.get(i), 10), Integer.parseInt(groupeMin.get(i), 10),
Integer.parseInt(groupeMax.get(i), 10) Integer.parseInt(groupeMax.get(i), 10)));
)
);
} else { } else {
System.out.println("[!] Erreur lors du chargement de la liste des groupes."); System.out.println("[!] Erreur lors du chargement de la liste des groupes.");
System.exit(-1); System.exit(-1);
} }
} }
System.out.println("[+] Liste des groupes chargees."); System.out.println("[+] Liste des groupes chargees.");
return listGroupe; return listGroupe;
} }
@ -223,7 +220,7 @@ public class BDatabase {
* Recuperer les requetes * Recuperer les requetes
* *
* @return la liste des requetes * @return la liste des requetes
* */ */
public ArrayList<Requete> getRequestList() { public ArrayList<Requete> getRequestList() {
ArrayList<Requete> toReturn = new ArrayList<>(); ArrayList<Requete> toReturn = new ArrayList<>();
ArrayList<String> requestId = this.fetchAll("SELECT id FROM fi_demandes"); ArrayList<String> requestId = this.fetchAll("SELECT id FROM fi_demandes");
@ -233,17 +230,15 @@ public class BDatabase {
ArrayList<String> requestType = this.fetchAll("SELECT type FROM fi_demandes"); ArrayList<String> requestType = this.fetchAll("SELECT type FROM fi_demandes");
ArrayList<String> requestStatut = this.fetchAll("SELECT statut FROM fi_demandes"); ArrayList<String> requestStatut = this.fetchAll("SELECT statut FROM fi_demandes");
for(int i = 0; i <= requestId.size()-1; i++) { for (int i = 0; i <= requestId.size() - 1; i++) {
toReturn.add( toReturn.add(
new RequeteNP( new RequeteNP(
Integer.parseInt(requestId.get(i)), Integer.parseInt(requestId.get(i)),
requestMessage.get(i), requestMessage.get(i),
Integer.parseInt(requestEtu.get(i)), Integer.parseInt(requestEtu.get(i)),
Integer.parseInt(requestType.get(i)), Integer.parseInt(requestType.get(i)),
Integer.parseInt(requestWitchGrup.get(i)), Integer.parseInt(requestWitchGrup.get(i)),
requestStatut.get(i) requestStatut.get(i)));
)
);
} }
return toReturn; return toReturn;

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,7 @@ public class ProfView extends JPanel {
settings.setPadding(new Insets(0, 0, 0, 50)); settings.setPadding(new Insets(0, 0, 0, 50));
String[] groupeList = new String[this.g.size()]; String[] groupeList = new String[this.g.size()];
for(int i = 0; i <= this.g.size()-1; i++) { for (int i = 0; i <= this.g.size() - 1; i++) {
groupeList[i] = this.g.get(i).getName(); groupeList[i] = this.g.get(i).getName();
} }
@ -97,7 +97,7 @@ public class ProfView extends JPanel {
this.text.setPreferredSize(new Dimension(110, 30)); this.text.setPreferredSize(new Dimension(110, 30));
text.addKeyListener(new KeyAdapter() { text.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) { public void keyTyped(KeyEvent e) {
if (text.getText().length() >= 3 ) if (text.getText().length() >= 3)
e.consume(); e.consume();
} }
}); });

View File

@ -61,7 +61,7 @@ public class StudentView extends JPanel {
settings.setPadding(new Insets(0, 0, 0, 50)); settings.setPadding(new Insets(0, 0, 0, 50));
String[] groupeList = new String[this.g.size()]; String[] groupeList = new String[this.g.size()];
for(int i = 0; i <= this.g.size()-1; i++) { for (int i = 0; i <= this.g.size() - 1; i++) {
groupeList[i] = this.g.get(i).getName(); groupeList[i] = this.g.get(i).getName();
} }