Search in sources :

Example 31 with Statement

use of org.openrdf.model.Statement in project vcell by virtualcell.

the class IndexedGraph method retainAll.

public boolean retainAll(Collection<?> collection) {
    boolean hasChanged = false;
    Iterator<Statement> iterator = statements.iterator();
    while (iterator.hasNext()) {
        Statement statement = iterator.next();
        if (!collection.contains(statement)) {
            iterator.remove();
            removeFromAllMaps(statement);
            hasChanged = true;
        }
    }
    return hasChanged;
}
Also used : Statement(org.openrdf.model.Statement)

Example 32 with Statement

use of org.openrdf.model.Statement in project vcell by virtualcell.

the class SesameRioUtil method writeRDFToRDFWriter.

private static void writeRDFToRDFWriter(RDFWriter rdfWriter, Graph graph, Map<String, String> nsMap) throws RDFHandlerException {
    rdfWriter.startRDF();
    for (Map.Entry<String, String> entry : nsMap.entrySet()) {
        rdfWriter.handleNamespace(entry.getKey(), entry.getValue());
    }
    for (Statement statement : graph) {
        rdfWriter.handleStatement(statement);
    }
    rdfWriter.endRDF();
}
Also used : Statement(org.openrdf.model.Statement) Map(java.util.Map)

Example 33 with Statement

use of org.openrdf.model.Statement in project vcell by virtualcell.

the class VCMetaDataMiriamManager method removeStoredCrossReferencedLink.

public void removeStoredCrossReferencedLink(MiriamResource miriamResource, URL url) {
    ValueFactory valueFactory = vcMetaData.getRdfData().getValueFactory();
    Resource resource = valueFactory.createURI(miriamResource.getMiriamURN());
    Iterator<Statement> iter = vcMetaData.getRdfData().match(resource, MIRIAM.BioProperties.isDescribedBy, valueFactory.createLiteral(url.toString()));
    while (iter.hasNext()) {
        iter.next();
        iter.remove();
    }
}
Also used : Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource) ValueFactory(org.openrdf.model.ValueFactory)

Example 34 with Statement

use of org.openrdf.model.Statement in project blueprints by tinkerpop.

the class SailGraph method addEdge.

public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) {
    if (label == null)
        throw ExceptionFactory.edgeLabelCanNotBeNull();
    Value outVertexValue = ((SailVertex) outVertex).getRawVertex();
    Value inVertexValue = ((SailVertex) inVertex).getRawVertex();
    if (!(outVertexValue instanceof Resource)) {
        throw new IllegalArgumentException(outVertex.toString() + " is not a legal URI or blank node");
    }
    try {
        URI labelURI = new URIImpl(this.expandPrefix(label));
        Statement statement = new StatementImpl((Resource) outVertexValue, labelURI, inVertexValue);
        SailHelper.addStatement(statement, this.sailConnection.get());
        return new SailEdge(statement, this);
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : Statement(org.openrdf.model.Statement) StatementImpl(org.openrdf.model.impl.StatementImpl) Value(org.openrdf.model.Value) Resource(org.openrdf.model.Resource) URIImpl(org.openrdf.model.impl.URIImpl) URI(org.openrdf.model.URI) SailException(org.openrdf.sail.SailException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) RDFHandlerException(org.openrdf.rio.RDFHandlerException)

Example 35 with Statement

use of org.openrdf.model.Statement in project blueprints by tinkerpop.

the class SailVertex method updateLiteral.

private void updateLiteral(final Literal oldLiteral, final Literal newLiteral) {
    try {
        final Set<Statement> statements = new HashSet<Statement>();
        final CloseableIteration<? extends Statement, SailException> results = this.graph.getSailConnection().get().getStatements(null, null, oldLiteral, false);
        while (results.hasNext()) {
            statements.add(results.next());
        }
        results.close();
        this.graph.getSailConnection().get().removeStatements(null, null, oldLiteral);
        for (Statement statement : statements) {
            SailHelper.addStatement(statement.getSubject(), statement.getPredicate(), newLiteral, statement.getContext(), this.graph.getSailConnection().get());
        }
    } catch (SailException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : Statement(org.openrdf.model.Statement) SailException(org.openrdf.sail.SailException) HashSet(java.util.HashSet)

Aggregations

Statement (org.openrdf.model.Statement)67 Resource (org.openrdf.model.Resource)22 Value (org.openrdf.model.Value)22 URI (org.openrdf.model.URI)21 HashSet (java.util.HashSet)16 SailException (org.openrdf.sail.SailException)10 Collection (java.util.Collection)9 Literal (org.openrdf.model.Literal)9 Graph (org.openrdf.model.Graph)7 Edge (com.tinkerpop.blueprints.Edge)6 Test (org.junit.Test)6 Vertex (com.tinkerpop.blueprints.Vertex)5 HashMap (java.util.HashMap)5 Map (java.util.Map)4 PrintWriter (java.io.PrintWriter)3 Set (java.util.Set)3 BNode (org.openrdf.model.BNode)3 ValueFactory (org.openrdf.model.ValueFactory)3 RDFHandlerException (org.openrdf.rio.RDFHandlerException)3 RdfXmlSerializer (org.qi4j.library.rdf.serializer.RdfXmlSerializer)3