Skip to content

Commit 98854a1

Browse files
author
Achim Brandt
committed
updates for traversal updates
1 parent 80a7584 commit 98854a1

File tree

6 files changed

+519
-0
lines changed

6 files changed

+519
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Copyright 2004-2015 triAGENS GmbH, Cologne, Germany
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
* Copyright holder is triAGENS GmbH, Cologne, Germany
16+
*
17+
* @author a-brandt
18+
* @author Copyright 2015, triAGENS GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb;
22+
23+
import com.arangodb.entity.TraversalEntity;
24+
import com.arangodb.impl.BaseDriverInterface;
25+
26+
public interface InternalTraversalDriver extends BaseDriverInterface {
27+
28+
public enum Direction {
29+
OUTBOUND, INBOUND, ANY
30+
}
31+
32+
public enum Strategy {
33+
DEPTHFIRST, BREADTHFIRST
34+
}
35+
36+
public enum Order {
37+
PREORDER, POSTORDER
38+
}
39+
40+
public enum ItemOrder {
41+
FORWARD, BACKWARD
42+
}
43+
44+
public enum Uniqueness {
45+
NONE, GLOBAL, PATH
46+
}
47+
48+
<V, E> TraversalEntity<V, E> getTraversal(
49+
String databaseName,
50+
String graphName,
51+
String edgeCollection,
52+
String startVertex,
53+
Class<V> vertexClazz,
54+
Class<E> edgeClass,
55+
String filter,
56+
Long minDepth,
57+
Long maxDepth,
58+
String visitor,
59+
Direction direction,
60+
String init,
61+
String expander,
62+
String sort,
63+
Strategy strategy,
64+
Order order,
65+
ItemOrder itemOrder,
66+
Uniqueness verticesUniqueness,
67+
Uniqueness edgesUniqueness,
68+
Long maxIterations) throws ArangoException;
69+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Copyright 2004-2015 triAGENS GmbH, Cologne, Germany
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
* Copyright holder is triAGENS GmbH, Cologne, Germany
16+
*
17+
* @author a-brandt
18+
* @author Copyright 2015, triAGENS GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.entity;
22+
23+
/**
24+
* Licensed under the Apache License, Version 2.0 (the "License");
25+
* you may not use this file except in compliance with the License.
26+
* You may obtain a copy of the License at
27+
*
28+
* http://www.apache.org/licenses/LICENSE-2.0
29+
*
30+
* Unless required by applicable law or agreed to in writing, software
31+
* distributed under the License is distributed on an "AS IS" BASIS,
32+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33+
* See the License for the specific language governing permissions and
34+
* limitations under the License.
35+
*
36+
* Copyright holder is triAGENS GmbH, Cologne, Germany
37+
*
38+
* @author a-brandt
39+
* @author Copyright 2015, triAGENS GmbH, Cologne, Germany
40+
*/
41+
42+
import java.util.List;
43+
44+
import com.arangodb.entity.marker.VertexEntity;
45+
46+
/**
47+
* @author a-brandt
48+
*/
49+
public class PathEntity<V, E> extends BaseEntity {
50+
51+
/**
52+
* List of edges.
53+
*/
54+
private List<EdgeEntity<E>> edges;
55+
56+
/**
57+
* List of vertices.
58+
*/
59+
private List<VertexEntity<V>> vertices;
60+
61+
public List<EdgeEntity<E>> getEdges() {
62+
return edges;
63+
}
64+
65+
public void setEdges(List<EdgeEntity<E>> edges) {
66+
this.edges = edges;
67+
}
68+
69+
public List<VertexEntity<V>> getVertices() {
70+
return vertices;
71+
}
72+
73+
public void setVertices(List<VertexEntity<V>> vertices) {
74+
this.vertices = vertices;
75+
}
76+
77+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright 2004-2015 triAGENS GmbH, Cologne, Germany
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
* Copyright holder is triAGENS GmbH, Cologne, Germany
16+
*
17+
* @author a-brandt
18+
* @author Copyright 2015, triAGENS GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.entity;
22+
23+
/**
24+
* @author a-brandt
25+
*/
26+
public class TraversalEntity<V, E> extends BaseEntity {
27+
28+
/**
29+
* Visited vertices and edges.
30+
*/
31+
private VisitedEntity<V, E> visited;
32+
33+
public VisitedEntity<V, E> getVisited() {
34+
return visited;
35+
}
36+
37+
public void setVisited(VisitedEntity<V, E> visited) {
38+
this.visited = visited;
39+
}
40+
41+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Copyright 2004-2015 triAGENS GmbH, Cologne, Germany
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
* Copyright holder is triAGENS GmbH, Cologne, Germany
16+
*
17+
* @author a-brandt
18+
* @author Copyright 2015, triAGENS GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.entity;
22+
23+
import java.util.List;
24+
25+
import com.arangodb.entity.marker.VertexEntity;
26+
27+
/**
28+
* @author a-brandt
29+
*/
30+
public class VisitedEntity<V, E> extends BaseEntity {
31+
32+
/**
33+
* List of vertices.
34+
*/
35+
private List<VertexEntity<V>> vertices;
36+
37+
/**
38+
* List of paths.
39+
*/
40+
private List<PathEntity<V, E>> paths;
41+
42+
public List<VertexEntity<V>> getVertices() {
43+
return vertices;
44+
}
45+
46+
public void setVertices(List<VertexEntity<V>> vertices) {
47+
this.vertices = vertices;
48+
}
49+
50+
public List<PathEntity<V, E>> getPaths() {
51+
return paths;
52+
}
53+
54+
public void setPaths(List<PathEntity<V, E>> paths) {
55+
this.paths = paths;
56+
}
57+
58+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/**
2+
* Copyright 2004-2015 triAGENS GmbH, Cologne, Germany
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
* Copyright holder is triAGENS GmbH, Cologne, Germany
16+
*
17+
* @author a-brandt
18+
* @author Copyright 2015, triAGENS GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.impl;
22+
23+
import java.util.HashMap;
24+
import java.util.Map;
25+
26+
import com.arangodb.ArangoConfigure;
27+
import com.arangodb.ArangoException;
28+
import com.arangodb.entity.EntityFactory;
29+
import com.arangodb.entity.TraversalEntity;
30+
import com.arangodb.http.HttpManager;
31+
import com.arangodb.http.HttpResponseEntity;
32+
33+
/**
34+
* @author a-brandt
35+
*/
36+
public class InternalTraversalDriverImpl extends BaseArangoDriverImpl implements com.arangodb.InternalTraversalDriver {
37+
38+
InternalTraversalDriverImpl(ArangoConfigure configure, HttpManager httpManager) {
39+
super(configure, httpManager);
40+
}
41+
42+
@Override
43+
public <V, E> TraversalEntity<V, E> getTraversal(
44+
String databaseName,
45+
String graphName,
46+
String edgeCollection,
47+
String startVertex,
48+
Class<V> vertexClazz,
49+
Class<E> edgeClass,
50+
String filter,
51+
Long minDepth,
52+
Long maxDepth,
53+
String visitor,
54+
Direction direction,
55+
String init,
56+
String expander,
57+
String sort,
58+
Strategy strategy,
59+
Order order,
60+
ItemOrder itemOrder,
61+
Uniqueness verticesUniqueness,
62+
Uniqueness edgesUniqueness,
63+
Long maxIterations) throws ArangoException {
64+
65+
Map<String, Object> object = new HashMap<String, Object>();
66+
67+
if (graphName != null) {
68+
object.put("graphName", graphName);
69+
}
70+
if (edgeCollection != null) {
71+
object.put("edgeCollection", edgeCollection);
72+
}
73+
if (startVertex != null) {
74+
object.put("startVertex", startVertex);
75+
}
76+
if (filter != null) {
77+
object.put("filter", filter);
78+
}
79+
if (minDepth != null) {
80+
object.put("minDepth", minDepth);
81+
}
82+
if (maxDepth != null) {
83+
object.put("maxDepth", maxDepth);
84+
}
85+
if (visitor != null) {
86+
object.put("visitor", visitor);
87+
}
88+
if (direction != null) {
89+
object.put("direction", direction.toString().toLowerCase());
90+
}
91+
if (init != null) {
92+
object.put("init", init);
93+
}
94+
if (expander != null) {
95+
object.put("expander", expander);
96+
}
97+
if (sort != null) {
98+
object.put("sort", sort);
99+
}
100+
if (strategy != null) {
101+
object.put("strategy", strategy.toString().toLowerCase());
102+
}
103+
if (order != null) {
104+
object.put("order", order.toString().toLowerCase());
105+
}
106+
if (itemOrder != null) {
107+
object.put("itemOrder", itemOrder.toString().toLowerCase());
108+
}
109+
if (verticesUniqueness != null || edgesUniqueness != null) {
110+
Map<String, Object> uniqueness = new HashMap<String, Object>();
111+
112+
if (verticesUniqueness != null) {
113+
uniqueness.put("vertices", verticesUniqueness.toString().toLowerCase());
114+
}
115+
if (edgesUniqueness != null) {
116+
uniqueness.put("edges", edgesUniqueness.toString().toLowerCase());
117+
}
118+
119+
object.put("uniqueness", uniqueness);
120+
}
121+
if (maxIterations != null) {
122+
object.put("maxIterations", maxIterations);
123+
}
124+
125+
String body = EntityFactory.toJsonString(object);
126+
127+
HttpResponseEntity response = httpManager.doPost(createEndpointUrl(baseUrl, databaseName, "/_api/traversal"),
128+
null, body);
129+
130+
// TraversalEntity<V, E> traversal = createEntity(response,
131+
// TraversalEntity.class);
132+
//
133+
// return traversal;
134+
135+
return null;
136+
}
137+
138+
}

0 commit comments

Comments
 (0)