/** * Check if the element has a property with provided key. * * @param key the property key to check * @return the extended Pipeline */ public GremlinPipeline<S, ? extends Element> has(final String key) { return this.has(key, Tokens.T.neq, null); }
protected Pipe getQueryPipe() { return new GremlinPipeline().has(Constants.ENTITY_TEXT_PROPERTY_KEY). hasNot(Constants.ENTITY_TYPE_PROPERTY_KEY, "Taxonomy"); } }
/** * Add an IdFilterPipe, LabelFilterPipe, or PropertyFilterPipe to the end of the Pipeline. * If the incoming element has the provided key/value as check with .equals(), then let the element pass. * If the key is id or label, then use respect id or label filtering. * * @param key the property key to check * @param value the object to filter on (in an OR manner) * @return the extended Pipeline */ public GremlinPipeline<S, ? extends Element> has(final String key, final Object value) { return this.has(key, Tokens.T.eq, value); }
@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(); }
/** * Check if the element does not have a property with provided key. * * @param key the property key to check * @return the extended Pipeline */ public GremlinPipeline<S, ? extends Element> hasNot(final String key) { return this.has(key, Tokens.T.eq, null); }
has(PropertyName.TYPE, VertexType.REPOSITORY). hasNot(PropertyName.FULLNAME, "/").dedup(). property(PropertyName.FULLNAME).
/** * Add an IdFilterPipe, LabelFilterPipe, or PropertyFilterPipe to the end of the Pipeline. * If the incoming element has the provided key/value as check with .equals(), then filter the element. * If the key is id or label, then use respect id or label filtering. * * @param key the property key to check * @param value the objects to filter on (in an OR manner) * @return the extended Pipeline */ public GremlinPipeline<S, ? extends Element> hasNot(final String key, final Object value) { return this.has(key, Tokens.T.neq, value); }
@Override protected Pipe getQueryPipe() { return new GremlinPipeline().has("__typeName", "Taxonomy"); } }
/** * Add an IdFilterPipe, LabelFilterPipe, or PropertyFilterPipe to the end of the Pipeline. * If the incoming element has the provided key/value as check with .equals(), then let the element pass. * If the key is id or label, then use respect id or label filtering. * * @param key the property key to check * @param compareToken the comparison to use * @param value the object to filter on * @return the extended Pipeline */ public GremlinPipeline<S, ? extends Element> has(final String key, final Tokens.T compareToken, final Object value) { return this.has(key, Tokens.mapPredicate(compareToken), value); }
/** * Add a GraphQueryPipe to the end of the Pipeline. * If optimizations are enabled, then the the next steps can fold into a GraphQueryPipe compilation. * * @param key they key that all the emitted vertices should be checked on * @param value the value that all the emitted vertices should have for the key * @return the extended Pipeline */ public GremlinPipeline<S, Vertex> V(final String key, final Object value) { return this.add(new GraphQueryPipe(Vertex.class)).has(key, value); }
/** * Add a GraphQueryPipe to the end of the Pipeline. * If optimizations are enabled, then the the next steps can fold into a GraphQueryPipe compilation. * * @param key they key that all the emitted edges should be checked on * @param value the value that all the emitted edges should have for the key * @return the extended Pipeline */ public GremlinPipeline<S, Edge> E(final String key, final Object value) { return this.add(new GraphQueryPipe(Edge.class)).has(key, value); }
@Override protected Pipe getQueryPipe() { GremlinPipeline p; if (termPath.getTaxonomyName().equals("*")) { p = new GremlinPipeline().has("Taxonomy.name").out(); } else { p = new GremlinPipeline().has("Taxonomy.name", termPath.getTaxonomyName()).out(). has(Constants.ENTITY_TYPE_PROPERTY_KEY, Text.PREFIX, termPath.getFullyQualifiedName()); } return p; } }
@Override public void query(GraphRewrite event, GremlinPipeline<Vertex, Vertex> pipeline) { Predicate regexPredicate = new Predicate() { @Override public boolean evaluate(Object first, Object second) { return ((String) first).matches((String) second); } }; pipeline.as("result") .out(FileReferenceModel.FILE_MODEL) .out(JavaSourceFileModel.JAVA_CLASS_MODEL) .has(JavaClassModel.QUALIFIED_NAME, regexPredicate, compiledTypeFilterPattern.pattern()) .back("result"); } }
public boolean isMavenConfiguration(XmlFileModel resource) { return (new GremlinPipeline<Vertex, Vertex>(resource.asVertex())).in("xmlFacet").as("facet") .has(WindupVertexFrame.TYPE_PROP, this.getTypeValueForSearch()).back("facet") .iterator().hasNext(); }
public MavenProjectModel getMavenConfigurationFromResource(XmlFileModel resource) { @SuppressWarnings("unchecked") Iterator<Vertex> v = (Iterator<Vertex>) (new GremlinPipeline<Vertex, Vertex>(resource.asVertex())) .in("xmlFacet").as("facet") .has(WindupVertexFrame.TYPE_PROP, this.getTypeValueForSearch()).back("facet") .iterator(); if (v.hasNext()) { return getGraphContext().getFramed().frame(v.next(), this.getType()); } return null; }
@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; }
@Override public void query(GraphRewrite event, GremlinPipeline<Vertex, Vertex> pipeline) { pipeline.has(DoctypeMetaModel.PROPERTY_PUBLIC_ID, Text.REGEX, hibernateRegex); FramedGraphQuery systemIDQuery = event.getGraphContext().getQuery().type(DoctypeMetaModel.class) .has(DoctypeMetaModel.PROPERTY_SYSTEM_ID, Text.REGEX, hibernateRegex); GremlinPipeline<Vertex, Vertex> systemIdPipeline = new GremlinPipeline<>(systemIDQuery.vertices()); pipeline.add(systemIdPipeline); pipeline.dedup(); } };
userList = pipe.start(repo).out(EdgeType.PULLREQUEST). out(EdgeType.PULLREQUESTDISCUSSION).in(). has(PropertyName.TYPE, VertexType.USER).dedup().toList(); log.info("Discussion users: {}", userList.size()); users.addAll(userList);
@Override public void query(GraphRewrite event, GremlinPipeline<Vertex, Vertex> pipeline) { pipeline.has(DoctypeMetaModel.PROPERTY_PUBLIC_ID, Text.REGEX, hibernateRegex); FramedGraphQuery systemIDQuery = event.getGraphContext().getQuery().type(DoctypeMetaModel.class) .has(DoctypeMetaModel.PROPERTY_SYSTEM_ID, Text.REGEX, hibernateRegex); GremlinPipeline<Vertex, Vertex> systemIdPipeline = new GremlinPipeline<>(systemIDQuery.vertices()); pipeline.add(systemIdPipeline); pipeline.dedup(); } };