Search in sources :

Example 16 with DatasetGraph

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

the class AbstractTestUpdateGraph method testUpdateScript3.

@Test
public void testUpdateScript3() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    script(gStore, "update-3.ru");
    assertTrue(graphEmpty(gStore.getGraph(org.apache.jena.graph.NodeFactory.createURI("http://example/g1"))));
    assertTrue(graphEmpty(gStore.getDefaultGraph()));
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 17 with DatasetGraph

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

the class AbstractTestUpdateGraph method testModify1.

@Test
public void testModify1() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    defaultGraphData(gStore, data2());
    namedGraphData(gStore, graphIRI, Factory.createDefaultGraph());
    UpdateModify modify = new UpdateModify();
    Element element = QueryFactory.createElement("{ ?s <http://example/p> ?o }");
    modify.setElement(element);
    modify.getInsertAcc().addQuad(new Quad(graphIRI, triple1));
    modify.getDeleteAcc().addTriple(SSE.parseTriple("(?s <http://example/p> ?o)"));
    modify.getDeleteAcc().addQuad(SSE.parseQuad("(<http://example/graph> ?s <http://example/p> ?o)"));
    UpdateAction.execute(modify, gStore);
    assertFalse(graphEmpty(gStore.getGraph(graphIRI)));
    assertTrue(graphEmpty(gStore.getDefaultGraph()));
    assertTrue(graphContains(gStore.getGraph(graphIRI), triple1));
}
Also used : Quad(org.apache.jena.sparql.core.Quad) Element(org.apache.jena.sparql.syntax.Element) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 18 with DatasetGraph

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

the class AbstractTestUpdateBase method defaultGraphData.

protected void defaultGraphData(DatasetGraph gStore, Graph data) {
    Graph g = gStore.getDefaultGraph();
    g.clear();
    GraphUtil.addInto(g, data);
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph)

Example 19 with DatasetGraph

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

the class AbstractTestUpdateBase method namedGraphData.

protected void namedGraphData(DatasetGraph gStore, Node uri, Graph data) {
    Graph g = gStore.getGraph(uri);
    if (g == null) {
        gStore.addGraph(uri, GraphFactory.createJenaDefaultGraph());
        g = gStore.getGraph(uri);
    } else
        g.clear();
    GraphUtil.addInto(g, data);
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph)

Example 20 with DatasetGraph

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

the class AbstractTestUpdateGraph method testUpdateScript7.

@Test
public void testUpdateScript7() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    script(gStore, "data-4.ru");
    assertTrue(graphContains(gStore.getDefaultGraph(), new Triple(s, p, NodeFactoryExtra.parseNode("123"))));
    Graph g = gStore.getGraph(graphIRI);
    assertTrue(graphContains(gStore.getGraph(graphIRI), new Triple(s, p, o2)));
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) 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