Permalink
Browse files

bug19484: jena always uses reasoning

Test added, and prepush passes.

<release-note>
bug19484: jena always uses reasoning

Fixed so reasoning is off by default and enabled when InfModel is used.
</release-note>

Change-Id: I7ce7dbc5272c380add91c20263767e38831e830e
  • Loading branch information...
1 parent b15bc90 commit 2d4b3a1d518a5565d9ecfa21a2426a89f1fcb55f Mike Hinchey committed with dklayer Jul 6, 2010
@@ -56,6 +56,7 @@ public boolean execAsk() {
throw new UnsupportedOperationException(query.getLanguage().getName() + " language does not support ASK queries.");
}
AGBooleanQuery bq = model.getGraph().getConnection().prepareBooleanQuery(query.getLanguage(), query.getQueryString());
+ bq.setIncludeInferred(model.getGraph().inferred);
boolean result;
try {
bq.setDataset(model.getGraph().getDataset());
@@ -77,6 +78,7 @@ public Model execConstruct(Model m) {
throw new UnsupportedOperationException(query.getLanguage().getName() + " language does not support CONSTRUCT queries.");
}
AGGraphQuery gq = model.getGraph().getConnection().prepareGraphQuery(query.getLanguage(), query.getQueryString());
+ gq.setIncludeInferred(model.getGraph().inferred);
GraphQueryResult result;
try {
gq.setDataset(model.getGraph().getDataset());
@@ -111,6 +113,7 @@ public Model execDescribe(Model m) {
@Override
public ResultSet execSelect() {
AGTupleQuery tq = model.getGraph().getConnection().prepareTupleQuery(query.getLanguage(), query.getQueryString());
+ tq.setIncludeInferred(model.getGraph().inferred);
TupleQueryResult result;
try {
tq.setDataset(model.getGraph().getDataset());
@@ -49,6 +49,7 @@
protected boolean prepared = false;
public AGQuery(AGRepositoryConnection con, QueryLanguage ql, String queryString, String baseURI) {
+ super.setIncludeInferred(false); // set default
this.httpCon = con;
this.queryLanguage = ql;
this.queryString = queryString;
View
@@ -18,10 +18,17 @@
import com.franz.agraph.jena.AGGraphMaker;
import com.franz.agraph.jena.AGInfModel;
import com.franz.agraph.jena.AGModel;
+import com.franz.agraph.jena.AGQuery;
+import com.franz.agraph.jena.AGQueryExecution;
+import com.franz.agraph.jena.AGQueryExecutionFactory;
+import com.franz.agraph.jena.AGQueryFactory;
import com.franz.agraph.jena.AGReasoner;
+import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.StmtIterator;
+import com.hp.hpl.jena.vocabulary.OWL;
public class JenaTests extends AGAbstractTest {
@@ -107,4 +114,40 @@ public void jenaGraphs_bug19491() throws Exception {
//Assert.assertEquals("infModel should be full", 2, infModel.size());
}
+ @Test
+ @Category(TestSuites.Prepush.class)
+ public void jenaReasoning_bug19484() throws Exception {
+ AGGraphMaker maker = closeLater( new AGGraphMaker(conn));
+ AGGraph graph = closeLater( maker.getGraph());
+ AGModel model = closeLater( new AGModel(graph));
+
+ Resource bob = model.createResource("http://example.org/people/bob");
+ Resource dave = model.createResource("http://example.org/people/dave");
+ Property fatherOf = model.createProperty("http://example.org/ontology/fatherOf");
+ Property hasFather = model.createProperty("http://example.org/ontology/hasFather");
+
+ model.add(hasFather, OWL.inverseOf, fatherOf);
+ model.add(bob, fatherOf, dave);
+
+ AGQuery query = AGQueryFactory.create("select * where { <http://example.org/people/dave> <http://example.org/ontology/hasFather> ?o . }");
+ {
+ AGInfModel inf = closeLater( new AGInfModel(new AGReasoner(), model));
+
+ StmtIterator stmts = closeLater( inf.listStatements(dave, hasFather, bob));
+ Assert.assertTrue("with reasoning", stmts.hasNext());
+
+ AGQueryExecution exe = closeLater( AGQueryExecutionFactory.create(query, inf));
+ ResultSet results = exe.execSelect();
+ Assert.assertTrue("with reasoning", results.hasNext());
+ }
+ {
+ StmtIterator stmts = closeLater( model.listStatements(dave, hasFather, bob));
+ Assert.assertFalse("without reasoning", stmts.hasNext());
+
+ AGQueryExecution exe = closeLater( AGQueryExecutionFactory.create(query, model));
+ ResultSet results = exe.execSelect();
+ Assert.assertFalse("without reasoning", results.hasNext());
+ }
+ }
+
}

0 comments on commit 2d4b3a1

Please sign in to comment.