diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index dade0e0..cbc9a27 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -166,7 +166,6 @@ public class Htmlizer FederationPage.build(); FederationStatsPage.build(); OrganizationPage.buildAll(); - OrganizationStatsPage.buildAll(); PropertyFileCheckPage.buildAll(); PropertiesFilesPage.build(); PropertyStatsPage.buildAll(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationGeneralStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationGeneralStatsPage.java new file mode 100644 index 0000000..ca4b278 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationGeneralStatsPage.java @@ -0,0 +1,109 @@ +/* + * 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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.HtmlizerContext; +import fr.devinsy.statoolinfos.core.Organization; +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem; +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 OrganizationGeneralStatsPage. + */ +public class OrganizationGeneralStatsPage +{ + private static Logger logger = LoggerFactory.getLogger(OrganizationGeneralStatsPage.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 general page {}…"); + + File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); + + TagDataManager data = new TagDataManager(); + + // + data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); + data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.SUMMARY)); + + // + data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization)); + data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(organization.getServices())); + + data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organization)); + + data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(organization.getServices())); + data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(organization.getServices())); + data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(organization.getServices())); + data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(organization.getServices())); + + // + { + RegistrationStats stats = StatAgent.statRegistrationTypes(organization.getServices()); + + 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)); + } + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationGeneralStatsView.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 general page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationGenericMetricPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationGenericMetricPage.java new file mode 100644 index 0000000..2034242 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationGenericMetricPage.java @@ -0,0 +1,80 @@ +/* + * 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 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.MenuItem; +import fr.devinsy.xidyn.XidynException; +import fr.devinsy.xidyn.data.TagDataManager; +import fr.devinsy.xidyn.presenters.PresenterUtils; + +/** + * The Class OrganizationGenericMetricPage. + */ +public class OrganizationGenericMetricPage +{ + private static Logger logger = LoggerFactory.getLogger(OrganizationGenericMetricPage.class); + + /** + * Builds the. + * + * @param organization + * the service + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Organization organization) throws StatoolInfosException + { + String result; + + try + { + logger.debug("Building oranization generic metric page {}…", organization.get("service.name")); + + TagDataManager data = new TagDataManager(); + + // + data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); + data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.GENERIC)); + + // + int graphicIndex = 0; + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml"); + trail.add(organization.getName(), organization.getTechnicalName() + "-" + organization.getTechnicalName() + ".xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building organization generic metric page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java new file mode 100644 index 0000000..624d3aa --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java @@ -0,0 +1,167 @@ +/* + * 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 org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +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")); + + data.setEscapedContent("organizationURL", organization.getWebsite()); + data.setEscapedAttribute("organizationURL", "href", organization.getWebsite()); + + data.setEscapedContent("organizationDescription", organization.get("organization.description")); + + data.setEscapedContent("organizationMemberOfName", StringUtils.defaultIfBlank(organization.getFederation().getName(), "n/a")); + data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDate(), "n/a")); + data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDate(), "n/a")); + data.setContent("organizationAge", StringUtils.defaultIfBlank(organization.getAge(), "n/a")); + if (StringUtils.isBlank(organization.getEndDate())) + { + data.setContent("organizationMemberOfWord", "depuis"); + data.setAttribute("organizationEndDateData", "style", "display: none;"); + } + else + { + data.setContent("organizationMemberOfWord", ":"); + } + + data.setContent("organizationMemberStartDate", StringUtils.defaultIfBlank(organization.getMemberStartDate(), "n/a")); + data.setContent("organizationMemberEndDate", StringUtils.defaultIfBlank(organization.getMemberEndDate(), "n/a")); + data.setContent("organizationMemberAge", StringUtils.defaultIfBlank(organization.getMemberAge(), "n/a")); + if (StringUtils.isBlank(organization.getMemberEndDate())) + { + data.setAttribute("organizationMemberEndDateData", "style", "display: none;"); + } + else + { + data.setContent("organizationStartDateWord", ""); + } + + data.setContent("serviceCount", organization.getServices().size()); + + data.setAttribute("rawLink", "href", organization.getTechnicalName() + ".properties"); + data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-check.xhtml"); + + data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.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"); + } + + { + 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() + "-checkalerts.xhtml"); + } + + if (StringUtils.isNotBlank(organization.getLegalWebsite())) + { + data.setEscapedAttribute("legalLink", "href", organization.getLegalWebsite()); + data.setAttribute("legalLinkImg", "class", ""); + data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); + } + if (StringUtils.isNotBlank(organization.getContactWebsite())) + { + data.setEscapedAttribute("contactLink", "href", organization.getContactWebsite()); + 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 (StringUtils.isNotBlank(organization.getUserGuideWebsite())) + { + data.setEscapedAttribute("userDocLink", "href", organization.getUserGuideWebsite()); + data.setAttribute("userDocLinkImg", "class", ""); + data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); + } + if (StringUtils.isNotBlank(organization.getTechnicalGuideWebsite())) + { + data.setEscapedAttribute("technicalDocLink", "href", organization.getTechnicalGuideWebsite()); + 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/OrganizationMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java new file mode 100644 index 0000000..47762fb --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java @@ -0,0 +1,103 @@ +/* + * 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 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 MenuItem + { + SUMMARY, + GENERAL, + GENERIC, + WEB, + SPECIFIC + } + + /** + * Htmlize. + * + * @param organization + * the service + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Organization organization, final MenuItem item) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-stats.xhtml"); + data.setAttribute("generalTypeButton", "href", organization.getTechnicalName() + "-stats-general.xhtml"); + data.setAttribute("genericTypeButton", "href", organization.getTechnicalName() + "-stats-genericmetrics.xhtml"); + data.setAttribute("webTypeButton", "href", organization.getTechnicalName() + "-stats-webmetrics.xhtml"); + data.setAttribute("specificTypeButton", "href", organization.getTechnicalName() + "-stats-specificmetrics.xhtml"); + + if ((item == null) || (item == MenuItem.SUMMARY)) + { + data.appendAttribute("summaryTypeButton", "class", "button selected"); + } + else if (item == MenuItem.GENERAL) + { + data.appendAttribute("generalTypeButton", "class", "button selected"); + } + else if (item == MenuItem.GENERIC) + { + data.appendAttribute("genericTypeButton", "class", "button selected"); + } + else if (item == MenuItem.WEB) + { + data.appendAttribute("webTypeButton", "class", "button selected"); + } + else if (item == MenuItem.SPECIFIC) + { + data.appendAttribute("specificTypeButton", "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 service metric menu view: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java index 2a1508b..a8a9d41 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java @@ -23,18 +23,15 @@ 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.catgenerator.core.CatGenerator; 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.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; @@ -74,6 +71,27 @@ public class OrganizationPage // page = PropertyFilesCheckPage.htmlize(organization.getName(), organization.getInputChecksAll().getAlertLines()); FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8); + + // + logger.info("Htmlize organization general metric page: {}.", organization.getName()); + page = OrganizationStatsPage.htmlize(organization); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats.xhtml"), page, StandardCharsets.UTF_8); + + logger.info("Htmlize organization general metric page: {}.", organization.getName()); + page = OrganizationGeneralStatsPage.htmlize(organization); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-general.xhtml"), page, StandardCharsets.UTF_8); + + logger.info("Htmlize organization generic metric page: {}.", organization.getName()); + page = OrganizationGenericMetricPage.htmlize(organization); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-genericmetrics.xhtml"), page, StandardCharsets.UTF_8); + + logger.info("Htmlize organization web metric page: {}.", organization.getName()); + page = OrganizationWebMetricPage.htmlize(organization); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-webmetrics.xhtml"), page, StandardCharsets.UTF_8); + + logger.info("Htmlize service specific metric page: {}.", organization.getName()); + page = OrganizationSpecificMetricPage.htmlize(organization); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-specificmetrics.xhtml"), page, StandardCharsets.UTF_8); } /** @@ -109,100 +127,8 @@ public class OrganizationPage TagDataManager data = new TagDataManager(); - data.setAttribute("organizationRawButton", "href", organization.getTechnicalName() + ".properties"); - - data.setAttribute("organizationLogo", "src", organization.getLogoFileName()); - data.setEscapedContent("organizationName", organization.get("organization.name")); - - data.setEscapedContent("organizationURL", organization.getWebsite()); - data.setEscapedAttribute("organizationURL", "href", organization.getWebsite()); - - data.setEscapedContent("organizationDescription", organization.get("organization.description")); - - data.setEscapedContent("organizationMemberOfName", StringUtils.defaultIfBlank(organization.getFederation().getName(), "n/a")); - data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDate(), "n/a")); - data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDate(), "n/a")); - data.setContent("organizationAge", StringUtils.defaultIfBlank(organization.getAge(), "n/a")); - if (StringUtils.isBlank(organization.getEndDate())) - { - data.setContent("organizationMemberOfWord", "depuis"); - data.setAttribute("organizationEndDateData", "style", "display: none;"); - } - else - { - data.setContent("organizationMemberOfWord", ":"); - } - - data.setContent("organizationMemberStartDate", StringUtils.defaultIfBlank(organization.getMemberStartDate(), "n/a")); - data.setContent("organizationMemberEndDate", StringUtils.defaultIfBlank(organization.getMemberEndDate(), "n/a")); - data.setContent("organizationMemberAge", StringUtils.defaultIfBlank(organization.getMemberAge(), "n/a")); - if (StringUtils.isBlank(organization.getMemberEndDate())) - { - data.setAttribute("organizationMemberEndDateData", "style", "display: none;"); - } - else - { - data.setContent("organizationStartDateWord", ""); - } - - data.setContent("serviceCount", organization.getServices().size()); - - data.setAttribute("rawLink", "href", organization.getTechnicalName() + ".properties"); - data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-check.xhtml"); - - data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.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"); - } - - { - 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() + "-checkalerts.xhtml"); - } - - if (StringUtils.isNotBlank(organization.getLegalWebsite())) - { - data.setEscapedAttribute("legalLink", "href", organization.getLegalWebsite()); - data.setAttribute("legalLinkImg", "class", ""); - data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (StringUtils.isNotBlank(organization.getContactWebsite())) - { - data.setEscapedAttribute("contactLink", "href", organization.getContactWebsite()); - 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 (StringUtils.isNotBlank(organization.getUserGuideWebsite())) - { - data.setEscapedAttribute("userDocLink", "href", organization.getUserGuideWebsite()); - data.setAttribute("userDocLinkImg", "class", ""); - data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - if (StringUtils.isNotBlank(organization.getTechnicalGuideWebsite())) - { - data.setEscapedAttribute("technicalDocLink", "href", organization.getTechnicalGuideWebsite()); - data.setAttribute("technicalDocLinkImg", "class", ""); - data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); - } - + // + data.setContent("organizationHeaderView", OrganizationHeaderView.htmlize(organization)); data.setContent("serviceListView", ServiceListView.build(organization.getServices().sortByName())); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organization.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationSpecificMetricPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationSpecificMetricPage.java new file mode 100644 index 0000000..d939a88 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationSpecificMetricPage.java @@ -0,0 +1,80 @@ +/* + * 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 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.MenuItem; +import fr.devinsy.xidyn.XidynException; +import fr.devinsy.xidyn.data.TagDataManager; +import fr.devinsy.xidyn.presenters.PresenterUtils; + +/** + * The Class OrganizationSpecificMetricPage. + */ +public class OrganizationSpecificMetricPage +{ + private static Logger logger = LoggerFactory.getLogger(OrganizationSpecificMetricPage.class); + + /** + * Builds the. + * + * @param organization + * the service + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Organization organization) throws StatoolInfosException + { + String result; + + 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, MenuItem.SPECIFIC)); + + // + int graphicIndex = 0; + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml"); + trail.add(organization.getName(), organization.getTechnicalName() + "-" + organization.getTechnicalName() + ".xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building organization specific metric page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java index c305141..ff2868c 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java @@ -20,57 +20,43 @@ package fr.devinsy.statoolinfos.htmlize; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; +import java.time.YearMonth; -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.stats.StatAgent; -import fr.devinsy.statoolinfos.stats.services.RegistrationStats; +import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem; +import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; +import fr.devinsy.statoolinfos.htmlize.charts.MonthValues; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.presenters.PresenterUtils; /** - * The Class SocialNetworksPage. + * The Class OrganizationStatsPage. */ public class OrganizationStatsPage { private static Logger logger = LoggerFactory.getLogger(OrganizationStatsPage.class); /** - * Builds the. + * 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 void buildAll() throws StatoolInfosException, IOException + public static String htmlize(final Organization organization) throws StatoolInfosException, IOException { - Federation federation = HtmlizerContext.instance().getFederation(); + String result; - for (Organization organization : federation.getOrganizations()) - { - htmlize(organization); - } - } - - /** - * Builds the. - * - * @throws StatoolInfosException - * the statool infos exception - * @throws IOException - * Signals that an I/O exception has occurred. - */ - public static void htmlize(final Organization organization) throws StatoolInfosException, IOException - { try { logger.debug("Building organization stats page {}…"); @@ -79,40 +65,46 @@ public class OrganizationStatsPage TagDataManager data = new TagDataManager(); - data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization)); - data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(organization.getServices())); - - data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organization)); - - data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(organization.getServices())); - data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(organization.getServices())); - data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(organization.getServices())); - data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(organization.getServices())); - // - { - RegistrationStats stats = StatAgent.statRegistrationTypes(organization.getServices()); + data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); + data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.SUMMARY)); - 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)); + String tagIds[] = { "fullChart", "lastChart", "2020Chart", "2021Chart" }; + YearMonth starts[] = { null, YearMonth.now().minusMonths(11), YearMonth.of(2020, 01), YearMonth.of(2021, 01) }; + YearMonth ends[] = { null, YearMonth.now(), YearMonth.of(2020, 12), YearMonth.of(2021, 12) }; + + for (int index = 0; index < tagIds.length; index++) + { + String tagId = tagIds[index]; + YearMonth start = starts[index]; + YearMonth end = ends[index]; + + int graphicIndex = 0; + + MonthValues metric = organization.getMetricMonthValuesAll("metrics.http.hits.visitors"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); + + metric = organization.getMetricMonthValuesAll("metrics.http.ip.visitors"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); + + metric = organization.getMetricMonthValuesAll("metrics.http.visits.visitors"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); } // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStats.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml", data).toString(); // BreadcrumbTrail trail = new BreadcrumbTrail(); trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml"); - String page = WebCharterView.build(content, trail); - - FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-stats.xhtml"), page, StandardCharsets.UTF_8); + 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/OrganizationWebMetricPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationWebMetricPage.java new file mode 100644 index 0000000..7c76cb1 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationWebMetricPage.java @@ -0,0 +1,155 @@ +/* + * 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 fr.devinsy.statoolinfos.core.Organization; +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem; +import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; +import fr.devinsy.statoolinfos.htmlize.charts.MonthValues; +import fr.devinsy.xidyn.XidynException; +import fr.devinsy.xidyn.data.TagDataManager; +import fr.devinsy.xidyn.presenters.PresenterUtils; + +/** + * The Class OrganizationWebMetricPage. + */ +public class OrganizationWebMetricPage +{ + private static Logger logger = LoggerFactory.getLogger(OrganizationWebMetricPage.class); + + /** + * Builds the. + * + * @param organization + * the service + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Organization organization) throws StatoolInfosException + { + String result; + + try + { + logger.debug("Building oranization web metric page {}…", organization.get("service.name")); + + TagDataManager data = new TagDataManager(); + + // + data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); + data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.WEB)); + + // + String tagIds[] = { "fullChart", "lastChart", "2020Chart", "2021Chart" }; + YearMonth starts[] = { null, YearMonth.now().minusMonths(11), YearMonth.of(2020, 01), YearMonth.of(2021, 01) }; + YearMonth ends[] = { null, YearMonth.now(), YearMonth.of(2020, 12), YearMonth.of(2021, 12) }; + + for (int index = 0; index < tagIds.length; index++) + { + String tagId = tagIds[index]; + YearMonth start = starts[index]; + YearMonth end = ends[index]; + + int graphicIndex = 0; + + MonthValues metric = organization.getMetricMonthValuesAll("metrics.http.hits"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.BLUE)); + + MonthValues metric4 = organization.getMetricMonthValuesAll("metrics.http.hits.ipv4"); + MonthValues metric6 = organization.getMetricMonthValuesAll("metrics.http.hits.ipv6"); + data.setContent(tagId, graphicIndex++, + ChartHtmlizer.htmlizeMetricsChart("http.hits (ipv4 + ipv6)", start, end, new ChartColor[] { ChartColor.YELLOW, ChartColor.GREEN }, metric4, metric6)); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric4, ChartColor.YELLOW)); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric6, ChartColor.GREEN)); + + metric4 = organization.getMetricMonthValuesAll("metrics.http.hits.bots"); + metric6 = organization.getMetricMonthValuesAll("metrics.http.hits.visitors"); + data.setContent(tagId, graphicIndex++, + ChartHtmlizer.htmlizeMetricsChart("http.hits (visitors + bots)", start, end, new ChartColor[] { ChartColor.GREEN, ChartColor.YELLOW }, metric6, metric4)); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric6, ChartColor.GREEN)); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric4, ChartColor.YELLOW)); + + metric = organization.getMetricMonthValuesAll("metrics.http.errors"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.RED)); + + metric = organization.getMetricMonthValuesAll("metrics.http.errors.php"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.RED)); + + metric = organization.getMetricMonthValuesAll("metrics.http.files"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.BLUE)); + + metric = organization.getMetricMonthValuesAll("metrics.http.pages"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.BLUE)); + + metric = organization.getMetricMonthValuesAll("metrics.http.bytes"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.BLUE)); + + metric = organization.getMetricMonthValuesAll("metrics.http.ip"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.BLUE)); + + metric4 = organization.getMetricMonthValuesAll("metrics.http.ip.bots"); + metric6 = organization.getMetricMonthValuesAll("metrics.http.ip.visitors"); + data.setContent(tagId, graphicIndex++, + ChartHtmlizer.htmlizeMetricsChart("http.ip (visitors + bots)", start, end, new ChartColor[] { ChartColor.GREEN, ChartColor.YELLOW }, metric6, metric4)); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric6, ChartColor.GREEN)); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric4, ChartColor.YELLOW)); + + metric4 = organization.getMetricMonthValuesAll("metrics.http.ip.ipv4"); + metric6 = organization.getMetricMonthValuesAll("metrics.http.ip.ipv6"); + data.setContent(tagId, graphicIndex++, + ChartHtmlizer.htmlizeMetricsChart("http.ip (ipv4 + ipv6)", start, end, new ChartColor[] { ChartColor.YELLOW, ChartColor.GREEN }, metric4, metric6)); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric4, ChartColor.YELLOW)); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric6, ChartColor.GREEN)); + + metric = organization.getMetricMonthValuesAll("metrics.http.visits"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.BLUE)); + + metric4 = organization.getMetricMonthValuesAll("metrics.http.visits.bots"); + metric6 = organization.getMetricMonthValuesAll("metrics.http.visits.visitors"); + data.setContent(tagId, graphicIndex++, + ChartHtmlizer.htmlizeMetricsChart("http.visits (visitors + bots)", start, end, new ChartColor[] { ChartColor.GREEN, ChartColor.YELLOW }, metric6, metric4)); + + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric6, ChartColor.GREEN)); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric4, ChartColor.YELLOW)); + } + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml"); + trail.add(organization.getName(), organization.getTechnicalName() + "-" + organization.getTechnicalName() + ".xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building organization web metric page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java index 395074e..460c032 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java @@ -89,7 +89,7 @@ public class ServiceMetricMenuView } // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricMenuView.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml", data).toString(); result = XidynUtils.extractBodyContent(content); } catch (XidynException exception) diff --git a/src/fr/devinsy/statoolinfos/htmlize/serviceMetricMenuView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml similarity index 100% rename from src/fr/devinsy/statoolinfos/htmlize/serviceMetricMenuView.xhtml rename to src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml diff --git a/src/fr/devinsy/statoolinfos/htmlize/organization.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organization.xhtml index e1cfc35..fb594f2 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/organization.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/organization.xhtml @@ -11,41 +11,7 @@ -
-
-
- -
-
- - -
-

Description absente…

-
-
Depuis n/an/a (n/a)
-
Membre n/a depuis/: n/an/a (n/a)
- -
-
Nombre de services : n/a
-
+
diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationStats.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationGeneralStatsView.xhtml similarity index 92% rename from src/fr/devinsy/statoolinfos/htmlize/organizationStats.xhtml rename to src/fr/devinsy/statoolinfos/htmlize/organizationGeneralStatsView.xhtml index cf51071..79a4d5a 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/organizationStats.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/organizationGeneralStatsView.xhtml @@ -11,9 +11,10 @@ -
- -

Statistiques

+
+
+
+
diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml new file mode 100644 index 0000000..586cdc7 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml @@ -0,0 +1,50 @@ + + + + + StatoolInfos + + + + + + + +
+
+
+ +
+
+ + +
+

Description absente…

+
+
Depuis n/an/a (n/a)
+
Membre n/a depuis/: n/an/a (n/a)
+ +
+
Nombre de services : n/a
+
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml new file mode 100644 index 0000000..d3e9cbe --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml @@ -0,0 +1,31 @@ + + + + + StatoolInfos + + + + + + + +
+
+
+