Added alert check pages.

This commit is contained in:
Christian P. MOMON 2021-01-15 04:58:55 +01:00
parent 3a8103bcfa
commit fe471608fe
12 changed files with 523 additions and 37 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -25,6 +25,7 @@ import fr.devinsy.statoolinfos.core.Service.Status;
*/
public class PropertyCheck
{
private String fileName;
private long index;
private String line;
private Status status;
@ -72,6 +73,7 @@ public class PropertyCheck
*/
public PropertyCheck(final long index, final String line, final Status status, final String comment)
{
this.fileName = null;
this.index = index;
this.line = line;
this.status = status;
@ -83,6 +85,11 @@ public class PropertyCheck
return this.comment;
}
public String getFileName()
{
return this.fileName;
}
public long getIndex()
{
return this.index;
@ -103,6 +110,11 @@ public class PropertyCheck
this.comment = comment;
}
public void setFileName(final String fileName)
{
this.fileName = fileName;
}
public void setIndex(final long index)
{
this.index = index;

View file

@ -43,7 +43,7 @@ public class PropertyChecks extends ArrayList<PropertyCheck>
*
* @return the property checks
*/
public PropertyChecks extractActiveLines()
public PropertyChecks getActiveLines()
{
PropertyChecks result;
@ -63,29 +63,6 @@ public class PropertyChecks extends ArrayList<PropertyCheck>
return result;
}
/**
* Extract alert lines.
*
* @return the property checks
*/
public PropertyChecks extractAlertLines()
{
PropertyChecks result;
result = new PropertyChecks();
for (PropertyCheck check : this)
{
if (check.getStatus() != Status.OK)
{
result.add(check);
}
}
//
return result;
}
/**
* Gets the alert count.
*
@ -108,6 +85,29 @@ public class PropertyChecks extends ArrayList<PropertyCheck>
return result;
}
/**
* Extract alert lines.
*
* @return the property checks
*/
public PropertyChecks getAlertLines()
{
PropertyChecks result;
result = new PropertyChecks();
for (PropertyCheck check : this)
{
if (check.getStatus() != Status.OK)
{
result.add(check);
}
}
//
return result;
}
/**
* Gets the error count.
*
@ -173,4 +173,25 @@ public class PropertyChecks extends ArrayList<PropertyCheck>
//
return result;
}
/**
* Sets the file name.
*
* @param fileName
* the new file name
*/
public PropertyChecks setFileName(final String fileName)
{
PropertyChecks result;
for (PropertyCheck check : this)
{
check.setFileName(fileName);
}
result = this;
//
return result;
}
}

View file

@ -202,6 +202,21 @@ public class Organization extends PathPropertyList
return result;
}
/**
* Gets the local file name.
*
* @return the local file name
*/
public String getLocalFileName()
{
String result;
result = getTechnicalName() + ".properties";
//
return result;
}
/**
* Gets the logo file name.
*

View file

@ -277,6 +277,21 @@ public class Service extends PathPropertyList
return result;
}
/**
* Gets the local name.
*
* @return the local name
*/
public String getLocalFileName()
{
String result;
result = this.organization.getTechnicalName() + "-" + getTechnicalName() + ".properties";
//
return result;
}
public String getLogoFileName()
{
return this.logoFileName;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -91,6 +91,13 @@ public class PropertiesFilesPage
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
data.setContent("fileCount", stats.size());
data.setContent("lineCount", stats.getLineCount());
data.setContent("propertyCount", stats.getPropertyCount());
data.setContent("blankPropertyCount", stats.getBlankPropertyCount());
data.setContent("filledPropertyCount", stats.getFilledPropertyCount());
data.setContent("warningCount", stats.getWarningCount());
data.setContent("errorCount", stats.getErrorCount());
data.setContent("voidCount", stats.getVoidCount());
//
int index = 0;
@ -104,7 +111,7 @@ public class PropertiesFilesPage
data.setAttribute("fileListLine", index, "fileListLineOwnerLogo", "src", stat.getOrganization().getLogoFileName());
data.setContent("fileListLine", index, "fileListLineLineCount", stat.getLineCount());
data.setContent("fileListLine", index, "fileListLineActiveCount", stat.getActiveLineCount());
data.setContent("fileListLine", index, "fileListLineActiveCount", stat.getPropertyCount());
data.setContent("fileListLine", index, "fileListLineBlankPropertyCount", stat.getBlankPropertyCount());
data.setContent("fileListLine", index, "fileListLineFilledPropertyCount", stat.getFilledPropertyCount());

View file

@ -59,25 +59,64 @@ public class PropertyFileCheckPage
PropertyChecker checker = new PropertyChecker();
PropertyChecks allAlertChecks = new PropertyChecks();
PropertyChecks federationAlertChecks = new PropertyChecks();
PropertyChecks organizationAlertChecks = new PropertyChecks();
PropertyChecks serviceAlertChecks = new PropertyChecks();
//
PropertyChecks checks = checker.checkFederation(federation.getInputFile());
String page = PropertyFileCheckPage.htmlize("Fédération", checks);
String page = htmlize("Fédération", checks);
FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8);
PropertyChecks alerts = checks.getAlertLines().setFileName(federation.getName());
allAlertChecks.addAll(alerts);
federationAlertChecks.addAll(alerts);
//
for (Organization organization : federation.getOrganizations())
{
checks = checker.checkOrganization(organization.getInputFile());
page = PropertyFileCheckPage.htmlize("Organisation", checks);
page = htmlize("Organisation", checks);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8);
if (organization.getServiceCount() > 0)
{
alerts = checks.getAlertLines().setFileName(organization.getLocalFileName());
allAlertChecks.addAll(alerts);
organizationAlertChecks.addAll(alerts);
}
for (Service service : organization.getServices())
{
checks = checker.checkService(service.getInputFile());
page = PropertyFileCheckPage.htmlize("Service", checks);
page = htmlize("Service", checks);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8);
if (organization.getServiceCount() > 0)
{
alerts = checks.getAlertLines().setFileName(service.getLocalFileName());
allAlertChecks.addAll(alerts);
serviceAlertChecks.addAll(alerts);
}
}
}
//
page = PropertyFilesCheckPage.htmlize("Tous", allAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks.xhtml"), page, StandardCharsets.UTF_8);
page = PropertyFilesCheckPage.htmlize("Fédération", federationAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks-federation.xhtml"), page, StandardCharsets.UTF_8);
page = PropertyFilesCheckPage.htmlize("Membres", organizationAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks-organizations.xhtml"), page, StandardCharsets.UTF_8);
page = PropertyFilesCheckPage.htmlize("Services", serviceAlertChecks);
FileUtils.write(new File(htmlizeDirectory, "alertChecks-services.xhtml"), page, StandardCharsets.UTF_8);
}
/**
* Builds the.
*
@ -129,7 +168,7 @@ public class PropertyFileCheckPage
//
index = 0;
PropertyChecks subchecks = checks.extractActiveLines();
PropertyChecks subchecks = checks.getActiveLines();
if (subchecks.isEmpty())
{
data.setAttribute("shrunkBlockTable", "class", "xid:nodisplay");
@ -150,7 +189,7 @@ public class PropertyFileCheckPage
//
index = 0;
subchecks = checks.extractAlertLines();
subchecks = checks.getAlertLines();
if (subchecks.isEmpty())
{
data.setAttribute("alertBlockTable", "class", "xid:nodisplay");

View file

@ -0,0 +1,146 @@
/*
* Copyright (C) 2020-2021 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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.checker.PropertyCheck;
import fr.devinsy.statoolinfos.checker.PropertyChecks;
import fr.devinsy.statoolinfos.core.Service.Status;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class PropertyFileCheckPage.
*/
public class PropertyFilesCheckPage
{
private static Logger logger = LoggerFactory.getLogger(PropertyFilesCheckPage.class);
/**
* Builds the.
*
* @param title
* the title
* @param checks
* the checks
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlize(final String title, final PropertyChecks checks) throws StatoolInfosException
{
String result;
try
{
logger.debug("Building propertyFilesCheck page…");
TagDataManager data = new TagDataManager();
data.setContent("lineCount", checks.size());
data.setContent("warningCount", checks.getWarningCount());
data.setContent("errorCount", checks.getErrorCount());
data.setContent("voidCount", checks.getVoidCount());
//
data.setContent("statsTitle", title);
//
int index = 0;
if (checks.isEmpty())
{
data.setAttribute("blockTable", "class", "xid:nodisplay");
}
else
{
for (PropertyCheck check : checks)
{
//
data.setEscapedContent("line", index, "lineFileName", check.getFileName());
data.setContent("line", index, "lineIndex", check.getIndex());
data.setEscapedContent("line", index, "lineComment", check.getComment());
data.setEscapedContent("line", index, "lineContent", check.getLine());
data.setAttribute("line", index, "lineContent", "class", statusToCSS(check.getStatus()));
index += 1;
}
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml", data).toString();
BreadcrumbTrail trail = new BreadcrumbTrail();
trail.add("Propriétés", "propertyStats.xhtml");
result = WebCharterView.build(content, trail);
}
catch (XidynException exception)
{
throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception);
}
//
return result;
}
/**
* Status to CSS.
*
* @param status
* the status
* @return the string
*/
public static String statusToCSS(final Status status)
{
String result;
switch (status)
{
case OK:
result = "bg_ok";
break;
case WARNING:
result = "bg_warning";
break;
case ALERT:
result = "bg_alert";
break;
case ERROR:
result = "bg_error";
break;
case OVER:
result = "bg_over";
break;
case VOID:
default:
result = "bg_void";
}
//
return result;
}
}

View file

@ -12,10 +12,45 @@
</head>
<body>
<div class="center_table" style="width: 1400px;">
<div style="margin-left: 0px; margin-bottom: 10px;">
<a id="filesButton" href="propertiesFiles.xhtml" class="button">Staistiques</a>
<a id="allButton" href="alertChecks.xhtml" class="button">Toutes</a>
<a id="federationButton" href="alertChecks-federation.xhtml" class="button">Fédération</a>
<a id="organizationButton" href="alertChecks-organizations.xhtml" class="button">Membres</a>
<a id="serviceButton" href="alertChecks-services.xhtml" class="button">Services</a>
</div>
<div class="center" >
<h2>Fichiers properties</h2>
<div>Nombre de fichiers : <span id="fileCount">n/a</span></div>
<div>
<table style="width: 300px;" class="table_classic left">
<tr>
<td style="width: 150px;">Fichiers :</td>
<td id="fileCount" class="right">n/a</td>
</tr>
<tr>
<td>Lignes :</td>
<td id="lineCount" class="right">n/a</td>
</tr>
<tr>
<td>Propriétés :</td>
<td id="propertyCount" class="right">n/a</td>
</tr>
<tr>
<td>Propriétés vides :</td>
<td id="blankPropertyCount" class="right">n/a</td>
</tr>
<tr>
<td>Alertes :</td>
<td class="right">
<span id="warningCount" class="bg_warning" title="Attendus">n/a</span>
<span id="errorCount" class="bg_error" title="Erreurs">n/a</span>
<span id="voidCount" class="bg_void" title="Inconnus">n/a</span>
</td>
</tr>
</table>
</div>
</div>
<table id="propertyFileListTable" class="table_classic left">
<thead>
<tr>

View file

@ -16,9 +16,9 @@
<h2 id="statsTitle">n/a</h2>
</div>
<div style="margin-left: 0px; margin-bottom: 10px;">
<a id="" href="#all" class="button" onclick="javascript:setView('ALL');">Tout</a>
<a id="" href="#shrunk" class="button" onclick="javascript:setView('SHRUNK');">Réduit</a>
<a id="" href="#alerts" class="button" onclick="javascript:setView('ALERTS');">Alertes</a>
<a id="allButton" href="#all" class="button" onclick="javascript:setView('ALL');">Tout</a>
<a id="shrunkButton" href="#shrunk" class="button" onclick="javascript:setView('SHRUNK');">Réduit</a>
<a id="alertButton" href="#alerts" class="button" onclick="javascript:setView('ALERTS');">Alertes</a>
<span style="margin-left: 150px;">Statistiques : </span>
<span id="lineCount" style="padding: 0 10px; background-color: #d5d5d5" title="Nombre de lignes">n/a</span>

View file

@ -0,0 +1,48 @@
<?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: 1400px;">
<div style="margin-left: 0px; margin-bottom: 10px;">
<a id="filesButton" href="propertiesFiles.xhtml" class="button">Statistiques</a>
<a id="allButton" href="alertChecks.xhtml" class="button">Tous</a>
<a id="federationButton" href="alertChecks-federation.xhtml" class="button">Fédération</a>
<a id="organizationButton" href="alertChecks-organizations.xhtml" class="button">Membres</a>
<a id="serviceButton" href="alertChecks-services.xhtml" class="button">Services</a>
</div>
<div class="center">
<h2 id="statsTitle">n/a</h2>
</div>
<div style="margin-left: 0px; margin-bottom: 10px;">
<span style="margin-left: 150px;">Statistiques : </span>
<span id="lineCount" style="padding: 0 10px;" title="Nombre de lignes">n/a</span>
<span id="warningCount" class="bg_warning" style="padding: 0 10px;" title="Attendus">n/a</span>
<span id="errorCount" class="bg_error" style="padding: 0 10px;" title="Erreurs">n/a</span>
<span id="voidCount" class="bg_void" style="padding: 0 10px;" title="Inconnus">n/a</span>
</div>
<div id="block" style="width: 100%;">
<table id="blockTable" class="table_simple">
<tbody>
<tr id="line">
<td id="lineFileName" style="padding-top: 0; padding-bottom: 0;">
<a href="#" id="lineFileNameLink">n/a</a>
</td>
<td id="lineIndex" style="width: 30px; text-align: right; right; padding-right: 5px;">000</td>
<td id="lineContent" style="padding-left: 10px;">n/a</td>
<td id="lineComment" style="width: 200px; padding-left: 5px;">n/a</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -88,6 +88,11 @@ public class PropertiesFileStat
return this.organization;
}
public int getPropertyCount()
{
return this.activeLineCount;
}
public LocalDateTime getUpdateDate()
{
return this.updateDate;

View file

@ -46,6 +46,149 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
super();
}
/**
* Gets the active line count.
*
* @return the active line count
*/
public long getActiveLineCount()
{
long result;
result = 0;
for (PropertiesFileStat stat : this)
{
result += stat.getActiveLineCount();
}
//
return result;
}
/**
* Gets the blank property count.
*
* @return the blank property count
*/
public long getBlankPropertyCount()
{
long result;
result = 0;
for (PropertiesFileStat stat : this)
{
result += stat.getBlankPropertyCount();
}
//
return result;
}
public long getErrorCount()
{
long result;
result = 0;
for (PropertiesFileStat stat : this)
{
result += stat.getErrorCount();
}
//
return result;
}
/**
* Gets the filled property count.
*
* @return the filled property count
*/
public long getFilledPropertyCount()
{
long result;
result = 0;
for (PropertiesFileStat stat : this)
{
result += stat.getFilledPropertyCount();
}
//
return result;
}
/**
* Gets the line count.
*
* @return the line count
*/
public long getLineCount()
{
long result;
result = 0;
for (PropertiesFileStat stat : this)
{
result += stat.getLineCount();
}
//
return result;
}
/**
* Gets the property count.
*
* @return the property count
*/
public long getPropertyCount()
{
long result;
result = getActiveLineCount();
//
return result;
}
/**
* Gets the void count.
*
* @return the void count
*/
public long getVoidCount()
{
long result;
result = 0;
for (PropertiesFileStat stat : this)
{
result += stat.getVoidCount();
}
//
return result;
}
/**
* Gets the warning count.
*
* @return the warning count
*/
public long getWarningCount()
{
long result;
result = 0;
for (PropertiesFileStat stat : this)
{
result += stat.getWarningCount();
}
//
return result;
}
/**
* Sort.
*