Skip to content
GitLab
Explore
Sign in
Register
Show whitespace changes
Inline
Side-by-side
src/main/java/fr/ldnr/starWars/enumerations/EtatPilote.java
View file @
b6f318ef
...
...
@@ -9,5 +9,5 @@ package fr.ldnr.starWars.enumerations;
* @author stag
*/
public
enum
EtatPilote
{
DISPONIBLE
,
EN_MISSION
,
BLESSE
,
TUE
;
DISPONIBLE
,
EN_MISSION
,
BLESSE
,
MORT_AU_COMBAT
;
}
src/main/java/fr/ldnr/starWars/enumerations/GradePilote.java
View file @
b6f318ef
...
...
@@ -13,5 +13,5 @@ package fr.ldnr.starWars.enumerations;
* @author stag
*/
public
enum
GradePilote
{
OFFICIER
,
LIEUTENANT
,
CAPITAINE
,
COMMANDANT
OFFICIER
,
LIEUTENANT
,
CAPITAINE
,
MAJOR
,
COMMANDANT
}
src/main/java/fr/ldnr/starWars/enumerations/ResultatMission.java
View file @
b6f318ef
...
...
@@ -9,5 +9,5 @@ package fr.ldnr.starWars.enumerations;
* @author stag
*/
public
enum
ResultatMission
{
VICTOIRE
,
NA
,
DEFAITE
VICTOIRE
,
DEFAITE
,
NA
}
src/main/java/fr/ldnr/starWars/
controllers/AffectationPiloteChasseur
.java
→
src/main/java/fr/ldnr/starWars/
enumerations/StatutMission
.java
View file @
b6f318ef
/*
* 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/
Interface
.java to edit this template
*/
package
fr.ldnr.starWars.
controller
s
;
package
fr.ldnr.starWars.
enumeration
s
;
/**
*
* @author stag
*/
public
class
AffectationPiloteChasseur
{
public
enum
StatutMission
{
ENCOUR
,
TERMINE
}
src/main/java/fr/ldnr/starWars/repositories/ChasseurRepository.java
View file @
b6f318ef
...
...
@@ -5,6 +5,10 @@
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
;
/**
...
...
@@ -13,4 +17,6 @@ import org.springframework.data.repository.CrudRepository;
*/
public
interface
ChasseurRepository
extends
CrudRepository
<
Chasseur
,
Long
>
{
List
<
Chasseur
>
findByEtat
(
EtatChasseur
etat
);
}
src/main/java/fr/ldnr/starWars/repositories/MissionRepository.java
View file @
b6f318ef
...
...
@@ -5,6 +5,9 @@
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
;
/**
...
...
@@ -12,5 +15,5 @@ import org.springframework.data.repository.CrudRepository;
* @author stag
*/
public
interface
MissionRepository
extends
CrudRepository
<
Mission
,
Long
>{
public
List
<
Mission
>
findByStatut
(
StatutMission
statut
);
}
src/main/java/fr/ldnr/starWars/repositories/PiloteRepository.java
View file @
b6f318ef
...
...
@@ -5,7 +5,11 @@
package
fr.ldnr.starWars.repositories
;
import
fr.ldnr.starWars.domains.Pilote
;
import
fr.ldnr.starWars.services.PiloteService
;
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
;
...
...
@@ -16,4 +20,18 @@ import org.springframework.stereotype.Repository;
@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
View file @
b6f318ef
...
...
@@ -14,4 +14,8 @@ public interface AffectationService {
public
Affectation
save
(
Affectation
affectation
);
}
src/main/java/fr/ldnr/starWars/services/AffectationServiceImplt.java
View file @
b6f318ef
...
...
@@ -6,7 +6,6 @@ package fr.ldnr.starWars.services;
import
fr.ldnr.starWars.domains.Affectation
;
import
fr.ldnr.starWars.repositories.AffectationRepository
;
import
fr.ldnr.starWars.repositories.MissionRepository
;
import
jakarta.persistence.EntityManager
;
import
jakarta.persistence.PersistenceContext
;
import
org.springframework.stereotype.Service
;
...
...
src/main/java/fr/ldnr/starWars/services/ChasseurService.java
View file @
b6f318ef
...
...
@@ -7,6 +7,7 @@ package fr.ldnr.starWars.services;
import
fr.ldnr.starWars.domains.Chasseur
;
import
fr.ldnr.starWars.enumerations.EtatChasseur
;
import
fr.ldnr.starWars.enumerations.TypeChasseur
;
import
java.util.List
;
/**
*
...
...
@@ -18,11 +19,18 @@ public interface ChasseurService {
Chasseur
save
(
Chasseur
chasseur
);
public
List
<
Chasseur
>
findByEtat
(
EtatChasseur
etat
);
public
Iterable
<
Chasseur
>
trouverParId
(
Long
id_chasseur
);
public
Iterable
<
Chasseur
>
trouverParEtat
(
EtatChasseur
etat
);
public
Iterable
<
Chasseur
>
trouverParType
(
TypeChasseur
type
);
public
Iterable
<
Chasseur
>
modifierEtat
(
Long
id_chasseur
,
EtatChasseur
nouvelEtat
);
public
Iterable
<
TypeChasseur
>
listeTypeChasseur
();
public
Chasseur
findById
(
Integer
idChasseur
);
}
src/main/java/fr/ldnr/starWars/services/ChasseurServiceImpl.java
View file @
b6f318ef
...
...
@@ -35,15 +35,14 @@ public class ChasseurServiceImpl implements ChasseurService {
@Override
public
Chasseur
save
(
Chasseur
chasseur
)
{
return
chasseur
;
return
chasseurRepository
.
save
(
chasseur
);
}
@Override
public
Iterable
<
Chasseur
>
trouverParEtat
(
EtatChasseur
etat
)
{
List
<
Chasseur
>
list
=
new
ArrayList
<>();
list
=
em
.
createQuery
(
"FROM Chasseur c WHERE
u
.chasseur.etat = :etat"
)
list
=
em
.
createQuery
(
"FROM Chasseur c WHERE
c
.chasseur.etat = :etat"
)
.
setParameter
(
"etat"
,
etat
)
.
getResultList
();
return
list
;
...
...
@@ -66,7 +65,6 @@ public class ChasseurServiceImpl implements ChasseurService {
return
list
;
}
@Override
public
Iterable
<
Chasseur
>
trouverParType
(
TypeChasseur
type
)
{
...
...
@@ -77,5 +75,27 @@ public class ChasseurServiceImpl implements ChasseurService {
return
list
;
}
@Override
public
Iterable
<
Chasseur
>
modifierEtat
(
Long
id_chasseur
,
EtatChasseur
nouvelEtat
)
{
Chasseur
chasseurModif
=
em
.
find
(
Chasseur
.
class
,
id_chasseur
);
chasseurModif
.
setEtat
(
nouvelEtat
);
em
.
merge
(
chasseurModif
);
return
(
Iterable
<
Chasseur
>)
chasseurModif
;
}
@Override
public
List
<
Chasseur
>
findByEtat
(
EtatChasseur
etat
)
{
return
chasseurRepository
.
findByEtat
(
etat
);
}
@Override
public
Chasseur
findById
(
Integer
idChasseur
)
{
Chasseur
chasseur
=
new
Chasseur
();
chasseur
=
(
Chasseur
)
em
.
createQuery
(
"SELECT c FROM Chasseur c WHERE c.idChasseur= :id"
)
.
setParameter
(
"id"
,
idChasseur
).
getSingleResult
();
return
chasseur
;
}
}
src/main/java/fr/ldnr/starWars/services/MissionService.java
View file @
b6f318ef
...
...
@@ -6,18 +6,26 @@ package fr.ldnr.starWars.services;
import
fr.ldnr.starWars.domains.Mission
;
import
fr.ldnr.starWars.enumerations.ResultatMission
;
import
fr.ldnr.starWars.enumerations.StatutMission
;
import
fr.ldnr.starWars.enumerations.TypeMission
;
import
java.util.List
;
/**
*
* @author Vincent
*/
public
interface
MissionService
{
Iterable
<
Mission
>
findAll
();
Mission
save
(
Mission
mission
);
public
Iterable
<
TypeMission
>
listMission
();
public
Iterable
<
ResultatMission
>
resultatMission
();
public
Mission
findById
(
Integer
idMission
);
List
<
Mission
>
findByStatut
(
StatutMission
statut
);
}
src/main/java/fr/ldnr/starWars/services/MissionServiceImpl.java
View file @
b6f318ef
...
...
@@ -4,8 +4,11 @@
*/
package
fr.ldnr.starWars.services
;
import
fr.ldnr.starWars.domains.Chasseur
;
import
fr.ldnr.starWars.domains.Mission
;
import
fr.ldnr.starWars.domains.Pilote
;
import
fr.ldnr.starWars.enumerations.ResultatMission
;
import
fr.ldnr.starWars.enumerations.StatutMission
;
import
fr.ldnr.starWars.enumerations.TypeMission
;
import
fr.ldnr.starWars.repositories.MissionRepository
;
import
jakarta.persistence.EntityManager
;
...
...
@@ -39,10 +42,30 @@ public class MissionServiceImpl implements MissionService {
List
<
TypeMission
>
list
=
Arrays
.
asList
(
TypeMission
.
values
());
return
list
;
}
@Override
public
Iterable
<
ResultatMission
>
resultatMission
()
{
List
<
ResultatMission
>
resultat
=
Arrays
.
asList
(
ResultatMission
.
values
());
return
resultat
;
}
@Override
public
Mission
save
(
Mission
mission
)
{
return
missionRepository
.
save
(
mission
);
}
@Override
public
Mission
findById
(
Integer
idMission
)
{
Mission
mission
=
new
Mission
();
mission
=
(
Mission
)
entityManager
.
createQuery
(
"SELECT m FROM Mission m WHERE m.idMission = :id"
)
.
setParameter
(
"id"
,
idMission
).
getSingleResult
();
return
mission
;
}
@Override
public
List
<
Mission
>
findByStatut
(
StatutMission
statut
)
{
return
missionRepository
.
findByStatut
(
statut
);
}
}
src/main/java/fr/ldnr/starWars/services/PiloteService.java
View file @
b6f318ef
...
...
@@ -9,7 +9,7 @@ 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.
Optional
;
import
java.util.
List
;
/**
*
...
...
@@ -19,16 +19,26 @@ public interface PiloteService {
public
Iterable
<
Pilote
>
findAll
();
public
Pilote
trouverPar
Nom
(
String
nom
);
public
Pilote
findBy
Nom
(
String
nom
);
public
Iterable
<
Pilote
>
trouverPar
Etat
(
EtatPilote
etat
);
public
List
<
Pilote
>
findBy
Etat
(
EtatPilote
etat
);
public
Iterable
<
Pilote
>
trouverPar
Grade
(
GradePilote
grade
);
public
List
<
Pilote
>
findBy
Grade
(
GradePilote
grade
);
public
Iterable
<
Pilote
>
trouverParType
(
TypePilote
type
);
public
List
<
Pilote
>
findByType
(
TypePilote
type
);
public
List
<
Pilote
>
findByRace
(
RacePilote
race
);
public
List
<
Pilote
>
findByEtatAndType
(
EtatPilote
etat
,
TypePilote
type
);
public
Iterable
<
RacePilote
>
listRace
();
public
Iterable
<
TypePilote
>
listType
();
public
Iterable
<
GradePilote
>
listGrade
();
public
Iterable
<
EtatPilote
>
listEtat
();
public
Pilote
save
(
Pilote
pilote
);
public
Pilote
findById
(
Integer
id_pilote
);
...
...
src/main/java/fr/ldnr/starWars/services/PiloteServiceImpl.java
View file @
b6f318ef
...
...
@@ -12,11 +12,8 @@ import fr.ldnr.starWars.enumerations.TypePilote;
import
fr.ldnr.starWars.repositories.PiloteRepository
;
import
jakarta.persistence.EntityManager
;
import
jakarta.persistence.PersistenceContext
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
static
java
.
util
.
Collections
.
list
;
import
java.util.List
;
import
static
org
.
springframework
.
data
.
util
.
TypeUtils
.
type
;
import
org.springframework.stereotype.Service
;
/**
...
...
@@ -40,57 +37,70 @@ public class PiloteServiceImpl implements PiloteService {
}
@Override
public
Pilote
trouverParNom
(
String
nom
)
{
return
(
Pilote
)
entityManager
.
createQuery
(
"SELECT p FROM Pilote p WHERE p.nom = :nom"
)
.
setParameter
(
"nom"
,
nom
)
.
getSingleResult
();
}
@Override
public
Iterable
<
Pilote
>
trouverParEtat
(
EtatPilote
etat
)
{
List
<
Pilote
>
list
=
new
ArrayList
<>();
list
=
entityManager
.
createQuery
(
"SELECT p FROM Pilote p WHERE p.etat_pilote = :etat"
)
.
setParameter
(
"etat"
,
etat
)
.
getResultList
();
public
Iterable
<
RacePilote
>
listRace
()
{
List
<
RacePilote
>
list
=
Arrays
.
asList
(
RacePilote
.
values
());
return
list
;
}
@Override
public
Iterable
<
Pilote
>
trouverParGrade
(
GradePilote
grade
)
{
List
<
Pilote
>
list
=
new
ArrayList
<>();
list
=
entityManager
.
createQuery
(
"SELECT p FROM Pilote p WHERE p.grade = :grade"
)
.
setParameter
(
"grade"
,
grade
)
.
getResultList
();
public
Iterable
<
TypePilote
>
listType
()
{
List
<
TypePilote
>
list
=
Arrays
.
asList
(
TypePilote
.
values
());
return
list
;
}
@Override
public
Iterable
<
Pilote
>
trouverParType
(
TypePilote
type
)
{
List
<
Pilote
>
list
=
new
ArrayList
<>();
list
=
entityManager
.
createQuery
(
"SELECT p FROM Pilote p WHERE p.grade = :type"
)
.
setParameter
(
"type"
,
type
)
.
getResultList
();
public
Iterable
<
GradePilote
>
listGrade
()
{
List
<
GradePilote
>
list
=
Arrays
.
asList
(
GradePilote
.
values
());
return
list
;
}
@Override
public
Iterable
<
Race
Pilote
>
list
Race
()
{
List
<
Race
Pilote
>
list
=
Arrays
.
asList
(
Race
Pilote
.
values
());
public
Iterable
<
Etat
Pilote
>
list
Etat
()
{
List
<
Etat
Pilote
>
list
=
Arrays
.
asList
(
Etat
Pilote
.
values
());
return
list
;
}
@Override
public
Pilote
save
(
Pilote
pilote
)
{
pilote
.
setType_pilote
(
TypePilote
.
APPRENTI
);
return
piloteRepository
.
save
(
pilote
);
}
@Override
public
Pilote
findById
(
Integer
id
_p
ilote
)
{
public
Pilote
findById
(
Integer
id
P
ilote
)
{
Pilote
pilote
=
new
Pilote
();
pilote
=
(
Pilote
)
entityManager
.
createQuery
(
"SELECT p FROM Pilote p WHERE p.id
_p
ilote = :id"
)
.
setParameter
(
"id"
,
id
_p
ilote
).
getSingleResult
();
pilote
=
(
Pilote
)
entityManager
.
createQuery
(
"SELECT p FROM Pilote p WHERE p.id
P
ilote = :id"
)
.
setParameter
(
"id"
,
id
P
ilote
).
getSingleResult
();
return
pilote
;
}
@Override
public
List
<
Pilote
>
findByEtat
(
EtatPilote
etat
)
{
return
piloteRepository
.
findByEtat
(
etat
);
}
@Override
public
Pilote
findByNom
(
String
nom
)
{
return
piloteRepository
.
findByNom
(
nom
);
}
@Override
public
List
<
Pilote
>
findByGrade
(
GradePilote
grade
)
{
return
piloteRepository
.
findByGrade
(
grade
);
}
@Override
public
List
<
Pilote
>
findByType
(
TypePilote
type
)
{
return
piloteRepository
.
findByType
(
type
);
}
@Override
public
List
<
Pilote
>
findByRace
(
RacePilote
race
)
{
return
piloteRepository
.
findByRace
(
race
);
}
@Override
public
List
<
Pilote
>
findByEtatAndType
(
EtatPilote
etat
,
TypePilote
type
)
{
return
piloteRepository
.
findByEtatAndType
(
etat
,
type
);
}
}
src/main/resources/fonts/Star Wars.ttf
0 → 100644
View file @
b6f318ef
File added
src/main/resources/img/screenshot000.jpg
0 → 100644
View file @
b6f318ef
902 KiB
src/main/resources/img/ywing_starfighter_star_wars_3d_model_c4d_max_obj_fbx_ma_lwo_3ds_3dm_stl_4427505_o.jpg
0 → 100644
View file @
b6f318ef
158 KiB
src/main/resources/static/style.css
View file @
b6f318ef
@font-face
{
font-family
:
'Star Wars'
,
sans-serif
;
}
h1
{
font-family
:
'Star Wars'
,
sans-serif
;
}
body
{
font-family
:
'Star Wars'
,
sans-serif
;
background-image
:
url("https://p.turbosquid.com/ts-thumb/p4/gieJXZ/ZM/screenshot001/png/1650377346/1920x1080/fit_q99/cfea16e5fcc5a49514ffdb25a1eeb849c115d0eb/screenshot001.jpg")
;
background-size
:
50%
;
//
background-position
:
bottom
right
;
background-repeat
:
no-repeat
;
background-size
:
cover
;
}
body
{
display
:
flex
;
flex-direction
:
column
;
...
...
@@ -13,3 +31,42 @@ th{
a
{
color
:
yellow
;
}
.tri
{
display
:
flex
;
flex-direction
:
row
;
width
:
50%
;
justify-content
:
space-between
;
}
.box
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
margin
:
auto
;
}
.label
{
width
:
100px
;
/* Largeur souhaitée pour les labels */
text-align
:
right
;
/* Alignez le texte du label à droite */
margin-right
:
auto
;
/* Marge à droite pour l'espacement du texte du label */
margin-left
:
auto
;
}
.bouton
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
margin-left
:
auto
;
margin-right
:
auto
;
}
main
::before
{
content
:
""
;
position
:
absolute
;
top
:
0
;
right
:
0
;
bottom
:
0
;
left
:
0
;
background
:
rgba
(
0
,
0
,
0
,
0.5
);
/* Adjust the last value (alpha) to control the transparency */
z-index
:
-1
;
/* Place the overlay behind the content */
}
\ No newline at end of file
src/main/resources/templates/affectation.html
0 → 100644
View file @
b6f318ef
<!DOCTYPE html>
<!--
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this template
-->
<html>
<head>
<title>
Affectation
</title>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
rel=
"stylesheet"
href=
"/style.css"
>
<link
href=
"https://fonts.cdnfonts.com/css/star-wars"
rel=
"stylesheet"
>
<style>
@import
url('https://fonts.cdnfonts.com/css/star-wars')
;
</style>
</head>
<body>
<header>
<h1>
affecter un chasseur a un pilote
</h1>
</header>
<main>
<form
action=
"affectation"
>
<fieldset>
<legend>
affecter un chasseur à un pilote
</legend>
<div>
<label
for=
"pilotes"
>
choisir un pilote :
</label>
<select
id=
"pilotes"
name=
"pilotes"
>
<option
th:each=
"pilotes : ${listePilotes}"
th:value=
"${pilotes}"
th:text=
"${pilotes.nom}"
>
</option>
</select>
</div>
<div>
<label
for=
"chasseurs"
>
choisir un chasseur :
</label>
<select
id=
"chasseurs"
name=
"chasseurs"
>
<option
th:each=
"chasseurs : ${listeChasseurs}"
th:value=
"${chasseurs}"
th:text=
"${chasseurs.type_chasseur}"
>
</option>
</select>
</div>
</fieldset>
<input
type=
"submit"
value=
"Valider"
/>
<input
type=
"reset"
value=
"Annuler"
/>
</form>
</main>
<footer>
<a
href=
"/menu"
class=
"menu"
>
retour au menu
</a>
</footer>
</body>
</html>
Prev
1
2
3
Next