From 633efbcc8cee303d426806f0df7a834c82611c59 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 13 Jun 2021 00:48:51 +0200 Subject: [PATCH] Refactored Property Check in content view. --- .../htmlize/FederationHeaderView.java | 2 +- .../FederationPropertyFileCheckPage.java | 95 +++++++++++ .../statoolinfos/htmlize/Htmlizer.java | 11 +- .../OrganizationPropertyFileCheckPage.java | 99 ++++++++++++ ...ckPage.java => PropertyFileCheckView.java} | 51 ++---- .../htmlize/ServicePropertyFileCheckPage.java | 147 ++++++++++++++++++ .../htmlize/federationHeaderView.xhtml | 4 +- .../htmlize/organizationHeaderView.xhtml | 4 +- .../htmlize/propertyFileCheck.xhtml | 2 +- .../htmlize/serviceHeaderView.xhtml | 4 +- 10 files changed, 373 insertions(+), 46 deletions(-) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/FederationPropertyFileCheckPage.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyFileCheckPage.java rename src/fr/devinsy/statoolinfos/htmlize/{PropertyFileCheckPage.java => PropertyFileCheckView.java} (80%) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/ServicePropertyFileCheckPage.java diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java index 96bd695..62d10b5 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java @@ -51,7 +51,7 @@ public class FederationHeaderView * the statool infos exception * @throws IOException */ - public static String htmlize(final Federation federation) throws StatoolInfosException, IOException + public static String htmlize(final Federation federation) throws StatoolInfosException { String result; diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyFileCheckPage.java new file mode 100644 index 0000000..2bc0052 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyFileCheckPage.java @@ -0,0 +1,95 @@ +/* + * 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 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.xidyn.XidynException; +import fr.devinsy.xidyn.data.TagDataManager; +import fr.devinsy.xidyn.presenters.PresenterUtils; + +/** + * The Class PropertyFileCheckPage. + */ +public class FederationPropertyFileCheckPage +{ + private static Logger logger = LoggerFactory.getLogger(FederationPropertyFileCheckPage.class); + + /** + * Builds the. + * + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws StatoolInfosException + * the statool infos exception + */ + public static void build() throws IOException, StatoolInfosException + { + Federation federation = HtmlizerContext.instance().getFederation(); + File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); + + String page = htmlize(federation); + FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8); + } + + /** + * Htmlize. + * + * @param federation + * the federation + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Federation federation) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", FederationHeaderView.htmlize(federation)); + data.setContent("contentView", PropertyFileCheckView.htmlize(federation.getInputChecks())); + + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add("Propriétés", federation.getLocalFileBaseName() + "-check.xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building federation property file check page: " + exception.getMessage(), exception); + } + + // + return result; + } + +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index 1a62105..4de74b8 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -160,24 +160,27 @@ public class Htmlizer AboutPage.build(); CategoriesPage.build(); CategoryPage.buildAll(); - FederationCrawlJournalPage.build(); - OrganizationCrawlJournalPage.buildAll(); - ServiceCrawlJournalPage.buildAll(); EditoPage.build(); ExportsPage.build(); FederationPage.build(); FederationStatsPage.build(); + FederationCrawlJournalPage.build(); FederationUptimePage.build(); + FederationPropertyFileCheckPage.build(); OrganizationPage.buildAll(); + OrganizationCrawlJournalPage.buildAll(); OrganizationUptimePage.buildAll(); - PropertyFileCheckPage.buildAll(); + OrganizationPropertyFileCheckPage.buildAll(); PropertiesFilesPage.build(); PropertyStatsPage.buildAll(); ServicePage.buildAll(); + ServiceCrawlJournalPage.buildAll(); ServiceUptimePage.buildAll(); + ServicePropertyFileCheckPage.buildAll(); ServicesPage.build(); SoftwaresPage.build(); SoftwarePage.buildAll(); SocialNetworksPage.buildAll(); + PropertyFileCheckView.buildAll(); } } diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyFileCheckPage.java new file mode 100644 index 0000000..9e567ad --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyFileCheckPage.java @@ -0,0 +1,99 @@ +/* + * 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 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.Organization; +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 OrganizationPropertyFileCheckView. + */ +public class OrganizationPropertyFileCheckPage +{ + private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyFileCheckPage.class); + + /** + * Builds the all 1. + * + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws StatoolInfosException + * the statool infos exception + */ + public static void buildAll() throws IOException, StatoolInfosException + { + Federation federation = HtmlizerContext.instance().getFederation(); + File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); + + for (Organization organization : federation.getOrganizations()) + { + String page = htmlize(organization); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); + } + } + + /** + * Htmlize. + * + * @param organization + * the organization + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Organization organization) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); + data.setContent("contentView", PropertyFileCheckView.htmlize(organization.getInputChecks())); + + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); + trail.add("Propriétés", organization.getLocalFileBaseName() + "-check.xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building organization property file check page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckView.java similarity index 80% rename from src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java rename to src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckView.java index bd91a23..f2560d5 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckView.java @@ -38,19 +38,22 @@ import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.presenters.PresenterUtils; +import fr.devinsy.xidyn.utils.XidynUtils; /** - * The Class PropertyFileCheckPage. + * The Class PropertyFileCheckView. */ -public class PropertyFileCheckPage +public class PropertyFileCheckView { - private static Logger logger = LoggerFactory.getLogger(PropertyFileCheckPage.class); + private static Logger logger = LoggerFactory.getLogger(PropertyFileCheckView.class); /** - * Builds the. - * + * Builds the all. + * * @throws IOException + * Signals that an I/O exception has occurred. * @throws StatoolInfosException + * the statool infos exception */ public static void buildAll() throws IOException, StatoolInfosException { @@ -63,20 +66,14 @@ public class PropertyFileCheckPage PropertyChecks serviceAlertChecks = new PropertyChecks(); // - PropertyChecks checks = federation.getInputChecks(); - 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()); + PropertyChecks alerts = federation.getInputChecks().getAlertLines().setFileName(federation.getName()); allAlertChecks.addAll(alerts); federationAlertChecks.addAll(alerts); // for (Organization organization : federation.getOrganizations()) { - checks = organization.getInputChecks(); - page = htmlize("Organisation", checks); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); + PropertyChecks checks = organization.getInputChecks(); // Ignore ghost organizations. if (organization.getServiceCount() > 0) @@ -87,21 +84,13 @@ public class PropertyFileCheckPage for (Service service : organization.getServices()) { - checks = service.getInputChecks(); - page = htmlize("Service", checks); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); - - alerts = checks.getAlertLines().setFileName(service.getLocalFileName()); + alerts = service.getInputChecks().getAlertLines().setFileName(service.getLocalFileName()); allAlertChecks.addAll(alerts); serviceAlertChecks.addAll(alerts); for (Metrics metrics : service.getMetrics()) { - checks = metrics.getInputChecks(); - page = htmlize("Metrics", checks); - FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); - - alerts = checks.getAlertLines().setFileName(metrics.getLocalFileName()); + alerts = metrics.getInputChecks().getAlertLines().setFileName(metrics.getLocalFileName()); allAlertChecks.addAll(alerts); serviceAlertChecks.addAll(alerts); } @@ -110,7 +99,7 @@ public class PropertyFileCheckPage } // - page = PropertyFilesCheckPage.htmlize("Tous", allAlertChecks); + String page = PropertyFilesCheckPage.htmlize("Tous", allAlertChecks); FileUtils.write(new File(htmlizeDirectory, "alertChecks.xhtml"), page, StandardCharsets.UTF_8); page = PropertyFilesCheckPage.htmlize("Fédération", federationAlertChecks); @@ -134,14 +123,12 @@ public class PropertyFileCheckPage * @throws StatoolInfosException * the statool infos exception */ - public static String htmlize(final String title, final PropertyChecks checks) throws StatoolInfosException + public static String htmlize(final PropertyChecks checks) throws StatoolInfosException { String result; try { - logger.debug("Building propertyStats page…"); - TagDataManager data = new TagDataManager(); data.setContent("lineCount", checks.size()); @@ -150,7 +137,7 @@ public class PropertyFileCheckPage data.setContent("voidCount", checks.getVoidCount()); // - data.setContent("statsTitle", title); + data.setContent("statsTitle", "Propriétés"); // int index = 0; @@ -213,14 +200,11 @@ public class PropertyFileCheckPage // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml", data).toString(); - - BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Propriétés", "propertyStats.xhtml"); - result = WebCharterView.build(content, trail); + result = XidynUtils.extractBodyContent(content); } catch (XidynException exception) { - throw new StatoolInfosException("Error building service page: " + exception.getMessage(), exception); + throw new StatoolInfosException("Error building property check view: " + exception.getMessage(), exception); } // @@ -268,5 +252,4 @@ public class PropertyFileCheckPage // return result; } - } diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyFileCheckPage.java new file mode 100644 index 0000000..732211d --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyFileCheckPage.java @@ -0,0 +1,147 @@ +/* + * 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 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.Metrics; +import fr.devinsy.statoolinfos.core.Service; +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 ServicePropertyFileCheckView. + */ +public class ServicePropertyFileCheckPage +{ + private static Logger logger = LoggerFactory.getLogger(ServicePropertyFileCheckPage.class); + + /** + * Builds the all. + * + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws StatoolInfosException + * the statool infos exception + */ + public static void buildAll() throws IOException, StatoolInfosException + { + Federation federation = HtmlizerContext.instance().getFederation(); + File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); + + for (Service service : federation.getServicesAll()) + { + String page = htmlize(service); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); + + for (Metrics metrics : service.getMetrics()) + { + page = htmlize(service, metrics); + FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); + } + } + } + + /** + * Htmlize. + * + * @param service + * the service + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Service service) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", ServiceHeaderView.htmlize(service)); + data.setContent("contentView", PropertyFileCheckView.htmlize(service.getInputChecks())); + + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); + trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); + trail.add("Propriétés", service.getLocalFileBaseName() + "-check.xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building service property file check page: " + exception.getMessage(), exception); + } + + // + return result; + } + + /** + * Htmlize. + * + * @param service + * the service + * @param metrics + * the metrics + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Service service, final Metrics metrics) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", ServiceHeaderView.htmlize(service)); + data.setContent("contentView", PropertyFileCheckView.htmlize(metrics.getInputChecks())); + + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); + trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); + trail.add("Propriétés", service.getLocalFileBaseName() + "-check.xhtml"); + trail.add("Propriétés", metrics.getLocalFileBaseName() + "-check.xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building metrics property file check page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml index beb4a88..febec58 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml @@ -29,8 +29,8 @@ - - + + diff --git a/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml index aa75848..b201b58 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/organizationHeaderView.xhtml @@ -31,8 +31,8 @@ - - + + diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml index 41c0c8e..61f6c8d 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml @@ -13,7 +13,7 @@
-

n/a

+

Propriétés

Tout diff --git a/src/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml index a7e35f9..5b77bc8 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml @@ -39,8 +39,8 @@ - - + +