Skip to content
GitLab
Explore
Sign in
Register
Show whitespace changes
Inline
Side-by-side
src/main/java/fr/ldnr/starWars/controllers/NouvelleMissionController.java
View file @
c873add6
...
...
@@ -4,10 +4,157 @@
*/
package
fr.ldnr.starWars.controllers
;
import
fr.ldnr.starWars.domains.Affectation
;
import
fr.ldnr.starWars.domains.Chasseur
;
import
fr.ldnr.starWars.domains.Mission
;
import
fr.ldnr.starWars.domains.Pilote
;
import
fr.ldnr.starWars.enumerations.EtatChasseur
;
import
fr.ldnr.starWars.enumerations.EtatPilote
;
import
fr.ldnr.starWars.enumerations.StatutMission
;
import
fr.ldnr.starWars.enumerations.TypeMission
;
import
fr.ldnr.starWars.services.AffectationService
;
import
fr.ldnr.starWars.services.ChasseurService
;
import
fr.ldnr.starWars.services.MissionService
;
import
fr.ldnr.starWars.services.PiloteService
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
*
* @author stag
*/
@Controller
public
class
NouvelleMissionController
{
@Autowired
private
final
MissionService
missionService
;
@Autowired
private
final
PiloteService
piloteService
;
@Autowired
private
final
ChasseurService
chasseurService
;
@Autowired
private
final
AffectationService
affectationService
;
// pour stocker les pilotes et les chasseurs temporairement
ArrayList
<
Pilote
>
listPiloteTemp
=
new
ArrayList
<>();
ArrayList
<
Chasseur
>
listChasseurTemp
=
new
ArrayList
<>();
Integer
idMission
;
public
NouvelleMissionController
(
MissionService
missionService
,
PiloteService
piloteService
,
ChasseurService
chasseurService
,
AffectationService
affectationService
)
{
this
.
missionService
=
missionService
;
this
.
piloteService
=
piloteService
;
this
.
chasseurService
=
chasseurService
;
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
);
return
"nouvelleMission"
;
}
@PostMapping
(
"/nouvelleMission"
)
public
String
nouvelleMissionSubmit
(
Model
model
,
@RequestParam
(
value
=
"titre"
)
String
titre
,
@RequestParam
(
value
=
"typeMissions"
)
String
typeMissions
)
{
// 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);
// ATTENTION, BUG WHEN WE REFRESH THE PAGE, IT'LL KEEP ADDING THE AFFECTATION (LIKE PUSHING BUTTON AFFECTATION)
return
"nouvelleMission"
;
}
@PostMapping
(
"/affectation"
)
// Handle Affectation form submission
//@PostMapping("/affectation/{idMission}")
// public String affectationSubmit(@PathVariable Long missionId, @ModelAttribute Affectation affectation, Model model) {
public
String
affectationSubmit
(
Model
model
,
@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
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
();
affectation
.
setChasseur
(
chasseurRecupere
);
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
);
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
);
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());
//
return
"nouvelleMission"
;
}
}
src/main/java/fr/ldnr/starWars/domains/Affectation.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package
fr.ldnr.starWars.domains
;
import
jakarta.persistence.EmbeddedId
;
import
jakarta.persistence.Entity
;
import
jakarta.persistence.GeneratedValue
;
import
jakarta.persistence.GenerationType
;
import
jakarta.persistence.Id
;
import
jakarta.persistence.JoinColumn
;
import
jakarta.persistence.ManyToOne
;
import
jakarta.persistence.MapsId
;
import
java.util.Objects
;
/**
*
* @author stag
*/
@Entity
public
class
Affectation
{
@Id
// to mark the primary key
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Integer
idAffectation
;;
@ManyToOne
private
Pilote
pilote
;
@ManyToOne
private
Chasseur
chasseur
;
@ManyToOne
private
Mission
mission
;
public
Integer
getIdAffectation
()
{
return
idAffectation
;
}
public
void
setIdAffectation
(
Integer
idAffectation
)
{
this
.
idAffectation
=
idAffectation
;
}
public
Pilote
getPilote
()
{
return
pilote
;
}
public
void
setPilote
(
Pilote
pilote
)
{
this
.
pilote
=
pilote
;
}
public
Chasseur
getChasseur
()
{
return
chasseur
;
}
public
void
setChasseur
(
Chasseur
chasseur
)
{
this
.
chasseur
=
chasseur
;
}
public
Mission
getMission
()
{
return
mission
;
}
public
void
setMission
(
Mission
mission
)
{
this
.
mission
=
mission
;
}
@Override
public
int
hashCode
()
{
int
hash
=
3
;
hash
=
59
*
hash
+
Objects
.
hashCode
(
this
.
idAffectation
);
return
hash
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
Affectation
other
=
(
Affectation
)
obj
;
return
Objects
.
equals
(
this
.
idAffectation
,
other
.
idAffectation
);
}
// @Override
// public String toString() {
// return "Affectation{" + "idAffectation=" + idAffectation + ", pilote=" + pilote + ", chasseur=" + chasseur + ", mission=" + mission + '}';
// }
}
src/main/java/fr/ldnr/starWars/domains/Chasseur.java
View file @
c873add6
...
...
@@ -4,10 +4,103 @@
*/
package
fr.ldnr.starWars.domains
;
import
fr.ldnr.starWars.enumerations.EtatChasseur
;
import
fr.ldnr.starWars.enumerations.TypeChasseur
;
import
jakarta.persistence.Entity
;
import
jakarta.persistence.GeneratedValue
;
import
jakarta.persistence.GenerationType
;
import
jakarta.persistence.Id
;
import
jakarta.persistence.OneToMany
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
/**
*
* @author stag
*/
@Entity
public
class
Chasseur
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Integer
idChasseur
;
private
TypeChasseur
type
;
private
EtatChasseur
etat
;
@OneToMany
(
mappedBy
=
"chasseur"
)
Set
<
Affectation
>
affectation
=
new
HashSet
<>();
public
Integer
getIdChasseur
()
{
return
idChasseur
;
}
public
void
setIdChasseur
(
Integer
idChasseur
)
{
this
.
idChasseur
=
idChasseur
;
}
public
TypeChasseur
getType
()
{
return
type
;
}
public
void
setType
(
TypeChasseur
type
)
{
this
.
type
=
type
;
}
public
EtatChasseur
getEtat
()
{
return
etat
;
}
public
void
setEtat
(
EtatChasseur
etat
)
{
this
.
etat
=
etat
;
}
@Override
public
int
hashCode
()
{
int
hash
=
3
;
hash
=
61
*
hash
+
Objects
.
hashCode
(
this
.
idChasseur
);
return
hash
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
Chasseur
other
=
(
Chasseur
)
obj
;
return
Objects
.
equals
(
this
.
idChasseur
,
other
.
idChasseur
);
}
@Override
public
String
toString
()
{
return
"Chasseur{"
+
"id_chasseur="
+
idChasseur
+
", type_chasseur="
+
type
+
", etat_chasseur="
+
etat
+
'}'
;
}
public
void
setId
(
String
string
)
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
// Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
public
Set
<
Affectation
>
getAffectation
()
{
return
affectation
;
}
public
void
setAffectation
(
Set
<
Affectation
>
affectation
)
{
this
.
affectation
=
affectation
;
}
public
Object
getChasseurs
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
// Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
}
src/main/java/fr/ldnr/starWars/domains/Mission.java
View file @
c873add6
...
...
@@ -4,10 +4,120 @@
*/
package
fr.ldnr.starWars.domains
;
import
fr.ldnr.starWars.enumerations.ResultatMission
;
import
fr.ldnr.starWars.enumerations.StatutMission
;
import
fr.ldnr.starWars.enumerations.TypeMission
;
import
jakarta.persistence.Entity
;
import
jakarta.persistence.GeneratedValue
;
import
jakarta.persistence.GenerationType
;
import
jakarta.persistence.Id
;
import
jakarta.persistence.OneToMany
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
/**
*
* @author stag
*/
@Entity
public
class
Mission
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Integer
idMission
;
private
String
titre
;
private
TypeMission
type
;
private
Integer
nbHeure
;
private
ResultatMission
resultat
;
private
StatutMission
statut
;
@OneToMany
(
mappedBy
=
"mission"
)
Set
<
Affectation
>
affectation
=
new
HashSet
<>();
public
Integer
getIdMission
()
{
return
idMission
;
}
public
void
setIdMission
(
Integer
idMission
)
{
this
.
idMission
=
idMission
;
}
public
String
getTitre
()
{
return
titre
;
}
public
void
setTitre
(
String
titre
)
{
this
.
titre
=
titre
;
}
public
TypeMission
getType
()
{
return
type
;
}
public
void
setType
(
TypeMission
type
)
{
this
.
type
=
type
;
}
public
Integer
getNbHeure
()
{
return
nbHeure
;
}
public
void
setNbHeure
(
Integer
nbHeure
)
{
this
.
nbHeure
=
nbHeure
;
}
public
StatutMission
getStatut
()
{
return
statut
;
}
public
void
setStatut
(
StatutMission
statut
)
{
this
.
statut
=
statut
;
}
public
Set
<
Affectation
>
getAffectation
()
{
return
affectation
;
}
public
void
setAffectation
(
Set
<
Affectation
>
affectation
)
{
this
.
affectation
=
affectation
;
}
@Override
public
int
hashCode
()
{
int
hash
=
5
;
hash
=
73
*
hash
+
Objects
.
hashCode
(
this
.
idMission
);
return
hash
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
Mission
other
=
(
Mission
)
obj
;
return
Objects
.
equals
(
this
.
idMission
,
other
.
idMission
);
}
public
ResultatMission
getResultat
()
{
return
resultat
;
}
public
void
setResultat
(
ResultatMission
resultat
)
{
this
.
resultat
=
resultat
;
}
@Override
public
String
toString
()
{
return
"Mission{"
+
"id_mission="
+
idMission
+
", titre_mission="
+
titre
+
", type_mission="
+
type
+
", nbHeure="
+
nbHeure
+
", resultat="
+
resultat
+
", affectation="
+
affectation
+
'}'
;
}
}
src/main/java/fr/ldnr/starWars/domains/Pilote.java
View file @
c873add6
...
...
@@ -4,10 +4,139 @@
*/
package
fr.ldnr.starWars.domains
;
import
fr.ldnr.starWars.enumerations.EtatPilote
;
import
fr.ldnr.starWars.enumerations.GradePilote
;
import
fr.ldnr.starWars.enumerations.RacePilote
;
import
fr.ldnr.starWars.enumerations.TypePilote
;
import
jakarta.persistence.Entity
;
import
jakarta.persistence.FetchType
;
import
jakarta.persistence.GeneratedValue
;
import
jakarta.persistence.GenerationType
;
import
jakarta.persistence.Id
;
import
jakarta.persistence.OneToMany
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
/**
*
* @author stag
*/
@Entity
public
class
Pilote
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Integer
idPilote
;
private
String
nom
;
private
String
prenom
;
private
Integer
age
;
private
RacePilote
race
;
private
TypePilote
type
;
private
EtatPilote
etat
;
private
GradePilote
grade
;
@OneToMany
(
mappedBy
=
"pilote"
,
fetch
=
FetchType
.
EAGER
)
Set
<
Affectation
>
affectation
=
new
HashSet
<>();
public
Integer
getIdPilote
()
{
return
idPilote
;
}
public
void
setIdPilote
(
Integer
idPilote
)
{
this
.
idPilote
=
idPilote
;
}
public
String
getNom
()
{
return
nom
;
}
public
void
setNom
(
String
nom
)
{
this
.
nom
=
nom
;
}
public
String
getPrenom
()
{
return
prenom
;
}
public
void
setPrenom
(
String
prenom
)
{
this
.
prenom
=
prenom
;
}
public
Integer
getAge
()
{
return
age
;
}
public
void
setAge
(
Integer
age
)
{
this
.
age
=
age
;
}
public
Set
<
Affectation
>
getAffectation
()
{
return
affectation
;
}
public
void
setAffectation
(
Set
<
Affectation
>
affectation
)
{
this
.
affectation
=
affectation
;
}
public
RacePilote
getRace
()
{
return
race
;
}
public
void
setRace
(
RacePilote
race
)
{
this
.
race
=
race
;
}
public
EtatPilote
getEtat
()
{
return
etat
;
}
public
void
setEtat
(
EtatPilote
etat
)
{
this
.
etat
=
etat
;
}
public
GradePilote
getGrade
()
{
return
grade
;
}
public
void
setGrade
(
GradePilote
grade
)
{
this
.
grade
=
grade
;
}
public
TypePilote
getType
()
{
return
type
;
}
public
void
setType
(
TypePilote
type
)
{
this
.
type
=
type
;
}
@Override
public
int
hashCode
()
{
int
hash
=
7
;
hash
=
67
*
hash
+
Objects
.
hashCode
(
this
.
idPilote
);
return
hash
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(
obj
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
obj
.
getClass
())
{
return
false
;
}
final
Pilote
other
=
(
Pilote
)
obj
;
return
Objects
.
equals
(
this
.
idPilote
,
other
.
idPilote
);
}
@Override
public
String
toString
()
{
return
"Pilote{"
+
"idPilote="
+
idPilote
+
", nom="
+
nom
+
", prenom="
+
prenom
+
", age="
+
age
+
", race="
+
race
+
", type="
+
type
+
", etat="
+
etat
+
", grade="
+
grade
+
", affectation="
+
affectation
+
'}'
;
}
}
src/main/java/fr/ldnr/starWars/enumerations/EtatChasseur.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template
*/
package
fr.ldnr.starWars.enumerations
;
/**
*
* @author stag
*/
public
enum
EtatChasseur
{
OPERATIONNEL
,
EN_MISSION
,
MAINTENANCE
,
DETRUIT
;
}
src/main/java/fr/ldnr/starWars/enumerations/EtatPilote.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template
*/
package
fr.ldnr.starWars.enumerations
;
/**
*
* @author stag
*/
public
enum
EtatPilote
{
DISPONIBLE
,
EN_MISSION
,
BLESSE
,
MORT_AU_COMBAT
;
}
src/main/java/fr/ldnr/starWars/enumerations/GradePilote.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template
*/
package
fr.ldnr.starWars.enumerations
;
/**
* Apprenti : moins de 100 heures de vol Officier : moins de 500 heures de vol
* Lieutenant : moins de 1500 heures de vol et au moins une mission de combat
* Capitaine : moins de 4000 heures de vol et au moins 3 missions Commandant :
* 4000 heures de vol et au moins 10 missions
*
* @author stag
*/
public
enum
GradePilote
{
OFFICIER
,
LIEUTENANT
,
CAPITAINE
,
MAJOR
,
COMMANDANT
}
src/main/java/fr/ldnr/starWars/enumerations/RacePilote.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template
*/
package
fr.ldnr.starWars.enumerations
;
/**
*
* @author stag
*/
public
enum
RacePilote
{
CHALACTEENS
,
CHISS
,
HUMAINS
,
ITHORIENS
,
MIRIALANS
,
KELDOR
,
KIFFARS
,
MIRALUKAS
,
NAGAIS
,
NEIMOIDIENS
,
NIKTOS
,
NOGHRIS
,
ONGREES
,
PAUANS
,
QUERMIENS
,
RAKATA
,
RODIENS
,
THISSPASIENS
,
TOGRUTAS
,
WOOKIES
,
WRONIANS
,
ZABRAKS
}
src/main/java/fr/ldnr/starWars/enumerations/ResultatMission.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template
*/
package
fr.ldnr.starWars.enumerations
;
/**
*
* @author stag
*/
public
enum
ResultatMission
{
VICTOIRE
,
DEFAITE
,
NA
}
src/main/java/fr/ldnr/starWars/enumerations/StatutMission.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
*/
package
fr.ldnr.starWars.enumerations
;
/**
*
* @author stag
*/
public
enum
StatutMission
{
ENCOUR
,
TERMINE
}
src/main/java/fr/ldnr/starWars/
controllers/ChasseurControlle
r.java
→
src/main/java/fr/ldnr/starWars/
enumerations/TypeChasseu
r.java
View file @
c873add6
...
...
@@ -2,12 +2,12 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package
fr.ldnr.starWars.
controller
s
;
package
fr.ldnr.starWars.
enumeration
s
;
/**
*
* @author
stag
* @author
Johad
*/
public
class
ChasseurControlle
r
{
public
enum
TypeChasseu
r
{
X_WING
,
Y_WING
;
}
src/main/java/fr/ldnr/starWars/enumerations/TypeMission.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template
*/
package
fr.ldnr.starWars.enumerations
;
/**
*
* @author stag
*/
public
enum
TypeMission
{
ENTRAINEMENT
,
COMBAT
}
src/main/java/fr/ldnr/starWars/
controllers/PiloteController
.java
→
src/main/java/fr/ldnr/starWars/
enumerations/TypePilote
.java
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/
Class
.java to edit this template
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/
Enum
.java to edit this template
*/
package
fr.ldnr.starWars.
controller
s
;
package
fr.ldnr.starWars.
enumeration
s
;
/**
*
* @author stag
*/
public
class
PiloteController
{
public
enum
TypePilote
{
APPRENTI
,
COMBATTANT
}
src/main/java/fr/ldnr/starWars/
controllers/MissionController
.java
→
src/main/java/fr/ldnr/starWars/
repositories/AffectationRepository
.java
View file @
c873add6
...
...
@@ -2,12 +2,17 @@
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package
fr.ldnr.starWars.controllers
;
package
fr.ldnr.starWars.repositories
;
import
fr.ldnr.starWars.domains.Affectation
;
import
org.springframework.data.repository.CrudRepository
;
import
org.springframework.stereotype.Repository
;
/**
*
* @author stag
*/
public
class
MissionController
{
@Repository
public
interface
AffectationRepository
extends
CrudRepository
<
Affectation
,
Long
>
{
}
src/main/java/fr/ldnr/starWars/repositories/ChasseurRepository.java
View file @
c873add6
...
...
@@ -4,10 +4,19 @@
*/
package
fr.ldnr.starWars.repositories
;
import
fr.ldnr.starWars.domains.Chasseur
;
import
fr.ldnr.starWars.domains.Pilote
;
import
fr.ldnr.starWars.enumerations.EtatChasseur
;
import
fr.ldnr.starWars.enumerations.EtatPilote
;
import
java.util.List
;
import
org.springframework.data.repository.CrudRepository
;
/**
*
* @author stag
*/
public
interface
ChasseurRepository
{
public
interface
ChasseurRepository
extends
CrudRepository
<
Chasseur
,
Long
>
{
List
<
Chasseur
>
findByEtat
(
EtatChasseur
etat
);
}
src/main/java/fr/ldnr/starWars/repositories/MissionRepository.java
View file @
c873add6
...
...
@@ -4,10 +4,16 @@
*/
package
fr.ldnr.starWars.repositories
;
import
fr.ldnr.starWars.domains.Mission
;
import
fr.ldnr.starWars.enumerations.EtatPilote
;
import
fr.ldnr.starWars.enumerations.StatutMission
;
import
java.util.List
;
import
org.springframework.data.repository.CrudRepository
;
/**
*
* @author stag
*/
public
interface
MissionRepository
{
public
interface
MissionRepository
extends
CrudRepository
<
Mission
,
Long
>
{
public
List
<
Mission
>
findByStatut
(
StatutMission
statut
);
}
src/main/java/fr/ldnr/starWars/repositories/PiloteRepository.java
View file @
c873add6
...
...
@@ -4,10 +4,34 @@
*/
package
fr.ldnr.starWars.repositories
;
import
fr.ldnr.starWars.domains.Pilote
;
import
fr.ldnr.starWars.enumerations.EtatPilote
;
import
fr.ldnr.starWars.enumerations.GradePilote
;
import
fr.ldnr.starWars.enumerations.RacePilote
;
import
fr.ldnr.starWars.enumerations.TypePilote
;
import
java.util.List
;
import
org.springframework.data.repository.CrudRepository
;
import
org.springframework.stereotype.Repository
;
/**
*
* @author stag
*/
public
interface
PiloteRepository
{
@Repository
public
interface
PiloteRepository
extends
CrudRepository
<
Pilote
,
Long
>
{
Pilote
findByNom
(
String
nom
);
List
<
Pilote
>
findByEtat
(
EtatPilote
etat
);
List
<
Pilote
>
findByGrade
(
GradePilote
grade
);
List
<
Pilote
>
findByType
(
TypePilote
type_pilote
);
List
<
Pilote
>
findByRace
(
RacePilote
race
);
// to test
//List<Pilote> findByEtatInAndTypeIn(List<EtatPilote> etats, List<TypePilote> types);
List
<
Pilote
>
findByEtatAndType
(
EtatPilote
etat
,
TypePilote
type
);
}
src/main/java/fr/ldnr/starWars/services/AffectationService.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
*/
package
fr.ldnr.starWars.services
;
import
fr.ldnr.starWars.domains.Affectation
;
/**
*
* @author stag
*/
public
interface
AffectationService
{
public
Affectation
save
(
Affectation
affectation
);
}
src/main/java/fr/ldnr/starWars/services/AffectationServiceImplt.java
0 → 100644
View file @
c873add6
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package
fr.ldnr.starWars.services
;
import
fr.ldnr.starWars.domains.Affectation
;
import
fr.ldnr.starWars.repositories.AffectationRepository
;
import
jakarta.persistence.EntityManager
;
import
jakarta.persistence.PersistenceContext
;
import
org.springframework.stereotype.Service
;
/**
*
* @author stag
*/
@Service
public
class
AffectationServiceImplt
implements
AffectationService
{
@PersistenceContext
private
EntityManager
entityManager
;
AffectationRepository
affectationRepository
;
public
AffectationServiceImplt
(
AffectationRepository
affectationRepository
)
{
this
.
affectationRepository
=
affectationRepository
;
}
@Override
public
Affectation
save
(
Affectation
affectation
)
{
return
affectationRepository
.
save
(
affectation
);
}
}
Prev
1
2
3
4
5
Next