feat: implement educator management and display educator initials on training schedule
This commit is contained in:
@@ -3,6 +3,7 @@ package com.astalange.web.controller;
|
||||
import com.astalange.core.entity.*;
|
||||
import com.astalange.core.repository.CategorieRepository;
|
||||
import com.astalange.core.repository.CreneauEntrainementRepository;
|
||||
import com.astalange.core.repository.EducateurRepository;
|
||||
import com.astalange.core.repository.EquipeRepository;
|
||||
import com.astalange.core.repository.SaisonRepository;
|
||||
import com.astalange.core.repository.TerrainRepository;
|
||||
@@ -23,17 +24,20 @@ public class PlanningController {
|
||||
private final CategorieRepository categorieRepository;
|
||||
private final SaisonRepository saisonRepository;
|
||||
private final EquipeRepository equipeRepository;
|
||||
private final EducateurRepository educateurRepository;
|
||||
|
||||
public PlanningController(CreneauEntrainementRepository creneauRepository,
|
||||
TerrainRepository terrainRepository,
|
||||
CategorieRepository categorieRepository,
|
||||
SaisonRepository saisonRepository,
|
||||
EquipeRepository equipeRepository) {
|
||||
EquipeRepository equipeRepository,
|
||||
EducateurRepository educateurRepository) {
|
||||
this.creneauRepository = creneauRepository;
|
||||
this.terrainRepository = terrainRepository;
|
||||
this.categorieRepository = categorieRepository;
|
||||
this.saisonRepository = saisonRepository;
|
||||
this.equipeRepository = equipeRepository;
|
||||
this.educateurRepository = educateurRepository;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@@ -56,10 +60,33 @@ public class PlanningController {
|
||||
}
|
||||
|
||||
List<CreneauEntrainement> creneaux = creneauRepository.findBySaisonAndJourSemaineFetch(saisonActive, selectedDay);
|
||||
List<Educateur> educateurs = educateurRepository.findAllWithCategorieAndEquipe();
|
||||
|
||||
// Detect conflicts
|
||||
// Detect conflicts and populate educator initials
|
||||
for (int i = 0; i < creneaux.size(); i++) {
|
||||
CreneauEntrainement c1 = creneaux.get(i);
|
||||
|
||||
// Populate educator initials
|
||||
List<String> initials = new ArrayList<>();
|
||||
for (Educateur ed : educateurs) {
|
||||
boolean match = false;
|
||||
if (c1.getEquipe() != null) {
|
||||
if (ed.getEquipe() != null && ed.getEquipe().getId().equals(c1.getEquipe().getId())) {
|
||||
match = true;
|
||||
}
|
||||
} else if (c1.getCategorie() != null) {
|
||||
if (ed.getCategorie() != null && ed.getCategorie().getId().equals(c1.getCategorie().getId())) {
|
||||
match = true;
|
||||
} else if (ed.getEquipe() != null && ed.getEquipe().getCategorie() != null && ed.getEquipe().getCategorie().getId().equals(c1.getCategorie().getId())) {
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
initials.add(ed.getInitiales());
|
||||
}
|
||||
}
|
||||
c1.setInitialesEducateurs(String.join(", ", initials));
|
||||
|
||||
for (int j = 0; j < creneaux.size(); j++) {
|
||||
if (i == j) continue;
|
||||
CreneauEntrainement c2 = creneaux.get(j);
|
||||
|
||||
Reference in New Issue
Block a user