--- /dev/null
+/*
+ * Copyright © FYLAB and the Conseil Régional d'Île-de-France, 2009
+ * This file is part of L'Interface Libre et Interactive de l'Enseignement (Lilie).
+ *
+ * Lilie is free software. You can redistribute it and/or modify since
+ * you respect the terms of either (at least one of the both license) :
+ * - under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * - the CeCILL-C as published by CeCILL-C; either version 1 of the
+ * License, or any later version
+ *
+ * There are special exceptions to the terms and conditions of the
+ * licenses as they are applied to this software. View the full text of
+ * the exception in file LICENSE.txt in the directory of this software
+ * distribution.
+ *
+ * Lilie is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Licenses for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the CeCILL-C along with Lilie. If not, see :
+ * <http://www.gnu.org/licenses/> and
+ * <http://www.cecill.info/licences.fr.html>.
+ */
+
+
+
+
+
+
+package org.lilie.services.eliot.absences.saisie.discipline.incident
+
+import org.lilie.services.eliot.scolarite.Personne
+import org.lilie.services.eliot.scolarite.StructureEnseignement
+import org.lilie.services.eliot.absences.TypeProtagonisteIncident
+import org.lilie.services.eliot.absences.TypeIncident
+import org.lilie.services.eliot.absences.LieuIncident
+import grails.converters.JSON
+import java.text.SimpleDateFormat
+import org.lilie.services.eliot.constantes.ConstDate
+
+/**
+ * Cette classe permet de parser les paramétres de filtre de recherche sur les incidents et de déterminer
+ * les requetes permettant de remonter les personnes à filtrer
+ * @author othe
+ */
+class CritereIncident {
+
+ Date dateDebut
+ Date dateFin
+ List<LieuIncident> lieux
+ List<TypeIncident> typesIncident
+ List<TypeProtagonisteIncident> typesProtagoniste
+ List<ProfilCenseur> profils
+ List<StructureEnseignement> classes
+ List<Personne> personnes
+
+ Boolean direction = false
+ Boolean personnelsEducation = false
+ Boolean enseignants = false
+ Boolean eleves = false
+ Boolean parents = false
+
+ public CritereIncident(String jsonCriteres) {
+
+ if (jsonCriteres) {
+ parseJson(jsonCriteres)
+ selectionListePersonne()
+ } else {
+ throw new IllegalStateException("On doit passer un json valide à ce constructeur.")
+ }
+
+ }
+
+ private void parseJson(String jsonCriteres) {
+ Map criteres = (Map) JSON.parse(jsonCriteres)
+
+ if (criteres.dateDebut != null) {
+ dateDebut = parseDate(criteres.dateDebut)
+ }
+
+ if (criteres.dateFin != null) {
+ dateFin = parseDate(criteres.dateFin)
+ }
+
+ if (criteres.lieux != null) {
+ lieux = LieuIncident.getAll(criteres.lieux)
+ }
+
+ if (criteres.types != null) {
+ typesIncident = TypeIncident.getAll(criteres.types)
+ }
+
+ if (criteres.typesProtagoniste != null) {
+ typesProtagoniste = criteres.typesProtagoniste.collect {
+ TypeProtagonisteIncident.parseByCode(Integer.parseInt(it))
+ }
+ }
+
+ if (criteres.profils != null) {
+ profils = criteres.profils.collect {
+ ProfilCenseur.parseByCode(Integer.parseInt(it))
+ }
+ }
+
+ if (criteres.classes != null) {
+ classes = StructureEnseignement.getAll(criteres.classes)
+ }
+
+ if (criteres.personnes != null) {
+ personnes = Personne.getAll(criteres.personnes)
+ }
+
+ }
+
+ /**
+ * Parse une cahine du format dd/MM/yyyy en date
+ * @author bahj
+ */
+ private Date parseDate(String date) {
+ SimpleDateFormat formatDate = new SimpleDateFormat(ConstDate.DATE_JJMMAAA, Locale.FRANCE)
+ return formatDate.parse(date)
+ }
+
+ public boolean getCopiePersonne() {
+ return (personnes)
+ }
+
+ /**
+ * Détermine quelles listes de personnes doivent être requetées
+ */
+ private void selectionListePersonne() {
+
+ if (!getCopiePersonne()) {
+ traitementDirPersEducEns()
+ }
+
+ // il faut au moins 2 classes ou une classe et pas de personnes (reprise du code initial)
+ if ((classes?.size() > 1) || (classes && !personnes)) {
+ traitementParentEleve()
+ }
+
+ }
+
+ /**
+ * Détermine s'il faut lister les parent ou les élèves
+ */
+ private void traitementParentEleve() {
+
+ eleves = true
+ parents = true
+
+ if (typesProtagoniste) {
+ eleves = typesProtagoniste.contains(TypeProtagonisteIncident.ELEVE)
+ parents = typesProtagoniste.contains(TypeProtagonisteIncident.PARENT)
+ }
+
+ }
+
+ /**
+ * Détermine s'il faut lister les directeurs, personnels d'éducations ou enseignants
+ */
+ private void traitementDirPersEducEns() {
+
+ if ((!typesProtagoniste) || (typesProtagoniste.contains(TypeProtagonisteIncident.CENSEUR))) {
+
+ if ((typesProtagoniste) ||
+ (profils)) {
+
+ direction = true
+ personnelsEducation = true
+ enseignants = true
+
+ if (profils) {
+ direction = profils.contains(ProfilCenseur.DIRECTIONS)
+ personnelsEducation = profils.contains(ProfilCenseur.PERSONNELS_EDUCATION)
+ enseignants = profils.contains(ProfilCenseur.ENSEIGNANTS)
+ }
+ else {
+ if (classes) {
+ direction = false
+ personnelsEducation = false
+ enseignants = false
+ }
+ }
+ }
+ }
+
+ }
+
+}
ConfigurationHolder.config.eliot.absences.incident.consultation.
nombreLignesParPage ?: 100
-
/**
* Page de consultations des incidents
* @author bahj
render resultats as JSON
}
-
- private Map parseCriteres(def jsonCriteres) {
-
- Map result = [:]
- if (jsonCriteres != null) {
- Map criteres = (Map) JSON.parse(jsonCriteres)
-
- if (criteres.dateDebut != null) {
- result.dateDebut = parseDate(criteres.dateDebut)
- }
-
- if (criteres.dateFin != null) {
- result.dateFin = parseDate(criteres.dateFin)
- }
-
- if (criteres.lieux != null) {
- result.lieux = LieuIncident.getAll(criteres.lieux)
- }
-
- if (criteres.types != null) {
- result.typesIncident = TypeIncident.getAll(criteres.types)
- }
-
- if (criteres.typesProtagoniste != null) {
- result.typesProtagoniste = criteres.typesProtagoniste.collect {
- TypeProtagonisteIncident.parseByCode(Integer.parseInt(it))
- }
- }
-
- if (criteres.profils != null) {
- result.profils = criteres.profils.collect {
- ProfilCenseur.parseByCode(Integer.parseInt(it))
- }
- }
-
- if (criteres.classes != null) {
- result.classes = StructureEnseignement.getAll(criteres.classes)
- }
-
- if (criteres.personnes != null) {
- result.personnes = Personne.getAll(criteres.personnes)
- }
-
- }
-
- return result
- }
-
-
/**
* Récupération des incidents
* partie commune à l'affichage et à l'export
Boolean triAscendant,
Integer offset,
Integer limit) {
- Map criteres = parseCriteres(jsonCriteres)
+
+ CritereIncident criteres = new CritereIncident(jsonCriteres)
ListeIncidentsInfo listeIncidents = absencesIncidentService.findIncidents(
securiteSession,
List<IncidentConsultationInfo> incidentInfos =
affichageIncidentService.getIncidentConsultationsInfos(
- listeIncidents.incidents,
- nomsAffichageByIdExterne
- )
+ listeIncidents.incidents,
+ nomsAffichageByIdExterne
+ )
- [incidents : incidentInfos, nbr : listeIncidents.nbIncidents]
+ [incidents: incidentInfos, nbr: listeIncidents.nbIncidents]
}
)
}
-
/**
* Affiche la page de création d'un nouvel incident
*/
)
}
-
/**
* Affiche l'incident en mode modification
*/
render resultats as JSON
}
-
/**
* Switch la création et la modification d'un incident
* @author bahj
render resultats as JSON
}
-
/**
* Cree un incident
*/
return resultats
}
-
/**
* Modifie un incident
*/
return protagonistesDto
}
-
/**
* Construit un incidentModificationInfo, utilisé dans la vue de modification
* @author bahj
)
}
-
/**
* Construit la liste des partenaires à prévenir de l'incident à modifier
* @author bahj
return idPartenaires
}
-
/**
* Construit la liste des protagonistes de l'incident à modifier
* @author bahj
return protagonistesModInfo
}
-
/**
* Gestion du breadCrumbs
*/
Boolean ascendant,
Integer start,
Integer limit,
- Map criteres = [:]) {
+ CritereIncident criteres = new CritereIncident()) {
ListeIncidentsInfo result = new ListeIncidentsInfo(
nbIncidents: 0,
if (criteres.dateFin != null) {
Date dateFin = criteres.dateFin
- use (TimeCategory) {
+ use(TimeCategory) {
dateFin += 23.hours + 59.minutes
}
result.incidents = Incident.executeQuery(hql, hqlParams, paginationMap).unique()
- result.nbIncidents = Incident.executeQuery(hqlCount, hqlParams).first()
+ result.nbIncidents = (Integer)Incident.executeQuery(hqlCount, hqlParams).first()
return result
}
private List<Personne> getAllPersonneAFiltrer(SecuriteSession securiteSession,
Etablissement etablissement,
- Map criteres) {
+ CritereIncident criteres) {
List<Personne> personnes = []
- if ((criteres.personnes != null) && (criteres.personnes.size() > 0)) {
+ if (criteres.copiePersonne) {
personnes.addAll(criteres.personnes)
}
- else if ((criteres.typesProtagoniste == null) ||
- criteres.typesProtagoniste.contains(TypeProtagonisteIncident.CENSEUR)) {
-
- if (((criteres.typesProtagoniste != null) && (criteres.typesProtagoniste.size() > 0)) ||
- ((criteres.profils != null) && (criteres.profils.size() > 0))) {
-
- Boolean direction = true
- Boolean personnelsEducation = true
- Boolean enseignants = true
-
- if ((criteres.profils != null) && (criteres.profils.size() > 0)) {
- direction = criteres.profils.contains(ProfilCenseur.DIRECTIONS)
- personnelsEducation = criteres.profils.contains(ProfilCenseur.PERSONNELS_EDUCATION)
- enseignants = criteres.profils.contains(ProfilCenseur.ENSEIGNANTS)
- }
- else if ((criteres.classes != null) && (criteres.classes.size() > 0)) {
- direction = false
- personnelsEducation = false
- enseignants = false
- }
-
- if (direction) {
- personnes.addAll(personneAnnuaireService.
- findAllPersonnelDirectionByEtablissement(etablissement))
- }
-
- if (personnelsEducation) {
- personnes.addAll(personneAnnuaireService.
- findAllPersonnelEducationByEtablissement(etablissement))
- }
-
- if (enseignants) {
- personnes.addAll(personneAnnuaireService.
- findAllEnseignantByEtablissement(etablissement))
- }
- }
+ if (criteres.direction) {
+ personnes.addAll(personneAnnuaireService.
+ findAllPersonnelDirectionByEtablissement(etablissement))
}
- if ((criteres.classes != null) &&
- ((criteres.classes.size() > 1) || (criteres.personnes == null))) {
-
- Boolean eleves = true
- Boolean parents = true
+ if (criteres.personnelsEducation) {
+ personnes.addAll(personneAnnuaireService.
+ findAllPersonnelEducationByEtablissement(etablissement))
+ }
- if ((criteres.typesProtagoniste != null) && (criteres.typesProtagoniste.size() > 0)) {
- eleves = criteres.typesProtagoniste.contains(TypeProtagonisteIncident.ELEVE)
- parents = criteres.typesProtagoniste.contains(TypeProtagonisteIncident.PARENT)
- }
+ if (criteres.enseignants) {
+ personnes.addAll(personneAnnuaireService.
+ findAllEnseignantByEtablissement(etablissement))
+ }
- if (eleves) {
- personnes.addAll(scolariteService.findAllPersonneEleveForStructure(
- securiteSession,
- criteres.classes.collect {it.id}
- ))
- }
+ if (criteres.eleves) {
+ personnes.addAll(scolariteService.findAllPersonneEleveForStructure(
+ securiteSession,
+ criteres.classes.collect {it.id}
+ ))
+ }
- if (parents) {
- personnes.addAll(localStructureEnseignementService.findAllParentsForStructures(
- securiteSession,
- criteres.classes
- ))
- }
+ if (criteres.parents) {
+ personnes.addAll(localStructureEnseignementService.findAllParentsForStructures(
+ securiteSession,
+ criteres.classes
+ ))
}
return personnes
Boolean result = false
incident.partenairesAPrevenir.each {
PartenaireAPrevenirIncident part ->
- if (ids.contains(part.partenaireAPrevenirId)) {
- result = true
- }
- ids.add(part.partenaireAPrevenirId)
+ if (ids.contains(part.partenaireAPrevenirId)) {
+ result = true
+ }
+ ids.add(part.partenaireAPrevenirId)
}
return result
}
return findIncidentByEleves(eleves, incidentAExclure, start, limit)
}
-
/**
* Retourne les infos nécessaires au remplissage de la grille des incident
* dans la saisie des punitions
* @return un GrilleIncidentsForEleveInfo
*/
GrilleIncidentsForEleveInfo findIncidentByEleves(List<Autorite> eleves,
- Incident incidentAExclure,
- Integer start,
- Integer limit
+ Incident incidentAExclure,
+ Integer start,
+ Integer limit
) {
GrilleIncidentsForEleveInfo result = new GrilleIncidentsForEleveInfo()