/** * Add an OutEdgesPipe to the end of the Pipeline. * Emit the outgoing edges for the incoming vertex. * * @param labels the edge labels to traverse * @return the extended Pipeline */ public GremlinPipeline<S, Edge> outE(final String... labels) { return this.outE(Integer.MAX_VALUE, labels); }
@Override protected Pipe getQueryPipe() { GremlinPipeline p; if (guid.equals("*")) { p = new GremlinPipeline().has(Constants.ENTITY_TEXT_PROPERTY_KEY). hasNot(Constants.ENTITY_TYPE_PROPERTY_KEY, "Taxonomy").outE(); } else { p = new GremlinPipeline().has(Constants.GUID_PROPERTY_KEY, guid).outE(); } //todo: this is basically the same pipeline used in TagRelation.asPipe() p.add(new FilterFunctionPipe<>(new PipeFunction<Edge, Boolean>() { @Override public Boolean compute(Edge edge) { String type = edge.getVertex(Direction.OUT).getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY); VertexWrapper v = new TermVertexWrapper(edge.getVertex(Direction.IN)); return edge.getLabel().startsWith(type) && v.getPropertyKeys().contains("available_as_tag"); } })); return p.inV(); }
@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; }