Search in sources :

Example 81 with Dataset

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

the class AbstractTestRDFConnection method dataset_put_1.

@Test
public void dataset_put_1() {
    try (RDFConnection conn = connection()) {
        conn.putDataset(dataset);
        Dataset ds1 = conn.fetchDataset();
        assertTrue("Datasets not isomorphic", isomorphic(dataset, 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 82 with Dataset

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

the class AbstractTestRDFConnection method dataset_post_1.

@Test
public void dataset_post_1() {
    try (RDFConnection conn = connection()) {
        conn.loadDataset(dataset);
        Dataset ds1 = conn.fetchDataset();
        assertTrue("Datasets not isomorphic", isomorphic(dataset, 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 83 with Dataset

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

the class AbstractTestRDFConnection method dataset_load_1.

@Test
public void dataset_load_1() {
    String testDataFile = DIR + "data.trig";
    try (RDFConnection conn = connection()) {
        conn.loadDataset(testDataFile);
        Dataset ds0 = RDFDataMgr.loadDataset(testDataFile);
        Dataset ds = conn.fetchDataset();
        assertTrue("Datasets not isomorphic", isomorphic(ds0, ds));
    }
}
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 84 with Dataset

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

the class AbstractTestRDFConnection method named_graph_put_1.

@Test
public void named_graph_put_1() {
    try (RDFConnection conn = connection()) {
        conn.put(graphName, model1);
        Dataset ds1 = conn.fetchDataset();
        Model m0 = conn.fetch(graphName);
        assertTrue("Models not isomorphic", isomorphic(model1, ds1.getNamedModel(graphName)));
        Model m = conn.fetch(graphName);
        assertTrue("Models not isomorphic", isomorphic(model1, m));
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 85 with Dataset

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

the class spatialindexer method processModulesAndArgs.

@Override
protected void processModulesAndArgs() {
    super.processModulesAndArgs();
    // Two forms : with and without arg.
    // Maximises similarity with other tools.
    String file;
    if (super.contains(assemblerDescDecl)) {
        if (getValues(assemblerDescDecl).size() != 1)
            throw new CmdException("Multiple assembler descriptions given");
        if (getPositional().size() != 0)
            throw new CmdException("Additional assembler descriptions given");
        file = getValue(assemblerDescDecl);
    } else {
        if (getNumPositional() != 1)
            throw new CmdException("Multiple assembler descriptions given");
        file = getPositionalArg(0);
    }
    if (file == null)
        throw new CmdException("No dataset specified");
    // Assumes a single test daatset description in the assembler file.
    Dataset ds = SpatialDatasetFactory.create(file);
    if (ds == null)
        throw new CmdException("No dataset description found");
    // get index.
    dataset = (DatasetGraphSpatial) (ds.asDatasetGraph());
    spatialIndex = dataset.getSpatialIndex();
    if (spatialIndex == null)
        throw new CmdException("Dataset has no spatial index");
    context = new SpatialIndexContext(spatialIndex);
}
Also used : CmdException(jena.cmd.CmdException) Dataset(org.apache.jena.query.Dataset) SpatialIndexContext(org.apache.jena.query.spatial.SpatialIndexContext)

Aggregations

Dataset (org.apache.jena.query.Dataset)138 Test (org.junit.Test)63 BaseTest (org.apache.jena.atlas.junit.BaseTest)39 Model (org.apache.jena.rdf.model.Model)31 Resource (org.apache.jena.rdf.model.Resource)20 Node (org.apache.jena.graph.Node)13 RDFNode (org.apache.jena.rdf.model.RDFNode)8 UpdateBuilder (org.apache.jena.arq.querybuilder.UpdateBuilder)7 RDFConnection (org.apache.jena.rdfconnection.RDFConnection)7 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)7 ConfigTest (org.apache.jena.tdb.ConfigTest)7 CmdException (jena.cmd.CmdException)6 Graph (org.apache.jena.graph.Graph)6 SelectBuilder (org.apache.jena.arq.querybuilder.SelectBuilder)5 JenaTransactionException (org.apache.jena.sparql.JenaTransactionException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Path (java.nio.file.Path)4 Property (org.apache.jena.rdf.model.Property)4 OutputStream (java.io.OutputStream)3 Triple (org.apache.jena.graph.Triple)3