public static Direction parseDirection(String direction) { if (direction == null || direction.isEmpty()) { return Direction.BOTH; } try { return Direction.valueOf(direction); } catch (Exception e) { throw new IllegalArgumentException(String.format( "Direction value must be in [OUT, IN, BOTH], " + "but got '%s'", direction)); } }
@Override public void loadState(final Graph graph, final Configuration configuration) { direction = Direction.valueOf(configuration.getString(DIRECTION_CFG_KEY)); switch (direction) { case IN: this.messageScope = this.inMessageScope; break; case OUT: this.messageScope = this.outMessageScope; break; case BOTH: this.messageScope = this.bothMessageScope; break; default: throw new IllegalStateException("Should not reach this point!"); } }
@Override public void loadState(final Graph graph, final Configuration configuration) { direction = Direction.valueOf(configuration.getString(DIRECTION_CFG_KEY)); switch (direction) { case IN: this.messageScope = this.inMessageScope; break; case OUT: this.messageScope = this.outMessageScope; break; case BOTH: this.messageScope = this.bothMessageScope; break; default: throw new IllegalStateException("Should not reach this point!"); } }
private EdgeSchema getEdgeSchema(JSONObject edgeJson) throws JSONException { Direction direction = Direction.valueOf(edgeJson.optString("direction")); return new InnerRowEdgeSchema(this, direction, edgeJson, table, graph); } }
private EdgeSchema getEdgeSchema(JSONObject edgeJson) throws JSONException { Direction direction = Direction.valueOf(edgeJson.optString("direction")); return new InnerEdgeRestSchema(edgeJson, this.graph, this.baseUrl, this.templateHolder, this.resultPath, this.opTranslator, this.maxResultSize, this.complexTranslator, this.valuesToString, direction, this, this.resource); }
private EdgeSchema getEdgeSchema(JSONObject edgeJson) throws JSONException { String path = edgeJson.optString("path", null); Direction direction = Direction.valueOf(edgeJson.optString("direction")); if(path == null) return new InnerEdgeSchema(this, direction, index, type, edgeJson, client, graph); return new NestedEdgeSchema(this, direction, index, type, path, edgeJson, client, graph); }
@Override public List<Map<String, Object>> getEdges(Long executionID, Integer vertexID, String edgeDirection, String edgeLabel, Boolean dedup) { GraphContext graphContext = getGraph(executionID); if (vertexID == null) throw new IllegalArgumentException("ID not specified"); Vertex vertex = graphContext.getGraph().vertices(vertexID).next(); List<Map<String, Object>> vertices = new ArrayList<>(); Iterator<Vertex> relatedVertices = vertex.vertices(Direction.valueOf(edgeDirection), edgeLabel); while (relatedVertices.hasNext()) { Vertex v = relatedVertices.next(); vertices.add(convertToMap(executionID, v, 0, dedup)); } return vertices; }