diff --git a/src/fr/devinsy/statoolinfos/core/Categories.java b/src/fr/devinsy/statoolinfos/core/Categories.java index 93b61c7..3f245ef 100644 --- a/src/fr/devinsy/statoolinfos/core/Categories.java +++ b/src/fr/devinsy/statoolinfos/core/Categories.java @@ -54,7 +54,7 @@ public class Categories extends ArrayList for (Category category : this) { - if (category.getSoftwares().containsAnyIgnoreCase(softwareName)) + if (category.matchesSoftware(softwareName)) { result.add(category); } @@ -84,7 +84,7 @@ public class Categories extends ArrayList { Category category = iterator.next(); - if (category.getSoftwares().containsIgnoreCase(softwareName)) + if (category.matchesSoftware(softwareName)) { ended = true; result = true; diff --git a/src/fr/devinsy/statoolinfos/core/Category.java b/src/fr/devinsy/statoolinfos/core/Category.java index 7791d97..a6c8c8d 100644 --- a/src/fr/devinsy/statoolinfos/core/Category.java +++ b/src/fr/devinsy/statoolinfos/core/Category.java @@ -18,6 +18,8 @@ */ package fr.devinsy.statoolinfos.core; +import java.util.Iterator; + import org.apache.commons.lang3.StringUtils; import fr.devinsy.strings.StringList; @@ -139,6 +141,48 @@ public class Category return result; } + /** + * Matches. + * + * @param softwareName + * the software name + * @return true, if successful + */ + public boolean matchesSoftware(final String softwareName) + { + boolean result; + + String target = StringUtils.stripAccents(softwareName).replaceAll("[\\W\\s]", ""); + + boolean ended = false; + Iterator iterator = this.softwares.iterator(); + result = false; + while (!ended) + { + if (iterator.hasNext()) + { + String source1 = iterator.next(); + String source2 = StringUtils.stripAccents(source1).replaceAll("[\\W\\s]", ""); + + System.out.println("<" + source1 + "/" + source2 + "><" + softwareName + "/" + target + "> " + StringUtils.equalsIgnoreCase(target, source1)); + + if (StringUtils.equalsIgnoreCase(target, source2)) + { + ended = true; + result = true; + } + } + else + { + ended = true; + result = false; + } + } + + // + return result; + } + public void setDescription(final String description) { this.description = description; diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java index d03541f..52289a7 100644 --- a/src/fr/devinsy/statoolinfos/stats/StatAgent.java +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.java @@ -92,7 +92,7 @@ public class StatAgent for (Service service : federation.getServices()) { String softwareName = service.getSoftwareName(); - if (category.getSoftwares().containsIgnoreCase(softwareName)) + if (category.matchesSoftware(softwareName)) { stat.incServiceCount(); YearMonth month = YearMonth.now().minusMonths(1); diff --git a/src/fr/devinsy/statoolinfos/stats/properties/PropertyStats.java b/src/fr/devinsy/statoolinfos/stats/properties/PropertyStats.java index 073070e..712e046 100644 --- a/src/fr/devinsy/statoolinfos/stats/properties/PropertyStats.java +++ b/src/fr/devinsy/statoolinfos/stats/properties/PropertyStats.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Christian Pierre MOMON + * Copyright (C) 2020 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. *