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.HashSet;
24 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
45 * @return - A collection of edges.
46 * @throws CrudException
48 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException;
51 * Retrieve a collection of {@link Vertex} objects which match the supplied
52 * type label and filter properties.
55 * - The vertex type that we want to retrieve.
57 * - The parameters to filter our results by.
58 * @return - The {@link OperationResult} OperationResult
59 * @throws CrudException
61 public OperationResult getVertices(String type, Map<String, Object> filter, String version) throws CrudException;
64 * Retrieve a collection of {@link Vertex} objects which match the supplied
65 * type label and filter properties.
68 * - The vertex type that we want to retrieve.
70 * - The parameters to filter our results by.
72 * - The properties to retrieve with the vertex
73 * @return - The {@link OperationResult} OperationResult
74 * @throws CrudException
76 public OperationResult getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version) throws CrudException;
79 * Retrieve an {@link Edge} from the graph database by specifying its unique
83 * - The unique identifier for the Edge to be retrieved.
85 * - The type that we want to retrieve.
87 * - query parameters to be passed
88 * @return - The {@link OperationResult} OperationResult corresponding to the specified identifier.
89 * @throws CrudException
91 public OperationResult getEdge(String id, String type, Map<String, String> queryParams) throws CrudException;
94 * Retrieve a collection of {@link Edge} objects with a given type and which
95 * match a set of supplied filter parameters.
98 * - The type of edges that we are interested in.
100 * - The parameters that we want to filter our edges by.
101 * @return - The {@link OperationResult} OperationResult
102 * @throws CrudException
104 public OperationResult getEdges(String type, Map<String, Object> filter) throws CrudException;
107 * Insert a new {@link Vertex} into the graph data store.
110 * - The type label to assign to the vertex.
112 * - The properties to associated with this vertex.
113 * @return - The result of the Vertex creation.
114 * @throws CrudException
116 public OperationResult addVertex(String type, Map<String, Object> properties, String version) throws CrudException;
119 * Updates an existing {@link Vertex}.
122 * - The unique identifier of the vertex to be updated.
124 * - The properties to associate with the vertex.
125 * @return - The result of the update OperationResult.
126 * @throws CrudException
128 public OperationResult updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException;
131 * Removes the specified vertex from the graph data base.
134 * NOTE: The vertex MUST contain NO incident edges before it can be deleted.
137 * - The unique identifier of the vertex to be deleted.
138 * @throws CrudException
140 public void deleteVertex(String id, String type) throws CrudException;
143 * Adds an edge to the graph database.
146 * - The 'type' label to apply to the edge.
148 * - The source vertex for this edge.
150 * - The target vertex for this edge.
152 * - The properties map to associate with this edge.
153 * @return - The {@link OperationResult} OperationResult containing the Edge that was created.
154 * @throws CrudException
156 public OperationResult addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException;
159 * Updates an existing {@link Edge}.
162 * - The edge to be updated.
163 * @return - The result of the update OperationResult.
164 * @throws CrudException
166 public OperationResult updateEdge(Edge edge) throws CrudException;
169 * Remove the specified edge from the graph data base.
172 * - The unique identifier of the edge to be deleted.
173 * @throws CrudException
175 public void deleteEdge(String id, String type) throws CrudException;
177 public String openTransaction();
179 public void commitTransaction(String id) throws CrudException;
181 public void rollbackTransaction(String id) throws CrudException;
183 public boolean transactionExists(String id) throws CrudException;
185 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId) throws CrudException;
187 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version, String txId)
188 throws CrudException;
190 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId) throws CrudException;
192 public Edge updateEdge(Edge edge, String txId) throws CrudException;
194 public void deleteVertex(String id, String type, String txId) throws CrudException;
196 public void deleteEdge(String id, String type, String txId) throws CrudException;
198 public Edge getEdge(String id, String type, String txId) throws CrudException;