use of nl.knaw.huygens.timbuctoo.v5.graphql.defaultconfiguration.DirectionalStep in project timbuctoo by HuygensING.
the class SummaryPropDataRetriever method getDataQuad.
private Optional<CursorQuad> getDataQuad(List<DirectionalStep> path, String uri, Optional<Graph> graph, QuadStore quadStore) {
/*
* A collect of the data might look a bit nicer, but that will cause all the data to be loaded from the database.
* This way only the data needed is retrieved.
* See https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html#StreamOps for more info.
*/
Optional<CursorQuad> foundQuad;
DirectionalStep firstStep = path.get(0);
try (Stream<CursorQuad> quads = quadStore.getQuadsInGraph(uri, firstStep.getStep(), firstStep.getDirection(), "", graph)) {
foundQuad = quads.map(quad -> {
if (path.size() > 1) {
/*
* make sure paths are not further retrieved, when the object has a value type
* this could lead to false positives if the value of the property is a uri used as part of the path
*/
if (quad.getValuetype().isPresent()) {
return Optional.<CursorQuad>empty();
}
return getDataQuad(path.subList(1, path.size()), quad.getObject(), graph, quadStore);
} else {
return Optional.of(quad);
}
}).filter(Optional::isPresent).findFirst().map(Optional::get);
}
return foundQuad;
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.defaultconfiguration.DirectionalStep in project timbuctoo by HuygensING.
the class SummaryPropDataRetriever method getDataQuad.
private Optional<CursorQuad> getDataQuad(List<DirectionalStep> path, String uri, QuadStore quadStore) {
/*
* A collect of the data might look a bit nicer, but that will cause all the data to be loaded from the database.
* This way only the data needed is retrieved.
* See https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html#StreamOps for more info.
*/
Optional<CursorQuad> foundQuad;
DirectionalStep firstStep = path.get(0);
try (Stream<CursorQuad> quads = quadStore.getQuads(uri, firstStep.getStep(), firstStep.getDirection(), "")) {
foundQuad = quads.map(quad -> {
if (path.size() > 1) {
/*
* make sure paths are not further retrieved, when the object has a value type
* this could lead to false positives if the value of the property is a uri used as part of the path
*/
if (quad.getValuetype().isPresent()) {
return Optional.<CursorQuad>empty();
}
return getDataQuad(path.subList(1, path.size()), quad.getObject(), quadStore);
} else {
return Optional.of(quad);
}
}).filter(Optional::isPresent).findFirst().map(Optional::get);
}
return foundQuad;
}
Aggregations