Search in sources :

Example 61 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractDatasetGraphFindPatterns method find_pattern_g.

@Test
public void find_pattern_g() {
    DatasetGraph dsg = create(dataPattern);
    List<Quad> quads1 = Iter.toList(dsg.find(node(":gx"), null, null, null));
    List<Quad> quads2 = Arrays.asList(q_g, q_gs, q_gp, q_go, q_gsp, q_gso, q_gpo, q_gspo);
    BaseTest.assertEqualsUnordered("find(g)", quads1, quads2);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 62 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractDatasetGraphFindPatterns method find_pattern_spo.

@Test
public void find_pattern_spo() {
    DatasetGraph dsg = create(dataPattern);
    List<Quad> quads1 = Iter.toList(dsg.find(null, node(":sx"), node(":px"), node(":ox")));
    List<Quad> quads2 = Arrays.asList(q_spo, q_gspo);
    BaseTest.assertEqualsUnordered("find(spo)", quads1, quads2);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 63 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractDatasetGraphFindPatterns method find_pattern_gs.

@Test
public void find_pattern_gs() {
    DatasetGraph dsg = create(dataPattern);
    List<Quad> quads1 = Iter.toList(dsg.find(node(":gx"), node(":sx"), null, null));
    List<Quad> quads2 = Arrays.asList(q_gs, q_gsp, q_gso, q_gspo);
    BaseTest.assertEqualsUnordered("find(gs)", quads1, quads2);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 64 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractDatasetGraphTests method quad_02.

@Test
public void quad_02() {
    DatasetGraph dsg = emptyDataset();
    assertNotNull(dsg);
    Quad quad = SSE.parseQuad("(quad <g> <s> <p> <o>)");
    dsg.add(quad);
    dsg.containsGraph(NodeFactory.createURI("g"));
    dsg.delete(quad);
    assertTrue(dsg.isEmpty());
    assertTrue(dsg.getDefaultGraph().isEmpty());
    assertTrue(dsg.getGraph(NodeFactory.createURI("g")).isEmpty());
}
Also used : Quad(org.apache.jena.sparql.core.Quad) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 65 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractDatasetGraphTests method deleteAny_01.

@Test
public void deleteAny_01() {
    DatasetGraph dsg = emptyDataset();
    Node subject = NodeFactory.createURI("http://example/s");
    Node predicate = NodeFactory.createURI("http://example/p");
    Node object = NodeFactory.createBlankNode();
    dsg.add(new Quad(Quad.defaultGraphIRI, subject, predicate, object));
    dsg.deleteAny(Node.ANY, subject, null, null);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) Node(org.apache.jena.graph.Node) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Aggregations

DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)222 Test (org.junit.Test)132 BaseTest (org.apache.jena.atlas.junit.BaseTest)59 Quad (org.apache.jena.sparql.core.Quad)47 Node (org.apache.jena.graph.Node)29 Graph (org.apache.jena.graph.Graph)18 StoreConnection (org.apache.jena.tdb.StoreConnection)17 DatasetGraphTxn (org.apache.jena.tdb.transaction.DatasetGraphTxn)15 Model (org.apache.jena.rdf.model.Model)10 IOException (java.io.IOException)7 Triple (org.apache.jena.graph.Triple)7 Dataset (org.apache.jena.query.Dataset)7 StreamRDF (org.apache.jena.riot.system.StreamRDF)7 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)5 ResultSet (org.apache.jena.query.ResultSet)5 JsonLDWriteContext (org.apache.jena.riot.JsonLDWriteContext)5 Element (org.apache.jena.sparql.syntax.Element)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 RiotException (org.apache.jena.riot.RiotException)4 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)4