Search in sources :

Example 6 with StmtIterator

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

the class TestModelEvents method testAddStatementIterator.

public void testAddStatementIterator() {
    model.register(SL);
    final Statement[] sa = ModelHelper.statements(model, "x R y; a P b; x R y");
    final StmtIterator it = asIterator(sa);
    model.add(it);
    SL.assertHas(new Object[] { "addIterator", Arrays.asList(sa) });
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) Statement(org.apache.jena.rdf.model.Statement)

Example 7 with StmtIterator

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

the class TestReaders method testReadLocalNTriple.

public void testReadLocalNTriple() {
    model.read(getInputStream("TestReaders.nt"), "", "N-TRIPLE");
    Assert.assertEquals("Wrong size model", 5, model.size());
    final StmtIterator iter = model.listStatements(null, null, "foo\"\\\n\r\tbar");
    Assert.assertTrue("No next statement found", iter.hasNext());
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator)

Example 8 with StmtIterator

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

the class TestReasoners method testTransitiveSpecReuse.

/**
     * The reasoner contract for bind(data) is not quite precise. It allows for
     * reasoners which have state so that reusing the same reasoner on a second data
     * model might lead to interference. This in fact used to happen with the transitive
     * reasoner. This is a test to check the top level symptoms of this which can be
     * solved just be not reusing reasoners.
     * @todo this test might be better moved to OntModel tests somewhere
     */
public void testTransitiveSpecReuse() {
    OntModel om1 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF);
    Resource c1 = om1.createResource(PrintUtil.egNS + "Class1");
    Resource c2 = om1.createResource(PrintUtil.egNS + "Class2");
    Resource c3 = om1.createResource(PrintUtil.egNS + "Class3");
    om1.add(c1, RDFS.subClassOf, c2);
    om1.add(c2, RDFS.subClassOf, c3);
    om1.prepare();
    assertFalse(om1.isEmpty());
    OntModel om2 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF);
    StmtIterator si = om2.listStatements();
    boolean ok = !si.hasNext();
    si.close();
    assertTrue("Transitive reasoner state leak", ok);
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) Resource(org.apache.jena.rdf.model.Resource) OntModel(org.apache.jena.ontology.OntModel)

Example 9 with StmtIterator

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

the class TestReasoners method testModelFactoryRDFS.

/**
     * Test the ModelFactory interface
     */
public void testModelFactoryRDFS() {
    Model data = ModelFactory.createDefaultModel();
    Property p = data.createProperty("urn:x-hp:ex/p");
    Resource a = data.createResource("urn:x-hp:ex/a");
    Resource b = data.createResource("urn:x-hp:ex/b");
    Resource C = data.createResource("urn:x-hp:ex/c");
    data.add(p, RDFS.range, C).add(a, p, b);
    Model result = ModelFactory.createRDFSModel(data);
    StmtIterator i = result.listStatements(b, RDF.type, (RDFNode) null);
    TestUtil.assertIteratorValues(this, i, new Object[] { data.createStatement(b, RDF.type, RDFS.Resource), data.createStatement(b, RDF.type, C) });
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) OntModel(org.apache.jena.ontology.OntModel) InfModel(org.apache.jena.rdf.model.InfModel) Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Property(org.apache.jena.rdf.model.Property)

Example 10 with StmtIterator

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

the class UnionModelAssembler method addSubModels.

private void addSubModels(Assembler a, Resource root, MultiUnion union, Mode mode) {
    for (StmtIterator it = root.listProperties(JA.subModel); it.hasNext(); ) {
        Resource resource = getResource(it.nextStatement());
        union.addGraph(a.openModel(resource, mode).getGraph());
    }
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) Resource(org.apache.jena.rdf.model.Resource)

Aggregations

StmtIterator (org.apache.jena.rdf.model.StmtIterator)15 Statement (org.apache.jena.rdf.model.Statement)8 Model (org.apache.jena.rdf.model.Model)7 Resource (org.apache.jena.rdf.model.Resource)6 Property (org.apache.jena.rdf.model.Property)3 OntModel (org.apache.jena.ontology.OntModel)2 InfModel (org.apache.jena.rdf.model.InfModel)2 ThreadInfo (java.lang.management.ThreadInfo)1 ThreadMXBean (java.lang.management.ThreadMXBean)1 ExecutorService (java.util.concurrent.ExecutorService)1 DownloadBean (mom.trd.opentheso.SelectedBeans.DownloadBean)1 Triple (org.apache.jena.graph.Triple)1 OntClass (org.apache.jena.ontology.OntClass)1 OntResource (org.apache.jena.ontology.OntResource)1 RDFNode (org.apache.jena.rdf.model.RDFNode)1 Reasoner (org.apache.jena.reasoner.Reasoner)1 TransitiveReasoner (org.apache.jena.reasoner.transitiveReasoner.TransitiveReasoner)1 Store (org.apache.jena.sdb.Store)1 JenaException (org.apache.jena.shared.JenaException)1 ExtendedIterator (org.apache.jena.util.iterator.ExtendedIterator)1