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