20b568c0eec279f0fe159ce754f484ee4e9eb72a
[aai/gizmo.git] / src / main / java / org / openecomp / crud / dao / GraphDao.java
1 /**
2  * ============LICENSE_START=======================================================
3  * Gizmo
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
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
12  *
13  *    http://www.apache.org/licenses/LICENSE-2.0
14  *
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=========================================================
21  *
22  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23  */
24 package org.openecomp.crud.dao;
25
26 import org.openecomp.crud.entity.Edge;
27 import org.openecomp.crud.entity.Vertex;
28 import org.openecomp.crud.exception.CrudException;
29
30 import java.util.List;
31 import java.util.Map;
32
33 public interface GraphDao {
34
35   public Vertex getVertex(String id, String type) throws CrudException;
36
37   /**
38    * Retrieve all of the edges which are incident to the vertex with the specified identifier.
39    *
40    * @param id - The unique identifier of the vertex to retrieve the edges for.
41    * @return - A collection of edges.
42    * @throws CrudException
43    */
44   public List<Edge> getVertexEdges(String id) throws CrudException;
45
46   /**
47    * Retrieve a collection of {@link Vertex} objects which match the supplied type label
48    * and filter properties.
49    *
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
54    */
55   public List<Vertex> getVertices(String type, Map<String, Object> filter) throws CrudException;
56
57   /**
58    * Retrieve an {@link Edge} from the graph database by specifying its unique identifier.
59    *
60    * @param id - The unique identifier for the Edge to be retrieved.
61    * @return - The Edge corresponding to the specified identifier.
62    * @throws CrudException
63    */
64   public Edge getEdge(String id, String type) throws CrudException;
65
66   /**
67    * Retrieve a collection of {@link Edge} objects with a given type and which match a set of
68    * supplied filter parameters.
69    *
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
74    */
75   public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException;
76
77   /**
78    * Insert a new {@link Vertex} into the graph data store.
79    *
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
84    */
85   public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException;
86
87   /**
88    * Updates an existing {@link Vertex}.
89    *
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
94    */
95   public Vertex updateVertex(String id, String type, Map<String, Object> properties)
96       throws CrudException;
97
98   /**
99    * Removes the specified vertex from the graph data base.
100    *
101    * <p>NOTE: The vertex MUST contain NO incident edges before it can be deleted.
102    *
103    * @param id - The unique identifier of the vertex to be deleted.
104    * @throws CrudException
105    */
106   public void deleteVertex(String id, String type) throws CrudException;
107
108   /**
109    * Adds an edge to the graph database.
110    *
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
117    */
118   public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties)
119       throws CrudException;
120
121   /**
122    * Updates an existing {@link Edge}.
123    *
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
128    */
129   public Edge updateEdge(Edge edge) throws CrudException;
130
131   /**
132    * Remove the specified edge from the graph data base.
133    *
134    * @param id - The unique identifier of the edge to be deleted.
135    * @throws CrudException
136    */
137   public void deleteEdge(String id, String type) throws CrudException;
138 }