diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java index fe7c8fa..2ecc2a2 100644 --- a/src/fr/devinsy/statoolinfos/core/Organization.java +++ b/src/fr/devinsy/statoolinfos/core/Organization.java @@ -92,6 +92,21 @@ public class Organization extends PathPropertyList return result; } + /** + * Gets the country code. + * + * @return the country code + */ + public String getCountryCode() + { + String result; + + result = get("organization.country.code"); + + // + return result; + } + /** * Gets the crawled date. * diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index c9aa07a..7a77fbd 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -149,6 +149,21 @@ public class Service extends PathPropertyList return result; } + /** + * Gets the country code. + * + * @return the country code + */ + public String getCountryCode() + { + String result; + + result = get("organization.country.code"); + + // + return result; + } + public LocalDateTime getCrawledDate() { LocalDateTime result; diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java index 0788168..e04d8c7 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java @@ -41,7 +41,7 @@ import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.presenters.PresenterUtils; /** - * The Class SocialNetworksPage. + * The Class FederationStatsPage. */ public class FederationStatsPage { @@ -68,9 +68,12 @@ public class FederationStatsPage TagDataManager data = new TagDataManager(); data.setContent("turnoutChart", Htmlizer.htmlizeOrganizationTurnoutChart(federation.getOrganizations())); + data.setContent("organizationCountryChart", Htmlizer.htmlizeOrganizationCountryChart(federation.getOrganizations())); + data.setContent("hostServerTypeChart", Htmlizer.htmlizeHostServerTypeChart(federation.getAllServices())); data.setContent("hostProviderTypeChart", Htmlizer.htmlizeHostProviderTypeChart(federation.getAllServices())); data.setContent("serviceInstallTypeChart", Htmlizer.htmlizeServiceInstallTypeChart(federation.getAllServices())); + data.setContent("serviceCountryChart", Htmlizer.htmlizeServiceCountryChart(federation.getAllServices())); // { diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index 074e81f..7ac5da4 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -41,6 +41,7 @@ import fr.devinsy.statoolinfos.htmlize.charts.PieChart; import fr.devinsy.statoolinfos.htmlize.charts.PieChart.Position; import fr.devinsy.statoolinfos.htmlize.charts.PieChartView; import fr.devinsy.statoolinfos.stats.StatAgent; +import fr.devinsy.statoolinfos.stats.country.CountryStats; import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats; import fr.devinsy.statoolinfos.stats.services.HostProviderTypeStats; import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats; @@ -247,6 +248,31 @@ public class Htmlizer return result; } + /** + * @param organizations + * @return + * @throws StatoolInfosException + */ + public static String htmlizeOrganizationCountryChart(final Organizations organizations) throws StatoolInfosException + { + String result; + + CountryStats stats = StatAgent.statsCountry(organizations); + + PieChart pie = new PieChart("Pays des membres"); + int index = 0; + for (String country : stats.keySet()) + { + pie.add(country, stats.get(country), ChartColor.values()[index]); + } + pie.setLegendPosition(Position.RIGHT); + + result = PieChartView.build(pie); + + // + return result; + } + /** * Htmlize organization turnout chart. * @@ -296,6 +322,35 @@ public class Htmlizer return result; } + /** + * Htmlize service country chart. + * + * @param services + * the services + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlizeServiceCountryChart(final Services services) throws StatoolInfosException + { + String result; + + CountryStats stats = StatAgent.statsCountry(services); + + PieChart pie = new PieChart("Pays des services"); + int index = 0; + for (String country : stats.keySet()) + { + pie.add(country, stats.get(country), ChartColor.values()[index]); + } + pie.setLegendPosition(Position.RIGHT); + + result = PieChartView.build(pie); + + // + return result; + } + /** * Htmlize service install type chart. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java index bf2899f..0178606 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationStatsPage.java @@ -89,6 +89,7 @@ public class OrganizationStatsPage data.setContent("hostServerTypeChart", Htmlizer.htmlizeHostServerTypeChart(organization.getServices())); data.setContent("hostProviderTypeChart", Htmlizer.htmlizeHostProviderTypeChart(organization.getServices())); data.setContent("serviceInstallTypeChart", Htmlizer.htmlizeServiceInstallTypeChart(organization.getServices())); + data.setContent("serviceCountryChart", Htmlizer.htmlizeServiceCountryChart(organization.getServices())); // { diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml index f670c81..16e79d3 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml @@ -17,11 +17,13 @@