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.HashSet;
27 import java.util.List;
30 import org.onap.crud.entity.Edge;
32 import org.onap.crud.entity.Vertex;
33 import org.onap.crud.exception.CrudException;
35 public interface GraphDao {
37 public Vertex getVertex(String id, String version) throws CrudException;
39 public Vertex getVertex(String id, String type, String version) throws CrudException;
42 * Retrieve all of the edges which are incident to the vertex with the
43 * specified identifier.
46 * - The unique identifier of the vertex to retrieve the edges for.
47 * @return - A collection of edges.
48 * @throws CrudException
50 public List<Edge> getVertexEdges(String id) 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 - A collection of vertices.
61 * @throws CrudException
63 public List<Vertex> 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 - A collection of vertices.
76 * @throws CrudException
78 public List<Vertex> getVertices(String type, Map<String, Object> filter, HashSet<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.
86 * @return - The Edge corresponding to the specified identifier.
87 * @throws CrudException
89 public Edge getEdge(String id, String type) throws CrudException;
92 * Retrieve a collection of {@link Edge} objects with a given type and which
93 * match a set of supplied filter parameters.
96 * - The type of edges that we are interested in.
98 * - The parameters that we want to filter our edges by.
99 * @return - A collection of edges which match the supplied filter parameters.
100 * @throws CrudException
102 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException;
105 * Insert a new {@link Vertex} into the graph data store.
108 * - The type label to assign to the vertex.
110 * - The properties to associated with this vertex.
111 * @return - The {@link Vertex} object that was created.
112 * @throws CrudException
114 public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException;
117 * Updates an existing {@link Vertex}.
120 * - The unique identifier of the vertex to be updated.
122 * - The properties to associate with the vertex.
123 * @return - The udpated vertex.
124 * @throws CrudException
126 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version) throws CrudException;
129 * Removes the specified vertex from the graph data base.
132 * NOTE: The vertex MUST contain NO incident edges before it can be deleted.
135 * - The unique identifier of the vertex to be deleted.
136 * @throws CrudException
138 public void deleteVertex(String id, String type) throws CrudException;
141 * Adds an edge to the graph database.
144 * - The 'type' label to apply to the edge.
146 * - The source vertex for this edge.
148 * - The target vertex for this edge.
150 * - The properties map to associate with this edge.
151 * @return - The {@link Edge} object that was created.
152 * @throws CrudException
154 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version) throws CrudException;
157 * Updates an existing {@link Edge}.
160 * - The unique identifier of the edge to be updated.
162 * - The properties to associate with the edge.
163 * @return - The update edge.
164 * @throws CrudException
166 public Edge 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;