Added federation statistics page. Added PieChart management.

This commit is contained in:
Christian P. MOMON 2020-11-17 05:44:31 +01:00
parent 7f6bfe2d52
commit 96a7b338c7
18 changed files with 1072 additions and 11 deletions

View file

@ -45,6 +45,25 @@ public class Service extends PathPropertyList
private static Logger logger = LoggerFactory.getLogger(Service.class);
public enum HostProviderType
{
HOME,
HOSTEDBAY,
HOSTEDSERVER,
OUTSOURCED,
UNKNOWN
}
public enum HostServerType
{
NANO,
PHYSICAL,
VIRTUAL,
SHARED,
CLOUD,
UNKNOWN
}
public enum Status
{
OK,
@ -149,6 +168,54 @@ public class Service extends PathPropertyList
return result;
}
/**
* Gets the host provider type.
*
* @return the host provider type
*/
public HostProviderType getHostProviderType()
{
HostProviderType result;
try
{
String value = StringUtils.toRootUpperCase(get("host.provider.type"));
result = HostProviderType.valueOf(value);
}
catch (IllegalArgumentException | NullPointerException exception)
{
result = HostProviderType.UNKNOWN;
}
//
return result;
}
/**
* Gets the host server type.
*
* @return the host server type
*/
public HostServerType getHostServerType()
{
HostServerType result;
try
{
String value = StringUtils.toRootUpperCase(get("host.server.type"));
result = HostServerType.valueOf(value);
}
catch (IllegalArgumentException | NullPointerException exception)
{
result = HostServerType.UNKNOWN;
}
//
return result;
}
public File getInputFile()
{
return this.inputFile;

View file

@ -0,0 +1,111 @@
/*
* Copyright (C) 2020 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.htmlize;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.statoolinfos.htmlize.charts.PieChart;
import fr.devinsy.statoolinfos.htmlize.charts.PieChartView;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats;
import fr.devinsy.statoolinfos.stats.services.HostProviderTypeStats;
import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class SocialNetworksPage.
*/
public class FederationStatsPage
{
private static Logger logger = LoggerFactory.getLogger(FederationStatsPage.class);
/**
* Builds the.
*
* @param title
* the title
* @param organizations
* the organizations
* @return the string
* @throws StatoolInfosException
* the statool infos exception
* @throws IOException
*/
public static void build() throws StatoolInfosException, IOException
{
try
{
logger.debug("Building federation stats page {}…");
Federation federation = HtmlizerContext.instance().getFederation();
// CrawlCache cache = HtmlizerContext.instance().getCache();
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
TagDataManager data = new TagDataManager();
//
{
OrganizationTurnoutStats turnout = StatAgent.statsOrganizationTurnout(federation);
PieChart pie = new PieChart("Participation");
pie.add("Active", turnout.getActiveCount(), ChartColor.GREEN);
pie.add("Passive", turnout.getPassiveCount(), ChartColor.ORANGE);
data.setContent("turnoutChart", PieChartView.build(pie));
}
//
{
HostServerTypeStats stats = StatAgent.statHostServerType(federation);
PieChart pie = Htmlizer.toPieChart(stats);
data.setContent("hostServerTypeChart", PieChartView.build(pie));
}
//
{
HostProviderTypeStats stats = StatAgent.statHostProviderType(federation);
PieChart pie = Htmlizer.toPieChart(stats);
data.setContent("hostProviderTypeChart", PieChartView.build(pie));
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationStats.xhtml", data).toString();
//
BreadcrumbTrail trail = new BreadcrumbTrail();
String page = WebCharterView.build(content, trail);
FileUtils.write(new File(htmlizeDirectory, "federationStats.xhtml"), page, StandardCharsets.UTF_8);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building federation stats page: " + exception.getMessage(), exception);
}
}
}

View file

@ -31,6 +31,11 @@ import fr.devinsy.statoolinfos.core.Category;
import fr.devinsy.statoolinfos.core.Configuration;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.statoolinfos.htmlize.charts.PieChart;
import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats;
import fr.devinsy.statoolinfos.stats.services.HostProviderTypeStats;
import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats;
/**
* The Class Htmlizer.
@ -254,6 +259,7 @@ public class Htmlizer
AboutPage.build();
EditoPage.build();
FederationStatsPage.build();
FederationPage.build();
OrganizationPage.buildAll();
ServicePage.buildAll();
@ -267,4 +273,68 @@ public class Htmlizer
SoftwarePage.buildAll();
SocialNetworksPage.buildAll();
}
/**
* To pie chart.
*
* @param stats
* the stats
* @return the pie chart
*/
public static PieChart toPieChart(final HostProviderTypeStats stats)
{
PieChart result;
result = new PieChart("Types d'hébergement");
result.add("Home", stats.getHomeCount(), ChartColor.GREEN);
result.add("Baie", stats.getHostedBayCount(), ChartColor.YELLOW);
result.add("Serveur", stats.getHostedServerCount(), ChartColor.ORANGE);
result.add("Externalisé", stats.getOutsourcedCount(), ChartColor.RED);
result.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE);
//
return result;
}
/**
* To pie chart.
*
* @param source
* the source
* @return the pie chart
*/
public static PieChart toPieChart(final HostServerTypeStats stats)
{
PieChart result;
result = new PieChart("Types de serveur");
result.add("Nano", stats.getNanoCount(), ChartColor.GREEN);
result.add("Physique", stats.getPhysicalCount(), ChartColor.PURPLE);
result.add("Virtuel", stats.getVirtualCount(), ChartColor.YELLOW);
result.add("Mutualisé", stats.getSharedCount(), ChartColor.ORANGE);
result.add("Cloud", stats.getCloudCount(), ChartColor.RED);
result.add("Inconnu", stats.getUnknownCount(), ChartColor.BLUE);
//
return result;
}
/**
* To pie chart.
*
* @param stats
* the stats
* @return the pie chart
*/
public static PieChart toPieChart(final OrganizationTurnoutStats stats)
{
PieChart result;
result = new PieChart("Participation");
result.add("Active", stats.getActiveCount(), ChartColor.GREEN);
result.add("Passive", stats.getPassiveCount(), ChartColor.ORANGE);
//
return result;
}
}

