diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java index b09dd5f..e8c898f 100644 --- a/src/fr/devinsy/statoolinfos/core/Organization.java +++ b/src/fr/devinsy/statoolinfos/core/Organization.java @@ -43,9 +43,6 @@ public class Organization extends PathPropertyList { private static final long serialVersionUID = -2709210934548224213L; - /** - * The Enum Status. - */ public enum Status { ACTIVE, @@ -53,6 +50,17 @@ public class Organization extends PathPropertyList AWAY } + public enum Type + { + ASSOCIATION, + COMPANY, + COOPERATIVE, + INDIVIDUAL, + INFORMAL, + MICROCOMPANY, + OTHER + } + private Federation federation; private Services services; private File inputFile; @@ -813,6 +821,49 @@ public class Organization extends PathPropertyList return result; } + public Type getType() + { + Type result; + + String value = get("organization.type"); + + if (StringUtils.isBlank(value)) + { + result = null; + } + else if (StringUtils.equalsIgnoreCase(value, "ASSOCIATION")) + { + result = Type.ASSOCIATION; + } + else if (StringUtils.equalsIgnoreCase(value, "COOPERATIVE")) + { + result = Type.COOPERATIVE; + } + else if (StringUtils.equalsIgnoreCase(value, "MICROCOMPANY")) + { + result = Type.MICROCOMPANY; + } + else if (StringUtils.equalsIgnoreCase(value, "COMPANY")) + { + result = Type.COMPANY; + } + else if (StringUtils.equalsIgnoreCase(value, "INDIVIDUAL")) + { + result = Type.INDIVIDUAL; + } + else if (StringUtils.equalsIgnoreCase(value, "OTHER")) + { + result = Type.OTHER; + } + else + { + result = null; + } + + // + return result; + } + /** * Gets the URL all. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java index e55456e..8483a1c 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ChartHtmlizer.java @@ -60,6 +60,7 @@ import fr.devinsy.statoolinfos.stats.categories.CategoryStat; import fr.devinsy.statoolinfos.stats.categories.CategoryStats; import fr.devinsy.statoolinfos.stats.country.CountryStats; import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats; +import fr.devinsy.statoolinfos.stats.organizations.OrganizationTypeStats; import fr.devinsy.statoolinfos.stats.services.HostProviderTypeStats; import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats; import fr.devinsy.statoolinfos.stats.services.RegistrationStats; @@ -1074,6 +1075,40 @@ public class ChartHtmlizer return result; } + /** + * Htmlize organization type chart. + * + * @param services + * the services + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlizeOrganizationTypeChart(final Organizations organizations) throws StatoolInfosException + { + String result; + + OrganizationTypeStats stats = StatAgent.statOrganizationType(organizations); + + // {ASSOCIATION, INFORMAL, COOPERATIVE, MICROCOMPANY, COMPANY, + // INDIVIDUAL, OTHER}, obligatoire). + PieChart pie = new PieChart("Types d'organisations"); + pie.add("Association", stats.getAssociationCount(), ChartColor.GREEN); + pie.add("Informel", stats.getInformalCount(), ChartColor.YELLOW); + pie.add("Coopérative", stats.getCooperativeCount(), ChartColor.ORANGE); + pie.add("Micro-entreprise", stats.getMicrocompanyCount(), ChartColor.RED); + pie.add("Entreprise", stats.getCompanyCount(), ChartColor.VIOLET); + pie.add("Individu", stats.getIndividualCount(), ChartColor.PURPLE); + pie.add("Autre", stats.getOtherCount(), ChartColor.GREY); + pie.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE); + pie.setLegendPosition(Position.RIGHT); + + result = DoughnutChartView.build(pie); + + // + return result; + } + /** * Htmlize registration chart. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java index 575156f..9ac717b 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationStatsPage.java @@ -96,11 +96,14 @@ public class FederationStatsPage } data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services)); + data.setContent("organisationTypeChart", ChartHtmlizer.htmlizeOrganizationTypeChart(organizations)); + + data.setContent("softwareDistributionPieChart", ChartHtmlizer.htmlizeSoftwareDistributionPieChart(services)); + data.setContent("categoryDistributionPieChart", ChartHtmlizer.htmlizeCatergoryDistributionPieChart(services)); data.setContent("softwareDistributionChart", ChartHtmlizer.htmlizeSoftwareDistributionChart()); - data.setContent("softwareDistributionPieChart", ChartHtmlizer.htmlizeSoftwareDistributionPieChart(services)); + data.setContent("categoryDistributionChart", ChartHtmlizer.htmlizeCategoryDistributionChart()); - 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/federationStats.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml index 877f571..f858b04 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml @@ -50,6 +50,7 @@
+