diff --git a/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java b/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java index 8d69b29..79fcccb 100644 --- a/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java +++ b/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java @@ -20,6 +20,8 @@ package fr.devinsy.statoolinfos.checker; import java.util.ArrayList; +import fr.devinsy.statoolinfos.core.Service.Status; + /** * The Class PropertyChecks. */ @@ -57,4 +59,92 @@ public class PropertyChecks extends ArrayList // return result; } + + /** + * Gets the alert count. + * + * @return the alert count + */ + public int getAlertCount() + { + int result; + + result = 0; + for (PropertyCheck check : this) + { + if (check.getStatus() == Status.ALERT) + { + result += 1; + } + } + + // + return result; + } + + /** + * Gets the error count. + * + * @return the error count + */ + public int getErrorCount() + { + int result; + + result = 0; + for (PropertyCheck check : this) + { + if (check.getStatus() == Status.ERROR) + { + result += 1; + } + } + + // + return result; + } + + /** + * Gets the void count. + * + * @return the void count + */ + public int getVoidCount() + { + int result; + + result = 0; + for (PropertyCheck check : this) + { + if (check.getStatus() == Status.VOID) + { + result += 1; + } + } + + // + return result; + } + + /** + * Gets the warning count. + * + * @return the warning count + */ + public int getWarningCount() + { + int result; + + result = 0; + for (PropertyCheck check : this) + { + if (check.getStatus() == Status.WARNING) + { + result += 1; + } + } + + // + return result; + } } \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/core/Factory.java b/src/fr/devinsy/statoolinfos/core/Factory.java index de18d98..8821bf6 100644 --- a/src/fr/devinsy/statoolinfos/core/Factory.java +++ b/src/fr/devinsy/statoolinfos/core/Factory.java @@ -247,7 +247,7 @@ public class Factory URL serviceInputURL = new URL(property.getValue()); Service service = loadService(serviceInputURL, cache); service.setOrganization(result); - result.setLogoFileName(result.getTechnicalName() + "-" + result.getLogoFileName()); + service.setLogoFileName(result.getTechnicalName() + "-" + result.getLogoFileName()); result.getServices().add(service); } } diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java index 0635792..a26dfe6 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java @@ -79,7 +79,51 @@ public class PropertiesFilesPage data.setContent("fileListLine", index, "fileListLineActiveCount", stat.getActiveLineCount()); data.setContent("fileListLine", index, "fileListLineBlankPropertyCount", stat.getBlankPropertyCount()); data.setContent("fileListLine", index, "fileListLineFilledPropertyCount", stat.getFilledPropertyCount()); - data.setContent("fileListLine", index, "fileListLineErrorCount", stat.getErrorCount()); + + if (stat.getWarningCount() > 0) + { + data.setAttribute("fileListLine", index, "fileListLineWarningCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); + data.setContent("fileListLine", index, "fileListLineWarningCountLink", stat.getWarningCount()); + data.setAttribute("fileListLine", index, "fileListLineWarningCount", "style", "background-color: yellow;"); + } + else + { + data.setContent("fileListLine", index, "fileListLineWarningCount", stat.getWarningCount()); + } + + if (stat.getAlertCount() > 0) + { + data.setAttribute("fileListLine", index, "fileListLineAlertCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); + data.setContent("fileListLine", index, "fileListLineAlertCountLink", stat.getAlertCount()); + data.setAttribute("fileListLine", index, "fileListLineAlertCount", "style", "background-color: orange;"); + } + else + { + data.setContent("fileListLine", index, "fileListLineAlertCount", stat.getAlertCount()); + } + + if (stat.getErrorCount() > 0) + { + data.setAttribute("fileListLine", index, "fileListLineErrorCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); + data.setContent("fileListLine", index, "fileListLineErrorCountLink", stat.getErrorCount()); + data.setAttribute("fileListLine", index, "fileListLineErrorCount", "style", "background-color: red;"); + } + else + { + data.setContent("fileListLine", index, "fileListLineErrorCount", stat.getErrorCount()); + } + + if (stat.getVoidCount() > 0) + { + data.setAttribute("fileListLine", index, "fileListLineVoidCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); + data.setContent("fileListLine", index, "fileListLineVoidCountLink", stat.getVoidCount()); + data.setAttribute("fileListLine", index, "fileListLineVoidCount", "style", "background-color: rgb(54, 162, 235, 0.2);"); + } + else + { + data.setContent("fileListLine", index, "fileListLineVoidCount", stat.getVoidCount()); + } + data.setContent("fileListLine", index, "fileListLineDate", stat.getUpdateDate().toString()); index += 1; diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml index f2ff918..cfd9ea0 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml @@ -11,7 +11,7 @@ -
+

Fichiers properties

