Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 24 additions & 3 deletions robot-command/src/main/java/org/obolibrary/robot/QueryCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
import org.apache.jena.query.Dataset;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.tdb.TDBFactory;
import org.phenoscape.owlet.Owlet;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.reasoner.OWLReasoner;
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -239,14 +242,27 @@ private static void executeInMemory(
CommandLine line, OWLOntology inputOntology, List<List<String>> queries) throws Exception {
boolean useGraphs = CommandLineHelper.getBooleanValue(line, "use-graphs", false);
Dataset dataset = QueryOperation.loadOntologyAsDataset(inputOntology, useGraphs);
boolean useOwlet = CommandLineHelper.getBooleanValue(line, "owlet", false);

Owlet owlet = getOwlet(line, inputOntology, useOwlet);
try {
runQueries(line, dataset, queries);
runQueries(line, dataset, queries, owlet);
} finally {
dataset.close();
// TDBFactory.release(dataset);
}
}

private static Owlet getOwlet(CommandLine line, OWLOntology inputOntology, boolean useOwlet) {
Owlet owlet = null;
if(useOwlet) {
OWLReasonerFactory rf = CommandLineHelper.getReasonerFactory(line);
OWLReasoner r = rf.createReasoner(inputOntology);
owlet = new Owlet(r);
}
return owlet;
}

/**
* Given a command line and a list of queries, execute 'query' using TDB and writing mappings to
* disk.
Expand All @@ -260,8 +276,9 @@ private static void executeOnDisk(CommandLine line, List<List<String>> queries)
Dataset dataset = createTDBDataset(line);
boolean keepMappings = CommandLineHelper.getBooleanValue(line, "keep-tdb-mappings", false);
String tdbDir = CommandLineHelper.getDefaultValue(line, "tdb-directory", ".tdb");

try {
runQueries(line, dataset, queries);
runQueries(line, dataset, queries, null);
} finally {
dataset.close();
TDBFactory.release(dataset);
Expand Down Expand Up @@ -396,7 +413,7 @@ private static List<List<String>> getQueries(CommandLine line) {
* @param queries List of queries
* @throws IOException on issue reading or writing files
*/
private static void runQueries(CommandLine line, Dataset dataset, List<List<String>> queries)
private static void runQueries(CommandLine line, Dataset dataset, List<List<String>> queries, Owlet owlet)
throws IOException {
String format = CommandLineHelper.getOptionalValue(line, "format");
String outputDir = CommandLineHelper.getDefaultValue(line, "output-dir", "");
Expand All @@ -406,6 +423,10 @@ private static void runQueries(CommandLine line, Dataset dataset, List<List<Stri
String outputPath = q.get(1);

String query = FileUtils.readFileToString(new File(queryPath), Charset.defaultCharset());

if(owlet != null) {
query = owlet.expandQueryString(query, false);
}

String formatName = format;
if (formatName == null) {
Expand Down
20 changes: 18 additions & 2 deletions robot-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<version>3.17.0</version>
<version>4.9.0</version>
<exclusions>
<exclusion>
<groupId>com.github.jsonld-java</groupId>
Expand All @@ -134,7 +134,7 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-tdb</artifactId>
<version>3.17.0</version>
<version>4.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
Expand Down Expand Up @@ -288,6 +288,22 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<version>4.9.0</version>
Comment thread
matentzn marked this conversation as resolved.
Outdated
</dependency>
<dependency>
<groupId>org.phenoscape</groupId>
<artifactId>owlet_2.13</artifactId>
Comment thread
matentzn marked this conversation as resolved.
Outdated
<version>1.9</version>
<exclusions>
<exclusion>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down