Added federation organization type chart. Improved federation charts.

This commit is contained in:
Christian P. MOMON 2022-07-23 01:24:23 +02:00
parent fbf6e50b49
commit edc60840d0
6 changed files with 253 additions and 5 deletions

View file

@ -43,9 +43,6 @@ public class Organization extends PathPropertyList
{ {
private static final long serialVersionUID = -2709210934548224213L; private static final long serialVersionUID = -2709210934548224213L;
/**
* The Enum Status.
*/
public enum Status public enum Status
{ {
ACTIVE, ACTIVE,
@ -53,6 +50,17 @@ public class Organization extends PathPropertyList
AWAY AWAY
} }
public enum Type
{
ASSOCIATION,
COMPANY,
COOPERATIVE,
INDIVIDUAL,
INFORMAL,
MICROCOMPANY,
OTHER
}
private Federation federation; private Federation federation;
private Services services; private Services services;
private File inputFile; private File inputFile;
@ -813,6 +821,49 @@ public class Organization extends PathPropertyList
return result; 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. * Gets the URL all.
* *

View file

@ -60,6 +60,7 @@ import fr.devinsy.statoolinfos.stats.categories.CategoryStat;
import fr.devinsy.statoolinfos.stats.categories.CategoryStats; import fr.devinsy.statoolinfos.stats.categories.CategoryStats;
import fr.devinsy.statoolinfos.stats.country.CountryStats; import fr.devinsy.statoolinfos.stats.country.CountryStats;
import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats; 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.HostProviderTypeStats;
import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats; import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats;
import fr.devinsy.statoolinfos.stats.services.RegistrationStats; import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
@ -1074,6 +1075,40 @@ public class ChartHtmlizer
return result; 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. * Htmlize registration chart.
* *

View file

@ -96,11 +96,14 @@ public class FederationStatsPage
} }
data.setContent("serviceDateStatusChart", ChartHtmlizer.htmlizeServiceDateStatusChart(services)); 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("softwareDistributionChart", ChartHtmlizer.htmlizeSoftwareDistributionChart());
data.setContent("softwareDistributionPieChart", ChartHtmlizer.htmlizeSoftwareDistributionPieChart(services));
data.setContent("categoryDistributionChart", ChartHtmlizer.htmlizeCategoryDistributionChart()); data.setContent("categoryDistributionChart", ChartHtmlizer.htmlizeCategoryDistributionChart());
data.setContent("categoryDistributionPieChart", ChartHtmlizer.htmlizeCatergoryDistributionPieChart(services));
// //
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml", data).toString(); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml", data).toString();

View file

@ -50,6 +50,7 @@
</div> </div>
<div id="serviceDateStatusChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/> <div id="serviceDateStatusChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
</div> </div>
<div id="organisationTypeChart" class="chartborder" style="width: 500px; height: 250px; display: inline-block;"/>
<div> <div>
<div id="categoryDistributionPieChart" class="chartborder" style="width: 500px; height: 300px; display: inline-block;"/> <div id="categoryDistributionPieChart" class="chartborder" style="width: 500px; height: 300px; display: inline-block;"/>
<div id="softwareDistributionPieChart" class="chartborder" style="width: 500px; height: 300px; display: inline-block;"/> <div id="softwareDistributionPieChart" class="chartborder" style="width: 500px; height: 300px; display: inline-block;"/>

View file

@ -44,6 +44,7 @@ import fr.devinsy.statoolinfos.stats.categories.CategoryStat;
import fr.devinsy.statoolinfos.stats.categories.CategoryStats; import fr.devinsy.statoolinfos.stats.categories.CategoryStats;
import fr.devinsy.statoolinfos.stats.country.CountryStats; import fr.devinsy.statoolinfos.stats.country.CountryStats;
import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats; import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats;
import fr.devinsy.statoolinfos.stats.organizations.OrganizationTypeStats;
import fr.devinsy.statoolinfos.stats.properties.PropertyStats; import fr.devinsy.statoolinfos.stats.properties.PropertyStats;
import fr.devinsy.statoolinfos.stats.propertyfiles.PropertiesFileStats; import fr.devinsy.statoolinfos.stats.propertyfiles.PropertiesFileStats;
import fr.devinsy.statoolinfos.stats.services.HostProviderTypeStats; import fr.devinsy.statoolinfos.stats.services.HostProviderTypeStats;
@ -328,6 +329,29 @@ public class StatAgent
return result; return result;
} }
/**
* Stat organization type.
*
* @param organization
* the organization
* @return the organization type stats
*/
public static OrganizationTypeStats statOrganizationType(final Organizations organizations)
{
OrganizationTypeStats result;
result = new OrganizationTypeStats();
//
for (Organization organization : organizations)
{
result.inc(organization.getType());
}
//
return result;
}
/** /**
* Stat registration types. * Stat registration types.
* *

View file

@ -0,0 +1,134 @@
/*
* Copyright (C) 2022 Christian Pierre MOMON <christian@momon.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.stats.organizations;
import fr.devinsy.statoolinfos.core.Organization;
/**
* The Class OrganizationTypeStats.
*/
public class OrganizationTypeStats
{
private long associationCount;
private long informalCount;
private long cooperativeCount;
private long microcompanyCount;
private long companyCount;
private long individualCount;
private long otherCount;
private long unknownCount;
/**
* Instantiates a new organization type stats.
*/
public OrganizationTypeStats()
{
this.associationCount = 0;
this.informalCount = 0;
this.cooperativeCount = 0;
this.microcompanyCount = 0;
this.companyCount = 0;
this.individualCount = 0;
this.otherCount = 0;
this.unknownCount = 0;
}
public long getAssociationCount()
{
return this.associationCount;
}
public long getCompanyCount()
{
return this.companyCount;
}
public long getCooperativeCount()
{
return this.cooperativeCount;
}
public long getIndividualCount()
{
return this.individualCount;
}
public long getInformalCount()
{
return this.informalCount;
}
public long getMicrocompanyCount()
{
return this.microcompanyCount;
}
public long getOtherCount()
{
return this.otherCount;
}
public long getUnknownCount()
{
return this.unknownCount;
}
/**
* Inc.
*
* @param type
* the type
*/
public void inc(final Organization.Type type)
{
if (type == null)
{
this.unknownCount += 1;
}
else
{
switch (type)
{
case ASSOCIATION:
this.associationCount += 1;
break;
case COMPANY:
this.companyCount += 1;
break;
case COOPERATIVE:
this.cooperativeCount += 1;
break;
case INDIVIDUAL:
this.individualCount += 1;
break;
case INFORMAL:
this.informalCount += 1;
break;
case MICROCOMPANY:
this.microcompanyCount += 1;
break;
case OTHER:
this.otherCount += 1;
break;
default:
this.unknownCount += 1;
}
}
}
}