--- /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.rapport
+
+import groovy.xml.MarkupBuilder
+import org.codehaus.groovy.runtime.InvokerHelper
+import org.lilie.services.eliot.basculeannee.erreurs.BasculeAnneeErreur
+
+/**
+ * Gère des motifs récurrent des rapports html d'eliot
+ * @author othe
+ */
+public class RapportBuilder extends MarkupBuilder {
+
+ public RapportBuilder() {
+ super()
+ }
+
+ public RapportBuilder(Writer writer) {
+ super(writer)
+ }
+
+ public Object invokeMethod(String methodName, Object args) {
+
+ Object name = getName(methodName)
+ Object node = null
+ List list = InvokerHelper.asList(args)
+
+ switch (name) {
+
+ case 'logerror':
+
+ List<BasculeAnneeErreur> basculeAnneeErreurs = (List<BasculeAnneeErreur>) list.get(0)
+
+ node = super.doInvokeMethod(methodName, 'div', [["id": "Logs", "class": "portal-menu-separator"], {
+ basculeAnneeErreurs.each {BasculeAnneeErreur log ->
+ p('class': 'erreur', log.toString())
+ dbr {}
+ }
+
+ }])
+
+ return node
+
+ case 'rowint':
+
+ String valueName = (String) list.get(0)
+ Integer value = (Integer) list.get(1)
+ TypeItemRapport clazz = null
+
+ if (list.size() == 3) {
+ clazz = (TypeItemRapport) list.get(2)
+ }
+
+ String valeur = "${value ?: 0}"
+
+ if (clazz) {
+ if (value > 0) {
+ node = super.doInvokeMethod(methodName, 'tr', [['class': 'warning'], {
+ td valueName
+ td valeur
+ }])
+ }
+
+ } else {
+ node = super.doInvokeMethod(methodName, 'tr') {
+ td valueName
+ td valeur
+ }
+ }
+
+ return node
+
+ case 'mapitem':
+
+ String valueName = (String) list.get(0)
+ String value = (String) list.get(1)
+
+ node = super.doInvokeMethod(methodName, 'li', valueName)
+ setParent(getCurrent(), node)
+
+ node = super.doInvokeMethod(methodName, 'li', value)
+ setParent(getCurrent(), node)
+
+ node = super.doInvokeMethod(methodName, 'br', [])
+ setParent(getCurrent(), node)
+
+ return node
+
+ case 'corps':
+
+ Object object = list.get(0)
+
+ if (object == null) {
+ throw new IllegalArgumentException("La balise 'corps' doit avoir une liste en paramètre")
+ }
+
+ if (!object instanceof List) {
+ throw new IllegalArgumentException("La balise 'corps' doit avoir une liste en paramètre")
+ }
+
+ node = super.doInvokeMethod(methodName, 'h4') {
+
+ List lst = (List) object
+ lst.each {String ligne ->
+ Object nodeElement
+ if (ligne) {
+ li ligne.toString()
+ } else {
+ br()
+ }
+ }
+ }
+ return node
+
+ case 'dbr':
+
+ node = super.doInvokeMethod(methodName, 'br', [])
+ setParent(getCurrent(), node)
+ node = super.doInvokeMethod(methodName, 'br', [])
+ setParent(getCurrent(), node)
+
+ return node
+
+ default:
+ return doInvokeMethod(methodName, name, args);
+ }
+ }
+
+}