From b4b01f561042c18bc06522f999627193ff03585f Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 27 May 2021 05:08:19 +0200 Subject: [PATCH] Refactored stats menu in organization and service. --- .../htmlize/OrganizationMetricMenuView.java | 16 +-- .../htmlize/OrganizationPage.java | 6 +- .../htmlize/OrganizationStatsPage.java | 43 ++++---- ...java => OrganizationSummaryStatsPage.java} | 49 +++++---- .../htmlize/ServiceGenericMetricPage.java | 8 +- .../htmlize/ServiceMetricMenuView.java | 24 ++-- .../statoolinfos/htmlize/ServicePage.java | 40 ++----- .../htmlize/ServiceSpecificMetricPage.java | 8 +- ...ceStatsPage.java => ServiceStatsView.java} | 19 ++-- .../htmlize/ServiceSummaryMetricPage.java | 104 ++++++++++++++++++ .../htmlize/ServiceWebMetricPage.java | 4 +- .../statoolinfos/htmlize/metricMenuView.xhtml | 2 +- ...View.xhtml => organizationStatsView.xhtml} | 0 .../statoolinfos/htmlize/service.xhtml | 16 +-- .../htmlize/serviceMetricView.xhtml | 31 ++++++ .../statoolinfos/htmlize/serviceStats.xhtml | 48 -------- .../htmlize/serviceStatsView.xhtml | 45 ++++++++ 17 files changed, 276 insertions(+), 187 deletions(-) rename src/fr/devinsy/statoolinfos/htmlize/{OrganizationGeneralStatsPage.java => OrganizationSummaryStatsPage.java} (59%) rename src/fr/devinsy/statoolinfos/htmlize/{ServiceStatsPage.java => ServiceStatsView.java} (82%) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/ServiceSummaryMetricPage.java rename src/fr/devinsy/statoolinfos/htmlize/{organizationGeneralStatsView.xhtml => organizationStatsView.xhtml} (100%) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/serviceMetricView.xhtml delete mode 100644 src/fr/devinsy/statoolinfos/htmlize/serviceStats.xhtml create mode 100644 src/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java index 47762fb..f82238b 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationMetricMenuView.java @@ -37,8 +37,8 @@ public class OrganizationMetricMenuView public enum MenuItem { - SUMMARY, GENERAL, + SUMMARY, GENERIC, WEB, SPECIFIC @@ -61,20 +61,20 @@ public class OrganizationMetricMenuView { TagDataManager data = new TagDataManager(); - data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-stats.xhtml"); - data.setAttribute("generalTypeButton", "href", organization.getTechnicalName() + "-stats-general.xhtml"); + data.setAttribute("generalTypeButton", "href", organization.getTechnicalName() + "-stats.xhtml"); + data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-stats-summarymetrics.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) + if ((item == null) || (item == MenuItem.GENERAL)) { data.appendAttribute("generalTypeButton", "class", "button selected"); } + else if (item == MenuItem.SUMMARY) + { + data.appendAttribute("summaryTypeButton", "class", "button selected"); + } else if (item == MenuItem.GENERIC) { data.appendAttribute("genericTypeButton", "class", "button selected"); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java index a8a9d41..10cc72e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java @@ -77,9 +77,9 @@ public class OrganizationPage 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 summarty metric page: {}.", organization.getName()); + page = OrganizationSummaryStatsPage.htmlize(organization); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-summarymetrics.xhtml"), page, StandardCharsets.UTF_8); logger.info("Htmlize organization generic metric page: {}.", organization.getName()); page = OrganizationGenericMetricPage.htmlize(organization); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java index ff2868c..d895d50 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java @@ -20,7 +20,6 @@ package fr.devinsy.statoolinfos.htmlize; import java.io.File; import java.io.IOException; -import java.time.YearMonth; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,8 +28,8 @@ 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.htmlize.charts.ChartColor; -import fr.devinsy.statoolinfos.htmlize.charts.MonthValues; +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; @@ -67,32 +66,32 @@ public class OrganizationStatsPage // data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.SUMMARY)); + data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.GENERAL)); - 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) }; + // + data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization)); + data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(organization.getServices())); - for (int index = 0; index < tagIds.length; index++) + 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())); + + // { - String tagId = tagIds[index]; - YearMonth start = starts[index]; - YearMonth end = ends[index]; + RegistrationStats stats = StatAgent.statRegistrationTypes(organization.getServices()); - 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)); + 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/organizationMetricView.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStatsView.xhtml", data).toString(); // BreadcrumbTrail trail = new BreadcrumbTrail(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationGeneralStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationSummaryStatsPage.java similarity index 59% rename from src/fr/devinsy/statoolinfos/htmlize/OrganizationGeneralStatsPage.java rename to src/fr/devinsy/statoolinfos/htmlize/OrganizationSummaryStatsPage.java index ca4b278..aff254a 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationGeneralStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationSummaryStatsPage.java @@ -20,6 +20,7 @@ package fr.devinsy.statoolinfos.htmlize; import java.io.File; import java.io.IOException; +import java.time.YearMonth; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,8 +29,8 @@ 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.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; @@ -37,9 +38,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils; /** * The Class OrganizationGeneralStatsPage. */ -public class OrganizationGeneralStatsPage +public class OrganizationSummaryStatsPage { - private static Logger logger = LoggerFactory.getLogger(OrganizationGeneralStatsPage.class); + private static Logger logger = LoggerFactory.getLogger(OrganizationSummaryStatsPage.class); /** * Htmlize. @@ -58,7 +59,7 @@ public class OrganizationGeneralStatsPage try { - logger.debug("Building organization general page {}…"); + logger.debug("Building organization summary page {}…"); File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); @@ -68,30 +69,30 @@ public class OrganizationGeneralStatsPage 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())); + 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) }; - 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())); - - // + for (int index = 0; index < tagIds.length; index++) { - RegistrationStats stats = StatAgent.statRegistrationTypes(organization.getServices()); + String tagId = tagIds[index]; + YearMonth start = starts[index]; + YearMonth end = ends[index]; - 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)); + 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/organizationGeneralStatsView.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationMetricView.xhtml", data).toString(); // BreadcrumbTrail trail = new BreadcrumbTrail(); @@ -100,7 +101,7 @@ public class OrganizationGeneralStatsPage } catch (XidynException exception) { - throw new StatoolInfosException("Error building organization general page: " + exception.getMessage(), exception); + throw new StatoolInfosException("Error building organization summary page: " + exception.getMessage(), exception); } // diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceGenericMetricPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceGenericMetricPage.java index f5b4442..7244aa4 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceGenericMetricPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceGenericMetricPage.java @@ -50,19 +50,19 @@ public class ServiceGenericMetricPage try { - logger.debug("Building service page {}…", service.get("service.name")); + logger.debug("Building service generic metrics view {}…", service.get("service.name")); TagDataManager data = new TagDataManager(); // data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERIC)); + data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERIC)); // int graphicIndex = 0; // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricView.xhtml", data).toString(); BreadcrumbTrail trail = new BreadcrumbTrail(); trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml"); @@ -71,7 +71,7 @@ public class ServiceGenericMetricPage } catch (XidynException exception) { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); + throw new StatoolInfosException("Error building service generic metric view: " + exception.getMessage(), exception); } // diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java index 460c032..45571f8 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceMetricMenuView.java @@ -37,10 +37,10 @@ public class ServiceMetricMenuView public enum MenuItem { - SUMMARY, GENERAL, - GENERIC, + SUMMARY, WEB, + GENERIC, SPECIFIC } @@ -61,20 +61,20 @@ public class ServiceMetricMenuView { TagDataManager data = new TagDataManager(); - data.setAttribute("summaryTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); - data.setAttribute("generalTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-general.xhtml"); - data.setAttribute("genericTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-generic.xhtml"); - data.setAttribute("webTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-web.xhtml"); - data.setAttribute("specificTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-specific.xhtml"); + data.setAttribute("generalTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); + data.setAttribute("summaryTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-summarymetrics.xhtml"); + data.setAttribute("genericTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-genericmetrics.xhtml"); + data.setAttribute("webTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-webmetrics.xhtml"); + data.setAttribute("specificTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-specificmetrics.xhtml"); - if ((item == null) || (item == MenuItem.SUMMARY)) - { - data.appendAttribute("summaryTypeButton", "class", "button selected"); - } - else if (item == MenuItem.GENERAL) + if ((item == null) || (item == MenuItem.GENERAL)) { data.appendAttribute("generalTypeButton", "class", "button selected"); } + else if (item == MenuItem.SUMMARY) + { + data.appendAttribute("summaryTypeButton", "class", "button selected"); + } else if (item == MenuItem.GENERIC) { data.appendAttribute("genericTypeButton", "class", "button selected"); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java index bcad7dc..fd00e9b 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java @@ -21,7 +21,6 @@ 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; @@ -33,9 +32,6 @@ 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.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; @@ -80,22 +76,22 @@ public class ServicePage FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + ".xhtml"), page, StandardCharsets.UTF_8); // - logger.info("Htmlize service general metric page: {}.", service.getName()); - page = ServiceStatsPage.htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-general.xhtml"), page, StandardCharsets.UTF_8); + logger.info("Htmlize service summary metric page: {}.", service.getName()); + page = ServiceSummaryMetricPage.htmlize(service); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-summarymetrics.xhtml"), page, StandardCharsets.UTF_8); // logger.info("Htmlize service generic metric page: {}.", service.getName()); page = ServiceGenericMetricPage.htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-genericmetrics.xhtml"), page, StandardCharsets.UTF_8); logger.info("Htmlize service web metric page: {}.", service.getName()); page = ServiceWebMetricPage.htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-webmetrics.xhtml"), page, StandardCharsets.UTF_8); logger.info("Htmlize service specific metric page: {}.", service.getName()); page = ServiceSpecificMetricPage.htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-specificmetrics.xhtml"), page, StandardCharsets.UTF_8); } /** @@ -135,7 +131,7 @@ public class ServicePage // data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SUMMARY)); + data.setContent("statsView", ServiceStatsView.htmlize(service)); // // data.setContent("fooChart", graphicIndex++, @@ -143,28 +139,6 @@ public class ServicePage // service.getPrefixes(); - 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 = service.getMetricMonthValues("metrics.http.hits.visitors"); - data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); - - metric = service.getMetricMonthValues("metrics.http.ip.visitors"); - data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); - - metric = service.getMetricMonthValues("metrics.http.visits.visitors"); - data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); - } - // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceSpecificMetricPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceSpecificMetricPage.java index c1fb2a7..f68aaa6 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceSpecificMetricPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceSpecificMetricPage.java @@ -50,19 +50,19 @@ public class ServiceSpecificMetricPage try { - logger.debug("Building service specific page {}…", service.get("service.name")); + logger.debug("Building service specific metric view {}…", service.get("service.name")); TagDataManager data = new TagDataManager(); // data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SPECIFIC)); + data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SPECIFIC)); // int graphicIndex = 0; // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricView.xhtml", data).toString(); BreadcrumbTrail trail = new BreadcrumbTrail(); trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml"); @@ -71,7 +71,7 @@ public class ServiceSpecificMetricPage } catch (XidynException exception) { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); + throw new StatoolInfosException("Error building service specific metrics view: " + exception.getMessage(), exception); } // diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java similarity index 82% rename from src/fr/devinsy/statoolinfos/htmlize/ServiceStatsPage.java rename to src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java index b988e2a..33cd96e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java @@ -30,13 +30,14 @@ 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 ServiceStatsPage +public class ServiceStatsView { - private static Logger logger = LoggerFactory.getLogger(ServiceStatsPage.class); + private static Logger logger = LoggerFactory.getLogger(ServiceStatsView.class); /** * Builds the. @@ -53,13 +54,12 @@ public class ServiceStatsPage try { - logger.debug("Building service stats page {}…", service.get("service.name")); + logger.debug("Building service stats view {}…", service.get("service.name")); TagDataManager data = new TagDataManager(); // - data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERAL)); + data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERAL)); // data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(service)); @@ -86,16 +86,13 @@ public class ServiceStatsPage data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(mock)); // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceStats.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceStatsView.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); + result = XidynUtils.extractBodyContent(content); } catch (XidynException exception) { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); + throw new StatoolInfosException("Error building service view: " + exception.getMessage(), exception); } // diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceSummaryMetricPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceSummaryMetricPage.java new file mode 100644 index 0000000..9b28b65 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceSummaryMetricPage.java @@ -0,0 +1,104 @@ +/* + * 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.time.YearMonth; + +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.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 ServiceSummaryMetricPage. + */ +public class ServiceSummaryMetricPage +{ + private static Logger logger = LoggerFactory.getLogger(ServiceSummaryMetricPage.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 summary view {}…", service.get("service.name")); + + TagDataManager data = new TagDataManager(); + + // + data.setContent("headerView", ServiceHeaderView.htmlize(service)); + data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.SUMMARY)); + + // + 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 = service.getMetricMonthValues("metrics.http.hits.visitors"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); + + metric = service.getMetricMonthValues("metrics.http.ip.visitors"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); + + metric = service.getMetricMonthValues("metrics.http.visits.visitors"); + data.setContent(tagId, graphicIndex++, ChartHtmlizer.htmlizeMetricsChart(start, end, metric, ChartColor.GREEN)); + } + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricView.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 summary metrics view: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceWebMetricPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceWebMetricPage.java index c41fd60..869f624 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceWebMetricPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceWebMetricPage.java @@ -60,7 +60,7 @@ public class ServiceWebMetricPage // data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("serviceMetricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.WEB)); + data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.WEB)); // service.getPrefixes(); @@ -138,7 +138,7 @@ public class ServiceWebMetricPage } // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricView.xhtml", data).toString(); BreadcrumbTrail trail = new BreadcrumbTrail(); trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml"); diff --git a/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml index 1a66e88..45b8ede 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/metricMenuView.xhtml @@ -14,8 +14,8 @@
Type - Résumé Général + Résumé Génériques Web Spécifiques diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationGeneralStatsView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationStatsView.xhtml similarity index 100% rename from src/fr/devinsy/statoolinfos/htmlize/organizationGeneralStatsView.xhtml rename to src/fr/devinsy/statoolinfos/htmlize/organizationStatsView.xhtml diff --git a/src/fr/devinsy/statoolinfos/htmlize/service.xhtml b/src/fr/devinsy/statoolinfos/htmlize/service.xhtml index 8128a01..d1a77be 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/service.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/service.xhtml @@ -12,20 +12,6 @@
-
-
-