Skip to content

Commit

Permalink
bug19491: jena reasoning not on full graph
Browse files Browse the repository at this point in the history
<release-note>
bug19491: jena reasoning not on full graph

In the Jena API, AGInfModel, reasoning was previously done on graphs
(default or named), is now done on the full repo.  Reasoning on scoped
graphs will be included in a future release.
</release-note>

Change-Id: Iac640438b175ca4b97c67197a7da4bafa4cb895b
  • Loading branch information
Mike Hinchey authored and dklayer committed Aug 10, 2010
1 parent b6b51a8 commit f1a783c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/com/franz/agraph/jena/AGInfGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

import java.util.Iterator;

import org.openrdf.query.Dataset;
import org.openrdf.query.impl.DatasetImpl;

import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;
Expand All @@ -35,6 +38,13 @@ public class AGInfGraph extends AGGraph implements InfGraph {
inferred = true;
}

@Override
public Dataset getDataset() {
// TODO: use the whole store until graph-scoped reasoning is available
DatasetImpl dataset = new DatasetImpl();
return dataset;
}

@Override
public ExtendedIterator<Triple> find(Node subject, Node property,
Node object, Graph param) {
Expand Down
9 changes: 9 additions & 0 deletions src/test/Closer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
public abstract class Closer implements Closeable {

private final List toClose = new LinkedList();

/**
* Add a resource to be closed with {@link #close()}.
*/
public <Obj extends Object>
Obj closeLater(Obj o) {
toClose.add(o);
return o;
}

/**
* Add a resource to be closed with {@link #close()}.
Expand Down
32 changes: 30 additions & 2 deletions src/test/JenaTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@

import com.franz.agraph.jena.AGGraph;
import com.franz.agraph.jena.AGGraphMaker;
import com.franz.agraph.jena.AGInfModel;
import com.franz.agraph.jena.AGModel;
import com.franz.agraph.jena.AGReasoner;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;

public class JenaTests extends AGAbstractTest {

private void addOne(AGModel model) throws RepositoryException {
Assert.assertEquals(0, conn.size());
Assert.assertEquals(0, model.size());

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");

model.add(bob, fatherOf, dave);

Assert.assertEquals(1, conn.size());
Assert.assertEquals(1, model.size());
}

@Test
Expand Down Expand Up @@ -77,6 +80,31 @@ public void jenaAutoCommitFalse() throws Exception {
model.abort();
throw e;
}
}

@Test
@Category(TestSuites.Prepush.class)
public void jenaGraphs_bug19491() throws Exception {
AGGraphMaker maker = closeLater( new AGGraphMaker(conn) );
AGGraph defaultGraph = closeLater( maker.getGraph() );
AGModel defaultModel = closeLater( new AGModel(defaultGraph) );
addOne(defaultModel);

AGGraph namedGraph = closeLater( maker.openGraph("http://example.com/named") );
AGModel namedModel = closeLater( new AGModel(namedGraph) );
addOne(namedModel);

AGReasoner reasoner = new AGReasoner();
defaultGraph = closeLater( maker.getGraph() );
defaultModel = closeLater( new AGModel(defaultGraph) );
AGInfModel infModel = closeLater( new AGInfModel(reasoner, defaultModel));
Assert.assertEquals("conn is full", 2, conn.size());
Assert.assertEquals("infModel should be full", 2,
closeLater( infModel.listStatements((Resource)null, (Property)null, (RDFNode)null)).toList().size());
Assert.assertEquals("defaultModel should be partial", 1,
closeLater( defaultModel.listStatements((Resource)null, (Property)null, (RDFNode)null)).toList().size());
// TODO: size is not correct for infModel, dunno why
//Assert.assertEquals("infModel should be full", 2, infModel.size());
}

}

0 comments on commit f1a783c

Please sign in to comment.