merge avec main (risque de problèmes potenciels)
This commit is contained in:
commit
46b32190d0
@ -9,12 +9,19 @@ import javafx.scene.Scene;
|
|||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
public class Main extends Application {
|
public class AppMain extends Application {
|
||||||
private Scene scene = new Scene(new Pane());
|
private Scene scene = new Scene(new Pane());
|
||||||
private ScreenController gestionnaireDePages = new ScreenController(scene);
|
private ScreenController gestionnaireDePages = new ScreenController(scene);
|
||||||
|
|
||||||
|
public static boolean testMode;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws IOException{
|
public void start(Stage stage) throws IOException{
|
||||||
|
|
||||||
|
String res = getParameters().getNamed().get("testMode");
|
||||||
|
testMode = res!=null&&res.equals("true");
|
||||||
|
|
||||||
|
|
||||||
ScreenController.addScreen("Acceuil",FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fp/fp.fxml")));
|
ScreenController.addScreen("Acceuil",FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fp/fp.fxml")));
|
||||||
|
|
||||||
//TODO Ajouter les pages d'admin pour l'ajout des usages
|
//TODO Ajouter les pages d'admin pour l'ajout des usages
|
||||||
@ -28,7 +35,6 @@ public class Main extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
Thread.sleep(5000);
|
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import fr.univ_amu.iut.model.Usage;
|
|||||||
public class Donnees {
|
public class Donnees {
|
||||||
private static Academie academieSelectionee = null;
|
private static Academie academieSelectionee = null;
|
||||||
private static Thematique thematiqueSelectionee = null;
|
private static Thematique thematiqueSelectionee = null;
|
||||||
private static Discipline disciplineSelectionee = Discipline.Toutes;
|
private static Discipline disciplineSelectionee = null;
|
||||||
private static List<Usage> usagesObtenus;
|
private static List<Usage> usagesObtenus;
|
||||||
|
|
||||||
public static List<Usage> getUsagesObtenus() {
|
public static List<Usage> getUsagesObtenus() {
|
||||||
@ -36,7 +36,7 @@ public class Donnees {
|
|||||||
if(thematiqueSelectionee == Donnees.thematiqueSelectionee){
|
if(thematiqueSelectionee == Donnees.thematiqueSelectionee){
|
||||||
thematiqueSelectionee = null;
|
thematiqueSelectionee = null;
|
||||||
}
|
}
|
||||||
System.out.println("Thematique selectionée : %s".formatted((thematiqueSelectionee == null)? "Aucune Thematique" : thematiqueSelectionee.getNom()));
|
System.out.println("Thematique selectionée : %s".formatted(thematiqueSelectionee));
|
||||||
Donnees.thematiqueSelectionee = thematiqueSelectionee;
|
Donnees.thematiqueSelectionee = thematiqueSelectionee;
|
||||||
}
|
}
|
||||||
public static Discipline getDisciplineSelectionee() {
|
public static Discipline getDisciplineSelectionee() {
|
||||||
@ -44,9 +44,9 @@ public class Donnees {
|
|||||||
}
|
}
|
||||||
public static void setDisciplineSelectionee(Discipline disciplineSelectionee) {
|
public static void setDisciplineSelectionee(Discipline disciplineSelectionee) {
|
||||||
if(disciplineSelectionee == Donnees.disciplineSelectionee){
|
if(disciplineSelectionee == Donnees.disciplineSelectionee){
|
||||||
disciplineSelectionee = Discipline.Toutes;
|
disciplineSelectionee = null;
|
||||||
}
|
}
|
||||||
System.out.println("Discipline Selectionee : %s".formatted(disciplineSelectionee.getNom()));
|
System.out.println("Discipline Selectionee : %s".formatted(disciplineSelectionee));
|
||||||
Donnees.disciplineSelectionee = disciplineSelectionee;
|
Donnees.disciplineSelectionee = disciplineSelectionee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,6 @@ package fr.univ_amu.iut;
|
|||||||
|
|
||||||
public class Launcher {
|
public class Launcher {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Main.main(args);
|
AppMain.main(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,8 @@ import fr.univ_amu.iut.test.DAOFactoryTest;
|
|||||||
public class DAOFactoryProducer {
|
public class DAOFactoryProducer {
|
||||||
public static DAOFactory getFactory(DAOType type) {
|
public static DAOFactory getFactory(DAOType type) {
|
||||||
return switch (type){
|
return switch (type){
|
||||||
case JPA -> new DAOFactoryJPA();
|
case JPA -> new DAOFactoryJPA("gestionUsagesPU");
|
||||||
|
case JPA_MEMORY -> new DAOFactoryJPA("gestionUsagesPUMemory");
|
||||||
case TEST -> new DAOFactoryTest();
|
case TEST -> new DAOFactoryTest();
|
||||||
default -> throw new IllegalArgumentException();
|
default -> throw new IllegalArgumentException();
|
||||||
};
|
};
|
||||||
|
@ -2,5 +2,6 @@ package fr.univ_amu.iut.dao.factory;
|
|||||||
|
|
||||||
public enum DAOType {
|
public enum DAOType {
|
||||||
JPA,
|
JPA,
|
||||||
TEST
|
JPA_MEMORY, // JPA, mais sans persistence (base de données en mémoire) (utilisé pour le test de JPA)
|
||||||
|
TEST // utilisé pour le test de l'interface graphique
|
||||||
}
|
}
|
||||||
|
@ -37,15 +37,11 @@ public class DAOFactoryJPA implements DAOFactory {
|
|||||||
public DAOFactoryJPA(String unitName){
|
public DAOFactoryJPA(String unitName){
|
||||||
this.unitName = unitName;
|
this.unitName = unitName;
|
||||||
|
|
||||||
|
|
||||||
insertAllHelper(createDAORegionAcademique(), RegionAcademique.toutes());
|
insertAllHelper(createDAORegionAcademique(), RegionAcademique.toutes());
|
||||||
insertAllHelper(createDAOAcademie(), Academie.toutes());
|
insertAllHelper(createDAOAcademie(), Academie.toutes());
|
||||||
insertAllHelper(createDAOThematique(), Thematique.toutes());
|
insertAllHelper(createDAOThematique(), Thematique.toutes());
|
||||||
insertAllHelper(createDAODiscipline(), Discipline.toutes());
|
insertAllHelper(createDAODiscipline(), Discipline.toutes());
|
||||||
}
|
}
|
||||||
public DAOFactoryJPA(){
|
|
||||||
this("gestionUsagesPU");
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityManager getEntityManager() {
|
public EntityManager getEntityManager() {
|
||||||
if(entityManager == null){
|
if(entityManager == null){
|
||||||
|
@ -8,12 +8,15 @@ public class TableEntry {
|
|||||||
|
|
||||||
private String nom;
|
private String nom;
|
||||||
private String discipline;
|
private String discipline;
|
||||||
|
private String thematique;
|
||||||
private String description;
|
private String description;
|
||||||
private String niveau;
|
private String niveau;
|
||||||
|
|
||||||
public TableEntry(Usage usage) {
|
public TableEntry(Usage usage) {
|
||||||
nom = usage.getNom();
|
nom = usage.getNom();
|
||||||
|
thematique = usage.getThematique().getNom();
|
||||||
discipline = usage.getDiscipline().getNom();
|
discipline = usage.getDiscipline().getNom();
|
||||||
|
System.out.println("DESC="+usage.getDescription());
|
||||||
description = usage.getDescription();
|
description = usage.getDescription();
|
||||||
niveau = usage.getNiveau().getNom();
|
niveau = usage.getNiveau().getNom();
|
||||||
}
|
}
|
||||||
@ -34,6 +37,15 @@ public class TableEntry {
|
|||||||
this.discipline = discipline;
|
this.discipline = discipline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getThematique() {
|
||||||
|
return thematique;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThematique(String thematique) {
|
||||||
|
this.thematique = thematique;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
@ -51,4 +63,36 @@ public class TableEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
TableEntry that = (TableEntry) o;
|
||||||
|
|
||||||
|
if (nom != null ? !nom.equals(that.nom) : that.nom != null) return false;
|
||||||
|
if (discipline != null ? !discipline.equals(that.discipline) : that.discipline != null) return false;
|
||||||
|
if (description != null ? !description.equals(that.description) : that.description != null) return false;
|
||||||
|
return niveau != null ? niveau.equals(that.niveau) : that.niveau == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = nom != null ? nom.hashCode() : 0;
|
||||||
|
result = 31 * result + (discipline != null ? discipline.hashCode() : 0);
|
||||||
|
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||||
|
result = 31 * result + (niveau != null ? niveau.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "TableEntry{" +
|
||||||
|
"nom='" + nom + '\'' +
|
||||||
|
", discipline='" + discipline + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
|
", niveau='" + niveau + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package fr.univ_amu.iut.fp;
|
package fr.univ_amu.iut.fp;
|
||||||
|
|
||||||
|
import fr.univ_amu.iut.AppMain;
|
||||||
import fr.univ_amu.iut.Donnees;
|
import fr.univ_amu.iut.Donnees;
|
||||||
import fr.univ_amu.iut.dao.DAODiscipline;
|
import fr.univ_amu.iut.dao.DAODiscipline;
|
||||||
import fr.univ_amu.iut.dao.DAOThematique;
|
import fr.univ_amu.iut.dao.DAOThematique;
|
||||||
@ -18,6 +19,7 @@ import javafx.fxml.Initializable;
|
|||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
@ -27,7 +29,6 @@ import javafx.event.ActionEvent;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
@ -43,6 +44,9 @@ public class Controller implements Initializable {
|
|||||||
@FXML
|
@FXML
|
||||||
private Pane stackPaneFrance;
|
private Pane stackPaneFrance;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextField barreDeRecherche;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private AnchorPane discipline;
|
private AnchorPane discipline;
|
||||||
|
|
||||||
@ -52,26 +56,27 @@ public class Controller implements Initializable {
|
|||||||
@FXML
|
@FXML
|
||||||
private Button recherche;
|
private Button recherche;
|
||||||
|
|
||||||
List<String> listNomThematique = new ArrayList<>();
|
@FXML
|
||||||
|
private Button rechercheTextuelle;
|
||||||
|
|
||||||
// Style des boutons
|
// Style des boutons
|
||||||
Background btNormalBackground = new Background(new BackgroundFill(Color.rgb(255, 110, 64), new CornerRadii(30), Insets.EMPTY));
|
Background btNormalBackground = new Background(new BackgroundFill(Color.rgb(255,110,64), new CornerRadii(30), Insets.EMPTY));
|
||||||
Background btNormalHover = new Background(new BackgroundFill(Color.rgb(255, 152, 120), new CornerRadii(30), Insets.EMPTY));
|
Background btNormalHover = new Background(new BackgroundFill(Color.rgb(255,152,120), new CornerRadii(30), Insets.EMPTY));
|
||||||
Background btSelectedBackground = new Background(new BackgroundFill(Color.rgb(255, 60, 0), new CornerRadii(30), Insets.EMPTY));
|
Background btNormalSelected = new Background(new BackgroundFill(Color.rgb(255,60,0), new CornerRadii(30), Insets.EMPTY));
|
||||||
|
|
||||||
private void initFrance() {
|
private void initFrance() {
|
||||||
france = FranceBuilder.create()
|
france = FranceBuilder.create()
|
||||||
.backgroundColor(Color.web("#f5f0e1"))
|
.backgroundColor(Color.web("#f5f0e1"))
|
||||||
.fillColor(Color.web("#1e3d59"))
|
.fillColor(Color.web("#1e3d59"))
|
||||||
.mousePressHandler(evt -> {
|
.mousePressHandler(evt -> {
|
||||||
AcademiePath academiePath = (AcademiePath) evt.getSource();
|
AcademiePath academiePath = (AcademiePath) evt.getSource();
|
||||||
Donnees.setAcademieSelectionee(academiePath.getAcademie());
|
Donnees.setAcademieSelectionee(academiePath.getAcademie());
|
||||||
})
|
})
|
||||||
.selectionEnabled(true)
|
.selectionEnabled(true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button initButton(Object obj, int x, int y) {
|
private Button initButton(Object obj,int x,int y){
|
||||||
String nom = "";
|
String nom = "";
|
||||||
|
|
||||||
EventHandler<ActionEvent> actionHandler;
|
EventHandler<ActionEvent> actionHandler;
|
||||||
@ -105,7 +110,7 @@ public class Controller implements Initializable {
|
|||||||
|
|
||||||
onPressHandler = event -> {
|
onPressHandler = event -> {
|
||||||
Button bt = (Button) event.getSource();
|
Button bt = (Button) event.getSource();
|
||||||
if (bt.getBackground().equals(btSelectedBackground)) {
|
if (bt.getBackground().equals(btNormalSelected)) {
|
||||||
bt.setBackground(btNormalHover);
|
bt.setBackground(btNormalHover);
|
||||||
bt.setOnMouseEntered(onEnterHandler);
|
bt.setOnMouseEntered(onEnterHandler);
|
||||||
bt.setOnMouseExited(onExitHandler);
|
bt.setOnMouseExited(onExitHandler);
|
||||||
@ -127,7 +132,7 @@ public class Controller implements Initializable {
|
|||||||
}
|
}
|
||||||
bt.setOnMouseEntered(null);
|
bt.setOnMouseEntered(null);
|
||||||
bt.setOnMouseExited(null);
|
bt.setOnMouseExited(null);
|
||||||
bt.setBackground(btSelectedBackground);
|
bt.setBackground(btNormalSelected);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -182,7 +187,7 @@ public class Controller implements Initializable {
|
|||||||
stackPaneFrance.getChildren().add(france);
|
stackPaneFrance.getChildren().add(france);
|
||||||
|
|
||||||
// init
|
// init
|
||||||
daoFactory = DAOFactoryProducer.getFactory(DAOType.JPA);
|
daoFactory = DAOFactoryProducer.getFactory(AppMain.testMode ? DAOType.TEST : DAOType.JPA);
|
||||||
daoDiscipline = daoFactory.createDAODiscipline();
|
daoDiscipline = daoFactory.createDAODiscipline();
|
||||||
daoThematique = daoFactory.createDAOThematique();
|
daoThematique = daoFactory.createDAOThematique();
|
||||||
daoUsage = daoFactory.createDAOUsage();
|
daoUsage = daoFactory.createDAOUsage();
|
||||||
@ -194,10 +199,9 @@ public class Controller implements Initializable {
|
|||||||
|
|
||||||
placeButtonThematique();
|
placeButtonThematique();
|
||||||
placeButtonDiscipline();
|
placeButtonDiscipline();
|
||||||
EventHandler<ActionEvent> handler = event -> {
|
EventHandler<ActionEvent> handleRechercheTextuelle = event ->{
|
||||||
//TODO Recherche en fonctions des objets selectionnés
|
|
||||||
|
|
||||||
Donnees.setUsagesObtenus(daoUsage.findByCriterias(Donnees.getThematiqueSelectionee(), Donnees.getDisciplineSelectionee(), Donnees.getAcademieSelectionee()));
|
Donnees.setUsagesObtenus(daoUsage.findByNamePart(barreDeRecherche.getText()));
|
||||||
|
|
||||||
Stage resultats = new Stage();
|
Stage resultats = new Stage();
|
||||||
try {
|
try {
|
||||||
@ -206,8 +210,21 @@ public class Controller implements Initializable {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
recherche.setOnAction(handler);
|
rechercheTextuelle.setOnAction(handleRechercheTextuelle);
|
||||||
|
|
||||||
|
|
||||||
|
EventHandler<ActionEvent> handleRechercheCrieters = event ->{
|
||||||
|
System.out.println("test");
|
||||||
|
Donnees.setUsagesObtenus(daoUsage.findByCriterias(Donnees.getThematiqueSelectionee(),Donnees.getDisciplineSelectionee(),Donnees.getAcademieSelectionee()));
|
||||||
|
Stage resultats = new Stage();
|
||||||
|
try {
|
||||||
|
resultats.setScene(new Scene(FXMLLoader.load(getClass().getResource("/fr/univ_amu/iut/fResultat/FResultat.fxml"))));
|
||||||
|
resultats.show();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
recherche.setOnAction(handleRechercheCrieters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,17 @@
|
|||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.StackPane?>
|
<?import javafx.scene.layout.StackPane?>
|
||||||
|
|
||||||
<AnchorPane id="root" prefHeight="798.0" prefWidth="1365.0" style="-fx-background-color: #f5f0e1#f5f0e1;" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univ_amu.iut.fp.Controller">
|
<AnchorPane id="root" prefHeight="860.0" prefWidth="1365.0" style="-fx-background-color: #f5f0e1#f5f0e1;" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univ_amu.iut.fp.Controller">
|
||||||
<children>
|
<children>
|
||||||
<StackPane id="stackPaneFrance" fx:id="stackPaneFrance" layoutX="43.0" layoutY="92.0" prefHeight="649.0" prefWidth="642.0" style="-fx-background-color: blue;" />
|
<StackPane id="stackPaneFrance" fx:id="stackPaneFrance" layoutX="43.0" layoutY="92.0" prefHeight="649.0" prefWidth="642.0" style="-fx-background-color: blue;" />
|
||||||
<AnchorPane layoutX="11.0" prefHeight="80.0" prefWidth="1019.0" style="-fx-background-color: #1e3d59#1e3d59;" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
|
<AnchorPane layoutX="11.0" prefHeight="80.0" prefWidth="1019.0" style="-fx-background-color: #1e3d59#1e3d59;" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
<TextField id="barreDeRecherche " layoutX="329.0" layoutY="27.0" prefHeight="27.0" prefWidth="372.0" promptText="Entrer nom projet :" style="-fx-background-color: #CDD0D4#CDD0D4; -fx-border-radius: 5em; -fx-background-radius: 5em;" text=" " AnchorPane.leftAnchor="329.0" AnchorPane.rightAnchor="329.0">
|
<TextField fx:id="barreDeRecherche" id="barreDeRecherche" layoutX="329.0" layoutY="27.0" prefHeight="27.0" prefWidth="372.0" promptText="Entrer nom projet :" style="-fx-background-color: #CDD0D4#CDD0D4; -fx-border-radius: 5em; -fx-background-radius: 5em;" text=" " AnchorPane.leftAnchor="329.0" AnchorPane.rightAnchor="329.0">
|
||||||
<cursor>
|
<cursor>
|
||||||
<Cursor fx:constant="TEXT" />
|
<Cursor fx:constant="TEXT" />
|
||||||
</cursor>
|
</cursor>
|
||||||
</TextField>
|
</TextField>
|
||||||
<Button layoutX="1066.0" layoutY="27.0" mnemonicParsing="false" text="RECHERCHER VIA LE NOM" />
|
<Button fx:id="rechercheTextuelle" layoutX="1066.0" layoutY="27.0" mnemonicParsing="false" text="RECHERCHER VIA LE NOM" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<StackPane layoutX="744.0" layoutY="100.0" prefHeight="181.0" prefWidth="622.0" style="-fx-background-color: none;" AnchorPane.rightAnchor="-1.0" AnchorPane.topAnchor="100.0">
|
<StackPane layoutX="744.0" layoutY="100.0" prefHeight="181.0" prefWidth="622.0" style="-fx-background-color: none;" AnchorPane.rightAnchor="-1.0" AnchorPane.topAnchor="100.0">
|
||||||
@ -26,7 +26,6 @@
|
|||||||
<content>
|
<content>
|
||||||
<AnchorPane id="discipline" fx:id="discipline" minHeight="0.0" minWidth="0.0" prefHeight="442.0" prefWidth="620.0" style="-fx-background-color: #f5f0e1#f5f0e1;">
|
<AnchorPane id="discipline" fx:id="discipline" minHeight="0.0" minWidth="0.0" prefHeight="442.0" prefWidth="620.0" style="-fx-background-color: #f5f0e1#f5f0e1;">
|
||||||
<children>
|
<children>
|
||||||
|
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
|
@ -15,9 +15,7 @@ public class Discipline implements Serializable {
|
|||||||
|
|
||||||
private static final List<Discipline> INSTANCES = new ArrayList<>();
|
private static final List<Discipline> INSTANCES = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
public static Discipline Toutes = new Discipline("Toutes disciplines");
|
|
||||||
|
|
||||||
public static Discipline HistoireGeographie = new Discipline("Histoire-géographie");
|
public static Discipline HistoireGeographie = new Discipline("Histoire-géographie");
|
||||||
|
|
||||||
public static Discipline PhysiqueChimie = new Discipline("Physique-chimie");
|
public static Discipline PhysiqueChimie = new Discipline("Physique-chimie");
|
||||||
|
@ -16,12 +16,7 @@ public class DAOThematiqueTest implements DAOThematique {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Thematique> findAll() {
|
public List<Thematique> findAll() {
|
||||||
List<Thematique> liste = new ArrayList<>();
|
return Thematique.toutes();
|
||||||
for (int i = 0; i < 12; i++){
|
|
||||||
Thematique thematique = new Thematique("Thematique n° "+i);
|
|
||||||
liste.add(thematique);
|
|
||||||
}
|
|
||||||
return liste;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,14 +21,24 @@ public class DAOUsageTest implements DAOUsage{
|
|||||||
@Override
|
@Override
|
||||||
public List<Usage> findAll() {
|
public List<Usage> findAll() {
|
||||||
List<Usage> usages = new ArrayList<>();
|
List<Usage> usages = new ArrayList<>();
|
||||||
for( int i = 0; i < 69 ; i++){
|
for( int i = 0; i < 42 ; i++){
|
||||||
Usage tmp = new Usage();
|
Usage tmp = new Usage();
|
||||||
tmp.setNom(String.valueOf(i));
|
tmp.setNom("Usage n°"+ i);
|
||||||
tmp.setDiscipline(Discipline.Technologie);
|
tmp.setDiscipline(Discipline.Technologie);
|
||||||
|
tmp.setThematique(Thematique.CreationNumerique);
|
||||||
tmp.setNiveau(Niveau.Tous);
|
tmp.setNiveau(Niveau.Tous);
|
||||||
tmp.setDescription("je suis un commentaire tres long mais surtout tres utile, je sert a tester l'interface graphique et la mettre au bout de ses limtes");
|
tmp.setDescription("je suis un commentaire tres long mais surtout tres utile, je sert a tester l'interface graphique et la mettre au bout de ses limites");
|
||||||
usages.add(tmp);
|
usages.add(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Usage tmp = new Usage();
|
||||||
|
tmp.setNom("Usage spécial 1");
|
||||||
|
tmp.setDiscipline(Discipline.PhysiqueChimie);
|
||||||
|
tmp.setThematique(Thematique.ClasseInversee);
|
||||||
|
tmp.setNiveau(Niveau.PremierDegre);
|
||||||
|
tmp.setDescription("Un usage très simple, pour un test de recherche");
|
||||||
|
usages.add(tmp);
|
||||||
|
|
||||||
return usages;
|
return usages;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +62,15 @@ public class DAOUsageTest implements DAOUsage{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Usage> findByCriterias(Thematique thematique, Discipline discipline, Academie academie) {
|
public List<Usage> findByCriterias(Thematique thematique, Discipline discipline, Academie academie) {
|
||||||
// TODO Auto-generated method stub
|
List<Usage> list = new ArrayList<>();
|
||||||
return null;
|
for(Usage usage : findAll()){
|
||||||
|
if((thematique==null||thematique==usage.getThematique())&&
|
||||||
|
(discipline==null||discipline==usage.getDiscipline())&&
|
||||||
|
(academie==null||academie==usage.getAcademie())){
|
||||||
|
list.add(usage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<property name="eclipselink.logging.parameters" value="true"/>
|
<property name="eclipselink.logging.parameters" value="true"/>
|
||||||
</properties>
|
</properties>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
<persistence-unit name="gestionUsagesPUTest" transaction-type="RESOURCE_LOCAL">
|
<persistence-unit name="gestionUsagesPUMemory" transaction-type="RESOURCE_LOCAL">
|
||||||
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
|
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
|
||||||
<exclude-unlisted-classes>false</exclude-unlisted-classes>
|
<exclude-unlisted-classes>false</exclude-unlisted-classes>
|
||||||
|
|
||||||
|
@ -1,11 +1,130 @@
|
|||||||
package fr.univ_amu.iut;
|
package fr.univ_amu.iut;
|
||||||
|
|
||||||
|
import fr.univ_amu.iut.fResultat.TableEntry;
|
||||||
|
import fr.univ_amu.iut.model.Discipline;
|
||||||
|
import fr.univ_amu.iut.model.Niveau;
|
||||||
|
import fr.univ_amu.iut.model.Thematique;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.Window;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.testfx.api.FxRobot;
|
||||||
|
import org.testfx.framework.junit5.ApplicationExtension;
|
||||||
|
import org.testfx.framework.junit5.ApplicationTest;
|
||||||
|
import org.testfx.framework.junit5.Start;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
@ExtendWith(ApplicationExtension.class)
|
||||||
public class AppTest {
|
public class AppTest {
|
||||||
|
|
||||||
|
Stage stage;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUpClass() throws Exception {
|
||||||
|
ApplicationTest.launch(AppMain.class, "--testMode=true");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Start
|
||||||
|
public void start(Stage stage) throws Exception {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_should_never_fail() {
|
public void test_should_never_fail() {
|
||||||
assertThat(true).isTrue();
|
assertThat(true).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_initialize_stage_is_showing() {
|
||||||
|
assertThat(stage.isShowing()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void title_is_correct() {
|
||||||
|
assertThat(stage.getTitle()).isEqualTo("Carte des académie");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void boutons_ajoutes() {
|
||||||
|
Pane disciplinesPane = (Pane) stage.getScene().lookup("#discipline");
|
||||||
|
Pane thematiquesPane = (Pane) stage.getScene().lookup("#thematique");
|
||||||
|
|
||||||
|
assertThat(disciplinesPane.getChildren().size()).isEqualTo(Discipline.toutes().size());
|
||||||
|
assertThat(thematiquesPane.getChildren().size()).isEqualTo(Thematique.toutes().size());
|
||||||
|
|
||||||
|
for(int i=0;i<disciplinesPane.getChildren().size();i++){
|
||||||
|
String actualtext = ((Button)disciplinesPane.getChildren().get(i)).getText();
|
||||||
|
String expectedText = Discipline.toutes().get(i).getNom();
|
||||||
|
assertThat(actualtext).isEqualTo(expectedText);
|
||||||
|
}
|
||||||
|
for(int i=0;i<thematiquesPane.getChildren().size();i++){
|
||||||
|
String actualtext = ((Button)thematiquesPane.getChildren().get(i)).getText();
|
||||||
|
String expectedText = Thematique.toutes().get(i).getNom();
|
||||||
|
assertThat(actualtext).isEqualTo(expectedText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void search_should_open_window(FxRobot robot) {
|
||||||
|
Pane disciplinesPane = (Pane) stage.getScene().lookup("#discipline");
|
||||||
|
Pane thematiquesPane = (Pane) stage.getScene().lookup("#thematique");
|
||||||
|
Node recherche = stage.getScene().lookup("#recherche");
|
||||||
|
|
||||||
|
robot.clickOn(disciplinesPane.getChildren().get(1));
|
||||||
|
robot.clickOn(thematiquesPane.getChildren().get(0));
|
||||||
|
|
||||||
|
|
||||||
|
int windowsCount = Stage.getWindows().size();
|
||||||
|
robot.clickOn(recherche);
|
||||||
|
assertThat(Stage.getWindows().size()).isEqualTo(windowsCount+1);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void search_window_should_have_1_result(FxRobot robot) {
|
||||||
|
Pane disciplinesPane = (Pane) stage.getScene().lookup("#discipline");
|
||||||
|
Pane thematiquesPane = (Pane) stage.getScene().lookup("#thematique");
|
||||||
|
Node recherche = stage.getScene().lookup("#recherche");
|
||||||
|
|
||||||
|
robot.clickOn(disciplinesPane.getChildren().get(1));
|
||||||
|
robot.clickOn(thematiquesPane.getChildren().get(0));
|
||||||
|
|
||||||
|
|
||||||
|
int windowsCount = Stage.getWindows().size();
|
||||||
|
robot.clickOn(recherche);
|
||||||
|
|
||||||
|
Scene resultScene = Stage.getWindows().get(windowsCount).getScene();
|
||||||
|
TableView<?> table = (TableView<?>) resultScene.lookup("#table");
|
||||||
|
assertThat(table.getItems().size()).isEqualTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void search_window_result_should_be_shown(FxRobot robot) {
|
||||||
|
Pane disciplinesPane = (Pane) stage.getScene().lookup("#discipline");
|
||||||
|
Pane thematiquesPane = (Pane) stage.getScene().lookup("#thematique");
|
||||||
|
Node recherche = stage.getScene().lookup("#recherche");
|
||||||
|
|
||||||
|
robot.clickOn(disciplinesPane.getChildren().get(1));
|
||||||
|
robot.clickOn(thematiquesPane.getChildren().get(0));
|
||||||
|
|
||||||
|
robot.clickOn(recherche);
|
||||||
|
|
||||||
|
Scene resultScene = Stage.getWindows().get(1).getScene();
|
||||||
|
TableView<TableEntry> table = (TableView<TableEntry>) resultScene.lookup("#table");
|
||||||
|
TableEntry entry = table.getItems().get(0);
|
||||||
|
|
||||||
|
assertThat(entry.getNom()).isEqualTo("Usage spécial 1");
|
||||||
|
assertThat(entry.getDescription()).isEqualTo("Un usage très simple, pour un test de recherche");
|
||||||
|
assertThat(entry.getDiscipline()).isEqualTo(Discipline.PhysiqueChimie.getNom());
|
||||||
|
assertThat(entry.getThematique()).isEqualTo(Thematique.ClasseInversee.getNom());
|
||||||
|
assertThat(entry.getNiveau()).isEqualTo(Niveau.PremierDegre.getNom());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package fr.univ_amu.iut;
|
package fr.univ_amu.iut;
|
||||||
|
|
||||||
|
import fr.univ_amu.iut.dao.factory.DAOFactory;
|
||||||
|
import fr.univ_amu.iut.dao.factory.DAOFactoryProducer;
|
||||||
|
import fr.univ_amu.iut.dao.factory.DAOType;
|
||||||
import fr.univ_amu.iut.dao.jpa.DAOFactoryJPA;
|
import fr.univ_amu.iut.dao.jpa.DAOFactoryJPA;
|
||||||
import fr.univ_amu.iut.model.*;
|
import fr.univ_amu.iut.model.*;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
@ -10,11 +13,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
public class BackendTest {
|
public class BackendTest {
|
||||||
|
|
||||||
private static DAOFactoryJPA daoFactory;
|
private static DAOFactory daoFactory;
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
daoFactory = new DAOFactoryJPA("gestionUsagesPUTest");
|
daoFactory = DAOFactoryProducer.getFactory(DAOType.JPA_MEMORY);
|
||||||
|
|
||||||
Usage usage = new Usage();
|
Usage usage = new Usage();
|
||||||
usage.setNom("Premier usage");
|
usage.setNom("Premier usage");
|
||||||
|
Loading…
Reference in New Issue
Block a user