2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.crud.dao;
26 import java.util.List;
29 import org.onap.crud.entity.Edge;
31 import org.onap.crud.entity.Vertex;
32 import org.onap.crud.exception.CrudException;
34 public interface GraphDao {
36 public Vertex getVertex(String id) throws CrudException;
38 public Vertex getVertex(String id, String type) throws CrudException;
41 * Retrieve all of the edges which are incident to the vertex with the
42 * specified identifier.
45 * - The unique identifier of the vertex to retrieve the edges for.
46 * @return - A collection of edges.
47 * @throws CrudException
49 public List<Edge> getVertexEdges(String id) 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) throws CrudException;
65 * Retrieve an {@link Edge} from the graph database by specifying its unique
69 * - The unique identifier for the Edge to be retrieved.
70 * @return - The Edge corresponding to the specified identifier.
71 * @throws CrudException
73 public Edge getEdge(String id, String type) throws CrudException;
76 * Retrieve a collection of {@link Edge} objects with a given type and which
77 * match a set of supplied filter parameters.
80 * - The type of edges that we are interested in.
82 * - The parameters that we want to filter our edges by.
83 * @return - A collection of edges which match the supplied filter parameters.
84 * @throws CrudException
86 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException;
89 * Insert a new {@link Vertex} into the graph data store.
92 * - The type label to assign to the vertex.
94 * - The properties to associated with this vertex.
95 * @return - The {@link Vertex} object that was created.
96 * @throws CrudException
98 public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException;
101 * Updates an existing {@link Vertex}.
104 * - The unique identifier of the vertex to be updated.
106 * - The properties to associate with the vertex.
107 * @return - The udpated vertex.
108 * @throws CrudException
110 public Vertex updateVertex(String id, String type, Map<String, Object> properties) throws CrudException;
113 * Removes the specified vertex from the graph data base.
116 * NOTE: The vertex MUST contain NO incident edges before it can be deleted.
119 * - The unique identifier of the vertex to be deleted.
120 * @throws CrudException
122 public void deleteVertex(String id, String type) throws CrudException;
125 * Adds an edge to the graph database.
128 * - The 'type' label to apply to the edge.
130 * - The source vertex for this edge.
132 * - The target vertex for this edge.
134 * - The properties map to associate with this edge.
135 * @return - The {@link Edge} object that was created.
136 * @throws CrudException
138 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties) throws CrudException;
141 * Updates an existing {@link Edge}.
144 * - The unique identifier of the edge to be updated.
146 * - The properties to associate with the edge.
147 * @return - The update edge.
148 * @throws CrudException
150 public Edge updateEdge(Edge edge) throws CrudException;
153 * Remove the specified edge from the graph data base.
156 * - The unique identifier of the edge to be deleted.
157 * @throws CrudException
159 public void deleteEdge(String id, String type) throws CrudException;
161 public String openTransaction();
163 public void commitTransaction(String id) throws CrudException;
165 public void rollbackTransaction(String id) throws CrudException;
167 public boolean transactionExists(String id) throws CrudException;
169 public Vertex addVertex(String type, Map<String, Object> properties, String txId) throws CrudException;
171 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String txId)
172 throws CrudException;
174 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String txId) throws CrudException;
176 public Edge updateEdge(Edge edge, String txId) throws CrudException;
178 public void deleteVertex(String id, String type, String txId) throws CrudException;
180 public void deleteEdge(String id, String type, String txId) throws CrudException;
182 public Edge getEdge(String id, String type, String txId) throws CrudException;