Performance Improvements for Gizmo bulk API
[aai/gizmo.git] / src / main / java / org / onap / crud / dao / GraphDao.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.crud.dao;
22
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Set;
26 import org.onap.aai.restclient.client.OperationResult;
27 import org.onap.crud.dao.champ.ChampBulkPayload;
28 import org.onap.crud.entity.Edge;
29 import org.onap.crud.entity.Vertex;
30 import org.onap.crud.exception.CrudException;
31
32 public interface GraphDao {
33
34   public Vertex getVertex(String id, String version) throws CrudException;
35
36   public OperationResult getVertex(String id, String type, String version, Map<String, String> queryParams) throws CrudException;
37
38   /**
39    * Retrieve all of the edges which are incident to the vertex with the
40    * specified identifier.
41    *
42    * @param id
43    *          - The unique identifier of the vertex to retrieve the edges for.
44    * @param queryParams
45    *              - query parameters to be passed
46    * @param txid
47    *      - a DB transaction ID to use (if null, no transactionId is used)
48    * @return - A collection of edges.
49    * @throws CrudException
50    */
51   public List<Edge> getVertexEdges(String id, Map<String, String> queryParams, String txId) throws CrudException;
52
53   /**
54    * Retrieve a collection of {@link Vertex} objects which match the supplied
55    * type label and filter properties.
56    *
57    * @param type
58    *          - The vertex type that we want to retrieve.
59    * @param filter
60    *          - The parameters to filter our results by.
61    * @return - The {@link OperationResult} OperationResult
62    * @throws CrudException
63    */
64   public OperationResult getVertices(String type, Map<String, Object> filter, String version) throws CrudException;
65
66   /**
67    * Retrieve a collection of {@link Vertex} objects which match the supplied
68    * type label and filter properties.
69    *
70    * @param type
71    *          - The vertex type that we want to retrieve.
72    * @param filter
73    *          - The parameters to filter our results by.
74    * @param properties
75    *          - The properties to retrieve with the vertex
76    * @return - The {@link OperationResult} OperationResult
77    * @throws CrudException
78    */
79   public OperationResult getVertices(String type, Map<String, Object> filter, Set<String> properties, String version) throws CrudException;
80
81   /**
82    * Retrieve an {@link Edge} from the graph database by specifying its unique
83    * identifier.
84    *
85    * @param id
86    *          - The unique identifier for the Edge to be retrieved.
87    * @param type
88    *          - The type that we want to retrieve.
89    * @param queryParams
90    *              - query parameters to be passed
91    * @return - The {@link OperationResult} OperationResult corresponding to the specified identifier.
92    * @throws CrudException
93    */
94   public OperationResult getEdge(String id, String type, Map<String, String> queryParams) throws CrudException;
95
96   /**
97    * Retrieve a collection of {@link Edge} objects with a given type and which
98    * match a set of supplied filter parameters.
99    *
100    * @param type
101    *          - The type of edges that we are interested in.
102    * @param filter
103    *          - The parameters that we want to filter our edges by.
104    * @return - The {@link OperationResult} OperationResult
105    * @throws CrudException
106    */
107   public OperationResult getEdges(String type, Map<String, Object> filter) throws CrudException;
108
109   /**
110    * Insert a new {@link Vertex} into the graph data store.
111    *
112    * @param type
113    *          - The type label to assign to the vertex.
114    * @param properties
115    *          - The properties to associated with this vertex.
116    * @return - The result of the Vertex creation.
117    * @throws CrudException
118    */
119   public OperationResult addVertex(String type, Map<String, Object> properties, String version) throws CrudException;
120
121   /**
122    * Updates an existing {@link Vertex}.
123    *
124    * @param id
125    *          - The unique identifier of the vertex to be updated.
126    * @param properties
127    *          - The properties to associate with the vertex.
128    * @return - The result of the update OperationResult.
129    * @throws CrudException
130    */
131   public OperationResult updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException;
132
133   /**
134    * Removes the specified vertex from the graph data base.
135    *
136    * <p>
137    * NOTE: The vertex MUST contain NO incident edges before it can be deleted.
138    *
139    * @param id
140    *          - The unique identifier of the vertex to be deleted.
141    * @throws CrudException
142    */
143   public void deleteVertex(String id, String type) throws CrudException;
144
145   /**
146    * Adds an edge to the graph database.
147    *
148    * @param type
149    *          - The 'type' label to apply to the edge.
150    * @param source
151    *          - The source vertex for this edge.
152    * @param target
153    *          - The target vertex for this edge.
154    * @param properties
155    *          - The properties map to associate with this edge.
156    * @return - The {@link OperationResult} OperationResult containing the Edge that was created.
157    * @throws CrudException
158    */
159   public OperationResult addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException;
160
161   /**
162    * Updates an existing {@link Edge}.
163    *
164    * @param edge
165    *          - The edge to be updated.
166    * @return - The result of the update OperationResult.
167    * @throws CrudException
168    */
169   public OperationResult updateEdge(Edge edge) throws CrudException;
170
171   /**
172    * Remove the specified edge from the graph data base.
173    *
174    * @param id
175    *          - The unique identifier of the edge to be deleted.
176    * @throws CrudException
177    */
178   public void deleteEdge(String id) throws CrudException;
179
180   public String openTransaction();
181
182   public void commitTransaction(String id) throws CrudException;
183
184   public void rollbackTransaction(String id) throws CrudException;
185
186   public boolean transactionExists(String id) throws CrudException;
187
188   public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException;
189
190   public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
191           throws CrudException;
192
193   public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException;
194
195   public Edge updateEdge(Edge edge, String txId) throws CrudException;
196
197   public void deleteVertex(String id, String type, String txId) throws CrudException;
198
199   public void deleteEdge(String id, String txId) throws CrudException;
200
201   public Edge getEdge(String id, String txId) throws CrudException;
202
203   public Edge getEdge(String id) throws CrudException;
204
205   public OperationResult bulkOperation(ChampBulkPayload champPayload) throws CrudException;
206 }