Skip to content

Commit

Permalink
Merge pull request #1168 from ontodev/fix-1165
Browse files Browse the repository at this point in the history
Handle IRIs that are not entities in export
  • Loading branch information
jamesaoverton authored Nov 30, 2023
2 parents 4630074 + 4acc9a6 commit 182046b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- '--annotate-with-source true' does not work with extract --method subset [#1160]
- Fix how Template adds entities to the QuotedEntityChecker [#1104]
- Handle IRIs that are not entities in export [#1168]

## [1.9.5] - 2023-09-20

Expand Down Expand Up @@ -380,6 +381,7 @@ First official release of ROBOT!
[`template`]: http://robot.obolibrary.org/template
[`validate`]: http://robot.obolibrary.org/validate

[#1168]: https://github.com/ontodev/robot/pull/1168
[#1160]: https://github.com/ontodev/robot/pull/1160
[#1148]: https://github.com/ontodev/robot/pull/1148
[#1135]: https://github.com/ontodev/robot/pull/1135
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,12 @@ private static List<String> getPropertyValues(
IRI iri = a.getValue().asIRI().orNull();
if (iri != null) {
Set<OWLEntity> entities = ontology.getEntitiesInSignature(iri);
for (OWLEntity e : entities) {
values.add(OntologyHelper.renderManchester(e, provider, rt));
if (entities.size() > 0) {
for (OWLEntity e : entities) {
values.add(OntologyHelper.renderManchester(e, provider, rt));
}
} else {
values.add(iri.toString());
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.obolibrary.robot;

import static org.junit.Assert.assertEquals;

import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -29,6 +32,23 @@
*/
public class ExportOperationTest extends CoreTest {

/**
* Utility method to write XLSX file for debugging.
*
* @param workbook Workfbook to write
* @param path Path (string) to save to, under `robot-core/`
*/
void writeXLSX(Workbook workbook, String path) {
try {
System.out.println("Writing result to robot-core/" + path);
FileOutputStream out = new FileOutputStream(path);
workbook.write(out);
out.close();
} catch (Exception ex) {
System.out.println("Error writing workbook: " + ex);
}
}

/**
* Test exporting simple.owl to XLSX.
*
Expand Down Expand Up @@ -121,7 +141,7 @@ public void testLargeExcelExport() throws Exception {
*/
@Test
public void testExportNamedHeadingsSimple() throws Exception {
OWLOntology ontology = loadOntology("/simple.owl");
OWLOntology ontology = loadOntology("/simple_defined_by.owl");
IOHelper ioHelper = new IOHelper();
ioHelper.addPrefix(
"simple", "https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl#");
Expand All @@ -135,6 +155,7 @@ public void testExportNamedHeadingsSimple() throws Exception {
"CURIE",
"Type",
"SYNONYMS",
"rdfs:isDefinedBy",
"SUBCLASSES",
"SubClass Of",
"SubProperty Of",
Expand All @@ -153,8 +174,7 @@ public void testExportNamedHeadingsSimple() throws Exception {
Workbook wb = t.asWorkbook("|");

Sheet s = wb.getSheetAt(0);
// There should be three rows (0, 1, 2)
assert (s.getLastRowNum() == 3);
assertEquals(s.getLastRowNum(), 4);

// Validate header
// should match size and label
Expand All @@ -176,6 +196,11 @@ public void testExportNamedHeadingsSimple() throws Exception {
String expectedHeader = columns.get(colIx);
assert (foundHeader.equals(expectedHeader));
}

// rdfs:isDefinedBy should work
assertEquals(
s.getRow(4).getCell(6).getStringCellValue(),
"https://github.com/ontodev/robot/robot-core/src/test/resources/simple.owl");
}

/**
Expand Down

0 comments on commit 182046b

Please sign in to comment.