View file

@ -35,7 +35,7 @@ import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.htmlize.charts.BarMonthsChartView;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColors;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.DisplayMode;
import fr.devinsy.xidyn.data.TagDataManager;
@ -219,7 +219,7 @@ public class ServicePage
metric = service.getMetric("metrics.http.errors");
if ((metric != null) && (!metric.isEmpty()))
{
data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColors.RED));
data.setContent("fooChart", graphicIndex++, BarMonthsChartView.build(metric, ChartColor.RED));
}
//

View file

@ -50,7 +50,7 @@ public class BarMonthsChartView
{
String result;
result = build(metric, ChartColors.BLUE);
result = build(metric, ChartColor.BLUE);
//
return result;
@ -64,7 +64,7 @@ public class BarMonthsChartView
* @return the string
* @throws StatoolInfosException
*/
public static String build(final Metric metric, final ChartColors color) throws StatoolInfosException
public static String build(final Metric metric, final ChartColor color) throws StatoolInfosException
{
String result;
@ -95,7 +95,7 @@ public class BarMonthsChartView
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final String title, final String description, final StringList labels, final StringList values, final ChartColors color) throws StatoolInfosException
public static String build(final String title, final String description, final StringList labels, final StringList values, final ChartColor color) throws StatoolInfosException
{
String result;
try

View file

@ -29,7 +29,7 @@ import fr.devinsy.strings.StringList;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class projectsRawPageBuilder.
* The Class BarTimeChartView.
*/
public class BarTimeChartView
{

View file

@ -19,16 +19,16 @@
package fr.devinsy.statoolinfos.htmlize.charts;
/**
* The Enum ChartColors.
* The Enum ChartColor.
*/
public enum ChartColors
public enum ChartColor
{
RED("rgb(255, 99, 132)"),
ORANGE("rgb(255, 159, 64)"),
YELLOW("rgb(255, 205, 86)"),
GREEN("rgb(75, 192, 192)"),
BLUE("rgb(54, 162, 235)"),
PURPLE("'rgb(153, 102, 255)"),
PURPLE("rgb(153, 102, 255)"),
GREY("rgb(201, 203, 207)");
private String code;
@ -40,7 +40,7 @@ public enum ChartColors
* @param code
* the code
*/
ChartColors(final String code)
ChartColor(final String code)
{
this.code = code;
this.light = code.replace(")", ", 0.2)");
@ -62,7 +62,7 @@ public enum ChartColors
}
/**
* Gamma.
* Light.
*
* @return the string
*/

View file

@ -0,0 +1,148 @@
/*
* Copyright (C) 2020 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.htmlize.charts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.strings.StringList;
/**
* The Class PieChart.
*/
public class PieChart
{
private static Logger logger = LoggerFactory.getLogger(PieChart.class);
private String title;
private boolean displayTitle;
private PieChartDatas datas;
/**
* Instantiates a new pie chart.
*/
public PieChart(final String title)
{
this.title = title;
this.displayTitle = true;
this.datas = new PieChartDatas();
}
/**
* Adds the.
*
* @param label
* the label
* @param value
* the value
* @param color
* the color
*/
public void add(final String label, final double value, final ChartColor color)
{
this.datas.add(new PieChartData(label, value, color));
}
/**
* Gets the colors.
*
* @return the colors
*/
public StringList getColors()
{
StringList result;
result = new StringList();
for (PieChartData data : this.datas)
{
result.add(data.getColor().code());
}
//
return result;
}
public PieChartDatas getDatas()
{
return this.datas;
}
/**
* Gets the labels.
*
* @return the labels
*/
public StringList getLabels()
{
StringList result;
result = new StringList();
for (PieChartData data : this.datas)
{
result.add(data.getLabel());
}
//
return result;
}
public String getTitle()
{
return this.title;
}
/**
* Gets the values.
*
* @return the values
*/
public double[] getValues()
{
double[] result;
result = new double[this.datas.size()];
int index = 0;
for (PieChartData data : this.datas)
{
result[index] = data.getValue();
index += 1;
}
//
return result;
}
public boolean isDisplayTitle()
{
return this.displayTitle;
}
public void setDisplayTitle(final boolean displayTitle)
{
this.displayTitle = displayTitle;
}
public void setTitle(final String title)
{
this.title = title;
}
}

View file

@ -0,0 +1,81 @@
/*
* Copyright (C) 2020 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.htmlize.charts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class PieChartData.
*/
public class PieChartData
{
private static Logger logger = LoggerFactory.getLogger(PieChartData.class);
private String label;
private double value;
private ChartColor color;
/**
* Instantiates a new pie chart data.
*
* @param label
* the label
* @param value
* the value
* @param color
* the color
*/
public PieChartData(final String label, final double value, final ChartColor color)
{
this.label = label;
this.value = value;
this.color = color;
}
public ChartColor getColor()
{
return this.color;
}
public String getLabel()
{
return this.label;
}
public double getValue()
{
return this.value;
}
public void setColor(final ChartColor color)
{
this.color = color;
}
public void setLabel(final String label)
{
this.label = label;
}
public void setValue(final double value)
{
this.value = value;
}
}

View file

@ -0,0 +1,42 @@
/*
* Copyright (C) 2020 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.htmlize.charts;
import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class PieChartDatas.
*/
public class PieChartDatas extends ArrayList<PieChartData>
{
private static final long serialVersionUID = 6300072061870020566L;
private static Logger logger = LoggerFactory.getLogger(PieChartDatas.class);
/**
* Instantiates a new pie chart datas.
*/
public PieChartDatas()
{
super();
}
}

View file

@ -0,0 +1,95 @@
/*
* Copyright (C) 2020 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.htmlize.charts;
import java.io.IOException;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.strings.StringList;
import fr.devinsy.xidyn.utils.XidynUtils;
/**
* The Class PieChartView.
*/
public class PieChartView
{
private static Logger logger = LoggerFactory.getLogger(PieChartView.class);
/**
* Builds the.
*
* @param pie
* the pie
* @return the string
* @throws StatoolInfosException
*/
public static String build(final PieChart pie) throws StatoolInfosException
{
String result;
result = build(pie.getTitle(), pie.getLabels(), new StringList(pie.getValues()), pie.getColors());
//
return result;
}
/**
* Builds the.
*
* @param title
* the title
* @param description
* the description
* @param labels
* the labels
* @param values
* the values
* @param color
* the color
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final String title, final StringList labels, final StringList values, final StringList colors) throws StatoolInfosException
{
String result;
try
{
String source = XidynUtils.load(PieChartView.class.getResource("/fr/devinsy/statoolinfos/htmlize/charts/pieChartView.xhtml"));
result = XidynUtils.extractBodyContent(source);
result = result.replace("myChart", "myChart_" + DigestUtils.sha1Hex(title + "PieChart"));
result = result.replaceFirst("data: \\[.*\\]", "data: " + ChabuUtils.toJSonNumbers(values));
result = result.replaceFirst("backgroundColor: \\[.*\\]", "backgroundColor: " + ChabuUtils.toJSonStrings(colors));
result = result.replaceFirst("text: '.*'", "text: '" + title.replace("'", "\\\\'") + "'");
result = result.replaceFirst("labels: \\[.*\\]", "labels: " + ChabuUtils.toJSonStrings(labels));
}
catch (IOException exception)
{
throw new StatoolInfosException("Error building bar months chart view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>StatoolInfos</title>
<meta charset="UTF-8" />
<meta name="keywords" content="statoolinfos,devinsy,federation" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="statoolinfos.css" />
<script src="sorttable.js"></script>
<script src="Chart.bundle.min.js"></script>
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="datatables.min.js"></script>
</head>
<body>
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx,
{
type: 'pie',
data: {
datasets:
[{
data: [ 10,40,50 ],
backgroundColor: [window.chartColors.red,window.chartColors.orange,window.chartColors.yellow,window.chartColors.green,window.chartColors.blue],
/*label: 'Dataset 1'*/
}],
labels: ['Red', 'Orange', 'Yellow', 'Green', 'Blue']
},
options:
{
maintainAspectRatio: false,
display: true,
responsive: true,
legend:
{
position: 'right',
},
title:
{
display: true,
text: 'a title'
},
}
});
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>StatoolInfos</title>
<meta charset="UTF-8" />
<meta name="keywords" content="statoolinfos,devinsy,federation" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="statoolinfos.css" />
<script src="sorttable.js" />
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div class="row center_table" style="width: 1100px;">
<h2 id="title" class="center">Statistiques</h2>
<div>
<div>
<div id="turnoutChart" style="width: 250px; height: 200px; display: inline-block; border: 1px solid red;"/>
</div>
<div>
<div id="hostServerTypeChart" style="width: 250px; height: 200px; display: inline-block; border: 1px solid red;"/>
<div id="hostProviderTypeChart" style="width: 250px; height: 200px; display: inline-block; border: 1px solid red;"/>
</div>
</div>
</div>
</body>
</html>

