Search in sources :

Example 16 with Resource

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

Example 17 with Resource

use of org.openrdf.model.Resource 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 18 with Resource

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

the class RDFEvaluator method createAllObjectsForPool.

public <T> Set<T> createAllObjectsForPool(RDFObjectPool<T> pool) {
    Set<T> objects = new HashSet<T>();
    Set<Resource> supportedTypes = pool.getSupportedTypes();
    for (Graph graph : graphs) {
        for (Resource type : supportedTypes) {
            Iterator<Statement> stmtIter = graph.match(null, RDF.TYPE, type);
            while (stmtIter.hasNext()) {
                Statement statement = stmtIter.next();
                try {
                    objects.add(pool.getOrCreateObject(statement.getSubject(), Collections.singleton(type)));
                } catch (UnsupportedRDFTypeException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return objects;
}
Also used : Graph(org.openrdf.model.Graph) Statement(org.openrdf.model.Statement) UnsupportedRDFTypeException(org.vcell.sybil.rdf.pool.UnsupportedRDFTypeException) Resource(org.openrdf.model.Resource) HashSet(java.util.HashSet)

Example 19 with Resource

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

the class MIRIAMizer method newRefGroup.

public RefGroup newRefGroup(Graph graph, Resource resource, MIRIAMQualifier qualifier, MIRIAMRef ref) {
    Resource bag = graph.getValueFactory().createBNode();
    graph.add(bag, RDF.TYPE, RDF.BAG);
    graph.add(resource, qualifier.getProperty(), bag);
    RefGroup group = new RefGroup(bag);
    group.add(graph, ref);
    return group;
}
Also used : Resource(org.openrdf.model.Resource)

Example 20 with Resource

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

the class MIRIAMizer method newRefGroup.

public RefGroup newRefGroup(Graph graph, Resource resource, MIRIAMQualifier qualifier, Set<MIRIAMRef> refs) {
    Resource bag = graph.getValueFactory().createBNode();
    graph.add(bag, RDF.TYPE, RDF.BAG);
    graph.add(resource, qualifier.getProperty(), bag);
    RefGroup group = new RefGroup(bag);
    for (MIRIAMRef ref : refs) {
        group.add(graph, ref);
    }
    return group;
}
Also used : Resource(org.openrdf.model.Resource)

Aggregations

Resource (org.openrdf.model.Resource)60 Statement (org.openrdf.model.Statement)22 URI (org.openrdf.model.URI)20 Value (org.openrdf.model.Value)17 HashSet (java.util.HashSet)14 Graph (org.openrdf.model.Graph)7 Literal (org.openrdf.model.Literal)6 SailConnection (org.openrdf.sail.SailConnection)5 SailException (org.openrdf.sail.SailException)5 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 NotifyingSailConnection (org.openrdf.sail.NotifyingSailConnection)4 Map (java.util.Map)3 Set (java.util.Set)3 Element (org.jdom.Element)3 HashGraph (org.sbpax.impl.HashGraph)3 VCID (cbit.vcell.biomodel.meta.VCID)2 Registry (cbit.vcell.biomodel.meta.registry.Registry)2 Edge (com.tinkerpop.blueprints.Edge)2