Search in sources :

Example 46 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class AbstractTestDatasetWithGraphTextIndex method putTurtleInModel.

private void putTurtleInModel(String turtle, String modelName) {
    Model model = modelName != null ? dataset.getNamedModel(modelName) : dataset.getDefaultModel();
    Reader reader = new StringReader(turtle);
    dataset.begin(ReadWrite.WRITE);
    try {
        model.read(reader, "", "TURTLE");
        dataset.commit();
    } finally {
        dataset.end();
    }
}
Also used : Model(org.apache.jena.rdf.model.Model) StringReader(java.io.StringReader) StringReader(java.io.StringReader) Reader(java.io.Reader)

Example 47 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class AbstractTestDatasetWithTextIndexBase method loadData.

protected void loadData(String turtle) {
    Model model = dataset.getDefaultModel();
    Reader reader = new StringReader(turtle);
    dataset.begin(ReadWrite.WRITE);
    model.read(reader, "", "TURTLE");
    dataset.commit();
}
Also used : Model(org.apache.jena.rdf.model.Model) StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader)

Example 48 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestBuildTextDataset method loadData.

private static void loadData(Dataset dataset) {
    dataset.begin(ReadWrite.WRITE);
    try {
        Model m = dataset.getDefaultModel();
        RDFDataMgr.read(m, DIR + "/data1.ttl");
        dataset.commit();
    } finally {
        dataset.end();
    }
}
Also used : Model(org.apache.jena.rdf.model.Model)

Example 49 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestDatasetWithLuceneMultilingualTextIndex method before.

@Before
public void before() {
    Reader reader = new StringReader(SPEC);
    Model specModel = ModelFactory.createDefaultModel();
    specModel.read(reader, "", "TURTLE");
    TextAssembler.init();
    Resource root = specModel.getResource(SPEC_ROOT_URI);
    dataset = (Dataset) Assembler.general.open(root);
}
Also used : StringReader(java.io.StringReader) Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Reader(java.io.Reader) StringReader(java.io.StringReader) Before(org.junit.Before)

Example 50 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestDatasetWithLuceneMultilingualTextIndex method testRetrievingSKOSConcepts.

@Test
public void testRetrievingSKOSConcepts() {
    String queryString = StrUtils.strjoinNL("PREFIX text: <http://jena.apache.org/text#>", "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>", "PREFIX skos: <http://www.w3.org/2004/02/skos/core#>", "SELECT ?s", "WHERE {", "    { ?s text:query ( skos:prefLabel 'frites' 'lang:fr' ) }", "    UNION ", "    { ?s text:query ( skos:prefLabel 'Kartoffelpüree' 'lang:de' ) }", "}");
    Set<String> expectedURIs = new HashSet<>();
    expectedURIs.addAll(Arrays.asList("http://example.com/dishes#fries", "http://example.com/dishes#mashed"));
    dataset.begin(ReadWrite.WRITE);
    Model model = dataset.getDefaultModel();
    RDFDataMgr.read(model, DIR + "/data.skos", Lang.RDFXML);
    dataset.commit();
    doTestQuery(dataset, "", queryString, expectedURIs, expectedURIs.size());
}
Also used : Model(org.apache.jena.rdf.model.Model) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Model (org.apache.jena.rdf.model.Model)444 Test (org.junit.Test)177 BaseTest (org.apache.jena.atlas.junit.BaseTest)96 Resource (org.apache.jena.rdf.model.Resource)87 StringReader (java.io.StringReader)43 Dataset (org.apache.jena.query.Dataset)31 RDFReader (org.apache.jena.rdf.model.RDFReader)30 Property (org.apache.jena.rdf.model.Property)24 DatasetAccessor (org.apache.jena.query.DatasetAccessor)20 InfModel (org.apache.jena.rdf.model.InfModel)20 Node (org.apache.jena.graph.Node)19 Statement (org.apache.jena.rdf.model.Statement)18 RDFConnection (org.apache.jena.rdfconnection.RDFConnection)15 Reader (java.io.Reader)14 JsonString (org.apache.jena.atlas.json.JsonString)14 AbstractFusekiTest (org.apache.jena.fuseki.AbstractFusekiTest)14 FusekiTest (org.apache.jena.fuseki.FusekiTest)14 Graph (org.apache.jena.graph.Graph)14 JenaException (org.apache.jena.shared.JenaException)14 Triple (org.apache.jena.graph.Triple)13