diff --git a/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java b/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java index 3ea7d16..e626900 100644 --- a/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java +++ b/src/fr/devinsy/statoolinfos/core/StatoolInfosUtils.java @@ -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. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java index a25a14e..f458dfc 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java @@ -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()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index d29f9c0..080a17a 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -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. } } diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java new file mode 100644 index 0000000..d2e6490 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java @@ -0,0 +1,101 @@ +/* + * 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.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; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java new file mode 100644 index 0000000..3a20785 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java @@ -0,0 +1,91 @@ +/* + * 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 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; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml index 96ce1a3..1a65e3e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml @@ -13,6 +13,11 @@

StatoolInfosv0.0.14AboutPage updated on
xx/xx/xxxx xx:xx

+ +

Federation name

diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml new file mode 100644 index 0000000..01e3430 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml @@ -0,0 +1,47 @@ + + + + + StatoolInfos + + + + + + + +
+

StatoolInfosv0.0.14AboutPage updated on
xx/xx/xxxx xx:xx

+ + + +
+

Fichiers properties

+
Nombre de fichiers : n/a
+
+ + + + + + + + + + + + +
NomOrganisationNombre de propertySource
+ + +  n/a + + n/an/a
+
+
+
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml new file mode 100644 index 0000000..4c6683b --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml @@ -0,0 +1,46 @@ + + + + + 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
+
+ + + + + + + + + + + + + + + +
PathBlank CountFile %Filled CountFile %
n/an/an/an/an/a
+
+
+
+ + diff --git a/src/fr/devinsy/statoolinfos/stats/PropertiesFileStat.java b/src/fr/devinsy/statoolinfos/stats/PropertiesFileStat.java new file mode 100644 index 0000000..0a7d45f --- /dev/null +++ b/src/fr/devinsy/statoolinfos/stats/PropertiesFileStat.java @@ -0,0 +1,38 @@ +/* + * 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.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() + { + } +} diff --git a/src/fr/devinsy/statoolinfos/stats/PropertiesFileStats.java b/src/fr/devinsy/statoolinfos/stats/PropertiesFileStats.java new file mode 100644 index 0000000..c6a382a --- /dev/null +++ b/src/fr/devinsy/statoolinfos/stats/PropertiesFileStats.java @@ -0,0 +1,37 @@ +/* + * 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.stats; + +import java.util.ArrayList; + +/** + * The Class PropertiesFileStats. + */ +public class PropertiesFileStats extends ArrayList +{ + private static final long serialVersionUID = 8828667177906801801L; + + /** + * Instantiates a new properties file stats. + */ + public PropertiesFileStats() + { + super(); + } +} diff --git a/src/fr/devinsy/statoolinfos/stats/PropertyStat.java b/src/fr/devinsy/statoolinfos/stats/PropertyStat.java new file mode 100644 index 0000000..0879a4a --- /dev/null +++ b/src/fr/devinsy/statoolinfos/stats/PropertyStat.java @@ -0,0 +1,89 @@ +/* + * 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.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; + } +} diff --git a/src/fr/devinsy/statoolinfos/stats/PropertyStatList.java b/src/fr/devinsy/statoolinfos/stats/PropertyStatList.java new file mode 100644 index 0000000..60605fa --- /dev/null +++ b/src/fr/devinsy/statoolinfos/stats/PropertyStatList.java @@ -0,0 +1,37 @@ +/* + * 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.stats; + +import java.util.ArrayList; + +/** + * The Class PropertyStatList. + */ +public class PropertyStatList extends ArrayList +{ + private static final long serialVersionUID = -3654806428144379451L; + + /** + * Instantiates a new property stats. + */ + public PropertyStatList() + { + super(); + } +} diff --git a/src/fr/devinsy/statoolinfos/stats/PropertyStatSet.java b/src/fr/devinsy/statoolinfos/stats/PropertyStatSet.java new file mode 100644 index 0000000..946506e --- /dev/null +++ b/src/fr/devinsy/statoolinfos/stats/PropertyStatSet.java @@ -0,0 +1,48 @@ +/* + * 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.stats; + +import java.util.HashMap; + +/** + * The Class PropertyStatSet. + */ +public class PropertyStatSet extends HashMap +{ + 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); + } +} diff --git a/src/fr/devinsy/statoolinfos/stats/PropertyStats.java b/src/fr/devinsy/statoolinfos/stats/PropertyStats.java new file mode 100644 index 0000000..9cda852 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/stats/PropertyStats.java @@ -0,0 +1,134 @@ +/* + * 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.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); + } + } +} diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java new file mode 100644 index 0000000..b5a2bfa --- /dev/null +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.java @@ -0,0 +1,67 @@ +/* + * 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.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; + } +}