Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (2)
révision bug affiche que pilotes/chasseurs disponible après affectation dans la même mission
· 8c18c021
Elly Smagghe
authored
Nov 06, 2023
8c18c021
ajout message d'erreur impossible créer une mission si chasseur ou pilote non disponible
· 256b4d7f
Elly Smagghe
authored
Nov 06, 2023
TODOLIST : impossible d'affecter (button) si chasseur ou pilote non rempli
256b4d7f
Show whitespace changes
Inline
Side-by-side
src/main/java/fr/ldnr/starWars/controllers/ClotureMission.java
View file @
256b4d7f
...
...
@@ -42,6 +42,9 @@ public class ClotureMission {
public
String
clotureMission
(
Model
model
)
{
model
.
addAttribute
(
"resultatMission"
,
missionService
.
resultatMission
());
model
.
addAttribute
(
"missions"
,
missionService
.
findByStatut
(
StatutMission
.
ENCOUR
));
if
(
missionService
.
findByStatut
(
StatutMission
.
ENCOUR
).
isEmpty
())
{
model
.
addAttribute
(
"errorMissionNull"
,
"Il n'y pas mission en cours"
);
}
return
"clotureMission"
;
}
...
...
@@ -50,7 +53,6 @@ public class ClotureMission {
@RequestParam
(
value
=
"heures"
)
String
heures
,
@RequestParam
(
value
=
"resultats"
)
String
resultats
,
@RequestParam
(
value
=
"missions"
)
String
missions
)
{
model
.
addAttribute
(
"missions"
,
missionService
.
findByStatut
(
StatutMission
.
ENCOUR
));
// recuperate Mission from db by Id
Integer
idMission
=
(
Integer
.
valueOf
(
missions
));
...
...
@@ -64,6 +66,8 @@ public class ClotureMission {
// persister missionRecupere dans la db
missionService
.
save
(
missionRecupere
);
model
.
addAttribute
(
"missions"
,
missionService
.
findByStatut
(
StatutMission
.
ENCOUR
));
model
.
addAttribute
(
"resultatMission"
,
missionService
.
resultatMission
());
// boucle tous les pilotes dans la Mission
Set
<
Pilote
>
pilotes
=
new
HashSet
<>();
// Create a set to store pilotes in the Mission
...
...
@@ -114,6 +118,7 @@ public class ClotureMission {
pilote
.
setType
(
newType
);
System
.
out
.
println
(
"newType : "
+
newType
);
// update status to disponible?
// then update to db
piloteService
.
save
(
pilote
);
// ---------- FIN CALCUL NB HEURE ET PUIS UPDATE GRADE OU TYPE
...
...
src/main/java/fr/ldnr/starWars/controllers/ListeMissionController.java
View file @
256b4d7f
...
...
@@ -24,7 +24,8 @@ public class ListeMissionController {
@GetMapping
(
"/listeMission"
)
public
String
listeMission
(
Model
model
)
{
model
.
addAttribute
(
"missions"
,
missionService
.
findByStatut
(
StatutMission
.
TERMINE
));
// model.addAttribute("missions", missionService.findByStatut(StatutMission.TERMINE));
model
.
addAttribute
(
"missions"
,
missionService
.
findAll
());
return
"listeMission"
;
}
...
...
src/main/java/fr/ldnr/starWars/controllers/NouvelleMissionController.java
View file @
256b4d7f
...
...
@@ -52,21 +52,16 @@ public class NouvelleMissionController {
this
.
affectationService
=
affectationService
;
}
@RequestMapping
(
"/nouvelleMission"
)
public
String
getMission
(
Model
model
)
{
model
.
addAttribute
(
"typeMissions"
,
missionService
.
listMission
());
model
.
addAttribute
(
"mission"
,
new
Mission
());
model
.
addAttribute
(
"affectationFormVisible"
,
false
);
// Initially hidden
// Update the table with Pilot and Plane info
List
<
Pilote
>
listPilotes
=
piloteService
.
findByEtat
(
EtatPilote
.
DISPONIBLE
);
List
<
Chasseur
>
listChasseurs
=
chasseurService
.
findByEtat
(
EtatChasseur
.
OPERATIONNEL
);
model
.
addAttribute
(
"pilotesDispo"
,
listPilotes
);
model
.
addAttribute
(
"chasseursDispo"
,
listChasseurs
);
model
.
addAttribute
(
"pilotesDispo"
,
listPilotes
);
model
.
addAttribute
(
"chasseursDispo"
,
listChasseurs
);
listPiloteTemp
.
clear
();
listChasseurTemp
.
clear
();
// List<Pilote> listPilotes = piloteService.findByEtat(EtatPilote.DISPONIBLE);
// List<Chasseur> listChasseurs = chasseurService.findByEtat(EtatChasseur.OPERATIONNEL);
// model.addAttribute("pilotesDispo", listPilotes);
// model.addAttribute("chasseursDispo", listChasseurs);
return
"nouvelleMission"
;
}
...
...
@@ -75,20 +70,28 @@ public class NouvelleMissionController {
public
String
nouvelleMissionSubmit
(
Model
model
,
@RequestParam
(
value
=
"titre"
)
String
titre
,
@RequestParam
(
value
=
"typeMissions"
)
String
typeMissions
)
{
// for display
// model.addAttribute("typeMissions", missionService.listMission());
List
<
Pilote
>
listPilotes
=
piloteService
.
findByEtat
(
EtatPilote
.
DISPONIBLE
);
List
<
Chasseur
>
listChasseurs
=
chasseurService
.
findByEtat
(
EtatChasseur
.
OPERATIONNEL
);
if
(
listPilotes
.
isEmpty
()
||
listChasseurs
.
isEmpty
())
{
model
.
addAttribute
(
"errorMissionPasDeRessources"
,
"Impossible de créer une mission, pilote ou chasseur non disponible"
);
return
"nouvelleMission"
;
}
model
.
addAttribute
(
"pilotesDispo"
,
listPilotes
);
model
.
addAttribute
(
"chasseursDispo"
,
listChasseurs
);
// Save the mission to the database
Mission
mission
=
new
Mission
();
mission
.
setTitre
(
titre
);
mission
.
setType
(
TypeMission
.
valueOf
(
typeMissions
));
mission
.
setStatut
(
StatutMission
.
ENCOUR
);
System
.
out
.
println
(
"CHECK : "
+
mission
);
model
.
addAttribute
(
"typeMissions"
,
missionService
.
listMission
());
List
<
Pilote
>
listPilotes
=
piloteService
.
findByEtat
(
EtatPilote
.
DISPONIBLE
);
List
<
Chasseur
>
listChasseurs
=
chasseurService
.
findByEtat
(
EtatChasseur
.
OPERATIONNEL
);
model
.
addAttribute
(
"pilotesDispo"
,
listPilotes
);
model
.
addAttribute
(
"chasseursDispo"
,
listChasseurs
);
missionService
.
save
(
mission
);
idMission
=
mission
.
getIdMission
();
//System.out.println("CHECK2 : " + idMission);
listPiloteTemp
.
clear
();
listChasseurTemp
.
clear
();
// ATTENTION, BUG WHEN WE REFRESH THE PAGE, IT'LL KEEP ADDING THE AFFECTATION (LIKE PUSHING BUTTON AFFECTATION)
return
"nouvelleMission"
;
}
...
...
@@ -101,29 +104,16 @@ public class NouvelleMissionController {
@RequestParam
(
value
=
"piloteSelect"
)
String
piloteSelect
,
@RequestParam
(
value
=
"chasseurSelect"
)
String
chasseurSelect
)
{
// Update the table with Pilot and Plane info
model
.
addAttribute
(
"typeMissions"
,
missionService
.
listMission
());
List
<
Pilote
>
listPilotes
=
piloteService
.
findByEtat
(
EtatPilote
.
DISPONIBLE
);
List
<
Chasseur
>
listChasseurs
=
chasseurService
.
findByEtat
(
EtatChasseur
.
OPERATIONNEL
);
model
.
addAttribute
(
"pilotesDispo"
,
listPilotes
);
model
.
addAttribute
(
"chasseursDispo"
,
listChasseurs
);
System
.
out
.
println
(
"CHECK "
+
piloteSelect
);
// recuperate Pilote from db
Integer
idPilote
=
(
Integer
.
valueOf
(
piloteSelect
));
Pilote
piloteRecupere
=
piloteService
.
findById
(
idPilote
);
System
.
out
.
println
(
"CHECK PILOTE RECUPEREE : "
+
piloteRecupere
);
// recuperate Chasseur from db
Integer
idChasseur
=
(
Integer
.
valueOf
(
chasseurSelect
));
//System.out.println("CHECK chasseurSelect : " + chasseurSelect);
Chasseur
chasseurRecupere
=
chasseurService
.
findById
(
idChasseur
);
System
.
out
.
println
(
"CHECK Chasseur RECUPEREE : "
+
chasseurRecupere
);
// recuperate
Chasseur
from db
// recuperate
Mission
from db
Mission
missionRecupere
=
missionService
.
findById
(
idMission
);
System
.
out
.
println
(
"CHECK Mission RECUPEREE : "
+
missionRecupere
);
//System.out.println("id Mission : " + idMission);
// create et remplir affectation
Affectation
affectation
=
new
Affectation
();
...
...
@@ -131,31 +121,30 @@ public class NouvelleMissionController {
affectation
.
setPilote
(
piloteRecupere
);
affectation
.
setMission
(
missionRecupere
);
affectationService
.
save
(
affectation
);
System
.
out
.
println
(
"affectation : "
+
affectation
);
piloteRecupere
.
getAffectation
().
add
(
affectation
);
chasseurRecupere
.
getAffectation
().
add
(
affectation
);
missionRecupere
.
getAffectation
().
add
(
affectation
);
piloteRecupere
.
setEtat
(
EtatPilote
.
EN_MISSION
);
chasseurRecupere
.
setEtat
(
EtatChasseur
.
EN_MISSION
);
piloteService
.
save
(
piloteRecupere
);
chasseurService
.
save
(
chasseurRecupere
);
missionService
.
save
(
missionRecupere
);
listPiloteTemp
.
add
(
piloteRecupere
);
listChasseurTemp
.
add
(
chasseurRecupere
);
System
.
out
.
println
(
"check listPiloteTemp : "
+
listPiloteTemp
);
System
.
out
.
println
(
"check listChasseurTemp : "
+
listChasseurTemp
);
//
System.out.println("check listPiloteTemp : " + listPiloteTemp);
//
System.out.println("check listChasseurTemp : " + listChasseurTemp);
model
.
addAttribute
(
"listPiloteTemps"
,
listPiloteTemp
);
model
.
addAttribute
(
"listChasseurTemps"
,
listChasseurTemp
);
model
.
addAttribute
(
"idMission"
,
idMission
);
model
.
addAttribute
(
"missionToDisplay"
,
missionService
.
findById
(
idMission
));
//
// Affectation a = new Affectation();
// a.setChasseur(chasseurRecupere);
// a.setPilote(piloteRecupere);
// a.setMission(missionRecupere);
// piloteRecupere.getAffectation().add(a);
// System.out.println("apres ajouter affectation : " + piloteRecupere.getAffectation().toString());
//
// Update the table with Pilot and Plane info
model
.
addAttribute
(
"typeMissions"
,
missionService
.
listMission
());
List
<
Pilote
>
listPilotes
=
piloteService
.
findByEtat
(
EtatPilote
.
DISPONIBLE
);
List
<
Chasseur
>
listChasseurs
=
chasseurService
.
findByEtat
(
EtatChasseur
.
OPERATIONNEL
);
model
.
addAttribute
(
"pilotesDispo"
,
listPilotes
);
model
.
addAttribute
(
"chasseursDispo"
,
listChasseurs
);
return
"nouvelleMission"
;
}
...
...
src/main/resources/templates/clotureMission.html
View file @
256b4d7f
...
...
@@ -14,8 +14,8 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
<header>
<h1><span
class=
'faulty-letter'
>
{
</span>
Cloture Mission
</h1>
</header>
<form
class=
'mission'
action=
"/clotureMission"
method=
"post"
>
<p
th:text=
"${errorMissionNull}"
></p>
<form
class=
'mission'
th:
action=
"
@{
/clotureMission
}
"
method=
"post"
>
<div
class=
'box'
>
<label
for=
"missions"
>
Choisir une mission :
</label>
<select
id=
"missions"
name=
"missions"
>
...
...
src/main/resources/templates/nouvelleMission.html
View file @
256b4d7f
...
...
@@ -19,6 +19,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
<form
class=
'mission'
th:object=
"${mission}"
th:action=
"@{/nouvelleMission}"
method=
"post"
>
<div
>
<div>
<label
for=
"typeMissions"
>
Choisir une mission :
</label>
<select
id=
"typeMissions"
name=
"typeMissions"
>
<option
th:each=
"typeMission : ${typeMissions}"
th:value=
"${typeMission}"
th:text=
"${typeMission}"
></option>
...
...
@@ -30,7 +31,10 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
</div>
<button
type=
"submit"
>
Creer mission
</button>
</div>
<span
th:text=
"${errorMissionPasDeRessources}"
></span>
</form>
<form
class=
'mission'
th:object=
"${affectation}"
th:action=
"@{/affectation/{idMission}}"
method=
"post"
>
...
...
@@ -50,6 +54,7 @@ Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this temp
th:text=
"${chasseurDispo.type + ' ' + chasseurDispo.etat}"
>
</option>
</select>
</div>
<button
type=
"submit"
>
Affecter
</button>
</form>
...
...