Search in sources :

Example 26 with Dataset

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

the class SpatialDatasetAssembler method open.

//    private DatasetAssembler datasetAssembler = new DatasetAssembler() ;
//    
//    public static Resource getType() { return textDataset ; }
/*
<#spatial_dataset> rdf:type     spatial:SpatialDataset ;
    spatial:dataset <#dataset> ;
    spatial:index   <#index> ;
    .

    */
@Override
public Dataset open(Assembler a, Resource root, Mode mode) {
    Resource dataset = GraphUtils.getResourceValue(root, pDataset);
    Resource index = GraphUtils.getResourceValue(root, pIndex);
    Dataset ds = (Dataset) a.open(dataset);
    SpatialIndex textIndex = (SpatialIndex) a.open(index);
    Dataset dst = SpatialDatasetFactory.create(ds, textIndex);
    return dst;
}
Also used : SpatialVocab.pDataset(org.apache.jena.query.spatial.assembler.SpatialVocab.pDataset) Dataset(org.apache.jena.query.Dataset) SpatialIndex(org.apache.jena.query.spatial.SpatialIndex) Resource(org.apache.jena.rdf.model.Resource)

Example 27 with Dataset

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

the class ExTDB_Txn2 method main.

public static void main(String... argv) {
    String directory = "MyDatabases/DB1";
    Dataset dataset = TDBFactory.createDataset(directory);
    // Start WRITE transaction. 
    //   It's possible to read from the datet inside the write transaction.
    //   An application can have other Datasets, in the same JVM, 
    //   tied to the same TDB database performing read
    //   transactions concurrently. If another write transaction
    //   starts, the call of dataset.begin(WRITE) blocks until
    //   existing writer finishes.
    dataset.begin(ReadWrite.WRITE);
    try {
        GraphStore graphStore = GraphStoreFactory.create(dataset);
        // Do a SPARQL Update.
        String sparqlUpdateString = StrUtils.strjoinNL("PREFIX . <http://example/>", "INSERT { :s :p ?now } WHERE { BIND(now() AS ?now) }");
        execUpdate(sparqlUpdateString, graphStore);
        dataset.commit();
    // Or call .abort()
    } finally {
        // Notify the end of the transaction.
        // The transaction was finished at the point .commit or .abort was called.
        // .end will force an abort() if no previous call to .commit() or .abort()
        // has occurred, so .end() help manage track the state of the transaction.
        // .end() can be called multiple times for the same .begin(WRITE)
        dataset.end();
    }
}
Also used : GraphStore(org.apache.jena.update.GraphStore) Dataset(org.apache.jena.query.Dataset)

Example 28 with Dataset

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

the class TestSpatialDatasetAssembler method testSimpleDatasetAssembler.

@Test
public void testSimpleDatasetAssembler() {
    Dataset dataset = (Dataset) Assembler.general.open(spec1);
    assertTrue(dataset.getContext().get(SpatialQuery.spatialIndex) instanceof SpatialIndexLucene);
}
Also used : SpatialIndexLucene(org.apache.jena.query.spatial.SpatialIndexLucene) Dataset(org.apache.jena.query.Dataset) Test(org.junit.Test)

Example 29 with Dataset

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

the class ExTDB1 method main.

public static void main(String... argv) {
    // Direct way: Make a TDB-back Jena model in the named directory.
    String directory = "MyDatabases/DB1";
    Dataset ds = TDBFactory.createDataset(directory);
    Model model = ds.getDefaultModel();
    // ... do work ...
    // Close the dataset.
    ds.close();
}
Also used : Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model)

Example 30 with Dataset

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

the class ExTDB2 method main.

public static void main(String... argv) {
    String assemblerFile = "Store/tdb-assembler.ttl";
    Dataset ds = TDBFactory.assembleDataset(assemblerFile);
    // ... do work ...
    ds.close();
}
Also used : Dataset(org.apache.jena.query.Dataset)

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