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;
27 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 Vertex 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
46 * @return - A collection of edges.
47 * @throws CrudException
49 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException;
52 * Retrieve a collection of {@link Vertex} objects which match the supplied
53 * type label and filter properties.
56 * - The vertex type that we want to retrieve.
58 * - The parameters to filter our results by.
59 * @return - A collection of vertices.
60 * @throws CrudException
62 public List<Vertex> getVertices(String type, Map<String, Object> filter, String version) throws CrudException;
65 * Retrieve a collection of {@link Vertex} objects which match the supplied
66 * type label and filter properties.
69 * - The vertex type that we want to retrieve.
71 * - The parameters to filter our results by.
73 * - The properties to retrieve with the vertex
74 * @return - A collection of vertices.
75 * @throws CrudException
77 public List<Vertex> getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version) throws CrudException;
80 * Retrieve an {@link Edge} from the graph database by specifying its unique
84 * - The unique identifier for the Edge to be retrieved.
86 * - The type that we want to retrieve.
88 * - query parameters to be passed
89 * @return - The Edge corresponding to the specified identifier.
90 * @throws CrudException
92 public Edge getEdge(String id, String type, Map<String, String> queryParams) throws CrudException;
95 * Retrieve a collection of {@link Edge} objects with a given type and which
96 * match a set of supplied filter parameters.
99 * - The type of edges that we are interested in.
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
105 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException;
108 * Insert a new {@link Vertex} into the graph data store.
111 * - The type label to assign to the vertex.
113 * - The properties to associated with this vertex.
114 * @return - The {@link Vertex} object that was created.
115 * @throws CrudException
117 public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException;
120 * Updates an existing {@link Vertex}.
123 * - The unique identifier of the vertex to be updated.
125 * - The properties to associate with the vertex.
126 * @return - The udpated vertex.
127 * @throws CrudException
129 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException;
132 * Removes the specified vertex from the graph data base.
135 * NOTE: The vertex MUST contain NO incident edges before it can be deleted.
138 * - The unique identifier of the vertex to be deleted.
139 * @throws CrudException
141 public void deleteVertex(String id, String type) throws CrudException;
144 * Adds an edge to the graph database.
147 * - The 'type' label to apply to the edge.
149 * - The source vertex for this edge.
151 * - The target vertex for this edge.
153 * - The properties map to associate with this edge.
154 * @return - The {@link Edge} object that was created.
155 * @throws CrudException
157 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException;
160 * Updates an existing {@link Edge}.
163 * - The unique identifier of the edge to be updated.
165 * - The properties to associate with the edge.
166 * @return - The update edge.
167 * @throws CrudException
169 public Edge 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, String type) 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 type, String txId) throws CrudException;
201 public Edge getEdge(String id, String type, String txId) throws CrudException;