@Override public String toString() { return "AbstractRowSchema{" + "table='" + table + '\'' + "} " + super.toString(); } }
@Override public Map<String, Object> toFields(E element) { return getFields(element); }
private void addRecursive(Set<ElementSchema> result, Set<ElementSchema> schemas) { schemas.forEach(schema -> { if(result.contains(schema)) return; result.add(schema); Set childSchemas = schema.getChildSchemas(); addRecursive(result, childSchemas); }); }
@Override default Collection<Vertex> fromFields(Map<String, Object> fields) { Vertex element = createElement(fields); if(element == null) return null; return Collections.singleton(element); }
protected PredicatesHolder getVertexPredicates(List<Vertex> vertices, Direction direction) { PredicatesHolder outPredicates = this.outVertexSchema.toPredicates(vertices); PredicatesHolder inPredicates = this.inVertexSchema.toPredicates(vertices); if(direction.equals(Direction.OUT)) return outPredicates; if(direction.equals(Direction.IN)) return inPredicates; return PredicatesHolderFactory.or(inPredicates, outPredicates); }
private <E extends Element> Set<JdbcSchema<E>> collectSchemas(Set<? extends ElementSchema> schemas) { Set<JdbcSchema<E>> rowSchemas = new HashSet<>(); schemas.forEach(schema -> { if (schema instanceof JdbcSchema) { rowSchemas.add((JdbcSchema<E>) schema); Set<JdbcSchema<E>> childSchemas = collectSchemas(schema.getChildSchemas()); rowSchemas.addAll(childSchemas); } }); return rowSchemas; }
@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; }
public Set<ElementSchema> get(Boolean recursive) { if(!recursive) return schemas; Set<ElementSchema> result = new HashSet<>(); addRecursive(result, this.schemas); return result; }
@Override protected Edge create(Map<String, Object> fields) { Map<String, Object> properties = getProperties(fields); if (properties == null) return null; return new UniEdge(properties, outVertexSchema.createElement(fields), inVertexSchema.createElement(fields), this, graph); }
protected PredicatesHolder getVertexPredicates(List<Vertex> vertices, Direction direction) { PredicatesHolder outPredicates = this.outVertexSchema.toPredicates(vertices); PredicatesHolder inPredicates = this.inVertexSchema.toPredicates(vertices); if(direction.equals(Direction.OUT) && outPredicates.notAborted()) return outPredicates; if(direction.equals(Direction.IN) && inPredicates.notAborted()) return inPredicates; if (outPredicates.notAborted() && inPredicates.notAborted()) return PredicatesHolderFactory.or(inPredicates, outPredicates); else if (outPredicates.isAborted()) return inPredicates; else if (inPredicates.isAborted()) return outPredicates; else return PredicatesHolderFactory.abort(); }
private Set<DocumentSchema> collectSchemas(Set<? extends ElementSchema> schemas) { Set<DocumentSchema> docSchemas = new HashSet<>(); schemas.forEach(schema -> { if (schema instanceof DocumentSchema) { docSchemas.add((DocumentSchema) schema); Set<DocumentSchema> childSchemas = collectSchemas(schema.getChildSchemas()); docSchemas.addAll(childSchemas); } }); return docSchemas; }
@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 Collection<Edge> fromFields(Map<String, Object> fields) { Map<String, Object> edgeProperties = getProperties(fields); if(edgeProperties == null) return null; Vertex outVertex = outVertexSchema.createElement(fields); if(outVertex == null) return null; Vertex inVertex = inVertexSchema.createElement(fields); if(inVertex == null) return null; UniEdge uniEdge = new UniEdge(edgeProperties, outVertex, inVertex, this, graph); return Collections.singleton(uniEdge); }
protected PredicatesHolder getVertexPredicates(List<Vertex> vertices, Direction direction) { PredicatesHolder outPredicates = this.outVertexSchema.toPredicates(vertices); PredicatesHolder inPredicates = this.inVertexSchema.toPredicates(vertices); if (direction.equals(Direction.OUT) && outPredicates.notAborted()) return outPredicates; if (direction.equals(Direction.IN) && inPredicates.notAborted()) return inPredicates; if (outPredicates.notAborted() && inPredicates.notAborted()) return PredicatesHolderFactory.or(inPredicates, outPredicates); else if (outPredicates.isAborted()) return inPredicates; else if (inPredicates.isAborted()) return outPredicates; else return PredicatesHolderFactory.abort(); } }
private Set<RestSchema> collectSchemas(Set<? extends ElementSchema> schemas) { Set<RestSchema> docSchemas = new HashSet<>(); schemas.forEach(schema -> { if (schema instanceof RestSchema) { docSchemas.add((RestSchema) schema); Set<RestSchema> childSchemas = collectSchemas(schema.getChildSchemas()); docSchemas.addAll(childSchemas); } }); return docSchemas; }
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 Collection<Edge> fromFields(Map<String, Object> fields) { Map<String, Object> edgeProperties = getProperties(fields); if(edgeProperties == null) return null; Vertex outVertex = outVertexSchema.createElement(fields); if(outVertex == null) return null; Vertex inVertex = inVertexSchema.createElement(fields); if(inVertex == null) return null; UniEdge uniEdge = new UniEdge(edgeProperties, outVertex, inVertex, this, graph); return Collections.singleton(uniEdge); }
@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); }
private UniEdge createEdge(Vertex parentVertex, Map<String, Object> edgeFields) { Map<String, Object> edgeProperties = getProperties(edgeFields); if (edgeProperties == null) return null; Vertex childVertex = childVertexSchema.createElement(edgeFields); if (childVertex == null) return null; UniEdge edge = new UniEdge(edgeProperties, parentDirection.equals(Direction.OUT) ? parentVertex : childVertex, parentDirection.equals(Direction.IN) ? parentVertex : childVertex, this, graph); return edge; }
@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); }