2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.crud.dao;
23 import java.util.List;
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;
32 public interface GraphDao {
34 public Vertex getVertex(String id, String version) throws CrudException;
36 public OperationResult getVertex(String id, String type, String version, Map<String, String> queryParams) throws CrudException;
39 * Retrieve all of the edges which are incident to the vertex with the
40 * specified identifier.
43 * - The unique identifier of the vertex to retrieve the edges for.
45 * - query parameters to be passed
47 * - a DB transaction ID to use (if null, no transactionId is used)
48 * @return - A collection of edges.
49 * @throws CrudException
51 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams, String txId) throws CrudException;
54 * Retrieve a collection of {@link Vertex} objects which match the supplied
55 * type label and filter properties.
58 * - The vertex type that we want to retrieve.
60 * - The parameters to filter our results by.
61 * @return - The {@link OperationResult} OperationResult
62 * @throws CrudException
64 public OperationResult getVertices(String type, Map<String, Object> filter, String version) throws CrudException;
67 * Retrieve a collection of {@link Vertex} objects which match the supplied
68 * type label and filter properties.
71 * - The vertex type that we want to retrieve.
73 * - The parameters to filter our results by.
75 * - The properties to retrieve with the vertex
76 * @return - The {@link OperationResult} OperationResult
77 * @throws CrudException
79 public OperationResult getVertices(String type, Map<String, Object> filter, Set<String> properties, String version) throws CrudException;
82 * Retrieve an {@link Edge} from the graph database by specifying its unique
86 * - The unique identifier for the Edge to be retrieved.
88 * - The type that we want to retrieve.
90 * - query parameters to be passed
91 * @return - The {@link OperationResult} OperationResult corresponding to the specified identifier.
92 * @throws CrudException
94 public OperationResult getEdge(String id, String type, Map<String, String> queryParams) throws CrudException;
97 * Retrieve a collection of {@link Edge} objects with a given type and which
98 * match a set of supplied filter parameters.
101 * - The type of edges that we are interested in.
103 * - The parameters that we want to filter our edges by.
104 * @return - The {@link OperationResult} OperationResult
105 * @throws CrudException
107 public OperationResult getEdges(String type, Map<String, Object> filter) throws CrudException;
110 * Insert a new {@link Vertex} into the graph data store.
113 * - The type label to assign to the vertex.
115 * - The properties to associated with this vertex.
116 * @return - The result of the Vertex creation.
117 * @throws CrudException
119 public OperationResult addVertex(String type, Map<String, Object> properties, String version) throws CrudException;
122 * Updates an existing {@link Vertex}.
125 * - The unique identifier of the vertex to be updated.
127 * - The properties to associate with the vertex.
128 * @return - The result of the update OperationResult.
129 * @throws CrudException
131 public OperationResult updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException;
134 * Removes the specified vertex from the graph data base.
137 * NOTE: The vertex MUST contain NO incident edges before it can be deleted.
140 * - The unique identifier of the vertex to be deleted.
141 * @throws CrudException
143 public void deleteVertex(String id, String type) throws CrudException;
146 * Adds an edge to the graph database.
149 * - The 'type' label to apply to the edge.
151 * - The source vertex for this edge.
153 * - The target vertex for this edge.
155 * - The properties map to associate with this edge.
156 * @return - The {@link OperationResult} OperationResult containing the Edge that was created.
157 * @throws CrudException
159 public OperationResult addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException;
162 * Updates an existing {@link Edge}.
165 * - The edge to be updated.
166 * @return - The result of the update OperationResult.
167 * @throws CrudException
169 public OperationResult updateEdge(Edge edge) throws CrudException;
172 * Remove the specified edge from the graph data base.
175 * - The unique identifier of the edge to be deleted.
176 * @throws CrudException
178 public void deleteEdge(String id) throws CrudException;
180 public String openTransaction();
182 public void commitTransaction(String id) throws CrudException;
184 public void rollbackTransaction(String id) throws CrudException;
186 public boolean transactionExists(String id) throws CrudException;
188 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException;
190 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
191 throws CrudException;
193 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException;
195 public Edge updateEdge(Edge edge, String txId) throws CrudException;
197 public void deleteVertex(String id, String type, String txId) throws CrudException;
199 public void deleteEdge(String id, String txId) throws CrudException;
201 public Edge getEdge(String id, String txId) throws CrudException;
203 public Edge getEdge(String id) throws CrudException;
205 public OperationResult bulkOperation(ChampBulkPayload champPayload) throws CrudException;