Search in sources :

Example 1 with RDFValueSets

use of org.vcell.sybil.rdf.nodestore.RDFValueSets in project vcell by virtualcell.

the class RDFEvaluator method getProperties.

public <T, T2> RDFObjectSets<T2> getProperties(T subject, RDFObjectPool<T> pool, URI property, RDFObjectPool<T2> pool2) {
    RDFValueSets valueSets = getProperties(subject, pool, property);
    Set<T2> objects = new HashSet<T2>();
    Map<Resource, Set<Resource>> unsupported = new HashMap<Resource, Set<Resource>>();
    for (Resource objectResource : valueSets.getResources()) {
        Set<Resource> types = getProperties(objectResource, RDF.TYPE).getResources();
        try {
            T2 object2 = pool2.getOrCreateObject(objectResource, types);
            objects.add(object2);
        } catch (UnsupportedRDFTypeException e) {
            unsupported.put(objectResource, types);
        }
    }
    return new RDFObjectSets<T2>(valueSets, objects, unsupported);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) UnsupportedRDFTypeException(org.vcell.sybil.rdf.pool.UnsupportedRDFTypeException) RDFValueSets(org.vcell.sybil.rdf.nodestore.RDFValueSets) Resource(org.openrdf.model.Resource) RDFObjectSets(org.vcell.sybil.rdf.pool.RDFObjectSets) HashSet(java.util.HashSet)

Example 2 with RDFValueSets

use of org.vcell.sybil.rdf.nodestore.RDFValueSets in project vcell by virtualcell.

the class RDFEvaluator method getProperties.

public <T> RDFValueSets getProperties(T subject, RDFObjectPool<T> pool, URI property) {
    Set<Value> objects = new HashSet<Value>();
    Set<Resource> subjectResources = pool.getResources(subject);
    for (Graph graph : graphs) {
        for (Resource subjectResource : subjectResources) {
            Iterator<Statement> stmtIter = graph.match(subjectResource, property, null);
            while (stmtIter.hasNext()) {
                objects.add(stmtIter.next().getObject());
            }
        }
    }
    return new RDFValueSets(objects);
}
Also used : Graph(org.openrdf.model.Graph) Statement(org.openrdf.model.Statement) RDFValueSets(org.vcell.sybil.rdf.nodestore.RDFValueSets) Value(org.openrdf.model.Value) Resource(org.openrdf.model.Resource) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 Resource (org.openrdf.model.Resource)2 RDFValueSets (org.vcell.sybil.rdf.nodestore.RDFValueSets)2 HashMap (java.util.HashMap)1 Set (java.util.Set)1 Graph (org.openrdf.model.Graph)1 Statement (org.openrdf.model.Statement)1 Value (org.openrdf.model.Value)1 RDFObjectSets (org.vcell.sybil.rdf.pool.RDFObjectSets)1 UnsupportedRDFTypeException (org.vcell.sybil.rdf.pool.UnsupportedRDFTypeException)1