diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index 93683a3..3c11da5 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -22,7 +22,6 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.time.LocalDateTime; -import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -672,41 +671,6 @@ public class Service extends PathPropertyList return result; } - /** - * Checks for filled metrics. - * - * @return true, if successful - */ - public boolean hasFilledMetrics() - { - boolean result; - - boolean ended = false; - Iterator iterator = this.iterator(); - result = false; - while (!ended) - { - if (iterator.hasNext()) - { - PathProperty property = iterator.next(); - - if (StringUtils.isNotBlank(property.getValue())) - { - ended = true; - result = true; - } - } - else - { - ended = true; - result = false; - } - } - - // - return result; - } - /** * Checks if is registration client. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index c0d683e..7f0c0eb 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -354,9 +354,9 @@ public class Htmlizer OrganizationTurnoutStats stats = StatAgent.statsOrganizationTurnout(organizations); PieChart pie = new PieChart("Participation"); - pie.add("Active A", stats.getWithSelfFileCount(), ChartColor.ORANGE); - pie.add("Active B", stats.getWithServiceFileCount(), ChartColor.YELLOW); - pie.add("Active C", stats.getWithServiceMetricCount(), ChartColor.GREEN); + pie.add("1 fichier", stats.getWithSelfFileCount(), ChartColor.ORANGE); + pie.add("n fichiers", stats.getWithServiceFileCount(), ChartColor.YELLOW); + pie.add("Métriques", stats.getWithServiceMetricCount(), ChartColor.GREEN); pie.add("Passive", stats.getPassiveCount(), ChartColor.BLUE); pie.setLegendPosition(Position.RIGHT); diff --git a/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java b/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java index 2df9c10..b20f2c7 100644 --- a/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java +++ b/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java @@ -22,6 +22,8 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Iterator; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -160,6 +162,37 @@ public class PathPropertyList extends ArrayList implements PathPro return result; } + /** + * Gets the by pattern. + * + * @param regex + * the regex + * @return the by pattern + */ + public PathPropertyList getByPattern(final String regex) + { + PathPropertyList result; + + result = new PathPropertyList(); + + if (StringUtils.isNotBlank(regex)) + { + Pattern pattern = Pattern.compile(regex); + + for (PathProperty property : this) + { + Matcher matcher = pattern.matcher(property.getPath()); + if (matcher.matches()) + { + result.add(property); + } + } + } + + // + return result; + } + /** * Gets the by prefix. * @@ -404,6 +437,41 @@ public class PathPropertyList extends ArrayList implements PathPro return result; } + /** + * Checks for filled metrics. + * + * @return true, if successful + */ + public boolean hasFilledValue() + { + boolean result; + + boolean ended = false; + Iterator iterator = this.iterator(); + result = false; + while (!ended) + { + if (iterator.hasNext()) + { + PathProperty property = iterator.next(); + + if (StringUtils.isNotBlank(property.getValue())) + { + ended = true; + result = true; + } + } + else + { + ended = true; + result = false; + } + } + + // + return result; + } + @Override public void put(final String key, final long value) { diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java index bfb91e1..e8ded18 100644 --- a/src/fr/devinsy/statoolinfos/stats/StatAgent.java +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.java @@ -37,6 +37,7 @@ import fr.devinsy.statoolinfos.core.Services; import fr.devinsy.statoolinfos.core.Software; import fr.devinsy.statoolinfos.core.Softwares; import fr.devinsy.statoolinfos.crawl.CrawlCache; +import fr.devinsy.statoolinfos.properties.PathPropertyList; import fr.devinsy.statoolinfos.stats.categories.CategoryStat; import fr.devinsy.statoolinfos.stats.categories.CategoryStats; import fr.devinsy.statoolinfos.stats.organizations.OrganizationTurnoutStats; @@ -381,7 +382,9 @@ public class StatAgent { Service service = iterator.next(); - if (service.hasFilledMetrics()) + PathPropertyList lines = service.getByPattern("metrics\\..*\\.\\d{4}\\.(months|weeks|days)"); + + if (lines.hasFilledValue()) { ended = true; result.incWithServiceMetricCount();