New endpoints to auto populate edge properties.
[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) throws CrudException;
36
37   public Vertex getVertex(String id, String type) throws CrudException;
38
39   /**
40    * Retrieve all of the edges which are incident to the vertex with the specified identifier.
41    *
42    * @param id - The unique identifier of the vertex to retrieve the edges for.
43    * @return - A collection of edges.
44    * @throws CrudException
45    */
46   public List<Edge> getVertexEdges(String id) throws CrudException;
47
48   /**
49    * Retrieve a collection of {@link Vertex} objects which match the supplied type label
50    * and filter properties.
51    *
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
56    */
57   public List<Vertex> getVertices(String type, Map<String, Object> filter) throws CrudException;
58
59   /**
60    * Retrieve an {@link Edge} from the graph database by specifying its unique identifier.
61    *
62    * @param id - The unique identifier for the Edge to be retrieved.
63    * @return - The Edge corresponding to the specified identifier.
64    * @throws CrudException
65    */
66   public Edge getEdge(String id, String type) throws CrudException;
67
68   /**
69    * Retrieve a collection of {@link Edge} objects with a given type and which match a set of
70    * supplied filter parameters.
71    *
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
76    */
77   public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException;
78
79   /**
80    * Insert a new {@link Vertex} into the graph data store.
81    *
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
86    */
87   public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException;
88
89   /**
90    * Updates an existing {@link Vertex}.
91    *
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
96    */
97   public Vertex updateVertex(String id, String type, Map<String, Object> properties)
98       throws CrudException;
99
100   /**
101    * Removes the specified vertex from the graph data base.
102    *
103    * <p>NOTE: The vertex MUST contain NO incident edges before it can be deleted.
104    *
105    * @param id - The unique identifier of the vertex to be deleted.
106    * @throws CrudException
107    */
108   public void deleteVertex(String id, String type) throws CrudException;
109
110   /**
111    * Adds an edge to the graph database.
112    *
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
119    */
120   public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties)
121       throws CrudException;
122
123   /**
124    * Updates an existing {@link Edge}.
125    *
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
130    */
131   public Edge updateEdge(Edge edge) throws CrudException;
132
133   /**
134    * Remove the specified edge from the graph data base.
135    *
136    * @param id - The unique identifier of the edge to be deleted.
137    * @throws CrudException
138    */
139   public void deleteEdge(String id, String type) throws CrudException;
140 }