Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bumped to support Graph.query().

  • Loading branch information...
commit 60d7006e90e0edd2df690fe1478eda2a0ec224a8 1 parent 120a24e
@okram okram authored
View
2  LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2009-2012, TinkerPop [http://tinkerpop.com]
+Copyright (c) 2009-2013, TinkerPop [http://tinkerpop.com]
All rights reserved.
Redistribution and use in source and binary forms, with or without
View
5 src/main/java/com/tinkerpop/furnace/util/QueryHelper.java
@@ -2,6 +2,7 @@
import com.tinkerpop.blueprints.Query;
import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.blueprints.VertexQuery;
import com.tinkerpop.furnace.util.QueryTemplate.HasContainer;
/**
@@ -9,8 +10,8 @@
*/
public class QueryHelper {
- public static Query createQuery(final Vertex vertex, final QueryTemplate queryTemplate) {
- final Query query = vertex.query();
+ public static VertexQuery createQuery(final Vertex vertex, final QueryTemplate queryTemplate) {
+ final VertexQuery query = vertex.query();
for (final HasContainer hasContainer : queryTemplate.hasContainers) {
if (hasContainer.compare.equals(Query.Compare.EQUAL)) {
query.has(hasContainer.key, hasContainer.value);
View
160 src/main/java/com/tinkerpop/furnace/wrappers/DerivedGraph.java
@@ -1,91 +1,97 @@
package com.tinkerpop.furnace.wrappers;
-import java.util.HashMap;
-import java.util.Map;
-
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Features;
import com.tinkerpop.blueprints.Graph;
+import com.tinkerpop.blueprints.GraphQuery;
import com.tinkerpop.blueprints.Vertex;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class DerivedGraph implements Graph {
- private final Graph rawGraph;
- protected final Map<String, Derivation> derivations = new HashMap<String, Derivation>();
-
- public DerivedGraph(final Graph rawGraph) {
- this.rawGraph = rawGraph;
- }
-
- public void addDerivation(final String label, final Derivation derivation) {
- this.derivations.put(label, derivation);
- }
-
- public Derivation getDerivation(final String label) {
- return this.derivations.get(label);
- }
-
- @Override
- public void shutdown() {
- this.rawGraph.shutdown();
- }
-
- @Override
- public Iterable<Vertex> getVertices(final String key, final Object value) {
- return this.rawGraph.getVertices(key, value);
- }
-
- @Override
- public Iterable<Edge> getEdges(final String key, final Object value) {
- return this.rawGraph.getEdges(key, value);
- }
-
- @Override
- public Features getFeatures() {
- return this.rawGraph.getFeatures();
- }
-
- @Override
- public Vertex addVertex(final Object id) {
- return new DerivedVertex(this.rawGraph.addVertex(id), this);
- }
-
- @Override
- public void removeVertex(final Vertex vertex) {
- this.rawGraph.removeVertex(vertex);
- }
-
- @Override
- public Vertex getVertex(final Object id) {
- return new DerivedVertex(this.rawGraph.getVertex(id), this);
- }
-
- @Override
- public Iterable<Vertex> getVertices() {
- return this.rawGraph.getVertices();
- }
-
- @Override
- public Iterable<Edge> getEdges() {
- return this.rawGraph.getEdges();
- }
-
- @Override
- public Edge getEdge(final Object id) {
- return this.rawGraph.getEdge(id);
- }
-
- @Override
- public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) {
- return this.rawGraph.addEdge(id, outVertex, inVertex, label);
- }
-
- @Override
- public void removeEdge(final Edge edge) {
- this.rawGraph.removeEdge(edge);
- }
+ private final Graph rawGraph;
+ protected final Map<String, Derivation> derivations = new HashMap<String, Derivation>();
+
+ public DerivedGraph(final Graph rawGraph) {
+ this.rawGraph = rawGraph;
+ }
+
+ public void addDerivation(final String label, final Derivation derivation) {
+ this.derivations.put(label, derivation);
+ }
+
+ public Derivation getDerivation(final String label) {
+ return this.derivations.get(label);
+ }
+
+ @Override
+ public void shutdown() {
+ this.rawGraph.shutdown();
+ }
+
+ @Override
+ public Iterable<Vertex> getVertices(final String key, final Object value) {
+ return this.rawGraph.getVertices(key, value);
+ }
+
+ @Override
+ public Iterable<Edge> getEdges(final String key, final Object value) {
+ return this.rawGraph.getEdges(key, value);
+ }
+
+ @Override
+ public Features getFeatures() {
+ return this.rawGraph.getFeatures();
+ }
+
+ @Override
+ public Vertex addVertex(final Object id) {
+ return new DerivedVertex(this.rawGraph.addVertex(id), this);
+ }
+
+ @Override
+ public void removeVertex(final Vertex vertex) {
+ this.rawGraph.removeVertex(vertex);
+ }
+
+ @Override
+ public Vertex getVertex(final Object id) {
+ return new DerivedVertex(this.rawGraph.getVertex(id), this);
+ }
+
+ @Override
+ public Iterable<Vertex> getVertices() {
+ return this.rawGraph.getVertices();
+ }
+
+ @Override
+ public Iterable<Edge> getEdges() {
+ return this.rawGraph.getEdges();
+ }
+
+ @Override
+ public Edge getEdge(final Object id) {
+ return this.rawGraph.getEdge(id);
+ }
+
+ @Override
+ public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) {
+ return this.rawGraph.addEdge(id, outVertex, inVertex, label);
+ }
+
+ @Override
+ public void removeEdge(final Edge edge) {
+ this.rawGraph.removeEdge(edge);
+ }
+
+ @Override
+ public GraphQuery query() {
+ return this.rawGraph.query();
+ }
}
View
173 src/main/java/com/tinkerpop/furnace/wrappers/DerivedVertex.java
@@ -1,101 +1,100 @@
package com.tinkerpop.furnace.wrappers;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Query;
import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.util.DefaultQuery;
+import com.tinkerpop.blueprints.VertexQuery;
import com.tinkerpop.blueprints.util.MultiIterable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class DerivedVertex implements Vertex {
- private final DerivedGraph graph;
- protected final Vertex rawVertex;
-
- public DerivedVertex(final Vertex rawVertex, final DerivedGraph graph) {
- this.rawVertex = rawVertex;
- this.graph = graph;
- }
-
- @Override
- public Iterable<Edge> getEdges(final Direction direction, final String... labels) {
- return new ArrayList<Edge>();
- }
-
- @Override
- public Iterable<Vertex> getVertices(final Direction direction, final String... labels) {
- final List<Iterable<Vertex>> vertices = new ArrayList<Iterable<Vertex>>();
- for (final String label : labels) {
- final Derivation derivation = this.graph.getDerivation(label);
- if (null != derivation) {
- vertices.add(derivation.adjacent(this));
- } else {
- vertices.add(this.rawVertex.getVertices(direction, label));
- }
- }
- return new MultiIterable<Vertex>(vertices);
- }
-
- @Override
- public Query query() {
- return new DefaultQuery(this);
- }
-
- @Override
- public Object getId() {
- return this.rawVertex.getId();
- }
-
- @Override
- public Object getProperty(final String key) {
- return this.rawVertex.getProperty(key);
- }
-
- @Override
- public void setProperty(final String key, final Object value) {
- this.rawVertex.setProperty(key, value);
- }
-
- @Override
- public Object removeProperty(final String key) {
- return this.rawVertex.removeProperty(key);
- }
-
- @Override
- public Set<String> getPropertyKeys() {
- return this.rawVertex.getPropertyKeys();
- }
-
- @Override
- public int hashCode() {
- return this.rawVertex.hashCode();
- }
-
- @Override
- public String toString() {
- return this.rawVertex.toString();
- }
-
- @Override
- public boolean equals(Object object) {
- return (object instanceof Vertex) && ((Vertex) object).getId().equals(this.getId());
- }
-
- @Override
- public void remove() {
- this.rawVertex.remove();
- }
-
- @Override
- public Edge addEdge(String label, Vertex vertex) {
- return this.rawVertex.addEdge(label, vertex);
- }
+ private final DerivedGraph graph;
+ protected final Vertex rawVertex;
+
+ public DerivedVertex(final Vertex rawVertex, final DerivedGraph graph) {
+ this.rawVertex = rawVertex;
+ this.graph = graph;
+ }
+
+ @Override
+ public Iterable<Edge> getEdges(final Direction direction, final String... labels) {
+ return new ArrayList<Edge>();
+ }
+
+ @Override
+ public Iterable<Vertex> getVertices(final Direction direction, final String... labels) {
+ final List<Iterable<Vertex>> vertices = new ArrayList<Iterable<Vertex>>();
+ for (final String label : labels) {
+ final Derivation derivation = this.graph.getDerivation(label);
+ if (null != derivation) {
+ vertices.add(derivation.adjacent(this));
+ } else {
+ vertices.add(this.rawVertex.getVertices(direction, label));
+ }
+ }
+ return new MultiIterable<Vertex>(vertices);
+ }
+
+ @Override
+ public VertexQuery query() {
+ return this.rawVertex.query();
+ }
+
+ @Override
+ public Object getId() {
+ return this.rawVertex.getId();
+ }
+
+ @Override
+ public Object getProperty(final String key) {
+ return this.rawVertex.getProperty(key);
+ }
+
+ @Override
+ public void setProperty(final String key, final Object value) {
+ this.rawVertex.setProperty(key, value);
+ }
+
+ @Override
+ public Object removeProperty(final String key) {
+ return this.rawVertex.removeProperty(key);
+ }
+
+ @Override
+ public Set<String> getPropertyKeys() {
+ return this.rawVertex.getPropertyKeys();
+ }
+
+ @Override
+ public int hashCode() {
+ return this.rawVertex.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return this.rawVertex.toString();
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return (object instanceof Vertex) && ((Vertex) object).getId().equals(this.getId());
+ }
+
+ @Override
+ public void remove() {
+ this.rawVertex.remove();
+ }
+
+ @Override
+ public Edge addEdge(String label, Vertex vertex) {
+ return this.rawVertex.addEdge(label, vertex);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.