diff --git a/src/fr/devinsy/statoolinfos/core/Federation.java b/src/fr/devinsy/statoolinfos/core/Federation.java index 030c741..01ae2f4 100644 --- a/src/fr/devinsy/statoolinfos/core/Federation.java +++ b/src/fr/devinsy/statoolinfos/core/Federation.java @@ -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. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index b038970..ed6b3aa 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -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); + } } /** diff --git a/src/fr/devinsy/statoolinfos/htmlize/MainMenuView.java b/src/fr/devinsy/statoolinfos/htmlize/MainMenuView.java new file mode 100644 index 0000000..e22b278 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/MainMenuView.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2020 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.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; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java index 26b93f7..ec67423 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java @@ -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) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage2.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage2.java new file mode 100644 index 0000000..52d38fe --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage2.java @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2020 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.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; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/mainMenu.xhtml b/src/fr/devinsy/statoolinfos/htmlize/mainMenu.xhtml new file mode 100644 index 0000000..a9335d6 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/mainMenu.xhtml @@ -0,0 +1,26 @@ + + + + + StatoolInfos + + + + + + + +
+

StatoolInfosv0.0.14À proposPage updated on
xx/xx/xxxx xx:xx

+ + +
+ Accueil +
+
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml index c768d6b..c671ac4 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml @@ -27,9 +27,9 @@ Path - Filled Count + Filled Count File % - Blank Count + Blank Count File % @@ -45,6 +45,7 @@ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertyStats2.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertyStats2.xhtml new file mode 100644 index 0000000..90b5c6d --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/propertyStats2.xhtml @@ -0,0 +1,143 @@ + + + + + StatoolInfos + + + + + + + +
+

StatoolInfosv0.0.14À proposPage updated on
xx/xx/xxxx xx:xx

+ + + +
+
+

Statistics des property

+
Nombre de property : n/a
+
Nombre de fichiers : n/a
+
+ + + + + + + + + + + + + + + + + + + +
PathFilled CountFile %Blank CountFile %
n/an/an/an/an/a
+
+
+ +
 
+ +
+

Statistics des property

+
Nombre de property : n/a
+
Nombre de fichiers : n/a
+
+ + + + + + + + + + + + + + + + + + + +
PathFilled CountFile %Blank CountFile %
n/an/an/an/an/a
+
+
+
+ +
+
+

Statistics des property

+
Nombre de property : n/a
+
Nombre de fichiers : n/a
+
+ + + + + + + + + + + + + + + + + + + +
PathFilled CountFile %Blank CountFile %
n/an/an/an/an/a
+
+
+ +
 
+ +
+

Statistics des property

+
Nombre de property : n/a
+
Nombre de fichiers : n/a
+
+ + + + + + + + + + + + + + + + + + + +
PathFilled CountFile %Blank CountFile %
n/an/an/an/an/a
+
+
+
+ +
+ + diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java index b5a2bfa..5a6aca7 100644 --- a/src/fr/devinsy/statoolinfos/stats/StatAgent.java +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.java @@ -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;