diff --git a/src/main/java/fr/emse/gitlab/saref/checkers/Clause_9_6_4_Checker.java b/src/main/java/fr/emse/gitlab/saref/checkers/Clause_9_6_4_Checker.java index bd8e711db1e1af686d7ce9f11a1f06a03271afad..04e9f52c7e63f4cd51ec22749cf13d121ebd4491 100644 --- a/src/main/java/fr/emse/gitlab/saref/checkers/Clause_9_6_4_Checker.java +++ b/src/main/java/fr/emse/gitlab/saref/checkers/Clause_9_6_4_Checker.java @@ -52,7 +52,7 @@ import fr.emse.gitlab.saref.managers.RepositoryManager; public class Clause_9_6_4_Checker extends AbstractClauseChecker { private static enum MESSAGE { - profile, consistent, satisfiable; + profile, consistent, satisfiable, exception; } private final SAREFExample example; @@ -89,25 +89,29 @@ public class Clause_9_6_4_Checker extends AbstractClauseChecker { OntologyManager ontologyManager = pipeline.getOntologyManager(); - Set<Explanation<OWLAxiom>> incExplanation = ontologyManager.getInconsistenceExplanations(ontology, errorLogger); - if (incExplanation != null && !incExplanation.isEmpty()) { - String explanation = incExplanation.stream().map(e -> e.getAxioms().toString()) - .collect(Collectors.joining("\n- ", "\n\n- ", "\n\n")); - logError(getMessage(MESSAGE.consistent, explanation)); - } else { - ExplanationGenerator<OWLAxiom> generator = ontologyManager.getExplanationGenerator(ontology); - ontology.classesInSignature(Imports.INCLUDED).forEach(c -> { - if(c.isOWLNothing()) { - return; - } - Set<Explanation<OWLAxiom>> incExplanation2 = ontologyManager.getIncoherenceExplanations(generator, c); - if (!incExplanation2.isEmpty()) { - String explanation = incExplanation2.stream().map(e -> e.getAxioms().toString()) - .collect(Collectors.joining("\n- ", "\n\n- ", "\n\n")); - logError(getMessage(MESSAGE.satisfiable, c, explanation)); - - } - }); + try { + Set<Explanation<OWLAxiom>> incExplanation = ontologyManager.getInconsistenceExplanations(ontology, errorLogger); + if (incExplanation != null && !incExplanation.isEmpty()) { + String explanation = incExplanation.stream().map(e -> e.getAxioms().toString()) + .collect(Collectors.joining("\n- ", "\n\n- ", "\n\n")); + logError(getMessage(MESSAGE.consistent, explanation)); + } else { + ExplanationGenerator<OWLAxiom> generator = ontologyManager.getExplanationGenerator(ontology); + ontology.classesInSignature(Imports.INCLUDED).forEach(c -> { + if(c.isOWLNothing()) { + return; + } + Set<Explanation<OWLAxiom>> incExplanation2 = ontologyManager.getIncoherenceExplanations(generator, c); + if (!incExplanation2.isEmpty()) { + String explanation = incExplanation2.stream().map(e -> e.getAxioms().toString()) + .collect(Collectors.joining("\n- ", "\n\n- ", "\n\n")); + logError(getMessage(MESSAGE.satisfiable, c, explanation)); + + } + }); + } + } catch (Exception ex) { + logError(getMessage(MESSAGE.exception), ex); } } diff --git a/src/main/resources/messages/Clause_9_6_4_Checker.properties b/src/main/resources/messages/Clause_9_6_4_Checker.properties index 9714a79abc8ef99dfdee4c0633617c8f3e14955c..74f81319d5a7ebc4cb691c26e0daecaeb4c7d00e 100644 --- a/src/main/resources/messages/Clause_9_6_4_Checker.properties +++ b/src/main/resources/messages/Clause_9_6_4_Checker.properties @@ -1,3 +1,4 @@ profile=The dataset in the example document shall satisfy the OWL2 DL profile. Violations are: %s consistent=The dataset in the example document shall be Consistent. Violations are: %s satisfiable=OWL Class %s declared in the example document should be satisfiable. Violations are: %s +exception=An exception occurred while trying to reason with the ontology.