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.entity.Edge;
28 import org.onap.crud.entity.Vertex;
29 import org.onap.crud.exception.CrudException;
31 public interface GraphDao {
33 public Vertex getVertex(String id, String version) throws CrudException;
35 public OperationResult getVertex(String id, String type, String version, Map<String, String> queryParams) throws CrudException;
38 * Retrieve all of the edges which are incident to the vertex with the
39 * specified identifier.
42 * - The unique identifier of the vertex to retrieve the edges for.
44 * - query parameters to be passed
46 * - a DB transaction ID to use (if null, no transactionId is used)
47 * @return - A collection of edges.
48 * @throws CrudException
50 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams, String txId) throws CrudException;
53 * Retrieve a collection of {@link Vertex} objects which match the supplied
54 * type label and filter properties.
57 * - The vertex type that we want to retrieve.
59 * - The parameters to filter our results by.
60 * @return - The {@link OperationResult} OperationResult
61 * @throws CrudException
63 public OperationResult getVertices(String type, Map<String, Object> filter, String version) throws CrudException;
66 * Retrieve a collection of {@link Vertex} objects which match the supplied
67 * type label and filter properties.
70 * - The vertex type that we want to retrieve.
72 * - The parameters to filter our results by.
74 * - The properties to retrieve with the vertex
75 * @return - The {@link OperationResult} OperationResult
76 * @throws CrudException
78 public OperationResult getVertices(String type, Map<String, Object> filter, Set<String> properties, String version) throws CrudException;
81 * Retrieve an {@link Edge} from the graph database by specifying its unique
85 * - The unique identifier for the Edge to be retrieved.
87 * - The type that we want to retrieve.
89 * - query parameters to be passed
90 * @return - The {@link OperationResult} OperationResult corresponding to the specified identifier.
91 * @throws CrudException
93 public OperationResult getEdge(String id, String type, Map<String, String> queryParams) throws CrudException;
96 * Retrieve a collection of {@link Edge} objects with a given type and which
97 * match a set of supplied filter parameters.
100 * - The type of edges that we are interested in.
102 * - The parameters that we want to filter our edges by.
103 * @return - The {@link OperationResult} OperationResult
104 * @throws CrudException
106 public OperationResult getEdges(String type, Map<String, Object> filter) throws CrudException;
109 * Insert a new {@link Vertex} into the graph data store.
112 * - The type label to assign to the vertex.
114 * - The properties to associated with this vertex.
115 * @return - The result of the Vertex creation.
116 * @throws CrudException
118 public OperationResult addVertex(String type, Map<String, Object> properties, String version) throws CrudException;
121 * Updates an existing {@link Vertex}.
124 * - The unique identifier of the vertex to be updated.
126 * - The properties to associate with the vertex.
127 * @return - The result of the update OperationResult.
128 * @throws CrudException
130 public OperationResult updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException;
133 * Removes the specified vertex from the graph data base.
136 * NOTE: The vertex MUST contain NO incident edges before it can be deleted.
139 * - The unique identifier of the vertex to be deleted.
140 * @throws CrudException
142 public void deleteVertex(String id, String type) throws CrudException;
145 * Adds an edge to the graph database.
148 * - The 'type' label to apply to the edge.
150 * - The source vertex for this edge.
152 * - The target vertex for this edge.
154 * - The properties map to associate with this edge.
155 * @return - The {@link OperationResult} OperationResult containing the Edge that was created.
156 * @throws CrudException
158 public OperationResult addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException;
161 * Updates an existing {@link Edge}.
164 * - The edge to be updated.
165 * @return - The result of the update OperationResult.
166 * @throws CrudException
168 public OperationResult updateEdge(Edge edge) throws CrudException;
171 * Remove the specified edge from the graph data base.
174 * - The unique identifier of the edge to be deleted.
175 * @throws CrudException
177 public void deleteEdge(String id) throws CrudException;
179 public String openTransaction();
181 public void commitTransaction(String id) throws CrudException;
183 public void rollbackTransaction(String id) throws CrudException;
185 public boolean transactionExists(String id) throws CrudException;
187 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException;
189 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
190 throws CrudException;
192 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException;
194 public Edge updateEdge(Edge edge, String txId) throws CrudException;
196 public void deleteVertex(String id, String type, String txId) throws CrudException;
198 public void deleteEdge(String id, String txId) throws CrudException;
200 public Edge getEdge(String id, String txId) throws CrudException;
202 public Edge getEdge(String id) throws CrudException;