@Override public Set<String> toFields(Set<String> propertyKeys) { Set<String> fields = super.toFields(propertyKeys); Set<String> outFields = outVertexSchema.toFields(propertyKeys); fields.addAll(outFields); Set<String> inFields = inVertexSchema.toFields(propertyKeys); fields.addAll(inFields); return fields; }
@Override public Set<String> toFields(Set<String> propertyKeys) { Set<String> fields = super.toFields(propertyKeys); Set<String> outFields = outVertexSchema.toFields(propertyKeys); fields.addAll(outFields); Set<String> inFields = inVertexSchema.toFields(propertyKeys); fields.addAll(inFields); return fields; }
@Override protected Set<String> toFields() { Set<String> edgeFields = super.toFields(); Set<String> outVertexFields = outVertexSchema instanceof RestVertex ? ((RestVertex) outVertexSchema).toFields() : outVertexSchema.toFields(Collections.emptySet()); Set<String> inVertexFields = inVertexSchema instanceof RestVertex ? ((RestVertex) inVertexSchema).toFields() : inVertexSchema.toFields(Collections.emptySet()); return Stream.of(edgeFields, outVertexFields, inVertexFields).flatMap(Collection::stream).collect(Collectors.toSet()); }
@Override public Set<String> toFields(Set<String> propertyKeys) { Set<String> fields = super.toFields(propertyKeys).stream() .map(key -> path + "." + key).collect(Collectors.toSet()); Set<String> parentFields = parentVertexSchema.toFields(propertyKeys); fields.addAll(parentFields); Set<String> childFields = childVertexSchema.toFields(propertyKeys); fields.addAll(childFields); return fields; }
private Map<String, Object> getVertexFields(Edge edge, Direction direction) { VertexSchema vertexSchema = direction.equals(parentDirection) ? parentVertexSchema : childVertexSchema; Vertex parent = edge.vertices(direction).next(); return vertexSchema.toFields(parent); }
@Override public BaseRequest addElement(Edge element) throws NoSuchElementException{ Map<String, Object> outVertexFields = outVertexSchema.toFields(element.outVertex()); Map<String, Object> inVertexFields = inVertexSchema.toFields(element.inVertex()); Map<String, Object> fields = toFields(element); if (fields == null || outVertexFields == null || inVertexFields == null) throw new NoSuchElementException(); Map<String, Object> stringObjectMap = Stream.of(outVertexFields.entrySet(), inVertexFields.entrySet(), fields.entrySet()).flatMap(Collection::stream) .map(entry -> { String[] split = entry.getKey().split("\\."); return new HashMap.SimpleEntry<>(split[split.length - 1], entry.getValue()); }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); Map<String, Object> urlMap = new HashMap<>(); urlMap.putAll(stringObjectMap); urlMap.put("resource", resource); return insertElement(urlMap, stringObjectMap); }
@Override public Map<String, Object> toFields(Edge edge) { Map<String, Object> edgeFields = getFields(edge); Map<String, Object> inFields = inVertexSchema.toFields(edge.inVertex()); Map<String, Object> outFields = outVertexSchema.toFields(edge.outVertex()); return ConversionUtils.merge(Lists.newArrayList(edgeFields, inFields, outFields), this::mergeFields, false); }
@Override public Map<String, Object> toFields(Edge edge) { Map<String, Object> edgeFields = getFields(edge); Map<String, Object> inFields = inVertexSchema.toFields(edge.inVertex()); Map<String, Object> outFields = outVertexSchema.toFields(edge.outVertex()); return ConversionUtils.merge(Lists.newArrayList(edgeFields, inFields, outFields), this::mergeFields, false); }