Initial commit with all the necessary files
[aai/aai-common.git] / aai-core / src / main / java / org / openecomp / aai / serialization / engines / query / QueryEngine.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.openecomp.aai
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11      http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.aai.serialization.engines.query;
22
23 import java.util.List;
24
25 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
26 import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
27 import org.apache.tinkerpop.gremlin.structure.Direction;
28 import org.apache.tinkerpop.gremlin.structure.Edge;
29 import org.apache.tinkerpop.gremlin.structure.Element;
30 import org.apache.tinkerpop.gremlin.structure.Vertex;
31
32 import org.openecomp.aai.db.props.AAIProperties;
33 import org.openecomp.aai.introspection.Loader;
34
35 public abstract class QueryEngine {
36
37         final protected GraphTraversalSource g;
38
39         /**
40          * Instantiates a new query engine.
41          *
42          * @param graphEngine the graph engine
43          */
44         public QueryEngine (GraphTraversalSource g) {
45                 this.g = g;
46         }
47         
48         /**
49          * Find parents.
50          *
51          * @param start the start
52          * @return the list
53          */
54         public abstract List<Vertex> findParents(Vertex start);
55         
56         /**
57          * Find children.
58          *
59          * @param start the start
60          * @return the list
61          */
62         public abstract List<Vertex> findAllChildren(Vertex start);
63         
64         public abstract List<Vertex> findChildrenOfType(Vertex start, String type);
65         /**
66          * Find deletable.
67          *
68          * @param start the start
69          * @return the list
70          */
71         public abstract List<Vertex> findDeletable(Vertex start);
72         
73         public Tree<Element> findSubGraph(Vertex start) {
74                 return findSubGraph(start, AAIProperties.MAXIMUM_DEPTH, false);
75         }
76         public abstract Tree<Element> findSubGraph(Vertex start, int iterations, boolean nodeOnly);
77         /**
78          * Find related vertices.
79          *
80          * @param start the start
81          * @param direction the direction
82          * @param label the label
83          * @param nodeType the node type
84          * @return the list
85          */
86         public abstract List<Vertex> findRelatedVertices(Vertex start, Direction direction, String label, String nodeType);
87
88         public abstract List<Edge> findEdgesForVersion(Vertex start, Loader loader);
89         
90         public abstract List<Vertex> findCousinVertices(Vertex start);
91
92 }