@RequestMapping(value = "/getListeNoteClasseByAjax", method = RequestMethod.GET) @ResponseBody public String getListeNoteClasse(Model uiModel, HttpServletRequest httpServletRequest) { long matiere = Long.parseLong(httpServletRequest.getParameter("matiere")); long evaluation = Long.parseLong(httpServletRequest.getParameter("evaluation")); List<Notes> listeN = Notes.getListeNoteClasse( Matiere.findMatiere(matiere), Evaluation.findEvaluation(evaluation)) .getResultList(); return Notes.toJsonArray(listeN); }
@RequestMapping(value = "/saveNoteClasseByAjax", method = RequestMethod.GET) @ResponseBody public String saveNoteClasseByAjax( @RequestParam(value = "matiere") long matiere, @RequestParam(value = "evaluation") long evaluation, @RequestParam(value = "inscription") long inscription, @RequestParam(value = "noteEtudiant") long value, Model uiModel, HttpServletRequest httpServletRequest) { Notes note; Matiere mat = Matiere.findMatiere(matiere); Evaluation ev = Evaluation.findEvaluation(evaluation); Inscription inscript = Inscription.findInscription(inscription); Eleve eleve = inscript.getEleve(); note = Notes.findNote(mat, ev, inscript); if (value > 20) { return null; } if (note == null) { note = new Notes(); note.setCoefficient(mat.getCoefficient()); note.setMatiere(mat); note.setDateSaisie(new Date()); note.setEleve(eleve); note.setInscripionEleve(inscript); note.setEvaluation(ev); note.setPourcentage(ev.getPourcentage()); note.setValeur(value); note.setEtablissement(ev.getEtablissement()); note.setAgentSaisie(SecurityUtil.getUserName()); note.persist(); } else { note.setCoefficient(mat.getCoefficient()); note.setMatiere(mat); note.setEleve(eleve); note.setInscripionEleve(inscript); note.setEvaluation(ev); note.setPourcentage(ev.getPourcentage()); note.setValeur(value); note.setEtablissement(ev.getEtablissement()); note.setDateUpdate(new Date()); note.setAgentUpdate(SecurityUtil.getUserName()); note.merge(); } List<Notes> listeN = Notes.getListeNoteClasse( Matiere.findMatiere(matiere), Evaluation.findEvaluation(evaluation)) .getResultList(); System.out.println("Taille - : " + listeN.size()); return Notes.toJsonArray(listeN); }