* <http://www.cecill.info/licences.fr.html>.
*/
-
-
-
-
package org.lilie.services.eliot.notes.domaine
import grails.converters.JSON
import org.lilie.services.eliot.scolarite.PeriodeService
import org.lilie.services.eliot.scolarite.TypePeriode
import org.lilie.services.eliot.notes.NotesFonction
+import org.lilie.services.eliot.scolarite.NaturePeriode
+import org.lilie.services.eliot.notes.scolarite.NotesSousServiceService
+
/**
* La classe contient toutes les actions communes qui concernent à
NotesDroitService notesDroitService
NotesStructureEnseignementService notesStructureEnseignementService
PeriodeService periodeService
+ NotesSousServiceService notesSousServiceService
/**
* Retourne la liste des classe auxquelles l'utilisateur a l'accès
[
id: it.id,
code: it.code,
- typeIntervalle: it?.structureEnseignementNotes.typeIntervalle]
+ typeIntervalle: it?.structureEnseignementNotes?.typeIntervalle]
}]
}
TypePeriode typePeriode = TypePeriode.get(typePeriodeId)
List<StructureEnseignement> classes =
- notesStructureEnseignementService.internalFindAllClasse(typePeriode, etablissementCourant())
+ notesStructureEnseignementService.internalFindAllClasse(typePeriode, etablissementCourant())
classes.sort {a, b -> cc.compare(a.code, b.code)}
render result as JSON
}
+ def listeClassesParNaturePeriode = {
+ Map result = tryCatch {
+ notesDroitService.verifieAutorisationByEtablissement(
+ securiteSession,
+ etablissementCourant(),
+ Action.CONSULTATION,
+ NotesFonction.DIRECTION_ASSIMILE
+ )
+
+ String naturePeriodeStr = params.naturePeriode
+ if (naturePeriodeStr == null) {
+ throw new IllegalArgumentException('naturePeriode est null')
+ }
+ NaturePeriode naturePeriode = NaturePeriode.parseString(naturePeriodeStr)
+
+ String classeIdStr = params.classeId
+ if (classeIdStr == null) {
+ throw new IllegalArgumentException('classeId est null')
+ }
+ Long classeId = Long.parseLong(classeIdStr)
+
+ String typePeriodeIdStr = params.typePeriodeId
+ if (naturePeriode == NaturePeriode.EXAMEN && typePeriodeIdStr == null) {
+ throw new IllegalArgumentException('typePeriodeId est null')
+ }
+ TypePeriode typePeriode = typePeriodeIdStr ?
+ TypePeriode.get(typePeriodeIdStr) : null
+
+
+ List<StructureEnseignement> classes = notesStructureEnseignementService.
+ findAllClasseForEtablissementNatureTypePeriode(
+ securiteSession,
+ etablissementCourant(),
+ naturePeriode,
+ typePeriode)
+
+ classes.sort {a, b -> cc.compare(a.code, b.code)}
+
+ List classesList = classes.findAll { it.id != classeId }.collect {
+ [id: it.id, code: it.code]
+ }
+
+ return [classes: classesList]
+ }
+
+ render result as JSON
+ }
+
+
+
}