From fe471608fe22ab9b8d82fe2800f11e93cbae1861 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 15 Jan 2021 04:58:55 +0100 Subject: [PATCH] Added alert check pages. --- .../statoolinfos/checker/PropertyCheck.java | 14 +- .../statoolinfos/checker/PropertyChecks.java | 69 ++++++--- .../statoolinfos/core/Organization.java | 15 ++ src/fr/devinsy/statoolinfos/core/Service.java | 15 ++ .../htmlize/PropertiesFilesPage.java | 11 +- .../htmlize/PropertyFileCheckPage.java | 49 +++++- .../htmlize/PropertyFilesCheckPage.java | 146 ++++++++++++++++++ .../htmlize/propertiesFiles.xhtml | 37 ++++- .../htmlize/propertyFileCheck.xhtml | 6 +- .../htmlize/propertyFilesCheck.xhtml | 48 ++++++ .../propertyfiles/PropertiesFileStat.java | 7 +- .../propertyfiles/PropertiesFileStats.java | 143 +++++++++++++++++ 12 files changed, 523 insertions(+), 37 deletions(-) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/PropertyFilesCheckPage.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml diff --git a/src/fr/devinsy/statoolinfos/checker/PropertyCheck.java b/src/fr/devinsy/statoolinfos/checker/PropertyCheck.java index c16b9b1..e8ad152 100644 --- a/src/fr/devinsy/statoolinfos/checker/PropertyCheck.java +++ b/src/fr/devinsy/statoolinfos/checker/PropertyCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Christian Pierre MOMON + * Copyright (C) 2020-2021 Christian Pierre MOMON * * 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; diff --git a/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java b/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java index dc97158..a83a7fe 100644 --- a/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java +++ b/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java @@ -43,7 +43,7 @@ public class PropertyChecks extends ArrayList * * @return the property checks */ - public PropertyChecks extractActiveLines() + public PropertyChecks getActiveLines() { PropertyChecks result; @@ -63,29 +63,6 @@ public class PropertyChecks extends ArrayList 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 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 // 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; + } } \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java index 7795043..fe7c8fa 100644 --- a/src/fr/devinsy/statoolinfos/core/Organization.java +++ b/src/fr/devinsy/statoolinfos/core/Organization.java @@ -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. * diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index b9aa710..c9aa07a 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -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; diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java index 44636be..6988b8e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Christian Pierre MOMON + * Copyright (C) 2020-2021 Christian Pierre MOMON * * 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()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java index 578e8f6..d1a86e5 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java @@ -59,23 +59,62 @@ 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); + } /** @@ -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"); diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyFilesCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyFilesCheckPage.java new file mode 100644 index 0000000..8be30ff --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyFilesCheckPage.java @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2020-2021 Christian Pierre MOMON + * + * 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 . + */ +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; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml index e9c1aa4..f15b60b 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml @@ -12,10 +12,45 @@
+

Fichiers properties

-
Nombre de fichiers : n/a
+
+ + + + + + + + + + + + + + + + + + + + + +
Fichiers :n/a
Lignes :n/a
Propriétés :n/a
Propriétés vides :n/a
Alertes : + n/a + n/a + n/a +
+
+ diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml index 9a4c244..18aca71 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml @@ -16,9 +16,9 @@

n/a

- Tout - Réduit - Alertes + Tout + Réduit + Alertes Statistiques : n/a diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml new file mode 100644 index 0000000..29eecb8 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml @@ -0,0 +1,48 @@ + + + + + StatoolInfos + + + + + + + +
+ +
+

n/a

+
+
+ Statistiques : + n/a + n/a + n/a + n/a +
+
+
+ + + + + + + + +
+ n/a + 000n/an/a
+
+ + + diff --git a/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStat.java b/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStat.java index 3947dec..8329d05 100644 --- a/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStat.java +++ b/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStat.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Christian Pierre MOMON + * Copyright (C) 2020-2021 Christian Pierre MOMON * * 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; diff --git a/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStats.java b/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStats.java index 472a2ea..4483de3 100644 --- a/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStats.java +++ b/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStats.java @@ -46,6 +46,149 @@ public class PropertiesFileStats extends ArrayList 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. *