From fbf6e50b49594452a1aa3a010a5bfdaeb110cb1e Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 22 Jul 2022 18:32:54 +0200 Subject: [PATCH] Refactored federation stats. Added provider hypervisor chart. --- src/fr/devinsy/statoolinfos/core/Service.java | 15 +++++ .../statoolinfos/htmlize/ChartHtmlizer.java | 63 +++++++++++++++++++ .../htmlize/FederationStatsPage.java | 6 +- .../htmlize/federationStats.xhtml | 11 ++-- 4 files changed, 88 insertions(+), 7 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index 8ed90ec..f8dc55b 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -275,6 +275,21 @@ public class Service extends PathPropertyList return result; } + /** + * Gets the host provider hypervisor. + * + * @return the host provider hypervisor + */ + public String getHostProviderHypervisor() + { + String result; + + result = get("host.provider.hypervisor"); + + // + return result; + } + /** * Gets the host provider type. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java index e5adab4..e55456e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java @@ -245,6 +245,69 @@ public class ChartHtmlizer return result; } + /** + * Htmlize host provider hypervisor chart. + * + * @param services + * the services + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlizeHostProviderHypervisorChart(final Services services) throws StatoolInfosException + { + String result; + + ChartColors colors = ChartColor.valueList(); + colors.remove(ChartColor.BLUE); + + StringCounters counters = new StringCounters(); + long unknowns = 0; + for (Service service : services) + { + String hypervisor = service.getHostProviderHypervisor(); + if (StringUtils.isBlank(hypervisor)) + { + unknowns += 1; + } + else + { + counters.inc(StringUtils.capitalize(hypervisor.toLowerCase())); + } + } + + StringCounterList list = counters.toList().sortByCounter().reverse(); + + PieChart pie = new PieChart("Distributions des hyperviseurs"); + pie.setLegendPosition(Position.RIGHT); + + int index = 0; + while ((index < list.size() && (index < 7))) + { + ChartColor color = colors.get(index); + StringCounter counter = list.get(index); + pie.add(counter.getString(), counter.getCounter(), color); + + index += 1; + } + + int others = 0; + while (index < list.size()) + { + StringCounter counter = list.get(index); + others += counter.getCounter(); + + index += 1; + } + pie.add("Autres", others, ChartColor.GREY); + pie.add("Inconnus", unknowns, ChartColor.BLUE); + + result = DoughnutChartView.build(pie); + + // + return result; + } + /** * Htmlize host provider type chart. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java index 3f78a30..575156f 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java @@ -74,12 +74,15 @@ public class FederationStatsPage data.setContent("organizationCountChart", ChartHtmlizer.htmlizeOrganizationCountChart(federation)); data.setContent("organizationInOutChart", ChartHtmlizer.htmlizeOrganizationInOutChart(federation)); - data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services)); + data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(federation)); data.setContent("hostServerTypeChart", ChartHtmlizer.htmlizeHostServerTypeChart(services)); data.setContent("hostProviderTypeChart", ChartHtmlizer.htmlizeHostProviderTypeChart(services)); data.setContent("serviceCountryChart", ChartHtmlizer.htmlizeServiceCountryChart(services)); data.setContent("hostNameChart", ChartHtmlizer.htmlizeHostNamePieChart(services)); + data.setContent("hostProviderHypervisorChart", ChartHtmlizer.htmlizeHostProviderHypervisorChart(services)); + + data.setContent("hostServerDistributionChart", ChartHtmlizer.htmlizeHostServerDistributionChart(services)); data.setContent("serviceInstallTypeChart", ChartHtmlizer.htmlizeServiceInstallTypeChart(services)); { @@ -92,7 +95,6 @@ public class FederationStatsPage data.setContent("registrationClientTypeChart", ChartHtmlizer.htmlizeRegistrationClientPieChart(stats)); } - data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(federation)); data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services)); data.setContent("softwareDistributionChart", ChartHtmlizer.htmlizeSoftwareDistributionChart()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml index f789977..877f571 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml @@ -23,14 +23,18 @@
-
+
-
+
+
+
+
+
@@ -44,10 +48,7 @@
-
-
-