diff --git a/README.md b/README.md index ce0f8a1..f8b1a9b 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Usage: statoolinfos clear remove property files from conf statoolinfos crawl crawl all file from conf and input statoolinfos format format property files in tiny way - statoolinfos htmlize generate web pages from conf + s̶t̶a̶t̶o̶o̶l̶i̶n̶f̶o̶s̶ ̶h̶t̶m̶l̶i̶z̶e̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶<̶c̶o̶n̶f̶i̶g̶u̶r̶a̶t̶i̶o̶n̶f̶i̶l̶e̶>̶ ̶ ̶ ̶ ̶ ̶g̶e̶n̶e̶r̶a̶t̶e̶ ̶w̶e̶b̶ ̶p̶a̶g̶e̶s̶ ̶f̶r̶o̶m̶ ̶c̶o̶n̶f̶ REMOVED since splitweb statoolinfos probe OPTION [|] generate metrics files from conf OPTION = [-full|-today|-previousday|-NN] with NN a day count statoolinfos tagdate update the file.datetime file @@ -101,6 +101,14 @@ Usage: statoolinfos list errlog display http error log lines ``` +### htmlize removed +The htmlize command is removed since 2024-07. + +As a reminder, the htmlize command generated absolutely all the pages needed for a static site. + +As the number of pages generated became too large (> 10000 with 100 organizations), the decision was made to separate the html valuation into a separate project, StatoolInfosWeb. + +A dynamic web site allows to generate page only when it is necessary. ## Generate metrics files diff --git a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java index cf461a2..bbecbdb 100644 --- a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java +++ b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java @@ -110,7 +110,7 @@ public final class StatoolInfosCLI message.appendln(" statoolinfos clear remove property files from conf"); message.appendln(" statoolinfos crawl crawl all file from conf and input"); message.appendln(" statoolinfos format format property files in tiny way"); - message.appendln(" statoolinfos htmlize generate web pages from conf"); + message.appendln(" s̶t̶a̶t̶o̶o̶l̶i̶n̶f̶o̶s̶ ̶h̶t̶m̶l̶i̶z̶e̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶ ̶<̶c̶o̶n̶f̶i̶g̶u̶r̶a̶t̶i̶o̶n̶f̶i̶l̶e̶> REMOVED since splitweb"); message.appendln(" statoolinfos probe OPTION [|] generate metrics files from conf"); message.appendln(" OPTION = [-full|-today|-previousday|-NN] with NN a day count"); message.appendln(" statoolinfos tagdate update the file.datetime file"); @@ -300,21 +300,6 @@ public final class StatoolInfosCLI } } } - else if (CLIUtils.isMatching(args, "htmlize", ".+\\.conf")) - { - Chrono chrono = new Chrono().start(); - File configurationFile = new File(StringUtils.trim(args[1])); - try - { - StatoolInfos.htmlize(configurationFile); - } - catch (Exception exception) - { - logger.error("Error with [{}]: {}", configurationFile.getAbsoluteFile(), exception.getMessage()); - exception.printStackTrace(); - } - System.out.println(chrono.format()); - } else if (CLIUtils.isMatching(args, "list", "ip", "(-all|-bot|-nobot)", ".+\\.conf*")) { BotFilter filter = parseLogFilterOption(args[2]); diff --git a/src/fr/devinsy/statoolinfos/core/StatoolInfos.java b/src/fr/devinsy/statoolinfos/core/StatoolInfos.java index cf0359f..4f4dce2 100644 --- a/src/fr/devinsy/statoolinfos/core/StatoolInfos.java +++ b/src/fr/devinsy/statoolinfos/core/StatoolInfos.java @@ -31,7 +31,6 @@ import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.HtmlizerContext; import fr.devinsy.statoolinfos.build.Builder; import fr.devinsy.statoolinfos.crawl.Crawler; -import fr.devinsy.statoolinfos.htmlize.Htmlizer; import fr.devinsy.statoolinfos.metrics.Prober; import fr.devinsy.statoolinfos.metrics.httpaccess.HttpAccessLog; import fr.devinsy.statoolinfos.metrics.httpaccess.HttpAccessLogs; @@ -92,7 +91,6 @@ public class StatoolInfos Builder.clear(configuration); new Crawler(configuration.getCrawlCacheDirectory()).clear(); - Htmlizer.clear(configuration); } /** @@ -150,21 +148,6 @@ public class StatoolInfos } } - /** - * Htmlize. - * - * @param configurationFile - * the input - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void htmlize(final File configurationFile) throws StatoolInfosException, IOException - { - Htmlizer.htmlize(configurationFile); - } - /** * List files. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/AboutPage.java b/src/fr/devinsy/statoolinfos/htmlize/AboutPage.java deleted file mode 100644 index 3d48037..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/AboutPage.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2020 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.crawl.CrawlCache; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class AboutPage. - */ -public class AboutPage -{ - private static Logger logger = LoggerFactory.getLogger(AboutPage.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 - { - logger.info("Htmlize about page."); - - Federation federation = HtmlizerContext.instance().getFederation(); - CrawlCache cache = HtmlizerContext.instance().getCache(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - String page = htmlize(); - FileUtils.write(new File(htmlizeDirectory, "about.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize() throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building about page {}."); - - TagDataManager data = new TagDataManager(); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/about.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("À propos", "about.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building about page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/Breadcrumb.java b/src/fr/devinsy/statoolinfos/htmlize/Breadcrumb.java deleted file mode 100644 index ee494d8..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/Breadcrumb.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2020 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; - -/** - * The Class Breadcrumb. - */ -public class Breadcrumb -{ - private String label; - private String link; - - /** - * Instantiates a new breadcrumb. - */ - public Breadcrumb() - { - } - - /** - * Instantiates a new breadcrumb. - * - * @param label - * the label - * @param link - * the link - */ - public Breadcrumb(final String label, final String link) - { - this.label = label; - this.link = link; - } - - /** - * Gets the label. - * - * @return the label - */ - public String getLabel() - { - return this.label; - } - - /** - * Gets the link. - * - * @return the link - */ - public String getLink() - { - return this.link; - } - - /** - * Sets the label. - * - * @param label - * the new label - */ - public void setLabel(final String label) - { - this.label = label; - } - - /** - * Sets the link. - * - * @param link - * the new link - */ - public void setLink(final String link) - { - this.link = link; - } - -} \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/htmlize/BreadcrumbTrail.java b/src/fr/devinsy/statoolinfos/htmlize/BreadcrumbTrail.java deleted file mode 100644 index 93605e8..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/BreadcrumbTrail.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2020-2023 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.util.ArrayList; - -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class BreadcrumbTrail. - */ -public class BreadcrumbTrail extends ArrayList -{ - private static final long serialVersionUID = -2688444486042912675L; - - /** - * Instantiates a new breadcrumb trail. - */ - public BreadcrumbTrail() - { - this("🏡", "index.xhtml"); - } - - /** - * Instantiates a new breadcrumb trail. - * - * @param label - * the label - * @param link - * the link - */ - public BreadcrumbTrail(final String label, final String link) - { - super(); - add(label, link); - } - - /** - * Adds the. - * - * @param label - * the label - * @return the breadcrumb trail - */ - public BreadcrumbTrail add(final String label) - { - BreadcrumbTrail result; - - Breadcrumb crumb = new Breadcrumb(label, null); - - add(crumb); - - result = this; - - // - return result; - } - - /** - * Adds the. - * - * @param label - * the label - * @param link - * the link - * @return the breadcrumb trail - */ - public BreadcrumbTrail add(final String label, final String link) - { - BreadcrumbTrail result; - - Breadcrumb crumb = new Breadcrumb(label, link); - - add(crumb); - - result = this; - - // - return result; - } - - /** - * To string. - * - * @return the string - */ - @Override - public String toString() - { - String result; - - StringList buffer = new StringList(); - - for (Breadcrumb crumb : this) - { - if (crumb.getLink() == null) - { - buffer.append(XidynUtils.escapeXmlBlank(crumb.getLabel())); - } - else - { - buffer.append(String.format("%s", crumb.getLink(), XidynUtils.escapeXmlBlank(crumb.getLabel()))); - } - buffer.append(" > "); - } - if (buffer.size() > 2) - { - buffer.removeLast(); - } - - result = buffer.toString(); - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/CategoriesPage.java b/src/fr/devinsy/statoolinfos/htmlize/CategoriesPage.java deleted file mode 100644 index 721931e..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/CategoriesPage.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2020-2023 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Categories; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.core.StatoolInfosUtils; -import fr.devinsy.statoolinfos.stats.StatAgent; -import fr.devinsy.statoolinfos.stats.categories.CategoryStat; -import fr.devinsy.statoolinfos.stats.categories.CategoryStats; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class CategoriesPage. - */ -public class CategoriesPage -{ - private static Logger logger = LoggerFactory.getLogger(CategoriesPage.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 - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - Categories categories = HtmlizerContext.instance().getCategories(); - - logger.info("Htmlize categories page."); - CategoryStats stats = StatAgent.statAllCategories(federation, categories); - String page = CategoriesPage.htmlize(stats); - FileUtils.write(new File(htmlizeDirectory, "categories.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param stats - * the stats - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final CategoryStats stats) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building categories page."); - - TagDataManager data = new TagDataManager(); - - data.setContent("categoryCount", stats.size()); - - int index = 0; - for (CategoryStat stat : stats) - { - data.setEscapedContent("categoryListLine", index, "categoryListLineNameValue", stat.getCategory().getName()); - data.setAttribute("categoryListLine", index, "categoryListLineNameLink", "href", "category-" + stat.getCategory().getTechnicalName() + ".xhtml"); - data.setAttribute("categoryListLine", index, "categoryListLineNameLink", "title", stat.getCategory().getDescription()); - data.setAttribute("categoryListLine", index, "categoryListLineNameLogo", "src", stat.getCategory().getLogoPath()); - - data.setEscapedContent("categoryListLine", index, "categoryListLineSoftwares", stat.getCategory().getSoftwares().sort().toStringWithFrenchCommas()); - data.setContent("categoryListLine", index, "categoryListLineOrganizationCount", stat.getOrganizationCount()); - data.setContent("categoryListLine", index, "categoryListLineServiceCount", StatoolInfosUtils.defaultIfZero(stat.getServiceCount(), "😿")); - data.setContent("categoryListLine", index, "categoryListLineUserCount", StatoolInfosUtils.defaultIfZero(stat.getUserCount(), "😢")); - data.setContent("categoryListLine", index, "categoryListLineVisitCount", StatoolInfosUtils.defaultIfZero(stat.getVisitCount(), "😞")); - - index += 1; - } - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/categories.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Catégories", "categories.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building categories page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/CategoriesView.java b/src/fr/devinsy/statoolinfos/htmlize/CategoriesView.java deleted file mode 100644 index 9c05d86..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/CategoriesView.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2020 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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Categories; -import fr.devinsy.statoolinfos.core.Category; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class CategoriesView. - */ -public class CategoriesView -{ - private static Logger logger = LoggerFactory.getLogger(CategoriesView.class); - - public enum Mode - { - ALL, - ICONS_ONLY, - LABELS_ONLY - } - - /** - * Builds the. - * - * @param categories - * the categories - * @param mode - * the mode - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String build(final Categories categories, final Mode mode) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building categories view."); - - TagDataManager data = new TagDataManager(); - - int index = 0; - for (Category category : categories) - { - data.setAttribute("category", index, "categoryLink", "href", "category-" + category.getTechnicalName() + ".xhtml"); - - if (mode == Mode.ALL) - { - data.setAttribute("category", index, "categoryLink", "title", category.getDescription()); - data.setAttribute("category", index, "categoryLogo", "src", category.getLogoPath()); - data.setEscapedContent("category", index, "categoryName", category.getName()); - } - else if (mode == Mode.ICONS_ONLY) - { - data.setAttribute("category", index, "categoryLink", "title", category.getName()); - data.setAttribute("category", index, "categoryLogo", "src", category.getLogoPath()); - data.setAttribute("category", index, "categoryName", "class", "xid:nodisplay"); - } - else if (mode == Mode.LABELS_ONLY) - { - data.setAttribute("category", index, "categoryLink", "title", category.getDescription()); - data.setAttribute("category", index, "categoryLogo", "class", "xid:nodisplay"); - data.setEscapedContent("category", index, "categoryName", category.getName()); - } - - index += 1; - } - - String page = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/categoriesView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(page.replaceAll("id=\"[^\"]*\"", "")); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building categories view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/CategoryPage.java b/src/fr/devinsy/statoolinfos/htmlize/CategoryPage.java deleted file mode 100644 index fa77af1..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/CategoryPage.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2020-2022 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Categories; -import fr.devinsy.statoolinfos.core.Category; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.crawl.CrawlCache; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServicesPage. - */ -public class CategoryPage -{ - private static Logger logger = LoggerFactory.getLogger(CategoryPage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * @throws IOException - */ - public static void buildAll() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - CrawlCache cache = HtmlizerContext.instance().getCache(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - Categories categories = HtmlizerContext.instance().getCategories(); - - logger.info("Htmlize category pages."); - for (Category category : categories) - { - Services services = federation.getServices().getBy(category); - String page = CategoryPage.htmlize(category, services); - FileUtils.write(new File(htmlizeDirectory, "category-" + category.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); - } - } - - /** - * Builds the. - * - * @param category - * the category - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Category category, final Services services) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building category page."); - - TagDataManager data = new TagDataManager(); - - data.setAttribute("categoryLogo", "src", category.getLogoPath()); - data.setEscapedContent("categoryName", category.getName()); - data.setEscapedContent("categoryDescription", category.getDescription()); - data.setEscapedContent("categorySoftwares", category.getSoftwares().sort().toStringWithFrenchCommas()); - data.setContent("serviceCount", services.size()); - data.setContent("serviceListView", ServiceListView.htmlize(services.sortByName())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/category.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Catégories", "categories.xhtml"); - trail.add(category.getName(), "category-" + category.getTechnicalName() + ".xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building category page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java deleted file mode 100644 index 61b8ddf..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java +++ /dev/null @@ -1,1754 +0,0 @@ -/* - * Copyright (C) 2020-2022 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.time.DayOfWeek; -import java.time.LocalDate; -import java.time.Year; -import java.time.YearMonth; -import java.time.format.DateTimeFormatter; -import java.util.Locale; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.threeten.extra.YearWeek; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Categories; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.Organizations; -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.charts.BarChart; -import fr.devinsy.statoolinfos.htmlize.charts.BarChartView; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColors; -import fr.devinsy.statoolinfos.htmlize.charts.DoughnutChartView; -import fr.devinsy.statoolinfos.htmlize.charts.PieChart; -import fr.devinsy.statoolinfos.htmlize.charts.PieChart.Position; -import fr.devinsy.statoolinfos.htmlize.charts.PieChartView; -import fr.devinsy.statoolinfos.metrics.StringCounter; -import fr.devinsy.statoolinfos.metrics.StringCounterList; -import fr.devinsy.statoolinfos.metrics.StringCounters; -import fr.devinsy.statoolinfos.properties.MonthValues; -import fr.devinsy.statoolinfos.properties.PathProperty; -import fr.devinsy.statoolinfos.properties.PathPropertyList; -import fr.devinsy.statoolinfos.properties.WeekValues; -import fr.devinsy.statoolinfos.properties.YearValues; -import fr.devinsy.statoolinfos.stats.StatAgent; -import fr.devinsy.statoolinfos.stats.categories.CategoryStat; -import fr.devinsy.statoolinfos.stats.categories.CategoryStats; -import fr.devinsy.statoolinfos.stats.country.CountryStats; -import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats; -import fr.devinsy.statoolinfos.stats.organizations.OrganizationTypeStats; -import fr.devinsy.statoolinfos.stats.services.HostProviderTypeStats; -import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats; -import fr.devinsy.statoolinfos.stats.services.RegistrationStats; -import fr.devinsy.statoolinfos.stats.services.ServiceInstallTypeStats; -import fr.devinsy.statoolinfos.stats.softwares.SoftwareStat; -import fr.devinsy.statoolinfos.stats.softwares.SoftwareStats; -import fr.devinsy.strings.StringList; - -/** - * The Class ChartHtmlizer. - */ -public class ChartHtmlizer -{ - private static Logger logger = LoggerFactory.getLogger(ChartHtmlizer.class); - - /** - * Instantiates a new chart htmlizer. - */ - private ChartHtmlizer() - { - } - - /** - * Htmlize category distribution chart. - * - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeCategoryDistributionChart() throws StatoolInfosException - { - String result; - - BarChart chart; - - chart = new BarChart("Distribution des catégories les plus proposées"); - chart.addDataset("Catégories"); - - Federation federation = HtmlizerContext.instance().getFederation(); - Categories categories = HtmlizerContext.instance().getCategories(); - - CategoryStats stats = StatAgent.statAllCategories(federation, categories); - stats.sortByServiceCount().reverse(); - - for (CategoryStat stat : stats) - { - if (stat.getServiceCount() > 0) - { - chart.add(stat.getCategory().getName(), stat.getServiceCount(), ChartColor.PURPLE); - } - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize catergory distribution pie chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeCatergoryDistributionPieChart(final Services services) throws StatoolInfosException - { - String result; - - Federation federation = HtmlizerContext.instance().getFederation(); - Categories categories = HtmlizerContext.instance().getCategories(); - - CategoryStats stats = StatAgent.statAllCategories(federation, categories); - stats.sortByServiceCount().reverse(); - - ChartColors colors = ChartColor.valueList(); - colors.remove(ChartColor.BLUE); - - PieChart pie = new PieChart("Répartition des services par catégorie"); - int index = 0; - while ((index < stats.size() && (index < 10))) - { - ChartColor color = colors.get(index); - CategoryStat stat = stats.get(index); - pie.add(StringUtils.abbreviate(stat.getCategory().getName(), 30), stat.getServiceCount(), color); - - index += 1; - } - - int others = 0; - while (index < stats.size()) - { - CategoryStat stat = stats.get(index); - others += stat.getServiceCount(); - - index += 1; - } - pie.add("Autres catégories", others, ChartColor.BLUE); - pie.setLegendPosition(Position.RIGHT); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize host name pie chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeHostNamePieChart(final Services services) throws StatoolInfosException - { - String result; - - ChartColors colors = ChartColor.valueList(); - colors.remove(ChartColor.BLUE); - - StringCounters counters = new StringCounters(); - long unknowns = 0; - for (Service service : services) - { - if (service.getHostProviderType() == null) - { - unknowns += 1; - } - else - { - switch (service.getHostProviderType()) - { - case HOME: - counters.inc("Auto-hébergé"); - break; - - case HOSTEDBAY: - case HOSTEDSERVER: - case OUTSOURCED: - counters.inc(service.getHostName()); - break; - - case UNKNOWN: - unknowns += 1; - default: - } - } - } - - StringCounterList list = counters.toList().sortByCounter().reverse(); - - PieChart pie = new PieChart("Hébergeurs des services"); - pie.setLegendPosition(Position.RIGHT); - - int index = 0; - while ((index < list.size() && (index < 8))) - { - ChartColor color = colors.get(index); - StringCounter counter = list.get(index); - pie.add(counter.getString(), counter.getCounter(), color); - - index += 1; - } - - int others = 0; - while (index < list.size()) - { - StringCounter counter = list.get(index); - others += counter.getCounter(); - - index += 1; - } - pie.add("Autres", others, ChartColor.GREY); - pie.add("Inconnus", unknowns, ChartColor.BLUE); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize host provider hypervisor chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeHostProviderHypervisorChart(final Services services) throws StatoolInfosException - { - String result; - - ChartColors colors = ChartColor.valueList(); - colors.remove(ChartColor.BLUE); - - StringCounters counters = new StringCounters(); - long unknowns = 0; - for (Service service : services) - { - String hypervisor = service.getHostProviderHypervisor(); - if (StringUtils.isBlank(hypervisor)) - { - unknowns += 1; - } - else - { - counters.inc(StringUtils.capitalize(hypervisor.toLowerCase())); - } - } - - StringCounterList list = counters.toList().sortByCounter().reverse(); - - PieChart pie = new PieChart("Distributions des hyperviseurs"); - pie.setLegendPosition(Position.RIGHT); - - int index = 0; - while ((index < list.size() && (index < 7))) - { - ChartColor color = colors.get(index); - StringCounter counter = list.get(index); - pie.add(counter.getString(), counter.getCounter(), color); - - index += 1; - } - - int others = 0; - while (index < list.size()) - { - StringCounter counter = list.get(index); - others += counter.getCounter(); - - index += 1; - } - pie.add("Autres", others, ChartColor.GREY); - pie.add("Inconnus", unknowns, ChartColor.BLUE); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize host provider type chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - */ - public static String htmlizeHostProviderTypeChart(final Services services) throws StatoolInfosException - { - String result; - - HostProviderTypeStats stats = StatAgent.statHostProviderType(services); - - PieChart pie = new PieChart("Types d'hébergement"); - pie.add("Home", stats.getHomeCount(), ChartColor.GREEN); - pie.add("Baie", stats.getHostedBayCount(), ChartColor.YELLOW); - pie.add("Serveur", stats.getHostedServerCount(), ChartColor.ORANGE); - pie.add("Externalisé", stats.getOutsourcedCount(), ChartColor.RED); - pie.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE); - pie.setLegendPosition(Position.RIGHT); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize host server distribution chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeHostServerDistributionChart(final Services services) throws StatoolInfosException - { - String result; - - ChartColors colors = ChartColor.valueList(); - colors.remove(ChartColor.BLUE); - - StringCounters counters = new StringCounters(); - long unknowns = 0; - for (Service service : services) - { - if (StringUtils.isBlank(service.getHostServerDistribution())) - { - unknowns += 1; - } - else - { - counters.inc(StringUtils.capitalize(service.getHostServerDistribution().toLowerCase())); - } - } - - StringCounterList list = counters.toList().sortByCounter().reverse(); - - PieChart pie = new PieChart("Distributions serveur"); - pie.setLegendPosition(Position.RIGHT); - - int index = 0; - while ((index < list.size() && (index < 7))) - { - ChartColor color = colors.get(index); - StringCounter counter = list.get(index); - pie.add(counter.getString(), counter.getCounter(), color); - - index += 1; - } - - int others = 0; - while (index < list.size()) - { - StringCounter counter = list.get(index); - others += counter.getCounter(); - - index += 1; - } - pie.add("Autres", others, ChartColor.GREY); - pie.add("Inconnus", unknowns, ChartColor.BLUE); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize host server type chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - */ - public static String htmlizeHostServerTypeChart(final Services services) throws StatoolInfosException - { - String result; - - HostServerTypeStats stats = StatAgent.statHostServerType(services); - - PieChart pie = new PieChart("Types de serveur"); - pie.add("Nano", stats.getNanoCount(), ChartColor.PURPLE); - pie.add("Physique", stats.getPhysicalCount(), ChartColor.GREEN); - pie.add("Virtuel", stats.getVirtualCount(), ChartColor.YELLOW); - pie.add("Mutualisé", stats.getSharedCount(), ChartColor.ORANGE); - pie.add("Cloud", stats.getCloudCount(), ChartColor.RED); - pie.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE); - pie.setLegendPosition(Position.RIGHT); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize metrics chart. - * - * @param title - * the title - * @param start - * the start - * @param end - * the end - * @param colors - * the colors - * @param datasets - * the datasets - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeMetricsChart(final String title, final Year start, final Year end, final ChartColor[] colors, final YearValues... datasets) throws StatoolInfosException - { - String result; - - Year startTarget; - if (start == null) - { - startTarget = null; - for (YearValues dataset : datasets) - { - Year current = dataset.getOldestTimestamp(); - - if (current != null) - { - if ((startTarget == null) || (current.isBefore(startTarget))) - { - startTarget = current; - } - } - } - } - else - { - startTarget = start; - } - - Year endTarget; - if (end == null) - { - endTarget = Year.now(); - } - else - { - endTarget = end; - } - - BarChart chart = new BarChart(title); - chart.setStacked(true); - for (YearValues dataset : datasets) - { - chart.addDataset(dataset.getLabel()); - } - - if (startTarget != null) - { - for (Year timestamp = startTarget; !timestamp.isAfter(endTarget); timestamp = timestamp.plusYears(1)) - { - String timestampLabel = timestamp.format(DateTimeFormatter.ofPattern("yyyy", Locale.FRANCE)); - chart.getLabels().add(timestampLabel); - - for (int index = 0; index < datasets.length; index++) - { - double value = datasets[index].getValue(timestamp); - chart.add(index, value, colors[index % colors.length]); - } - } - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize metrics chart. - * - * @param title - * the title - * @param start - * the start - * @param end - * the end - * @param colors - * the colors - * @param datasets - * the datasets - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeMetricsChart(final String title, final YearMonth start, final YearMonth end, final ChartColor[] colors, final MonthValues... datasets) throws StatoolInfosException - { - String result; - - YearMonth startTarget; - if (start == null) - { - startTarget = null; - for (MonthValues dataset : datasets) - { - YearMonth current = dataset.getOldestTimestamp(); - - if (current != null) - { - if ((startTarget == null) || (current.isBefore(startTarget))) - { - startTarget = current; - } - } - } - } - else - { - startTarget = start; - } - - YearMonth endTarget; - if (end == null) - { - endTarget = YearMonth.now(); - } - else - { - endTarget = end; - } - - BarChart chart = new BarChart(title); - chart.setStacked(true); - for (MonthValues dataset : datasets) - { - chart.addDataset(dataset.getLabel()); - } - - if (startTarget != null) - { - for (YearMonth timestamp = startTarget; !timestamp.isAfter(endTarget); timestamp = timestamp.plusMonths(1)) - { - String timestampLabel = timestamp.format(DateTimeFormatter.ofPattern("yyyy-MMM", Locale.FRANCE)); - chart.getLabels().add(timestampLabel); - - for (int index = 0; index < datasets.length; index++) - { - double value = datasets[index].getValue(timestamp); - chart.add(index, value, colors[index % colors.length]); - } - } - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize metrics chart. - * - * @param title - * the title - * @param start - * the start - * @param end - * the end - * @param colors - * the colors - * @param datasets - * the datasets - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeMetricsChart(final String title, final YearWeek start, final YearWeek end, final ChartColor[] colors, final WeekValues... datasets) throws StatoolInfosException - { - String result; - - YearWeek startTarget; - if (start == null) - { - startTarget = null; - for (WeekValues dataset : datasets) - { - YearWeek current = dataset.getOldestTimestamp(); - - if (current != null) - { - if ((startTarget == null) || (current.isBefore(startTarget))) - { - startTarget = current; - } - } - } - } - else - { - startTarget = start; - } - - YearWeek endTarget; - if (end == null) - { - endTarget = YearWeek.now(); - } - else - { - endTarget = end; - } - - BarChart chart = new BarChart(title); - chart.setStacked(true); - for (WeekValues dataset : datasets) - { - chart.addDataset(dataset.getLabel()); - } - - if (startTarget != null) - { - for (YearWeek timestamp = startTarget; !timestamp.isAfter(endTarget); timestamp = timestamp.plusWeeks(1)) - { - LocalDate date = timestamp.atDay(DayOfWeek.MONDAY).plusDays(6); - String timestampLabel = date.format(DateTimeFormatter.ofPattern("yyyy-MMM-dd", Locale.FRANCE)); - chart.getLabels().add(timestampLabel); - - for (int index = 0; index < datasets.length; index++) - { - double value = datasets[index].getValue(timestamp); - chart.add(index, value, colors[index % colors.length]); - } - } - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize metrics chart. - * - * @param start - * the start - * @param end - * the end - * @param dataset - * the dataset - * @param color - * the color - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeMetricsChart(final Year start, final Year end, final YearValues dataset, final ChartColor color) throws StatoolInfosException - { - String result; - - Year startTarget; - if (start == null) - { - startTarget = dataset.getOldestTimestamp(); - } - else - { - startTarget = start; - } - - Year endTarget; - if (end == null) - { - endTarget = Year.now(); - } - else - { - endTarget = end; - } - - ChartColor targetColor; - if (color == null) - { - targetColor = ChartColor.BLUE; - } - else - { - targetColor = color; - } - - BarChart chart = new BarChart(dataset.getLabel()); - // chart.setStacked(true); - chart.setAnimated(false); - chart.addDataset(dataset.getLabel()); - - if (startTarget != null) - { - for (Year timestamp = startTarget; !timestamp.isAfter(endTarget); timestamp = timestamp.plusYears(1)) - { - String timestampLabel = timestamp.format(DateTimeFormatter.ofPattern("yyyy", Locale.FRANCE)); - chart.getLabels().add(timestampLabel); - - double value = dataset.getValue(timestamp); - chart.add(0, value, targetColor); - } - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize metrics chart. - * - * @param start - * the start - * @param end - * the end - * @param dataset - * the dataset - * @param color - * the color - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeMetricsChart(final YearMonth start, final YearMonth end, final MonthValues dataset, final ChartColor color) throws StatoolInfosException - { - String result; - - YearMonth startTarget; - if (start == null) - { - startTarget = dataset.getOldestTimestamp(); - } - else - { - startTarget = start; - } - - YearMonth endTarget; - if (end == null) - { - endTarget = YearMonth.now(); - } - else - { - endTarget = end; - } - - ChartColor targetColor; - if (color == null) - { - targetColor = ChartColor.BLUE; - } - else - { - targetColor = color; - } - - BarChart chart = new BarChart(dataset.getLabel()); - // chart.setStacked(true); - chart.setAnimated(false); - chart.addDataset(dataset.getLabel()); - - if (startTarget != null) - { - for (YearMonth timestamp = startTarget; !timestamp.isAfter(endTarget); timestamp = timestamp.plusMonths(1)) - { - String timestampLabel = timestamp.format(DateTimeFormatter.ofPattern("yyyy-MMM", Locale.FRANCE)); - chart.getLabels().add(timestampLabel); - - double value = dataset.getValue(timestamp); - chart.add(0, value, targetColor); - } - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize metrics chart. - * - * @param start - * the start - * @param end - * the end - * @param dataset - * the dataset - * @param color - * the color - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeMetricsChart(final YearWeek start, final YearWeek end, final WeekValues dataset, final ChartColor color) throws StatoolInfosException - { - String result; - - YearWeek startTarget; - if (start == null) - { - startTarget = dataset.getOldestTimestamp(); - } - else - { - startTarget = start; - } - - YearWeek endTarget; - if (end == null) - { - endTarget = YearWeek.now(); - } - else - { - endTarget = end; - } - - ChartColor targetColor; - if (color == null) - { - targetColor = ChartColor.BLUE; - } - else - { - targetColor = color; - } - - BarChart chart = new BarChart(dataset.getLabel()); - // chart.setStacked(true); - chart.setAnimated(false); - chart.addDataset(dataset.getLabel()); - - if (startTarget != null) - { - for (YearWeek timestamp = startTarget; !timestamp.isAfter(endTarget); timestamp = timestamp.plusWeeks(1)) - { - LocalDate date = timestamp.atDay(DayOfWeek.MONDAY).plusDays(6); - String timestampLabel = date.format(DateTimeFormatter.ofPattern("yyyy-MMM-dd", Locale.FRANCE)); - chart.getLabels().add(timestampLabel); - - double value = dataset.getValue(timestamp); - chart.add(0, value, targetColor); - } - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize organization count chart. - * - * @param federation - * the federation - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeOrganizationCountChart(final Federation federation) throws StatoolInfosException - { - String result; - - BarChart chart; - - chart = new BarChart("Nombre de membres"); - chart.addDataset("Membres"); - - PathPropertyList values = federation.getByYearPrefix("metrics.members.count").sortByPath(); - - for (PathProperty property : values) - { - chart.add(property.getLeaf(), Double.parseDouble(property.getValue()), ChartColor.GREEN); - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * @param organizations - * @return - * @throws StatoolInfosException - */ - public static String htmlizeOrganizationCountryChart(final Organizations organizations) throws StatoolInfosException - { - String result; - - CountryStats stats = StatAgent.statsCountry(organizations); - - PieChart pie = new PieChart("Pays des membres"); - - StringList countries = new StringList(stats.keySet()).sort(); - countries.remove(CountryStats.UNKNOWN_LABEL); - - ChartColors colors = new ChartColors(); - colors.add(ChartColor.GREEN); - colors.add(ChartColor.ORANGE); - colors.add(ChartColor.RED); - colors.add(ChartColor.PURPLE); - colors.add(ChartColor.TURQUOISE); - colors.add(ChartColor.YELLOW); - - int index = 0; - for (String country : countries) - { - pie.add(country, stats.get(country), colors.get(index)); - - index += 1; - } - pie.add("Inconnu", stats.getUnknown(), ChartColor.BLUE); - - pie.setLegendPosition(Position.RIGHT); - - result = PieChartView.build(pie); - - // - return result; - } - - /** - * Htmlize organization in out chart. - * - * @param federation - * the federation - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeOrganizationInOutChart(final Federation federation) throws StatoolInfosException - { - String result; - - BarChart chart = new BarChart("Entrées/Sorties"); - // chart.setStacked(true); - - chart.addDataset("Sorties"); - PathPropertyList values = federation.getByYearPrefix("metrics.members.out").sortByPath(); - for (PathProperty property : values) - { - chart.add(0, Double.parseDouble(property.getValue()), ChartColor.RED); - } - - chart.addDataset("Entrées"); - values = federation.getByYearPrefix("metrics.members.in").sortByPath(); - for (PathProperty property : values) - { - chart.getLabels().add(property.getLeaf()); - chart.add(1, Double.parseDouble(property.getValue()), ChartColor.GREEN); - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize organization turnout chart. - * - * @param organization - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeOrganizationTurnoutChart(final Organization organization) throws StatoolInfosException - { - String result; - - Organizations organizations = new Organizations(); - organizations.add(organization); - - result = htmlizeOrganizationTurnoutChart(organizations); - - // - return result; - } - - /** - * Htmlize organization turnout chart. - * - * @param organizations - * the organizations - * @return the string - * @throws StatoolInfosException - */ - public static String htmlizeOrganizationTurnoutChart(final Organizations organizations) throws StatoolInfosException - { - String result; - - OrganizationTurnoutStats stats = StatAgent.statsOrganizationTurnout(organizations); - - PieChart pie = new PieChart("Participation"); - pie.add("1 fichier", stats.getWithSelfFileCount(), ChartColor.ORANGE); - pie.add("n fichiers", stats.getWithServiceFileCount(), ChartColor.YELLOW); - pie.add("Métriques", stats.getWithServiceMetricCount(), ChartColor.GREEN); - pie.add("Passive", stats.getPassiveCount(), ChartColor.BLUE); - pie.setLegendPosition(Position.RIGHT); - - result = PieChartView.build(pie); - - // - return result; - } - - /** - * Htmlize organization turnout chart. - * - * @param service - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeOrganizationTurnoutChart(final Service service) throws StatoolInfosException - { - String result; - - OrganizationTurnoutStats stats = StatAgent.statsOrganizationTurnout(service); - - PieChart pie = new PieChart("Participation"); - pie.add("1 fichier", stats.getWithSelfFileCount(), ChartColor.ORANGE); - pie.add("n fichiers", stats.getWithServiceFileCount(), ChartColor.YELLOW); - pie.add("Métriques", stats.getWithServiceMetricCount(), ChartColor.GREEN); - pie.add("Passive", stats.getPassiveCount(), ChartColor.BLUE); - pie.setLegendPosition(Position.RIGHT); - - result = PieChartView.build(pie); - - // - return result; - } - - /** - * Htmlize organization type chart. - * - * @param organization - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeOrganizationTypeChart(final Organization organization) throws StatoolInfosException - { - String result; - - Organizations organizations = new Organizations(); - organizations.add(organization); - - result = htmlizeOrganizationTypeChart(organizations); - - // - return result; - } - - /** - * Htmlize organization type chart. - * - * @param organizations - * the organizations - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeOrganizationTypeChart(final Organizations organizations) throws StatoolInfosException - { - String result; - - OrganizationTypeStats stats = StatAgent.statOrganizationType(organizations); - - // {ASSOCIATION, INFORMAL, COOPERATIVE, MICROCOMPANY, COMPANY, - // INDIVIDUAL, OTHER}, obligatoire). - PieChart pie = new PieChart("Types d'organisations"); - pie.add("Association", stats.getAssociationCount(), ChartColor.GREEN); - pie.add("Informel", stats.getInformalCount(), ChartColor.YELLOW); - pie.add("Coopérative", stats.getCooperativeCount(), ChartColor.ORANGE); - pie.add("Micro-entreprise", stats.getMicrocompanyCount(), ChartColor.RED); - pie.add("Entreprise", stats.getCompanyCount(), ChartColor.VIOLET); - pie.add("Individu", stats.getIndividualCount(), ChartColor.PURPLE); - pie.add("Autre", stats.getOtherCount(), ChartColor.GREY); - pie.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE); - pie.setLegendPosition(Position.RIGHT); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize registration chart. - * - * @param stats - * the stats - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeRegistrationBarChart(final RegistrationStats stats) throws StatoolInfosException - { - String result; - - BarChart bar = new BarChart("Types d'inscription"); - bar.addDataset("Nombre"); - bar.add("Sans", stats.getNoneCount(), ChartColor.GREEN); - bar.add("Libre", stats.getFreeCount(), ChartColor.YELLOW); - bar.add("Membre", stats.getMemberCount(), ChartColor.ORANGE); - bar.add("Client", stats.getClientCount(), ChartColor.RED); - bar.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE); - - result = BarChartView.build(bar); - - // - return result; - } - - /** - * Htmlize registration client pie chart. - * - * @param stats - * the stats - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeRegistrationClientPieChart(final RegistrationStats stats) throws StatoolInfosException - { - String result; - - PieChart pie = new PieChart("Client"); - pie.setLegendVisible(false); - pie.add("Sans", stats.getClientCount(), ChartColor.RED); - pie.add("Client", stats.getCount() - stats.getClientCount(), ChartColor.BLUE); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize registration free pie chart. - * - * @param stats - * the stats - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeRegistrationFreePieChart(final RegistrationStats stats) throws StatoolInfosException - { - String result; - - PieChart pie = new PieChart("Libre"); - pie.setLegendVisible(false); - pie.add("Sans", stats.getFreeCount(), ChartColor.YELLOW); - pie.add("Libre", stats.getCount() - stats.getFreeCount(), ChartColor.BLUE); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize registration member pie chart. - * - * @param stats - * the stats - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeRegistrationMemberPieChart(final RegistrationStats stats) throws StatoolInfosException - { - String result; - - PieChart pie = new PieChart("Membre"); - pie.setLegendVisible(false); - pie.add("Sans", stats.getMemberCount(), ChartColor.ORANGE); - pie.add("Membre", stats.getCount() - stats.getMemberCount(), ChartColor.BLUE); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize registration none pie chart. - * - * @param stats - * the stats - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeRegistrationNonePieChart(final RegistrationStats stats) throws StatoolInfosException - { - String result; - - PieChart pie = new PieChart("Sans"); - pie.setLegendVisible(false); - pie.add("Sans", stats.getNoneCount(), ChartColor.GREEN); - pie.add("Autre", stats.getCount() - stats.getNoneCount(), ChartColor.BLUE); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize service count month chart. - * - * @param federation - * the federation - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceCountMonthChart(final Federation federation) throws StatoolInfosException - { - String result; - - result = htmlizeServiceCountMonthChart(federation.getServicesAll(), YearMonth.from(federation.getStartDate())); - - // - return result; - } - - /** - * Htmlize service count chart. - * - * @param organization - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceCountMonthChart(final Organization organization) throws StatoolInfosException - { - String result; - - LocalDate startDate = organization.getFederation().getStartDate(); - - if (startDate == null) - { - result = null; - } - else - { - result = htmlizeServiceCountMonthChart(organization.getServices(), YearMonth.from(startDate)); - } - - // - return result; - } - - /** - * Htmlize service count chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceCountMonthChart(final Services services) throws StatoolInfosException - { - String result; - - YearMonth first = null; - for (Service service : services) - { - LocalDate date = service.getStartDate(); - if (date != null) - { - YearMonth current = YearMonth.from(date); - if ((first == null) || (first.isBefore(current))) - { - first = current; - } - } - } - - result = htmlizeServiceCountMonthChart(services, first); - - // - return result; - } - - /** - * Htmlize service count month chart. - * - * @param services - * the services - * @param first - * the first - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceCountMonthChart(final Services services, final YearMonth first) throws StatoolInfosException - { - String result; - - BarChart chart; - - chart = new BarChart("Nombre de services (mois)"); - chart.addDataset("Services"); - - YearMonth now = YearMonth.now(); - YearMonth current = first; - while (current.compareTo(now) <= 0) - { - long count = 0; - for (Service service : services) - { - LocalDate startDate = service.getStartDate(); - LocalDate endDate = service.getEndDate(); - - if (startDate != null) - { - YearMonth start = YearMonth.from(startDate); - YearMonth end; - if (endDate == null) - { - end = now; - } - else - { - end = YearMonth.from(endDate); - } - - if ((current.compareTo(start) >= 0) && (current.compareTo(end) <= 0)) - { - count += 1; - } - } - } - - chart.add(current.toString(), count, ChartColor.VIOLET); - - current = current.plusMonths(1); - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize service country chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * )* the statool infos exception - */ - public static String htmlizeServiceCountryChart(final Services services) throws StatoolInfosException - { - String result; - - CountryStats stats = StatAgent.statsCountry(services); - - PieChart pie = new PieChart("Pays des services"); - StringList countries = new StringList(stats.keySet()).sort(); - countries.remove(CountryStats.UNKNOWN_LABEL); - - ChartColors colors = new ChartColors(); - colors.add(ChartColor.GREEN); - colors.add(ChartColor.ORANGE); - colors.add(ChartColor.RED); - colors.add(ChartColor.PURPLE); - colors.add(ChartColor.TURQUOISE); - colors.add(ChartColor.YELLOW); - - int index = 0; - for (String country : countries) - { - pie.add(country, stats.get(country), colors.get(index)); - - index += 1; - } - pie.add("Inconnu", stats.getUnknown(), ChartColor.BLUE); - - pie.setLegendPosition(Position.RIGHT); - - result = PieChartView.build(pie); - - // - return result; - } - - /** - * Htmlize service count year chart. - * - * @param federation - * the federation - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceCountYearChart(final Federation federation) throws StatoolInfosException - { - String result; - - BarChart chart; - - chart = new BarChart("Nombre de services"); - chart.addDataset("Services"); - - Year current = federation.getStartYear(); - Year now = Year.now(); - while (!current.isAfter(now)) - { - long count = federation.getServiceCountBy(current); - - chart.add(String.valueOf(current), count, ChartColor.YELLOW); - - current = current.plusYears(1); - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize service count year chart. - * - * @param organization - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceCountYearChart(final Organization organization) throws StatoolInfosException - { - String result; - - result = htmlizeServiceCountYearChart(organization.getServices(), organization.getFederation().getStartYear()); - - // - return result; - } - - /** - * Htmlize service count year chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceCountYearChart(final Services services) throws StatoolInfosException - { - String result; - - Integer first = null; - for (Service service : services) - { - LocalDate date = service.getStartDate(); - if (date != null) - { - int current = date.getYear(); - if ((first == null) || (first < current)) - { - first = current; - } - } - } - - result = htmlizeServiceCountYearChart(services, first); - - // - return result; - } - - /** - * Htmlize service count chart. - * - * @param services - * the services - * @param first - * the first - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceCountYearChart(final Services services, final Integer first) throws StatoolInfosException - { - String result; - - BarChart chart; - - chart = new BarChart("Nombre de services"); - chart.addDataset("Services"); - - if (first != null) - { - int now = Year.now().getValue(); - int current = first; - while (current <= now) - { - long count = services.countBy(Year.of(current)); - chart.add(String.valueOf(current), count, ChartColor.YELLOW); - - current += 1; - } - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize service count year chart. - * - * @param services - * the services - * @param first - * the first - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceCountYearChart(final Services services, final Year first) throws StatoolInfosException - { - String result; - - Integer value; - if (first == null) - { - value = null; - } - else - { - value = first.getValue(); - } - - result = htmlizeServiceCountYearChart(services, value); - - // - return result; - } - - /** - * Htmlize service date status chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceDateStatusChart(final Services services) throws StatoolInfosException - { - String result; - - PieChart pie = new PieChart("Services avec ou sans date"); - - long filled = 0; - long unfilled = 0; - for (Service service : services) - { - if (service.getStartDate() == null) - { - unfilled += 1; - } - else - { - filled += 1; - } - } - - pie.add("Avec", filled, ChartColor.VIOLET); - pie.add("Sans", unfilled, ChartColor.BLUE); - - pie.setLegendPosition(Position.RIGHT); - - result = PieChartView.build(pie); - - // - return result; - } - - /** - * Htmlize service install type chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeServiceInstallTypeChart(final Services services) throws StatoolInfosException - { - String result; - - ServiceInstallTypeStats stats = StatAgent.statServiceInstallType(services); - - PieChart pie = new PieChart("Types d'installation du service"); - pie.add("Distribution", stats.getDistributionCount(), ChartColor.GREEN0); - pie.add("Fournisseur", stats.getProviderCount(), ChartColor.GREEN); - pie.add("Paquet", stats.getPackageCount(), ChartColor.YELLOW); - pie.add("Outillage", stats.getToolingCount(), ChartColor.ORANGE); - pie.add("Dépôt cloné", stats.getClonerepoCount(), ChartColor.RED); - pie.add("Archive", stats.getArchiveCount(), ChartColor.VIOLET); - pie.add("Sources", stats.getSourcesCount(), ChartColor.PURPLE); - pie.add("Containeur", stats.getContainerCount(), ChartColor.TURQUOISE); - pie.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE); - pie.setLegendPosition(Position.RIGHT); - - result = DoughnutChartView.build(pie); - - // - return result; - } - - /** - * Htmlize software distribution chart. - * - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeSoftwareDistributionChart() throws StatoolInfosException - { - String result; - - BarChart chart = new BarChart("Distribution des logiciels proposés par au moins deux services"); - chart.addDataset("Logiciel"); - - Federation federation = HtmlizerContext.instance().getFederation(); - Categories categories = HtmlizerContext.instance().getCategories(); - - SoftwareStats stats = StatAgent.statAllSoftwares(federation, categories); - stats.sortByServiceCount().reverse(); - - for (SoftwareStat stat : stats) - { - if (stat.getServiceCount() > 1) - { - chart.add(stat.getName(), stat.getServiceCount(), ChartColor.PURPLE); - } - } - - result = BarChartView.build(chart); - - // - return result; - } - - /** - * Htmlize software used chart. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlizeSoftwareDistributionPieChart(final Services services) throws StatoolInfosException - { - String result; - - Federation federation = HtmlizerContext.instance().getFederation(); - Categories categories = HtmlizerContext.instance().getCategories(); - - SoftwareStats stats = StatAgent.statAllSoftwares(federation, categories); - stats.sortByServiceCount().reverse(); - - ChartColors colors = ChartColor.valueList(); - colors.remove(ChartColor.BLUE); - - PieChart pie = new PieChart("Répartition des services par logiciel"); - int index = 0; - while ((index < stats.size() && (index < 10))) - { - ChartColor color = colors.get(index); - SoftwareStat stat = stats.get(index); - pie.add(stat.getName(), stat.getServiceCount(), color); - - index += 1; - } - - int others = 0; - while (index < stats.size()) - { - SoftwareStat stat = stats.get(index); - others += stat.getServiceCount(); - - index += 1; - } - pie.add("Autres", others, ChartColor.BLUE); - pie.setLegendPosition(Position.RIGHT); - - result = DoughnutChartView.build(pie); - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/CrawlJournalView.java b/src/fr/devinsy/statoolinfos/htmlize/CrawlJournalView.java deleted file mode 100644 index ef917f2..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/CrawlJournalView.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.time.format.DateTimeFormatter; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.crawl.CrawlJournal; -import fr.devinsy.statoolinfos.crawl.CrawlLog; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class CrawlJournalPage. - */ -public class CrawlJournalView -{ - private static Logger logger = LoggerFactory.getLogger(CrawlJournalView.class); - - /** - * Htmlize. - * - * @param journal - * the journal - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final CrawlJournal journal) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setEscapedContent("title", "Journal des téléchargements"); - data.setContent("date", journal.getDatetime().format(DateTimeFormatter.ofPattern("dd/MM/YYYY HH:mm"))); - data.setContent("totalCount", journal.size()); - data.setContent("errorCount", journal.getErrors().size()); - - int index = 0; - for (CrawlLog log : journal) - { - data.setEscapedContent("crawlLogLine", index, "crawlLogLineParentUrlLink", StringUtils.abbreviate(log.getParentUrlValue(), 35)); - data.setEscapedAttribute("crawlLogLine", index, "crawlLogLineParentUrlLink", "href", StringUtils.defaultString(log.getParentUrlValue(), "#")); - data.setEscapedAttribute("crawlLogLine", index, "crawlLogLineParentUrlLink", "title", StringUtils.defaultString(log.getParentUrlValue(), "#")); - - data.setEscapedContent("crawlLogLine", index, "crawlLogLineUrlLink", log.getUrl().toString()); - data.setEscapedAttribute("crawlLogLine", index, "crawlLogLineUrlLink", "href", log.getUrl().toString()); - - data.setContent("crawlLogLine", index, "crawlLogLineStatus", log.getStatus().toString()); - - if (log.getStatus().isError()) - { - data.setAttribute("crawlLogLine", index, "crawlLogLineStatus", "style", "background-color: red;"); - } - else - { - data.setAttribute("crawlLogLine", index, "crawlLogLineStatus", "style", "background-color: lime;"); - } - - index += 1; - } - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/crawlJournalView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building crawl journal page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/EditoPage.java b/src/fr/devinsy/statoolinfos/htmlize/EditoPage.java deleted file mode 100644 index a3b4bf7..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/EditoPage.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2020 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Configuration; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class EditoPage. - */ -public class EditoPage -{ - private static Logger logger = LoggerFactory.getLogger(EditoPage.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 - { - logger.info("Htmlize edito page."); - - Configuration configuration = HtmlizerContext.instance().getConfiguration(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - String edito; - File editoDirectory = configuration.getEditoDirectory(); - if ((editoDirectory != null) && (editoDirectory.exists())) - { - File editoFile = new File(editoDirectory, "edito.xhtml"); - - if (editoFile.exists()) - { - logger.info("EDITO: found data."); - // Copy files. - FileUtils.copyDirectory(editoDirectory, htmlizeDirectory); - - // Load body edito xhtml file. - edito = FileUtils.readFileToString(editoFile, StandardCharsets.UTF_8); - edito = XidynUtils.extractBodyContent(edito); - } - else - { - logger.info("EDITO: not found data."); - edito = null; - } - } - else - { - logger.info("EDITO: not found configuration."); - edito = null; - } - - String page = htmlize(edito); - FileUtils.write(new File(htmlizeDirectory, "edito.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final String edito) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building edito page {}."); - - TagDataManager data = new TagDataManager(); - - if (edito != null) - { - data.setContent("edito", edito); - } - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/edito.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Édito", "edito.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building edito page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ExportsPage.java b/src/fr/devinsy/statoolinfos/htmlize/ExportsPage.java deleted file mode 100644 index aa4bc0f..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ExportsPage.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.io.CSVFile; -import fr.devinsy.statoolinfos.io.JSONFile; -import fr.devinsy.statoolinfos.io.ODSFile; -import fr.devinsy.statoolinfos.uptime.ServiceUptimes; -import fr.devinsy.statoolinfos.uptime.ServiceUptimesFile; -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. - */ - public static void build() - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - // - try - { - logger.info("EXPORTS CSV."); - CSVFile.save(new File(htmlizeDirectory, "organizations.csv"), federation.getOrganizations()); - CSVFile.save(new File(htmlizeDirectory, "services.csv"), federation.getServicesAll()); - } - catch (IOException exception) - { - logger.error("Error during CSV export: " + exception.getMessage(), exception); - } - - // - try - { - logger.info("EXPORTS JSON."); - JSONFile.save(new File(htmlizeDirectory, "federation.json"), federation); - JSONFile.save(new File(htmlizeDirectory, "organizations.json"), federation.getOrganizations()); - JSONFile.save(new File(htmlizeDirectory, "services.json"), federation.getServicesAll()); - } - catch (IOException exception) - { - logger.error("Error during JSON export: " + exception.getMessage(), exception); - } - - // - try - { - logger.info("EXPORTS ODS."); - ODSFile.save(new File(htmlizeDirectory, "organizations.ods"), federation.getOrganizations()); - ODSFile.save(new File(htmlizeDirectory, "services.ods"), federation.getServicesAll()); - } - catch (Exception exception) - { - logger.error("Error during ODS export: " + exception.getMessage(), exception); - } - - // - try - { - logger.info("EXPORTS SERVICE UPTIME JOURNAL."); - ServiceUptimes uptimes = ServiceUptimes.of(federation.getServicesAll(), HtmlizerContext.instance().getUptimeJournal()); - ServiceUptimesFile.saveCSV(new File(htmlizeDirectory, "serviceUptimeJournal.csv"), uptimes); - ServiceUptimesFile.saveODS(new File(htmlizeDirectory, "serviceUptimeJournal.ods"), uptimes); - } - catch (Exception exception) - { - logger.error("Error during Uptime export: " + exception.getMessage(), exception); - } - - // - try - { - String page = htmlize(); - FileUtils.write(new File(htmlizeDirectory, "exports.xhtml"), page, StandardCharsets.UTF_8); - } - catch (StatoolInfosException | IOException exception) - { - logger.error("Error building export page: " + exception.getMessage(), exception); - } - } - - /** - * 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/FederationCrawlJournalPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationCrawlJournalPage.java deleted file mode 100644 index 2e1121f..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationCrawlJournalPage.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class CrawlJournalFederationPage. - */ -public class FederationCrawlJournalPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationCrawlJournalPage.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 - { - try - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", FederationHeaderView.htmlize(federation)); - data.setContent("contentView", CrawlJournalView.htmlize(federation.getCrawlJournal())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - String page = WebCharterView.build(content, trail); - FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-crawl.xhtml"), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation crawl journal page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java deleted file mode 100644 index 8bef194..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2020-2023 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 org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.checker.PropertyChecks; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.DisplayMode; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class FederationHeaderView. - */ -public class FederationHeaderView -{ - private static Logger logger = LoggerFactory.getLogger(FederationHeaderView.class); - - /** - * Htmlize. - * - * @param federation - * the federation - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Federation federation) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setAttribute("federationRawButton", "href", federation.getTechnicalName() + ".properties"); - data.setAttribute("federationLogo", "src", federation.getLogoFileName()); - data.setEscapedContent("federationName", federation.getName()); - data.setEscapedContent("federationDescription", federation.getDescription()); - - if (federation.getWebsiteURL() != null) - { - data.setEscapedContent("federationURL", federation.getWebsiteURL().toString()); - data.setEscapedAttribute("federationURL", "href", federation.getWebsiteURL().toString()); - } - data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDateValue(), "n/a")); - - data.setAttribute("organizationsLink", "href", federation.getTechnicalName() + "-organizations.xhtml"); - data.setAttribute("servicesLink", "href", federation.getTechnicalName() + "-services.xhtml"); - data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties"); - data.setAttribute("propertyCheckLink", "href", federation.getTechnicalName() + "-propertycheck.xhtml"); - data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml"); - data.setAttribute("metricsLink", "href", federation.getTechnicalName() + "-metrics-summary-months-last.xhtml"); - data.setAttribute("figuresLink", "href", federation.getTechnicalName() + "-services-figures.xhtml"); - - data.setAttribute("crawlLink", "href", federation.getTechnicalName() + "-crawl.xhtml"); - data.setAttribute("uptimeLink", "href", federation.getLocalFileBaseName() + "-uptimes.xhtml"); - - if (HtmlizerContext.instance().getUptimeJournal().hasRecentError(federation.getActiveServices())) - { - data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ko-mono.svg"); - } - else - { - data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ok-mono.svg"); - } - - if (federation.getCrawlJournal().getErrors().isEmpty()) - { - data.setAttribute("crawlLinkImg", "src", "circle-icons/download-mono.svg"); - } - else - { - data.setAttribute("crawlLinkImg", "src", "circle-icons/download.svg"); - } - - { - PropertyChecks checks = federation.getInputChecksAll(); - - data.setContent("errorCount", checks.getErrorCount()); - data.setContent("warningCount", checks.getWarningCount()); - data.setContent("voidCount", checks.getVoidCount()); - - data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-propertyalerts.xhtml"); - } - - if (federation.getLegalURL() != null) - { - data.setEscapedAttribute("legalLink", "href", federation.getLegalURL().toString()); - data.setAttribute("legalLinkImg", "class", ""); - data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (federation.getContactURL() != null) - { - data.setEscapedAttribute("contactLink", "href", federation.getContactURL().toString()); - data.setAttribute("contactLinkImg", "class", ""); - data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (StringUtils.isNotBlank(federation.getContactEmail())) - { - data.setEscapedAttribute("emailLink", "href", "mailto:" + federation.getContactEmail()); - data.setAttribute("emailLinkImg", "class", ""); - data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (federation.getUserGuideURL() != null) - { - data.setEscapedAttribute("userDocLink", "href", federation.getUserGuideURL().toString()); - data.setAttribute("userDocLinkImg", "class", ""); - data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (federation.getTechnicalGuideURL() != null) - { - data.setEscapedAttribute("technicalDocLink", "href", federation.getTechnicalGuideURL().toString()); - data.setAttribute("technicalDocLinkImg", "class", ""); - data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml", data).toString(); - - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation header view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java deleted file mode 100644 index 61e0afa..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationMetricsPage. - */ -public class FederationMetricGenericPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationMetricGenericPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param federation - * the federation - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", FederationHeaderView.htmlize(federation)); - data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.GENERIC, view, period)); - - // - FederationMetricHtmlizer.htmlize(data, "graphic.users", federation, view, period, "metrics.service.users", ChartColor.GREEN); - - FederationMetricHtmlizer.htmlize(data, "graphic.users.ipv4-ipv6", federation, view, period, "service.users (ipv4 + ipv6)", "metrics.service.users.ipv4", ChartColor.YELLOW, - "metrics.service.users.ipv6", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "graphic.users.ipv4", federation, view, period, "metrics.service.users.ipv4", ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "graphic.users.ipv6", federation, view, period, "metrics.service.users.ipv6", ChartColor.GREEN); - - FederationMetricHtmlizer.htmlize(data, "graphic.accounts", federation, view, period, "metrics.service.accounts", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "graphic.accounts.active", federation, view, period, "metrics.service.accounts.active", ChartColor.GREEN); - - FederationMetricHtmlizer.htmlize(data, "graphic.database.bytes", federation, view, period, "metrics.service.database.bytes", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", federation, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString(); - - // - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Metrics génériques"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-generic-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricHtmlizer.java deleted file mode 100644 index f243d43..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricHtmlizer.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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.time.YearMonth; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.threeten.extra.YearWeek; - -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.statoolinfos.properties.MonthValues; -import fr.devinsy.statoolinfos.properties.WeekValues; -import fr.devinsy.statoolinfos.properties.YearValues; -import fr.devinsy.xidyn.data.TagDataManager; - -/** - * The Class MetricHtmlizeDataUtils. - */ -public class FederationMetricHtmlizer -{ - private static Logger logger = LoggerFactory.getLogger(FederationMetricHtmlizer.class); - - /** - * Htmlize data. - * - * @param data - * the data - * @param metricId - * the metric id - * @param federation - * the federation - * @param view - * the view - * @param period - * the period - * @param metricPath - * the metric path - * @param color - * the color - * @throws StatoolInfosException - * the statool infos exception - */ - public static void htmlize(final TagDataManager data, final String metricId, final Federation federation, final ViewMenu view, final PeriodMenu period, final String metricPath, - final ChartColor color) throws StatoolInfosException - { - if (view == ViewMenu.YEARS) - { - YearValues yearMetric = federation.getMetricYearValuesAll(metricPath); - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color)); - } - } - else if (view == ViewMenu.MONTHS) - { - MonthValues monthMetric = federation.getMetricMonthValuesAll(metricPath); - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(year, 01), YearMonth.of(year, 12), monthMetric, color)); - } - } - else if (view == ViewMenu.WEEKS) - { - WeekValues weekMetric = federation.getMetricWeekValuesAll(metricPath); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(year, 01), YearWeek.of(year, 53), weekMetric, color)); - } - } - } - - /** - * Htmlize. - * - * @param data - * the data - * @param metricId - * the metric id - * @param federation - * the federation - * @param view - * the view - * @param period - * the period - * @param metricLabel - * the metric label - * @param metricPath1 - * the metric path 1 - * @param color1 - * the color 1 - * @param metricPath2 - * the metric path 2 - * @param color2 - * the color 2 - * @throws StatoolInfosException - * the statool infos exception - */ - public static void htmlize(final TagDataManager data, final String metricId, final Federation federation, final ViewMenu view, final PeriodMenu period, final String metricLabel, - final String metricPath1, final ChartColor color1, final String metricPath2, final ChartColor color2) throws StatoolInfosException - { - if (view == ViewMenu.YEARS) - { - YearValues yearMetric1 = federation.getMetricYearValuesAll(metricPath1); - YearValues yearMetric2 = federation.getMetricYearValuesAll(metricPath2); - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2)); - } - } - else if (view == ViewMenu.MONTHS) - { - // - MonthValues monthMetric1 = federation.getMetricMonthValuesAll(metricPath1); - MonthValues monthMetric2 = federation.getMetricMonthValuesAll(metricPath2); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, - ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, - ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(year, 01), YearMonth.of(year, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); - } - } - else if (view == ViewMenu.WEEKS) - { - WeekValues weekMetric1 = federation.getMetricWeekValuesAll(metricPath1); - WeekValues weekMetric2 = federation.getMetricWeekValuesAll(metricPath2); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(year, 01), YearWeek.of(year, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); - } - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricMenuView.java deleted file mode 100644 index 46dc6c2..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricMenuView.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (C) 2021-2023 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.util.ArrayList; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class OrganizationMetricMenuView. - */ -public class FederationMetricMenuView -{ - private static Logger logger = LoggerFactory.getLogger(FederationMetricMenuView.class); - - public enum PeriodMenu - { - FULL, - LAST, - Y2021, - Y2022; - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - String result; - - if (this.name().startsWith("Y")) - { - result = this.name().substring(1); - } - else - { - result = this.name().toLowerCase(); - } - - // - return result; - } - - /** - * Gets the years. - * - * @return the years - */ - public static PeriodMenu[] getYears() - { - PeriodMenu[] result; - - ArrayList list = new ArrayList(); - for (PeriodMenu item : values()) - { - if (item.name().startsWith("Y")) - { - list.add(item); - } - } - - result = list.toArray(new PeriodMenu[0]); - - // - return result; - } - } - - public enum TypeMenu - { - SUMMARY, - WEB, - GENERIC, - SPECIFIC; - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - String result; - - result = this.name().toLowerCase(); - - // - return result; - } - } - - public enum ViewMenu - { - YEARS, - MONTHS, - WEEKS, - DAYS; - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - String result; - - result = this.name().toLowerCase(); - - // - return result; - } - } - - /** - * Htmlize. - * - * @param federation - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Federation federation, final TypeMenu type, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - // - String filename = String.format("%s-metrics-summary-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("summaryTypeButton", "href", filename); - - filename = String.format("%s-metrics-generic-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("genericTypeButton", "href", filename); - - filename = String.format("%s-metrics-specific-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("specificTypeButton", "href", filename); - - filename = String.format("%s-metrics-web-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("webTypeButton", "href", filename); - - // - filename = String.format("%s-metrics-%s-years-%s.xhtml", federation.getLocalFileBaseName(), type.getName(), PeriodMenu.FULL.getName()); - data.setAttribute("yearsViewButton", "href", filename); - - filename = String.format("%s-metrics-%s-months-%s.xhtml", federation.getLocalFileBaseName(), type.getName(), period.getName()); - data.setAttribute("monthsViewButton", "href", filename); - - filename = String.format("%s-metrics-%s-weeks-%s.xhtml", federation.getLocalFileBaseName(), type.getName(), period.getName()); - data.setAttribute("weeksViewButton", "href", filename); - - data.setAttribute("daysViewButton", "href", "#"); - - // - filename = String.format("%s-metrics-%s-%s-full.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("fullPeriodButton", "href", filename); - - if (view != ViewMenu.YEARS) - { - filename = String.format("%s-metrics-%s-%s-last.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("lastPeriodButton", "href", filename); - - filename = String.format("%s-metrics-%s-%s-2021.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("2021PeriodButton", "href", filename); - - filename = String.format("%s-metrics-%s-%s-2022.xhtml", federation.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("2022PeriodButton", "href", filename); - } - - // - if ((type == null) || (type == TypeMenu.SUMMARY)) - { - data.appendAttribute("summaryTypeButton", "class", "button selected"); - } - else if (type == TypeMenu.GENERIC) - { - data.appendAttribute("genericTypeButton", "class", "button selected"); - } - else if (type == TypeMenu.WEB) - { - data.appendAttribute("webTypeButton", "class", "button selected"); - } - else if (type == TypeMenu.SPECIFIC) - { - data.appendAttribute("specificTypeButton", "class", "button selected"); - } - - // - if ((view == null) || (view == ViewMenu.YEARS)) - { - data.appendAttribute("yearsViewButton", "class", "button selected"); - } - else if (view == ViewMenu.MONTHS) - { - data.appendAttribute("monthsViewButton", "class", "button selected"); - } - else if (view == ViewMenu.WEEKS) - { - data.appendAttribute("weeksViewButton", "class", "button selected"); - } - else if (view == ViewMenu.DAYS) - { - data.appendAttribute("daysViewButton", "class", "button selected"); - } - - // - if ((period == null) || (period == PeriodMenu.FULL)) - { - data.appendAttribute("fullPeriodButton", "class", "button selected"); - } - else if (period == PeriodMenu.LAST) - { - data.appendAttribute("lastPeriodButton", "class", "button selected"); - } - else if (period == PeriodMenu.Y2021) - { - data.appendAttribute("2021PeriodButton", "class", "button selected"); - } - else if (period == PeriodMenu.Y2022) - { - data.appendAttribute("2022PeriodButton", "class", "button selected"); - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building metric menu view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSpecificPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSpecificPage.java deleted file mode 100644 index 7dd13d1..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSpecificPage.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationMetricsPage. - */ -public class FederationMetricSpecificPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationMetricSpecificPage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", FederationHeaderView.htmlize(federation)); - data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.SPECIFIC, view, period)); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString(); - - // - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Metrics spécifiques"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-specific-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSummaryPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSummaryPage.java deleted file mode 100644 index 93e83c7..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSummaryPage.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationMetricsPage. - */ -public class FederationMetricSummaryPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationMetricSummaryPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param federation - * the federation - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", FederationHeaderView.htmlize(federation)); - data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.SUMMARY, view, period)); - - FederationMetricHtmlizer.htmlize(data, "http.hits.humans", federation, view, period, "metrics.http.hits.humans", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.visitors", federation, view, period, "metrics.http.visitors", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.visits", federation, view, period, "metrics.http.visits", ChartColor.GREEN); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Metrics résumé"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-summary-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricWebPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricWebPage.java deleted file mode 100644 index 6a1af52..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricWebPage.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationMetricWebPage. - */ -public class FederationMetricWebPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationMetricWebPage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", FederationHeaderView.htmlize(federation)); - data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.WEB, view, period)); - - // - FederationMetricHtmlizer.htmlize(data, "http.hits", federation, view, period, "metrics.http.hits", ChartColor.BLUE); - - FederationMetricHtmlizer.htmlize(data, "http.hits-ipv4ipv6", federation, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6", - ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.hits.ipv4", federation, view, period, "metrics.http.hits.ipv4", ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "http.hits.ipv6", federation, view, period, "metrics.http.hits.ipv6", ChartColor.GREEN); - - FederationMetricHtmlizer.htmlize(data, "http.hits-humansbots", federation, view, period, "http.hits (humans + bots)", "metrics.http.hits.humans", ChartColor.GREEN, - "metrics.http.hits.bots", - ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "http.hits.humans", federation, view, period, "metrics.http.hits.humans", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.hits.bots", federation, view, period, "metrics.http.hits.bots", ChartColor.YELLOW); - - FederationMetricHtmlizer.htmlize(data, "http.hits.humans-ipv4ipv6", federation, view, period, "http.hits.humans (ipv4 + ipv6)", "metrics.http.hits.humans.ipv4", ChartColor.YELLOW, - "metrics.http.hits.humans.ipv6", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv4", federation, view, period, "metrics.http.hits.humans.ipv4", ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv6", federation, view, period, "metrics.http.hits.humans.ipv6", ChartColor.GREEN); - - FederationMetricHtmlizer.htmlize(data, "http.errors", federation, view, period, "metrics.http.errors", ChartColor.RED); - FederationMetricHtmlizer.htmlize(data, "http.errors.php", federation, view, period, "metrics.http.errors.php", ChartColor.RED); - - FederationMetricHtmlizer.htmlize(data, "http.files", federation, view, period, "metrics.http.files", ChartColor.BLUE); - FederationMetricHtmlizer.htmlize(data, "http.pages", federation, view, period, "metrics.http.pages", ChartColor.BLUE); - FederationMetricHtmlizer.htmlize(data, "http.bytes", federation, view, period, "metrics.http.bytes", ChartColor.BLUE); - - FederationMetricHtmlizer.htmlize(data, "http.ip", federation, view, period, "metrics.http.ip", ChartColor.BLUE); - - FederationMetricHtmlizer.htmlize(data, "http.ip-humansbots", federation, view, period, "http.ip (humans + bots)", "metrics.http.ip.humans", ChartColor.GREEN, "metrics.http.ip.bots", - ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "http.ip.humans", federation, view, period, "metrics.http.ip.humans", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.ip.bots", federation, view, period, "metrics.http.ip.bots", ChartColor.YELLOW); - - FederationMetricHtmlizer.htmlize(data, "http.ip-ipv4ipv6", federation, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6", - ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.ip.ipv4", federation, view, period, "metrics.http.ip.ipv4", ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "http.ip.ipv6", federation, view, period, "metrics.http.ip.ipv6", ChartColor.GREEN); - - FederationMetricHtmlizer.htmlize(data, "http.requesters", federation, view, period, "metrics.http.requesters", ChartColor.BLUE); - - FederationMetricHtmlizer.htmlize(data, "http.requesters-humansbots", federation, view, period, "http.requesters (humans + bots)", "metrics.http.requesters.humans", ChartColor.GREEN, - "metrics.http.requesters.bots", ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "http.requesters.humans", federation, view, period, "metrics.http.requesters.humans", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.requesters.bots", federation, view, period, "metrics.http.requesters.bots", ChartColor.YELLOW); - - FederationMetricHtmlizer.htmlize(data, "http.requesters-ipv4ipv6", federation, view, period, "http.requesters (ipv4 + ipv6)", "metrics.http.requesters.ipv4", ChartColor.YELLOW, - "metrics.http.requesters.ipv6", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.requesters.ipv4", federation, view, period, "metrics.http.requesters.ipv4", ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "http.requesters.ipv6", federation, view, period, "metrics.http.requesters.ipv6", ChartColor.GREEN); - - FederationMetricHtmlizer.htmlize(data, "http.visitors", federation, view, period, "metrics.http.visitors", ChartColor.BLUE); - FederationMetricHtmlizer.htmlize(data, "http.visitors-ipv4ipv6", federation, view, period, "http.visitors (ipv4 + ipv6)", "metrics.http.visitors.ipv4", ChartColor.YELLOW, - "metrics.http.visitors.ipv6", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.visitors.ipv4", federation, view, period, "metrics.http.visitors.ipv4", ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "http.visitors.ipv6", federation, view, period, "metrics.http.visitors.ipv6", ChartColor.GREEN); - - FederationMetricHtmlizer.htmlize(data, "http.visits", federation, view, period, "metrics.http.visits", ChartColor.BLUE); - FederationMetricHtmlizer.htmlize(data, "http.visits-ipv4ipv6", federation, view, period, "http.visits (ipv4 + ipv6)", "metrics.http.visits.ipv4", ChartColor.YELLOW, - "metrics.http.visits.ipv6", ChartColor.GREEN); - FederationMetricHtmlizer.htmlize(data, "http.visits.ipv4", federation, view, period, "metrics.http.visits.ipv4", ChartColor.YELLOW); - FederationMetricHtmlizer.htmlize(data, "http.visits.ipv6", federation, view, period, "metrics.http.visits.ipv6", ChartColor.GREEN); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString(); - - // - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Metrics web"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-web-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationOrganizationsPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationOrganizationsPage.java deleted file mode 100644 index cb0b0bb..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationOrganizationsPage.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2020-2022 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationOrganizationsPage. - */ -public class FederationOrganizationsPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationOrganizationsPage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - */ - public static void build() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - // - logger.info("PAGE FEDERATION organizations page: {}.", federation.getName()); - String page = htmlize(federation); - - FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-organizations.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param federation - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - */ - public static String htmlize(final Federation federation) throws StatoolInfosException, IOException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation)); - - data.setContent("organizationListView", OrganizationListView.htmlize(federation.getMemberOrganizations(), federation.getAwayOrganizations())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationOrganizations.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation organizations page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPages.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPages.java deleted file mode 100644 index 1009d8c..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPages.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.catgenerator.core.CatGenerator; -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.crawl.CrawlCache; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu; - -/** - * The Class FederationPage. - */ -public class FederationPages -{ - private static Logger logger = LoggerFactory.getLogger(FederationPages.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - */ - public static void build() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - CrawlCache cache = HtmlizerContext.instance().getCache(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - // - logger.info("PAGE FEDERATION Htmlize federation logo."); - htmlizeFederationLogo(federation, cache, htmlizeDirectory); - - // - logger.info("PAGE FEDERATION Htmlize federation properties files."); - FileUtils.copyFile(federation.getInputFile(), new File(htmlizeDirectory, federation.getTechnicalName() + ".properties")); - - logger.info("PAGE FEDERATION federation page: {}.", federation.getName()); - String page = FederationOrganizationsPage.htmlize(federation); - FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8); - - // - FederationOrganizationsPage.build(); - FederationServicesPage.build(); - FederationServicesFiguresPage.build(); - FederationCrawlJournalPage.build(); - FederationPropertyCheckPage.build(); - FederationPropertyAlertPage.buildAll(); - FederationStatsPage.build(); - FederationUptimePage.build(); - - // - logger.info("Htmlize federation metric pages: {}.", federation.getName()); - for (ViewMenu view : ViewMenu.values()) - { - for (PeriodMenu period : PeriodMenu.values()) - { - if ((view != ViewMenu.YEARS) || (period == PeriodMenu.FULL)) - { - if (view != ViewMenu.DAYS) - { - FederationMetricSummaryPage.build(htmlizeDirectory, federation, view, period); - FederationMetricGenericPage.build(htmlizeDirectory, federation, view, period); - FederationMetricSpecificPage.build(htmlizeDirectory, federation, view, period); - FederationMetricWebPage.build(htmlizeDirectory, federation, view, period); - } - } - } - } - } - - /** - * Htmlize federation logo. - * - * @param federation - * the federation - * @param cache - * the cache - * @param htmlizeDirectory - * the htmlize directory - * @throws IOException - * Signals that an I/O exception has occurred. - */ - private static void htmlizeFederationLogo(final Federation federation, final CrawlCache cache, final File htmlizeDirectory) throws IOException - { - logger.info("Htmlize federation logo."); - - File target = new File(htmlizeDirectory, federation.getLogoFileName()); - - File logoFile = cache.restoreFile(federation.getLogoURL()); - if (logoFile == null) - { - logger.info("CatGeneratoring cat avatar: {}", target.getAbsoluteFile()); - CatGenerator.buildAvatarTo(federation.getTechnicalName(), target); - } - else - { - FileUtils.copyFile(logoFile, target); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyAlertPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyAlertPage.java deleted file mode 100644 index b791578..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyAlertPage.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.checker.PropertyChecks; -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.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationPropertyCheckAlertPage. - */ -public class FederationPropertyAlertPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationPropertyAlertPage.class); - - public enum PropertyAlertScope - { - ALL, - FEDERATION, - ORGANIZATIONS, - SERVICES, - METRICS - } - - /** - * Builds the all. - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws StatoolInfosException - * the statool infos exception - */ - public static void buildAll() throws IOException, StatoolInfosException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - String page = htmlize(PropertyAlertScope.ALL); - FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8); - - page = htmlize(PropertyAlertScope.FEDERATION); - FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-propertyalerts-federation.xhtml"), page, StandardCharsets.UTF_8); - - page = htmlize(PropertyAlertScope.ORGANIZATIONS); - FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-propertyalerts-organizations.xhtml"), page, StandardCharsets.UTF_8); - - page = htmlize(PropertyAlertScope.SERVICES); - FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-propertyalerts-services.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Htmlize. - * - * @param scope - * the scope - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final PropertyAlertScope scope) throws StatoolInfosException - { - String result; - - try - { - Federation federation = HtmlizerContext.instance().getFederation(); - - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", FederationHeaderView.htmlize(federation)); - // TODO submenu - data.setAttribute("allButton", "href", federation.getLocalFileBaseName() + "-propertyalerts.xhtml"); - data.setAttribute("federationButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-federation.xhtml"); - data.setAttribute("organizationButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-organizations.xhtml"); - data.setAttribute("serviceButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-services.xhtml"); - data.setAttribute("metricsButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-metrics.xhtml"); - - PropertyChecks checks; - if (scope == PropertyAlertScope.ALL) - { - checks = federation.getInputChecksAll().getAlertLines(); - } - else if (scope == PropertyAlertScope.FEDERATION) - { - checks = federation.getInputChecks().getAlertLines(); - } - else if (scope == PropertyAlertScope.ORGANIZATIONS) - { - checks = new PropertyChecks(); - for (Organization organization : federation.getOrganizations()) - { - checks.addAll(organization.getInputChecks().getAlertLines()); - } - } - else if (scope == PropertyAlertScope.SERVICES) - { - checks = new PropertyChecks(); - for (Service service : federation.getServicesAll()) - { - checks.addAll(service.getInputChecksAll().getAlertLines()); - } - } - else - { - checks = new PropertyChecks(); - } - data.setContent("contentView", PropertyAlertView.htmlize(checks)); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Propriétés en alertes", federation.getLocalFileBaseName() + "-propertyalerts.xhtml"); - - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation property file check alert page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyCheckPage.java deleted file mode 100644 index d458a26..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyCheckPage.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class PropertyFileCheckPage. - */ -public class FederationPropertyCheckPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationPropertyCheckPage.class); - - /** - * Builds the. - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws StatoolInfosException - * the statool infos exception - */ - public static void build() throws IOException, StatoolInfosException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - String page = htmlize(federation); - FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Htmlize. - * - * @param federation - * the federation - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Federation federation) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", FederationHeaderView.htmlize(federation)); - data.setContent("contentView", PropertyCheckView.htmlize(federation.getInputChecks())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Propriétés", federation.getLocalFileBaseName() + "-propertycheck.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation property file check page: " + exception.getMessage(), exception); - } - - // - return result; - } - -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationServicesFiguresPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationServicesFiguresPage.java deleted file mode 100644 index da322f2..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationServicesFiguresPage.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2022 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationServicesFiguresPage. - */ -public class FederationServicesFiguresPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationServicesFiguresPage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - */ - public static void build() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - // - logger.info("PAGE FEDERATION services figures page: {}.", federation.getName()); - String page = htmlize(federation); - - FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-services-figures.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param federation - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - */ - public static String htmlize(final Federation federation) throws StatoolInfosException, IOException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation)); - data.setContent("serviceListView", ServiceFigureView.htmlize(federation.getServices())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation services figures page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationServicesPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationServicesPage.java deleted file mode 100644 index f406ee4..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationServicesPage.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationServicesPage. - */ -public class FederationServicesPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationServicesPage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - */ - public static void build() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - // - logger.info("PAGE FEDERATION services page: {}.", federation.getName()); - String page = htmlize(federation); - - FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-services.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param federation - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - */ - public static String htmlize(final Federation federation) throws StatoolInfosException, IOException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation)); - data.setContent("serviceListView", ServiceListView.htmlize(federation.getServices())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation services page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java deleted file mode 100644 index 9ac717b..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2020-2022 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Organizations; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.stats.StatAgent; -import fr.devinsy.statoolinfos.stats.services.RegistrationStats; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationStatsPage. - */ -public class FederationStatsPage -{ - private static Logger logger = LoggerFactory.getLogger(FederationStatsPage.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 - { - try - { - logger.debug("Building federation stats page {}…"); - - Federation federation = HtmlizerContext.instance().getFederation(); - // CrawlCache cache = HtmlizerContext.instance().getCache(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - Organizations organizations = federation.getActiveOrganizations(); - Services services = federation.getActiveServices(); - - TagDataManager data = new TagDataManager(); - - data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation)); - - data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organizations)); - data.setContent("organizationCountryChart", ChartHtmlizer.htmlizeOrganizationCountryChart(organizations)); - data.setContent("organizationCountChart", ChartHtmlizer.htmlizeOrganizationCountChart(federation)); - data.setContent("organizationInOutChart", ChartHtmlizer.htmlizeOrganizationInOutChart(federation)); - - data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(federation)); - data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services)); - data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services)); - data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services)); - - data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services)); - data.setContent("hostProviderHypervisorChart", ChartHtmlizer.htmlizeHostProviderHypervisorChart(services)); - - data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services)); - data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services)); - - { - RegistrationStats stats = StatAgent.statRegistrationTypes(services); - - data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats)); - data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats)); - data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats)); - data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats)); - data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats)); - } - - data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services)); - data.setContent("organisationTypeChart", ChartHtmlizer.htmlizeOrganizationTypeChart(organizations)); - - data.setContent("softwareDistributionPieChart", ChartHtmlizer.htmlizeSoftwareDistributionPieChart(services)); - data.setContent("categoryDistributionPieChart", ChartHtmlizer.htmlizeCatergoryDistributionPieChart(services)); - - data.setContent("softwareDistributionChart", ChartHtmlizer.htmlizeSoftwareDistributionChart()); - - data.setContent("categoryDistributionChart", ChartHtmlizer.htmlizeCategoryDistributionChart()); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml", data).toString(); - - // - BreadcrumbTrail trail = new BreadcrumbTrail(); - String page = WebCharterView.build(content, trail); - - FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-stats.xhtml"), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building federation stats page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationUptimePage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationUptimePage.java deleted file mode 100644 index b6eca45..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationUptimePage.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2021-2022 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.uptime.UptimeJournal; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class FederationUptimePage. - */ -public class FederationUptimePage -{ - private static Logger logger = LoggerFactory.getLogger(FederationUptimePage.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 - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - UptimeJournal journal = HtmlizerContext.instance().getUptimeJournal(); - - String page = htmlize(federation, journal); - FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-uptimes.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Htmlize. - * - * @param federation - * the federation - * @param journal - * the journal - * @return the string - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static String htmlize(final Federation federation, final UptimeJournal journal) throws StatoolInfosException, IOException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", FederationHeaderView.htmlize(federation)); - data.setContent("uptimeView", UptimeView.htmlize(federation.getActiveServices(), journal)); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimePage.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Disponibilité des services", federation.getLocalFileBaseName() + "-uptimes.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building FederationUptime page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java deleted file mode 100644 index 8143eb3..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (C) 2020-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 org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Category; -import fr.devinsy.statoolinfos.core.Configuration; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.core.StatoolInfosUtils; -import fr.devinsy.statoolinfos.util.URLUtils; - -/** - * The Class Htmlizer. - */ -public class Htmlizer -{ - private static Logger logger = LoggerFactory.getLogger(Htmlizer.class); - - /** - * Instantiates a new htmlizer. - */ - private Htmlizer() - { - } - - /** - * Clear. - * - * @param configuration - * the configuration - */ - public static void clear(final Configuration configuration) - { - logger.info("Htmlize directory setting: {}", configuration.getHtmlizeDirectoryPath()); - - String htmlDirectoryPath = configuration.getHtmlizeDirectoryPath(); - if (StringUtils.isBlank(htmlDirectoryPath)) - { - logger.warn("Undefined htmlize directory."); - } - else if (!new File(htmlDirectoryPath).exists()) - { - logger.warn("Htmlize directory does not exist: {}.", htmlDirectoryPath); - } - else - { - File htmlizeDirectory = configuration.getHtmlizeDirectory(); - - for (File file : htmlizeDirectory.listFiles()) - { - if ((file.isFile()) && (StringUtils.endsWithAny(file.getName(), ".properties", ".js", ".html", ".ico", ".css", ".jpg", ".png", ".xhtml"))) - { - logger.info("Deleting " + file.getName()); - file.delete(); - } - } - } - } - - /** - * Copy categories stuff. - * - * @param path - * the path - * @throws IOException - * Signals that an I/O exception has occurred. - */ - private static void copyCategoriesStuff(final String path, final File targetDirectory) throws IOException - { - if (StringUtils.isNotBlank(path)) - { - File source = new File(path); - File target = new File(targetDirectory, "categories"); - - for (File file : source.listFiles()) - { - if (file.isFile()) - { - FileUtils.copyFileToDirectory(file, target); - } - } - } - - // Check. - for (Category category : HtmlizerContext.instance().getCategories()) - { - File categoryFile = new File(targetDirectory, category.getLogoPath()); - - if (!categoryFile.exists()) - { - category.setLogoPath(null); - } - } - } - - /** - * Copy stuff. - * - * @param target - * the target - * @throws IOException - */ - private static void copyStuff(final File targetDirectory) throws IOException - { - // Copy commons files (index, images, favicon, css…). - if (!new File(targetDirectory, "index.html").exists()) - { - String source = "/fr/devinsy/statoolinfos/htmlize/stuff/"; - URLUtils.copyDeeply(StatoolInfosUtils.class.getResource(source), targetDirectory); - - URLUtils.copyResource(source + "statoolinfos-logo.jpg", new File(targetDirectory, "logo.jpg")); - URLUtils.copyResource(source + "statoolinfos-logo.ico", new File(targetDirectory, "favicon.ico")); - } - } - - /** - * Htmlize. - * - * @param configurationFile - * the configuration file - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void htmlize(final File configurationFile) throws StatoolInfosException, IOException - { - logger.info("Htmlize {}", configurationFile.getAbsolutePath()); - - HtmlizerContext.instance().configure(configurationFile); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - copyStuff(htmlizeDirectory); - copyCategoriesStuff(HtmlizerContext.instance().getConfiguration().get("conf.htmlize.categories.icons"), htmlizeDirectory); - - AboutPage.build(); - CategoriesPage.build(); - CategoryPage.buildAll(); - EditoPage.build(); - ExportsPage.build(); - FederationPages.build(); - OrganizationPage.buildAll(); - OrganizationCrawlJournalPage.buildAll(); - OrganizationUptimePage.buildAll(); - OrganizationPropertyCheckPage.buildAll(); - OrganizationPropertyAlertPage.buildAll(); - PropertiesFilesPage.build(); - PropertyStatsPage.buildAll(); - ServicePage.buildAll(); - ServiceCrawlJournalPage.buildAll(); - ServicePropertyCheckPage.buildAll(); - ServicePropertyAlertPage.buildAll(); - ServiceUptimePage.buildAll(); - ServicesPage.build(); - SoftwaresPage.build(); - SoftwarePage.buildAll(); - SocialNetworksPage.buildAll(); - // PropertyCheckView.buildAll(); - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationCrawlJournalPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationCrawlJournalPage.java deleted file mode 100644 index ee9a91c..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationCrawlJournalPage.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.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.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class CrawlJournalOrganizationPage. - */ -public class OrganizationCrawlJournalPage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationCrawlJournalPage.class); - - /** - * Builds the. - * - * @param organization - * the organization - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final Organization organization) throws StatoolInfosException, IOException - { - try - { - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("contentView", CrawlJournalView.htmlize(organization.getCrawlJournal())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - String page = WebCharterView.build(content, trail); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-crawl.xhtml"), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organization crawl journal page: " + exception.getMessage(), exception); - } - } - - /** - * Builds the all. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void buildAll() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - - for (Organization organization : federation.getOrganizations()) - { - build(organization); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java deleted file mode 100644 index ced2944..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2021-2022 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 org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.checker.PropertyChecks; -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.DisplayMode; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class OrganizationHeaderView. - */ -public class OrganizationHeaderView -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationHeaderView.class); - - /** - * Htmlize. - * - * @param organization - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Organization organization) throws StatoolInfosException - { - String result; - - try - { - logger.debug("htmlizing service header page {}…", organization.get("service.name")); - - TagDataManager data = new TagDataManager(); - - data.setAttribute("organizationRawButton", "href", organization.getTechnicalName() + ".properties"); - - data.setAttribute("organizationLogo", "src", organization.getLogoFileName()); - data.setEscapedContent("organizationName", organization.get("organization.name")); - - if (organization.getWebsiteURL() != null) - { - data.setEscapedContent("organizationURL", organization.getWebsiteURL().toString()); - data.setEscapedAttribute("organizationURL", "href", organization.getWebsiteURL().toString()); - } - data.setEscapedContent("organizationDescription", organization.get("organization.description")); - - data.setEscapedContent("organizationMemberOfName", StringUtils.defaultIfBlank(organization.getFederation().getName(), "n/a")); - data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDateValue(), "n/a")); - data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDateValue(), "n/a")); - data.setContent("organizationAge", StringUtils.defaultIfBlank(organization.getAge(), "n/a")); - if (StringUtils.isBlank(organization.getEndDateValue())) - { - data.setContent("organizationMemberOfWord", "depuis"); - data.setAttribute("organizationEndDateData", "style", "display: none;"); - } - else - { - data.setContent("organizationMemberOfWord", ":"); - } - - data.setContent("organizationMemberStartDate", StringUtils.defaultIfBlank(organization.getMemberStartDateValue(), "n/a")); - data.setContent("organizationMemberEndDate", StringUtils.defaultIfBlank(organization.getMemberEndDateValue(), "n/a")); - data.setContent("organizationMemberAge", StringUtils.defaultIfBlank(organization.getMemberAge(), "n/a")); - if (StringUtils.isBlank(organization.getMemberEndDateValue())) - { - data.setAttribute("organizationMemberEndDateData", "style", "display: none;"); - } - else - { - data.setContent("organizationStartDateWord", ""); - } - - data.setAttribute("organizationsLink", "href", organization.getFederation().getTechnicalName() + "-organizations.xhtml"); - data.setAttribute("servicesLink", "href", organization.getTechnicalName() + "-services.xhtml"); - data.setAttribute("rawLink", "href", organization.getTechnicalName() + ".properties"); - data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-propertycheck.xhtml"); - - data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml"); - data.setAttribute("metricsLink", "href", organization.getTechnicalName() + "-metrics-summary-months-last.xhtml"); - - data.setAttribute("crawlLink", "href", organization.getTechnicalName() + "-crawl.xhtml"); - if (organization.getCrawlJournal().getErrors().isEmpty()) - { - data.setAttribute("crawlLinkImg", "src", "circle-icons/download-mono.svg"); - } - else - { - data.setAttribute("crawlLinkImg", "src", "circle-icons/download.svg"); - } - - data.setAttribute("uptimeLink", "href", organization.getLocalFileBaseName() + "-uptimes.xhtml"); - if (HtmlizerContext.instance().getUptimeJournal().hasRecentError(organization.getActiveServices())) - { - data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ko-mono.svg"); - } - else - { - data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ok-mono.svg"); - } - - { - PropertyChecks checks = organization.getInputChecksAll(); - - data.setContent("errorCount", checks.getErrorCount()); - data.setContent("warningCount", checks.getWarningCount()); - data.setContent("voidCount", checks.getVoidCount()); - - data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-propertyalerts.xhtml"); - } - - if (organization.getLegalURL() != null) - { - data.setEscapedAttribute("legalLink", "href", organization.getLegalURL().toString()); - data.setAttribute("legalLinkImg", "class", ""); - data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (organization.getContactURL() != null) - { - data.setEscapedAttribute("contactLink", "href", organization.getContactURL().toString()); - data.setAttribute("contactLinkImg", "class", ""); - data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (StringUtils.isNotBlank(organization.getContactEmail())) - { - data.setEscapedAttribute("emailLink", "href", "mailto:" + organization.getContactEmail()); - data.setAttribute("emailLinkImg", "class", ""); - data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (organization.getUserGuideURL() != null) - { - data.setEscapedAttribute("userDocLink", "href", organization.getUserGuideURL().toString()); - data.setAttribute("userDocLinkImg", "class", ""); - data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (organization.getTechnicalGuideURL() != null) - { - data.setEscapedAttribute("technicalDocLink", "href", organization.getTechnicalGuideURL().toString()); - data.setAttribute("technicalDocLinkImg", "class", ""); - data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml", data).toString(); - - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service header view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java deleted file mode 100644 index dcbef76..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationListView.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2020-2022 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.IOException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.Organizations; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.core.StatoolInfosUtils; -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class OrganizationsView. - */ -public class OrganizationListView -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationListView.class); - - /** - * Htmlize. - * - * @param organizations - * the organizations - * @return the string - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static String htmlize(final Organizations organizations, final Organizations aways) throws StatoolInfosException, IOException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - Organizations actives = organizations.filterActive(); - data.setContent("organizationCount", actives.size()); - data.setContent("serviceCount", actives.getActiveServiceCount()); - - String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", " "); - data.setContent("monthLabel", monthLabel); - data.setAttribute("userCountHeaderColumn", "title", monthLabel); - data.setAttribute("visitCountHeaderColumn", "title", monthLabel); - - int index = 0; - for (Organization organization : actives.sortByReverseServiceCount()) - { - data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml"); - data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getLogoFileName()); - data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName()); - data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName()); - - if (organization.getWebsiteURL() != null) - { - data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString()); - data.setEscapedAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString()); - } - data.setContent("organizationListLine", index, "organizationListLineServiceCount", StatoolInfosUtils.defaultIfZero(organization.getActiveServiceCount(), "😿")); - data.setContent("organizationListLine", index, "organizationListLineUserCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthUserCount(), "😢")); - data.setContent("organizationListLine", index, "organizationListLineVisitCount", StatoolInfosUtils.defaultIfZero(organization.getPreviousMonthVisitCount(), "😞")); - - data.setContent("organizationListLine", index, "organizationListLineDate", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY"))); - data.setAttribute("organizationListLine", index, "organizationListLineDate", "title", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss"))); - - index += 1; - } - - Organizations idles = organizations.getIdles(); - if (idles.isEmpty()) - { - data.setContent("idleMembers", "aucun."); - } - else - { - StringList buffer = new StringList(); - for (Organization idle : idles) - { - buffer.add(String.format("%s", idle.getTechnicalName() + ".xhtml", idle.getName())); - } - data.setContent("idleMembers", buffer.toString("", ", ", ".")); - } - - if (aways.isEmpty()) - { - data.setContent("awayMembers", "aucun."); - } - else - { - StringList buffer = new StringList(); - for (Organization away : aways) - { - buffer.add(String.format("%s", away.getTechnicalName() + ".xhtml", away.getName())); - } - data.setContent("awayMembers", buffer.toString("", ", ", ".")); - } - - String page = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml", data).toString(); - - result = XidynUtils.extractBodyContent(page); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organizations view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricGenericPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricGenericPage.java deleted file mode 100644 index ffe908d..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricGenericPage.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationGenericMetricPage. - */ -public class OrganizationMetricGenericPage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationMetricGenericPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param organization - * the organization - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.GENERIC, view, period)); - - // - OrganizationMetricHtmlizer.htmlize(data, "graphic.users", organization, view, period, "metrics.service.users", ChartColor.GREEN); - - OrganizationMetricHtmlizer.htmlize(data, "graphic.users.ipv4-ipv6", organization, view, period, "service.users (ipv4 + ipv6)", "metrics.service.users.ipv4", ChartColor.YELLOW, - "metrics.service.users.ipv6", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "graphic.users.ipv4", organization, view, period, "metrics.service.users.ipv4", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "graphic.users.ipv6", organization, view, period, "metrics.service.users.ipv6", ChartColor.GREEN); - - OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts", organization, view, period, "metrics.service.accounts", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "graphic.accounts.active", organization, view, period, "metrics.service.accounts.active", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "graphic.database.bytes", organization, view, period, "metrics.service.database.bytes", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", organization, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); - trail.add("Metrics génériques"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-generic-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organization generic metric page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricHtmlizer.java deleted file mode 100644 index ed44dd5..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricHtmlizer.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * 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.time.YearMonth; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.threeten.extra.YearWeek; - -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.statoolinfos.properties.MonthValues; -import fr.devinsy.statoolinfos.properties.WeekValues; -import fr.devinsy.statoolinfos.properties.YearValues; -import fr.devinsy.xidyn.data.TagDataManager; - -/** - * The Class OrganizationMetricHtmlizer. - */ -public class OrganizationMetricHtmlizer -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationMetricHtmlizer.class); - - /** - * Htmlize data. - * - * @param data - * the data - * @param metricId - * the metric id - * @param organization - * the organization - * @param metricPath - * the metric path - * @param color - * the color - * @throws StatoolInfosException - * the statool infos exception - */ - public static void htmlize(final TagDataManager data, final String metricId, final Organization organization, final ViewMenu view, final PeriodMenu period, final String metricPath, - final ChartColor color) throws StatoolInfosException - { - if (view == ViewMenu.YEARS) - { - YearValues yearMetric = organization.getMetricYearValuesAll(metricPath); - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color)); - } - } - else if (view == ViewMenu.MONTHS) - { - MonthValues monthMetric = organization.getMetricMonthValuesAll(metricPath); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(year, 01), YearMonth.of(year, 12), monthMetric, color)); - } - } - else if (view == ViewMenu.WEEKS) - { - WeekValues weekMetric = organization.getMetricWeekValuesAll(metricPath); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(year, 01), YearWeek.of(year, 53), weekMetric, color)); - } - } - } - - /** - * Htmlize data. - * - * @param data - * the data - * @param metricId - * the metric id - * @param organization - * the organization - * @param view - * the view - * @param period - * the period - * @param metricLabel - * the metric label - * @param metricPath1 - * the metric path 1 - * @param color1 - * the color 1 - * @param metricPath2 - * the metric path 2 - * @param color2 - * the color 2 - * @throws StatoolInfosException - * the statool infos exception - */ - public static void htmlize(final TagDataManager data, final String metricId, final Organization organization, final ViewMenu view, final PeriodMenu period, final String metricLabel, - final String metricPath1, final ChartColor color1, final String metricPath2, final ChartColor color2) throws StatoolInfosException - { - if (view == ViewMenu.YEARS) - { - YearValues yearMetric1 = organization.getMetricYearValuesAll(metricPath1); - YearValues yearMetric2 = organization.getMetricYearValuesAll(metricPath2); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, - ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2)); - } - } - else if (view == ViewMenu.MONTHS) - { - MonthValues monthMetric1 = organization.getMetricMonthValuesAll(metricPath1); - MonthValues monthMetric2 = organization.getMetricMonthValuesAll(metricPath2); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, - ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, - ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(year, 01), YearMonth.of(year, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); - } - } - else if (view == ViewMenu.WEEKS) - { - WeekValues weekMetric1 = organization.getMetricWeekValuesAll(metricPath1); - WeekValues weekMetric2 = organization.getMetricWeekValuesAll(metricPath2); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(year, 01), YearWeek.of(year, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); - } - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java deleted file mode 100644 index a8cc725..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (C) 2021-2023 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.util.ArrayList; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class OrganizationMetricMenuView. - */ -public class OrganizationMetricMenuView -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationMetricMenuView.class); - - public enum PeriodMenu - { - FULL, - LAST, - Y2021, - Y2022; - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - String result; - - if (this.name().startsWith("Y")) - { - result = this.name().substring(1); - } - else - { - result = this.name().toLowerCase(); - } - - // - return result; - } - - /** - * Gets the years. - * - * @return the years - */ - public static PeriodMenu[] getYears() - { - PeriodMenu[] result; - - ArrayList list = new ArrayList(); - for (PeriodMenu item : values()) - { - if (item.name().startsWith("Y")) - { - list.add(item); - } - } - - result = list.toArray(new PeriodMenu[0]); - - // - return result; - } - } - - public enum TypeMenu - { - SUMMARY, - WEB, - GENERIC, - SPECIFIC; - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - String result; - - result = this.name().toLowerCase(); - - // - return result; - } - } - - public enum ViewMenu - { - YEARS, - MONTHS, - WEEKS, - DAYS; - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - String result; - - result = this.name().toLowerCase(); - - // - return result; - } - } - - /** - * Htmlize. - * - * @param organization - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Organization organization, final TypeMenu type, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - // - String filename = String.format("%s-metrics-summary-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("summaryTypeButton", "href", filename); - - filename = String.format("%s-metrics-generic-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("genericTypeButton", "href", filename); - - filename = String.format("%s-metrics-specific-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("specificTypeButton", "href", filename); - - filename = String.format("%s-metrics-web-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("webTypeButton", "href", filename); - - // - filename = String.format("%s-metrics-%s-years-%s.xhtml", organization.getLocalFileBaseName(), type.getName(), PeriodMenu.FULL.getName()); - data.setAttribute("yearsViewButton", "href", filename); - - filename = String.format("%s-metrics-%s-months-%s.xhtml", organization.getLocalFileBaseName(), type.getName(), period.getName()); - data.setAttribute("monthsViewButton", "href", filename); - - filename = String.format("%s-metrics-%s-weeks-%s.xhtml", organization.getLocalFileBaseName(), type.getName(), period.getName()); - data.setAttribute("weeksViewButton", "href", filename); - - data.setAttribute("daysViewButton", "href", "#"); - - // - if (view != ViewMenu.YEARS) - { - filename = String.format("%s-metrics-%s-%s-full.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("fullPeriodButton", "href", filename); - - filename = String.format("%s-metrics-%s-%s-last.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("lastPeriodButton", "href", filename); - - filename = String.format("%s-metrics-%s-%s-2021.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("2021PeriodButton", "href", filename); - - filename = String.format("%s-metrics-%s-%s-2022.xhtml", organization.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("2022PeriodButton", "href", filename); - } - - // - if ((type == null) || (type == TypeMenu.SUMMARY)) - { - data.appendAttribute("summaryTypeButton", "class", "button selected"); - } - else if (type == TypeMenu.GENERIC) - { - data.appendAttribute("genericTypeButton", "class", "button selected"); - } - else if (type == TypeMenu.WEB) - { - data.appendAttribute("webTypeButton", "class", "button selected"); - } - else if (type == TypeMenu.SPECIFIC) - { - data.appendAttribute("specificTypeButton", "class", "button selected"); - } - - // - if ((view == null) || (view == ViewMenu.YEARS)) - { - data.appendAttribute("yearsViewButton", "class", "button selected"); - } - else if (view == ViewMenu.MONTHS) - { - data.appendAttribute("monthsViewButton", "class", "button selected"); - } - else if (view == ViewMenu.WEEKS) - { - data.appendAttribute("weeksViewButton", "class", "button selected"); - } - else if (view == ViewMenu.DAYS) - { - data.appendAttribute("daysViewButton", "class", "button selected"); - } - - // - if ((period == null) || (period == PeriodMenu.FULL)) - { - data.appendAttribute("fullPeriodButton", "class", "button selected"); - } - else if (period == PeriodMenu.LAST) - { - data.appendAttribute("lastPeriodButton", "class", "button selected"); - } - else if (period == PeriodMenu.Y2021) - { - data.appendAttribute("2021PeriodButton", "class", "button selected"); - } - else if (period == PeriodMenu.Y2022) - { - data.appendAttribute("2022PeriodButton", "class", "button selected"); - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building metric menu view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricSpecificPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricSpecificPage.java deleted file mode 100644 index e03ed92..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricSpecificPage.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationSpecificMetricPage. - */ -public class OrganizationMetricSpecificPage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationMetricSpecificPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param organization - * the organization - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - logger.debug("Building oranization specific metric page {}…", organization.get("service.name")); - - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.SPECIFIC, view, period)); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); - trail.add("Metrics spécifiques"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-specific-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organization specific metric page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricSummaryPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricSummaryPage.java deleted file mode 100644 index a0b35ec..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricSummaryPage.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationGeneralStatsPage. - */ -public class OrganizationMetricSummaryPage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationMetricSummaryPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param organization - * the organization - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.SUMMARY, view, period)); - - OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans", organization, view, period, "metrics.http.hits.humans", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.visitors", organization, view, period, "metrics.http.visitors", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.visits", organization, view, period, "metrics.http.visits", ChartColor.GREEN); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString(); - - // - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); - trail.add("Metrics résumé"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-summary-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organization summary page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricWebPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricWebPage.java deleted file mode 100644 index fedac7c..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricWebPage.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationWebMetricPage. - */ -public class OrganizationMetricWebPage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationMetricWebPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param organization - * the organization - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Organization organization, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, TypeMenu.WEB, view, period)); - - // - OrganizationMetricHtmlizer.htmlize(data, "http.hits", organization, view, period, "metrics.http.hits", ChartColor.BLUE); - - OrganizationMetricHtmlizer.htmlize(data, "http.hits-ipv4ipv6", organization, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, - "metrics.http.hits.ipv6", - ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.hits.ipv4", organization, view, period, "metrics.http.hits.ipv4", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "http.hits.ipv6", organization, view, period, "metrics.http.hits.ipv6", ChartColor.GREEN); - - OrganizationMetricHtmlizer.htmlize(data, "http.hits-humansbots", organization, view, period, "http.hits (humans + bots)", "metrics.http.hits.humans", ChartColor.GREEN, - "metrics.http.hits.bots", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans", organization, view, period, "metrics.http.hits.humans", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.hits.bots", organization, view, period, "metrics.http.hits.bots", ChartColor.YELLOW); - - OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans-ipv4ipv6", organization, view, period, "http.hits.humans (ipv4 + ipv6)", "metrics.http.hits.humans.ipv4", ChartColor.YELLOW, - "metrics.http.hits.humans.ipv6", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv4", organization, view, period, "metrics.http.hits.humans.ipv4", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv6", organization, view, period, "metrics.http.hits.humans.ipv6", ChartColor.GREEN); - - OrganizationMetricHtmlizer.htmlize(data, "http.errors", organization, view, period, "metrics.http.errors", ChartColor.RED); - OrganizationMetricHtmlizer.htmlize(data, "http.errors.php", organization, view, period, "metrics.http.errors.php", ChartColor.RED); - - OrganizationMetricHtmlizer.htmlize(data, "http.files", organization, view, period, "metrics.http.files", ChartColor.BLUE); - OrganizationMetricHtmlizer.htmlize(data, "http.pages", organization, view, period, "metrics.http.pages", ChartColor.BLUE); - OrganizationMetricHtmlizer.htmlize(data, "http.bytes", organization, view, period, "metrics.http.bytes", ChartColor.BLUE); - - OrganizationMetricHtmlizer.htmlize(data, "http.ip", organization, view, period, "metrics.http.ip", ChartColor.BLUE); - - OrganizationMetricHtmlizer.htmlize(data, "http.ip-humansbots", organization, view, period, "http.ip (humans + bots)", "metrics.http.ip.humans", ChartColor.GREEN, - "metrics.http.ip.bots", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "http.ip.humans", organization, view, period, "metrics.http.ip.humans", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.ip.bots", organization, view, period, "metrics.http.ip.bots", ChartColor.YELLOW); - - OrganizationMetricHtmlizer.htmlize(data, "http.ip-ipv4ipv6", organization, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6", - ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.ip.ipv4", organization, view, period, "metrics.http.ip.ipv4", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "http.ip.ipv6", organization, view, period, "metrics.http.ip.ipv6", ChartColor.GREEN); - - OrganizationMetricHtmlizer.htmlize(data, "http.requesters", organization, view, period, "metrics.http.requesters", ChartColor.BLUE); - - OrganizationMetricHtmlizer.htmlize(data, "http.requesters-humansbots", organization, view, period, "http.requesters (humans + bots)", "metrics.http.requesters.humans", ChartColor.GREEN, - "metrics.http.requesters.bots", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "http.requesters.humans", organization, view, period, "metrics.http.requesters.humans", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.requesters.bots", organization, view, period, "metrics.http.requesters.bots", ChartColor.YELLOW); - - OrganizationMetricHtmlizer.htmlize(data, "http.requesters-ipv4ipv6", organization, view, period, "http.requesters(ipv4 + ipv6)", "metrics.http.requesters.ipv4", ChartColor.YELLOW, - "metrics.http.requesters.ipv6", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.requesters.ipv4", organization, view, period, "metrics.http.requesters.ipv4", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "http.requesters.ipv6", organization, view, period, "metrics.http.requesters.ipv6", ChartColor.GREEN); - - OrganizationMetricHtmlizer.htmlize(data, "http.visitors", organization, view, period, "metrics.http.visitors", ChartColor.BLUE); - OrganizationMetricHtmlizer.htmlize(data, "http.visitors-ipv4ipv6", organization, view, period, "http.visitors (ipv4 + ipv6)", "metrics.http.visitors.ipv4", ChartColor.YELLOW, - "metrics.http.visitors.ipv6", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.visitors.ipv4", organization, view, period, "metrics.http.visitors.ipv4", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "http.visitors.ipv6", organization, view, period, "metrics.http.visitors.ipv6", ChartColor.GREEN); - - OrganizationMetricHtmlizer.htmlize(data, "http.visits", organization, view, period, "metrics.http.visits", ChartColor.BLUE); - OrganizationMetricHtmlizer.htmlize(data, "http.visits-ipv4ipv6", organization, view, period, "http.visits (ipv4 + ipv6)", "metrics.http.visits.ipv4", ChartColor.YELLOW, - "metrics.http.visits.ipv6", ChartColor.GREEN); - OrganizationMetricHtmlizer.htmlize(data, "http.visits.ipv4", organization, view, period, "metrics.http.visits.ipv4", ChartColor.YELLOW); - OrganizationMetricHtmlizer.htmlize(data, "http.visits.ipv6", organization, view, period, "metrics.http.visits.ipv6", ChartColor.GREEN); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); - trail.add("Metrics web"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-web-%s-%s.xhtml", organization.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organization web metric page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java deleted file mode 100644 index 866105e..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.catgenerator.core.CatGenerator; -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.crawl.CrawlCache; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.ViewMenu; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationPage. - */ -public class OrganizationPage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationPage.class); - - /** - * Builds the view. - * - * @param organization - * the organization - * @throws IOException - * @throws StatoolInfosException - */ - public static void build(final Organization organization) throws IOException, StatoolInfosException - { - CrawlCache cache = HtmlizerContext.instance().getCache(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - // Manage the logo file. - logger.info("Htmlize organization logo: {}.", organization.getName()); - htmlizeOrganizationLogo(organization, cache, htmlizeDirectory); - - // - logger.info("Htmlize organization properties file: {}.", organization.getName()); - FileUtils.copyFile(organization.getInputFile(), new File(htmlizeDirectory, organization.getTechnicalName() + ".properties")); - - // - logger.info("Htmlize organization page: {}.", organization.getName()); - String page = OrganizationPage.htmlize(organization); - FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); - FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-services.xhtml"), page, StandardCharsets.UTF_8); - - // - OrganizationPropertyAlertPage.buildAll(); - - // - logger.info("Htmlize organization general stats page: {}.", organization.getName()); - page = OrganizationStatsPage.htmlize(organization); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats.xhtml"), page, StandardCharsets.UTF_8); - - // - logger.info("Htmlize organization metric pages: {}.", organization.getName()); - for (ViewMenu view : ViewMenu.values()) - { - for (PeriodMenu period : PeriodMenu.values()) - { - if ((view != ViewMenu.YEARS) || (period == PeriodMenu.FULL)) - { - if (view != ViewMenu.DAYS) - { - OrganizationMetricSummaryPage.build(htmlizeDirectory, organization, view, period); - OrganizationMetricGenericPage.build(htmlizeDirectory, organization, view, period); - OrganizationMetricSpecificPage.build(htmlizeDirectory, organization, view, period); - OrganizationMetricWebPage.build(htmlizeDirectory, organization, view, period); - } - } - } - } - } - - /** - * Builds the all. - * - * @throws StatoolInfosException - * @throws IOException - */ - public static void buildAll() throws IOException, StatoolInfosException - { - for (Organization organization : HtmlizerContext.instance().getFederation().getOrganizations()) - { - build(organization); - } - } - - /** - * Builds the. - * - * @param organization - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Organization organization) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building organization page {}…", organization.get("organization.name")); - - TagDataManager data = new TagDataManager(); - - // - data.setContent("organizationHeaderView", OrganizationHeaderView.htmlize(organization)); - data.setContent("serviceListView", ServiceListView.htmlize(organization.getServices().sortByName())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organization.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organization page: " + exception.getMessage(), exception); - } - - // - return result; - } - - /** - * Htmlize organization logo. - * - * @param organization - * the organization - * @param cache - * the cache - * @param htmlizeDirectory - * the htmlize directory - * @throws IOException - * Signals that an I/O exception has occurred. - */ - private static void htmlizeOrganizationLogo(final Organization organization, final CrawlCache cache, final File htmlizeDirectory) throws IOException - { - File target = new File(htmlizeDirectory, organization.getLogoFileName()); - - File logoFile = cache.restoreFile(organization.getLogoURL()); - if (logoFile == null) - { - logger.info("CatGeneratoring cat avatar: {}", target.getAbsoluteFile()); - CatGenerator.buildAvatarTo(organization.getTechnicalName(), target); - } - else - { - FileUtils.copyFile(logoFile, target); - } - } - -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyAlertPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyAlertPage.java deleted file mode 100644 index bd5c79c..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyAlertPage.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2020-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.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.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationPropertyFileAlertPage. - */ -public class OrganizationPropertyAlertPage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyAlertPage.class); - - /** - * Builds the all 1. - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws StatoolInfosException - * the statool infos exception - */ - public static void buildAll() throws IOException, StatoolInfosException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - for (Organization organization : federation.getOrganizations()) - { - String page = htmlize(organization); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8); - } - } - - /** - * Htmlize. - * - * @param organization - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Organization organization) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("contentView", PropertyAlertView.htmlize(organization.getInputChecksAll().getAlertLines())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); - trail.add("Propriétés en alertes", organization.getLocalFileBaseName() + "-propertyalerts.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organization property check alert page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyCheckPage.java deleted file mode 100644 index 73e9bd7..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyCheckPage.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2020-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.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.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationPropertyFileCheckView. - */ -public class OrganizationPropertyCheckPage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyCheckPage.class); - - /** - * Builds the all 1. - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws StatoolInfosException - * the statool infos exception - */ - public static void buildAll() throws IOException, StatoolInfosException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - for (Organization organization : federation.getOrganizations()) - { - String page = htmlize(organization); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8); - } - } - - /** - * Htmlize. - * - * @param organization - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Organization organization) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("contentView", PropertyCheckView.htmlize(organization.getInputChecks())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); - trail.add("Propriétés", organization.getLocalFileBaseName() + "-propertycheck.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organization property file check page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java deleted file mode 100644 index 48e0b4c..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2020-2022 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.IOException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.stats.StatAgent; -import fr.devinsy.statoolinfos.stats.services.RegistrationStats; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationStatsPage. - */ -public class OrganizationStatsPage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationStatsPage.class); - - /** - * Htmlize. - * - * @param organization - * the organization - * @return the string - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static String htmlize(final Organization organization) throws StatoolInfosException, IOException - { - String result; - - try - { - logger.debug("Building organization stats page {}…"); - - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - - // - data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organization)); - - Services services = organization.getActiveServices(); - data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization)); - data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services)); - data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services)); - data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services)); - - data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services)); - data.setContent("hostProviderHypervisorChart", ChartHtmlizer.htmlizeHostProviderHypervisorChart(services)); - - data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services)); - data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services)); - - { - RegistrationStats stats = StatAgent.statRegistrationTypes(services); - - data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats)); - data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats)); - data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats)); - data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats)); - data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats)); - } - - data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services)); - data.setContent("organisationTypeChart", ChartHtmlizer.htmlizeOrganizationTypeChart(organization)); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml", data).toString(); - - // - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building organization stats page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationUptimePage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationUptimePage.java deleted file mode 100644 index 90770ec..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationUptimePage.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.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.StatoolInfosException; -import fr.devinsy.statoolinfos.uptime.UptimeJournal; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationUptimePage. - */ -public class OrganizationUptimePage -{ - private static Logger logger = LoggerFactory.getLogger(OrganizationUptimePage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final Organization organization) throws StatoolInfosException, IOException - { - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - UptimeJournal journal = HtmlizerContext.instance().getUptimeJournal(); - - String page = htmlize(organization, journal); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-uptimes.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the all. - * - * @throws IOException - * @throws StatoolInfosException - */ - public static void buildAll() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - - for (Organization organization : federation.getOrganizations()) - { - build(organization); - } - } - - /** - * Htmlize. - * - * @param organization - * the organization - * @param journal - * the journal - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Organization organization, final UptimeJournal journal) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("uptimeView", UptimeView.htmlize(organization.getServices(), journal)); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimePage.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); - trail.add("Disponibilité des services", organization.getLocalFileBaseName() + "-uptimes.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building about page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java deleted file mode 100644 index 28b3cbe..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2020-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.net.MalformedURLException; -import java.nio.charset.StandardCharsets; -import java.time.format.DateTimeFormatter; - -import org.apache.commons.io.FileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.crawl.CrawlCache; -import fr.devinsy.statoolinfos.stats.StatAgent; -import fr.devinsy.statoolinfos.stats.propertyfiles.PropertiesFileStat; -import fr.devinsy.statoolinfos.stats.propertyfiles.PropertiesFileStats; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class OrganizationPage. - */ -public class PropertiesFilesPage -{ - private static Logger logger = LoggerFactory.getLogger(PropertiesFilesPage.class); - - /** - * Builds the. - * - * @throws IOException - * @throws MalformedURLException - * @throws StatoolInfosException - */ - public static void build() throws MalformedURLException, IOException, StatoolInfosException - { - Federation federation = HtmlizerContext.instance().getFederation(); - CrawlCache cache = HtmlizerContext.instance().getCache(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - logger.info("Htmlize propertiesFiles page."); - PropertiesFileStats stats = StatAgent.statAllPropertiesFiles(federation, cache).sortByName(); - String page = PropertiesFilesPage.htmlize(stats); - FileUtils.write(new File(htmlizeDirectory, "propertiesFiles.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param stats - * the stats - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final PropertiesFileStats stats) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building propertyFiles page."); - - TagDataManager data = new TagDataManager(); - - data.setContent("fileCount", stats.size()); - data.setContent("lineCount", stats.getLineCount()); - data.setContent("propertyCount", stats.getPropertyCount()); - data.setContent("blankPropertyCount", stats.getBlankPropertyCount()); - data.setContent("filledPropertyCount", stats.getFilledPropertyCount()); - data.setContent("warningCount", stats.getWarningCount()); - data.setContent("errorCount", stats.getErrorCount()); - data.setContent("voidCount", stats.getVoidCount()); - - // - int index = 0; - for (PropertiesFileStat stat : stats.sortByName()) - { - data.setAttribute("fileListLine", index, "fileListLineNameLink", "href", stat.getLocalName()); - data.setEscapedContent("fileListLine", index, "fileListLineNameLink", stat.getLocalName()); - - data.setAttribute("fileListLine", index, "fileListLineOwnerLink", "href", stat.getOrganization().getTechnicalName() + ".xhtml"); - data.setEscapedContent("fileListLine", index, "fileListLineNameValue", stat.getOrganization().getName()); - data.setAttribute("fileListLine", index, "fileListLineOwnerLogo", "src", stat.getOrganization().getLogoFileName()); - - data.setContent("fileListLine", index, "fileListLineLineCount", stat.getLineCount()); - data.setContent("fileListLine", index, "fileListLineActiveCount", stat.getPropertyCount()); - data.setContent("fileListLine", index, "fileListLineBlankPropertyCount", stat.getBlankPropertyCount()); - data.setContent("fileListLine", index, "fileListLineFilledPropertyCount", stat.getFilledPropertyCount()); - - if (stat.getWarningCount() > 0) - { - data.setAttribute("fileListLine", index, "fileListLineWarningCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml")); - data.setContent("fileListLine", index, "fileListLineWarningCountLink", stat.getWarningCount()); - data.setAttribute("fileListLine", index, "fileListLineWarningCount", "style", "background-color: yellow;"); - } - else - { - data.setContent("fileListLine", index, "fileListLineWarningCount", stat.getWarningCount()); - } - - if (stat.getErrorCount() > 0) - { - data.setAttribute("fileListLine", index, "fileListLineErrorCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml")); - data.setContent("fileListLine", index, "fileListLineErrorCountLink", stat.getErrorCount()); - data.setAttribute("fileListLine", index, "fileListLineErrorCount", "style", "background-color: red;"); - } - else - { - data.setContent("fileListLine", index, "fileListLineErrorCount", stat.getErrorCount()); - } - - if (stat.getVoidCount() > 0) - { - data.setAttribute("fileListLine", index, "fileListLineVoidCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml")); - data.setContent("fileListLine", index, "fileListLineVoidCountLink", stat.getVoidCount()); - data.setAttribute("fileListLine", index, "fileListLineVoidCount", "style", "background-color: rgb(54, 162, 235, 0.2);"); - } - else - { - data.setContent("fileListLine", index, "fileListLineVoidCount", stat.getVoidCount()); - } - - data.setContent("fileListLine", index, "fileListLineDate", stat.getUpdateDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY"))); - data.setAttribute("fileListLine", index, "fileListLineDate", "title", stat.getUpdateDate().format(DateTimeFormatter.ofPattern("HH:mm:ss"))); - - index += 1; - } - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Fichiers", "propertiesFiles.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building propertiesFiles page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertPage.java deleted file mode 100644 index 30f2e3f..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertPage.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2020-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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.checker.PropertyCheck; -import fr.devinsy.statoolinfos.checker.PropertyChecks; -import fr.devinsy.statoolinfos.core.Service.Status; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class PropertyFileCheckPage. - */ -public class PropertyAlertPage -{ - private static Logger logger = LoggerFactory.getLogger(PropertyAlertPage.class); - - /** - * Builds the. - * - * @param title - * the title - * @param checks - * the checks - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final String title, final PropertyChecks checks) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building propertyFilesCheck page…"); - - TagDataManager data = new TagDataManager(); - - data.setContent("lineCount", checks.size()); - data.setContent("errorCount", checks.getErrorCount()); - data.setContent("warningCount", checks.getWarningCount()); - data.setContent("voidCount", checks.getVoidCount()); - - // - data.setContent("statsTitle", title); - - // - int index = 0; - if (checks.isEmpty()) - { - data.setAttribute("blockTable", "class", "xid:nodisplay"); - } - else - { - for (PropertyCheck check : checks) - { - // - data.setEscapedContent("line", index, "lineFileName", check.getFileName()); - data.setContent("line", index, "lineIndex", check.getIndex()); - data.setEscapedContent("line", index, "lineComment", check.getComment()); - data.setEscapedContent("line", index, "lineContent", check.getLine()); - data.setAttribute("line", index, "lineContent", "class", statusToCSS(check.getStatus())); - - index += 1; - } - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyCheck.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Propriétés", "propertyStats.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); - } - - // - return result; - } - - /** - * Status to CSS. - * - * @param status - * the status - * @return the string - */ - public static String statusToCSS(final Status status) - { - String result; - - switch (status) - { - case OK: - result = "bg_ok"; - break; - - case WARNING: - result = "bg_warning"; - break; - - case ALERT: - result = "bg_alert"; - break; - - case ERROR: - result = "bg_error"; - break; - - case OVER: - result = "bg_over"; - break; - - case VOID: - default: - result = "bg_void"; - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertView.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertView.java deleted file mode 100644 index c3076d4..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertView.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2020-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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.checker.PropertyCheck; -import fr.devinsy.statoolinfos.checker.PropertyChecks; -import fr.devinsy.statoolinfos.core.Service.Status; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class PropertyFileAlertView. - */ -public class PropertyAlertView -{ - private static Logger logger = LoggerFactory.getLogger(PropertyAlertView.class); - - /** - * Htmlize. - * - * @param checks - * the checks - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final PropertyChecks checks) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("lineCount", checks.size()); - data.setContent("errorCount", checks.getErrorCount()); - data.setContent("warningCount", checks.getWarningCount()); - data.setContent("voidCount", checks.getVoidCount()); - - // - int index = 0; - if (checks.isEmpty()) - { - data.setAttribute("blockTable", "class", "xid:nodisplay"); - } - else - { - for (PropertyCheck check : checks) - { - // - data.setEscapedContent("line", index, "lineFileName", check.getFileName()); - data.setContent("line", index, "lineIndex", check.getIndex()); - data.setEscapedContent("line", index, "lineComment", check.getComment()); - data.setEscapedContent("line", index, "lineContent", check.getLine()); - data.setAttribute("line", index, "lineContent", "class", statusToCSS(check.getStatus())); - - index += 1; - } - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyAlertView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building property file alert view: " + exception.getMessage(), exception); - } - - // - return result; - } - - /** - * Status to CSS. - * - * @param status - * the status - * @return the string - */ - public static String statusToCSS(final Status status) - { - String result; - - switch (status) - { - case OK: - result = "bg_ok"; - break; - - case WARNING: - result = "bg_warning"; - break; - - case ALERT: - result = "bg_alert"; - break; - - case ERROR: - result = "bg_error"; - break; - - case OVER: - result = "bg_over"; - break; - - case VOID: - default: - result = "bg_void"; - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyCheckView.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyCheckView.java deleted file mode 100644 index 3ebaa4c..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyCheckView.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.checker.PropertyCheck; -import fr.devinsy.statoolinfos.checker.PropertyChecks; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Metrics; -import fr.devinsy.statoolinfos.core.Organization; -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.Service.Status; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class PropertyFileCheckView. - */ -public class PropertyCheckView -{ - private static Logger logger = LoggerFactory.getLogger(PropertyCheckView.class); - - /** - * Builds the all. - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws StatoolInfosException - * the statool infos exception - */ - public static void buildAll() throws IOException, StatoolInfosException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - PropertyChecks allAlertChecks = new PropertyChecks(); - PropertyChecks federationAlertChecks = new PropertyChecks(); - PropertyChecks organizationAlertChecks = new PropertyChecks(); - PropertyChecks serviceAlertChecks = new PropertyChecks(); - - // - PropertyChecks alerts = federation.getInputChecks().getAlertLines().setFileName(federation.getName()); - allAlertChecks.addAll(alerts); - federationAlertChecks.addAll(alerts); - - // - for (Organization organization : federation.getOrganizations()) - { - PropertyChecks checks = organization.getInputChecks(); - - // Ignore ghost organizations. - if (organization.getServiceCount() > 0) - { - alerts = checks.getAlertLines().setFileName(organization.getLocalFileName()); - allAlertChecks.addAll(alerts); - organizationAlertChecks.addAll(alerts); - - for (Service service : organization.getServices()) - { - alerts = service.getInputChecks().getAlertLines().setFileName(service.getLocalFileName()); - allAlertChecks.addAll(alerts); - serviceAlertChecks.addAll(alerts); - - for (Metrics metrics : service.getMetrics()) - { - alerts = metrics.getInputChecks().getAlertLines().setFileName(metrics.getLocalFileName()); - allAlertChecks.addAll(alerts); - serviceAlertChecks.addAll(alerts); - } - } - } - } - - // - String page = PropertyAlertPage.htmlize("Tous", allAlertChecks); - FileUtils.write(new File(htmlizeDirectory, "alertChecks.xhtml"), page, StandardCharsets.UTF_8); - - page = PropertyAlertPage.htmlize("Fédération", federationAlertChecks); - FileUtils.write(new File(htmlizeDirectory, "alertChecks-federation.xhtml"), page, StandardCharsets.UTF_8); - - page = PropertyAlertPage.htmlize("Membres", organizationAlertChecks); - FileUtils.write(new File(htmlizeDirectory, "alertChecks-organizations.xhtml"), page, StandardCharsets.UTF_8); - - page = PropertyAlertPage.htmlize("Services", serviceAlertChecks); - FileUtils.write(new File(htmlizeDirectory, "alertChecks-services.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Htmlize. - * - * @param checks - * the checks - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final PropertyChecks checks) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("lineCount", checks.size()); - data.setContent("warningCount", checks.getWarningCount()); - data.setContent("errorCount", checks.getErrorCount()); - data.setContent("voidCount", checks.getVoidCount()); - - // - data.setContent("statsTitle", "Propriétés"); - - // - int index = 0; - if (checks.isEmpty()) - { - data.setAttribute("fullBlockTable", "class", "xid:nodisplay"); - } - else - { - for (PropertyCheck check : checks) - { - data.setContent("line", index, "lineIndex", check.getIndex()); - data.setEscapedContent("line", index, "lineComment", check.getComment()); - data.setEscapedContent("line", index, "lineContent", check.getLine()); - data.setAttribute("line", index, "lineContent", "class", statusToCSS(check.getStatus())); - - index += 1; - } - } - - // - index = 0; - PropertyChecks subchecks = checks.getActiveLines(); - if (subchecks.isEmpty()) - { - data.setAttribute("shrunkBlockTable", "class", "xid:nodisplay"); - } - else - { - for (PropertyCheck check : subchecks) - { - data.setContent("shrunkLine", index, "shrunkLineIndex", check.getIndex()); - data.setEscapedContent("shrunkLine", index, "shrunkLineContent", check.getLine()); - data.setEscapedContent("shrunkLine", index, "shrunkLineComment", check.getComment()); - data.setAttribute("shrunkLine", index, "shrunkLineContent", "class", statusToCSS(check.getStatus())); - - index += 1; - } - } - - // - index = 0; - subchecks = checks.getAlertLines(); - if (subchecks.isEmpty()) - { - data.setAttribute("alertBlockTable", "class", "xid:nodisplay"); - } - else - { - for (PropertyCheck check : subchecks) - { - data.setContent("alertLine", index, "alertLineIndex", check.getIndex()); - data.setEscapedContent("alertLine", index, "alertLineContent", check.getLine()); - data.setEscapedContent("alertLine", index, "alertLineComment", check.getComment()); - data.setAttribute("alertLine", index, "alertLineContent", "class", statusToCSS(check.getStatus())); - - index += 1; - } - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyCheckView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building property check view: " + exception.getMessage(), exception); - } - - // - return result; - } - - /** - * Status to CSS. - * - * @param status - * the status - * @return the string - */ - public static String statusToCSS(final Status status) - { - String result; - - switch (status) - { - case OK: - result = "bg_ok"; - break; - - case WARNING: - result = "bg_warning"; - break; - - case ALERT: - result = "bg_alert"; - break; - - case ERROR: - result = "bg_error"; - break; - - case OVER: - result = "bg_over"; - break; - - case VOID: - default: - result = "bg_void"; - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java deleted file mode 100644 index c214635..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2020-2023 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.core.StatoolInfosUtils; -import fr.devinsy.statoolinfos.crawl.CrawlCache; -import fr.devinsy.statoolinfos.stats.StatAgent; -import fr.devinsy.statoolinfos.stats.properties.PropertyStat; -import fr.devinsy.statoolinfos.stats.properties.PropertyStatList; -import fr.devinsy.statoolinfos.stats.properties.PropertyStats; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class PropertyStatsPage. - */ -public class PropertyStatsPage -{ - private static Logger logger = LoggerFactory.getLogger(PropertyStatsPage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void buildAll() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - CrawlCache cache = HtmlizerContext.instance().getCache(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - logger.info("Htmlize propertyStats page."); - - PropertyStats stats = StatAgent.statAllProperties(federation); - String page = PropertyStatsPage.htmlize("Toutes les propriétés", stats); - FileUtils.write(new File(htmlizeDirectory, "propertyStats.xhtml"), page, StandardCharsets.UTF_8); - - PropertyStats federationStats = StatAgent.statFederationProperties(federation); - page = PropertyStatsPage.htmlize("Les propriétés de la fédération", federationStats); - FileUtils.write(new File(htmlizeDirectory, "propertyStats-federation.xhtml"), page, StandardCharsets.UTF_8); - - PropertyStats organizationsStats = StatAgent.statOrganizationsProperties(federation.getActiveOrganizations()); - page = PropertyStatsPage.htmlize("Les propriétés des organizations", organizationsStats); - FileUtils.write(new File(htmlizeDirectory, "propertyStats-organizations.xhtml"), page, StandardCharsets.UTF_8); - - PropertyStats servicesStats = StatAgent.statServicesProperties(federation.getActiveServices()); - page = PropertyStatsPage.htmlize("Les propriétés des services", servicesStats); - FileUtils.write(new File(htmlizeDirectory, "propertyStats-services.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param title - * the title - * @param stats - * the stats - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final String title, final PropertyStats stats) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building propertyStats page…"); - - TagDataManager data = new TagDataManager(); - - // - data.setContent("statsTitle", title); - data.setContent("propertyCount", stats.getPropertyCount()); - data.setContent("fileCount", stats.getFileCount()); - - // - PropertyStatList generalStats = stats.getGeneralPropertyStats().getList().sortByReverseFilledCount(); - data.setContent("generalPropertyCount", generalStats.size()); - int index = 0; - for (PropertyStat stat : generalStats) - { - data.setEscapedContent("generalPropertyLine", index, "generalPropertyLinePath", stat.getPath()); - data.setContent("generalPropertyLine", index, "generalPropertyLineBlankCount", stat.getBlankCount()); - data.setContent("generalPropertyLine", index, "generalPropertyLineBlankCountPercentage", StatoolInfosUtils.toPercentage(stat.getBlankCount(), stats.getFileCount())); - data.setContent("generalPropertyLine", index, "generalPropertyLineFilledCount", stat.getFilledCount()); - data.setContent("generalPropertyLine", index, "generalPropertyLineFilledCountPercentage", StatoolInfosUtils.toPercentage(stat.getFilledCount(), stats.getFileCount())); - - index += 1; - } - - // - PropertyStatList metricStats = stats.getMetricPropertyStats().getList().sortByReverseFilledCount(); - data.setContent("metricPropertyCount", metricStats.size()); - index = 0; - for (PropertyStat stat : metricStats) - { - data.setEscapedContent("metricPropertyLine", index, "metricPropertyLinePath", stat.getPath()); - data.setContent("metricPropertyLine", index, "metricPropertyLineBlankCount", stat.getBlankCount()); - data.setContent("metricPropertyLine", index, "metricPropertyLineBlankCountPercentage", StatoolInfosUtils.toPercentage(stat.getBlankCount(), stats.getFileCount())); - data.setContent("metricPropertyLine", index, "metricPropertyLineFilledCount", stat.getFilledCount()); - data.setContent("metricPropertyLine", index, "metricPropertyLineFilledCountPercentage", StatoolInfosUtils.toPercentage(stat.getFilledCount(), stats.getFileCount())); - - index += 1; - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Propriétés", "propertyStats.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceCrawlJournalPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceCrawlJournalPage.java deleted file mode 100644 index 1b63519..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceCrawlJournalPage.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class CrawlJournalServicePage. - */ -public class ServiceCrawlJournalPage -{ - private static Logger logger = LoggerFactory.getLogger(ServiceCrawlJournalPage.class); - - /** - * Builds the. - * - * @param service - * the service - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final Service service) throws StatoolInfosException, IOException - { - try - { - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("contentView", CrawlJournalView.htmlize(service.getCrawlJournal())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - String page = WebCharterView.build(content, trail); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-crawl.xhtml"), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service crawl journal page: " + exception.getMessage(), exception); - } - } - - /** - * Builds the all. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void buildAll() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - - for (Service service : federation.getServicesAll()) - { - build(service); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceFigureView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceFigureView.java deleted file mode 100644 index 6cdb940..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceFigureView.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2022 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.time.LocalDate; -import java.time.YearMonth; -import java.time.format.DateTimeFormatter; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.core.StatoolInfosUtils; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class ServiceFigureView. - */ -public class ServiceFigureView -{ - private static Logger logger = LoggerFactory.getLogger(ServiceFigureView.class); - - /** - * Builds the. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Services services) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building services figures view."); - - TagDataManager data = new TagDataManager(); - - data.setContent("serviceCount", services.size()); - YearMonth month = YearMonth.now(); - data.setContent("currentMonth", month.format(DateTimeFormatter.ofPattern("MMMM yyyy"))); - - if (services.isEmpty()) - { - data.setAttribute("serviceListLine", "class", "xid:nodisplay"); - } - else - { - String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", " "); - data.setContent("monthLabel", monthLabel); - data.setAttribute("userCountHeaderColumn", "title", monthLabel); - data.setAttribute("visitCountHeaderColumn", "title", monthLabel); - - int index = 0; - for (Service service : services.sortByName()) - { - data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml"); - data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getLogoFileName()); - data.setEscapedAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "title", service.getOrganization().getName()); - - data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getLogoFileName()); - data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName()); - data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); - - data.setAttribute("serviceListLine", index, "serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png"); - data.setAttribute("serviceListLine", index, "serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString())); - - if (service.getWebsiteURL() != null) - { - data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsiteURL().toString()); - data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsiteURL().toString()); - data.setEscapedAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsiteURL().toString()); - } - - data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName()); - data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml"); - - data.setContent("serviceListLine", index, "serviceListLineHitCount", StatoolInfosUtils.defaultIfZero(service.getMonthHitCount(month), "😢")); - data.setContent("serviceListLine", index, "serviceListLineVisitCount", StatoolInfosUtils.defaultIfZero(service.getMonthVisitCount(month), "😞")); - data.setContent("serviceListLine", index, "serviceListLineVisitorCount", StatoolInfosUtils.defaultIfZero(service.getMonthVisitorCount(month), "😞")); - data.setContent("serviceListLine", index, "serviceListLineUserCount", StatoolInfosUtils.defaultIfZero(service.getMonthUserCount(month), "😢")); - data.setContent("serviceListLine", index, "serviceListLineAccountCount", StatoolInfosUtils.defaultIfZero(service.getMonthAccountCount(month), "😇")); - data.setContent("serviceListLine", index, "serviceListLineActiveAccountCount", StatoolInfosUtils.defaultIfZero(service.getMonthActiveAccountCount(month), "😇")); - data.setContent("serviceListLine", index, "serviceListLineDatabaseBytes", StatoolInfosUtils.defaultIfZero(service.getMonthDatabaseBytes(month), "😇")); - data.setContent("serviceListLine", index, "serviceListLineDatafilesBytes", StatoolInfosUtils.defaultIfZero(service.getMonthDatafilesBytes(month), "😇")); - - index += 1; - } - } - result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceFigureView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(result); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java deleted file mode 100644 index f4f3fdd..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (C) 2020-2022 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 org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.checker.PropertyChecks; -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.DisplayMode; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class ServiceHeaderView. - */ -public class ServiceHeaderView -{ - private static Logger logger = LoggerFactory.getLogger(ServiceHeaderView.class); - - /** - * Htmlize. - * - * @param service - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setAttribute("serviceLogo", "src", service.getLogoFileName()); - - data.setEscapedContent("serviceName", service.getName()); - if (service.getWebsiteURL() != null) - { - data.setEscapedAttribute("serviceName", "href", service.getWebsiteURL().toString()); - data.setEscapedContent("serviceURL", service.getWebsiteURL().toString()); - data.setEscapedAttribute("serviceURL", "href", service.getWebsiteURL().toString()); - } - - data.setEscapedContent("serviceDescription", StringUtils.defaultIfBlank(service.getDescription(), "n/a")); - - data.setContent("serviceStartDate", StringUtils.defaultIfBlank(service.getStartDateValue(), "n/a")); - data.setContent("serviceEndDate", StringUtils.defaultIfBlank(service.getEndDateValue(), "n/a")); - data.setContent("serviceAge", StringUtils.defaultIfBlank(service.getAge(), "n/a")); - if (StringUtils.isBlank(service.getEndDateValue())) - { - data.setAttribute("serviceEndDateData", "style", "display: none;"); - } - else - { - data.setAttribute("serviceStartDateWord", "style", "display: none;"); - } - - data.setAttribute("serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png"); - data.setAttribute("serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString())); - - data.setAttribute("organizationsLink", "href", service.getOrganization().getTechnicalName() + "-services.xhtml"); - data.setAttribute("servicesLink", "href", service.getLocalFileBaseName() + "-services.xhtml"); - - data.setAttribute("rawLink", "href", service.getLocalFileBaseName() + ".properties"); - data.setAttribute("rawCheckLink", "href", service.getLocalFileBaseName() + "-propertycheck.xhtml"); - - data.setAttribute("statsLink", "href", service.getLocalFileBaseName() + ".xhtml"); - data.setAttribute("metricsLink", "href", service.getLocalFileBaseName() + "-metrics-summary-months-last.xhtml"); - - if (service.getLegalURL() != null) - { - data.setEscapedAttribute("legalLink", "href", service.getLegalURL().toString()); - data.setAttribute("legalLinkImg", "class", ""); - data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getContactURL() != null) - { - data.setEscapedAttribute("contactLink", "href", service.getContactURL().toString()); - data.setAttribute("contactLinkImg", "class", ""); - data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (StringUtils.isNotBlank(service.getContactEmail())) - { - data.setEscapedAttribute("emailLink", "href", "mailto:" + service.getContactEmail()); - data.setAttribute("emailLinkImg", "class", ""); - data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getUserGuideURL() != null) - { - data.setEscapedAttribute("userDocLink", "href", service.getUserGuideURL().toString()); - data.setAttribute("userDocLinkImg", "class", ""); - data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getTechnicalGuideURL() != null) - { - data.setEscapedAttribute("technicalDocLink", "href", service.getTechnicalGuideURL().toString()); - data.setAttribute("technicalDocLinkImg", "class", ""); - data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - - // - if (service.isRegistrationNone()) - { - data.setAttribute("registrationNoneImg", "class", ""); - data.getIdData("registrationNoneImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.isRegistrationFree()) - { - data.setAttribute("registrationFreeImg", "class", ""); - data.getIdData("registrationFreeImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.isRegistrationMember()) - { - data.setAttribute("registrationMemberImg", "class", ""); - data.getIdData("registrationMemberImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.isRegistrationClient()) - { - data.setAttribute("registrationClientImg", "class", ""); - data.getIdData("registrationClientImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.isRegistrationLoadFull()) - { - data.setAttribute("registrationLoadImg", "class", ""); - data.getIdData("registrationLoadImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - - // - data.setEscapedContent("softwareName", StringUtils.defaultIfBlank(service.getSoftwareName(), "n/a")); - data.setContent("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "n/a")); - data.setEscapedContent("softwareLicenseName", StringUtils.defaultIfBlank(service.getSoftwareLicenseName(), "n/a")); - if (service.getSoftwareWebsite() != null) - { - data.setEscapedAttribute("softwareWebsiteLink", "href", service.getSoftwareWebsite().toString()); - data.setAttribute("softwareWebsiteLinkImg", "class", ""); - data.getIdData("softwareWebsiteLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getSoftwareLicenseURL() != null) - { - data.setEscapedAttribute("softwareLicenseLink", "href", service.getSoftwareLicenseURL().toString()); - data.setAttribute("softwareLicenseLinkImg", "class", ""); - data.getIdData("softwareLicenseLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getSoftwareSourceURL() != null) - { - data.setEscapedAttribute("softwareSourceLink", "href", service.getSoftwareSourceURL().toString()); - data.setAttribute("softwareSourceLinkImg", "class", ""); - data.getIdData("softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - - data.setAttribute("crawlLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-crawl.xhtml"); - if (service.getCrawlJournal().getErrors().isEmpty()) - { - data.setAttribute("crawlLinkImg", "src", "circle-icons/download-mono.svg"); - } - else - { - data.setAttribute("crawlLinkImg", "src", "circle-icons/download.svg"); - } - - data.setAttribute("uptimeLink", "href", service.getLocalFileBaseName() + "-uptimes.xhtml"); - Services services = new Services(); - services.add(service); - if (HtmlizerContext.instance().getUptimeJournal().hasRecentError(services)) - { - data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ko-mono.svg"); - } - else - { - data.setAttribute("uptimeLinkImg", "src", "circle-icons/countdown-ok-mono.svg"); - } - - { - PropertyChecks checks = service.getInputChecksAll(); - data.setContent("errorCount", checks.getErrorCount()); - data.setContent("warningCount", checks.getWarningCount()); - data.setContent("voidCount", checks.getVoidCount()); - - data.setAttribute("alertLink", "href", service.getLocalFileBaseName() + "-propertyalerts.xhtml"); - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service header view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java deleted file mode 100644 index 13f4527..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2020-2022 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.time.LocalDate; -import java.time.format.DateTimeFormatter; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.core.StatoolInfosUtils; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.DisplayMode; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class ServiceListView. - */ -public class ServiceListView -{ - private static Logger logger = LoggerFactory.getLogger(ServiceListView.class); - - /** - * Builds the. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Services services) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building service list view."); - - TagDataManager data = new TagDataManager(); - - data.setContent("serviceCount", services.size()); - - if (services.isEmpty()) - { - data.setAttribute("serviceListLine", "class", "xid:nodisplay"); - } - else - { - String monthLabel = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("MMMM yyyy")).replace(" ", " "); - data.setContent("monthLabel", monthLabel); - data.setAttribute("userCountHeaderColumn", "title", monthLabel); - data.setAttribute("visitCountHeaderColumn", "title", monthLabel); - - int index = 0; - for (Service service : services.sortByName()) - { - data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getLogoFileName()); - data.setEscapedContent("serviceListLine", index, "serviceListLineNameValue", service.getName()); - data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); - - data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml"); - data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getLogoFileName()); - data.setEscapedContent("serviceListLine", index, "serviceListLineOrganizationValue", service.getOrganization().getName()); - - if (service.getWebsiteURL() != null) - { - data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsiteURL().toString()); - data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsiteURL().toString()); - data.setEscapedAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsiteURL().toString()); - } - - data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName()); - data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml"); - - data.setContent("serviceListLine", index, "serviceListLineUserCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthUserCount(), "😢")); - data.setContent("serviceListLine", index, "serviceListLineVisitCount", StatoolInfosUtils.defaultIfZero(service.getPreviousMonthVisitCount(), "😞")); - - data.setEscapedContent("serviceListLine", index, "serviceListLineDate", service.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY"))); - data.setEscapedAttribute("serviceListLine", index, "serviceListLineDate", "title", service.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss"))); - - data.setAttribute("serviceListLine", index, "serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png"); - data.setAttribute("serviceListLine", index, "serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString())); - - if (service.getLegalURL() != null) - { - data.setEscapedAttribute("serviceListLine", index, "legalLink", "href", service.getLegalURL().toString()); - data.setAttribute("serviceListLine", index, "legalLinkImg", "class", ""); - data.getIdData("serviceListLine", index, "legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getContactURL() != null) - { - data.setEscapedAttribute("serviceListLine", index, "contactLink", "href", service.getContactURL().toString()); - data.setAttribute("serviceListLine", index, "contactLinkImg", "class", ""); - data.getIdData("serviceListLine", index, "contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (StringUtils.isNotBlank(service.getContactEmail())) - { - data.setEscapedAttribute("serviceListLine", index, "emailLink", "href", "mailto:" + service.getContactEmail()); - data.setAttribute("serviceListLine", index, "emailLinkImg", "class", ""); - data.getIdData("serviceListLine", index, "emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getUserGuideURL() != null) - { - data.setEscapedAttribute("serviceListLine", index, "userDocLink", "href", service.getUserGuideURL().toString()); - data.setAttribute("serviceListLine", index, "userDocLinkImg", "class", ""); - data.getIdData("serviceListLine", index, "userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getTechnicalGuideURL() != null) - { - data.setEscapedAttribute("serviceListLine", index, "technicalDocLink", "href", service.getTechnicalGuideURL().toString()); - data.setAttribute("serviceListLine", index, "technicalDocLinkImg", "class", ""); - data.getIdData("serviceListLine", index, "technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - - // - if (service.isRegistrationNone()) - { - data.setAttribute("serviceListLine", index, "serviceListLineRegistrationNoneImg", "class", "toto"); - data.getIdData("serviceListLine", index, "serviceListLineRegistrationNoneImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.isRegistrationFree()) - { - data.setAttribute("serviceListLine", index, "serviceListLineRegistrationFreeImg", "class", ""); - data.getIdData("serviceListLine", index, "serviceListLineRegistrationFreeImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.isRegistrationMember()) - { - data.setAttribute("serviceListLine", index, "serviceListLineRegistrationMemberImg", "class", ""); - data.getIdData("serviceListLine", index, "serviceListLineRegistrationMemberImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.isRegistrationClient()) - { - data.setAttribute("serviceListLine", index, "serviceListLineRegistrationClientImg", "class", ""); - data.getIdData("serviceListLine", index, "serviceListLineRegistrationClientImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.isRegistrationLoadFull()) - { - data.setAttribute("serviceListLine", index, "serviceListLineRegistrationLoadImg", "class", ""); - data.getIdData("serviceListLine", index, "serviceListLineRegistrationLoadImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - - // - data.setEscapedContent("softwareName", StringUtils.defaultIfBlank(service.getSoftwareName(), "n/a")); - data.setEscapedContent("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "n/a")); - data.setEscapedContent("softwareLicenseName", StringUtils.defaultIfBlank(service.getSoftwareLicenseName(), "n/a")); - if (service.getSoftwareWebsite() != null) - { - data.setEscapedAttribute("serviceListLine", index, "softwareWebsiteLink", "href", service.getSoftwareWebsite().toString()); - data.setAttribute("serviceListLine", index, "softwareWebsiteLinkImg", "class", ""); - data.getIdData("serviceListLine", index, "softwareWebsiteLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getSoftwareLicenseURL() != null) - { - data.setEscapedAttribute("serviceListLine", index, "softwareLicenseLink", "href", service.getSoftwareLicenseURL().toString()); - data.setAttribute("serviceListLine", index, "softwareLicenseLinkImg", "class", ""); - data.getIdData("serviceListLine", index, "softwareLicenseLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (service.getSoftwareSourceURL() != null) - { - data.setEscapedAttribute("serviceListLine", index, "softwareSourceLink", "href", service.getSoftwareSourceURL().toString()); - data.setAttribute("serviceListLine", index, "softwareSourceLinkImg", "class", ""); - data.getIdData("serviceListLine", index, "softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - - index += 1; - } - } - result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceListView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(result); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricGenericPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricGenericPage.java deleted file mode 100644 index b1193b5..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricGenericPage.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServicePage. - */ -public class ServiceMetricGenericPage -{ - private static Logger logger = LoggerFactory.getLogger(ServiceMetricGenericPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param service - * the service - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.GENERIC, view, period)); - - // - ServiceMetricHtmlizer.htmlize(data, "graphic.users", service, view, period, "metrics.service.users", ChartColor.GREEN); - - ServiceMetricHtmlizer.htmlize(data, "graphic.users.ipv4-ipv6", service, view, period, "service.users (ipv4 + ipv6)", "metrics.service.users.ipv4", ChartColor.YELLOW, - "metrics.service.users.ipv6", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "graphic.users.ipv4", service, view, period, "metrics.service.users.ipv4", ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "graphic.users.ipv6", service, view, period, "metrics.service.users.ipv6", ChartColor.GREEN); - - ServiceMetricHtmlizer.htmlize(data, "graphic.accounts", service, view, period, "metrics.service.accounts", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "graphic.accounts.active", service, view, period, "metrics.service.accounts.active", ChartColor.GREEN); - - ServiceMetricHtmlizer.htmlize(data, "graphic.database.bytes", service, view, period, "metrics.service.database.bytes", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "graphic.datafiles.bytes", service, view, period, "metrics.service.datafiles.bytes", ChartColor.GREEN); - - // TODO - // metrics.moderation.accounts.reported.* = - // metrics.moderation.accounts.sanctioned.* = - // metrics.moderation.accounts.disabled.* = - // metrics.moderation.accounts.silenced.* = - // metrics.moderation.accounts.cancelled.* = - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Metrics génériques"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-generic-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service generic metric view: " + exception.getMessage(), exception); - } - } -} \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricHtmlizer.java deleted file mode 100644 index c4bb622..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricHtmlizer.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * 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.time.YearMonth; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.threeten.extra.YearWeek; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.statoolinfos.properties.MonthValues; -import fr.devinsy.statoolinfos.properties.WeekValues; -import fr.devinsy.statoolinfos.properties.YearValues; -import fr.devinsy.xidyn.data.TagDataManager; - -/** - * The Class MetricHtmlizeDataUtils. - */ -public class ServiceMetricHtmlizer -{ - private static Logger logger = LoggerFactory.getLogger(ServiceMetricHtmlizer.class); - - /** - * Htmlize data. - * - * @param data - * the data - * @param metricId - * the metric id - * @param service - * the service - * @param metricPath - * the metric path - * @param color - * the color - * @throws StatoolInfosException - * the statool infos exception - */ - public static void htmlize(final TagDataManager data, final String metricId, final Service service, final ViewMenu view, final PeriodMenu period, final String metricPath, - final ChartColor color) throws StatoolInfosException - { - if (view == ViewMenu.YEARS) - { - YearValues yearMetric = service.getMetricYearValues(metricPath); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color)); - } - } - else if (view == ViewMenu.MONTHS) - { - MonthValues monthMetric = service.getMetricMonthValues(metricPath); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(year, 01), YearMonth.of(year, 12), monthMetric, color)); - } - } - else if (view == ViewMenu.WEEKS) - { - WeekValues weekMetric = service.getMetricWeekValues(metricPath); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(year, 01), YearWeek.of(year, 53), weekMetric, color)); - } - } - } - - /** - * Htmlize data. - * - * @param data - * the data - * @param metricId - * the metric id - * @param service - * the service - * @param metricLabel - * the metric label - * @param metricPath1 - * the metric path 1 - * @param color1 - * the color 1 - * @param metricPath2 - * the metric path 2 - * @param color2 - * the color 2 - * @throws StatoolInfosException - * the statool infos exception - */ - public static void htmlize(final TagDataManager data, final String metricId, final Service service, final ViewMenu view, final PeriodMenu period, final String metricLabel, - final String metricPath1, final ChartColor color1, final String metricPath2, final ChartColor color2) throws StatoolInfosException - { - if (view == ViewMenu.YEARS) - { - YearValues yearMetric1 = service.getMetricYearValues(metricPath1); - YearValues yearMetric2 = service.getMetricYearValues(metricPath2); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, - ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2)); - } - } - else if (view == ViewMenu.MONTHS) - { - MonthValues monthMetric1 = service.getMetricMonthValues(metricPath1); - MonthValues monthMetric2 = service.getMetricMonthValues(metricPath2); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, - ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, - ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(year, 01), YearMonth.of(year, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); - } - } - else if (view == ViewMenu.WEEKS) - { - WeekValues weekMetric1 = service.getMetricWeekValues(metricPath1); - WeekValues weekMetric2 = service.getMetricWeekValues(metricPath2); - - if (period == PeriodMenu.FULL) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); - } - else if (period == PeriodMenu.LAST) - { - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); - } - else - { - int year = Integer.parseInt(period.name().substring(1)); - data.setContent(metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(year, 01), YearWeek.of(year, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); - } - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java deleted file mode 100644 index d28a9ab..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (C) 2021-2023 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.util.ArrayList; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class ServiceMetricMenuView. - */ -public class ServiceMetricMenuView -{ - private static Logger logger = LoggerFactory.getLogger(ServiceMetricMenuView.class); - - public enum PeriodMenu - { - FULL, - LAST, - Y2021, - Y2022; - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - String result; - - if (this.name().startsWith("Y")) - { - result = this.name().substring(1); - } - else - { - result = this.name().toLowerCase(); - } - - // - return result; - } - - /** - * Gets the years. - * - * @return the years - */ - public static PeriodMenu[] getYears() - { - PeriodMenu[] result; - - ArrayList list = new ArrayList(); - for (PeriodMenu item : values()) - { - if (item.name().startsWith("Y")) - { - list.add(item); - } - } - - result = list.toArray(new PeriodMenu[0]); - - // - return result; - } - } - - public enum TypeMenu - { - SUMMARY, - WEB, - GENERIC, - SPECIFIC; - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - String result; - - result = this.name().toLowerCase(); - - // - return result; - } - } - - public enum ViewMenu - { - YEARS, - MONTHS, - WEEKS, - DAYS; - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - String result; - - result = this.name().toLowerCase(); - - // - return result; - } - } - - /** - * Htmlize. - * - * @param service - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service, final TypeMenu type, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - // - String filename = String.format("%s-metrics-summary-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("summaryTypeButton", "href", filename); - - filename = String.format("%s-metrics-generic-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("genericTypeButton", "href", filename); - - filename = String.format("%s-metrics-specific-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("specificTypeButton", "href", filename); - - filename = String.format("%s-metrics-web-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName()); - data.setAttribute("webTypeButton", "href", filename); - - // - filename = String.format("%s-metrics-%s-years-%s.xhtml", service.getLocalFileBaseName(), type.getName(), PeriodMenu.FULL.getName()); - data.setAttribute("yearsViewButton", "href", filename); - - filename = String.format("%s-metrics-%s-months-%s.xhtml", service.getLocalFileBaseName(), type.getName(), period.getName()); - data.setAttribute("monthsViewButton", "href", filename); - - filename = String.format("%s-metrics-%s-weeks-%s.xhtml", service.getLocalFileBaseName(), type.getName(), period.getName()); - data.setAttribute("weeksViewButton", "href", filename); - - data.setAttribute("daysViewButton", "href", "#"); - - // - filename = String.format("%s-metrics-%s-%s-full.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("fullPeriodButton", "href", filename); - - if (view != ViewMenu.YEARS) - { - filename = String.format("%s-metrics-%s-%s-last.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("lastPeriodButton", "href", filename); - - filename = String.format("%s-metrics-%s-%s-2021.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("2021PeriodButton", "href", filename); - - filename = String.format("%s-metrics-%s-%s-2022.xhtml", service.getLocalFileBaseName(), type.getName(), view.getName()); - data.setAttribute("2022PeriodButton", "href", filename); - } - - // - if ((type == null) || (type == TypeMenu.SUMMARY)) - { - data.appendAttribute("summaryTypeButton", "class", "button selected"); - } - else if (type == TypeMenu.GENERIC) - { - data.appendAttribute("genericTypeButton", "class", "button selected"); - } - else if (type == TypeMenu.WEB) - { - data.appendAttribute("webTypeButton", "class", "button selected"); - } - else if (type == TypeMenu.SPECIFIC) - { - data.appendAttribute("specificTypeButton", "class", "button selected"); - } - - // - if ((view == null) || (view == ViewMenu.YEARS)) - { - data.appendAttribute("yearsViewButton", "class", "button selected"); - } - else if (view == ViewMenu.MONTHS) - { - data.appendAttribute("monthsViewButton", "class", "button selected"); - } - else if (view == ViewMenu.WEEKS) - { - data.appendAttribute("weeksViewButton", "class", "button selected"); - } - else if (view == ViewMenu.DAYS) - { - data.appendAttribute("daysViewButton", "class", "button selected"); - } - - // - if ((period == null) || (period == PeriodMenu.FULL)) - { - data.appendAttribute("fullPeriodButton", "class", "button selected"); - } - else if (period == PeriodMenu.LAST) - { - data.appendAttribute("lastPeriodButton", "class", "button selected"); - } - else if (period == PeriodMenu.Y2021) - { - data.appendAttribute("2021PeriodButton", "class", "button selected"); - } - else if (period == PeriodMenu.Y2022) - { - data.appendAttribute("2022PeriodButton", "class", "button selected"); - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building metric menu view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricSpecificPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricSpecificPage.java deleted file mode 100644 index c7df7a0..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricSpecificPage.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServicePage. - */ -public class ServiceMetricSpecificPage -{ - private static Logger logger = LoggerFactory.getLogger(ServiceMetricSpecificPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param service - * the service - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.SPECIFIC, view, period)); - - // - int index = 1; - for (String metricPath : service.getMetricSpecificPrefixes()) - { - ServiceMetricHtmlizer.htmlize(data, "foo" + index++, service, view, period, metricPath, ChartColor.BLUE); - } - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSpecificView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Metrics spécifiques"); - - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-specific-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service specific metrics view: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricSummaryPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricSummaryPage.java deleted file mode 100644 index 45e05fe..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricSummaryPage.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServiceSummaryMetricPage. - */ -public class ServiceMetricSummaryPage -{ - private static Logger logger = LoggerFactory.getLogger(ServiceMetricSummaryPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param service - * the service - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.SUMMARY, view, period)); - - ServiceMetricHtmlizer.htmlize(data, "http.hits.humans", service, view, period, "metrics.http.hits.humans", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.visitors", service, view, period, "metrics.http.visitors", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.visits", service, view, period, "metrics.http.visits", ChartColor.GREEN); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Metrics résumé"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-summary-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricWebPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricWebPage.java deleted file mode 100644 index d169d05..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricWebPage.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.TypeMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu; -import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServicePage. - */ -public class ServiceMetricWebPage -{ - private static Logger logger = LoggerFactory.getLogger(ServiceMetricWebPage.class); - - /** - * Builds the. - * - * @param htmlizeDirectory - * the htmlize directory - * @param service - * the service - * @param view - * the view - * @param period - * the period - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final File htmlizeDirectory, final Service service, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException - { - try - { - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, TypeMenu.WEB, view, period)); - - ServiceMetricHtmlizer.htmlize(data, "http.hits", service, view, period, "metrics.http.hits", ChartColor.BLUE); - - ServiceMetricHtmlizer.htmlize(data, "http.hits-ipv4ipv6", service, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6", - ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.hits.ipv4", service, view, period, "metrics.http.hits.ipv4", ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "http.hits.ipv6", service, view, period, "metrics.http.hits.ipv6", ChartColor.GREEN); - - ServiceMetricHtmlizer.htmlize(data, "http.hits-humansbots", service, view, period, "http.hits (humans + bots)", "metrics.http.hits.humans", ChartColor.GREEN, - "metrics.http.hits.bots", - ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "http.hits.humans", service, view, period, "metrics.http.hits.humans", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.hits.bots", service, view, period, "metrics.http.hits.bots", ChartColor.YELLOW); - - ServiceMetricHtmlizer.htmlize(data, "http.hits.humans-ipv4ipv6", service, view, period, "http.hits.humans (ipv4 + ipv6)", "metrics.http.hits.humans.ipv4", ChartColor.YELLOW, - "metrics.http.hits.humans.ipv6", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.hits.humans.ipv4", service, view, period, "metrics.http.hits.humans.ipv4", ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "http.hits.humans.ipv6", service, view, period, "metrics.http.hits.humans.ipv6", ChartColor.GREEN); - - ServiceMetricHtmlizer.htmlize(data, "http.errors", service, view, period, "metrics.http.errors", ChartColor.RED); - ServiceMetricHtmlizer.htmlize(data, "http.errors.php", service, view, period, "metrics.http.errors.php", ChartColor.RED); - - ServiceMetricHtmlizer.htmlize(data, "http.files", service, view, period, "metrics.http.files", ChartColor.BLUE); - ServiceMetricHtmlizer.htmlize(data, "http.pages", service, view, period, "metrics.http.pages", ChartColor.BLUE); - ServiceMetricHtmlizer.htmlize(data, "http.bytes", service, view, period, "metrics.http.bytes", ChartColor.BLUE); - - ServiceMetricHtmlizer.htmlize(data, "http.ip", service, view, period, "metrics.http.ip", ChartColor.BLUE); - - ServiceMetricHtmlizer.htmlize(data, "http.ip-humansbots", service, view, period, "http.ip (humans + bots)", "metrics.http.ip.humans", ChartColor.GREEN, "metrics.http.ip.bots", - ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "http.ip.humans", service, view, period, "metrics.http.ip.humans", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.ip.bots", service, view, period, "metrics.http.ip.bots", ChartColor.YELLOW); - - ServiceMetricHtmlizer.htmlize(data, "http.ip-ipv4ipv6", service, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6", - ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.ip.ipv4", service, view, period, "metrics.http.ip.ipv4", ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "http.ip.ipv6", service, view, period, "metrics.http.ip.ipv6", ChartColor.GREEN); - - ServiceMetricHtmlizer.htmlize(data, "http.requesters", service, view, period, "metrics.http.requesters", ChartColor.BLUE); - - ServiceMetricHtmlizer.htmlize(data, "http.requesters-humansbots", service, view, period, "http.requesters (humans + bots)", "metrics.http.requesters.humans", ChartColor.GREEN, - "metrics.http.requesters.bots", ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "http.requesters.humans", service, view, period, "metrics.http.requesters.humans", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.requesters.bots", service, view, period, "metrics.http.requesters.bots", ChartColor.YELLOW); - - ServiceMetricHtmlizer.htmlize(data, "http.requesters-ipv4ipv6", service, view, period, "http.requesters (ipv4 + ipv6)", "metrics.http.requesters.ipv4", ChartColor.YELLOW, - "metrics.http.requesters.ipv6", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.requesters.ipv4", service, view, period, "metrics.http.requesters.ipv4", ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "http.requesters.ipv6", service, view, period, "metrics.http.requesters.ipv6", ChartColor.GREEN); - - ServiceMetricHtmlizer.htmlize(data, "http.visitors", service, view, period, "metrics.http.visitors", ChartColor.BLUE); - ServiceMetricHtmlizer.htmlize(data, "http.visitors-ipv4ipv6", service, view, period, "http.visitors (ipv4 + ipv6)", "metrics.http.visitors.ipv4", ChartColor.YELLOW, - "metrics.http.visitors.ipv6", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.visitors.ipv4", service, view, period, "metrics.http.visitors.ipv4", ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "http.visitors.ipv6", service, view, period, "metrics.http.visitors.ipv6", ChartColor.GREEN); - - ServiceMetricHtmlizer.htmlize(data, "http.visits", service, view, period, "metrics.http.visits", ChartColor.BLUE); - ServiceMetricHtmlizer.htmlize(data, "http.visits-ipv4ipv6", service, view, period, "http.visits (ipv4 + ipv6)", "metrics.http.visits.ipv4", ChartColor.YELLOW, - "metrics.http.visits.ipv6", ChartColor.GREEN); - ServiceMetricHtmlizer.htmlize(data, "http.visits.ipv4", service, view, period, "metrics.http.visits.ipv4", ChartColor.YELLOW); - ServiceMetricHtmlizer.htmlize(data, "http.visits.ipv6", service, view, period, "metrics.http.visits.ipv6", ChartColor.GREEN); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Metrics web"); - String page = WebCharterView.build(content, trail); - - String filename = String.format("%s-metrics-web-%s-%s.xhtml", service.getLocalFileBaseName(), view.getName(), period.getName()); - FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java deleted file mode 100644 index 5fdfd77..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.catgenerator.core.BirdGenerator; -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Metrics; -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.crawl.CrawlCache; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.PeriodMenu; -import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.ViewMenu; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServicePage. - */ -public class ServicePage -{ - private static Logger logger = LoggerFactory.getLogger(ServicePage.class); - - /** - * Builds the view. - * - * @throws IOException - * @throws StatoolInfosException - */ - public static void build(final Service service) throws IOException, StatoolInfosException - { - CrawlCache cache = HtmlizerContext.instance().getCache(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - // Manage the logo file. - logger.info("Htmlize service logo: {}.", service.getName()); - htmlizeServiceLogo(service, cache, htmlizeDirectory); - - // - logger.info("Htmlize service properties file: {}.", service.getName()); - FileUtils.copyFile(service.getInputFile(), - new File(htmlizeDirectory, service.getLocalFileBaseName() + ".properties")); - - // - for (Metrics metrics : service.getMetrics()) - { - FileUtils.copyFile(metrics.getInputFile(), - new File(htmlizeDirectory, metrics.getLocalFileBaseName() + ".properties")); - } - - // - logger.info("Htmlize service page: {}.", service.getName()); - String page = ServicePage.htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + ".xhtml"), page, StandardCharsets.UTF_8); - - ServiceServicesPage.build(service); - - // - logger.info("Htmlize service metric pages: {}.", service.getName()); - for (ViewMenu view : ViewMenu.values()) - { - for (PeriodMenu period : PeriodMenu.values()) - { - if ((view != ViewMenu.YEARS) || (period == PeriodMenu.FULL)) - { - if (view != ViewMenu.DAYS) - { - ServiceMetricSummaryPage.build(htmlizeDirectory, service, view, period); - ServiceMetricGenericPage.build(htmlizeDirectory, service, view, period); - ServiceMetricSpecificPage.build(htmlizeDirectory, service, view, period); - ServiceMetricWebPage.build(htmlizeDirectory, service, view, period); - } - } - } - } - } - - /** - * Builds the all. - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws StatoolInfosException - * the statool infos exception - */ - public static void buildAll() throws IOException, StatoolInfosException - { - for (Service service : HtmlizerContext.instance().getFederation().getServicesAll()) - { - build(service); - } - } - - /** - * Builds the. - * - * @param service - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building service page {}…", service.get("service.name")); - - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("statsView", ServiceStatsView.htmlize(service)); - - // - // data.setContent("fooChart", graphicIndex++, - // LineMonthsChartView.build()); - - // service.getPrefixes(); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml"); - trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); - } - - // - return result; - } - - /** - * @param service - * @param cache - * @param htmlizeDirectory - * @throws IOException - */ - private static void htmlizeServiceLogo(final Service service, final CrawlCache cache, final File htmlizeDirectory) throws IOException - { - File target = new File(htmlizeDirectory, service.getLogoFileName()); - - File logoFile = cache.restoreFile(service.getLogoURL()); - if (logoFile == null) - { - logger.info("BirdGeneratoring cat avatar: {}", target.getAbsoluteFile()); - BirdGenerator.buildAvatarTo(service.getTechnicalName(), target); - } - else - { - FileUtils.copyFile(logoFile, target); - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyAlertPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyAlertPage.java deleted file mode 100644 index 03ce2f3..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyAlertPage.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Metrics; -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServicePropertyCheckAlertPage. - */ -public class ServicePropertyAlertPage -{ - private static Logger logger = LoggerFactory.getLogger(ServicePropertyAlertPage.class); - - /** - * Builds the all. - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws StatoolInfosException - * the statool infos exception - */ - public static void buildAll() throws IOException, StatoolInfosException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - for (Service service : federation.getServicesAll()) - { - String page = htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8); - - for (Metrics metrics : service.getMetrics()) - { - page = htmlize(service, metrics); - FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8); - } - } - } - - /** - * Htmlize. - * - * @param service - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("contentView", PropertyAlertView.htmlize(service.getInputChecksAll().getAlertLines())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Propriétés en alertes", service.getLocalFileBaseName() + "-propertyalerts.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service property file alert page: " + exception.getMessage(), exception); - } - - // - return result; - } - - /** - * Htmlize. - * - * @param service - * the service - * @param metrics - * the metrics - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service, final Metrics metrics) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("contentView", PropertyAlertView.htmlize(metrics.getInputChecks().getAlertLines())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Propriétés en alertes", service.getLocalFileBaseName() + "-propertyalerts.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building metrics property file check alert page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyCheckPage.java deleted file mode 100644 index 25a6c1b..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyCheckPage.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Metrics; -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServicePropertyFileCheckView. - */ -public class ServicePropertyCheckPage -{ - private static Logger logger = LoggerFactory.getLogger(ServicePropertyCheckPage.class); - - /** - * Builds the all. - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws StatoolInfosException - * the statool infos exception - */ - public static void buildAll() throws IOException, StatoolInfosException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - for (Service service : federation.getServicesAll()) - { - String page = htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8); - - for (Metrics metrics : service.getMetrics()) - { - page = htmlize(service, metrics); - FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8); - } - } - } - - /** - * Htmlize. - * - * @param service - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("contentView", PropertyCheckView.htmlize(service.getInputChecks())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Propriétés", service.getLocalFileBaseName() + "-propertycheck.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service property file check page: " + exception.getMessage(), exception); - } - - // - return result; - } - - /** - * Htmlize. - * - * @param service - * the service - * @param metrics - * the metrics - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service, final Metrics metrics) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("contentView", PropertyCheckView.htmlize(metrics.getInputChecks())); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Propriétés", service.getLocalFileBaseName() + "-propertycheck.xhtml"); - trail.add("Propriétés", metrics.getLocalFileBaseName() + "-propertycheck.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building metrics property file check page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceServicesPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceServicesPage.java deleted file mode 100644 index de5ee30..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceServicesPage.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.catgenerator.core.BirdGenerator; -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.crawl.CrawlCache; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -// TODO: Auto-generated Javadoc -/** - * The Class ServiceServicesPage. - */ -public class ServiceServicesPage -{ - private static Logger logger = LoggerFactory.getLogger(ServiceServicesPage.class); - - /** - * Builds the view. - * - * @param service - * the service - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws StatoolInfosException - * the statool infos exception - */ - public static void build(final Service service) throws IOException, StatoolInfosException - { - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - // - String page = htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-services.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param service - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - // - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - - Services services = new Services(); - services.add(service); - data.setContent("servicesView", ServiceListView.htmlize(services)); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceServices.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml"); - trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java deleted file mode 100644 index 23aab1a..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2020-2022 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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.stats.StatAgent; -import fr.devinsy.statoolinfos.stats.services.RegistrationStats; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class ServiceStatsPage. - */ -public class ServiceStatsView -{ - private static Logger logger = LoggerFactory.getLogger(ServiceStatsView.class); - - /** - * Builds the. - * - * @param service - * the service - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building service stats view {}…", service.get("service.name")); - - TagDataManager data = new TagDataManager(); - - // - data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(service)); - - Services services = Services.of(service); - data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services)); - data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services)); - data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services)); - - data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services)); - data.setContent("hostProviderHypervisorChart", ChartHtmlizer.htmlizeHostProviderHypervisorChart(services)); - - data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services)); - data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services)); - - { - RegistrationStats stats = StatAgent.statRegistrationTypes(services); - - data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats)); - data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats)); - data.setContent("registrationFreeTypeChart", ChartHtmlizer.htmlizeRegistrationFreePieChart(stats)); - data.setContent("registrationMemberTypeChart", ChartHtmlizer.htmlizeRegistrationMemberPieChart(stats)); - data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats)); - } - - data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(services)); - data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services)); - - // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml", data).toString(); - - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceUptimePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceUptimePage.java deleted file mode 100644 index ca8cf90..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceUptimePage.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.uptime.UptimeJournal; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServiceUptimePage. - */ -public class ServiceUptimePage -{ - private static Logger logger = LoggerFactory.getLogger(ServiceUptimePage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void build(final Service service) throws StatoolInfosException, IOException - { - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - UptimeJournal journal = HtmlizerContext.instance().getUptimeJournal(); - - String page = htmlize(service, journal); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-uptimes.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the all. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void buildAll() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - - for (Service service : federation.getServicesAll()) - { - build(service); - } - } - - /** - * Htmlize. - * - * @param service - * the service - * @param journal - * the journal - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Service service, final UptimeJournal journal) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - - Services services = new Services(); - services.add(service); - data.setContent("uptimeView", UptimeView.htmlize(services, journal)); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimePage.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); - trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Disponibilité des services", service.getLocalFileBaseName() + "-uptimes.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building about page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java deleted file mode 100644 index 5554ac4..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2020-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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class ServicesPage. - */ -public class ServicesPage -{ - private static Logger logger = LoggerFactory.getLogger(ServicesPage.class); - - /** - * Builds the. - * - * @throws IOException - * @throws StatoolInfosException - */ - public static void build() throws IOException, StatoolInfosException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - logger.info("Htmlize services page."); - String page = ServicesPage.htmlize(federation.getServices()); - FileUtils.write(new File(htmlizeDirectory, "services.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Services services) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building services page."); - - TagDataManager data = new TagDataManager(); - - data.setContent("serviceListView", ServiceListView.htmlize(services)); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/services.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Services", "services.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/SocialNetworksPage.java b/src/fr/devinsy/statoolinfos/htmlize/SocialNetworksPage.java deleted file mode 100644 index 65e1676..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/SocialNetworksPage.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2020-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.lang3.StringUtils; -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.Organizations; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.crawl.CrawlCache; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.DisplayMode; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class SocialNetworksPage. - */ -public class SocialNetworksPage -{ - private static Logger logger = LoggerFactory.getLogger(SocialNetworksPage.class); - - /** - * Builds the all. - * - * @throws StatoolInfosException - * @throws IOException - */ - public static void buildAll() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - CrawlCache cache = HtmlizerContext.instance().getCache(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - logger.info("Htmlize social networks pages."); - Organizations organizations = federation.getOrganizations().filterBySocialNetworks(); - String page = SocialNetworksPage.htmlize("Réseaux sociaux", organizations); - FileUtils.write(new File(htmlizeDirectory, "socialNetworks.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param title - * the title - * @param organizations - * the organizations - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final String title, final Organizations organizations) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building social networks page {}…"); - - TagDataManager data = new TagDataManager(); - - data.setEscapedContent("title", title); - data.setContent("organizationCount", organizations.size()); - - int index = 0; - for (Organization organization : organizations) - { - data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml"); - data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getLogoFileName()); - data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName()); - data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName()); - - if (organization.getWebsiteURL() != null) - { - data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString()); - data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString()); - } - if (StringUtils.isNotBlank(organization.getDiasporaWebpage())) - { - data.setAttribute("organizationListLine", index, "organizationListLineDiasporaImg", "class", ""); - data.getIdData("organizationListLine", index, "organizationListLineDiasporaImg").getAttribute("class").setMode(DisplayMode.REPLACE); - data.setAttribute("organizationListLine", index, "organizationListLineDiasporaLink", "href", organization.getDiasporaWebpage()); - data.setAttribute("organizationListLine", index, "organizationListLineDiaspora", "data-search", "1"); - data.setAttribute("organizationListLine", index, "organizationListLineDiaspora", "data-order", "1"); - } - - if (StringUtils.isNotBlank(organization.getFunkwhaleWebpage())) - { - data.setAttribute("organizationListLine", index, "organizationListLineFunkwhaleImg", "class", ""); - data.getIdData("organizationListLine", index, "organizationListLineFunkwhaleImg").getAttribute("class").setMode(DisplayMode.REPLACE); - data.setAttribute("organizationListLine", index, "organizationListLineFunkwhaleLink", "href", organization.getFunkwhaleWebpage()); - data.setAttribute("organizationListLine", index, "organizationListLineFunkwhale", "data-search", "1"); - data.setAttribute("organizationListLine", index, "organizationListLineFunkwhale", "data-order", "1"); - } - - if (StringUtils.isNotBlank(organization.getMastodonWebpage())) - { - data.setAttribute("organizationListLine", index, "organizationListLineMastodonImg", "class", ""); - data.getIdData("organizationListLine", index, "organizationListLineMastodonImg").getAttribute("class").setMode(DisplayMode.REPLACE); - data.setAttribute("organizationListLine", index, "organizationListLineMastodonLink", "href", organization.getMastodonWebpage()); - data.setAttribute("organizationListLine", index, "organizationListLineMastodon", "data-search", "1"); - data.setAttribute("organizationListLine", index, "organizationListLineMastodon", "data-order", "1"); - } - - if (StringUtils.isNotBlank(organization.getMobilizonWebpage())) - { - data.setAttribute("organizationListLine", index, "organizationListLineMobilizonImg", "class", ""); - data.getIdData("organizationListLine", index, "organizationListLineMobilizonImg").getAttribute("class").setMode(DisplayMode.REPLACE); - data.setAttribute("organizationListLine", index, "organizationListLineMobilizonLink", "href", organization.getMobilizonWebpage()); - data.setAttribute("organizationListLine", index, "organizationListLineMobilizon", "data-search", "1"); - data.setAttribute("organizationListLine", index, "organizationListLineMobilizon", "data-order", "1"); - } - - if (StringUtils.isNotBlank(organization.getPixelfedWebpage())) - { - data.setAttribute("organizationListLine", index, "organizationListLinePixelfedImg", "class", ""); - data.getIdData("organizationListLine", index, "organizationListLinePixelfedImg").getAttribute("class").setMode(DisplayMode.REPLACE); - data.setAttribute("organizationListLine", index, "organizationListLinePixelfedLink", "href", organization.getPixelfedWebpage()); - data.setAttribute("organizationListLine", index, "organizationListLinePixelfed", "data-search", "1"); - data.setAttribute("organizationListLine", index, "organizationListLinePixelfed", "data-order", "1"); - } - - if (StringUtils.isNotBlank(organization.getPeertubeWebpage())) - { - data.setAttribute("organizationListLine", index, "organizationListLinePeertubeImg", "class", ""); - data.getIdData("organizationListLine", index, "organizationListLinePeertubeImg").getAttribute("class").setMode(DisplayMode.REPLACE); - data.setAttribute("organizationListLine", index, "organizationListLinePeertubeLink", "href", organization.getPeertubeWebpage()); - data.setAttribute("organizationListLine", index, "organizationListLinePeertube", "data-search", "1"); - data.setAttribute("organizationListLine", index, "organizationListLinePeertube", "data-order", "1"); - } - - index += 1; - } - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/socialNetworks.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building social networks page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/SoftwarePage.java b/src/fr/devinsy/statoolinfos/htmlize/SoftwarePage.java deleted file mode 100644 index cc218dc..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/SoftwarePage.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2020 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.Software; -import fr.devinsy.statoolinfos.core.Softwares; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class SoftwarePage. - */ -public class SoftwarePage -{ - private static Logger logger = LoggerFactory.getLogger(SoftwarePage.class); - - /** - * Builds the all. - * - * @throws StatoolInfosException - * @throws IOException - */ - public static void buildAll() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - - logger.info("Htmlize software pages."); - Softwares catalog = federation.getSoftwares(); - for (Software software : catalog.values()) - { - Services services = federation.getServices().getBy(software); - String page = SoftwarePage.htmlize(software, services); - FileUtils.write(new File(htmlizeDirectory, "software-" + software.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); - } - } - - /** - * Builds the. - * - * @param software - * the software - * @param services - * the services - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Software software, final Services services) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building services page."); - - TagDataManager data = new TagDataManager(); - - data.setEscapedContent("softwareName", software.getName()); - data.setEscapedContent("softwareDescription", software.getDescription()); - data.setContent("serviceCount", services.size()); - - data.setContent("serviceListView", ServiceListView.htmlize(services)); - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/software.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Logiciels", "softwares.xhtml"); - trail.add(software.getName(), "software-" + software.getTechnicalName() + ".xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building software page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/SoftwaresPage.java b/src/fr/devinsy/statoolinfos/htmlize/SoftwaresPage.java deleted file mode 100644 index ec39fad..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/SoftwaresPage.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2020-2022 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.Categories; -import fr.devinsy.statoolinfos.core.Federation; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.core.StatoolInfosUtils; -import fr.devinsy.statoolinfos.htmlize.CategoriesView.Mode; -import fr.devinsy.statoolinfos.stats.StatAgent; -import fr.devinsy.statoolinfos.stats.softwares.SoftwareStat; -import fr.devinsy.statoolinfos.stats.softwares.SoftwareStats; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; - -/** - * The Class SoftwaresPage. - */ -public class SoftwaresPage -{ - private static Logger logger = LoggerFactory.getLogger(SoftwaresPage.class); - - /** - * Builds the. - * - * @throws StatoolInfosException - * @throws IOException - */ - public static void build() throws StatoolInfosException, IOException - { - Federation federation = HtmlizerContext.instance().getFederation(); - File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); - Categories categories = HtmlizerContext.instance().getCategories(); - - logger.info("Htmlize softwares page."); - SoftwareStats stats = StatAgent.statAllSoftwares(federation, categories); - String page = SoftwaresPage.htmlize(stats); - FileUtils.write(new File(htmlizeDirectory, "softwares.xhtml"), page, StandardCharsets.UTF_8); - } - - /** - * Builds the. - * - * @param stats - * the stats - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final SoftwareStats stats) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building softwares page."); - - TagDataManager data = new TagDataManager(); - - data.setContent("softwareCount", stats.size()); - - int index = 0; - for (SoftwareStat stat : stats.sortByName()) - { - data.setEscapedContent("softwareListLine", index, "softwareListLineNameLink", stat.getName()); - data.setAttribute("softwareListLine", index, "softwareListLineNameLink", "href", "software-" + stat.getTechnicalName() + ".xhtml"); - - data.setContent("softwareListLine", index, "softwareListLineCategory", CategoriesView.build(stat.getCategories(), Mode.ALL)); - - data.setContent("softwareListLine", index, "softwareListLineOrganizationCount", stat.getOrganizationCount()); - data.setContent("softwareListLine", index, "softwareListLineServiceCount", StatoolInfosUtils.defaultIfZero(stat.getServiceCount(), "😿")); - data.setContent("softwareListLine", index, "softwareListLineUserCount", StatoolInfosUtils.defaultIfZero(stat.getUserCount(), "😢")); - data.setContent("softwareListLine", index, "softwareListLineVisitCount", StatoolInfosUtils.defaultIfZero(stat.getVisitCount(), "😞")); - - index += 1; - } - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/softwares.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Logiciels", "softwares.xhtml"); - result = WebCharterView.build(content, trail); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building softwares page: " + exception.getMessage(), exception); - } - - // - return result; - } - -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/UptimeView.java b/src/fr/devinsy/statoolinfos/htmlize/UptimeView.java deleted file mode 100644 index 60b1fdb..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/UptimeView.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2021-2022 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.time.DayOfWeek; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.Locale; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.Service; -import fr.devinsy.statoolinfos.core.Services; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.uptime.UptimeJournal; -import fr.devinsy.statoolinfos.uptime.UptimeStat; -import fr.devinsy.statoolinfos.uptime.UptimeStatus; -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class UptimeView. - */ -public class UptimeView -{ - private static Logger logger = LoggerFactory.getLogger(UptimeView.class); - - /** - * Gets the stat. - * - * @param services - * the services - * @param date - * the date - * @return the stat - */ - public static UptimeStat getStat(final UptimeJournal journal, final Services services, final LocalDate date) - { - UptimeStat result; - - result = new UptimeStat(); - - if ((services != null) || (date != null)) - { - for (Service service : services.sortByName()) - { - UptimeStat stat = journal.getStat(service.getWebsiteURL(), date); - if (stat.getStatus() == UptimeStatus.OK) - { - result.incOk(); - } - else if (stat.getStatus() == UptimeStatus.WARNING) - { - result.incWarning(); - } - else if (stat.getStatus() == UptimeStatus.ALERT) - { - result.incAlert(); - } - else if (stat.getStatus() == UptimeStatus.ERROR) - { - result.incError(); - } - else if (stat.getStatus() == UptimeStatus.VOID) - { - result.incVoid(); - } - } - - if (result.getCount() == 0) - { - result.setStatus(UptimeStatus.VOID); - } - else if (result.getOkCount() != result.getCount()) - { - result.setStatus(UptimeStatus.ERROR); - } - else - { - result.setStatus(UptimeStatus.OK); - } - } - - // - return result; - } - - /** - * Htmlize. - * - * @param services - * the services - * @param journal - * the journal - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String htmlize(final Services services, final UptimeJournal journal) throws StatoolInfosException - { - String result; - - try - { - TagDataManager data = new TagDataManager(); - - LocalDate now = LocalDate.now(); - - UptimeStat last = getStat(journal, services, now); - - data.setContent("okCount", last.getOkCount()); - data.setContent("warningCount", last.getWarningCount()); - data.setContent("alertCount", last.getAlertCount()); - data.setContent("errorCount", last.getErrorCount()); - data.setContent("voidCount", last.getVoidCount()); - data.setContent("unavailableCount", last.getUnavailableCount()); - - for (int dayCount = 0; dayCount < 22; dayCount++) - { - LocalDate date = now.minusDays(dayCount); - - // - data.setContent("lineHeader-" + dayCount, StringUtils.capitalize(date.format(DateTimeFormatter.ofPattern("EEEE", Locale.FRENCH)).substring(0, 2))); - data.setAttribute("lineHeader-" + dayCount, "title", date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))); - - DayOfWeek weekDay = date.getDayOfWeek(); - if ((weekDay == DayOfWeek.SUNDAY) || (weekDay == DayOfWeek.SATURDAY)) - { - data.setAttribute("lineHeader-" + dayCount, "style", "background-color: gainsboro;"); - } - else - { - data.setAttribute("lineHeader-" + dayCount, "style", "background-color: #ececec;"); - } - } - - int index = 0; - for (Service service : services.sortByName()) - { - // - data.setAttribute("line", index, "lineLogo", "src", service.getLogoFileName()); - data.setEscapedContent("line", index, "lineNameValue", service.getName()); - data.setAttribute("line", index, "lineNameLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); - - data.setAttribute("line", index, "lineOrganizationLink", "href", service.getOrganization().getTechnicalName() + ".xhtml"); - data.setAttribute("line", index, "lineOrganizationLogo", "src", service.getOrganization().getLogoFileName()); - data.setEscapedContent("line", index, "lineOrganizationValue", service.getOrganization().getName()); - - // - for (int dayCount = 0; dayCount < 22; dayCount++) - { - LocalDate date = now.minusDays(dayCount); - - // - DayOfWeek weekDay = date.getDayOfWeek(); - if ((weekDay == DayOfWeek.SUNDAY) || (weekDay == DayOfWeek.SATURDAY)) - { - data.setAttribute("line", index, "uptime-" + dayCount, "style", "background-color: gainsboro;"); - } - - // - UptimeStat stat = journal.getStat(service.getWebsiteURL(), date); - StringList lines = new StringList(); - String header = String.format("%d ok + %d err", stat.getOkCount(), stat.getErrorCount()); - lines.add(header); - header = date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")); - lines.add(header); - if (stat.getErrorCount() > 0) - { - lines.addAll(journal.getUptimes(service.getWebsiteURL(), date).toTimeList()); - } - - data.setAttribute("line", index, "statusImg-" + dayCount, "src", "status-" + stat.getStatus().toString().toLowerCase() + ".png"); - // String title = String.format("%d ok + %d err %s", - // stat.getOkCount(), stat.getErrorCount(), - // date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy"))); - data.setAttribute("line", index, "statusImg-" + dayCount, "title", lines.toStringSeparatedBy(" ")); - } - - // - index += 1; - } - - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/uptimeView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(content); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building about page: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/WebCharterView.java b/src/fr/devinsy/statoolinfos/htmlize/WebCharterView.java deleted file mode 100644 index 85dbbfd..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/WebCharterView.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2020 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.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Locale; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.HtmlizerContext; -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.statoolinfos.util.BuildInformation; -import fr.devinsy.xidyn.XidynException; -import fr.devinsy.xidyn.data.TagDataManager; -import fr.devinsy.xidyn.presenters.PresenterUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class WebCharterView. - */ -public class WebCharterView -{ - private static Logger logger = LoggerFactory.getLogger(WebCharterView.class); - - /** - * Builds the. - * - * @param content - * the content - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String build(final String content) throws StatoolInfosException - { - String result; - - result = build(content, new BreadcrumbTrail()); - - // - return result; - } - - /** - * Builds the. - * - * @param content - * the content - * @param trail - * the trail - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String build(final String content, final BreadcrumbTrail trail) throws StatoolInfosException - { - String result; - - try - { - logger.debug("Building WebCharterView."); - - TagDataManager data = new TagDataManager(); - - data.setContent("federationButton", HtmlizerContext.instance().getFederation().getName()); - data.setContent("versionsup", BuildInformation.instance().version()); - data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE))); - data.setContent("webCharterContent", XidynUtils.extractBodyContent(content)); - data.setContent("breadcrumbTrail", trail.toString()); - data.setAttribute("federationStatsButton", "href", HtmlizerContext.instance().getFederation().getTechnicalName() + "-stats.xhtml"); - - result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml", data).toString(); - } - catch (XidynException exception) - { - throw new StatoolInfosException("Error building webCharter view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/about.xhtml b/src/fr/devinsy/statoolinfos/htmlize/about.xhtml deleted file mode 100644 index 163cd52..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/about.xhtml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - StatoolInfos - - - - - - - -

Introduction

-

StatoolInfos is a simple tool of statistics about federation, organizations and services.

- -

License and source repository

-

The original author of StatoolInfos is Christian P. MOMON.

-

StatoolInfo is a free software released under the GNU AGPL license.

-

The official source repository is:

- -

Contributors: Angie, MrFlos, Quentin Duchemin, Fabrice61, Thomas @TConstans, @labecasse, Antoine Jaba, @setop, Jérémy Collot, - Pilou, Kepon, Laurent Sleto…

- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/categories.xhtml b/src/fr/devinsy/statoolinfos/htmlize/categories.xhtml deleted file mode 100644 index 6006726..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/categories.xhtml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
-

Catégories

- -
n/a catégories
-
- - - - - - - - - - - - - - - - - - - - - -
Nom de la catégorieLogicielsServicesOrganisationsUtilisateurs mensuelsVisites mensuelles
- - - n/a - - n/an/an/an/an/a
-
- - - diff --git a/src/fr/devinsy/statoolinfos/htmlize/categoriesView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/categoriesView.xhtml deleted file mode 100644 index ad0a325..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/categoriesView.xhtml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - StatoolInfos - - - - - - - - - diff --git a/src/fr/devinsy/statoolinfos/htmlize/category.xhtml b/src/fr/devinsy/statoolinfos/htmlize/category.xhtml deleted file mode 100644 index 3bb395a..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/category.xhtml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
-
- -
-
-
n/a
- - -
-
-
Logiciels : n/a
-
Nombre de services : n/a
-
-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChart.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarChart.java deleted file mode 100644 index 46d2ba2..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChart.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (C) 2020-2023 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.charts; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.strings.StringList; - -/** - * The Class BarChart. - */ -public class BarChart -{ - private static Logger logger = LoggerFactory.getLogger(BarChart.class); - - private String title; - private boolean displayTitle; - private StringList labels; - private BarChartDatasets datasets; - private boolean stacked; - private boolean animated; - - /** - * Instantiates a new bar chart. - * - * @param title - * the title - */ - public BarChart(final String title) - { - this.title = title; - this.displayTitle = true; - this.labels = new StringList(); - this.datasets = new BarChartDatasets(); - this.stacked = false; - this.animated = true; - } - - /** - * Adds the. - * - * @param datasetIndex - * the dataset index - * @param value - * the value - * @param color - * the color - */ - public void add(final int datasetIndex, final double value, final ChartColor color) - { - this.datasets.get(datasetIndex).add(new BarChartData(null, value, color)); - } - - /** - * Adds the. - * - * @param label - * the label - * @param value - * the value - * @param color - * the color - */ - public void add(final String label, final double value, final ChartColor color) - { - this.labels.add(label); - this.datasets.get(0).add(new BarChartData(label, value, color)); - } - - /** - * Adds the dataset. - * - * @param name - * the name - * @return the int - */ - public int addDataset(final String name) - { - int result; - - this.datasets.add(new BarChartDataset(name)); - - result = this.datasets.size() - 1; - - // - return result; - } - - /** - * Gets the colors. - * - * @return the colors - */ - public ChartColors getColors() - { - ChartColors result; - - result = this.datasets.get(0).getColors(); - - // - return result; - } - - /** - * Gets the dataset. - * - * @param index - * the index - * @return the dataset - */ - public BarChartDataset getDataset(final int index) - { - BarChartDataset result; - - result = this.datasets.get(index); - - // - return result; - } - - /** - * Gets the datasets. - * - * @return the datasets - */ - public BarChartDatasets getDatasets() - { - return this.datasets; - } - - /** - * Gets the labels. - * - * @return the labels - */ - public StringList getLabels() - { - StringList result; - - result = this.labels; - - // - return result; - } - - /** - * Gets the title. - * - * @return the title - */ - public String getTitle() - { - return this.title; - } - - /** - * Checks if is animated. - * - * @return true, if is animated - */ - public boolean isAnimated() - { - return this.animated; - } - - /** - * Checks if is display title. - * - * @return true, if is display title - */ - public boolean isDisplayTitle() - { - return this.displayTitle; - } - - /** - * Checks if is stacked. - * - * @return true, if is stacked - */ - public boolean isStacked() - { - return this.stacked; - } - - /** - * Sets the animated. - * - * @param animated - * the new animated - */ - public void setAnimated(final boolean animated) - { - this.animated = animated; - } - - public void setDisplayTitle(final boolean displayTitle) - { - this.displayTitle = displayTitle; - } - - public void setStacked(final boolean stacked) - { - this.stacked = stacked; - } - - public void setTitle(final String title) - { - this.title = title; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartData.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartData.java deleted file mode 100644 index 4bc2f6e..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartData.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2020-2023 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.charts; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class BarChartData. - */ -public class BarChartData -{ - private static Logger logger = LoggerFactory.getLogger(BarChartData.class); - - private String label; - private double value; - private ChartColor color; - - /** - * Instantiates a new pie chart data. - * - * @param label - * the label - * @param value - * the value - * @param color - * the color - */ - public BarChartData(final String label, final double value, final ChartColor color) - { - this.label = label; - this.value = value; - this.color = color; - } - - /** - * Gets the color. - * - * @return the color - */ - public ChartColor getColor() - { - return this.color; - } - - /** - * Gets the label. - * - * @return the label - */ - public String getLabel() - { - return this.label; - } - - /** - * Gets the value. - * - * @return the value - */ - public double getValue() - { - return this.value; - } - - /** - * Sets the color. - * - * @param color - * the new color - */ - public void setColor(final ChartColor color) - { - this.color = color; - } - - /** - * Sets the label. - * - * @param label - * the new label - */ - public void setLabel(final String label) - { - this.label = label; - } - - /** - * Sets the value. - * - * @param value - * the new value - */ - public void setValue(final double value) - { - this.value = value; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartDataset.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartDataset.java deleted file mode 100644 index b9579a9..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartDataset.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2020-2023 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.charts; - -import java.util.ArrayList; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class BarChartDataset. - */ -public class BarChartDataset extends ArrayList -{ - private static final long serialVersionUID = -5230173915580487951L; - private static Logger logger = LoggerFactory.getLogger(BarChartDataset.class); - - private String name; - private int borderWidth; - - /** - * Instantiates a new bar chart dataset. - * - * @param name - * the name - */ - public BarChartDataset(final String name) - { - super(); - this.name = name; - this.borderWidth = 1; - } - - /** - * Gets the border width. - * - * @return the border width - */ - public int getBorderWidth() - { - return this.borderWidth; - } - - /** - * Gets the colors. - * - * @return the colors - */ - public ChartColors getColors() - { - ChartColors result; - - result = new ChartColors(); - - for (BarChartData data : this) - { - result.add(data.getColor()); - } - - // - return result; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() - { - return this.name; - } - - /** - * Gets the values. - * - * @return the values - */ - public double[] getValues() - { - double[] result; - - result = new double[this.size()]; - - int index = 0; - for (BarChartData data : this) - { - result[index] = data.getValue(); - index += 1; - } - - // - return result; - } - - /** - * Sets the border width. - * - * @param borderWidth - * the new border width - */ - public void setBorderWidth(final int borderWidth) - { - this.borderWidth = borderWidth; - } - - /** - * Sets the name. - * - * @param name - * the new name - */ - public void setName(final String name) - { - this.name = name; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartDatasets.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartDatasets.java deleted file mode 100644 index 648d8f6..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartDatasets.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2020-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.charts; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class BarChartDatasets. - */ -public class BarChartDatasets extends ArrayList -{ - private static final long serialVersionUID = 306645976348400468L; - - private static Logger logger = LoggerFactory.getLogger(BarChartDatasets.class); - - /** - * Instantiates a new bar chart datasets. - */ - public BarChartDatasets() - { - super(); - } - - /** - * Gets the by name. - * - * @param name - * the name - * @return the by name - */ - public BarChartDataset get(final String name) - { - BarChartDataset result; - - boolean ended = false; - result = null; - Iterator iterator = this.iterator(); - while (!ended) - { - if (iterator.hasNext()) - { - BarChartDataset dataset = iterator.next(); - if (StringUtils.equals(dataset.getName(), name)) - { - ended = true; - result = dataset; - } - } - else - { - ended = true; - result = null; - } - } - - // - return result; - } - -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartView.java deleted file mode 100644 index 5fe83a5..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartView.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2020 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.charts; - -import java.io.IOException; - -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class BarChartView. - */ -public class BarChartView -{ - private static Logger logger = LoggerFactory.getLogger(BarChartView.class); - - /** - * Builds the. - * - * @param chart - * the bar - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String build(final BarChart chart) throws StatoolInfosException - { - String result; - - try - { - String source = XidynUtils.load(BarChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/barChartView.xhtml")); - result = XidynUtils.extractBodyContent(source); - - result = result.replace("myChart", "myChart_" + DigestUtils.sha1Hex(chart.getTitle() + "barChart" + RandomStringUtils.random(10))); - - StringList lines = new StringList(); - lines.append("{\n"); - lines.append(" type: 'bar',\n"); - lines.append(" data: \n"); - lines.append(" {\n"); - lines.append(" labels: ").append(ChabuUtils.toJSonStrings(chart.getLabels())).appendln(","); - lines.append(" datasets: \n"); - lines.append(" [\n"); - for (BarChartDataset dataset : chart.getDatasets()) - { - lines.append(" {\n"); - lines.append(" label: '").append(escape(dataset.getName())).appendln("',"); - lines.append(" data: ").append(ChabuUtils.toJSonNumbers(dataset.getValues())).appendln(","); - lines.append(" backgroundColor: ").append(ChabuUtils.toJSonStrings(dataset.getColors().getCodes())).appendln(","); - lines.append(" borderColor: ").append(ChabuUtils.toJSonStrings(dataset.getColors().getLights())).appendln(","); - lines.append(" borderWidth: ").append(dataset.getBorderWidth()).appendln(","); - lines.append(" },\n"); - } - lines.append(" ]\n"); - lines.append(" },\n"); - lines.append(" options: \n"); - lines.append(" {\n"); - lines.append(" maintainAspectRatio: false,\n"); - lines.append(" display: true,\n"); - lines.append(" responsive: true,\n"); - lines.append(" legend: \n"); - lines.append(" {\n"); - lines.append(" display: false,\n"); - lines.append(" position: 'top',\n"); - lines.append(" },\n"); - lines.append(" title:\n"); - lines.append(" {\n"); - lines.append(" display: true,\n"); - lines.append(" text: '").append(escape(chart.getTitle())).appendln("'"); - lines.append(" },\n"); - lines.append(" tooltips:\n"); - lines.append(" {\n"); - lines.append(" mode: 'index',\n"); - lines.append(" intersect: false\n"); - lines.append(" },\n"); - lines.append(" scales: \n"); - lines.append(" {\n"); - lines.append(" xAxes:\n"); - lines.append(" [{\n"); - lines.append(" ticks:\n"); - lines.append(" {\n"); - lines.append(" beginAtZero: true\n"); - lines.append(" },\n"); - lines.append(" stacked: ").append(chart.isStacked()).appendln(","); - lines.append(" }],\n"); - lines.append(" yAxes:\n"); - lines.append(" [{\n"); - lines.append(" ticks:\n"); - lines.append(" {\n"); - lines.append(" beginAtZero: true,\n"); - lines.append(" suggestedMax: 10,\n"); - lines.append(" precision: 0,\n"); - lines.append(" callback: function(value, index, values)"); - lines.append(" {\n"); - lines.append( - " if (value > 1000000000) return value/1000000000 + 'G'; else if (value > 1000000) return value/1000000 + 'M'; else if (value > 1000) return value/1000 + 'k';else return value;\n"); - lines.append(" }\n"); - lines.append(" },\n"); - lines.append(" stacked: ").append(chart.isStacked()).appendln(","); - lines.append(" }]\n"); - lines.append(" },\n"); - lines.append(" animation:\n"); - lines.append(" {\n"); - lines.append(" duration: ").append(chart.isAnimated() ? 1000 : 0).appendln(); - lines.append(" }\n"); - lines.append(" }\n"); - lines.append("}"); - - result = result.replaceFirst("\\{[\\s\\S]*\\}", lines.toString()); - } - catch (IOException exception) - { - throw new StatoolInfosException("Error building bar months chart view: " + exception.getMessage(), exception); - } - - // - return result; - } - - /** - * Escape. - * - * @param input - * the input - * @return the string - */ - public static String escape(final String input) - { - String result; - - if (StringUtils.isBlank(input)) - { - result = ""; - } - else - { - result = input.replace("'", "\\\\'"); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/ChabuUtils.java b/src/fr/devinsy/statoolinfos/htmlize/charts/ChabuUtils.java deleted file mode 100644 index 4ebd198..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/ChabuUtils.java +++ /dev/null @@ -1,718 +0,0 @@ -/* - * Copyright (C) 2020-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.charts; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Date; -import java.util.Iterator; -import java.util.Locale; - -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.math.NumberUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.strings.StringList; -import fr.devinsy.strings.StringsUtils; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class ChabuUtils. - */ -public class ChabuUtils -{ - private static Logger logger = LoggerFactory.getLogger(ChabuUtils.class); - - public static final DateTimeFormatter PATTERN_SHORTDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy", Locale.FRANCE); - public static final DateTimeFormatter PATTERN_LONGDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE); - - /** - * Builds the month labels. - * - * @param start - * the start - * @param end - * the end - * @return the string list - */ - public static StringList buildMonthLabels(final LocalDate start, final LocalDate end) - { - StringList result; - - result = new StringList(); - - if (start != null) - { - LocalDate normalizedEnd = normaliseMonthDate(end); - LocalDate date = normaliseMonthDate(start); - while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) - { - String label = date.format(DateTimeFormatter.ISO_DATE); - result.add(label); - date = date.plusMonths(1); - } - } - - // - return result; - } - - /** - * Builds the week labels. - * - * @param start - * the start - * @return the string list - */ - public static StringList buildWeekLabels(final LocalDate start) - { - StringList result; - - result = buildWeekLabels(start, LocalDate.now()); - - // - return result; - } - - /** - * Builds the week labels. - * - * @param start - * the start - * @param end - * the end - * @return the string list - */ - public static StringList buildWeekLabels(final LocalDate start, final LocalDate end) - { - StringList result; - - result = new StringList(); - - if (start != null) - { - LocalDate normalizedEnd = normaliseWeekDate(end); - LocalDate date = normaliseWeekDate(start); - while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) - { - String label = date.format(DateTimeFormatter.ISO_DATE); - result.add(label); - date = date.plusWeeks(1); - } - } - - // - return result; - } - - /** - * Builds the year month alpha labels. - * - * @param start - * the start - * @param end - * the end - * @return the string list - */ - public static StringList buildYearMonthAlphaLabels(final LocalDate start, final LocalDate end) - { - StringList result; - - result = new StringList(); - - if (start != null) - { - LocalDate normalizedEnd = normaliseMonthDate(end); - LocalDate date = normaliseMonthDate(start); - while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) - { - String label = date.format(DateTimeFormatter.ofPattern("YYYY-MMM", Locale.FRANCE)); - result.add(label); - date = date.plusMonths(1); - } - } - - // - return result; - } - - /** - * Builds the year month labels. - * - * @param start - * the start - * @param end - * the end - * @return the string list - */ - public static StringList buildYearMonthLabels(final LocalDate start, final LocalDate end) - { - StringList result; - - result = new StringList(); - - if (start != null) - { - LocalDate normalizedEnd = normaliseMonthDate(end); - LocalDate date = normaliseMonthDate(start); - while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) - { - String label = date.format(DateTimeFormatter.ofPattern("YYYY-MM", Locale.FRANCE)); - result.add(label); - date = date.plusMonths(1); - } - } - - // - return result; - } - - /** - * Escape JSONXML. - * - * @param data - * the data - * @return the string - */ - public static String escapeJSONXML(final String data) - { - String result; - - if (data == null) - { - result = null; - } - else - { - result = XidynUtils.escapeXmlBlank(data.replace("'", "\\\\'")); - } - - // - return result; - } - - /** - * Normalise month date. - * - * @param source - * the source - * @return the local date - */ - public static LocalDate normaliseMonthDate(final LocalDate source) - { - LocalDate result; - - if (source == null) - { - result = source; - } - else - { - result = source.minusDays(source.getDayOfMonth() - 1); - } - - // - return result; - } - - /** - * Normalise week date. - * - * @param source - * the source - * @return the local date - */ - public static LocalDate normaliseWeekDate(final LocalDate source) - { - LocalDate result; - - if (source == null) - { - result = source; - } - else - { - result = source.minusDays(source.getDayOfWeek().getValue() - 1); - } - - // - return result; - } - - /** - * Normalized month count list. - * - * @param source - * the source - * @param start - * the start - * @param end - * the end - * @return the date count list - */ - public static DateCountList normalizedMonthCountList(final DateCountList source, final LocalDate start, final LocalDate end) - { - DateCountList result; - - result = new DateCountList(); - - LocalDate normalizedEnd = normaliseMonthDate(end); - LocalDate date = normaliseMonthDate(start); - int index = source.indexOf(toYearMonth(start)); - if (index == -1) - { - index = 0; - } - while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) - { - String dateToken = toYearMonth(date); - long count; - if (index < source.size()) - { - DateCount current = source.get(index); - // ChabuUtils.logger.info("===> " + dateToken + " " + - // current.getDate()); - if (StringUtils.equals(current.getDate(), dateToken)) - { - count = current.getCount(); - index += 1; - } - else - { - count = 0; - } - } - else - { - count = 0; - } - result.add(new DateCount(dateToken, count)); - date = date.plusMonths(1); - } - - // - return result; - } - - /** - * Normalized week count list. - * - * @param source - * the source - * @param start - * the start - * @param end - * the end - * @return the date count list - */ - public static DateCountList normalizedWeekCountList(final DateCountList source, final LocalDate start, final LocalDate end) - { - DateCountList result; - - result = new DateCountList(); - - LocalDate normalizedEnd = normaliseWeekDate(end); - LocalDate date = normaliseWeekDate(start); - int index = source.indexOf(toYearWeek(start)); - if (index == -1) - { - index = 0; - } - while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) - { - String dateToken = toYearWeek(date); - long count; - if (index < source.size()) - { - DateCount current = source.get(index); - // AgirStatoolUtils.logger.info("===> " + dateToken + " " + - // current.getDate()); - if (StringUtils.equals(current.getDate(), dateToken)) - { - count = current.getCount(); - index += 1; - } - else - { - count = 0; - } - } - else - { - count = 0; - } - result.add(new DateCount(dateToken, count)); - date = date.plusWeeks(1); - } - - // - return result; - } - - /** - * Builds the week created count list. - * - * @param source - * the source - * @param start - * the start - * @return the date count list - */ - public static DateCountList normalizedWeekCountList(final DateCountMap source, final LocalDate start) - { - DateCountList result; - - result = new DateCountList(); - - LocalDate date = normaliseWeekDate(start); - LocalDate end = normaliseWeekDate(LocalDate.now()); - long count = 0; - while (date.isBefore(end) || date.isEqual(end)) - { - String dateToken = toYearWeek(date); - DateCount current = source.get(dateToken); - if (current != null) - { - count += current.getCount(); - } - result.add(new DateCount(dateToken, count)); - date = date.plusWeeks(1); - } - - // - return result; - } - - /** - * Gets the current time in long format. - * - * @return the long - */ - public static long now() - { - return new Date().getTime(); - } - - /** - * Select stat indicator. - * - * @param value - * the value - * @return the string - */ - public static String selectStatIndicator(final long value) - { - String result; - - if (value < 10) - { - result = null; - } - else if (value < 20) - { - result = "caution"; - } - else if (value < 50) - { - result = "warning"; - } - else - { - result = "alert"; - } - - // - return result; - } - - /** - * Select unassigned indicator. - * - * @param value - * the value - * @return the string - */ - public static String selectUnassignedIndicator(final long value) - { - String result; - - if (value == 0) - { - result = null; - } - else - { - result = "alert"; - } - - // - return result; - } - - /** - * To human long. - * - * @param value - * the value - * @return the string - */ - public static String toHumanLong(final LocalDateTime value) - { - String result; - - result = toHumanLong(value, null); - - // - return result; - } - - /** - * To human long. - * - * @param value - * the value - * @param defaultValue - * the default value - * @return the string - */ - public static String toHumanLong(final LocalDateTime value, final String defaultValue) - { - String result; - - if (value == null) - { - result = null; - } - else - { - result = value.format(PATTERN_LONGDATE); - } - - // - return result; - } - - /** - * To human short. - * - * @param value - * the value - * @return the string - */ - public static String toHumanShort(final LocalDateTime value) - { - String result; - - result = toHumanShort(value, null); - - // - return result; - } - - /** - * To human short. - * - * @param value - * the value - * @param defaultValue - * the default value - * @return the string - */ - public static String toHumanShort(final LocalDateTime value, final String defaultValue) - { - String result; - - if (value == null) - { - result = null; - } - else - { - result = value.format(PATTERN_SHORTDATE); - } - - // - return result; - } - - public static Integer toInteger(final String value) - { - Integer result; - - if ((value == null) || (!NumberUtils.isDigits(value))) - { - result = null; - } - else - { - result = Integer.parseInt(value); - } - - // - return result; - } - - /** - * To J son numbers. - * - * @param values - * the values - * @return the string - */ - public static String toJSonNumbers(final double[] values) - { - String result; - - StringList data = new StringList(values); - result = toJSonNumbers(data); - - // - return result; - } - - /** - * To J son numbers. - * - * @param values - * the values - * @return the string - */ - public static String toJSonNumbers(final StringList values) - { - String result; - - result = StringsUtils.toString(values, "[", ",", "]"); - - // - return result; - } - - /** - * To J son numbers. - * - * @param labels - * the labels - * @param values - * the source - * @return the string - */ - public static String toJSonNumbers(final StringList labels, final StringList values) - { - String result; - - Iterator labelIterator = labels.iterator(); - Iterator valueIterator = values.iterator(); - - StringList buffer = new StringList(); - while (labelIterator.hasNext()) - { - String label = labelIterator.next(); - String value = valueIterator.next(); - - buffer.append(String.format("{t: '%s', y: %s}", label, value)); - } - result = StringsUtils.toString(buffer, "[", ",", "]"); - - // - return result; - } - - /** - * To Json strings. - * - * @param source - * the source - * @return the string - */ - public static String toJSonStrings(final StringList source) - { - String result; - - StringList target = new StringList(); - - target.append("["); - for (String string : source) - { - target.append("'"); - target.append(escapeJSONXML(string)); - target.append("'"); - target.append(","); - } - if (!source.isEmpty()) - { - target.removeLast(); - } - target.append("]"); - - result = target.toString(); - - // - return result; - } - - /** - * To year month. - * - * @param source - * the source - * @return the string - */ - public static String toYearMonth(final LocalDate source) - { - String result; - - if (source == null) - { - result = null; - } - else - { - result = source.format(DateTimeFormatter.ofPattern("YYYYMM", Locale.FRANCE)); - } - - // - return result; - } - - /** - * To year week. - * - * @param source - * the source - * @return the string - */ - public static String toYearWeek(final LocalDate source) - { - String result; - - if (source == null) - { - result = null; - } - else - { - result = source.format(DateTimeFormatter.ofPattern("YYYYww", Locale.FRANCE)); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/ChartColor.java b/src/fr/devinsy/statoolinfos/htmlize/charts/ChartColor.java deleted file mode 100644 index add4f9e..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/ChartColor.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2020-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.charts; - -/** - * The Enum ChartColor. - */ -public enum ChartColor -{ - // https://html-color-codes.info/ - - GREEN0("rgb(0, 128, 0)"), // #008000 - GREEN("rgb(75, 192, 192)"), // #4bc0c0 - YELLOW("rgb(255, 205, 86)"), // #ffcd56 - ORANGE("rgb(255, 159, 64)"), // #ff9f40 - RED("rgb(255, 99, 132)"), // #ff6384 - HOTPINK("rgb(255, 105, 180)"), // #FF69B4 - VIOLET("rgb(190,129,247)"), // #be81f7 - PURPLE("rgb(153, 102, 255)"), // #9966ff - BLUE("rgb(54, 162, 235)"), // #36a2eb - TURQUOISE("rgb(64, 224, 208)"), // #40e0d0 - GREY("rgb(201, 203, 207)"); // #c9cbcf - - private String code; - private String light; - - /** - * Instantiates a new chart colors. - * - * @param code - * the code - */ - ChartColor(final String code) - { - this.code = code; - this.light = code.replace(")", ", 0.2)"); - } - - /** - * Code. - * - * @return the string - */ - public String code() - { - String result; - - result = this.code; - - // - return result; - } - - /** - * Light. - * - * @return the string - */ - public String light() - { - String result; - - result = this.light; - - // - return result; - } - - /** - * To list. - * - * @return the chart colors - */ - public static ChartColors valueList() - { - ChartColors result; - - result = new ChartColors(); - ChartColor[] values = values(); - for (int index = 0; index < values.length; index++) - { - result.add(values[index]); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/ChartColors.java b/src/fr/devinsy/statoolinfos/htmlize/charts/ChartColors.java deleted file mode 100644 index 5088688..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/ChartColors.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2020 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.charts; - -import java.util.ArrayList; - -import fr.devinsy.strings.StringList; - -/** - * The Class ChartColors. - */ -public class ChartColors extends ArrayList -{ - private static final long serialVersionUID = -8084994308407843536L; - - /** - * Instantiates a new chart colors. - */ - public ChartColors() - { - super(); - } - - /** - * Adds the all. - * - * @param colors - * the colors - */ - public void addAll(final ChartColor[] colors) - { - for (int index = 0; index < colors.length; index++) - { - add(colors[index]); - } - } - - /** - * Gets the ChartColor of the index with safe overflow. - * - * @param index - * the index - * @return the chart color - */ - @Override - public ChartColor get(final int index) - { - ChartColor result; - - result = super.get(index % size()); - - // - return result; - } - - /** - * Gets the colors. - * - * @return the colors - */ - public StringList getCodes() - { - StringList result; - - result = new StringList(); - - for (ChartColor color : this) - { - result.add(color.code()); - } - - // - return result; - } - - /** - * Gets the light colors. - * - * @return the light colors - */ - public StringList getLights() - { - StringList result; - - result = new StringList(); - - for (ChartColor color : this) - { - result.add(color.light()); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/DateCount.java b/src/fr/devinsy/statoolinfos/htmlize/charts/DateCount.java deleted file mode 100644 index c558ddb..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/DateCount.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2020-2023 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.charts; - -import org.apache.commons.lang3.StringUtils; - -/** - * The Class Projects. - */ -public class DateCount -{ - private String date; - private long count; - - /** - * Instantiates a new date count. - * - * @param date - * the date - * @param count - * the count - */ - public DateCount(final String date, final long count) - { - setDate(date); - this.count = count; - } - - /** - * Gets the count. - * - * @return the count - */ - public long getCount() - { - return this.count; - } - - /** - * Gets the date. - * - * @return the date - */ - public String getDate() - { - return this.date; - } - - /** - * Sets the count. - * - * @param count - * the new count - */ - public void setCount(final long count) - { - this.count = count; - } - - /** - * Sets the date. - * - * @param date - * the new date - */ - public void setDate(final String date) - { - if (StringUtils.isBlank(date)) - { - throw new IllegalArgumentException("Null parameter."); - } - else - { - this.date = date; - } - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountList.java b/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountList.java deleted file mode 100644 index 0223d11..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountList.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2020 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.charts; - -import java.util.ArrayList; - -import org.apache.commons.lang3.StringUtils; - -import fr.devinsy.strings.StringList; - -/** - * The Class Projects. - */ -public class DateCountList extends ArrayList -{ - private static final long serialVersionUID = -5526492552751712533L; - - /** - * Instantiates a new date count map. - */ - public DateCountList() - { - super(); - } - - /** - * Instantiates a new date count list. - * - * @param capacity - * the capacity - */ - public DateCountList(final int capacity) - { - super(capacity); - } - - /** - * Indexof. - * - * @param dateToken - * the date token - * @return the int - */ - public int indexOf(final String dateToken) - { - int result; - - boolean ended = false; - result = -1; - int index = 0; - while (!ended) - { - if (index < this.size()) - { - DateCount current = get(index); - if (StringUtils.equals(current.getDate(), dateToken)) - { - ended = true; - result = index; - } - else - { - index += 1; - } - } - else - { - ended = true; - result = -1; - } - } - - // - return result; - } - - /** - * To value list. - * - * @return the string list - */ - public StringList toValueList() - { - StringList result; - - result = new StringList(); - - for (DateCount item : this) - { - result.append(item.getCount()); - } - - // - return result; - } -} \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountMap.java b/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountMap.java deleted file mode 100644 index 41224f6..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/DateCountMap.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2020 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.charts; - -import java.util.HashMap; - -/** - * The Class Projects. - */ -public class DateCountMap extends HashMap -{ - private static final long serialVersionUID = -5526492552751712533L; - - /** - * Instantiates a new date count map. - */ - public DateCountMap() - { - super(); - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/DoughnutChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/DoughnutChartView.java deleted file mode 100644 index 56c50c2..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/DoughnutChartView.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2020 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.charts; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.StatoolInfosException; - -/** - * The Class DoughnutChartView. - */ -public class DoughnutChartView -{ - private static Logger logger = LoggerFactory.getLogger(DoughnutChartView.class); - - /** - * Builds the. - * - * @param pie - * the pie - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String build(final PieChart pie) throws StatoolInfosException - { - String result; - - pie.setType(PieChart.PieType.DOUGHNUT); - result = PieChartView.build(pie); - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/FooChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/FooChartView.java deleted file mode 100644 index 1fce1f9..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/FooChartView.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2020 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.charts; - -import java.io.IOException; -import java.time.LocalDate; -import java.time.LocalDateTime; - -import org.apache.commons.codec.digest.DigestUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class projectsRawPageBuilder. - */ -public class FooChartView -{ - private static Logger logger = LoggerFactory.getLogger(FooChartView.class); - - public static String build() throws StatoolInfosException - { - String result; - - try - { - String source = XidynUtils.load(FooChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml")); - String code = XidynUtils.extractBodyContent(source); - - code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(LocalDateTime.now() + "lineChart")); - - // DO MonthsBarChart - - LocalDate start = LocalDate.parse("2020-01-01"); - LocalDate end = LocalDate.parse("2020-12-31"); - - DateCountList dates = new DateCountList(); - dates.add(new DateCount("202001", 7)); - dates.add(new DateCount("202002", 9)); - dates.add(new DateCount("202003", 4)); - dates.add(new DateCount("202004", 2)); - dates.add(new DateCount("202005", 1)); - dates.add(new DateCount("202006", 7)); - - StringList labels = ChabuUtils.buildYearMonthLabels(start, end); - StringList values = ChabuUtils.normalizedMonthCountList(dates, start, end).toValueList(); - code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values)); - - /* - StringList labels = ChabuUtils.buildWeekLabels(LocalDate.parse("2020-01-01"), LocalDate.parse("2020-12-31")); - DateCountList dates = project.issueStats().getWeekCreatedIssueCounts(); - StringList values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList(); - code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values)); - - dates = project.issueStats().getWeekConcludedIssueCounts(); - values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList(); - code = code.replaceAll("data: \\[.*\\] ", "data: " + ChabuUtils.toJSonNumbers(labels, values)); - */ - result = code.toString(); - } - catch (IOException exception) - { - throw new StatoolInfosException("Error building foo charts view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/LineMonthsChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/LineMonthsChartView.java deleted file mode 100644 index 4376522..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/LineMonthsChartView.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2020 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.charts; - -import java.io.IOException; -import java.time.LocalDate; -import java.time.LocalDateTime; - -import org.apache.commons.codec.digest.DigestUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class projectsRawPageBuilder. - */ -public class LineMonthsChartView -{ - private static Logger logger = LoggerFactory.getLogger(LineMonthsChartView.class); - - public static String build() throws StatoolInfosException - { - String result; - - try - { - String source = XidynUtils.load(LineMonthsChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml")); - String code = XidynUtils.extractBodyContent(source); - - code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(LocalDateTime.now() + "lineChart")); - - // DO MonthsBarChart - - LocalDate start = LocalDate.parse("2020-01-01"); - LocalDate end = LocalDate.parse("2020-12-31"); - - DateCountList dates = new DateCountList(); - dates.add(new DateCount("202001", 7)); - dates.add(new DateCount("202002", 9)); - dates.add(new DateCount("202003", 4)); - dates.add(new DateCount("202004", 2)); - dates.add(new DateCount("202005", 1)); - dates.add(new DateCount("202006", 7)); - - StringList labels = ChabuUtils.buildYearMonthLabels(start, end); - StringList values = ChabuUtils.normalizedMonthCountList(dates, start, end).toValueList(); - code = code.replaceFirst("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values)); - - /* - StringList labels = ChabuUtils.buildWeekLabels(LocalDate.parse("2020-01-01"), LocalDate.parse("2020-12-31")); - DateCountList dates = project.issueStats().getWeekCreatedIssueCounts(); - StringList values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList(); - code = code.replaceAll("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(labels, values)); - - dates = project.issueStats().getWeekConcludedIssueCounts(); - values = ChabuUtils.normalizedWeekCountList(dates, start, end).toValueList(); - code = code.replaceAll("data: \\[.*\\] ", "data: " + ChabuUtils.toJSonNumbers(labels, values)); - */ - result = code.toString(); - } - catch (IOException exception) - { - throw new StatoolInfosException("Error building foo charts view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/PieChart.java b/src/fr/devinsy/statoolinfos/htmlize/charts/PieChart.java deleted file mode 100644 index 3eb4d26..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/PieChart.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (C) 2020-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.charts; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.strings.StringList; - -/** - * The Class PieChart. - */ -public class PieChart -{ - private static Logger logger = LoggerFactory.getLogger(PieChart.class); - - public enum PieType - { - DOUGHNUT, - PIE - } - - public enum Position - { - TOP, - RIGHT, - BOTTOM, - LEFT - } - - private String title; - private boolean titleVisible; - private Position titlePosition; - private PieType type; - private PieChartDatas datas; - private boolean legendVisible; - private Position legendPosition; - - /** - * Instantiates a new pie chart. - */ - public PieChart(final String title) - { - this.title = title; - this.titleVisible = true; - this.titlePosition = Position.TOP; - this.type = PieType.PIE; - this.datas = new PieChartDatas(); - this.legendVisible = true; - this.legendPosition = Position.TOP; - } - - /** - * Adds the. - * - * @param label - * the label - * @param value - * the value - * @param color - * the color - */ - public void add(final String label, final double value, final ChartColor color) - { - this.datas.add(new PieChartData(label, value, color)); - } - - /** - * Gets the colors. - * - * @return the colors - */ - public StringList getColors() - { - StringList result; - - result = new StringList(); - - for (PieChartData data : this.datas) - { - result.add(data.getColor().code()); - } - - // - return result; - } - - public PieChartDatas getDatas() - { - return this.datas; - } - - /** - * Gets the labels. - * - * @return the labels - */ - public StringList getLabels() - { - StringList result; - - result = new StringList(); - - for (PieChartData data : this.datas) - { - result.add(data.getLabel()); - } - - // - return result; - } - - public Position getLegendPosition() - { - return this.legendPosition; - } - - /** - * Gets the legend position value. - * - * @return the legend position value - */ - public String getLegendPositionValue() - { - String result; - - result = this.legendPosition.toString().toLowerCase(); - - // - return result; - } - - public String getTitle() - { - return this.title; - } - - public Position getTitlePosition() - { - return this.titlePosition; - } - - /** - * Gets the title position value. - * - * @return the title position value - */ - public String getTitlePositionValue() - { - String result; - - result = this.titlePosition.toString().toLowerCase(); - - // - return result; - } - - public PieType getType() - { - return this.type; - } - - /** - * Gets the values. - * - * @return the values - */ - public double[] getValues() - { - double[] result; - - result = new double[this.datas.size()]; - - int index = 0; - for (PieChartData data : this.datas) - { - result[index] = data.getValue(); - index += 1; - } - - // - return result; - } - - public boolean isLegendVisible() - { - return this.legendVisible; - } - - public boolean isTitleVisible() - { - return this.titleVisible; - } - - public void setLegendPosition(final Position legendPosition) - { - this.legendPosition = legendPosition; - } - - public void setLegendVisible(final boolean legendVisible) - { - this.legendVisible = legendVisible; - } - - public void setTitle(final String title) - { - this.title = title; - } - - public void setTitlePosition(final Position titlePosition) - { - this.titlePosition = titlePosition; - } - - public void setTitleVisible(final boolean titleVisible) - { - this.titleVisible = titleVisible; - } - - public void setType(final PieType type) - { - this.type = type; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/PieChartData.java b/src/fr/devinsy/statoolinfos/htmlize/charts/PieChartData.java deleted file mode 100644 index 3eb42ce..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/PieChartData.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2020-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.charts; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class PieChartData. - */ -public class PieChartData -{ - private static Logger logger = LoggerFactory.getLogger(PieChartData.class); - - private String label; - private double value; - private ChartColor color; - - /** - * Instantiates a new pie chart data. - * - * @param label - * the label - * @param value - * the value - * @param color - * the color - */ - public PieChartData(final String label, final double value, final ChartColor color) - { - this.label = label; - this.value = value; - this.color = color; - } - - public ChartColor getColor() - { - return this.color; - } - - public String getLabel() - { - return this.label; - } - - public double getValue() - { - return this.value; - } - - public void setColor(final ChartColor color) - { - this.color = color; - } - - public void setLabel(final String label) - { - this.label = label; - } - - public void setValue(final double value) - { - this.value = value; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/PieChartDatas.java b/src/fr/devinsy/statoolinfos/htmlize/charts/PieChartDatas.java deleted file mode 100644 index ef23276..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/PieChartDatas.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2020 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.charts; - -import java.util.ArrayList; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class PieChartDatas. - */ -public class PieChartDatas extends ArrayList -{ - private static final long serialVersionUID = 6300072061870020566L; - - private static Logger logger = LoggerFactory.getLogger(PieChartDatas.class); - - /** - * Instantiates a new pie chart datas. - */ - public PieChartDatas() - { - super(); - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/PieChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/PieChartView.java deleted file mode 100644 index beba4c0..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/PieChartView.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2020 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.charts; - -import java.io.IOException; - -import org.apache.commons.codec.digest.DigestUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fr.devinsy.statoolinfos.core.StatoolInfosException; -import fr.devinsy.strings.StringList; -import fr.devinsy.xidyn.utils.XidynUtils; - -/** - * The Class PieChartView. - */ -public class PieChartView -{ - private static Logger logger = LoggerFactory.getLogger(PieChartView.class); - - /** - * Builds the. - * - * @param pie - * the pie - * @return the string - * @throws StatoolInfosException - * the statool infos exception - */ - public static String build(final PieChart pie) throws StatoolInfosException - { - String result; - try - { - String source = XidynUtils.load(PieChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/pieChartView.xhtml")); - result = XidynUtils.extractBodyContent(source); - - result = result.replaceFirst("type: '.*'", "type: '" + pie.getType().toString().toLowerCase() + "'"); - result = result.replace("myChart", "myChart_" + DigestUtils.sha1Hex(pie.getTitle() + "PieChart")); - result = result.replaceFirst("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(new StringList(pie.getValues()))); - result = result.replaceFirst("backgroundColor: \\[.*\\]", "backgroundColor: " + ChabuUtils.toJSonStrings(pie.getColors())); - result = result.replaceFirst("text: '.*'", "text: '" + pie.getTitle().replace("'", "\\\\'") + "'"); - result = result.replaceFirst("labels: \\[.*\\]", "labels: " + ChabuUtils.toJSonStrings(pie.getLabels())); - result = result.replaceFirst("legend: .*,", String.format("legend: { display: %b, position: '%s' },", pie.isLegendVisible(), pie.getLegendPositionValue())); - result = result.replaceFirst("title: .*,", - String.format("title: { display: %b, position: '%s', text: '%s' },", pie.isTitleVisible(), pie.getTitlePositionValue(), pie.getTitle().replace("'", "\\\\'"))); - } - catch (IOException exception) - { - throw new StatoolInfosException("Error building bar months chart view: " + exception.getMessage(), exception); - } - - // - return result; - } -} diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/barChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/barChartView.xhtml deleted file mode 100644 index fe56e82..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/barChartView.xhtml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - StatoolInfos - - - - - - - - - - - - - - diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/barMonthsChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/barMonthsChartView.xhtml deleted file mode 100644 index d5baa8b..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/barMonthsChartView.xhtml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - StatoolInfos - - - - - - - - - - -
- - -
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/barTimeChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/barTimeChartView.xhtml deleted file mode 100644 index c31d893..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/barTimeChartView.xhtml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - StatoolInfos - - - - - - - - - - -
- - -
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml deleted file mode 100644 index 0763576..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/foo.xhtml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - StatoolInfos - - - - - - - - - - -
- - -
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml deleted file mode 100644 index ff4bb0b..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/lineMonthsChartView.xhtml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - StatoolInfos - - - - - - - - - - -
- - -
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/lineWeeksChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/lineWeeksChartView.xhtml deleted file mode 100644 index 0763576..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/lineWeeksChartView.xhtml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - StatoolInfos - - - - - - - - - - -
- - -
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/pieChartView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/charts/pieChartView.xhtml deleted file mode 100644 index c34f638..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/pieChartView.xhtml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - StatoolInfos - - - - - - - - - - - - - - diff --git a/src/fr/devinsy/statoolinfos/htmlize/crawlJournalView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/crawlJournalView.xhtml deleted file mode 100644 index b55d481..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/crawlJournalView.xhtml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
-

Journal des téléchargements

-
Nombre de téléchargements : n/a
-
Nombre d'erreurs : n/a
-
Date : n/a
-
-
-
- Tout - Erreurs -
-
- - - - - - - - - - - - - - - -
ParentURLStatut
n/an/an/a
-
-
- - - diff --git a/src/fr/devinsy/statoolinfos/htmlize/edito.xhtml b/src/fr/devinsy/statoolinfos/htmlize/edito.xhtml deleted file mode 100644 index 38eb200..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/edito.xhtml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-

Édito

-

Ceci est un édito par défaut.

-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/exports.xhtml b/src/fr/devinsy/statoolinfos/htmlize/exports.xhtml deleted file mode 100644 index 37bc43f..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/exports.xhtml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-

Exports

-
-
-
-
La fédération :
-
-
-
-
-
-
-
Les organisations :
-
-
-
-
-
-
-
Les services :
-
-
-
-
-
-
-
Disponibilités services :
-
-
-
-
-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml deleted file mode 100644 index 3a6052f..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml deleted file mode 100644 index 0be754c..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
-
- -
-
- - -
-

Description absente…

-
Depuis n/a
- -
-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationOrganizations.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationOrganizations.xhtml deleted file mode 100644 index 3a6052f..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/federationOrganizations.xhtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml deleted file mode 100644 index 2e6792a..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
- -
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml deleted file mode 100644 index 9e4607f..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/federationServices.xhtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml deleted file mode 100644 index f858b04..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
-

Statistiques

-

Les graphiques ci-dessous sont générés à partir de données déclarées et potentiellement partielles.

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml deleted file mode 100644 index d97da95..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml deleted file mode 100644 index 9092941..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
- -
- Vue - Années - Mois - Semaines - Jours -
-
- Période - Tout - 12 mois - 2021 - 2022 -
-
- - - - diff --git a/src/fr/devinsy/statoolinfos/htmlize/organization.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organization.xhtml deleted file mode 100644 index fb594f2..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/organization.xhtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml deleted file mode 100644 index dca4416..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
-
- -
-
- - -
-

Description absente…

-
-
Depuis n/an/a (n/a)
-
Membre n/a depuis/: n/an/a (n/a)
- -
- - diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml deleted file mode 100644 index 67f697b..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/organizationListView.xhtml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
-
n/a membres actifs
-
n/a services acfifs
- - - - - - - - - - - - - - - - - - - - - -
MembreURLServicesUtilisateurs mensuels*Visites mensuelles*Date
- - -  n/a - - n/an/an/an/an/a
-
(*) chiffres de n/a
-
Membres en sommeil : n/a
-
Anciens membres : n/a
-
- - - diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml deleted file mode 100644 index 6b1a838..0000000 --- a/src/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - StatoolInfos - - - - - - - -
-
-
-