1717import com .arangodb .config .ArangoConfigProperties ;
1818import com .arangodb .entity .*;
1919import com .arangodb .model .*;
20+ import com .arangodb .tinkerpop .gremlin .persistence .*;
2021import com .arangodb .tinkerpop .gremlin .structure .ArangoDBEdge ;
2122import com .arangodb .tinkerpop .gremlin .structure .ArangoDBVertex ;
22- import com .arangodb .tinkerpop .gremlin .persistence .EdgeData ;
23- import com .arangodb .tinkerpop .gremlin .persistence .VertexData ;
2423import com .arangodb .tinkerpop .gremlin .structure .*;
2524import org .apache .tinkerpop .gremlin .process .traversal .util .TraversalInterruptedException ;
2625import org .apache .tinkerpop .gremlin .structure .Direction ;
2726import org .apache .tinkerpop .gremlin .structure .Graph ;
2827import org .slf4j .Logger ;
2928import org .slf4j .LoggerFactory ;
3029
31- import com .arangodb .tinkerpop .gremlin .utils .ArangoDBUtil ;
32-
3330import static com .arangodb .tinkerpop .gremlin .utils .ArangoDBUtil .getArangoDirectionFromGremlinDirection ;
3431
3532/**
@@ -105,25 +102,6 @@ public static ArangoDBGraphException getArangoDBException(ArangoDBException ex)
105102 return new ArangoDBGraphException ("General ArangoDB error (unkown error code)" , ex );
106103 }
107104
108- /**
109- * "name to long" Message.
110- */
111-
112- public static String NAME_TO_LONG = "Name is too long: {} bytes (max 64 bytes for labels, 256 for keys)" ;
113-
114- /**
115- * Gets the naming convention error.
116- *
117- * @param cause the cause
118- * @param details the details
119- * @return the naming convention error
120- */
121-
122- public static ArangoDBGraphException getNamingConventionError (String cause , String details ) {
123- return new ArangoDBGraphException ("The provided label or name name does not satisfy the naming conventions." +
124- String .format (cause , details ));
125- }
126-
127105 }
128106
129107 private static final Logger logger = LoggerFactory .getLogger (ArangoDBGraphClient .class );
@@ -162,21 +140,6 @@ public void shutdown() {
162140 db .arango ().shutdown ();
163141 }
164142
165- /**
166- * Request the version of ArangoDB.
167- *
168- * @return the Version number
169- * @throws ArangoDBGraphException if user has no access to the db
170- */
171-
172- public String getVersion () throws ArangoDBGraphException {
173- try {
174- return db .getVersion ().getVersion ();
175- } catch (ArangoDBException ex ) {
176- throw ArangoDBExceptions .getArangoDBException (ex );
177- }
178- }
179-
180143 public ArangoDBGraphVariables getGraphVariables () {
181144 logger .debug ("Get graph variables" );
182145 ArangoDBGraphVariables result ;
@@ -205,9 +168,9 @@ public void insertGraphVariables(ArangoDBGraphVariables document) {
205168 if (document .isPaired ()) {
206169 throw new ArangoDBGraphException ("Paired docuements can not be inserted, only updated" );
207170 }
208- ArangoCollection gVars = db .collection (document . collection () );
171+ ArangoCollection gVars = db .collection (ArangoDBGraph . GRAPH_VARIABLES_COLLECTION );
209172 if (!gVars .exists ()) {
210- CollectionEntity ce = db . createCollection ( document . collection () );
173+ CollectionEntity ce = gVars . create ( );
211174 System .out .println (ce .getStatus ());
212175 }
213176 DocumentCreateEntity <?> vertexEntity ;
@@ -277,9 +240,9 @@ public void updateGraphVariables(ArangoDBGraphVariables document) {
277240 */
278241
279242 // FIXME: use multi-docs API
280- public ArangoIterable <VertexData > getGraphVertices (final List <String > ids ) {
243+ public ArangoIterable <VertexData > getGraphVertices (final List <ArangoDBId > ids ) {
281244 logger .debug ("Get all {} graph vertices, filtered by ids: {}" , graph .name (), ids );
282- List <String > prefixedColNames = graph .vertexCollections ().stream ().map (graph ::getPrefixedCollectioName ).collect (Collectors .toList ());
245+ List <String > prefixedColNames = graph .vertexCollections ().stream ().map (graph ::getPrefixedCollectionName ).collect (Collectors .toList ());
283246 return getGraphDocuments (ids , prefixedColNames , VertexData .class );
284247 }
285248
@@ -290,13 +253,13 @@ public ArangoIterable<VertexData> getGraphVertices(final List<String> ids) {
290253 * @return ArangoDBBaseQuery the query object
291254 */
292255 // FIXME: use multi-docs API
293- public ArangoIterable <EdgeData > getGraphEdges (List <String > ids ) {
256+ public ArangoIterable <EdgeData > getGraphEdges (List <ArangoDBId > ids ) {
294257 logger .debug ("Get all {} graph edges, filtered by ids: {}" , graph .name (), ids );
295- List <String > prefixedColNames = graph .edgeCollections ().stream ().map (graph ::getPrefixedCollectioName ).collect (Collectors .toList ());
258+ List <String > prefixedColNames = graph .edgeCollections ().stream ().map (graph ::getPrefixedCollectionName ).collect (Collectors .toList ());
296259 return getGraphDocuments (ids , prefixedColNames , EdgeData .class );
297260 }
298261
299- private <V > ArangoIterable <V > getGraphDocuments (List <String > ids , List <String > prefixedColNames , Class <V > clazz ) {
262+ private <V > ArangoIterable <V > getGraphDocuments (List <ArangoDBId > ids , List <String > prefixedColNames , Class <V > clazz ) {
300263 Map <String , Object > bindVars = new HashMap <>();
301264 ArangoDBQueryBuilder queryBuilder = new ArangoDBQueryBuilder ();
302265 if (ids .isEmpty ()) {
@@ -306,9 +269,9 @@ private <V> ArangoIterable<V> getGraphDocuments(List<String> ids, List<String> p
306269 queryBuilder .iterateCollection ("d" , prefixedColNames .get (0 ), bindVars );
307270 }
308271 } else {
309- List <String > prunedIds = ids .stream ()
310- .map (graph ::getPrefixedCollectioName )
311- .filter (it -> prefixedColNames .contains (ArangoDBUtil . extractCollection ( it )))
272+ List <ArangoDBId > prunedIds = ids .stream ()
273+ .map (graph ::getArangoDBId )
274+ .filter (it -> prefixedColNames .contains (it . getCollection ( )))
312275 .collect (Collectors .toList ());
313276 queryBuilder .with (prefixedColNames , bindVars ).documentsById (prunedIds , "d" , bindVars );
314277 }
@@ -396,7 +359,7 @@ public void insertEdge(ArangoDBEdge edge) {
396359 }
397360 throw arangoDBException ;
398361 }
399- edge .key (insertEntity . getKey () );
362+ edge .update (insertEntity );
400363 }
401364
402365 public void deleteEdge (ArangoDBEdge edge ) {
@@ -426,17 +389,15 @@ public void updateEdge(ArangoDBEdge edge) {
426389 throw ArangoDBExceptions .getArangoDBException (e );
427390 }
428391 logger .debug ("Edge updated, new rev {}" , updateEntity .getRev ());
429- edge .key (updateEntity . getKey () );
392+ edge .update (updateEntity );
430393 }
431394
432- public VertexData readVertex (String id ) {
395+ public VertexData readVertex (ArangoDBId id ) {
433396 logger .debug ("Read vertex {} in {}" , id , graph .name ());
434- String col = ArangoDBUtil .extractCollection (id );
435- String key = ArangoDBUtil .extractKey (id );
436397 try {
437398 return db .graph (graph .name ())
438- .vertexCollection (col )
439- .getVertex (key , VertexData .class );
399+ .vertexCollection (id . getCollection () )
400+ .getVertex (id . getKey () , VertexData .class );
440401 } catch (ArangoDBException e ) {
441402 logger .error ("Failed to read vertex: {}" , e .getErrorMessage ());
442403 throw ArangoDBExceptions .getArangoDBException (e );
@@ -458,7 +419,7 @@ public void insertVertex(ArangoDBVertex vertex) {
458419 }
459420 throw arangoDBException ;
460421 }
461- vertex .key (vertexEntity . getKey () );
422+ vertex .update (vertexEntity );
462423 }
463424
464425 public void deleteVertex (ArangoDBVertex vertex ) {
@@ -490,7 +451,7 @@ public void updateVertex(ArangoDBVertex vertex) {
490451 logger .debug ("Document updated, new rev {}" , vertexEntity .getRev ());
491452 }
492453
493- public Iterator <VertexData > getVertexNeighbors (String vertexId , List <String > edgeCollections , Direction direction ) {
454+ public Iterator <VertexData > getVertexNeighbors (ArangoDBId vertexId , List <String > edgeCollections , Direction direction ) {
494455 logger .debug ("Get vertex {}:{} Neighbors, in {}, from collections {}" , vertexId , direction , graph .name (), edgeCollections );
495456 Map <String , Object > bindVars = new HashMap <>();
496457 bindVars .put ("start" , vertexId );
@@ -501,7 +462,7 @@ public Iterator<VertexData> getVertexNeighbors(String vertexId, List<String> edg
501462 return executeAqlQuery (query , bindVars , null , VertexData .class );
502463 }
503464
504- public Iterator <EdgeData > getVertexEdges (String vertexId , List <String > edgeCollections , Direction direction ) {
465+ public Iterator <EdgeData > getVertexEdges (ArangoDBId vertexId , List <String > edgeCollections , Direction direction ) {
505466 logger .debug ("Get vertex {}:{} Edges, in {}, from collections {}" , vertexId , direction , graph .name (), edgeCollections );
506467 Map <String , Object > bindVars = new HashMap <>();
507468 bindVars .put ("start" , vertexId );
0 commit comments