diff --git a/CHANGELOG.md b/CHANGELOG.md index a5a64a297..bc66b3239 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix `deprecated_class_reference` [`report`] query [#902] - Fix error handling for JSON conversion [#907] - Fix handling of property chains when removing/filtering base axioms in [#914] +- Fix SPLIT unpacking in named individuals in [`template`] [#924] ### Changed - Do not allow malformed IRIs to be returned by `IOHelper` [#882] @@ -276,6 +277,7 @@ First official release of ROBOT! [`template`]: http://robot.obolibrary.org/template [`validate`]: http://robot.obolibrary.org/validate +[#924]: https://github.com/ontodev/robot/issues/924 [#914]: https://github.com/ontodev/robot/pull/914 [#907]: https://github.com/ontodev/robot/pull/907 [#902]: https://github.com/ontodev/robot/pull/902 diff --git a/robot-core/src/main/java/org/obolibrary/robot/Template.java b/robot-core/src/main/java/org/obolibrary/robot/Template.java index e87a50c39..b81dcc50f 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/Template.java +++ b/robot-core/src/main/java/org/obolibrary/robot/Template.java @@ -1881,6 +1881,10 @@ private void addIndividualAxioms(IRI iri, List row) throws Exception { // Handle annotations if (template.startsWith("A") || template.startsWith("LABEL")) { + if (split != null) { + // Add the split back on for getAnnotations + template = template + " SPLIT=" + split; + } // Add the annotations to the individual Set annotations = getAnnotations(template, value, row, column); for (OWLAnnotation annotation : annotations) { diff --git a/robot-core/src/test/java/org/obolibrary/robot/TemplateTest.java b/robot-core/src/test/java/org/obolibrary/robot/TemplateTest.java index 68d05e51b..8e39eca03 100644 --- a/robot-core/src/test/java/org/obolibrary/robot/TemplateTest.java +++ b/robot-core/src/test/java/org/obolibrary/robot/TemplateTest.java @@ -8,6 +8,7 @@ import org.semanticweb.owlapi.apibinding.OWLManager; import org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxClassExpressionParser; import org.semanticweb.owlapi.model.*; +import org.semanticweb.owlapi.search.EntitySearcher; /** * Tests Template class and class methods. @@ -156,4 +157,33 @@ public void testParseClass() throws Exception { TemplateHelper.tryParse("test", checker, parser, label, 0, 0).asOWLClass(); assert actualClass.getIRI().toString().equals(expectedClass.getIRI().toString()); } + + /** + * Test named individual with split property. + * + * @throws Exception if entities cannot be found + */ + @Test + public void testNamedIndividualSplit() throws Exception { + Map options = TemplateOperation.getDefaultOptions(); + IOHelper ioHelper = new IOHelper(); + ioHelper.addPrefix("ex", "http://example.com/"); + + Map>> tables = new LinkedHashMap<>(); + String path = "/template-individual-split.csv"; + tables.put(path, TemplateHelper.readCSV(this.getClass().getResourceAsStream(path))); + + OWLOntology ontology = TemplateOperation.template(null, ioHelper, tables, options); + + assertEquals("Count individuals", 1, ontology.getIndividualsInSignature().size()); + OWLNamedIndividual namedIndividual = ontology.getIndividualsInSignature().iterator().next(); + assertEquals( + "Count annotation properties", 1, ontology.getAnnotationPropertiesInSignature().size()); + OWLAnnotationProperty annotationProperty = + ontology.getAnnotationPropertiesInSignature().iterator().next(); + assertEquals( + "Count annotation properties of individual", + 2, + EntitySearcher.getAnnotationObjects(namedIndividual, ontology, annotationProperty).size()); + } } diff --git a/robot-core/src/test/resources/template-individual-split.csv b/robot-core/src/test/resources/template-individual-split.csv new file mode 100644 index 000000000..af9dc1492 --- /dev/null +++ b/robot-core/src/test/resources/template-individual-split.csv @@ -0,0 +1,3 @@ +ID,Entity Type,Synonyms +ID,TYPE,A IAO:0000118 SPLIT=| +ex:indv_1,owl:NamedIndividual,synonym 1|synonym 2 \ No newline at end of file