com.tinkerpop.blueprints.impls.rexster.RexsterVertexQuery Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blueprints-rexster-graph Show documentation
Show all versions of blueprints-rexster-graph Show documentation
Blueprints property graph implementation for Rexster
package com.tinkerpop.blueprints.impls.rexster;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.util.DefaultVertexQuery;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/**
* RexsterQuery makes no requests until edges(), vertices(), count() or vertexIds() is called.
*
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public class RexsterVertexQuery extends DefaultVertexQuery {
public final String baseUri;
public final RexsterGraph graph;
public RexsterVertexQuery(final String uri, final RexsterGraph graph) {
super(null);
this.baseUri = uri;
this.graph = graph;
}
public Iterable edges() {
final String directionReturnToken;
if (this.direction == Direction.IN) {
directionReturnToken = RexsterTokens.SLASH_INE;
} else if (this.direction == Direction.OUT) {
directionReturnToken = RexsterTokens.SLASH_OUTE;
} else {
directionReturnToken = RexsterTokens.SLASH_BOTHE;
}
return new RexsterEdgeIterable(buildUri(directionReturnToken), graph);
}
public Iterable vertices() {
final String directionReturnToken;
if (this.direction == Direction.IN) {
directionReturnToken = RexsterTokens.SLASH_IN;
} else if (this.direction == Direction.OUT) {
directionReturnToken = RexsterTokens.SLASH_OUT;
} else {
directionReturnToken = RexsterTokens.SLASH_BOTH;
}
return new RexsterVertexIterable(buildUri(directionReturnToken), graph);
}
public long count() {
final String directionReturnToken;
if (this.direction == Direction.IN) {
directionReturnToken = RexsterTokens.SLASH_INCOUNT;
} else if (this.direction == Direction.OUT) {
directionReturnToken = RexsterTokens.SLASH_OUTCOUNT;
} else {
directionReturnToken = RexsterTokens.SLASH_BOTHCOUNT;
}
final JSONObject jsonObject = RestHelper.get(buildUri(directionReturnToken));
return jsonObject.optLong(RexsterTokens.TOTAL_SIZE);
}
public Object vertexIds() {
final String directionReturnToken;
if (this.direction == Direction.IN) {
directionReturnToken = RexsterTokens.SLASH_INIDS;
} else if (this.direction == Direction.OUT) {
directionReturnToken = RexsterTokens.SLASH_OUTIDS;
} else {
directionReturnToken = RexsterTokens.SLASH_BOTHIDS;
}
final JSONArray jsonArray = RestHelper.getResultArray(buildUri(directionReturnToken));
final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy