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 java.util.List;
29 import org.openecomp.crud.entity.Edge;
31 import org.openecomp.crud.entity.Vertex;
32 import org.openecomp.crud.exception.CrudException;
34 public interface GraphDao {
36 public Vertex getVertex(String id) throws CrudException;
38 public Vertex getVertex(String id, String type) throws CrudException;
41 * Retrieve all of the edges which are incident to the vertex with the specified identifier.
43 * @param id - The unique identifier of the vertex to retrieve the edges for.
44 * @return - A collection of edges.
45 * @throws CrudException
47 public List<Edge> getVertexEdges(String id) throws CrudException;
50 * Retrieve a collection of {@link Vertex} objects which match the supplied type label
51 * and filter properties.
53 * @param type - The vertex type that we want to retrieve.
54 * @param filter - The parameters to filter our results by.
55 * @return - A collection of vertices.
56 * @throws CrudException
58 public List<Vertex> getVertices(String type, Map<String, Object> filter) throws CrudException;
61 * Retrieve an {@link Edge} from the graph database by specifying its unique identifier.
63 * @param id - The unique identifier for the Edge to be retrieved.
64 * @return - The Edge corresponding to the specified identifier.
65 * @throws CrudException
67 public Edge getEdge(String id, String type) throws CrudException;
70 * Retrieve a collection of {@link Edge} objects with a given type and which match a set of
71 * supplied filter parameters.
73 * @param type - The type of edges that we are interested in.
74 * @param filter - The parameters that we want to filter our edges by.
75 * @return - A collection of edges which match the supplied filter parameters.
76 * @throws CrudException
78 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException;
81 * Insert a new {@link Vertex} into the graph data store.
83 * @param type - The type label to assign to the vertex.
84 * @param properties - The properties to associated with this vertex.
85 * @return - The {@link Vertex} object that was created.
86 * @throws CrudException
88 public Vertex addVertex(String type, Map<String, Object> properties) throws CrudException;
91 * Updates an existing {@link Vertex}.
93 * @param id - The unique identifier of the vertex to be updated.
94 * @param properties - The properties to associate with the vertex.
95 * @return - The udpated vertex.
96 * @throws CrudException
98 public Vertex updateVertex(String id, String type, Map<String, Object> properties)
102 * Removes the specified vertex from the graph data base.
104 * <p>NOTE: The vertex MUST contain NO incident edges before it can be deleted.
106 * @param id - The unique identifier of the vertex to be deleted.
107 * @throws CrudException
109 public void deleteVertex(String id, String type) throws CrudException;
112 * Adds an edge to the graph database.
114 * @param type - The 'type' label to apply to the edge.
115 * @param source - The source vertex for this edge.
116 * @param target - The target vertex for this edge.
117 * @param properties - The properties map to associate with this edge.
118 * @return - The {@link Edge} object that was created.
119 * @throws CrudException
121 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties)
122 throws CrudException;
125 * Updates an existing {@link Edge}.
127 * @param id - The unique identifier of the edge to be updated.
128 * @param properties - The properties to associate with the edge.
129 * @return - The update edge.
130 * @throws CrudException
132 public Edge updateEdge(Edge edge) throws CrudException;
135 * Remove the specified edge from the graph data base.
137 * @param id - The unique identifier of the edge to be deleted.
138 * @throws CrudException
140 public void deleteEdge(String id, String type) throws CrudException;
143 public String openTransaction();
144 public void commitTransaction(String id) throws CrudException;
145 public void rollbackTransaction(String id) throws CrudException;
146 public boolean transactionExists(String id) throws CrudException;
148 public Vertex addVertex(String type, Map<String, Object> properties, String txId) throws CrudException;
149 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String txId)
150 throws CrudException;
151 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String txId)
152 throws CrudException;
154 public Edge updateEdge(Edge edge, String txId) throws CrudException;
155 public void deleteVertex(String id, String type, String txId) throws CrudException;
156 public void deleteEdge(String id, String type, String txId) throws CrudException;
157 public Edge getEdge(String id, String type, String txId) throws CrudException;