8000 Handle IRIs that are not entities in export by jamesaoverton · Pull Request #1168 · ontodev/robot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Handle IRIs that are not entities in export #1168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 class="x x-first x-last">simple.owl");
OWLOntology class="x x-first x-last">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