Update tinkerpop to 3.2.4
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / query / builder / QueryBuilder.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright © 2024 DEUTSCHE TELEKOM AG.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *    http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.aai.query.builder;
24
25 import java.io.UnsupportedEncodingException;
26 import java.net.URI;
27 import java.util.Iterator;
28 import java.util.List;
29 import java.util.Map;
30
31 import javax.ws.rs.core.MultivaluedMap;
32
33 import org.apache.tinkerpop.gremlin.process.traversal.Path;
34 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
35 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
36 import org.apache.tinkerpop.gremlin.structure.Edge;
37 import org.apache.tinkerpop.gremlin.structure.Vertex;
38 import org.onap.aai.config.SpringContextAware;
39 import org.onap.aai.db.props.AAIProperties;
40 import org.onap.aai.edges.EdgeIngestor;
41 import org.onap.aai.edges.enums.AAIDirection;
42 import org.onap.aai.edges.enums.EdgeProperty;
43 import org.onap.aai.edges.enums.EdgeType;
44 import org.onap.aai.exceptions.AAIException;
45 import org.onap.aai.introspection.Introspector;
46 import org.onap.aai.introspection.Loader;
47 import org.onap.aai.parsers.query.QueryParser;
48 import org.onap.aai.parsers.query.QueryParserStrategy;
49 import org.springframework.context.ApplicationContext;
50
51 /**
52  * The Class QueryBuilder.
53  */
54 public abstract class QueryBuilder<E> implements Iterator<E> {
55
56     protected final GraphTraversalSource source;
57     protected QueryParserStrategy factory = null;
58     protected Loader loader = null;
59     protected EdgeIngestor edgeRules;
60     protected boolean optimize = false;
61     protected Vertex start = null;
62
63     protected int parentStepIndex = 0;
64     protected int containerStepIndex = 0;
65     protected int stepIndex = 0;
66
67     /**
68      * Instantiates a new query builder.
69      *
70      * @param loader the loader
71      */
72     public QueryBuilder(Loader loader, GraphTraversalSource source) {
73         this.loader = loader;
74         this.source = source;
75         initEdgeIngestor();
76     }
77
78     /**
79      * Instantiates a new query builder.
80      *
81      * @param loader the loader
82      * @param start the start
83      */
84     public QueryBuilder(Loader loader, GraphTraversalSource source, Vertex start) {
85         this.loader = loader;
86         this.start = start;
87         this.source = source;
88         initEdgeIngestor();
89     }
90
91     public void changeLoader(Loader loader) {
92         this.loader = loader;
93     }
94
95     /**
96      * Creates a new {@link QueryBuilder} that contains the traversal up to the provided index.
97      * @param index
98      * @return
99      */
100     protected abstract QueryBuilder<E> cloneQueryAtStep(int index);
101
102     /**
103      * Gets the vertices by indexed property.
104      *
105      * @param key the key
106      * @param value the value
107      * @return the vertices by indexed property
108      */
109     public QueryBuilder<Vertex> getVerticesByIndexedProperty(String key, Object value) {
110         return this.getVerticesByProperty(key, value);
111     }
112
113     /**
114      * Gets the vertices by property.
115      *
116      * @param key the key
117      * @param value the value
118      * @return the vertices by property
119      */
120     public abstract QueryBuilder<Vertex> getVerticesByProperty(String key, Object value);
121
122     /**
123      * Gets the edges by property.
124      *
125      * @param key the key
126      * @param value the value
127      * @return the vertices by property
128      */
129     public QueryBuilder<Edge> getEdgesByProperty(String key, Object value) {
130         return this.has(key, value.toString());
131     }
132
133     /**
134      * filters by all the values for this property
135      *
136      * @param key
137      * @param values
138      * @return vertices that match these values
139      */
140     public QueryBuilder<Vertex> getVerticesByIndexedProperty(String key, List<?> values) {
141         return this.getVerticesByProperty(key, values);
142     }
143
144     /**
145      * filters by all the values for this property
146      *
147      * @param key
148      * @param values
149      * @return vertices that match these values
150      */
151     public abstract QueryBuilder<Vertex> getVerticesByProperty(String key, List<?> values);
152
153     /**
154      * filters by all the values for this property
155      *
156      * @param key
157      * @param value in comma delimited string format
158      * @return vertices that match these values
159      */
160     public abstract QueryBuilder<Vertex> getVerticesByCommaSeperatedValue(String key, String value);
161
162     /**
163      * Gets the vertices that have this property key.
164      *
165      * @param key the key
166      * @return the vertices by property
167      */
168     public abstract QueryBuilder<Vertex> getVerticesByProperty(String key);
169
170     /**
171      * Gets the vertices that do not have this property key.
172      *
173      * @param key the key
174      * @return the vertices by property
175      */
176     public abstract QueryBuilder<Vertex> getVerticesExcludeByProperty(String key);
177
178     /**
179      * filters by elements that start with the value for this property
180      *
181      * @param key
182      * @param value
183      * @return vertices that match these values
184      */
185     public abstract QueryBuilder<Vertex> getVerticesStartsWithProperty(String key, Object value);
186
187     /**
188      * Gets the vertices that are excluded by property.
189      *
190      * @param key the key
191      * @param value the value
192      * @return the vertices by property
193      */
194     public abstract QueryBuilder<Vertex> getVerticesExcludeByProperty(String key, Object value);
195
196     /**
197      * filters by all the values for this property and excludes the vertices
198      *
199      * @param key
200      * @param values
201      * @return vertices that match these values
202      */
203     public QueryBuilder<Vertex> getVerticesExcludeByIndexedProperty(String key, List<?> values) {
204         return this.getVerticesExcludeByProperty(key, values);
205     }
206
207     /**
208      * filters by all the values for this property and excludes the vertices
209      *
210      * @param key
211      * @param values
212      * @return vertices that match these values
213      */
214     public abstract QueryBuilder<Vertex> getVerticesExcludeByProperty(String key, List<?> values);
215
216     /**
217      * filters by all the values greater than for this property
218      *
219      * @param key
220      * @param value
221      * @return vertices that match these values
222      */
223     public abstract QueryBuilder<Vertex> getVerticesGreaterThanProperty(String key, Object value);
224
225     /**
226      * filters by all the values less than for this property
227      *
228      * @param key
229      * @param value
230      * @return vertices that match these values
231      */
232
233     public abstract QueryBuilder<Vertex> getVerticesLessThanProperty(String key, Object value);
234
235     /**
236      * Gets the child vertices from parent.
237      *
238      * @param parentKey the parent key
239      * @param parentValue the parent value
240      * @param childType the child type
241      * @return the child vertices from parent
242      */
243     public abstract QueryBuilder<Vertex> getChildVerticesFromParent(String parentKey, String parentValue,
244             String childType);
245
246     /**
247      * Gets the typed vertices by map.
248      *
249      * @param type the type
250      * @param map the map
251      * @return the typed vertices by map
252      */
253     public abstract QueryBuilder<Vertex> getTypedVerticesByMap(String type, Map<String, String> map);
254
255     /**
256      * Creates the DB query.
257      *
258      * @param obj the obj
259      * @return the query builder
260      */
261     public QueryBuilder<Vertex> createDBQuery(Introspector obj) {
262         this.createKeyQuery(obj);
263         this.createContainerQuery(obj);
264         return (QueryBuilder<Vertex>) this;
265     }
266
267     /**
268      * Creates the key query.
269      *
270      * @param obj the obj
271      * @return the query builder
272      */
273     public abstract QueryBuilder<Vertex> createKeyQuery(Introspector obj);
274
275     /**
276      * Creates the container query.<br>
277      * A container query is a query that will return a collection of objects:
278      * <pre>
279      * /cloud-infrastructure/complexes/complex/key1
280      *           ↑              ↑        ↑
281      *       namespace      container  object
282      *
283      * </pre>
284      * @param obj the Introspector into the db schema
285      * @return the query builder
286      */
287     public abstract QueryBuilder<Vertex> createContainerQuery(Introspector obj);
288
289     /**
290      * Creates the edge traversal.
291      *
292      * @param parent the parent
293      * @param child the child
294      * @return the query builder
295      */
296     public abstract QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, Introspector parent, Introspector child)
297             throws AAIException;
298
299     public abstract QueryBuilder<Vertex> getVerticesByBooleanProperty(String key, Object value);
300
301     public QueryBuilder<Vertex> getVerticesByBooleanProperty(String key, MissingOptionalParameter value) {
302         return (QueryBuilder<Vertex>) this;
303     }
304
305     /**
306      * Creates the private edge traversal.
307      *
308      * @param parent the parent
309      * @param child the child
310      * @return the query builder
311      */
312     public abstract QueryBuilder<Vertex> createPrivateEdgeTraversal(EdgeType type, Introspector parent,
313             Introspector child) throws AAIException;
314
315     /**
316      * Creates the edge traversal.
317      *
318      * @param parent the parent
319      * @param child the child
320      * @return the query builder
321      */
322     public QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, Vertex parent, Introspector child)
323             throws AAIException {
324         String nodeType = parent.<String>property(AAIProperties.NODE_TYPE).orElse(null);
325         this.createEdgeTraversal(type, nodeType, child.getDbName());
326         return (QueryBuilder<Vertex>) this;
327     }
328
329     /**
330      *
331      * @param type
332      * @param outNodeType
333      * @param inNodeType
334      * @return
335      * @throws AAIException
336      */
337     public QueryBuilder<Vertex> createEdgeTraversal(EdgeType type, String outNodeType, String inNodeType)
338             throws AAIException {
339         Introspector out = loader.introspectorFromName(outNodeType);
340         Introspector in = loader.introspectorFromName(inNodeType);
341
342         return createEdgeTraversal(type, out, in);
343     }
344
345     /**
346      *
347      * @param edgeType
348      * @param outNodeType
349      * @param inNodeType
350      * @return
351      * @throws AAIException
352      */
353     public QueryBuilder<Vertex> createEdgeTraversal(String edgeType, String outNodeType, String inNodeType)
354             throws AAIException {
355         /*
356          * When the optional parameter edgetype is sent it is a string that needs to be converted to Enum
357          */
358         EdgeType type = EdgeType.valueOf(edgeType);
359         Introspector out = loader.introspectorFromName(outNodeType);
360         Introspector in = loader.introspectorFromName(inNodeType);
361
362         return createEdgeTraversal(type, out, in);
363     }
364
365     /**
366      *
367      * @param edgeType
368      * @param outNodeType
369      * @param inNodeType
370      * @return
371      * @throws AAIException
372      */
373     public QueryBuilder<Vertex> createEdgeTraversal(MissingOptionalParameter edgeType, String outNodeType,
374             String inNodeType) throws AAIException {
375         /*
376          * When no optional parameter edgetype is sent get all edges between the 2 nodetypes
377          */
378         return this.createEdgeTraversal(outNodeType, inNodeType);
379     }
380
381     /**
382      *
383      * @param edgeType
384      * @param outNodeType
385      * @param inNodeType
386      * @return
387      * @throws AAIException
388      */
389     public QueryBuilder<Vertex> createEdgeTraversalWithLabels(MissingOptionalParameter edgeType, String outNodeType,
390             String inNodeType, List<String> labels) throws AAIException {
391         /*
392          * When no optional parameter edgetype is sent get all edges between the 2 nodetypes
393          */
394         return this.createEdgeTraversalWithLabels(outNodeType, inNodeType, labels);
395     }
396
397     public QueryBuilder<Vertex> createEdgeTraversal(String outNodeType, String inNodeType) throws AAIException {
398
399         Introspector out = loader.introspectorFromName(outNodeType);
400         Introspector in = loader.introspectorFromName(inNodeType);
401
402         QueryBuilder<Vertex> cousinBuilder = null;
403         QueryBuilder<Vertex> treeBuilder = null;
404         QueryBuilder<Vertex> queryBuilder = null;
405
406         try {
407             cousinBuilder = this.newInstance().createEdgeTraversal(EdgeType.COUSIN, out, in);
408         } catch (AAIException e) {
409         }
410
411         if (cousinBuilder != null) {
412             try {
413                 treeBuilder = this.newInstance().createEdgeTraversal(EdgeType.TREE, out, in);
414             } catch (AAIException e) {
415             }
416             if (treeBuilder != null) {
417                 queryBuilder = this.union(new QueryBuilder[] {cousinBuilder, treeBuilder});
418             } else {
419                 queryBuilder = this.union(new QueryBuilder[] {cousinBuilder});
420             }
421         } else {
422             treeBuilder = this.newInstance().createEdgeTraversal(EdgeType.TREE, out, in);
423             queryBuilder = this.union(new QueryBuilder[] {treeBuilder});
424         }
425
426         return queryBuilder;
427     }
428
429     public QueryBuilder<Vertex> createEdgeTraversalWithLabels(String outNodeType, String inNodeType,
430             List<String> labels) throws AAIException {
431
432         Introspector out = loader.introspectorFromName(outNodeType);
433         Introspector in = loader.introspectorFromName(inNodeType);
434
435         QueryBuilder<Vertex> cousinBuilder = null;
436         QueryBuilder<Vertex> treeBuilder = null;
437         QueryBuilder<Vertex> queryBuilder = null;
438
439         try {
440             cousinBuilder = this.newInstance().createEdgeTraversalWithLabels(EdgeType.COUSIN, out, in, labels);
441         } catch (AAIException e) {
442         }
443
444         if (cousinBuilder != null) {
445             try {
446                 treeBuilder = this.newInstance().createEdgeTraversalWithLabels(EdgeType.TREE, out, in, labels);
447             } catch (AAIException e) {
448             }
449             if (treeBuilder != null) {
450                 queryBuilder = this.union(new QueryBuilder[] {cousinBuilder, treeBuilder});
451             } else {
452                 queryBuilder = this.union(new QueryBuilder[] {cousinBuilder});
453             }
454         } else {
455             treeBuilder = this.newInstance().createEdgeTraversalWithLabels(EdgeType.TREE, out, in, labels);
456             queryBuilder = this.union(new QueryBuilder[] {treeBuilder});
457         }
458
459         return queryBuilder;
460     }
461
462     public QueryBuilder<Vertex> createPrivateEdgeTraversal(EdgeType type, String outNodeType, String inNodeType)
463             throws AAIException {
464         Introspector out = loader.introspectorFromName(outNodeType);
465         Introspector in = loader.introspectorFromName(inNodeType);
466         return createPrivateEdgeTraversal(type, out, in);
467     }
468
469     /**
470      *
471      * @param type
472      * @param outNodeType
473      * @param inNodeType
474      * @param labels
475      * @return
476      * @throws AAIException
477      */
478     public QueryBuilder<Vertex> createEdgeTraversalWithLabels(EdgeType type, String outNodeType, String inNodeType,
479             List<String> labels) throws AAIException {
480         Introspector out = loader.introspectorFromName(outNodeType);
481         Introspector in = loader.introspectorFromName(inNodeType);
482
483         return createEdgeTraversalWithLabels(type, out, in, labels);
484     }
485
486     /**
487      *
488      * @param type
489      * @param out
490      * @param in
491      * @param labels
492      * @return
493      */
494     public abstract QueryBuilder<Vertex> createEdgeTraversalWithLabels(EdgeType type, Introspector out, Introspector in,
495             List<String> labels) throws AAIException;
496
497     /**
498      * This method and it's overloaded counterpart are conditional statements.
499      * This method creates an edge traversal step if an optional property is present
500      * This is necessary in cases such as "if the Optional Property 1 is sent,
501      * find all Nodes of type A with edges to Nodes of type B with property 1,
502      * otherwise, simply find all nodes of type A".
503      * 
504      * @param type
505      * @param outNodeType
506      * @param inNodeType
507      * @param value
508      * @return
509      * @throws AAIException
510      */
511     public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType,
512             String inNodeType, Object value) throws AAIException {
513         return this.createEdgeTraversal(type, outNodeType, inNodeType);
514     }
515
516     /**
517      * This method and it's overloaded counterpart are conditional statements.
518      * This method skips an edge traversal step if there is an optional property missing.
519      * This is necessary in cases such as "if the Optional Property 1 is sent,
520      * find all Nodes of type A with edges to Nodes of type B with property 1,
521      * otherwise, simply find all nodes of type A".
522      * 
523      * @param type
524      * @param outNodeType
525      * @param inNodeType
526      * @param value
527      * @return
528      * @throws AAIException
529      */
530     public QueryBuilder<Vertex> createEdgeTraversalIfParameterIsPresent(EdgeType type, String outNodeType,
531             String inNodeType, MissingOptionalParameter value) throws AAIException {
532         return (QueryBuilder<Vertex>) this;
533     }
534
535     /**
536      *
537      * @param type
538      * @param outNodeType
539      * @param inNodeType
540      * @return
541      * @throws AAIException
542      */
543     public QueryBuilder<Edge> getEdgesBetween(EdgeType type, String outNodeType, String inNodeType)
544             throws AAIException {
545         this.getEdgesBetweenWithLabels(type, outNodeType, inNodeType, null);
546
547         return (QueryBuilder<Edge>) this;
548
549     }
550
551     /**
552      *
553      * @param type
554      * @param outNodeType
555      * @param inNodeType
556      * @param labels
557      * @return
558      * @throws AAIException
559      */
560     public abstract QueryBuilder<Edge> getEdgesBetweenWithLabels(EdgeType type, String outNodeType, String inNodeType,
561             List<String> labels) throws AAIException;
562
563     /**
564      * Creates the query from URI.
565      *
566      * @param uri the uri
567      * @return the query parser
568      * @throws UnsupportedEncodingException the unsupported encoding exception
569      * @throws AAIException the AAI exception
570      */
571     public abstract QueryParser createQueryFromURI(URI uri) throws UnsupportedEncodingException, AAIException;
572
573     /**
574      * Creates the query from URI.
575      *
576      * @param uri the uri
577      * @param queryParams the query params
578      * @return the query parser
579      * @throws UnsupportedEncodingException the unsupported encoding exception
580      * @throws AAIException the AAI exception
581      */
582     public abstract QueryParser createQueryFromURI(URI uri, MultivaluedMap<String, String> queryParams)
583             throws UnsupportedEncodingException, AAIException;
584
585     /**
586      * Creates a queryparser from a given object name.
587      *
588      * @param objName - name of the object type as it appears in the database
589      * @return
590      */
591     public abstract QueryParser createQueryFromObjectName(String objName);
592
593     /**
594      * Creates the query from relationship.
595      *
596      * @param relationship the relationship
597      * @return the query parser
598      * @throws UnsupportedEncodingException the unsupported encoding exception
599      * @throws AAIException the AAI exception
600      */
601     public abstract QueryParser createQueryFromRelationship(Introspector relationship)
602             throws UnsupportedEncodingException, AAIException;
603
604     /**
605      * Gets the parent query.
606      *
607      * @return the parent query
608      */
609     public abstract QueryBuilder<E> getParentQuery();
610
611     /**
612      * Gets the query.
613      *
614      * @return the query
615      */
616     public abstract <E2> E2 getQuery();
617
618     /**
619      * Form boundary.
620      */
621     public abstract void markParentBoundary();
622
623     public abstract QueryBuilder<E> limit(long amount);
624
625     /**
626      * New instance.
627      *
628      * @param start the start
629      * @return the query builder
630      */
631     public abstract QueryBuilder<E> newInstance(Vertex start);
632
633     /**
634      * New instance.
635      *
636      * @return the query builder
637      */
638     public abstract QueryBuilder<E> newInstance();
639
640     /**
641      * Gets the start.
642      *
643      * @return the start
644      */
645     public abstract Vertex getStart();
646
647     protected Object correctObjectType(Object obj) {
648
649         if (obj != null && obj.getClass().equals(Long.class)) {
650             return Integer.valueOf(obj.toString());
651         }
652
653         return obj;
654     }
655
656     /**
657      * uses all fields in the introspector to create a query
658      *
659      * @param obj
660      * @return
661      */
662     public abstract QueryBuilder<Vertex> exactMatchQuery(Introspector obj);
663
664     /**
665      * lets you join any number of QueryBuilders
666      * <b>be careful about starting with a union it will not use indexes</b>
667      *
668      * @param builder
669      * @return
670      */
671     public abstract QueryBuilder<E> union(QueryBuilder<E>... builder);
672
673     public abstract QueryBuilder<E> where(QueryBuilder<E>... builder);
674
675     public abstract QueryBuilder<E> or(QueryBuilder<E>... builder);
676
677     public abstract QueryBuilder<E> store(String name);
678
679     public abstract QueryBuilder<E> cap(String name);
680
681     public abstract QueryBuilder<E> unfold();
682
683     public abstract QueryBuilder<E> fold();
684
685     public abstract QueryBuilder<E> id();
686
687     public abstract QueryBuilder<E> dedup();
688
689     public abstract QueryBuilder<E> emit();
690
691     public abstract QueryBuilder<E> repeat(QueryBuilder<E> builder);
692
693     public abstract QueryBuilder<Edge> outE();
694
695     public abstract QueryBuilder<Edge> inE();
696
697     public abstract QueryBuilder<Vertex> inV();
698
699     public abstract QueryBuilder<Vertex> outV();
700
701     public abstract QueryBuilder<E> not(QueryBuilder<E> builder);
702
703     public abstract QueryBuilder<E> as(String name);
704
705     public abstract QueryBuilder<E> select(String name);
706
707     public abstract QueryBuilder<E> select(String... names);
708
709     public abstract QueryBuilder<E> until(QueryBuilder<E> builder);
710
711     public abstract QueryBuilder<E> groupCount();
712
713     public abstract QueryBuilder<E> by(String name);
714
715     public abstract QueryBuilder<E> valueMap();
716
717     public abstract QueryBuilder<E> valueMap(String... names);
718
719     public abstract QueryBuilder<E> both();
720
721     public abstract QueryBuilder<Tree> tree();
722
723     /**
724      * Used to prevent the traversal from repeating its path through the graph.
725      * See http://tinkerpop.apache.org/docs/3.0.1-incubating/#simplepath-step for more info.
726      *
727      * @return a QueryBuilder with the simplePath step appended to its traversal
728      */
729     public abstract QueryBuilder<E> simplePath();
730
731     /**
732      *
733      * @return QueryBuilder with the path step appended to its traversal
734      */
735     public abstract QueryBuilder<Path> path();
736
737     public abstract void markContainer();
738
739     public abstract QueryBuilder<E> getContainerQuery();
740
741     public abstract List<E> toList();
742
743     /**
744      * Used to skip step if there is an optional property missing.
745      *
746      * @param key
747      * @param value
748      * @return
749      */
750     public QueryBuilder<Vertex> getVerticesByProperty(String key, MissingOptionalParameter value) {
751         return (QueryBuilder<Vertex>) this;
752     }
753
754     /**
755      * TODO the edge direction is hardcoded here, make it more generic
756      * Returns the parent edge of the vertex
757      *
758      * @return
759      */
760     public QueryBuilder<Edge> getParentEdge() {
761         this.outE().has(EdgeProperty.CONTAINS.toString(), AAIDirection.IN.toString());
762         return (QueryBuilder<Edge>) this;
763     }
764
765     /**
766      * TODO the edge direction is hardcoded here, make it more generic
767      * Returns the parent vertex of the vertex
768      *
769      * @return
770      */
771     public QueryBuilder<Vertex> getParentVertex() {
772         this.getParentEdge().inV();
773         return (QueryBuilder<Vertex>) this;
774     }
775
776     protected abstract QueryBuilder<Edge> has(String key, String value);
777
778     protected void initEdgeIngestor() {
779         // TODO proper spring wiring, but that requires a lot of refactoring so for now we have this
780         ApplicationContext ctx = SpringContextAware.getApplicationContext();
781         EdgeIngestor ei = ctx.getBean(EdgeIngestor.class);
782         setEdgeIngestor(ei);
783     }
784
785     protected void setEdgeIngestor(EdgeIngestor ei) {
786         this.edgeRules = ei;
787     }
788
789     public QueryBuilder<Vertex> getVerticesByNumberProperty(String key, Object value) {
790         return getVerticesByProperty(key, value);
791     }
792
793     public QueryBuilder<Vertex> getVerticesByNumberProperty(String key) {
794         return getVerticesByProperty(key);
795     }
796
797     public QueryBuilder<Vertex> getVerticesByNumberProperty(String key, MissingOptionalParameter value) {
798         return getVerticesByProperty(key, value);
799     }
800
801     protected abstract void vertexHas(String key, Object value);
802
803     protected abstract void vertexHasNot(String key);
804
805     protected abstract void vertexHas(String key);
806
807     // TODO: This probably is not required but need to test
808     // protected abstract void vertexHas(final String key, final P<?> predicate);
809 }