Skip to content
......@@ -4,10 +4,13 @@
*/
package fr.ldnr.starWars.repositories;
import fr.ldnr.starWars.domains.Mission;
import org.springframework.data.repository.CrudRepository;
/**
*
* @author stag
*/
public interface MissionRepository {
public interface MissionRepository extends CrudRepository<Mission, Long>{
}
......@@ -4,10 +4,16 @@
*/
package fr.ldnr.starWars.repositories;
import fr.ldnr.starWars.domains.Pilote;
import fr.ldnr.starWars.services.PiloteService;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
/**
*
* @author stag
*/
public interface PiloteRepository {
@Repository
public interface PiloteRepository extends CrudRepository<Pilote, Long> {
}
/*
* 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);
}
/*
* 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 fr.ldnr.starWars.repositories.MissionRepository;
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);
}
}
......@@ -5,6 +5,8 @@
package fr.ldnr.starWars.services;
import fr.ldnr.starWars.domains.Chasseur;
import fr.ldnr.starWars.enumerations.EtatChasseur;
import fr.ldnr.starWars.enumerations.TypeChasseur;
/**
*
......@@ -13,4 +15,14 @@ import fr.ldnr.starWars.domains.Chasseur;
public interface ChasseurService {
Iterable<Chasseur> findAll();
Chasseur save(Chasseur chasseur);
public Iterable<Chasseur> trouverParId(Long id_chasseur);
public Iterable<Chasseur> trouverParEtat(EtatChasseur etat);
public Iterable<Chasseur> trouverParType(TypeChasseur type);
public Iterable<TypeChasseur> listeTypeChasseur();
}
/*
* 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.Chasseur;
import fr.ldnr.starWars.enumerations.EtatChasseur;
import fr.ldnr.starWars.enumerations.TypeChasseur;
import fr.ldnr.starWars.repositories.ChasseurRepository;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.stereotype.Service;
/**
......@@ -15,6 +18,8 @@ import org.springframework.stereotype.Service;
@Service
public class ChasseurServiceImpl implements ChasseurService {
@PersistenceContext
private EntityManager em;
ChasseurRepository chasseurRepository;
public ChasseurServiceImpl(ChasseurRepository cr) {
......@@ -22,13 +27,53 @@ public class ChasseurServiceImpl implements ChasseurService {
chasseurRepository = cr;
}
@Override
public Iterable<Chasseur> findAll() {
return chasseurRepository.findAll();
}
@Override
public Chasseur save(Chasseur chasseur) {
return chasseur;
}
@Override
public Iterable<Chasseur> trouverParEtat(EtatChasseur etat) {
List<Chasseur> list = new ArrayList<>();
list = em.createQuery("FROM Chasseur c WHERE u.chasseur.etat = :etat")
.setParameter("etat", etat)
.getResultList();
return list;
}
@Override
public Iterable<TypeChasseur> listeTypeChasseur() {
List<TypeChasseur> list = Arrays.asList(TypeChasseur.values());
return list;
}
@Override
public Iterable<Chasseur> trouverParType(TypeChasseur type) {
List<Chasseur> list = new ArrayList();
list = em.createQuery("FROM Chasseur c WHERE c.type = :type")
.setParameter("type", type)
.getResultList();
return list;
}
@Override
public Iterable<Chasseur> trouverParId(Long id_chasseur) {
List<Chasseur> list = new ArrayList();
list = em.createQuery("FROM Chasseur c WHERE c.id = :id")
.setParameter("id", id_chasseur)
.getResultList();
return list;
}
}
......@@ -4,10 +4,17 @@
*/
package fr.ldnr.starWars.services;
import fr.ldnr.starWars.domains.Mission;
import fr.ldnr.starWars.enumerations.TypeMission;
/**
*
* @author stag
* @author Vincent
*/
public interface MissionService {
Iterable<Mission> findAll();
public Iterable<TypeMission> listMission();
}
......@@ -4,10 +4,40 @@
*/
package fr.ldnr.starWars.services;
import fr.ldnr.starWars.domains.Mission;
import fr.ldnr.starWars.enumerations.TypeMission;
import fr.ldnr.starWars.repositories.MissionRepository;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.Arrays;
import java.util.List;
import org.springframework.stereotype.Service;
/**
*
* @author stag
* @author Vincent
*/
public class MissionServiceImpl {
@Service
public class MissionServiceImpl implements MissionService {
@PersistenceContext
private EntityManager entityManager;
MissionRepository missionRepository;
public MissionServiceImpl(MissionRepository missionRepository) {
this.missionRepository = missionRepository;
}
@Override
public Iterable<Mission>findAll() {
return missionRepository.findAll();
}
@Override
public Iterable<TypeMission> listMission() {
List<TypeMission> list = Arrays.asList(TypeMission.values());
return list;
}
}
......@@ -4,10 +4,30 @@
*/
package fr.ldnr.starWars.services;
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;
/**
*
* @author stag
*/
public interface PiloteService {
public Iterable<Pilote> findAll();
public Pilote trouverParNom(String nom);
public Iterable<Pilote> trouverParEtat(EtatPilote etat);
public Iterable<Pilote> trouverParGrade(GradePilote grade);
public Iterable<Pilote> trouverParType(TypePilote type);
public Iterable<RacePilote> listRace();
public Pilote save(Pilote pilote);
}
......@@ -4,10 +4,82 @@
*/
package fr.ldnr.starWars.services;
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 fr.ldnr.starWars.repositories.PiloteRepository;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.stereotype.Service;
/**
*
* @author stag
*/
public class PiloteServiceImpl {
@Service
public class PiloteServiceImpl implements PiloteService {
@PersistenceContext
private EntityManager entityManager;
PiloteRepository piloteRepository;
public PiloteServiceImpl(PiloteRepository piloteRepository) {
this.piloteRepository = piloteRepository;
}
@Override
public Iterable<Pilote> findAll() {
return piloteRepository.findAll();
}
@Override
public Pilote trouverParNom(String nom) {
return (Pilote) entityManager.createQuery("FROM Pilote p WHERE u.nom = :nom")
.setParameter("nom", nom)
.getSingleResult();
}
@Override
public Iterable<Pilote> trouverParEtat(EtatPilote etat) {
List<Pilote> list = new ArrayList<>();
list = entityManager.createQuery("FROM Pilote p WHERE p.etat_pilote = :etat")
.setParameter("etat", etat)
.getResultList();
return list;
}
@Override
public Iterable<Pilote> trouverParGrade(GradePilote grade) {
List<Pilote> list = new ArrayList<>();
list = entityManager.createQuery("FROM Pilote p WHERE p.grade = :grade")
.setParameter("grade", grade)
.getResultList();
return list;
}
@Override
public Iterable<Pilote> trouverParType(TypePilote type) {
List<Pilote> list = new ArrayList<>();
list = entityManager.createQuery("FROM Pilote p WHERE p.grade = :type")
.setParameter("type", type)
.getResultList();
return list;
}
@Override
public Iterable<RacePilote> listRace() {
List<RacePilote> list = Arrays.asList(RacePilote.values());
return list;
}
@Override
public Pilote save(Pilote pilote) {
return piloteRepository.save(pilote);
}
}
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:0522e6bf-5e28-43c6-933d-03fbb6b4bc6e;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
spring.datasource.user=SA
\ No newline at end of file
<!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 xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Cloture Mission</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<header>
<h1>Cloture Mission</h1>
</header>
<form action="clotureMission" method="post">
<div>
<label for="clotureMission">Nombre d'heure</label>
<input type="text" id="heures" name="heures"/>
</div>
<div>
<label for="resultat">Resultat Mission : </label>
<select id="resultat" name="resultats">
<option th:each="resultats : ${resultatMission}" th:value="${resultat}" th:text="${resultat}"></option>
</select>
</div>
<div>
<label>Détail</label>
<div>
<label for="pilote">Pilote</label>
<select id=""
</div>
</form>
<footer>
<a href="/menu" class="menu">Retour au Menu</a>
</footer>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Fiche Chasseur</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<h1>Fiche Chasseur</h1>
<table>
<tr>
<th>Identifiant</th>
<th>Type Chasseur</th>
<th>Etat Chasseur</th>
</tr>
<tr th:each="chasseur: ${ficheChasseur}">
<td th:text="${chasseur.id_chasseur}"></td>
<td th:text="${chasseur.type_chasseur}"></td>
<td th:text="${chasseur.etat_chasseur}"></td>
</tr>
</table>
</body>
</html>
<!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 xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Fiche Pilote</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<h1>Fiche Pilote</h1>
<p th:text="${pilote.prenom}">Prénom</p>
<p th:text="${pilote.nom}">Nom</p>
<p th:text="${pilote.race}">Race</p>
<p th:text="${pilote.age_inscription}">Age_inscription</p>
<p th:text="${pilote.etat_pilote}">État</p>
<!--besoin db des missions afin pouvoir afficher Missions-->
<p>Nombre d'heures de vol</p>
<p th:text="${pilote.grade}">Grade</p>
<!--besoin db des missions afin pouvoir afficher Missions-->
<p>Missions</p>
<p th:text="${pilote.type_pilote}">Type pilote</p>
</body>
</html>
<!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 xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Inscription Pilote</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<header>
<h1>Inscription Pilote</h1>
</header>
<form action="inscriptionPilote" method="post">
<div>
<label for="prenom">Prenom</label>
<input type="text" id="prenom" name="prenom"/>
</div>
<div>
<label for="nom">Nom</label>
<input type="text" id="nom" name="nom"/>
<!--th:value="${user.nomnom}"-->
</div>
<div>
<label for="races">Choose a race :</label>
<select id="races" name="races">
<option th:each="race : ${racePilotes}" th:value="${race}" th:text="${race}"></option>
</select>
</div>
<div>
<label for="age">Age</label>
<input type="text" id="age" name="age"/>
</div>
<input type="submit" value="Submit"/>
<input type="reset" value="Annuler"/>
</form>
<footer>
<a href="/menu" class="menu">Retour au Menu</a>
</footer>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Liste Chasseur</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<h1>Liste Chasseur</h1>
<form action="/nouveauChasseur" method="post">
<table>
<tr>
<th>Identifiant chasseur</th>
<th>Type chasseur</th>
<th>Etat chasseur</th>
</tr>
<tr>
<td th:each="chasseur : ${chasseur}" th:text="${chasseur.id_chasseur}"></td>
<td th:each="chasseur : ${chasseur}" th:text="${chasseur.type}"></td>
<td th:each="chasseur : ${chasseur}" th:text="${chasseur.etat}"></td>
</tr>
</table>
</form>
</body>
</html>
<!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 xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Liste Pilote</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<h1>Liste Pilote</h1>
<table>
<tr>
<th>Id pilote</th>
<th>nom</th>
<th>prenom</th>
<th>age</th>
<th>race</th>
<th>grade</th>
<th>etat</th>
</tr>
<tr>
<td th:each="pilote : ${pilotes}" th:text="${pilote.id_pilote}"></td>
<td th:each="pilote : ${pilotes}" th:text="${pilote.nom}"></td>
<td th:each="pilote : ${pilotes}" th:text="${pilote.prenom}"></td>
<td th:each="pilote : ${pilotes}" th:text="${pilote.age_inscription}"></td>
<td th:each="pilote : ${pilotes}" th:text="${pilote.race}"></td>
<td th:each="pilote : ${pilotes}" th:text="${pilote.grade}"></td>
<td th:each="pilote : ${pilotes}" th:text="${pilote.etat_pilote}"></td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Nouveau Chasseur</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<header><h1>Nouveau Chasseur</h1></header>
<form action="/nouveauChasseur" method="get">
<div>
<fieldset>
<legend>Selectionner un chasseur</legend>
<div th:each="type : ${type}">
<input type="radio" th:id="${type}" th:name="typeChasseur" th:value="${type}" />
<label th:for="${type}" th:text="${type}"></label>
</div>
</fieldset>
<div>
<input type="submit" value="Envoyer"/>
<input type="reset" value="Annuler"/>
</div>
</div>
</form>
<footer>
<a href="/menu" class="menu">Retour au Menu</a>
</footer>
</body>
</html>
<!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 xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Nouvelle Mission</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<header>
<h1>Nouvelle Mission</h1>
</header>
<form action="nouvelleMission" method="post">
<div>
<label for="missions">Choisir une mission :</label>
<select id="missions" name="missions">
<option th:each="mission : ${typeMissions}" th:value="${mission}" th:text="${mission}"></option>
</select>
</div>
<div>
<label for="missions">Titre</label>
<input type="text" id="titre" name="titre"/>
</div>
<input type="submit" value="Valider"/>
<input type="reset" value="Annuler"/>
</form>
<footer>
<a href="/menu" class="menu">Retour au Menu</a>
</footer>
</body>
</html>