use of com.hp.hpl.jena.rdf.model.AnonId in project stanbol by apache.
the class RdfIndexingSource method listObjects.
/* ----------------------------------------------------------------------
* RDF Backend implementation
* ----------------------------------------------------------------------
*/
@Override
public Collection<Node> listObjects(Node subject, Node property) {
Collection<Node> nodes = new ArrayList<Node>();
if (bnodePrefix != null && subject.isURI() && subject.getURI().startsWith(bnodePrefix)) {
subject = NodeFactory.createAnon(new AnonId(subject.getURI().substring(bnodePrefix.length())));
}
ExtendedIterator<Triple> it = indexingDataset.getDefaultGraph().find(subject, property, null);
while (it.hasNext()) {
//STANBOL-765: we need also to transform bnodes to URIs for the
//RDFBackend implementation
Node object = it.next().getObject();
if (bnodePrefix != null && object.isBlank()) {
StringBuilder sb = new StringBuilder(bnodePrefix);
sb.append(object.getBlankNodeId().getLabelString());
object = NodeFactory.createURI(sb.toString());
}
nodes.add(object);
}
it.close();
return nodes;
}
use of com.hp.hpl.jena.rdf.model.AnonId in project stanbol by apache.
the class RdfIndexingSource method listSubjects.
@Override
public Collection<Node> listSubjects(Node property, Node object) {
Collection<Node> nodes = new ArrayList<Node>();
if (bnodePrefix != null && object.isURI() && object.getURI().startsWith(bnodePrefix)) {
object = NodeFactory.createAnon(new AnonId(object.getURI().substring(bnodePrefix.length())));
}
ExtendedIterator<Triple> it = indexingDataset.getDefaultGraph().find(null, property, object);
while (it.hasNext()) {
Node subject = it.next().getSubject();
//RDFBackend implementation
if (bnodePrefix != null && subject.isBlank()) {
StringBuilder sb = new StringBuilder(bnodePrefix);
sb.append(subject.getBlankNodeId().getLabelString());
subject = NodeFactory.createURI(sb.toString());
}
nodes.add(subject);
}
it.close();
return nodes;
}