Skip to content
Commits on Source (18)
......@@ -2,6 +2,9 @@ package fr.ldnr.starWars;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@SpringBootApplication
public class StarWarsApplication {
......@@ -10,4 +13,14 @@ public class StarWarsApplication {
SpringApplication.run(StarWarsApplication.class, args);
}
@Configuration
public static class WebConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
// Définir la page menu.html comme page d'accueil
registry.addViewController("/").setViewName("menu");
}
}
}
......@@ -20,6 +20,7 @@ import fr.ldnr.starWars.repositories.AffectationRepository;
import fr.ldnr.starWars.repositories.ChasseurRepository;
import fr.ldnr.starWars.repositories.MissionRepository;
import fr.ldnr.starWars.repositories.PiloteRepository;
import java.util.List;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
......@@ -48,45 +49,54 @@ public class BootstrapData implements CommandLineRunner {
Pilote pilote1 = new Pilote();
pilote1.setNom("MAMA");
pilote1.setPrenom("Apprenti1");
pilote1.setAge_inscription(100);
pilote1.setAge(100);
pilote1.setRace(RacePilote.CHALACTEENS);
pilote1.setType_pilote(TypePilote.APPRENTI);
pilote1.setType(TypePilote.APPRENTI);
Pilote pilote2 = new Pilote();
pilote2.setNom("WOW");
pilote2.setPrenom("Combattant1");
pilote2.setAge_inscription(17);
pilote2.setAge(17);
pilote2.setRace(RacePilote.CHISS);
pilote2.setType_pilote(TypePilote.COMBATTANT);
pilote2.setType(TypePilote.COMBATTANT);
pilote2.setGrade(GradePilote.CAPITAINE);
pilote2.setEtat_pilote(EtatPilote.DISPONIBLE);
pilote2.setEtat(EtatPilote.DISPONIBLE);
Pilote pilote3 = new Pilote();
pilote3.setNom("WIW");
pilote3.setPrenom("Combattant2");
pilote3.setAge_inscription(29);
pilote3.setAge(29);
pilote3.setRace(RacePilote.ITHORIENS);
pilote3.setType_pilote(TypePilote.COMBATTANT);
pilote3.setType(TypePilote.COMBATTANT);
pilote3.setGrade(GradePilote.COMMANDANT);
pilote3.setEtat_pilote(EtatPilote.EN_MISSION);
pilote3.setEtat(EtatPilote.EN_MISSION);
Pilote pilote4 = new Pilote();
pilote4.setNom("WEW");
pilote4.setPrenom("Combattant3");
pilote4.setAge_inscription(29);
pilote4.setAge(29);
pilote4.setRace(RacePilote.MIRALUKAS);
pilote4.setType_pilote(TypePilote.COMBATTANT);
pilote4.setType(TypePilote.COMBATTANT);
pilote4.setGrade(GradePilote.LIEUTENANT);
pilote4.setEtat_pilote(EtatPilote.TUE);
pilote4.setEtat(EtatPilote.MORT_AU_COMBAT);
Pilote pilote5 = new Pilote();
pilote5.setNom("WUW");
pilote5.setPrenom("Combattant4");
pilote5.setAge_inscription(77);
pilote5.setAge(77);
pilote5.setRace(RacePilote.NAGAIS);
pilote5.setType_pilote(TypePilote.COMBATTANT);
pilote5.setType(TypePilote.COMBATTANT);
pilote5.setGrade(GradePilote.OFFICIER);
pilote5.setEtat_pilote(EtatPilote.BLESSE);
pilote5.setEtat(EtatPilote.DISPONIBLE);
Pilote pilote6 = new Pilote();
pilote6.setNom("DUREL");
pilote6.setPrenom("Johad");
pilote6.setAge(22);
pilote6.setRace(RacePilote.HUMAINS);
pilote6.setType(TypePilote.COMBATTANT);
pilote6.setGrade(GradePilote.OFFICIER);
pilote6.setEtat(EtatPilote.BLESSE);
piloteRepository.save(pilote1);
piloteRepository.save(pilote2);
......@@ -95,20 +105,20 @@ public class BootstrapData implements CommandLineRunner {
piloteRepository.save(pilote5);
Chasseur chasseur1 = new Chasseur();
chasseur1.setType_chasseur(TypeChasseur.X_WING);
chasseur1.setEtat_chasseur(EtatChasseur.OPERATIONNEL);
chasseur1.setType(TypeChasseur.X_WING);
chasseur1.setEtat(EtatChasseur.OPERATIONNEL);
Chasseur chasseur2 = new Chasseur();
chasseur2.setType_chasseur(TypeChasseur.Y_WING);
chasseur2.setEtat_chasseur(EtatChasseur.EN_MISSION);
chasseur2.setType(TypeChasseur.Y_WING);
chasseur2.setEtat(EtatChasseur.EN_MISSION);
Chasseur chasseur3 = new Chasseur();
chasseur3.setType_chasseur(TypeChasseur.X_WING);
chasseur3.setEtat_chasseur(EtatChasseur.MAINTENANCE);
chasseur3.setType(TypeChasseur.X_WING);
chasseur3.setEtat(EtatChasseur.MAINTENANCE);
Chasseur chasseur4 = new Chasseur();
chasseur4.setType_chasseur(TypeChasseur.X_WING);
chasseur4.setEtat_chasseur(EtatChasseur.DETRUIT);
chasseur4.setType(TypeChasseur.X_WING);
chasseur4.setEtat(EtatChasseur.DETRUIT);
chasseurRepository.save(chasseur1);
chasseurRepository.save(chasseur2);
......@@ -116,20 +126,20 @@ public class BootstrapData implements CommandLineRunner {
chasseurRepository.save(chasseur4);
Mission mission1 = new Mission();
mission1.setTitre_mission("Mission 1");
mission1.setType_mission(TypeMission.COMBAT);
mission1.setTitre("Mission 1");
mission1.setType(TypeMission.COMBAT);
mission1.setNbHeure(70);
mission1.setResultat(ResultatMission.DEFAITE);
Mission mission2 = new Mission();
mission2.setTitre_mission("Mission 2");
mission2.setType_mission(TypeMission.ENTRAINEMENT);
mission2.setTitre("Mission 2");
mission2.setType(TypeMission.ENTRAINEMENT);
mission2.setNbHeure(66);
mission2.setResultat(ResultatMission.VICTOIRE);
Mission mission3 = new Mission();
mission3.setTitre_mission("Mission 3");
mission3.setType_mission(TypeMission.COMBAT);
mission3.setTitre("Mission 3");
mission3.setType(TypeMission.COMBAT);
missionRepository.save(mission1);
missionRepository.save(mission2);
......@@ -145,5 +155,9 @@ public class BootstrapData implements CommandLineRunner {
affectation2.setPilote(pilote5);
affectation2.setChasseur(chasseur4);
List list = piloteRepository.findByEtat(EtatPilote.DISPONIBLE);
for(var pilote : list) {
System.out.println("CHECK : " + pilote);
}
}
}
/*
* 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;
/**
*
* @author stag
*/
public class AffectationPiloteChasseur {
}
/*
* 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;
import fr.ldnr.starWars.services.ChasseurService;
import fr.ldnr.starWars.services.PiloteService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
/**
*
* @author stag
*/
@Controller
public class AffectationPiloteChasseurController {
private final PiloteService piloteService;
private final ChasseurService chasseurService;
public AffectationPiloteChasseurController(
PiloteService piloteService,
ChasseurService chasseurService) {
this.piloteService = piloteService;
this.chasseurService = chasseurService;
}
@GetMapping("/affectation")
public String AffecterPiloteChasseur(Model model) {
model.addAttribute("listePilotes", piloteService.findAll());
model.addAttribute("listeChasseurs", chasseurService.findAll());
return "affectation";
}
}
......@@ -9,6 +9,7 @@ import fr.ldnr.starWars.services.PiloteService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
......@@ -32,4 +33,5 @@ public class FichePiloteController {
return "fichePilote";
}
}
......@@ -48,7 +48,7 @@ public class InscriptionPiloteController {
pilote.setNom(nom);
pilote.setPrenom(prenom);
pilote.setRace(race2);
pilote.setAge_inscription(age2);
pilote.setAge(age2);
System.out.println("Check pilote : " + pilote);
piloteService.save(pilote);
return "menu";
......@@ -57,16 +57,3 @@ public class InscriptionPiloteController {
}
}
}
// String prenom = request.getParameter("prenom");
// String nom = request.getParameter("nom");
// RacePilote race = RacePilote.class.cast(request.getParameter("races"));
// Integer age = Integer.parseInt(request.getParameter("age"));
//
// Pilote pilote = new Pilote();
// pilote.setNom(nom);
// pilote.setPrenom(prenom);
// pilote.setRace(race);
// pilote.setAge_inscription(age);
// System.out.println("Check pilote : " + pilote);
// return piloteService.save(pilote);
......@@ -4,10 +4,13 @@
*/
package fr.ldnr.starWars.controllers;
import fr.ldnr.starWars.enumerations.TypePilote;
import fr.ldnr.starWars.services.PiloteService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
*
......@@ -15,6 +18,7 @@ import org.springframework.web.bind.annotation.GetMapping;
*/
@Controller
public class ListePiloteController {
private final PiloteService piloteService;
public ListePiloteController(PiloteService piloteService) {
......@@ -24,6 +28,23 @@ public class ListePiloteController {
@GetMapping("/listePilote")
public String listePilote(Model model) {
model.addAttribute("pilotes", piloteService.findAll());
model.addAttribute("typePilotes", piloteService.listType());
model.addAttribute("gradePilotes", piloteService.listGrade());
model.addAttribute("etatPilotes", piloteService.listEtat());
model.addAttribute("racePilotes", piloteService.listRace());
model.addAttribute("gradePilotes", piloteService.listGrade());
return "listePilote";
}
// @PostMapping("/listePilote")
// public String listePilote(Model model,
// @RequestParam(value = "typePilotes") String types,
// @RequestParam(value = "gradePilotes") String grades,
// @RequestParam(value = "etatPilotes") String etats,
// @RequestParam(value = "racePilotes") String races) {
// model.addAttribute("pilotes", piloteService.listType());
// model.addAttribute("typePilotes", piloteService.findByType(TypePilote.valueOf(types)));
// return "listePilote";
// }
}
/*
* 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;
import fr.ldnr.starWars.enumerations.EtatPilote;
import fr.ldnr.starWars.enumerations.GradePilote;
import fr.ldnr.starWars.services.PiloteService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
*
* @author stag
*/
@Controller
public class ListePiloteParEtat {
private final PiloteService piloteService;
public ListePiloteParEtat(PiloteService piloteService) {
this.piloteService = piloteService;
}
@GetMapping("/listePiloteParEtat")
public String listePilote(Model model) {
model.addAttribute("etats", piloteService.listEtat());
return "listePiloteParEtat";
}
@PostMapping("/listePiloteParEtat")
public String listePilote(Model model, @RequestParam(value = "etats") String etats) {
model.addAttribute("etats", piloteService.listEtat());
// if (types.equals("all")) {
// model.addAttribute("pilotes", piloteService.findAll());
// }
model.addAttribute("pilotes", piloteService.findByEtat(EtatPilote.valueOf(etats)));
return "listePiloteParEtat";
}
}
/*
* 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;
import fr.ldnr.starWars.enumerations.GradePilote;
import fr.ldnr.starWars.services.PiloteService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
*
* @author stag
*/
@Controller
public class ListePiloteParGrade {
private final PiloteService piloteService;
public ListePiloteParGrade(PiloteService piloteService) {
this.piloteService = piloteService;
}
@GetMapping("/listePiloteParGrade")
public String listePilote(Model model) {
model.addAttribute("grades", piloteService.listGrade());
return "listePiloteParGrade";
}
@PostMapping("/listePiloteParGrade")
public String listePilote(Model model, @RequestParam(value = "grades") String grades) {
model.addAttribute("grades", piloteService.listGrade());
// if (types.equals("all")) {
// model.addAttribute("pilotes", piloteService.findAll());
// }
model.addAttribute("pilotes", piloteService.findByGrade(GradePilote.valueOf(grades)));
return "listePiloteParGrade";
}
}
/*
* 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;
import fr.ldnr.starWars.enumerations.TypePilote;
import fr.ldnr.starWars.services.PiloteService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
*
* @author stag
*/
@Controller
public class ListePiloteParType {
private final PiloteService piloteService;
public ListePiloteParType(PiloteService piloteService) {
this.piloteService = piloteService;
}
@GetMapping("/listePiloteParType")
public String listePilote(Model model) {
model.addAttribute("types", piloteService.listType());
return "listePiloteParType";
}
@PostMapping("/listePiloteParType")
public String listePilote(Model model, @RequestParam(value = "types") String types) {
model.addAttribute("types", piloteService.listType());
// if (types.equals("all")) {
// model.addAttribute("pilotes", piloteService.findAll());
// }
model.addAttribute("pilotes", piloteService.findByType(TypePilote.valueOf(types)));
return "listePiloteParType";
}
}
......@@ -5,11 +5,13 @@
package fr.ldnr.starWars.controllers;
import fr.ldnr.starWars.domains.Chasseur;
import fr.ldnr.starWars.enumerations.EtatChasseur;
import fr.ldnr.starWars.enumerations.TypeChasseur;
import fr.ldnr.starWars.services.ChasseurService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
......@@ -26,13 +28,24 @@ public class NouveauChasseurController {
}
@GetMapping("/nouveauChasseur")
public String sauvegarderChasseur(Model model, TypeChasseur typeChasseur) {
public String sauvegarderChasseur(Model model) {
model.addAttribute("type", chasseurService.listeTypeChasseur());
Chasseur nouveauChasseur = new Chasseur();
nouveauChasseur.setType_chasseur(typeChasseur);
System.out.println(typeChasseur);
chasseurService.save(nouveauChasseur);
return "nouveauChasseur";
}
@PostMapping("/nouveauChasseur")
public String sauvegardeChasseur(Model model,
@RequestParam(value = "typeChasseur") String typeChasseur) {
model.addAttribute("type", chasseurService.listeTypeChasseur());
if (!typeChasseur.isEmpty()) {
Chasseur chasseur = new Chasseur();
chasseur.setType(TypeChasseur.valueOf(typeChasseur));
chasseur.setEtat(EtatChasseur.OPERATIONNEL);
chasseurService.save(chasseur);
return "menu";
}
return "nouveauChasseur";
}
......
......@@ -30,3 +30,39 @@ public class NouvelleMissionController {
}
}
//@Controller
//public class NouvelleMissionController {
//
// private final MissionService missionService;
// private List<PaireChasseurPilote> paireList = new ArrayList<>();
//
// public NouvelleMissionController(MissionService missionService) {
// this.missionService = missionService;
// }
//
// @RequestMapping("/nouvelleMission")
// public String getMission(Model model) {
// model.addAttribute("typeMissions", missionService.listMission());
// model.addAttribute("paireList", paireList); // Afficher la liste du personnel affecté
// return "nouvelleMission";
// }
//
// @PostMapping("/nouvelleMission")
// public String createMission(@RequestParam("titre") String titre) {
// // Créez la mission dans la base de données avec le titre
// Mission mission = new Mission(titre);
// missionService.saveMission(mission);
//
// // Associez les paires chasseur/pilote à cette mission
// for (PaireChasseurPilote paire : paireList) {
// paire.setMission(mission);
// }
// missionService.savePaireList(paireList);
//
// // Réinitialisez la liste des paires pour les futures missions
// paireList.clear();
//
// return "redirect:/nouvelleMission"; // Redirigez vers la page "nouvelleMission"
// }
//}
......@@ -22,17 +22,17 @@ public class Affectation {
private AffectationId affectationId;
@ManyToOne
@MapsId("id_pilote") // to tie to to part of the key
@MapsId("idPilote") // to tie to to part of the key
@JoinColumn
private Pilote pilote;
@ManyToOne
@MapsId("id_chasseur")
@MapsId("idChasseur")
@JoinColumn
private Chasseur chasseur;
@ManyToOne
@MapsId("id_mission")
@MapsId("idMission")
@JoinColumn
private Mission mission;
......@@ -71,7 +71,7 @@ public class Affectation {
@Override
public int hashCode() {
int hash = 5;
hash = 67 * hash + Objects.hashCode(this.affectationId);
hash = 79 * hash + Objects.hashCode(this.affectationId);
return hash;
}
......
......@@ -16,21 +16,21 @@ import java.util.Objects;
@Embeddable
public class AffectationId implements Serializable {
@Column(name = "id_pilote")
private Integer id_pilote;
@Column(name = "idPilote")
private Integer idPilote;
@Column(name = "id_chasseur")
private Integer id_chasseur;
@Column(name = "idChasseur")
private Integer idChasseur;
@Column(name = "id_mission")
private Integer id_mission;
@Column(name = "idMission")
private Integer idMission;
@Override
public int hashCode() {
int hash = 3;
hash = 47 * hash + Objects.hashCode(this.id_pilote);
hash = 47 * hash + Objects.hashCode(this.id_chasseur);
hash = 47 * hash + Objects.hashCode(this.id_mission);
int hash = 7;
hash = 17 * hash + Objects.hashCode(this.idPilote);
hash = 17 * hash + Objects.hashCode(this.idChasseur);
hash = 17 * hash + Objects.hashCode(this.idMission);
return hash;
}
......@@ -46,15 +46,16 @@ public class AffectationId implements Serializable {
return false;
}
final AffectationId other = (AffectationId) obj;
if (!Objects.equals(this.id_pilote, other.id_pilote)) {
if (!Objects.equals(this.idPilote, other.idPilote)) {
return false;
}
if (!Objects.equals(this.id_chasseur, other.id_chasseur)) {
if (!Objects.equals(this.idChasseur, other.idChasseur)) {
return false;
}
return Objects.equals(this.id_mission, other.id_mission);
return Objects.equals(this.idMission, other.idMission);
}
}
......@@ -23,41 +23,41 @@ public class Chasseur {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id_chasseur;
private TypeChasseur type_chasseur;
private EtatChasseur etat_chasseur;
private Integer idChasseur;
private TypeChasseur type;
private EtatChasseur etat;
@OneToMany(mappedBy = "chasseur")
Set<Affectation> affectation;
public Integer getId_chasseur() {
return id_chasseur;
public Integer getIdChasseur() {
return idChasseur;
}
public void setId_chasseur(Integer id_chasseur) {
this.id_chasseur = id_chasseur;
public void setIdChasseur(Integer idChasseur) {
this.idChasseur = idChasseur;
}
public TypeChasseur getType_chasseur() {
return type_chasseur;
public TypeChasseur getType() {
return type;
}
public void setType_chasseur(TypeChasseur type_chasseur) {
this.type_chasseur = type_chasseur;
public void setType(TypeChasseur type) {
this.type = type;
}
public EtatChasseur getEtat_chasseur() {
return etat_chasseur;
public EtatChasseur getEtat() {
return etat;
}
public void setEtat_chasseur(EtatChasseur etat_chasseur) {
this.etat_chasseur = etat_chasseur;
public void setEtat(EtatChasseur etat) {
this.etat = etat;
}
@Override
public int hashCode() {
int hash = 3;
hash = 61 * hash + Objects.hashCode(this.id_chasseur);
hash = 61 * hash + Objects.hashCode(this.idChasseur);
return hash;
}
......@@ -73,17 +73,17 @@ public class Chasseur {
return false;
}
final Chasseur other = (Chasseur) obj;
return Objects.equals(this.id_chasseur, other.id_chasseur);
return Objects.equals(this.idChasseur, other.idChasseur);
}
@Override
public String toString() {
return "Chasseur{" + "id_chasseur="
+ id_chasseur
+ idChasseur
+ ", type_chasseur="
+ type_chasseur
+ type
+ ", etat_chasseur="
+ etat_chasseur + '}';
+ etat + '}';
}
public void setId(String string) {
......
......@@ -24,37 +24,37 @@ public class Mission {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id_mission;
private String titre_mission;
private TypeMission type_mission;
private Integer idMission;
private String titre;
private TypeMission type;
private Integer nbHeure;
private ResultatMission resultat;
@OneToMany(mappedBy = "mission")
Set<Affectation> affectation;
public Integer getId_mission() {
return id_mission;
public Integer getIdMission() {
return idMission;
}
public void setId_mission(Integer id_mission) {
this.id_mission = id_mission;
public void setIdMission(Integer idMission) {
this.idMission = idMission;
}
public String getTitre_mission() {
return titre_mission;
public String getTitre() {
return titre;
}
public void setTitre_mission(String titre_mission) {
this.titre_mission = titre_mission;
public void setTitre(String titre) {
this.titre = titre;
}
public TypeMission getType_mission() {
return type_mission;
public TypeMission getType() {
return type;
}
public void setType_mission(TypeMission type_mission) {
this.type_mission = type_mission;
public void setType(TypeMission type) {
this.type = type;
}
public Integer getNbHeure() {
......@@ -76,7 +76,7 @@ public class Mission {
@Override
public int hashCode() {
int hash = 5;
hash = 73 * hash + Objects.hashCode(this.id_mission);
hash = 73 * hash + Objects.hashCode(this.idMission);
return hash;
}
......@@ -92,7 +92,7 @@ public class Mission {
return false;
}
final Mission other = (Mission) obj;
return Objects.equals(this.id_mission, other.id_mission);
return Objects.equals(this.idMission, other.idMission);
}
public ResultatMission getResultat() {
......@@ -105,7 +105,7 @@ public class Mission {
@Override
public String toString() {
return "Mission{" + "id_mission=" + id_mission + ", titre_mission=" + titre_mission + ", type_mission=" + type_mission + ", nbHeure=" + nbHeure + ", resultat=" + resultat + ", affectation=" + affectation + '}';
return "Mission{" + "id_mission=" + idMission + ", titre_mission=" + titre + ", type_mission=" + type + ", nbHeure=" + nbHeure + ", resultat=" + resultat + ", affectation=" + affectation + '}';
}
}
......@@ -25,24 +25,24 @@ public class Pilote {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id_pilote;
private Integer idPilote;
private String nom;
private String prenom;
private Integer age_inscription;
private Integer age;
private RacePilote race;
private TypePilote type_pilote;
private EtatPilote etat_pilote;
private TypePilote type;
private EtatPilote etat;
private GradePilote grade;
@OneToMany(mappedBy = "pilote")
Set<Affectation> affectation;
public Integer getId_pilote() {
return id_pilote;
public Integer getIdPilote() {
return idPilote;
}
public void setId_pilote(Integer id_pilote) {
this.id_pilote = id_pilote;
public void setIdPilote(Integer idPilote) {
this.idPilote = idPilote;
}
public String getNom() {
......@@ -61,12 +61,12 @@ public class Pilote {
this.prenom = prenom;
}
public Integer getAge_inscription() {
return age_inscription;
public Integer getAge() {
return age;
}
public void setAge_inscription(Integer age_inscription) {
this.age_inscription = age_inscription;
public void setAge(Integer age) {
this.age = age;
}
public Set<Affectation> getAffectation() {
......@@ -85,12 +85,12 @@ public class Pilote {
this.race = race;
}
public EtatPilote getEtat_pilote() {
return etat_pilote;
public EtatPilote getEtat() {
return etat;
}
public void setEtat_pilote(EtatPilote etat_pilote) {
this.etat_pilote = etat_pilote;
public void setEtat(EtatPilote etat) {
this.etat = etat;
}
public GradePilote getGrade() {
......@@ -101,18 +101,18 @@ public class Pilote {
this.grade = grade;
}
public TypePilote getType_pilote() {
return type_pilote;
public TypePilote getType() {
return type;
}
public void setType_pilote(TypePilote type_pilote) {
this.type_pilote = type_pilote;
public void setType(TypePilote type) {
this.type = type;
}
@Override
public int hashCode() {
int hash = 7;
hash = 67 * hash + Objects.hashCode(this.id_pilote);
hash = 67 * hash + Objects.hashCode(this.idPilote);
return hash;
}
......@@ -128,12 +128,21 @@ public class Pilote {
return false;
}
final Pilote other = (Pilote) obj;
return Objects.equals(this.id_pilote, other.id_pilote);
return Objects.equals(this.idPilote, other.idPilote);
}
@Override
public String toString() {
return "Pilote{" + "id_pilote=" + id_pilote + ", nom=" + nom + ", prenom=" + prenom + ", age_inscription=" + age_inscription + ", race=" + race + ", etat_pilote=" + etat_pilote + ", grade=" + grade + ", affectation=" + affectation + '}';
return "Pilote{" + "idPilote=" + idPilote
+ ", nom=" + nom + ", prenom=" + prenom
+ ", age_inscription=" + age
+ ", race=" + race + ", type_pilote=" + type
+ ", etat=" + etat
+ ", grade=" + grade
+ ", affectation=" + "TBD}";
}
}
......@@ -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;
}
......@@ -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,13 @@ 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);
}
......@@ -29,13 +29,13 @@ public class ChasseurServiceImpl implements ChasseurService {
@Override
public Iterable<Chasseur> findAll() {
return chasseurRepository.findAll();
}
@Override
public Chasseur save(Chasseur chasseur) {
return chasseur;
return chasseurRepository.save(chasseur);
}
@Override
......@@ -57,22 +57,24 @@ public class ChasseurServiceImpl implements ChasseurService {
}
@Override
public Iterable<Chasseur> trouverParType(TypeChasseur type) {
public Iterable<Chasseur> trouverParId(Long id_chasseur) {
List<Chasseur> list = new ArrayList();
list = em.createQuery("FROM Chasseur c WHERE c.type = :type")
.setParameter("type", type)
list = em.createQuery("FROM Chasseur c WHERE c.id = :id")
.setParameter("id", id_chasseur)
.getResultList();
return list;
}
@Override
public Iterable<Chasseur> trouverParId(Long id_chasseur) {
public Iterable<Chasseur> trouverParType(TypeChasseur type) {
List<Chasseur> list = new ArrayList();
list = em.createQuery("FROM Chasseur c WHERE c.id = :id")
.setParameter("id", id_chasseur)
list = em.createQuery("FROM Chasseur c WHERE c.type = :type")
.setParameter("type", type)
.getResultList();
return list;
}
}