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.openecomp.crud.dao;
26 import org.openecomp.crud.entity.Edge;
27 import org.openecomp.crud.entity.Vertex;
28 import org.openecomp.crud.exception.CrudException;
30 import java.util.List;
33 public interface GraphDao {
35 public Vertex getVertex(String id, String type) throws CrudException;
38 * Retrieve all of the edges which are incident to the vertex with the specified identifier.
40 * @param id - The unique identifier of the vertex to retrieve the edges for.
41 * @return - A collection of edges.
42 * @throws CrudException
44 public List<Edge> getVertexEdges(String id) throws CrudException;
47 * Retrieve a collection of {@link Vertex} objects which match the supplied type label
48 * and filter properties.
50 * @param type - The vertex type that we want to retrieve.
51 * @param filter - The parameters to filter our results by.
52 * @return - A collection of vertices.
53 * @throws CrudException
55 public List<Vertex> getVertices(String type, Map<String, Object> filter) throws CrudException;
58 * Retrieve an {@link Edge} from the graph database by specifying its unique identifier.
60 * @param id - The unique identifier for the Edge to be retrieved.
61 * @return - The Edge corresponding to the specified identifier.
62 * @throws CrudException
64 public Edge getEdge(String id, String type) throws CrudException;
67 * Retrieve a collection of {@link Edge} objects with a given type and which match a set of
68 * supplied filter parameters.
70 * @param type - The type of edges that we are interested in.
71 * @param filter - The parameters that we want to filter our edges by.
72 * @return - A collection of edges which match the supplied filter parameters.
73 * @throws CrudException
75 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException;
78 * Insert a new {@link Vertex} into the graph data store.
80 * @param type - The type label to assign to the vertex.
81 * @param properties - The properties to associated with this vertex.
82 * @return - The {@link Vertex} object that was created.
83 * @throws CrudException
85 public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException;
88 * Updates an existing {@link Vertex}.
90 * @param id - The unique identifier of the vertex to be updated.
91 * @param properties - The properties to associate with the vertex.
92 * @return - The udpated vertex.
93 * @throws CrudException
95 public Vertex updateVertex(String id, String type, Map<String, Object> properties)
99 * Removes the specified vertex from the graph data base.
101 * <p>NOTE: The vertex MUST contain NO incident edges before it can be deleted.
103 * @param id - The unique identifier of the vertex to be deleted.
104 * @throws CrudException
106 public void deleteVertex(String id, String type) throws CrudException;
109 * Adds an edge to the graph database.
111 * @param type - The 'type' label to apply to the edge.
112 * @param source - The source vertex for this edge.
113 * @param target - The target vertex for this edge.
114 * @param properties - The properties map to associate with this edge.
115 * @return - The {@link Edge} object that was created.
116 * @throws CrudException
118 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties)
119 throws CrudException;
122 * Updates an existing {@link Edge}.
124 * @param id - The unique identifier of the edge to be updated.
125 * @param properties - The properties to associate with the edge.
126 * @return - The update edge.
127 * @throws CrudException
129 public Edge updateEdge(Edge edge) throws CrudException;
132 * Remove the specified edge from the graph data base.
134 * @param id - The unique identifier of the edge to be deleted.
135 * @throws CrudException
137 public void deleteEdge(String id, String type) throws CrudException;