Skip to content

Commit

Permalink
bug19484: jena always uses reasoning
Browse files Browse the repository at this point in the history
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
Mike Hinchey authored and dklayer committed Jul 20, 2010
1 parent b15bc90 commit 2d4b3a1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/com/franz/agraph/jena/AGQueryExecution.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions src/com/franz/agraph/repository/AGQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public abstract class AGQuery extends AbstractQuery {
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;
Expand Down
43 changes: 43 additions & 0 deletions src/test/JenaTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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.