View file

@ -30,6 +30,7 @@
<a id="" href="socialNetworks.xhtml" class="button" style="width: 130px;">Réseaux sociaux</a>
<a id="propertiesRawButton" href="propertiesFiles.xhtml" class="button">Fichiers</a>
<a id="propertiesRawButton" href="propertyStats.xhtml" class="button">Propriétés</a>
<a id="" href="federationStats.xhtml" class="button">Statistiques</a>
</div>
<div id="breadcrumbTrail" style="margin: 5px;">n/a > n/a</div>

View file

@ -21,6 +21,7 @@ package fr.devinsy.statoolinfos.stats;
import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -36,8 +37,11 @@ import fr.devinsy.statoolinfos.core.Softwares;
import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.stats.categories.CategoryStat;
import fr.devinsy.statoolinfos.stats.categories.CategoryStats;
import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats;
import fr.devinsy.statoolinfos.stats.properties.PropertyStats;
import fr.devinsy.statoolinfos.stats.propertyfiles.PropertiesFileStats;
import fr.devinsy.statoolinfos.stats.services.HostProviderTypeStats;
import fr.devinsy.statoolinfos.stats.services.HostServerTypeStats;
import fr.devinsy.statoolinfos.stats.softwares.SoftwareStat;
import fr.devinsy.statoolinfos.stats.softwares.SoftwareStats;
import fr.devinsy.strings.StringSet;
@ -211,6 +215,52 @@ public class StatAgent
return result;
}
/**
* Stat host provider type.
*
* @param federation
* the federation
* @return the host provider type stats
*/
public static HostProviderTypeStats statHostProviderType(final Federation federation)
{
HostProviderTypeStats result;
result = new HostProviderTypeStats();
//
for (Service service : federation.getAllServices())
{
result.inc(service.getHostProviderType());
}
//
return result;
}
/**
* Stat host server type.
*
* @param federation
* the federation
* @return the host server type stats
*/
public static HostServerTypeStats statHostServerType(final Federation federation)
{
HostServerTypeStats result;
result = new HostServerTypeStats();
//
for (Service service : federation.getAllServices())
{
result.inc(service.getHostServerType());
}
//
return result;
}
/**
* Stat organizations properties.
*
@ -251,4 +301,34 @@ public class StatAgent
//
return result;
}
/**
* Stats organization turnout.
*
* @param federation
* the federation
* @return the organization turnout stats
*/
public static OrganizationTurnoutStats statsOrganizationTurnout(final Federation federation)
{
OrganizationTurnoutStats result;
result = new OrganizationTurnoutStats();
//
for (Organization organization : federation.getOrganizations())
{
if (StringUtils.isBlank(organization.getStartDate()))
{
result.incPassiveCount();
}
else
{
result.incActiveCount();
}
}
//
return result;
}
}

