Update license date and text
[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.HashSet;
24 import java.util.List;
25 import java.util.Map;
26
27 import org.onap.crud.entity.Edge;
28
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 Vertex 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    * @return - A collection of edges.
47    * @throws CrudException
48    */
49   public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException;
50
51   /**
52    * Retrieve a collection of {@link Vertex} objects which match the supplied
53    * type label and filter properties.
54    *
55    * @param type
56    *          - The vertex type that we want to retrieve.
57    * @param filter
58    *          - The parameters to filter our results by.
59    * @return - A collection of vertices.
60    * @throws CrudException
61    */
62   public List<Vertex> getVertices(String type, Map<String, Object> filter, String version) throws CrudException;
63
64   /**
65    * Retrieve a collection of {@link Vertex} objects which match the supplied
66    * type label and filter properties.
67    *
68    * @param type
69    *          - The vertex type that we want to retrieve.
70    * @param filter
71    *          - The parameters to filter our results by.
72    * @param properties
73    *          - The properties to retrieve with the vertex
74    * @return - A collection of vertices.
75    * @throws CrudException
76    */
77   public List<Vertex> getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version) throws CrudException;
78
79   /**
80    * Retrieve an {@link Edge} from the graph database by specifying its unique
81    * identifier.
82    *
83    * @param id
84    *          - The unique identifier for the Edge to be retrieved.
85    * @param type
86    *          - The type that we want to retrieve.
87    * @param queryParams
88    *              - query parameters to be passed                
89    * @return - The Edge corresponding to the specified identifier.
90    * @throws CrudException
91    */
92   public Edge getEdge(String id, String type, Map<String, String> queryParams) throws CrudException;
93
94   /**
95    * Retrieve a collection of {@link Edge} objects with a given type and which
96    * match a set of supplied filter parameters.
97    *
98    * @param type
99    *          - The type of edges that we are interested in.
100    * @param filter
101    *          - The parameters that we want to filter our edges by.
102    * @return - A collection of edges which match the supplied filter parameters.
103    * @throws CrudException
104    */
105   public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException;
106
107   /**
108    * Insert a new {@link Vertex} into the graph data store.
109    *
110    * @param type
111    *          - The type label to assign to the vertex.
112    * @param properties
113    *          - The properties to associated with this vertex.
114    * @return - The {@link Vertex} object that was created.
115    * @throws CrudException
116    */
117   public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException;
118
119   /**
120    * Updates an existing {@link Vertex}.
121    *
122    * @param id
123    *          - The unique identifier of the vertex to be updated.
124    * @param properties
125    *          - The properties to associate with the vertex.
126    * @return - The udpated vertex.
127    * @throws CrudException
128    */
129   public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException;
130
131   /**
132    * Removes the specified vertex from the graph data base.
133    *
134    * <p>
135    * NOTE: The vertex MUST contain NO incident edges before it can be deleted.
136    *
137    * @param id
138    *          - The unique identifier of the vertex to be deleted.
139    * @throws CrudException
140    */
141   public void deleteVertex(String id, String type) throws CrudException;
142
143   /**
144    * Adds an edge to the graph database.
145    *
146    * @param type
147    *          - The 'type' label to apply to the edge.
148    * @param source
149    *          - The source vertex for this edge.
150    * @param target
151    *          - The target vertex for this edge.
152    * @param properties
153    *          - The properties map to associate with this edge.
154    * @return - The {@link Edge} object that was created.
155    * @throws CrudException
156    */
157   public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException;
158
159   /**
160    * Updates an existing {@link Edge}.
161    *
162    * @param id
163    *          - The unique identifier of the edge to be updated.
164    * @param properties
165    *          - The properties to associate with the edge.
166    * @return - The update edge.
167    * @throws CrudException
168    */
169   public Edge 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, String type) 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 type, String txId) throws CrudException;
200
201   public Edge getEdge(String id, String type, String txId) throws CrudException;
202 }