Search in sources :

Example 21 with Value

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

the class IndexedGraph method addToAllMaps.

protected void addToAllMaps(Statement statement) {
    Resource subject = statement.getSubject();
    URI predicate = statement.getPredicate();
    Value object = statement.getObject();
    addToMap(sMap, subject, statement);
    addToMap(pMap, predicate, statement);
    addToMap(oMap, object, statement);
    addToMap(spMap, new ListOfTwo<Value>(subject, predicate), statement);
    addToMap(soMap, new ListOfTwo<Value>(subject, object), statement);
    addToMap(poMap, new ListOfTwo<Value>(predicate, object), statement);
}
Also used : Resource(org.openrdf.model.Resource) Value(org.openrdf.model.Value) URI(org.openrdf.model.URI)

Example 22 with Value

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

the class OntologyInfo method resourcesFromStatement.

public static Set<Resource> resourcesFromStatement(Statement statement) {
    Resource subject = statement.getSubject();
    URI predicate = statement.getPredicate();
    Value object = statement.getObject();
    if (object instanceof Resource) {
        return new SetOfThree<Resource>(subject, predicate, (Resource) object);
    } else {
        return new SetOfTwo<Resource>(subject, predicate);
    }
}
Also used : SetOfTwo(org.sbpax.util.sets.SetOfTwo) SetOfThree(org.sbpax.util.sets.SetOfThree) Resource(org.openrdf.model.Resource) Value(org.openrdf.model.Value) URI(org.openrdf.model.URI)

Example 23 with Value

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

the class OntUtil method createDataRange.

public static BNode createDataRange(Graph graph, Value... values) {
    BNode unionNode = graph.getValueFactory().createBNode();
    graph.add(unionNode, RDF.TYPE, DATARANGE);
    Value listNode = createList(graph, values);
    graph.add(unionNode, OWL.ONEOF, listNode);
    return unionNode;
}
Also used : BNode(org.openrdf.model.BNode) Value(org.openrdf.model.Value)

Example 24 with Value

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

the class OntUtil method createList.

public static Value createList(Graph graph, int offset, Value... values) {
    if (offset < values.length) {
        BNode listNode = graph.getValueFactory().createBNode();
        graph.add(listNode, RDF.FIRST, values[offset]);
        Value restNode = createList(graph, offset + 1, values);
        graph.add(listNode, RDF.REST, restNode);
        return listNode;
    } else {
        return RDF.NIL;
    }
}
Also used : BNode(org.openrdf.model.BNode) Value(org.openrdf.model.Value)

Example 25 with Value

use of org.openrdf.model.Value 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)

Aggregations

Value (org.openrdf.model.Value)46 Statement (org.openrdf.model.Statement)22 URI (org.openrdf.model.URI)22 Resource (org.openrdf.model.Resource)17 HashSet (java.util.HashSet)11 BindingSet (org.openrdf.query.BindingSet)10 TupleQueryResult (org.openrdf.query.TupleQueryResult)8 BNode (org.openrdf.model.BNode)6 Literal (org.openrdf.model.Literal)6 ExpressionQueryResult (edu.mit.simile.backstage.model.data.ExpressionQueryResult)5 ScriptableArrayBuilder (edu.mit.simile.backstage.util.ScriptableArrayBuilder)5 HashMap (java.util.HashMap)5 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)5 DefaultScriptableObject (edu.mit.simile.backstage.util.DefaultScriptableObject)4 ArrayList (java.util.ArrayList)4 Graph (org.openrdf.model.Graph)4 SailException (org.openrdf.sail.SailException)4 Map (java.util.Map)3 Set (java.util.Set)3 SparqlFieldQuery (org.apache.stanbol.entityhub.query.sparql.SparqlFieldQuery)3