Search in sources :

Example 21 with Resource

use of org.apache.jena.rdf.model.Resource 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 22 with Resource

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

the class TestDatasetWithLuceneTextIndexWithLangField 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 23 with Resource

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

the class StageAltMain method makeData.

private static Model makeData() {
    Model model = ModelFactory.createDefaultModel();
    Resource r = model.createResource(NS + "r");
    Property p1 = model.createProperty(NS + "p1");
    Property p2 = model.createProperty(NS + "p2");
    model.add(r, p1, "xyz");
    model.add(r, p2, "abc");
    return model;
}
Also used : Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Property(org.apache.jena.rdf.model.Property)

Example 24 with Resource

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

the class TestLangTurtle method optionalDotInBase.

@Test
public void optionalDotInBase() {
    Model model = ModelFactory.createDefaultModel();
    StringReader reader = new StringReader("@base <http://example/> <x> <p> <o> .");
    RDFDataMgr.read(model, reader, null, RDFLanguages.TURTLE);
    assertEquals(1, model.size());
    Resource r = model.createResource("http://example/x");
    Property p = model.createProperty("http://example/p");
    assertTrue(model.contains(r, p));
}
Also used : Model(org.apache.jena.rdf.model.Model) StringReader(java.io.StringReader) Resource(org.apache.jena.rdf.model.Resource) Property(org.apache.jena.rdf.model.Property) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 25 with Resource

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

the class TestUpdateOperations method insert_where_01.

@Test
public void insert_where_01() {
    Model m = ModelFactory.createDefaultModel();
    Resource anon = m.createResource();
    anon.addProperty(RDF.type, OWL.Thing);
    assertEquals(1, m.size());
    UpdateRequest req = UpdateFactory.create("INSERT { ?s ?p ?o } WHERE { ?o ?p ?s }");
    UpdateAction.execute(req, m);
    assertEquals(2, m.size());
    assertEquals(1, m.listStatements(anon, null, (RDFNode) null).toList().size());
    assertEquals(1, m.listStatements(null, null, anon).toList().size());
}
Also used : Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) RDFNode(org.apache.jena.rdf.model.RDFNode) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Aggregations

Resource (org.apache.jena.rdf.model.Resource)179 Model (org.apache.jena.rdf.model.Model)87 Test (org.junit.Test)55 Property (org.apache.jena.rdf.model.Property)35 RDFNode (org.apache.jena.rdf.model.RDFNode)25 Dataset (org.apache.jena.query.Dataset)20 Literal (org.apache.jena.rdf.model.Literal)17 BaseTest (org.apache.jena.atlas.junit.BaseTest)16 Node (org.apache.jena.graph.Node)16 Statement (org.apache.jena.rdf.model.Statement)15 UpdateBuilder (org.apache.jena.arq.querybuilder.UpdateBuilder)13 StringReader (java.io.StringReader)9 Triple (org.apache.jena.graph.Triple)9 InfModel (org.apache.jena.rdf.model.InfModel)9 Reader (java.io.Reader)8 ArrayList (java.util.ArrayList)8 JsonString (org.apache.jena.atlas.json.JsonString)8 JsonLDWriteContext (org.apache.jena.riot.JsonLDWriteContext)6 PrefixMapping (org.apache.jena.shared.PrefixMapping)6 SelectBuilder (org.apache.jena.arq.querybuilder.SelectBuilder)5