This commit is contained in:
pro.boooooo 2022-12-07 20:47:08 +01:00
parent 276fc19076
commit 51407d32cc
11 changed files with 167 additions and 10 deletions

BIN
build/API/Requete.class Normal file

Binary file not shown.

BIN
build/MNP/RequeteNP.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

42
src/API/Requete.java Normal file
View File

@ -0,0 +1,42 @@
package API;
public interface Requete extends MonPrint {
/**
* Recuperer l'id de l'etudiant
*
* @return l'id de l'etudiant a l'origine du message
* */
public int getEtuId();
/**
* Recuperer le message
* */
public String getMessage();
/**
* Recuperer l'id d'un message
*
* @return l'id du message
* */
public int getIdMessage();
/**
* Recuperer le type de la requete
*
* @return le type de la requete 2 ou 1
* */
public int getType();
/**
* Recuperer le groupe que l'etudiant veut rejoindre
* */
public int getWitchGroupe();
/**
* @see MonPrint
* NB. On n'utilise le mécanisme des méthodes par défaut pour donner du code dans une interface. C'est un petit peu laid et à contre-emploi mais pratique ici.
*/
public default String monPrint() {
return null;
}
}

44
src/MNP/RequeteNP.java Normal file
View File

@ -0,0 +1,44 @@
package MNP;
import API.Requete;
public class RequeteNP implements Requete {
private final int id;
private final String message;
private final int etuSource;
private final int type;
private final int witchGroupe;
public RequeteNP(int id, String message, int etuSource, int type, int witchGroupe) {
this.id = id;
this.message = message;
this.etuSource = etuSource;
this.type = type;
this.witchGroupe = witchGroupe;
}
@Override
public int getEtuId() {
return this.etuSource;
}
@Override
public String getMessage() {
return this.message;
}
@Override
public int getIdMessage() {
return this.id;
}
@Override
public int getType() {
return this.type;
}
@Override
public int getWitchGroupe() {
return this.witchGroupe;
}
}

View File

@ -10,18 +10,12 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
public class AdminView extends JPanel {
private final ArrayList<Etudiant> e;
private final ArrayList<Groupe> g;
private final Controller listener;
public AdminView(ArrayList<Etudiant> e, ArrayList<Groupe> g, Controller listener) {
public AdminView(Controller listener) {
super();
this.setLayout(new GridBagLayout());
this.listener = listener;
this.g = g;
this.e = e;
Display();
}
@ -84,6 +78,18 @@ public class AdminView extends JPanel {
delGrup.setActionCommand("av::delGrup");
this.add(delGrup, settings);
settings.setPositionY(12);
this.add(new JLabel(" "), settings);
settings.setPositionY(13);
this.add(new JLabel(" "), settings);
settings.setPositionY(14);
CustomJButton showRequest = new CustomJButton("Consulter les requetes");
showRequest.addActionListener(this.listener);
showRequest.setActionCommand("av::ShowRequestFromStudent");
this.add(showRequest, settings);
this.repaint();
}
}

View File

@ -219,6 +219,35 @@ public class BDatabase {
return listGroupe;
}
/**
* Recuperer les requetes
*
* @return la liste des requetes
* */
public ArrayList<Requete> getRequestList() {
ArrayList<Requete> toReturn = new ArrayList<>();
ArrayList<String> requestId = this.fetchAll("SELECT id FROM fi_demandes");
ArrayList<String> requestEtu = this.fetchAll("SELECT id_eleve FROM fi_demandes");
ArrayList<String> requestWitchGrup = this.fetchAll("SELECT id_groupe FROM fi_demandes");
ArrayList<String> requestMessage = this.fetchAll("SELECT message FROM fi_demandes");
ArrayList<String> requestType = this.fetchAll("SELECT type FROM fi_demandes");
ArrayList<String> requestStatut = this.fetchAll("SELECT statut FROM fi_demandes");
for(int i = 0; i <= requestId.size()-1; i++) {
toReturn.add(
new RequeteNP(
Integer.parseInt(requestId.get(i)),
requestMessage.get(i),
Integer.parseInt(requestEtu.get(i)),
Integer.parseInt(requestType.get(i)),
Integer.parseInt(requestWitchGrup.get(i))
)
);
}
return toReturn;
}
/**
* Recuperer l'hote courant.
*

View File

@ -32,6 +32,7 @@ public class Controller implements ActionListener, ListSelectionListener {
private ArrayList<Etudiant> e;
private ArrayList<Groupe> g;
private ArrayList<Requete> r;
private JTable currentJTableUse;
private JComboBox<String> list;
@ -51,9 +52,10 @@ public class Controller implements ActionListener, ListSelectionListener {
this.db = db;
this.e = this.db.getEtuList();
this.g = this.db.getGroupeList();
this.r = this.db.getRequestList();
this.sv = new StudentView(this.e, this.g, this);
this.pv = new ProfView(this.e, this.g, this);
this.av = new AdminView(this.e, this.g, this);
this.av = new AdminView(this);
this.parent = new MainMenu(this);
}
@ -61,9 +63,10 @@ public class Controller implements ActionListener, ListSelectionListener {
this.db = db;
this.e = this.db.getEtuList();
this.g = this.db.getGroupeList();
this.r = this.db.getRequestList();
this.sv = new StudentView(this.e, this.g, this);
this.pv = new ProfView(this.e, this.g, this);
this.av = new AdminView(this.e, this.g, this);
this.av = new AdminView(this);
this.parent = new MainMenu(this, selectedView);
}
@ -618,6 +621,32 @@ public class Controller implements ActionListener, ListSelectionListener {
DisplayWithListner(this.createJTable(data, titre));
}
else if(Objects.equals(command, "av::ShowRequestFromStudent")) {
Object[][] data = new Object[this.r.size()][5];
String[] titre = {
"Etudiant",
"Groupe demande",
"Message",
"Type",
"Action"
};
for(int i = 0; i <= this.r.size()-1; i++) {
Object[] info = {
this.getEtuNameById(this.r.get(i).getEtuId()),
this.getGroupeById(this.r.get(i).getWitchGroupe()),
this.r.get(i).getMessage(),
this.r.get(i).getType(),
"[DECISION]"
};
data[i] = info;
}
DisplayWithListner(this.createJTable(data, titre));
}
}
@Override
@ -652,6 +681,13 @@ public class Controller implements ActionListener, ListSelectionListener {
}
}
public String getEtuNameById(int id) {
String nom = this.db.fetchAll("SELECT nom FROM fi_eleves WHERE id = " + id).get(0);
String prenom = this.db.fetchAll("SELECT prenom FROM fi_eleves WHERE id = " + id).get(0);
return nom + " " + prenom;
}
private void deleteGrup(TableModel tm, int[] cell) {
int choice = JOptionPane.showConfirmDialog(this.parent, "Etes-vous sur ?");
@ -805,7 +841,7 @@ public class Controller implements ActionListener, ListSelectionListener {
this.g = this.db.getGroupeList();
this.parent.updateTable(this.initTable());
}
public JTable initTable() {
Object[][] data = new Object[this.e.size()][3];
String[] title = {