Search in sources :

Example 6 with Dataset

use of org.apache.jena.query.Dataset in project jena by apache.

the class TestLocalIsolation method isolationDataset.

private void isolationDataset(Isolation isolation, boolean expected) {
    Dataset base = DatasetFactory.createTxnMem();
    RDFConnection conn1 = RDFConnectionFactory.connect(base, isolation);
    Quad quad = SSE.parseQuad("(:g :s :p :o)");
    try (RDFConnection conn2 = conn1) {
        Dataset ds = conn2.fetchDataset();
        ds.asDatasetGraph().add(quad);
    }
    assertEquals(expected, base.asDatasetGraph().contains(quad));
}
Also used : Quad(org.apache.jena.sparql.core.Quad) Dataset(org.apache.jena.query.Dataset)

Example 7 with Dataset

use of org.apache.jena.query.Dataset in project jena by apache.

the class TestLocalIsolation method isolationModel.

private void isolationModel(Isolation level, boolean expected) {
    Dataset base = DatasetFactory.createTxnMem();
    Statement stmt = base.getDefaultModel().createStatement(subject, property, object);
    RDFConnection conn1 = RDFConnectionFactory.connect(base, level);
    try (RDFConnection conn2 = conn1) {
        Model m = conn2.fetch();
        m.add(stmt);
    }
    assertEquals(expected, base.getDefaultModel().contains(stmt));
}
Also used : Dataset(org.apache.jena.query.Dataset)

Example 8 with Dataset

use of org.apache.jena.query.Dataset in project jena by apache.

the class AbstractTestRDFConnection method dataset_put_2.

@Test
public void dataset_put_2() {
    try (RDFConnection conn = connection()) {
        conn.putDataset(dataset);
        conn.putDataset(dataset2);
        Dataset ds1 = conn.fetchDataset();
        assertTrue("Datasets not isomorphic", isomorphic(dataset2, ds1));
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) Dataset(org.apache.jena.query.Dataset) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 9 with Dataset

use of org.apache.jena.query.Dataset in project jena by apache.

the class AbstractTestRDFConnection method dataset_post_2.

@Test
public void dataset_post_2() {
    try (RDFConnection conn = connection()) {
        conn.loadDataset(dataset);
        conn.loadDataset(dataset2);
        Dataset ds1 = conn.fetchDataset();
        long x = Iter.count(ds1.listNames());
        assertEquals("NG count", 3, x);
        assertFalse("Datasets are isomorphic", isomorphic(dataset, ds1));
        assertFalse("Datasets are isomorphic", isomorphic(dataset2, ds1));
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) Dataset(org.apache.jena.query.Dataset) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 10 with Dataset

use of org.apache.jena.query.Dataset in project jena by apache.

the class QueryTest method createDataset.

private static Dataset createDataset(List<String> defaultGraphURIs, List<String> namedGraphURIs) {
    // Allow "qt:data" to be quads in defaultGraphURIs.
    Dataset ds = DatasetFactory.createGeneral();
    if (defaultGraphURIs != null) {
        for (String sourceURI : defaultGraphURIs) {
            RDFDataMgr.read(ds, sourceURI);
        }
    }
    if (namedGraphURIs != null) {
        for (String sourceURI : namedGraphURIs) {
            String absSourceURI = IRIResolver.resolveString(sourceURI);
            Model m = ds.getNamedModel(absSourceURI);
            RDFDataMgr.read(m, sourceURI);
        }
    }
    return ds;
}
Also used : Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model)

Aggregations

Dataset (org.apache.jena.query.Dataset)725 Test (org.junit.Test)401 Model (org.apache.jena.rdf.model.Model)173 Ignore (org.junit.Ignore)93 URI (java.net.URI)80 Resource (org.apache.jena.rdf.model.Resource)70 QueryExecution (org.apache.jena.query.QueryExecution)53 ArrayList (java.util.ArrayList)46 QuerySolution (org.apache.jena.query.QuerySolution)46 ResultSet (org.apache.jena.query.ResultSet)45 WonNodeInformationService (won.protocol.service.WonNodeInformationService)28 Statement (org.apache.jena.rdf.model.Statement)26 Node (org.apache.jena.graph.Node)23 InputStream (java.io.InputStream)22 RDFNode (org.apache.jena.rdf.model.RDFNode)21 RdfUtils (won.protocol.util.RdfUtils)19 WonMessage (won.protocol.message.WonMessage)17 Literal (org.apache.jena.rdf.model.Literal)16 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16