From 907fd57c5d6aa4337820580c6f607eda916a1c0e Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 30 Oct 2020 01:29:55 +0100 Subject: [PATCH] Improved missing property check label. --- .../statoolinfos/checker/PropertyChecker.java | 10 ++++---- .../statoolinfos/checker/PropertyRule.java | 24 +++++++++++++++++++ .../statoolinfos/checker/PropertyRules.java | 21 +++++++++++++++- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/checker/PropertyChecker.java b/src/fr/devinsy/statoolinfos/checker/PropertyChecker.java index e327ba5..81b3d88 100644 --- a/src/fr/devinsy/statoolinfos/checker/PropertyChecker.java +++ b/src/fr/devinsy/statoolinfos/checker/PropertyChecker.java @@ -79,7 +79,7 @@ public class PropertyChecker this.federationRules.add("federation.logo", URL, PropertyMode.WISHED); this.federationRules.add("federation.contact.url", URL, PropertyMode.WISHED); this.federationRules.add("federation.contact.email", EMAIL, PropertyMode.WISHED); - this.federationRules.add("^federation\\.socialnetworks\\.\\S+$", URL, PropertyMode.WISHED); + this.federationRules.add("federation.socialnetworks.…", "^federation\\.socialnetworks\\.\\S+$", URL, PropertyMode.WISHED); this.federationRules.add("federation.legal.url", URL, PropertyMode.WISHED); this.federationRules.add("federation.legal", URL, PropertyMode.WISHED); this.federationRules.add("federation.guide.user", URL, PropertyMode.WISHED); @@ -111,13 +111,13 @@ public class PropertyChecker this.organizationRules.add("organization.status.description", STRING, PropertyMode.OPTIONAL); this.organizationRules.add("organization.website", URL, PropertyMode.WISHED); this.organizationRules.add("organization.logo", URL, PropertyMode.WISHED); - this.organizationRules.add("^organization\\.socialnetworks\\.\\S+$", URL, PropertyMode.WISHED); + this.organizationRules.add("organization.socialnetworks.…", "^organization\\.socialnetworks\\.\\S+$", URL, PropertyMode.WISHED); this.organizationRules.add("organization.owner.name", STRING, PropertyMode.OPTIONAL); this.organizationRules.add("organization.owner.website", URL, PropertyMode.OPTIONAL); this.organizationRules.add("organization.owner.logo", URL, PropertyMode.OPTIONAL); this.organizationRules.add("organization.contact.url", URL, PropertyMode.WISHED); this.organizationRules.add("organization.contact.email", EMAIL, PropertyMode.WISHED); - this.organizationRules.add("^organization\\.legal(\\.url)?$", URL, PropertyMode.WISHED); + this.organizationRules.add("organization.legal.url", "^organization\\.legal(\\.url)?$", URL, PropertyMode.WISHED); this.organizationRules.add("organization.guide.user", URL, PropertyMode.WISHED); this.organizationRules.add("organization.guide.technical", URL, PropertyMode.WISHED); this.organizationRules.add("organization.startdate", DATE, PropertyMode.WISHED); @@ -147,7 +147,7 @@ public class PropertyChecker this.serviceRules.add("service.logo", URL, PropertyMode.WISHED); this.serviceRules.add("service.contact.url", URL, PropertyMode.WISHED); this.serviceRules.add("service.contact.email", EMAIL, PropertyMode.WISHED); - this.serviceRules.add("^service\\.socialnetworks\\.\\S+$", URL, PropertyMode.OPTIONAL); + this.serviceRules.add("service.socialnetworks.…", "^service\\.socialnetworks\\.\\S+$", URL, PropertyMode.OPTIONAL); this.serviceRules.add("service.legal.url", URL, PropertyMode.WISHED); this.serviceRules.add("service.guide.user", URL, PropertyMode.WISHED); this.serviceRules.add("service.guide.technical", URL, PropertyMode.WISHED); @@ -226,7 +226,7 @@ public class PropertyChecker status = Status.WARNING; break; } - PropertyCheck check = new PropertyCheck(0, rule.getPathPattern().replaceAll("\\\\.", "."), status, "Propriété manquante"); + PropertyCheck check = new PropertyCheck(0, rule.getLabel(), status, "Propriété manquante"); result.add(check); } } diff --git a/src/fr/devinsy/statoolinfos/checker/PropertyRule.java b/src/fr/devinsy/statoolinfos/checker/PropertyRule.java index f212e44..c1dbcba 100644 --- a/src/fr/devinsy/statoolinfos/checker/PropertyRule.java +++ b/src/fr/devinsy/statoolinfos/checker/PropertyRule.java @@ -35,6 +35,7 @@ public class PropertyRule OPTIONAL } + private String label; private Pattern pathPattern; private Pattern valuePattern; private PropertyMode mode; @@ -50,10 +51,28 @@ public class PropertyRule * the mode */ public PropertyRule(final String pathRegex, final String valueRegex, final PropertyMode mode) + { + this(pathRegex, pathRegex, valueRegex, mode); + } + + /** + * Instantiates a new property rule. + * + * @param label + * the label + * @param pathRegex + * the path regex + * @param valueRegex + * the value regex + * @param mode + * the mode + */ + public PropertyRule(final String label, final String pathRegex, final String valueRegex, final PropertyMode mode) { this.pathPattern = Pattern.compile(pathRegex); this.valuePattern = Pattern.compile(valueRegex); this.mode = mode; + this.label = label; } /** @@ -89,6 +108,11 @@ public class PropertyRule return result; } + public String getLabel() + { + return this.label; + } + public PropertyMode getMode() { return this.mode; diff --git a/src/fr/devinsy/statoolinfos/checker/PropertyRules.java b/src/fr/devinsy/statoolinfos/checker/PropertyRules.java index bfe4048..d358088 100644 --- a/src/fr/devinsy/statoolinfos/checker/PropertyRules.java +++ b/src/fr/devinsy/statoolinfos/checker/PropertyRules.java @@ -60,7 +60,26 @@ public class PropertyRules extends ArrayList targetPath = path.replace(".", "\\."); } - PropertyRule rule = new PropertyRule(targetPath, pattern, mode); + PropertyRule rule = new PropertyRule(path, targetPath, pattern, mode); + + this.add(rule); + } + + /** + * Adds the. + * + * @param label + * the label + * @param path + * the path + * @param pattern + * the pattern + * @param mode + * the mode + */ + public void add(final String label, final String path, final String pattern, final PropertyMode mode) + { + PropertyRule rule = new PropertyRule(label, path, pattern, mode); this.add(rule); }