Nombre de fichiers : n/a
@@ -25,7 +25,10 @@ Propriétés Remplies Vides + Warning + Alerte Erreurs + Inconnues Date @@ -44,7 +47,10 @@ n/a n/a n/a - n/a + n/a + n/a + n/a + n/a n/a diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java index 4a22830..93c0351 100644 --- a/src/fr/devinsy/statoolinfos/stats/StatAgent.java +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.java @@ -140,11 +140,11 @@ public class StatAgent for (Organization organization : federation.getOrganizations()) { - result.add(result.stat(organization)); + result.stat(organization); for (Service service : organization.getServices()) { - result.add(result.stat(service)); + result.stat(service); } } diff --git a/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStat.java b/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStat.java index 8d61584..3947dec 100644 --- a/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStat.java +++ b/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStat.java @@ -35,7 +35,10 @@ public class PropertiesFileStat private int activeLineCount; private int blankPropertyCount; private int filledPropertyCount; + private int warningCount; + private int alertCount; private int errorCount; + private int voidCount; private LocalDateTime updateDate; /** @@ -50,6 +53,11 @@ public class PropertiesFileStat return this.activeLineCount; } + public int getAlertCount() + { + return this.alertCount; + } + public int getBlankPropertyCount() { return this.blankPropertyCount; @@ -90,11 +98,26 @@ public class PropertiesFileStat return this.url; } + public int getVoidCount() + { + return this.voidCount; + } + + public int getWarningCount() + { + return this.warningCount; + } + public void incActiveLineCount() { this.activeLineCount += 1; } + public void incAlertCount() + { + this.alertCount += 1; + } + public void incBlankPropertyCount() { this.blankPropertyCount += 1; @@ -115,11 +138,26 @@ public class PropertiesFileStat this.lineCount += 1; } + public void incVoidCount() + { + this.voidCount += 1; + } + + public void incWarningCount() + { + this.warningCount += 1; + } + public void setActiveLineCount(final int activeLineCount) { this.activeLineCount = activeLineCount; } + public void setAlertCount(final int alertCount) + { + this.alertCount = alertCount; + } + public void setBlankPropertyCount(final int blankPropertyCount) { this.blankPropertyCount = blankPropertyCount; @@ -159,4 +197,14 @@ public class PropertiesFileStat { this.url = url; } + + public void setVoidCount(final int voidCount) + { + this.voidCount = voidCount; + } + + public void setWarningCount(final int warningCount) + { + this.warningCount = warningCount; + } } diff --git a/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStats.java b/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStats.java index f5c7338..85a79ed 100644 --- a/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStats.java +++ b/src/fr/devinsy/statoolinfos/stats/propertyfiles/PropertiesFileStats.java @@ -24,6 +24,8 @@ import java.util.ArrayList; import org.apache.commons.lang3.StringUtils; +import fr.devinsy.statoolinfos.checker.PropertyChecker; +import fr.devinsy.statoolinfos.checker.PropertyChecks; import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.strings.StringList; @@ -125,23 +127,26 @@ public class PropertiesFileStats extends ArrayList * * @param organization * the organization - * @return the properties file stat * @throws IOException * Signals that an I/O exception has occurred. */ - public PropertiesFileStat stat(final Organization organization) throws IOException + public void stat(final Organization organization) throws IOException { - PropertiesFileStat result; + PropertiesFileStat stat = stat(organization.getInputFile()); - result = stat(organization.getInputFile()); + stat.setURL(organization.getInputURL()); + stat.setLocalName(organization.getTechnicalName() + ".properties"); + stat.setOrganization(organization); + stat.setUpdateDate(organization.getCrawledDate()); - result.setURL(organization.getInputURL()); - result.setLocalName(organization.getTechnicalName() + ".properties"); - result.setOrganization(organization); - result.setUpdateDate(organization.getCrawledDate()); + PropertyChecker checker = new PropertyChecker(); + PropertyChecks checks = checker.checkOrganization(organization.getInputFile()); + stat.setWarningCount(checks.getWarningCount()); + stat.setAlertCount(checks.getAlertCount()); + stat.setErrorCount(checks.getErrorCount()); + stat.setVoidCount(checks.getVoidCount()); - // - return result; + add(stat); } /** @@ -149,22 +154,22 @@ public class PropertiesFileStats extends ArrayList * * @param service * the service - * @return the properties file stat * @throws IOException * Signals that an I/O exception has occurred. */ - public PropertiesFileStat stat(final Service service) throws IOException + public void stat(final Service service) throws IOException { - PropertiesFileStat result; + PropertiesFileStat stat = stat(service.getInputFile()); - result = stat(service.getInputFile()); + stat.setURL(service.getInputURL()); + stat.setLocalName(service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".properties"); + stat.setOrganization(service.getOrganization()); + stat.setUpdateDate(service.getCrawledDate()); - result.setURL(service.getInputURL()); - result.setLocalName(service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".properties"); - result.setOrganization(service.getOrganization()); - result.setUpdateDate(service.getCrawledDate()); + PropertyChecker checker = new PropertyChecker(); + PropertyChecks checks = checker.checkService(service.getInputFile()); + stat.setErrorCount(checks.getErrorCount()); - // - return result; + add(stat); } }