Added property stats.
This commit is contained in:
parent
62f35ee4f5
commit
516398c893
15 changed files with 771 additions and 21 deletions
|
@ -311,6 +311,25 @@ public class StatoolInfosUtils
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* To percentage.
|
||||
*
|
||||
* @param value
|
||||
* the value
|
||||
* @param max
|
||||
* the max
|
||||
* @return the string
|
||||
*/
|
||||
public static String toPercentage(final int value, final int max)
|
||||
{
|
||||
String result;
|
||||
|
||||
result = (value * 100 / max) + " %";
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* To technical name.
|
||||
*
|
||||
|
|
|
@ -55,15 +55,13 @@ public class FederationPage
|
|||
|
||||
try
|
||||
{
|
||||
logger.debug("Building federation page {}…", federation.getName());
|
||||
logger.debug("Building propoertiesFile page {}…", federation.getName());
|
||||
|
||||
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.setAttribute("federationRawButton", "href", federation.getTechnicalName() + ".properties");
|
||||
|
||||
data.setAttribute("federationLogo", "src", federation.getTechnicalName() + "-logo.png");
|
||||
data.setEscapedContent("federationName", federation.getName());
|
||||
data.setEscapedContent("federationDescription", federation.getDescription());
|
||||
|
|
|
@ -35,6 +35,8 @@ import fr.devinsy.statoolinfos.core.Service;
|
|||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
|
||||
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
||||
import fr.devinsy.statoolinfos.stats.PropertyStats;
|
||||
import fr.devinsy.statoolinfos.stats.StatAgent;
|
||||
|
||||
/**
|
||||
* The Class Htmlizer.
|
||||
|
@ -246,15 +248,16 @@ public class Htmlizer
|
|||
}
|
||||
}
|
||||
|
||||
// Download federation stuff (favicon, logo…).
|
||||
// Build the federation page.
|
||||
//
|
||||
logger.info("Htmlize propertiesFiles page.");
|
||||
page = PropertiesFilesPage.build(federation);
|
||||
FileUtils.write(new File(htmlizeDirectory, "propertiesFiles.xhtml"), page, StandardCharsets.UTF_8);
|
||||
|
||||
// For each organization
|
||||
// Download organization stuff (favicon, logo…).
|
||||
// Build organization page.
|
||||
// for each service
|
||||
// Download service stuff (favicon, logo…).
|
||||
// Build service page.
|
||||
//
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -293,15 +296,5 @@ public class Htmlizer
|
|||
page = ServicePage.build(organization, service);
|
||||
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
// Download federation stuff (favicon, logo…).
|
||||
// Build the federation page.
|
||||
|
||||
// For each organization
|
||||
// Download organization stuff (favicon, logo…).
|
||||
// Build organization page.
|
||||
// for each service
|
||||
// Download service stuff (favicon, logo…).
|
||||
// Build service page.
|
||||
}
|
||||
}
|
||||
|
|
101
src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java
Normal file
101
src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* 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.Federation;
|
||||
import fr.devinsy.statoolinfos.core.Organization;
|
||||
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 OrganizationPage.
|
||||
*/
|
||||
public class PropertiesFilesPage
|
||||
{
|
||||
private static Logger logger = LoggerFactory.getLogger(PropertiesFilesPage.class);
|
||||
|
||||
/**
|
||||
* Builds the.
|
||||
*
|
||||
* @param federation
|
||||
* the organization
|
||||
* @return the string
|
||||
* @throws StatoolInfosException
|
||||
* the statool infos exception
|
||||
*/
|
||||
public static String build(final Federation federation) throws StatoolInfosException
|
||||
{
|
||||
String result;
|
||||
|
||||
try
|
||||
{
|
||||
logger.debug("Building federation page {}…", federation.getName());
|
||||
|
||||
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.setAttribute("federationRawButton", "href", federation.getTechnicalName() + ".properties");
|
||||
|
||||
data.setAttribute("federationLogo", "src", federation.getTechnicalName() + "-logo.png");
|
||||
data.setEscapedContent("federationName", federation.getName());
|
||||
data.setEscapedContent("federationDescription", federation.getDescription());
|
||||
data.setContent("organizationCount", federation.getOrganizations().size());
|
||||
data.setContent("serviceCount", federation.getServiceCount());
|
||||
|
||||
//
|
||||
int index = 0;
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
for (Organization organization : federation.getOrganizations())
|
||||
{
|
||||
data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml");
|
||||
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getTechnicalName() + "-logo.png");
|
||||
data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName());
|
||||
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite());
|
||||
data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite());
|
||||
data.setContent("organizationListLine", index, "organizationListLineServiceCount", organization.getServiceCount());
|
||||
|
||||
index += 1;
|
||||
}
|
||||
|
||||
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml", data).toString();
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
throw new StatoolInfosException("Error building propertiesFiles page: " + exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
91
src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java
Normal file
91
src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* 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 PropertyStatsPage
|
||||
{
|
||||
private static Logger logger = LoggerFactory.getLogger(PropertyStatsPage.class);
|
||||
|
||||
/**
|
||||
* Builds the.
|
||||
*
|
||||
* @param service
|
||||
* the service
|
||||
* @return the string
|
||||
* @throws StatoolInfosException
|
||||
* the statool infos exception
|
||||
*/
|
||||
public static String build(final PropertyStats stats) 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("propertyCount", stats.getPropertyCount());
|
||||
data.setContent("fileCount", stats.getFileCount());
|
||||
|
||||
int index = 0;
|
||||
for (PropertyStat stat : stats.getList())
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml", data).toString();
|
||||
}
|
||||
catch (XidynException exception)
|
||||
{
|
||||
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,11 @@
|
|||
<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">About</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 class="center">
|
||||
<h2><img id="federationLogo" src="#" style="width: 100px; heigth: 100px; vertical-align: middle;"/> <span id="federationName">Federation name</span></h2>
|
||||
|
|
47
src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml
Normal file
47
src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?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">About</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">Properties</a>
|
||||
</div>
|
||||
|
||||
<div class="center">
|
||||
<h2>Fichiers properties</h2>
|
||||
<div>Nombre de fichiers : <span id="fileCount">n/a</span></div>
|
||||
<div class="left">
|
||||
<table class="table_classic center_table" style="width: 600px; margin-left: auto; margin-right: auto;">
|
||||
<tr>
|
||||
<th style="width: 200px;">Nom</th>
|
||||
<th style="width: 200px;">Organisation</th>
|
||||
<th style="width: 100px;">Nombre de <i>property</i></th>
|
||||
<th style="width: 250px;">Source</th>
|
||||
</tr>
|
||||
<tr id="fileListLine">
|
||||
<td id="fileListLineName" style="padding-top: 0; padding-bottom: 0;">
|
||||
<a href="#" id="fileListLineNameLink">
|
||||
<img id="fileListLineLogo" src="" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
|
||||
 <span id="fileListLineNameValue">n/a</span>
|
||||
</a>
|
||||
</td>
|
||||
<td id="fileListLineLineCount" class="td_number">n/a</td>
|
||||
<td id="fileListLineSourceUrl"><a href="#" id="fileListLineSourceUrlLink">n/a</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
46
src/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml
Normal file
46
src/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?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="center">
|
||||
<h2>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" style="width: 600px; margin-left: auto; margin-right: auto;">
|
||||
<tr>
|
||||
<th style="width: 200px;">Path</th>
|
||||
<th style="width: 20px;">Blank Count</th>
|
||||
<th style="width: 10px;">File %</th>
|
||||
<th style="width: 20px;">Filled Count</th>
|
||||
<th style="width: 10px;">File %</th>
|
||||
</tr>
|
||||
<tr id="propertyLine">
|
||||
<td id="propertyLinePath" class="">n/a</td>
|
||||
<td id="propertyLineBlankCount" class="td_number">n/a</td>
|
||||
<td id="propertyLineBlankCountPercentage" class="td_number">n/a</td>
|
||||
<td id="propertyLineFilledCount" class="td_number">n/a</td>
|
||||
<td id="propertyLineFilledCountPercentage" class="td_number">n/a</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
38
src/fr/devinsy/statoolinfos/stats/PropertiesFileStat.java
Normal file
38
src/fr/devinsy/statoolinfos/stats/PropertiesFileStat.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* The Class PropertiesFileStat.
|
||||
*/
|
||||
public class PropertiesFileStat
|
||||
{
|
||||
private URL url;
|
||||
private int lineCount;
|
||||
private int activeLineCount;
|
||||
|
||||
/**
|
||||
* Instantiates a new properties file stat.
|
||||
*/
|
||||
public PropertiesFileStat()
|
||||
{
|
||||
}
|
||||
}
|
37
src/fr/devinsy/statoolinfos/stats/PropertiesFileStats.java
Normal file
37
src/fr/devinsy/statoolinfos/stats/PropertiesFileStats.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* The Class PropertiesFileStats.
|
||||
*/
|
||||
public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
|
||||
{
|
||||
private static final long serialVersionUID = 8828667177906801801L;
|
||||
|
||||
/**
|
||||
* Instantiates a new properties file stats.
|
||||
*/
|
||||
public PropertiesFileStats()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
89
src/fr/devinsy/statoolinfos/stats/PropertyStat.java
Normal file
89
src/fr/devinsy/statoolinfos/stats/PropertyStat.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* The Class PropertyStat.
|
||||
*/
|
||||
public class PropertyStat
|
||||
{
|
||||
private String path;
|
||||
private int blankCount;
|
||||
private int filledCount;
|
||||
|
||||
/**
|
||||
* Instantiates a new property stat.
|
||||
*/
|
||||
public PropertyStat(final String path)
|
||||
{
|
||||
if (StringUtils.isBlank(path))
|
||||
{
|
||||
throw new IllegalArgumentException("Null parameter.");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.path = path;
|
||||
this.blankCount = 0;
|
||||
this.filledCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getBlankCount()
|
||||
{
|
||||
return this.blankCount;
|
||||
}
|
||||
|
||||
public int getFilledCount()
|
||||
{
|
||||
return this.filledCount;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return this.path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inc blank.
|
||||
*/
|
||||
public void incBlank()
|
||||
{
|
||||
this.blankCount += 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inc filled.
|
||||
*/
|
||||
public void incFilled()
|
||||
{
|
||||
this.filledCount += 1;
|
||||
}
|
||||
|
||||
public void setBlankCount(final int blankCount)
|
||||
{
|
||||
this.blankCount = blankCount;
|
||||
}
|
||||
|
||||
public void setFilledCount(final int filledCount)
|
||||
{
|
||||
this.filledCount = filledCount;
|
||||
}
|
||||
}
|
37
src/fr/devinsy/statoolinfos/stats/PropertyStatList.java
Normal file
37
src/fr/devinsy/statoolinfos/stats/PropertyStatList.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* The Class PropertyStatList.
|
||||
*/
|
||||
public class PropertyStatList extends ArrayList<PropertyStat>
|
||||
{
|
||||
private static final long serialVersionUID = -3654806428144379451L;
|
||||
|
||||
/**
|
||||
* Instantiates a new property stats.
|
||||
*/
|
||||
public PropertyStatList()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
48
src/fr/devinsy/statoolinfos/stats/PropertyStatSet.java
Normal file
48
src/fr/devinsy/statoolinfos/stats/PropertyStatSet.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* The Class PropertyStatSet.
|
||||
*/
|
||||
public class PropertyStatSet extends HashMap<String, PropertyStat>
|
||||
{
|
||||
private static final long serialVersionUID = -728150929356133285L;
|
||||
|
||||
/**
|
||||
* Instantiates a new property stats.
|
||||
*/
|
||||
public PropertyStatSet()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Put.
|
||||
*
|
||||
* @param stat
|
||||
* the stat
|
||||
*/
|
||||
void put(final PropertyStat stat)
|
||||
{
|
||||
put(stat.getPath(), stat);
|
||||
}
|
||||
}
|
134
src/fr/devinsy/statoolinfos/stats/PropertyStats.java
Normal file
134
src/fr/devinsy/statoolinfos/stats/PropertyStats.java
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import fr.devinsy.statoolinfos.properties.PathProperty;
|
||||
import fr.devinsy.statoolinfos.properties.PathPropertyList;
|
||||
|
||||
/**
|
||||
* The Class PropertyStat.
|
||||
*/
|
||||
public class PropertyStats
|
||||
{
|
||||
private int fileCount;
|
||||
private PropertyStatSet stats;
|
||||
|
||||
/**
|
||||
* Instantiates a new property stat.
|
||||
*/
|
||||
public PropertyStats()
|
||||
{
|
||||
this.fileCount = 0;
|
||||
this.stats = new PropertyStatSet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param path
|
||||
* the path
|
||||
* @return the property stat
|
||||
*/
|
||||
public PropertyStat get(final String path)
|
||||
{
|
||||
PropertyStat result;
|
||||
|
||||
result = this.stats.get(path);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file count.
|
||||
*
|
||||
* @return the file count
|
||||
*/
|
||||
public int getFileCount()
|
||||
{
|
||||
return this.fileCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public PropertyStatList getList()
|
||||
{
|
||||
PropertyStatList result;
|
||||
|
||||
result = new PropertyStatList();
|
||||
|
||||
for (PropertyStat stat : this.stats.values())
|
||||
{
|
||||
result.add(stat);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getPropertyCount()
|
||||
{
|
||||
return this.stats.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stats.
|
||||
*
|
||||
* @return the stats
|
||||
*/
|
||||
public PropertyStatSet getStats()
|
||||
{
|
||||
return this.stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat.
|
||||
*
|
||||
* @param properties
|
||||
* the properties
|
||||
*/
|
||||
public void stat(final PathPropertyList properties)
|
||||
{
|
||||
this.fileCount += 1;
|
||||
|
||||
for (PathProperty property : properties)
|
||||
{
|
||||
PropertyStat stat = this.stats.get(property.getPath());
|
||||
|
||||
if (stat == null)
|
||||
{
|
||||
stat = new PropertyStat(property.getPath());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(property.getValue()))
|
||||
{
|
||||
stat.incBlank();
|
||||
}
|
||||
else
|
||||
{
|
||||
stat.incFilled();
|
||||
}
|
||||
|
||||
this.stats.put(stat);
|
||||
}
|
||||
}
|
||||
}
|
67
src/fr/devinsy/statoolinfos/stats/StatAgent.java
Normal file
67
src/fr/devinsy/statoolinfos/stats/StatAgent.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import fr.devinsy.statoolinfos.core.Federation;
|
||||
import fr.devinsy.statoolinfos.core.Organization;
|
||||
import fr.devinsy.statoolinfos.core.Service;
|
||||
|
||||
/**
|
||||
* The Class StatAgent.
|
||||
*/
|
||||
public class StatAgent
|
||||
{
|
||||
/**
|
||||
* Instantiates a new stat agent.
|
||||
*/
|
||||
private StatAgent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat properties.
|
||||
*
|
||||
* @param fedration
|
||||
* the fedration
|
||||
* @return the property stats
|
||||
*/
|
||||
public static PropertyStats statProperties(final Federation federation)
|
||||
{
|
||||
PropertyStats result;
|
||||
|
||||
PropertyStats stats = new PropertyStats();
|
||||
|
||||
stats.stat(federation);
|
||||
for (Organization organization : federation.getOrganizations())
|
||||
{
|
||||
stats.stat(organization);
|
||||
|
||||
for (Service service : organization.getServices())
|
||||
{
|
||||
stats.stat(service);
|
||||
}
|
||||
}
|
||||
|
||||
result = stats;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue