@Override public Iterator<Property> properties(String... propertyKeys) { return propertyIterator(propertyKeys); }
@Override public Collection<UniEdge> fromVertex(UniVertex parentVertex, Map<String, Object> fields) { Map edgeProperties = this.getProperties(fields); Object inVertex; Object outVertex; if (edgeProperties == null) return null; outVertex = this.outVertexSchema.equals(this.parentVertexSchema) ? parentVertex : this.outVertexSchema.createElement(fields); inVertex = this.outVertexSchema.equals(this.parentVertexSchema) ? parentVertex : this.inVertexSchema.createElement(fields); if (inVertex == null || outVertex == null) return null; UniEdge uniEdge = new UniEdge(edgeProperties, (Vertex)outVertex, (Vertex)inVertex, this, this.graph); return Collections.singleton(uniEdge); } }
@Override public Edge addEdge(AddEdgeQuery uniQuery) { UniEdge edge = new UniEdge(uniQuery.getProperties(), uniQuery.getOutVertex(), uniQuery.getInVertex(), null, this.graph); try { if (this.insert(edgeSchemas, edge)) return edge; } catch (DataAccessException ex) { throw Graph.Exceptions.edgeWithIdAlreadyExists(edge.id()); } return null; }
@Override public <V> Property<V> property(String key, V value) { UniProperty<V> vertexProperty = (UniProperty<V>) addPropertyLocal(key, value); PropertyQuery<UniElement> propertyQuery = new PropertyQuery<>(this, vertexProperty, PropertyQuery.Action.Add, null); this.graph.getControllerManager().getControllers(PropertyQuery.PropertyController.class).forEach(controller -> controller.property(propertyQuery)); return vertexProperty; }
@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 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 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); }
@Override public Edge addEdge(AddEdgeQuery uniQuery) { UniEdge edge = new UniEdge(uniQuery.getProperties(), uniQuery.getOutVertex(), uniQuery.getInVertex(), null, graph); // try { if (index(this.edgeSchemas, edge, true)) return edge; // } catch (DocumentAlreadyExistsException ex) { // logger.warn("Document already exists in elastic", ex); // throw Graph.Exceptions.edgeWithIdAlreadyExists(edge.id()); // } return null; }
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 Edge addEdge(AddEdgeQuery uniQuery) { UniEdge edge = new UniEdge(uniQuery.getProperties(), uniQuery.getOutVertex(), uniQuery.getInVertex(), null, graph); for (RestEdgeSchema edgeSchema : edgeSchemas) { try { BaseRequest baseRequest = edgeSchema.addElement(edge); if (baseRequest == null) return edge; baseRequest.asJson(); } catch (UnirestException e) { e.printStackTrace(); } catch (NoSuchElementException e) { continue; } } return edge; }