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) throws CrudException;
37 public Vertex getVertex(String id, String type) throws CrudException;
40 * Retrieve all of the edges which are incident to the vertex with the specified identifier.
42 * @param id - The unique identifier of the vertex to retrieve the edges for.
43 * @return - A collection of edges.
44 * @throws CrudException
46 public List<Edge> getVertexEdges(String id) throws CrudException;
49 * Retrieve a collection of {@link Vertex} objects which match the supplied type label
50 * and filter properties.
52 * @param type - The vertex type that we want to retrieve.
53 * @param filter - The parameters to filter our results by.
54 * @return - A collection of vertices.
55 * @throws CrudException
57 public List<Vertex> getVertices(String type, Map<String, Object> filter) throws CrudException;
60 * Retrieve an {@link Edge} from the graph database by specifying its unique identifier.
62 * @param id - The unique identifier for the Edge to be retrieved.
63 * @return - The Edge corresponding to the specified identifier.
64 * @throws CrudException
66 public Edge getEdge(String id, String type) throws CrudException;
69 * Retrieve a collection of {@link Edge} objects with a given type and which match a set of
70 * supplied filter parameters.
72 * @param type - The type of edges that we are interested in.
73 * @param filter - The parameters that we want to filter our edges by.
74 * @return - A collection of edges which match the supplied filter parameters.
75 * @throws CrudException
77 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException;
80 * Insert a new {@link Vertex} into the graph data store.
82 * @param type - The type label to assign to the vertex.
83 * @param properties - The properties to associated with this vertex.
84 * @return - The {@link Vertex} object that was created.
85 * @throws CrudException
87 public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException;
90 * Updates an existing {@link Vertex}.
92 * @param id - The unique identifier of the vertex to be updated.
93 * @param properties - The properties to associate with the vertex.
94 * @return - The udpated vertex.
95 * @throws CrudException
97 public Vertex updateVertex(String id, String type, Map<String, Object> properties)
101 * Removes the specified vertex from the graph data base.
103 * <p>NOTE: The vertex MUST contain NO incident edges before it can be deleted.
105 * @param id - The unique identifier of the vertex to be deleted.
106 * @throws CrudException
108 public void deleteVertex(String id, String type) throws CrudException;
111 * Adds an edge to the graph database.
113 * @param type - The 'type' label to apply to the edge.
114 * @param source - The source vertex for this edge.
115 * @param target - The target vertex for this edge.
116 * @param properties - The properties map to associate with this edge.
117 * @return - The {@link Edge} object that was created.
118 * @throws CrudException
120 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties)
121 throws CrudException;
124 * Updates an existing {@link Edge}.
126 * @param id - The unique identifier of the edge to be updated.
127 * @param properties - The properties to associate with the edge.
128 * @return - The update edge.
129 * @throws CrudException
131 public Edge updateEdge(Edge edge) throws CrudException;
134 * Remove the specified edge from the graph data base.
136 * @param id - The unique identifier of the edge to be deleted.
137 * @throws CrudException
139 public void deleteEdge(String id, String type) throws CrudException;