Skip to content

Commit

Permalink
Resolve version incompatibilities among commons-rdf, shexjava, and jena.
Browse files Browse the repository at this point in the history
  • Loading branch information
balhoff committed Jul 18, 2024
1 parent c7426ed commit 8b11272
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
8 changes: 8 additions & 0 deletions minerva-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-commonsrdf</artifactId>
</dependency>
<dependency>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove4j</artifactId>
Expand All @@ -73,6 +77,10 @@
<groupId>org.apache.jena</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.apache.commons</groupId>
<artifactId>commons-rdf-jena</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import info.aduna.iteration.Iterations;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.rdf.jena.JenaGraph;
import org.apache.commons.rdf.jena.JenaRDF;
import org.apache.jena.graph.Graph;
import org.apache.jena.shex.ShapeMap;
import org.apache.jena.shex.ShexReport;
Expand Down Expand Up @@ -243,14 +241,10 @@ private void writeModelToDatabase(OWLOntology model, IRI modelId) throws Reposit
}

private List<OWLOntologyChange> preSaveFileHandler(OWLOntology model) throws UnknownIdentifierException {
List<OWLOntologyChange> allChanges = null;
List<OWLOntologyChange> allChanges = new ArrayList<>();
for (PreFileSaveHandler handler : preFileSaveHandlers) {
List<OWLOntologyChange> changes = handler.handle(model);
if (changes != null && !changes.isEmpty()) {
if (allChanges == null) {
allChanges = new ArrayList<OWLOntologyChange>(
changes.size());
}
allChanges.addAll(changes);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import fr.inria.lille.shexjava.validation.Status;
import fr.inria.lille.shexjava.validation.Typing;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.rdf.api.RDF;
import org.apache.commons.rdf.api.RDFTerm;
import org.apache.commons.rdf.jena.JenaGraph;
import org.apache.commons.rdf.jena.JenaRDF;
import org.apache.commons.rdf.api.*;
import org.apache.commons.rdf.simple.SimpleRDF;
import org.apache.jena.commonsrdf.JenaCommonsRDF;
import org.apache.jena.commonsrdf.JenaRDF;
import org.apache.jena.commonsrdf.impl.JenaGraph;
import org.apache.jena.query.*;
import org.apache.jena.rdf.model.*;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.sys.JenaSystem;
import org.apache.log4j.Logger;
import org.geneontology.minerva.BlazegraphOntologyManager;
import org.geneontology.minerva.curie.CurieHandler;
Expand All @@ -34,7 +36,9 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.*;
import java.util.stream.Stream;

/**
* @author bgood
Expand Down Expand Up @@ -67,6 +71,7 @@ public ShexValidator(File shex_schema_file, File shex_map_file, BlazegraphOntolo
}

public void init(File shex_schema_file, File shex_map_file, BlazegraphOntologyManager go_lego, CurieHandler curieHandler_) throws Exception {
JenaSystem.init();
schema = GenParser.parseSchema(shex_schema_file.toPath());
GoQueryMap = makeGoQueryMap(shex_map_file.getAbsolutePath());
//tbox_reasoner = tbox_reasoner_;
Expand Down Expand Up @@ -115,9 +120,8 @@ public static Map<String, String> makeGoQueryMap(String shapemap_file) throws IO
public ShexValidationReport runShapeMapValidation(Model test_model) {
boolean explain = true;
ShexValidationReport r = new ShexValidationReport();
JenaRDF jr = new JenaRDF();
//this shex implementation likes to use the commons JenaRDF interface, nothing exciting here
JenaGraph shexy_graph = jr.asGraph(test_model);
Graph shexy_graph = JenaCommonsRDF.fromJena(test_model.getGraph());
boolean all_good = true;
try {
Typing all_typed = runRefineWithTimeout(shexy_graph);
Expand Down Expand Up @@ -251,7 +255,7 @@ public ShexValidationReport runShapeMapValidationWithRecursiveSingleNodeValidati
ShexValidationReport r = new ShexValidationReport();
JenaRDF jr = new JenaRDF();
//this shex implementation likes to use the commons JenaRDF interface, nothing exciting here
JenaGraph shexy_graph = jr.asGraph(test_model);
Graph shexy_graph = JenaCommonsRDF.fromJena(test_model.getGraph());
//recursive only checks the focus node against the chosen shape.
RecursiveValidationWithMemorization shex_model_validator = new RecursiveValidationWithMemorization(schema, shexy_graph);
//for each shape in the query map (e.g. MF, BP, CC, etc.)
Expand Down Expand Up @@ -391,7 +395,7 @@ private Map<Resource, Set<String>> getShapesToTestForEachResource(Model test_mod
return node_s_shapes;
}

private Typing runRefineWithTimeout(JenaGraph shexy_graph) {
private Typing runRefineWithTimeout(Graph shexy_graph) {
final ExecutorService service = Executors.newSingleThreadExecutor();
try {
final Future<Typing> f = service.submit(() -> {
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@
<version>4.9.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-commonsrdf</artifactId>
<version>4.9.0</version>
</dependency>
<dependency>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove4j</artifactId>
Expand Down

0 comments on commit 8b11272

Please sign in to comment.