Search in sources :

Example 26 with Statement

use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.

the class TreeModel method removeAll.

private void removeAll(TreeSet<Statement> owner, StatementTree chosen, Iterator<Statement> iter) {
    while (iter.hasNext()) {
        Statement last = iter.next();
        for (StatementTree tree : trees) {
            if (tree.owns(owner)) {
                tree.reindex();
                tree.remove(last);
            } else if (tree != chosen) {
                tree.remove(last);
            }
        }
        // remove from chosen
        iter.remove();
    }
}
Also used : Statement(org.eclipse.rdf4j.model.Statement)

Example 27 with Statement

use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.

the class SPARQLConnection method addWithoutCommit.

@Override
protected void addWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
    ValueFactory f = getValueFactory();
    Statement st = f.createStatement(subject, predicate, object);
    List<Statement> list = new ArrayList<Statement>(1);
    list.add(st);
    String sparqlCommand = createInsertDataCommand(list, contexts);
    sparqlTransaction.append(sparqlCommand);
    sparqlTransaction.append("; ");
}
Also used : Statement(org.eclipse.rdf4j.model.Statement) ArrayList(java.util.ArrayList) ValueFactory(org.eclipse.rdf4j.model.ValueFactory) SimpleValueFactory(org.eclipse.rdf4j.model.impl.SimpleValueFactory)

Example 28 with Statement

use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.

the class SPARQLConnection method removeWithoutCommit.

@Override
protected void removeWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
    String sparqlCommand = "";
    if (subject != null && predicate != null && object != null) {
        ValueFactory f = getValueFactory();
        Statement st = f.createStatement(subject, predicate, object);
        List<Statement> list = new ArrayList<Statement>(1);
        list.add(st);
        sparqlCommand = createDeleteDataCommand(list, contexts);
    } else {
        sparqlCommand = createDeletePatternCommand(subject, predicate, object, contexts);
    }
    sparqlTransaction.append(sparqlCommand);
    sparqlTransaction.append("; ");
}
Also used : Statement(org.eclipse.rdf4j.model.Statement) ArrayList(java.util.ArrayList) ValueFactory(org.eclipse.rdf4j.model.ValueFactory) SimpleValueFactory(org.eclipse.rdf4j.model.impl.SimpleValueFactory)

Example 29 with Statement

use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.

the class RDFXMLParserTest method testRDFXMLWhitespace.

@Test
public void testRDFXMLWhitespace() throws Exception {
    try (final InputStream in = this.getClass().getResourceAsStream("/org/eclipse/rdf4j/rio/rdfxml/rdfxml-whitespace-literal.rdf")) {
        parser.parse(in, "");
    }
    Statement stmt1 = sc.getStatements().iterator().next();
    assertEquals(1, sc.getStatements().size());
    assertEquals(RDFS.LABEL, stmt1.getPredicate());
    assertEquals(vf.createLiteral("  Literal with whitespace  "), stmt1.getObject());
}
Also used : InputStream(java.io.InputStream) Statement(org.eclipse.rdf4j.model.Statement) Test(org.junit.Test)

Example 30 with Statement

use of org.eclipse.rdf4j.model.Statement in project rdf4j by eclipse.

the class JSONLDInternalTripleCallback method triple.

private void triple(String s, String p, String value, String datatype, String language, String graph) {
    if (s == null || p == null || value == null) {
        // TODO: i don't know what to do here!!!!
        return;
    }
    final Resource subject = createResource(s);
    final IRI predicate = vf.createIRI(p);
    final IRI datatypeURI = datatype == null ? null : vf.createIRI(datatype);
    Value object;
    try {
        object = RDFParserHelper.createLiteral(value, language, datatypeURI, getParserConfig(), getParserErrorListener(), getValueFactory());
    } catch (final RDFParseException e) {
        throw new RuntimeException(e);
    }
    Statement result;
    if (graph == null) {
        result = vf.createStatement(subject, predicate, object);
    } else {
        result = vf.createStatement(subject, predicate, object, createResource(graph));
    }
    if (handler != null) {
        try {
            handler.handleStatement(result);
        } catch (final RDFHandlerException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : IRI(org.eclipse.rdf4j.model.IRI) RDFHandlerException(org.eclipse.rdf4j.rio.RDFHandlerException) Statement(org.eclipse.rdf4j.model.Statement) Resource(org.eclipse.rdf4j.model.Resource) Value(org.eclipse.rdf4j.model.Value) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException)

Aggregations

Statement (org.eclipse.rdf4j.model.Statement)74 IRI (org.eclipse.rdf4j.model.IRI)17 Test (org.junit.Test)17 Model (org.eclipse.rdf4j.model.Model)16 Literal (org.eclipse.rdf4j.model.Literal)15 Resource (org.eclipse.rdf4j.model.Resource)15 Value (org.eclipse.rdf4j.model.Value)13 RDFWriter (org.eclipse.rdf4j.rio.RDFWriter)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 ArrayList (java.util.ArrayList)10 LinkedHashModel (org.eclipse.rdf4j.model.impl.LinkedHashModel)8 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)8 RDFParseException (org.eclipse.rdf4j.rio.RDFParseException)8 StringWriter (java.io.StringWriter)7 BNode (org.eclipse.rdf4j.model.BNode)6 ValueFactory (org.eclipse.rdf4j.model.ValueFactory)6 SimpleValueFactory (org.eclipse.rdf4j.model.impl.SimpleValueFactory)6 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)6 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)6 IOException (java.io.IOException)5