View file

@ -0,0 +1,85 @@
/*
* Copyright (C) 2020 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;
/**
* The Class OrganizationTurnoutStats.
*/
public class OrganizationTurnoutStats
{
private long activeCount;
private long passiveCount;
/**
* Instantiates a new organization turnout stats.
*
* @param name
* the name
*/
public OrganizationTurnoutStats()
{
this.activeCount = 0;
this.passiveCount = 0;
}
public long getActiveCount()
{
return this.activeCount;
}
public long getPassiveCount()
{
return this.passiveCount;
}
/**
* Gets the total count.
*
* @return the total count
*/
public long getTotalCount()
{
long result;
result = this.activeCount + this.passiveCount;
//
return result;
}
public void incActiveCount()
{
this.activeCount += 1;
}
public void incPassiveCount()
{
this.passiveCount += 1;
}
public void setActiveCount(final long activeCount)
{
this.activeCount = activeCount;
}
public void setPassiveCount(final long passiveCount)
{
this.passiveCount = passiveCount;
}
}

View file

@ -0,0 +1,97 @@
/*
* Copyright (C) 2020 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.services;
import fr.devinsy.statoolinfos.core.Service.HostProviderType;
/**
* The Class HostProviderTypeStats.
*/
public class HostProviderTypeStats
{
private long homeCount;
private long hostedBayCount;
private long hostedServerCount;
private long outsourcedCount;
private long unknownCount;
/**
* Instantiates a new host provider type stats.
*/
public HostProviderTypeStats()
{
this.homeCount = 0;
this.hostedBayCount = 0;
this.hostedServerCount = 0;
this.outsourcedCount = 0;
this.unknownCount = 0;
}
public long getHomeCount()
{
return this.homeCount;
}
public long getHostedBayCount()
{
return this.hostedBayCount;
}
public long getHostedServerCount()
{
return this.hostedServerCount;
}
public long getOutsourcedCount()
{
return this.outsourcedCount;
}
public long getUnknownCount()
{
return this.unknownCount;
}
/**
* Inc.
*
* @param type
* the type
*/
public void inc(final HostProviderType type)
{
switch (type)
{
case HOME:
this.homeCount += 1;
break;
case HOSTEDBAY:
this.hostedBayCount += 1;
break;
case HOSTEDSERVER:
this.hostedServerCount += 1;
break;
case OUTSOURCED:
this.outsourcedCount += 1;
break;
default:
this.unknownCount += 1;
}
}
}

