diff --git a/src/fr/devinsy/statoolinfos/htmlize/ExportsPage.java b/src/fr/devinsy/statoolinfos/htmlize/ExportsPage.java
new file mode 100644
index 0000000..a265607
--- /dev/null
+++ b/src/fr/devinsy/statoolinfos/htmlize/ExportsPage.java
@@ -0,0 +1,242 @@
+/*
+ * Copyright (C) 2021 Christian Pierre MOMON
+ *
+ * This file is part of StatoolInfos, simple service statistics tool.
+ *
+ * StatoolInfos is free software: you can redistribute it and/or modify
+ * it 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.
+ *
+ * StatoolInfos 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
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with StatoolInfos. If not, see .
+ */
+package fr.devinsy.statoolinfos.htmlize;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.text.StringEscapeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import fr.devinsy.statoolinfos.HtmlizerContext;
+import fr.devinsy.statoolinfos.core.Federation;
+import fr.devinsy.statoolinfos.core.Organization;
+import fr.devinsy.statoolinfos.core.Service;
+import fr.devinsy.statoolinfos.core.StatoolInfosException;
+import fr.devinsy.statoolinfos.properties.PathPropertyUtils;
+import fr.devinsy.strings.StringList;
+import fr.devinsy.strings.StringsUtils;
+import fr.devinsy.xidyn.XidynException;
+import fr.devinsy.xidyn.presenters.PresenterUtils;
+
+/**
+ * The Class ExportsPage.
+ */
+public class ExportsPage
+{
+ private static Logger logger = LoggerFactory.getLogger(ExportsPage.class);
+
+ /**
+ * Builds the.
+ *
+ * @throws StatoolInfosException
+ * the statool infos exception
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ public static void build() throws StatoolInfosException, IOException
+ {
+ File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
+
+ //
+ logger.info("EXPORTS JSON.");
+ ExportsPage.buildFederationExport();
+ ExportsPage.buildOrganizationsExport();
+ ExportsPage.buildServicesExport();
+
+ //
+ String page = htmlize();
+ FileUtils.write(new File(htmlizeDirectory, "exports.xhtml"), page, StandardCharsets.UTF_8);
+ }
+
+ /**
+ * Builds the federation export.
+ *
+ * @throws StatoolInfosException
+ * the statool infos exception
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ public static void buildFederationExport() throws StatoolInfosException, IOException
+ {
+ Federation federation = HtmlizerContext.instance().getFederation();
+ File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
+
+ StringList lines = new StringList();
+
+ lines.appendln("{ \"federation\" : ");
+
+ lines.addAll(PathPropertyUtils.toJSON(federation));
+
+ lines.removeLast();
+ lines.appendln(",");
+ lines.appendln("\"organizations\" : [");
+
+ for (Organization organization : federation.getOrganizations())
+ {
+ lines.addAll(PathPropertyUtils.toJSON(organization));
+ lines.removeLast();
+
+ lines.appendln(",");
+ lines.append("\"services\" : [");
+
+ for (Service service : organization.getServices())
+ {
+ lines.addAll(PathPropertyUtils.toJSON(service));
+ lines.appendln(",");
+ }
+ if (!organization.getServices().isEmpty())
+ {
+ lines.removeLast(2);
+ }
+ lines.appendln();
+ lines.appendln("]");
+ lines.append("}");
+ lines.appendln(",");
+ }
+ if (!federation.getOrganizations().isEmpty())
+ {
+ lines.removeLast(2);
+ lines.appendln();
+ }
+
+ lines.appendln("]");
+
+ lines.appendln("}");
+ lines.appendln("}");
+
+ logger.info("Htmlize federation JSON Export pages.");
+ StringsUtils.writeToFile(new File(htmlizeDirectory, "federation.json"), lines);
+ }
+
+ /**
+ * Builds the organizations export.
+ *
+ * @throws StatoolInfosException
+ * the statool infos exception
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ public static void buildOrganizationsExport() throws StatoolInfosException, IOException
+ {
+ Federation federation = HtmlizerContext.instance().getFederation();
+ File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
+
+ StringList lines = new StringList();
+
+ lines.appendln("{ \"organizations\" : [");
+
+ for (Organization organization : federation.getOrganizations())
+ {
+ lines.addAll(PathPropertyUtils.toJSON(organization));
+ lines.append(",");
+ }
+ if (!federation.getOrganizations().isEmpty())
+ {
+ lines.removeLast();
+ }
+
+ lines.appendln("] }");
+
+ logger.info("Htmlize organizations JSON Export pages.");
+ StringsUtils.writeToFile(new File(htmlizeDirectory, "organizations.json"), lines);
+ }
+
+ /**
+ * Builds the services export.
+ *
+ * @throws StatoolInfosException
+ * the statool infos exception
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ public static void buildServicesExport() throws StatoolInfosException, IOException
+ {
+ Federation federation = HtmlizerContext.instance().getFederation();
+ File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
+
+ StringList lines = new StringList();
+
+ lines.appendln("{ \"services\" : [");
+
+ for (Service service : federation.getAllServices())
+ {
+ lines.addAll(PathPropertyUtils.toJSON(service));
+ lines.append(",");
+ }
+ if (!federation.getAllServices().isEmpty())
+ {
+ lines.removeLast();
+ }
+
+ lines.appendln("] }");
+
+ logger.info("Htmlize services JSON Export pages.");
+ StringsUtils.writeToFile(new File(htmlizeDirectory, "services.json"), lines);
+ }
+
+ /**
+ * Escape.
+ *
+ * @param source
+ * the source
+ * @return the string
+ */
+ public static String escapeJSON(final String source)
+ {
+ String result;
+
+ result = StringEscapeUtils.escapeJson(source);
+
+ //
+ return result;
+ }
+
+ /**
+ * Htmlize.
+ *
+ * @return the string
+ * @throws StatoolInfosException
+ * the statool infos exception
+ */
+ public static String htmlize() throws StatoolInfosException
+ {
+ String result;
+
+ try
+ {
+ logger.info("PAGE EXPORTS.");
+
+ String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/exports.xhtml", null).toString();
+
+ BreadcrumbTrail trail = new BreadcrumbTrail();
+ result = WebCharterView.build(content, trail);
+ }
+ catch (XidynException exception)
+ {
+ throw new StatoolInfosException("Error building federation page: " + exception.getMessage(), exception);
+ }
+
+ //
+ return result;
+ }
+}
diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java
index 2482236..5769eee 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java
+++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java
@@ -86,7 +86,7 @@ public class FederationPage
try
{
- logger.debug("Building propoertiesFile page {}…", federation.getName());
+ logger.debug("Building federation page {}…", federation.getName());
TagDataManager data = new TagDataManager();
diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java
index 37a656c..8f20f04 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java
+++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java
@@ -195,6 +195,7 @@ public class Htmlizer
SoftwaresPage.build();
SoftwarePage.buildAll();
SocialNetworksPage.buildAll();
+ ExportsPage.build();
}
/**
@@ -271,7 +272,7 @@ public class Htmlizer
chart = new BarChart("Nombre de membres");
- PathPropertyList values = federation.getByYearPrefix("metrics.federation.members.count").sortByPath();
+ PathPropertyList values = federation.getByYearPrefix("metrics.members.count").sortByPath();
for (PathProperty property : values)
{
diff --git a/src/fr/devinsy/statoolinfos/htmlize/exports.xhtml b/src/fr/devinsy/statoolinfos/htmlize/exports.xhtml
new file mode 100644
index 0000000..2b08515
--- /dev/null
+++ b/src/fr/devinsy/statoolinfos/htmlize/exports.xhtml
@@ -0,0 +1,40 @@
+
+
+
+
+ StatoolInfos
+
+
+
+
+
+
+
+
+
+
Exports
+
+
+
+
La fédération :
+
+
+
+
+
+
+
Les organisations :
+
+
+
+
+
+
+
+
+
diff --git a/src/fr/devinsy/statoolinfos/htmlize/stuff/statoolinfos.css b/src/fr/devinsy/statoolinfos/htmlize/stuff/statoolinfos.css
index 58b4697..b2ffff8 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/stuff/statoolinfos.css
+++ b/src/fr/devinsy/statoolinfos/htmlize/stuff/statoolinfos.css
@@ -822,4 +822,27 @@ table > tfoot > tr > th.danger
.chartborder
{
border: 1px solid #e7e7e7;
+}
+
+/************************************************/
+.exportsView div:first-child
+{
+ width: 200px;
+}
+
+.exportsView div
+{
+ vertical-align: middle !important;
+}
+
+.exportsView div:nth-child(3),
+.exportsView div:nth-child(4)
+{
+ margin-left: 50px;
+}
+
+.exportsView div img,
+.exportsView div a img
+{
+ width: 50px;
}
\ No newline at end of file
diff --git a/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml
index 6e0779e..101bd86 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml
+++ b/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml
@@ -31,6 +31,7 @@
Fichiers
Propriétés
Statistiques
+ Exports
n/a > n/a
diff --git a/src/fr/devinsy/statoolinfos/properties/PathPropertyUtils.java b/src/fr/devinsy/statoolinfos/properties/PathPropertyUtils.java
index 67f857e..58b45ec 100644
--- a/src/fr/devinsy/statoolinfos/properties/PathPropertyUtils.java
+++ b/src/fr/devinsy/statoolinfos/properties/PathPropertyUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 Christian Pierre MOMON
+ * Copyright (C) 2020-2021 Christian Pierre MOMON
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@@ -30,6 +30,7 @@ import java.net.URL;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -299,6 +300,48 @@ public class PathPropertyUtils
}
}
+ /**
+ * To JSON.
+ *
+ * @param properties
+ * the properties
+ * @return the string list
+ */
+ public static StringList toJSON(final PathPropertyList properties)
+ {
+ StringList result;
+
+ result = new StringList();
+
+ result.append("{");
+
+ if (properties != null)
+ {
+ boolean firstDone = false;
+ for (PathProperty property : properties)
+ {
+ if (StringUtils.isNotBlank(property.getValue()))
+ {
+ firstDone = true;
+ result.append("\"");
+ result.append(StringEscapeUtils.escapeJson(property.getPath()));
+ result.append("\" : \"");
+ result.append(StringEscapeUtils.escapeJson(property.getValue()));
+ result.append("\"");
+ result.append(",");
+ }
+ }
+ if (firstDone)
+ {
+ result.removeLast();
+ }
+ }
+ result.append("}");
+
+ //
+ return result;
+ }
+
/**
* Value of.
*