use of org.apache.atlas.catalog.projection.Relation in project incubator-atlas by apache.
the class ProjectionQueryExpression method asPipe.
@Override
public Pipe asPipe() {
//todo: encapsulate all of this path logic including path sep escaping and normalizing
final int sepIdx = getField().indexOf(QueryFactory.PATH_SEP_TOKEN);
final String edgeToken = getField().substring(0, sepIdx);
GremlinPipeline pipeline = new GremlinPipeline();
Relation relation = resourceDefinition.getRelations().get(fieldSegments[0]);
if (relation != null) {
pipeline = pipeline.outE();
pipeline.add(relation.asPipe()).inV();
} else {
if (resourceDefinition.getProjections().get(fieldSegments[0]) != null) {
return super.asPipe();
} else {
//todo: default Relation implementation
pipeline = pipeline.outE().has("label", Text.REGEX, String.format(".*\\.%s", edgeToken)).inV();
}
}
//todo: set resource definition from relation on underlying expression where appropriate
String childFieldName = getField().substring(sepIdx + QueryFactory.PATH_SEP_TOKEN.length());
underlyingExpression.setField(childFieldName);
Pipe childPipe;
if (childFieldName.contains(QueryFactory.PATH_SEP_TOKEN)) {
childPipe = new ProjectionQueryExpression(underlyingExpression, resourceDefinition).asPipe();
} else {
childPipe = underlyingExpression.asPipe();
}
pipeline.add(childPipe);
return negate ? new FilterFunctionPipe(new ExcludePipeFunction(pipeline)) : pipeline;
}
Aggregations