* @param incidentAExclure : l'incident à exclure de la sélection
* @param start : donnée de pagination
* @param limit : donnée de pagination
- * @return un GrilleIncidentsForEleveInfo
+ * @return un GrilleIncidentsForEleveInfo
*/
GrilleIncidentsForEleveInfo findIncidentByEleve(Autorite eleve,
Incident incidentAExclure,
Integer start,
Integer limit
) {
+ List<Autorite> eleves = [eleve]
+ return findIncidentByEleves(eleves, incidentAExclure, start, limit)
+ }
+
+
+ /**
+ * Retourne les infos nécessaires au remplissage de la grille des incident
+ * dans la saisie des punitions
+ * @param eleves : élèves dont on veut les incidents
+ * @param incidentAExclure : l'incident à exclure de la sélection
+ * @param start : donnée de pagination
+ * @param limit : donnée de pagination
+ * @return un GrilleIncidentsForEleveInfo
+ */
+ GrilleIncidentsForEleveInfo findIncidentByEleves(List<Autorite> eleves,
+ Incident incidentAExclure,
+ Integer start,
+ Integer limit
+ ) {
+
+ GrilleIncidentsForEleveInfo result = new GrilleIncidentsForEleveInfo()
+
+ if (eleves.size() == 0) {
+ result.nbIncidents = 0
+ result.incidents = []
+ return result
+ }
+
String hqlFromCount = """
from Incident as incident,
ProtagonisteIncident as protagonisteIncident
where protagonisteIncident.incident.id = incident.id
- and protagonisteIncident.autorite.id = :autoriteId
+ and protagonisteIncident.autorite.id in (:autoriteIds)
"""
Map params = [
- autoriteId: eleve.id
+ autoriteIds: eleves*.id
]
Map paramsCount = (Map) params.clone()
String hqlCount = "select count(*)" + hqlFromCount
- GrilleIncidentsForEleveInfo result = new GrilleIncidentsForEleveInfo()
-
Map paramsPagination = [
max: limit,
offset: start