diff --git a/src/fr/devinsy/statoolinfos/core/Federation.java b/src/fr/devinsy/statoolinfos/core/Federation.java index 65d9eb1..83b4895 100644 --- a/src/fr/devinsy/statoolinfos/core/Federation.java +++ b/src/fr/devinsy/statoolinfos/core/Federation.java @@ -27,6 +27,9 @@ import org.apache.commons.lang3.StringUtils; import fr.devinsy.statoolinfos.checker.PropertyChecks; import fr.devinsy.statoolinfos.crawl.CrawlJournal; +import fr.devinsy.statoolinfos.htmlize.charts.MonthValues; +import fr.devinsy.statoolinfos.htmlize.charts.WeekValues; +import fr.devinsy.statoolinfos.htmlize.charts.YearValues; import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathPropertyList; @@ -233,6 +236,21 @@ public class Federation extends PathPropertyList return result; } + /** + * Gets the local file base name. + * + * @return the local file base name + */ + public String getLocalFileBaseName() + { + String result; + + result = getTechnicalName(); + + // + return result; + } + /** * Gets the local file name. * @@ -277,6 +295,72 @@ public class Federation extends PathPropertyList return result; } + /** + * Gets the metric month values all. + * + * @param path + * the path + * @return the metric month values all + */ + public MonthValues getMetricMonthValuesAll(final String path) + { + MonthValues result; + + result = getMetricMonthValues(path); + + for (Organization organization : getOrganizations()) + { + result.addAll(organization.getMetricMonthValuesAll(path)); + } + + // + return result; + } + + /** + * Gets the metric week values all. + * + * @param path + * the path + * @return the metric week values all + */ + public WeekValues getMetricWeekValuesAll(final String path) + { + WeekValues result; + + result = getMetricWeekValues(path); + + for (Organization organization : getOrganizations()) + { + result.addAll(organization.getMetricWeekValuesAll(path)); + } + + // + return result; + } + + /** + * Gets the metric year values all. + * + * @param path + * the path + * @return the metric year values all + */ + public YearValues getMetricYearValuesAll(final String path) + { + YearValues result; + + result = getMetricYearValues(path); + + for (Organization organization : getOrganizations()) + { + result.addAll(organization.getMetricYearValuesAll(path)); + } + + // + return result; + } + /** * Gets the name. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java index 89b9f21..1eb0b32 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java @@ -71,6 +71,7 @@ public class FederationHeaderView data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties"); data.setAttribute("rawCheckLink", "href", federation.getTechnicalName() + "-check.xhtml"); data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml"); + data.setAttribute("metricsLink", "href", federation.getTechnicalName() + "-metrics.xhtml"); data.setAttribute("crawlLink", "href", federation.getTechnicalName() + "-crawl.xhtml"); if (federation.getCrawlJournal().getErrors().isEmpty()) diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java new file mode 100644 index 0000000..1a7ebca --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricGenericPage.java @@ -0,0 +1,80 @@ +/* + * 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.IOException; + +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.MenuItem; +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. + * + * @throws StatoolInfosException + * the statool infos exception + * @throws IOException + * Signals that an I/O exception has occurred. + */ + public static String htmlize(final Federation federation) throws StatoolInfosException, IOException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", FederationHeaderView.htmlize(federation)); + data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, MenuItem.GENERIC)); + + // + MetricHtmlizer.htmlizeData(data, "users.count", federation, "metrics.users.count", ChartColor.GREEN); + MetricHtmlizer.htmlizeData(data, "database.bytes", federation, "metrics.database.bytes", ChartColor.GREEN); + MetricHtmlizer.htmlizeData(data, "files.bytes", federation, "metrics.http.visits.visitors", ChartColor.GREEN); + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricGenericView.xhtml", data).toString(); + + // + BreadcrumbTrail trail = new BreadcrumbTrail(); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricMenuView.java new file mode 100644 index 0000000..7a89bbe --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricMenuView.java @@ -0,0 +1,97 @@ +/* + * 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.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 FederationMetricMenuView. + */ +public class FederationMetricMenuView +{ + private static Logger logger = LoggerFactory.getLogger(FederationMetricMenuView.class); + + public enum MenuItem + { + SUMMARY, + GENERIC, + WEB, + SPECIFIC + } + + /** + * Htmlize. + * + * @param federation + * the service + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Federation federation, final MenuItem item) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setAttribute("summaryTypeButton", "href", federation.getTechnicalName() + "-metrics.xhtml"); + data.setAttribute("genericTypeButton", "href", federation.getTechnicalName() + "-metrics-generic.xhtml"); + data.setAttribute("webTypeButton", "href", federation.getTechnicalName() + "-metrics-web.xhtml"); + data.setAttribute("specificTypeButton", "href", federation.getTechnicalName() + "-metrics-specific.xhtml"); + + if ((item == null) || (item == MenuItem.SUMMARY)) + { + data.appendAttribute("summaryTypeButton", "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/FederationMetricSpecificPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSpecificPage.java new file mode 100644 index 0000000..70c1587 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSpecificPage.java @@ -0,0 +1,74 @@ +/* + * 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.IOException; + +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.MenuItem; +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 String htmlize(final Federation federation) throws StatoolInfosException, IOException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", FederationHeaderView.htmlize(federation)); + data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, MenuItem.SPECIFIC)); + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString(); + + // + BreadcrumbTrail trail = new BreadcrumbTrail(); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSummaryPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSummaryPage.java new file mode 100644 index 0000000..6eab6f7 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricSummaryPage.java @@ -0,0 +1,79 @@ +/* + * 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.IOException; + +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.MenuItem; +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. + * + * @throws StatoolInfosException + * the statool infos exception + * @throws IOException + * Signals that an I/O exception has occurred. + */ + public static String htmlize(final Federation federation) throws StatoolInfosException, IOException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", FederationHeaderView.htmlize(federation)); + data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, MenuItem.SUMMARY)); + + MetricHtmlizer.htmlizeData(data, "http.hits.visitors", federation, "metrics.http.hits.visitors", ChartColor.GREEN); + MetricHtmlizer.htmlizeData(data, "http.ip.visitors", federation, "metrics.http.ip.visitors", ChartColor.GREEN); + MetricHtmlizer.htmlizeData(data, "http.visits.visitors", federation, "metrics.http.visits.visitors", ChartColor.GREEN); + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricSummaryView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationMetricWebPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricWebPage.java new file mode 100644 index 0000000..8400fca --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationMetricWebPage.java @@ -0,0 +1,112 @@ +/* + * 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.IOException; + +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.MenuItem; +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 String htmlize(final Federation federation) throws StatoolInfosException, IOException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", FederationHeaderView.htmlize(federation)); + data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, MenuItem.WEB)); + + // + MetricHtmlizer.htmlizeData(data, "http.hits", federation, "metrics.http.hits", ChartColor.BLUE); + + MetricHtmlizer.htmlizeData(data, "http.hits-ipv4ipv6", federation, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6", ChartColor.GREEN); + MetricHtmlizer.htmlizeData(data, "http.hits.ipv4", federation, "metrics.http.hits.ipv4", ChartColor.YELLOW); + MetricHtmlizer.htmlizeData(data, "http.hits.ipv6", federation, "metrics.http.hits.ipv6", ChartColor.GREEN); + + MetricHtmlizer.htmlizeData(data, "http.hits-visitorsbots", federation, "http.hits (visitors + bots)", "metrics.http.hits.visitors", ChartColor.GREEN, "metrics.http.hits.bots", + ChartColor.YELLOW); + MetricHtmlizer.htmlizeData(data, "http.hits.visitors", federation, "metrics.http.hits.visitors", ChartColor.GREEN); + MetricHtmlizer.htmlizeData(data, "http.hits.bots", federation, "metrics.http.hits.bots", ChartColor.YELLOW); + + MetricHtmlizer.htmlizeData(data, "http.errors", federation, "metrics.http.errors", ChartColor.RED); + MetricHtmlizer.htmlizeData(data, "http.errors.php", federation, "metrics.http.errors.php", ChartColor.RED); + + MetricHtmlizer.htmlizeData(data, "http.files", federation, "metrics.http.files", ChartColor.BLUE); + MetricHtmlizer.htmlizeData(data, "http.pages", federation, "metrics.http.pages", ChartColor.BLUE); + MetricHtmlizer.htmlizeData(data, "http.bytes", federation, "metrics.http.bytes", ChartColor.BLUE); + + MetricHtmlizer.htmlizeData(data, "http.ip", federation, "metrics.http.ip", ChartColor.BLUE); + + MetricHtmlizer.htmlizeData(data, "http.ip-visitorsbots", federation, "http.ip (visitors + bots)", "metrics.http.ip.visitors", ChartColor.GREEN, "metrics.http.ip.bots", + ChartColor.YELLOW); + MetricHtmlizer.htmlizeData(data, "http.ip.visitors", federation, "metrics.http.ip.visitors", ChartColor.GREEN); + MetricHtmlizer.htmlizeData(data, "http.ip.bots", federation, "metrics.http.ip.bots", ChartColor.YELLOW); + + MetricHtmlizer.htmlizeData(data, "http.ip-ipv4ipv6", federation, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6", ChartColor.GREEN); + MetricHtmlizer.htmlizeData(data, "http.ip.ipv4", federation, "metrics.http.ip.ipv4", ChartColor.YELLOW); + MetricHtmlizer.htmlizeData(data, "http.ip.ipv6", federation, "metrics.http.ip.ipv6", ChartColor.GREEN); + + MetricHtmlizer.htmlizeData(data, "http.visits", federation, "metrics.http.visits", ChartColor.BLUE); + + MetricHtmlizer.htmlizeData(data, "http.visits-visitorsbots", federation, "http.visits (visitors + bots)", "metrics.http.visits.visitors", ChartColor.GREEN, "metrics.http.visits.bots", + ChartColor.YELLOW); + MetricHtmlizer.htmlizeData(data, "http.visits.bots", federation, "metrics.http.visits.bots", ChartColor.YELLOW); + MetricHtmlizer.htmlizeData(data, "http.visits.visitors", federation, "metrics.http.visits.visitors", ChartColor.GREEN); + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString(); + + // + BreadcrumbTrail trail = new BreadcrumbTrail(); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java index a3cd445..5f05d14 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java @@ -72,6 +72,23 @@ public class FederationPage // page = PropertyFilesCheckPage.htmlize(federation.getName(), federation.getInputChecksAll().getAlertLines()); FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8); + + // + logger.info("Htmlize organization summarty metric page: {}.", federation.getName()); + page = FederationMetricSummaryPage.htmlize(federation); + FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-metrics.xhtml"), page, StandardCharsets.UTF_8); + + logger.info("Htmlize organization generic metric page: {}.", federation.getName()); + page = FederationMetricGenericPage.htmlize(federation); + FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8); + + logger.info("Htmlize organization web metric page: {}.", federation.getName()); + page = FederationMetricWebPage.htmlize(federation); + FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8); + + logger.info("Htmlize service specific metric page: {}.", federation.getName()); + page = FederationMetricSpecificPage.htmlize(federation); + FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8); } /** diff --git a/src/fr/devinsy/statoolinfos/htmlize/MetricHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/MetricHtmlizer.java index d57ec3a..87781a5 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/MetricHtmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/MetricHtmlizer.java @@ -24,6 +24,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.threeten.extra.YearWeek; +import fr.devinsy.statoolinfos.core.Federation; import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.StatoolInfosException; @@ -127,6 +128,95 @@ public class MetricHtmlizer return result; } + /** + * Htmlize data. + * + * @param data + * the data + * @param metricId + * the metric id + * @param federation + * the federation + * @param metricPath + * the metric path + * @param color + * the color + * @throws StatoolInfosException + * the statool infos exception + */ + public static void htmlizeData(final TagDataManager data, final String metricId, final Federation federation, final String metricPath, final ChartColor color) throws StatoolInfosException + { + YearValues yearMetric = federation.getMetricYearValuesAll(metricPath); + data.setContent("charts", CHART_YEARS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, yearMetric, color)); + + MonthValues monthMetric = federation.getMetricMonthValuesAll(metricPath); + data.setContent("charts", CHART_MONTHS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, monthMetric, color)); + data.setContent("charts", CHART_MONTHS_LAST, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.now().minusMonths(11), YearMonth.now(), monthMetric, color)); + data.setContent("charts", CHART_MONTHS_2020, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(2020, 01), YearMonth.of(2020, 12), monthMetric, color)); + data.setContent("charts", CHART_MONTHS_2021, metricId, ChartHtmlizer.htmlizeMetricsChart(YearMonth.of(2021, 01), YearMonth.of(2021, 12), monthMetric, color)); + + WeekValues weekMetric = federation.getMetricWeekValuesAll(metricPath); + data.setContent("charts", CHART_WEEKS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(null, null, weekMetric, color)); + data.setContent("charts", CHART_WEEKS_LAST, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.now().minusYears(1), YearWeek.now(), weekMetric, color)); + data.setContent("charts", CHART_WEEKS_2020, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(2020, 01), YearWeek.of(2020, 53), weekMetric, color)); + data.setContent("charts", CHART_WEEKS_2021, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(2021, 01), YearWeek.of(2021, 53), weekMetric, color)); + } + + /** + * Htmlize data. + * + * @param data + * the data + * @param metricId + * the metric id + * @param federation + * the federation + * @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 htmlizeData(final TagDataManager data, final String metricId, final Federation federation, final String metricLabel, final String metricPath1, + final ChartColor color1, final String metricPath2, final ChartColor color2) throws StatoolInfosException + { + // + YearValues yearMetric1 = federation.getMetricYearValuesAll(metricPath1); + YearValues yearMetric2 = federation.getMetricYearValuesAll(metricPath2); + data.setContent("charts", CHART_YEARS_FULL, metricId, + ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, yearMetric1, yearMetric2)); + + // + MonthValues monthMetric1 = federation.getMetricMonthValuesAll(metricPath1); + MonthValues monthMetric2 = federation.getMetricMonthValuesAll(metricPath2); + data.setContent("charts", CHART_MONTHS_FULL, metricId, ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); + data.setContent("charts", CHART_MONTHS_LAST, metricId, + ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.now().minusMonths(11), YearMonth.now(), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); + data.setContent("charts", CHART_MONTHS_2020, metricId, + ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(2020, 01), YearMonth.of(2020, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); + data.setContent("charts", CHART_MONTHS_2021, metricId, + ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearMonth.of(2021, 01), YearMonth.of(2021, 12), new ChartColor[] { color1, color2 }, monthMetric1, monthMetric2)); + + // + WeekValues weekMetric1 = federation.getMetricWeekValuesAll(metricPath1); + WeekValues weekMetric2 = federation.getMetricWeekValuesAll(metricPath2); + data.setContent("charts", CHART_WEEKS_FULL, metricId, + ChartHtmlizer.htmlizeMetricsChart(metricLabel, null, null, new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); + data.setContent("charts", CHART_WEEKS_LAST, metricId, + ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.now().minusYears(1), YearWeek.now(), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); + data.setContent("charts", CHART_WEEKS_2020, metricId, + ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(2020, 01), YearWeek.of(2020, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); + data.setContent("charts", CHART_WEEKS_2021, metricId, + ChartHtmlizer.htmlizeMetricsChart(metricLabel, YearWeek.of(2021, 01), YearWeek.of(2021, 53), new ChartColor[] { color1, color2 }, weekMetric1, weekMetric2)); + } + /** * Htmlize data. * @@ -161,28 +251,6 @@ public class MetricHtmlizer data.setContent("charts", CHART_WEEKS_2021, metricId, ChartHtmlizer.htmlizeMetricsChart(YearWeek.of(2021, 01), YearWeek.of(2021, 53), weekMetric, color)); } - /** - * Htmlize data. - * - * @param data - * the data - * @param metricId - * the metric id - * @param organization - * the organization - * @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 htmlizeData(final TagDataManager data, final String metricId, final Organization organization, final String metricLabel, final String metricPath1, final ChartColor color1, final String metricPath2, diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java index 8027d14..dbe11a9 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java @@ -73,7 +73,7 @@ public class OrganizationPage FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8); // - logger.info("Htmlize organization general metric page: {}.", organization.getName()); + 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); diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml index 8200bec..7c37cff 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml @@ -33,7 +33,8 @@ - + +