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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations