Improved property stats.

This commit is contained in:
Christian P. MOMON 2020-09-21 00:20:14 +02:00
parent ea08e62eb0
commit 4604ab1e7b
9 changed files with 485 additions and 14 deletions

View file

@ -65,6 +65,26 @@ public class Federation extends PathPropertyList
}
}
/**
* Gets the all services.
*
* @return the all services
*/
public Services getAllServices()
{
Services result;
result = new Services();
for (Organization organization : this.organizations)
{
result.addAll(organization.getServices());
}
//
return result;
}
/**
* Gets the description.
*

View file

@ -255,10 +255,15 @@ public class Htmlizer
FileUtils.write(new File(htmlizeDirectory, "propertiesFiles.xhtml"), page, StandardCharsets.UTF_8);
//
logger.info("Htmlize propertyStats page.");
PropertyStats stats = StatAgent.statProperties(federation);
page = PropertyStatsPage.build(stats);
FileUtils.write(new File(htmlizeDirectory, "propertyStats.xhtml"), page, StandardCharsets.UTF_8);
{
logger.info("Htmlize propertyStats page.");
PropertyStats stats = StatAgent.statAllProperties(federation);
PropertyStats federationStats = StatAgent.statFederationProperties(federation);
PropertyStats organizationsStats = StatAgent.statOrganizationsProperties(federation.getOrganizations());
PropertyStats servicesStats = StatAgent.statServicesProperties(federation.getAllServices());
page = PropertyStatsPage2.build(stats, federationStats, organizationsStats, servicesStats);
FileUtils.write(new File(htmlizeDirectory, "propertyStats.xhtml"), page, StandardCharsets.UTF_8);
}
}
/**

View file

@ -0,0 +1,71 @@
/*
* 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.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.util.BuildInformation;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class MainMenuView.
*/
public class MainMenuView
{
private static Logger logger = LoggerFactory.getLogger(MainMenuView.class);
/**
* Builds the.
*
* @param federation
* the organization
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final String... paths) throws StatoolInfosException
{
String result;
try
{
TagDataManager data = new TagDataManager();
data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/mainMenu.xhtml", data).toString();
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building mainMenu view: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -35,7 +35,7 @@ import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationPage.
* The Class PropertyStatsPage.
*/
public class PropertyStatsPage
{
@ -78,7 +78,7 @@ public class PropertyStatsPage
index += 1;
}
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml", data).toString();
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyStats2.xhtml", data).toString();
}
catch (XidynException exception)
{

View file

@ -0,0 +1,145 @@
/*
* 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.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.stats.PropertyStat;
import fr.devinsy.statoolinfos.stats.PropertyStats;
import fr.devinsy.statoolinfos.util.BuildInformation;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationPage.
*/
public class PropertyStatsPage2
{
private static Logger logger = LoggerFactory.getLogger(PropertyStatsPage2.class);
/**
* Builds the.
*
* @param service
* the service
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String build(final PropertyStats stats, final PropertyStats federationStats, final PropertyStats organizationsStats, final PropertyStats servicesStats) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building propertyStats page…");
TagDataManager data = new TagDataManager();
data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
//
data.setContent("statsTitle", "Tous");
data.setContent("propertyCount", stats.getPropertyCount());
data.setContent("fileCount", stats.getFileCount());
int index = 0;
for (PropertyStat stat : stats.getList().sortByFilledCount().reverse())
{
data.setEscapedContent("propertyLine", index, "propertyLinePath", stat.getPath());
data.setContent("propertyLine", index, "propertyLineBlankCount", stat.getBlankCount());
data.setContent("propertyLine", index, "propertyLineBlankCountPercentage", StatoolInfosUtils.toPercentage(stat.getBlankCount(), stats.getFileCount()));
data.setContent("propertyLine", index, "propertyLineFilledCount", stat.getFilledCount());
data.setContent("propertyLine", index, "propertyLineFilledCountPercentage", StatoolInfosUtils.toPercentage(stat.getFilledCount(), stats.getFileCount()));
index += 1;
}
//
data.setContent("statsTitleF", "Fédération");
data.setContent("propertyCountF", federationStats.getPropertyCount());
data.setContent("fileCountF", federationStats.getFileCount());
index = 0;
for (PropertyStat stat : federationStats.getList().sortByFilledCount().reverse())
{
data.setEscapedContent("propertyLineF", index, "propertyLinePathF", stat.getPath());
data.setContent("propertyLineF", index, "propertyLineBlankCountF", stat.getBlankCount());
data.setContent("propertyLineF", index, "propertyLineBlankCountPercentageF", StatoolInfosUtils.toPercentage(stat.getBlankCount(), federationStats.getFileCount()));
data.setContent("propertyLineF", index, "propertyLineFilledCountF", stat.getFilledCount());
data.setContent("propertyLineF", index, "propertyLineFilledCountPercentageF", StatoolInfosUtils.toPercentage(stat.getFilledCount(), federationStats.getFileCount()));
index += 1;
}
//
data.setContent("statsTitleO", "Organisations");
data.setContent("propertyCountO", organizationsStats.getPropertyCount());
data.setContent("fileCountO", organizationsStats.getFileCount());
index = 0;
for (PropertyStat stat : organizationsStats.getList().sortByFilledCount().reverse())
{
data.setEscapedContent("propertyLineO", index, "propertyLinePathO", stat.getPath());
data.setContent("propertyLineO", index, "propertyLineBlankCountO", stat.getBlankCount());
data.setContent("propertyLineO", index, "propertyLineBlankCountPercentageO", StatoolInfosUtils.toPercentage(stat.getBlankCount(), organizationsStats.getFileCount()));
data.setContent("propertyLineO", index, "propertyLineFilledCountO", stat.getFilledCount());
data.setContent("propertyLineO", index, "propertyLineFilledCountPercentageO", StatoolInfosUtils.toPercentage(stat.getFilledCount(), organizationsStats.getFileCount()));
index += 1;
}
//
data.setContent("statsTitleS", "Services");
data.setContent("propertyCountS", servicesStats.getPropertyCount());
data.setContent("fileCountS", servicesStats.getFileCount());
index = 0;
for (PropertyStat stat : servicesStats.getList().sortByFilledCount().reverse())
{
data.setEscapedContent("propertyLineS", index, "propertyLinePathS", stat.getPath());
data.setContent("propertyLineS", index, "propertyLineBlankCountS", stat.getBlankCount());
data.setContent("propertyLineS", index, "propertyLineBlankCountPercentageS", StatoolInfosUtils.toPercentage(stat.getBlankCount(), servicesStats.getFileCount()));
data.setContent("propertyLineS", index, "propertyLineFilledCountS", stat.getFilledCount());
data.setContent("propertyLineS", index, "propertyLineFilledCountPercentageS", StatoolInfosUtils.toPercentage(stat.getFilledCount(), servicesStats.getFileCount()));
index += 1;
}
//
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyStats2.xhtml", data).toString();
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
//
return result;
}
}

View file

@ -0,0 +1,26 @@
<?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 style="margin: 5px 10px 10px 10px;">
<h1><a href="index.xhtml"><img src="logo.jpg" style="width: 35px;"/> StatoolInfos</a><sup id="versionsup" style="font-size: 9px;">v0.0.14</sup> <a href="about.xhtml">À propos</a><span style="font-size: 9px; float: right;">Page updated on<br/><span id="lastUpdateDate" style="font-size: 9px;">xx/xx/xxxx xx:xx</span></span></h1>
<div style="margin: 5px;">
<a id="propertiesRawButton" href="propertiesFiles.xhtml" class="button">Properties</a>
<a id="propertiesRawButton" href="propertyStats.xhtml" class="button">Property Stats</a>
</div>
<div>
<a href="index.xhtml">Accueil</a> <span id="menuPath"> <span id="menuPathItem"></span></span>
</div>
</div>
</body>
</html>

View file

@ -27,9 +27,9 @@
<thead>
<tr>
<th style="width: 150px;">Path</th>
<th style="width: 20px;">Filled Count</th>
<th style="width: 10px;">Filled Count</th>
<th style="width: 10px;">File&#160;%</th>
<th style="width: 20px;">Blank Count</th>
<th style="width: 10px;">Blank Count</th>
<th style="width: 10px;">File&#160;%</th>
</tr>
</thead>
@ -45,6 +45,7 @@
</table>
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,143 @@
<?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 style="margin: 5px 10px 10px 10px;">
<h1><a href="index.xhtml"><img src="logo.jpg" style="width: 35px;"/> StatoolInfos</a><sup id="versionsup" style="font-size: 9px;">v0.0.14</sup> <a href="about.xhtml">À propos</a><span style="font-size: 9px; float: right;">Page updated on<br/><span id="lastUpdateDate" style="font-size: 9px;">xx/xx/xxxx xx:xx</span></span></h1>
<div style="margin: 5px;">
<a id="propertiesRawButton" href="#" class="button">Property Stats</a>
</div>
<div class="row center_table" style="width: 1100px;">
<div class="column center">
<h2 id="statsTitleO">Statistics des property</h2>
<div>Nombre de property : <span id="propertyCountO">n/a</span></div>
<div>Nombre de fichiers : <span id="fileCountO">n/a</span></div>
<div class="left">
<table class="table_classic center_table sortable">
<thead>
<tr>
<th style="width: 150px;">Path</th>
<th style="width: 10px;">Filled Count</th>
<th style="width: 10px;">File&#160;%</th>
<th style="width: 10px;">Blank Count</th>
<th style="width: 10px;">File&#160;%</th>
</tr>
</thead>
<tbody>
<tr id="propertyLineO">
<td id="propertyLinePathO" class="">n/a</td>
<td id="propertyLineFilledCountO" class="td_number">n/a</td>
<td id="propertyLineFilledCountPercentageO" class="td_number">n/a</td>
<td id="propertyLineBlankCountO" class="td_number">n/a</td>
<td id="propertyLineBlankCountPercentageO" class="td_number">n/a</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="column" style="width: 20px;">&#160;</div>
<div class="column center">
<h2 id="statsTitleS">Statistics des property</h2>
<div>Nombre de property : <span id="propertyCountS">n/a</span></div>
<div>Nombre de fichiers : <span id="fileCountS">n/a</span></div>
<div class="left">
<table class="table_classic center_table sortable " style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="width: 150px;">Path</th>
<th style="width: 10px;">Filled Count</th>
<th style="width: 10px;">File&#160;%</th>
<th style="width: 10px;">Blank Count</th>
<th style="width: 10px;">File&#160;%</th>
</tr>
</thead>
<tbody>
<tr id="propertyLineS">
<td id="propertyLinePathS" class="">n/a</td>
<td id="propertyLineFilledCountS" class="td_number">n/a</td>
<td id="propertyLineFilledCountPercentageS" class="td_number">n/a</td>
<td id="propertyLineBlankCountS" class="td_number">n/a</td>
<td id="propertyLineBlankCountPercentageS" class="td_number">n/a</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row center_table" style="width: 1100px;">
<div class="column center">
<h2 id="statsTitle">Statistics des property</h2>
<div>Nombre de property : <span id="propertyCount">n/a</span></div>
<div>Nombre de fichiers : <span id="fileCount">n/a</span></div>
<div class="left">
<table class="table_classic center_table sortable " style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="width: 150px;">Path</th>
<th style="width: 10px;">Filled Count</th>
<th style="width: 10px;">File&#160;%</th>
<th style="width: 10px;">Blank Count</th>
<th style="width: 10px;">File&#160;%</th>
</tr>
</thead>
<tbody>
<tr id="propertyLine">
<td id="propertyLinePath" class="">n/a</td>
<td id="propertyLineFilledCount" class="td_number">n/a</td>
<td id="propertyLineFilledCountPercentage" class="td_number">n/a</td>
<td id="propertyLineBlankCount" class="td_number">n/a</td>
<td id="propertyLineBlankCountPercentage" class="td_number">n/a</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="column" style="width: 20px;">&#160;</div>
<div class="column center">
<h2 id="statsTitleF">Statistics des property</h2>
<div>Nombre de property : <span id="propertyCountF">n/a</span></div>
<div>Nombre de fichiers : <span id="fileCountF">n/a</span></div>
<div class="left">
<table class="table_classic center_table sortable " style="margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="width: 150px;">Path</th>
<th style="width: 10px;">Filled Count</th>
<th style="width: 10px;">File&#160;%</th>
<th style="width: 10px;">Blank Count</th>
<th style="width: 10px;">File&#160;%</th>
</tr>
</thead>
<tbody>
<tr id="propertyLineF">
<td id="propertyLinePathF" class="">n/a</td>
<td id="propertyLineFilledCountF" class="td_number">n/a</td>
<td id="propertyLineFilledCountPercentageF" class="td_number">n/a</td>
<td id="propertyLineBlankCountF" class="td_number">n/a</td>
<td id="propertyLineBlankCountPercentageF" class="td_number">n/a</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>

View file

@ -20,7 +20,9 @@ package fr.devinsy.statoolinfos.stats;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Organizations;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services;
/**
* The Class StatAgent.
@ -42,24 +44,82 @@ public class StatAgent
* the fedration
* @return the property stats
*/
public static PropertyStats statProperties(final Federation federation)
public static PropertyStats statAllProperties(final Federation federation)
{
PropertyStats result;
PropertyStats stats = new PropertyStats();
result = new PropertyStats();
stats.stat(federation);
result.stat(federation);
for (Organization organization : federation.getOrganizations())
{
stats.stat(organization);
result.stat(organization);
for (Service service : organization.getServices())
{
stats.stat(service);
result.stat(service);
}
}
result = stats;
//
return result;
}
/**
* Stat federation properties.
*
* @param federation
* the federation
* @return the property stats
*/
public static PropertyStats statFederationProperties(final Federation federation)
{
PropertyStats result;
result = new PropertyStats();
result.stat(federation);
//
return result;
}
/**
* Stat organization properties.
*
* @param organization
* the federation
* @return the property stats
*/
public static PropertyStats statOrganizationsProperties(final Organizations organizations)
{
PropertyStats result;
result = new PropertyStats();
for (Organization organization : organizations)
{
result.stat(organization);
}
//
return result;
}
/**
* @param services
* @return
*/
public static PropertyStats statServicesProperties(final Services services)
{
PropertyStats result;
result = new PropertyStats();
for (Service service : services)
{
result.stat(service);
}
//
return result;