From 83c29920ba5753112162ebaf6d56637259d5e6d5 Mon Sep 17 00:00:00 2001 From: Rebecca Jackson Date: Tue, 14 Dec 2021 11:18:36 -0800 Subject: [PATCH 1/6] Un-deprecate getViolationCount on report objects --- .../org/obolibrary/robot/checks/Report.java | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/robot-core/src/main/java/org/obolibrary/robot/checks/Report.java b/robot-core/src/main/java/org/obolibrary/robot/checks/Report.java index 8f4204557..5cc62ee3f 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/checks/Report.java +++ b/robot-core/src/main/java/org/obolibrary/robot/checks/Report.java @@ -71,6 +71,24 @@ public class Report { private IRI ontologyIRI = null; + /** + * Map of rule name to number of violations for INFO level. Replaces info map to support violation + * count by rule name. + */ + public Map infoCountByRule = new HashMap<>(); + + /** + * Map of rule name to number of violations for WARN level. Replaces warn map to support violation + * count by rule name. + */ + public Map warnCountByRule = new HashMap<>(); + + /** + * Map of rule name to number of violations for ERROR level. Replaces error map to support + * violation count by rule name. + */ + public Map errorCountByRule = new HashMap<>(); + /** Map of rules and the violations for INFO level. */ @Deprecated public Map> info = new HashMap<>(); @@ -210,14 +228,17 @@ public void addReportQuery(ReportQuery rq) { case ERROR: errorViolations.add(rq); errorCount += rq.getViolations().size(); + errorCountByRule.put(rq.getRuleName(), rq.getViolations().size()); break; case WARN: warnViolations.add(rq); warnCount += rq.getViolations().size(); + warnCountByRule.put(rq.getRuleName(), rq.getViolations().size()); break; case INFO: infoViolations.add(rq); infoCount += rq.getViolations().size(); + infoCountByRule.put(rq.getRuleName(), rq.getViolations().size()); break; default: logger.error( @@ -572,17 +593,13 @@ public void addViolations(String ruleName, String level, List violati * @return number of violations for given rule name * @throws Exception if the rule name is not in this Report object */ - @Deprecated public Integer getViolationCount(String ruleName) throws Exception { - if (info.containsKey(ruleName)) { - List v = info.get(ruleName); - return v.size(); - } else if (warn.containsKey(ruleName)) { - List v = warn.get(ruleName); - return v.size(); - } else if (error.containsKey(ruleName)) { - List v = error.get(ruleName); - return v.size(); + if (infoCountByRule.containsKey(ruleName)) { + return infoCountByRule.get(ruleName); + } else if (warnCountByRule.containsKey(ruleName)) { + return warnCountByRule.get(ruleName); + } else if (errorCountByRule.containsKey(ruleName)) { + return errorCountByRule.get(ruleName); } throw new Exception(String.format("'%s' is not a rule in this Report", ruleName)); } From 4ec7af406a4a9a324e49fa32d5dbb93fe1437c0d Mon Sep 17 00:00:00 2001 From: Rebecca Jackson Date: Tue, 14 Dec 2021 11:29:47 -0800 Subject: [PATCH 2/6] Support getting IRIs from violations too --- .../org/obolibrary/robot/checks/Report.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/robot-core/src/main/java/org/obolibrary/robot/checks/Report.java b/robot-core/src/main/java/org/obolibrary/robot/checks/Report.java index 5cc62ee3f..0a4e794f9 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/checks/Report.java +++ b/robot-core/src/main/java/org/obolibrary/robot/checks/Report.java @@ -575,12 +575,15 @@ public void addViolations(String ruleName, String level, List violati if (INFO.equals(level)) { info.put(ruleName, violations); infoCount += violations.size(); + infoCountByRule.put(ruleName, violations.size()); } else if (WARN.equals(level)) { warn.put(ruleName, violations); warnCount += violations.size(); + warnCountByRule.put(ruleName, violations.size()); } else if (ERROR.equals(level)) { error.put(ruleName, violations); errorCount += violations.size(); + errorCountByRule.put(ruleName, violations.size()); } // Otherwise do nothing } @@ -609,33 +612,35 @@ public Integer getViolationCount(String ruleName) throws Exception { * * @return a set of IRI strings */ - @Deprecated public Set getIRIs() { - Set iris = new HashSet<>(); - iris.addAll(getIRIs(error)); - iris.addAll(getIRIs(warn)); - iris.addAll(getIRIs(info)); - return iris; + List allViolations = new ArrayList<>(); + for (ReportQuery rq : errorViolations) { + allViolations.addAll(rq.getViolations()); + } + for (ReportQuery rq : warnViolations) { + allViolations.addAll(rq.getViolations()); + } + for (ReportQuery rq : infoViolations) { + allViolations.addAll(rq.getViolations()); + } + return getIRIs(allViolations); } /** * Return all the IRI strings in the given list of Violations. * - * @param violationSets map of rule name and violations + * @param violations list of Violations * @return a set of IRI strings */ - @Deprecated - public Set getIRIs(Map> violationSets) { + public Set getIRIs(List violations) { Set iris = new HashSet<>(); - for (Entry> vs : violationSets.entrySet()) { - for (Violation v : vs.getValue()) { - iris.add(v.entity.getIRI().toString()); - for (Entry> statement : v.entityStatements.entrySet()) { - iris.add(statement.getKey().getIRI().toString()); - for (OWLEntity value : statement.getValue()) { - iris.add(value.getIRI().toString()); - } + for (Violation v : violations) { + iris.add(v.entity.getIRI().toString()); + for (Entry> statement : v.entityStatements.entrySet()) { + iris.add(statement.getKey().getIRI().toString()); + for (OWLEntity value : statement.getValue()) { + iris.add(value.getIRI().toString()); } } } From 3884b1f8dbb9e6bc5b4fd529861eddc87a9fb01a Mon Sep 17 00:00:00 2001 From: Rebecca Jackson Date: Tue, 14 Dec 2021 11:32:27 -0800 Subject: [PATCH 3/6] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa8c80501..9ec6ac916 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix custom [`report`] queries [#944] +- Fix methods in `Report` object for ROBOT as a library [#951] ## [1.8.2] - 2021-12-02 @@ -286,6 +287,7 @@ First official release of ROBOT! [`template`]: http://robot.obolibrary.org/template [`validate`]: http://robot.obolibrary.org/validate +[#951]: https://github.com/ontodev/robot/pull/951 [#944]: https://github.com/ontodev/robot/pull/944 [#938]: https://github.com/ontodev/robot/pull/938 [#929]: https://github.com/ontodev/robot/pull/929 From 2277b813a618d36d0141d3ce094ca48676fb56c3 Mon Sep 17 00:00:00 2001 From: "James A. Overton" Date: Wed, 15 Dec 2021 08:52:54 -0500 Subject: [PATCH 4/6] Try japicmp on 1.8.1 --- robot-core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/robot-core/pom.xml b/robot-core/pom.xml index f86876e04..c5ac26f07 100644 --- a/robot-core/pom.xml +++ b/robot-core/pom.xml @@ -42,7 +42,7 @@ ${project.groupId} ${project.artifactId} - 1.8.2 + 1.8.1 jar From 11d1ece59866ebab8bd45a83fb55f2e3b734f322 Mon Sep 17 00:00:00 2001 From: "James A. Overton" Date: Wed, 15 Dec 2021 08:55:10 -0500 Subject: [PATCH 5/6] Try japicmp 1.8.0 --- robot-core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/robot-core/pom.xml b/robot-core/pom.xml index c5ac26f07..4cb675ba7 100644 --- a/robot-core/pom.xml +++ b/robot-core/pom.xml @@ -42,7 +42,7 @@ ${project.groupId} ${project.artifactId} - 1.8.1 + 1.8.0 jar From e417b3b72ce1d00c6ee45e566e662a25afdacd46 Mon Sep 17 00:00:00 2001 From: "James A. Overton" Date: Wed, 15 Dec 2021 09:01:41 -0500 Subject: [PATCH 6/6] Temporarily remove japicmp plugin --- robot-core/pom.xml | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/robot-core/pom.xml b/robot-core/pom.xml index 4cb675ba7..416070770 100644 --- a/robot-core/pom.xml +++ b/robot-core/pom.xml @@ -31,44 +31,6 @@ - - - - com.github.siom79.japicmp - japicmp-maven-plugin - 0.15.2 - - - - ${project.groupId} - ${project.artifactId} - 1.8.0 - jar - - - - - ${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging} - - - - - true - true - - - - - - verify - - cmp - - - -