Update the aai-common with the latest code
[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         public abstract List<Vertex> findChildren(Vertex start);
67         /**
68          * Find deletable.
69          *
70          * @param start the start
71          * @return the list
72          */
73         public abstract List<Vertex> findDeletable(Vertex start);
74         
75         public Tree<Element> findSubGraph(Vertex start) {
76                 return findSubGraph(start, AAIProperties.MAXIMUM_DEPTH, false);
77         }
78         public abstract Tree<Element> findSubGraph(Vertex start, int iterations, boolean nodeOnly);
79         /**
80          * Find related vertices.
81          *
82          * @param start the start
83          * @param direction the direction
84          * @param label the label
85          * @param nodeType the node type
86          * @return the list
87          */
88         public abstract List<Vertex> findRelatedVertices(Vertex start, Direction direction, String label, String nodeType);
89
90         public abstract List<Edge> findEdgesForVersion(Vertex start, Loader loader);
91         
92         public abstract List<Vertex> findCousinVertices(Vertex start);
93
94 }