View file

@ -0,0 +1,107 @@
/*
* Copyright (C) 2020 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.services;
import fr.devinsy.statoolinfos.core.Service.HostServerType;
/**
* The Class HostServerTypeStats.
*/
public class HostServerTypeStats
{
private long nanoCount;
private long physicalCount;
private long virtualCount;
private long sharedCount;
private long cloudCount;
private long unknownCount;
/**
* Instantiates a new host server type stats.
*/
public HostServerTypeStats()
{
this.nanoCount = 0;
this.physicalCount = 0;
this.virtualCount = 0;
this.sharedCount = 0;
this.cloudCount = 0;
this.unknownCount = 0;
}
public long getCloudCount()
{
return this.cloudCount;
}
public long getNanoCount()
{
return this.nanoCount;
}
public long getPhysicalCount()
{
return this.physicalCount;
}
public long getSharedCount()
{
return this.sharedCount;
}
public long getUnknownCount()
{
return this.unknownCount;
}
public long getVirtualCount()
{
return this.virtualCount;
}
/**
* Inc.
*
* @param type
* the type
*/
public void inc(final HostServerType type)
{
switch (type)
{
case NANO:
this.nanoCount += 1;
break;
case PHYSICAL:
this.physicalCount += 1;
break;
case VIRTUAL:
this.virtualCount += 1;
break;
case SHARED:
this.sharedCount += 1;
break;
case CLOUD:
this.cloudCount += 1;
break;
default:
this.unknownCount += 1;
}
}
}