diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index c838dea..8ed90ec 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -299,6 +299,21 @@ public class Service extends PathPropertyList return result; } + /** + * Gets the host server distribution. + * + * @return the host server distribution + */ + public String getHostServerDistribution() + { + String result; + + result = get("host.server.distribution"); + + // + return result; + } + /** * Gets the host server type. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java index cc3cb8b..6c1f80a 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java @@ -273,6 +273,68 @@ public class ChartHtmlizer return result; } + /** + * Htmlize host server distribution chart. + * + * @param services + * the services + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlizeHostServerDistributionChart(final Services services) throws StatoolInfosException + { + String result; + + ChartColors colors = ChartColor.valueList(); + colors.remove(ChartColor.BLUE); + + StringCounters counters = new StringCounters(); + long unknowns = 0; + for (Service service : services) + { + if (StringUtils.isBlank(service.getHostServerDistribution())) + { + unknowns += 1; + } + else + { + counters.inc(StringUtils.capitalize(service.getHostServerDistribution().toLowerCase())); + } + } + + StringCounterList list = counters.toList().sortByCounter().reverse(); + + PieChart pie = new PieChart("Distributions serveur"); + pie.setLegendPosition(Position.RIGHT); + + int index = 0; + while ((index < list.size() && (index < 7))) + { + ChartColor color = colors.get(index); + StringCounter counter = list.get(index); + pie.add(counter.getString(), counter.getCounter(), color); + + index += 1; + } + + int others = 0; + while (index < list.size()) + { + StringCounter counter = list.get(index); + others += counter.getCounter(); + + index += 1; + } + pie.add("Autres", others, ChartColor.GREY); + pie.add("Inconnus", unknowns, ChartColor.BLUE); + + result = DoughnutChartView.build(pie); + + // + return result; + } + /** * Htmlize host server type chart. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java index ba2ae73..3f78a30 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Christian Pierre MOMON + * Copyright (C) 2020-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -28,6 +28,8 @@ import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.HtmlizerContext; import fr.devinsy.statoolinfos.core.Federation; +import fr.devinsy.statoolinfos.core.Organizations; +import fr.devinsy.statoolinfos.core.Services; import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.stats.StatAgent; import fr.devinsy.statoolinfos.stats.services.RegistrationStats; @@ -60,23 +62,28 @@ public class FederationStatsPage // CrawlCache cache = HtmlizerContext.instance().getCache(); File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); + Organizations organizations = federation.getActiveOrganizations(); + Services services = federation.getActiveServices(); + TagDataManager data = new TagDataManager(); data.setContent("federationHeaderView", FederationHeaderView.htmlize(federation)); - data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(federation.getActiveOrganizations())); - data.setContent("organizationCountryChart", ChartHtmlizer.htmlizeOrganizationCountryChart(federation.getActiveOrganizations())); + data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(organizations)); + data.setContent("organizationCountryChart", ChartHtmlizer.htmlizeOrganizationCountryChart(organizations)); data.setContent("organizationCountChart", ChartHtmlizer.htmlizeOrganizationCountChart(federation)); data.setContent("organizationInOutChart", ChartHtmlizer.htmlizeOrganizationInOutChart(federation)); - data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(federation.getServices())); - data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(federation.getServices())); - data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(federation.getServices())); - data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(federation.getServices())); + data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services)); + data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services)); + data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services)); + data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services)); + + data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services)); + data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services)); - // { - RegistrationStats stats = StatAgent.statRegistrationTypes(federation.getServices()); + RegistrationStats stats = StatAgent.statRegistrationTypes(services); data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats)); data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats)); @@ -86,14 +93,12 @@ public class FederationStatsPage } data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(federation)); - data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(federation.getServices())); + data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services)); data.setContent("softwareDistributionChart", ChartHtmlizer.htmlizeSoftwareDistributionChart()); - data.setContent("softwareDistributionPieChart", ChartHtmlizer.htmlizeSoftwareDistributionPieChart(federation.getServicesAll())); + data.setContent("softwareDistributionPieChart", ChartHtmlizer.htmlizeSoftwareDistributionPieChart(services)); data.setContent("categoryDistributionChart", ChartHtmlizer.htmlizeCategoryDistributionChart()); - data.setContent("categoryDistributionPieChart", ChartHtmlizer.htmlizeCatergoryDistributionPieChart(federation.getServicesAll())); - - data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(federation.getServices())); + data.setContent("categoryDistributionPieChart", ChartHtmlizer.htmlizeCatergoryDistributionPieChart(services)); // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java index 73c8f45..0d41277 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Christian Pierre MOMON + * Copyright (C) 2020-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -24,6 +24,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.devinsy.statoolinfos.core.Organization; +import fr.devinsy.statoolinfos.core.Services; import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.stats.StatAgent; import fr.devinsy.statoolinfos.stats.services.RegistrationStats; @@ -63,19 +64,19 @@ public class OrganizationStatsPage data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); // - 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())); + Services services = organization.getActiveServices(); + data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services)); + data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services)); + data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services)); + data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services)); + + data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services)); + data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services)); - // { - RegistrationStats stats = StatAgent.statRegistrationTypes(organization.getServices()); + RegistrationStats stats = StatAgent.statRegistrationTypes(services); data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats)); data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats)); @@ -84,6 +85,9 @@ public class OrganizationStatsPage data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats)); } + data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services)); + data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization)); + // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java index 841b4be..7bd29c1 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceStatsView.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2021 Christian Pierre MOMON + * Copyright (C) 2020-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -60,16 +60,17 @@ public class ServiceStatsView // data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(service)); - Services mock = Services.of(service); + Services services = Services.of(service); + data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services)); + data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services)); + data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services)); + data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services)); - data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(mock)); - data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(mock)); - data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(mock)); - data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(mock)); + data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services)); + data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services)); - // { - RegistrationStats stats = StatAgent.statRegistrationTypes(mock); + RegistrationStats stats = StatAgent.statRegistrationTypes(services); data.setContent("registrationTypeChart", ChartHtmlizer.htmlizeRegistrationBarChart(stats)); data.setContent("registrationNoneTypeChart", ChartHtmlizer.htmlizeRegistrationNonePieChart(stats)); @@ -78,8 +79,8 @@ public class ServiceStatsView data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats)); } - data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(mock)); - data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(mock)); + data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(services)); + data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services)); // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml", data).toString(); diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml index f6b593c..f789977 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml @@ -23,6 +23,7 @@
+
diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml index ca22763..89b7790 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml @@ -19,11 +19,15 @@
+
-
+
+
+
+
diff --git a/src/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml index a482980..2fcae8a 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/serviceStatsView.xhtml @@ -17,11 +17,15 @@
+
-
+
+
+
+
diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java index 0f3cb94..b973cdd 100644 --- a/src/fr/devinsy/statoolinfos/stats/StatAgent.java +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.java @@ -260,6 +260,29 @@ public class StatAgent return result; } + /** + * Stat host server distribution. + * + * @param services + * the services + * @return the host server type stats + */ + public static HostServerTypeStats statHostServerDistribution(final Services services) + { + HostServerTypeStats result; + + result = new HostServerTypeStats(); + + // + for (Service service : services) + { + result.inc(service.getHostServerType()); + } + + // + return result; + } + /** * Stat host server type. *