te.property(rt.name(), next.value); } else { throw new RuntimeException("Metaedges are not supported");
@Override public <V> Property<V> property(final String key, final V value) { if (this.removed) throw elementAlreadyRemoved(Edge.class, id); ElementHelper.validateProperty(key, value); final Property oldProperty = super.property(key); final Property<V> newProperty = new TinkerProperty<>(this, key, value); if (null == this.properties) this.properties = new HashMap<>(); this.properties.put(key, newProperty); TinkerHelper.autoUpdateIndex(this, key, value, oldProperty.isPresent() ? oldProperty.value() : null); return newProperty; }
@Override public void remove() { final TinkerVertex outVertex = (TinkerVertex) this.outVertex; final TinkerVertex inVertex = (TinkerVertex) this.inVertex; if (null != outVertex && null != outVertex.outEdges) { final Set<Edge> edges = outVertex.outEdges.get(this.label()); if (null != edges) edges.remove(this); } if (null != inVertex && null != inVertex.inEdges) { final Set<Edge> edges = inVertex.inEdges.get(this.label()); if (null != edges) edges.remove(this); } TinkerHelper.removeElementIndex(this); ((TinkerGraph) this.graph()).edges.remove(this.id()); this.properties = null; this.removed = true; }
public static void removeElementIndex(final TinkerEdge edge) { final TinkerGraph graph = (TinkerGraph) edge.graph(); if (graph.edgeIndex != null) graph.edgeIndex.removeElement(edge); }
protected static Edge addEdge(final TinkerGraph graph, final TinkerVertex outVertex, final TinkerVertex inVertex, final String label, final Object... keyValues) { ElementHelper.validateLabel(label); ElementHelper.legalPropertyKeyValueArray(keyValues); Object idValue = graph.edgeIdManager.convert(ElementHelper.getIdValue(keyValues).orElse(null)); final Edge edge; if (null != idValue) { if (graph.edges.containsKey(idValue)) throw Graph.Exceptions.edgeWithIdAlreadyExists(idValue); } else { idValue = graph.edgeIdManager.getNextId(graph); } edge = new TinkerEdge(idValue, outVertex, label, inVertex); ElementHelper.attachProperties(edge, keyValues); graph.edges.put(edge.id(), edge); TinkerHelper.addOutEdge(outVertex, label, edge); TinkerHelper.addInEdge(inVertex, label, edge); return edge; }
public static void autoUpdateIndex(final TinkerEdge edge, final String key, final Object newValue, final Object oldValue) { final TinkerGraph graph = (TinkerGraph) edge.graph(); if (graph.edgeIndex != null) graph.edgeIndex.autoUpdate(key, newValue, oldValue, edge); }
protected static Edge addEdge(final TinkerGraph graph, final TinkerVertex outVertex, final TinkerVertex inVertex, final String label, final Object... keyValues) { ElementHelper.validateLabel(label); ElementHelper.legalPropertyKeyValueArray(keyValues); Object idValue = graph.edgeIdManager.convert(ElementHelper.getIdValue(keyValues).orElse(null)); final Edge edge; if (null != idValue) { if (graph.edges.containsKey(idValue)) throw Graph.Exceptions.edgeWithIdAlreadyExists(idValue); } else { idValue = graph.edgeIdManager.getNextId(graph); } edge = new TinkerEdge(idValue, outVertex, label, inVertex); ElementHelper.attachProperties(edge, keyValues); graph.edges.put(edge.id(), edge); TinkerHelper.addOutEdge(outVertex, label, edge); TinkerHelper.addInEdge(inVertex, label, edge); return edge; }
@Override public <V> Property<V> property(String key, V value) { if (this.removed) throw elementAlreadyRemoved(Edge.class, id); ElementHelper.validateProperty(key, value); final Property oldProperty = super.property(key); final Property<V> p = updateSpecificProperty(key, value); TinkerHelper.autoUpdateIndex(this, key, value, oldProperty.isPresent() ? oldProperty.value() : null); return p; }
@Override public void remove() { final TinkerVertex outVertex = (TinkerVertex) this.outVertex; final TinkerVertex inVertex = (TinkerVertex) this.inVertex; if (null != outVertex && null != outVertex.outEdges) { final Set<Edge> edges = outVertex.outEdges.get(this.label()); if (null != edges) edges.remove(this); } if (null != inVertex && null != inVertex.inEdges) { final Set<Edge> edges = inVertex.inEdges.get(this.label()); if (null != edges) edges.remove(this); } TinkerHelper.removeElementIndex(this); ((TinkerGraph) this.graph()).edges.remove(this.id()); this.properties = null; this.removed = true; }
public static void removeIndex(final TinkerEdge edge, final String key, final Object value) { final TinkerGraph graph = (TinkerGraph) edge.graph(); if (graph.edgeIndex != null) graph.edgeIndex.remove(key, value, edge); }
@Override public <V> Property<V> property(final String key, final V value) { if (this.removed) throw elementAlreadyRemoved(Edge.class, id); ElementHelper.validateProperty(key, value); final Property oldProperty = super.property(key); final Property<V> newProperty = new TinkerProperty<>(this, key, value); if (null == this.properties) this.properties = new HashMap<>(); this.properties.put(key, newProperty); TinkerHelper.autoUpdateIndex(this, key, value, oldProperty.isPresent() ? oldProperty.value() : null); return newProperty; }
protected static Edge addEdge(final TinkerGraph graph, final TinkerVertex outVertex, final TinkerVertex inVertex, final String label, final Object... keyValues) { ElementHelper.validateLabel(label); ElementHelper.legalPropertyKeyValueArray(keyValues); Object idValue = graph.edgeIdManager.convert(ElementHelper.getIdValue(keyValues).orElse(null)); final Edge edge; if (null != idValue) { if (graph.edges.containsKey(idValue)) throw Graph.Exceptions.edgeWithIdAlreadyExists(idValue); } else { idValue = graph.edgeIdManager.getNextId(graph); } edge = new TinkerEdge(idValue, outVertex, label, inVertex); ElementHelper.attachProperties(edge, keyValues); graph.edges.put(edge.id(), edge); TinkerHelper.addOutEdge(outVertex, label, edge); TinkerHelper.addInEdge(inVertex, label, edge); return edge; }
RelationType rt = typeManager.getExistingRelationType(next.key); if (rt.isPropertyKey()) { te.property(rt.name(), next.value); } else { throw new RuntimeException("Metaedges are not supported");
@Override public void remove() { final TinkerVertex outVertex = (TinkerVertex) this.outVertex; final TinkerVertex inVertex = (TinkerVertex) this.inVertex; if (null != outVertex && null != outVertex.outEdges) { final Set<Edge> edges = outVertex.outEdges.get(this.label()); if (null != edges) edges.remove(this); } if (null != inVertex && null != inVertex.inEdges) { final Set<Edge> edges = inVertex.inEdges.get(this.label()); if (null != edges) edges.remove(this); } TinkerHelper.removeElementIndex(this); ((TinkerGraph) this.graph()).edges.remove(this.id()); this.properties = null; this.removed = true; }
public static void autoUpdateIndex(final TinkerEdge edge, final String key, final Object newValue, final Object oldValue) { final TinkerGraph graph = (TinkerGraph) edge.graph(); if (graph.edgeIndex != null) graph.edgeIndex.autoUpdate(key, newValue, oldValue, edge); }
@Override public <V> Property<V> property(final String key, final V value) { if (this.removed) throw elementAlreadyRemoved(Edge.class, id); ElementHelper.validateProperty(key, value); final Property oldProperty = super.property(key); final Property<V> newProperty = new TinkerProperty<>(this, key, value); if (null == this.properties) this.properties = new HashMap<>(); this.properties.put(key, newProperty); TinkerHelper.autoUpdateIndex(this, key, value, oldProperty.isPresent() ? oldProperty.value() : null); return newProperty; }
RelationType rt = typeManager.getExistingRelationType(next.key); if (rt.isPropertyKey()) { te.property(rt.name(), next.value); } else { throw new RuntimeException("Metaedges are not supported");
public static void removeIndex(final TinkerEdge edge, final String key, final Object value) { final TinkerGraph graph = (TinkerGraph) edge.graph(); if (graph.edgeIndex != null) graph.edgeIndex.remove(key, value, edge); }
te.property(rt.name(), next.value); } else { throw new RuntimeException("Metaedges are not supported");
public static void autoUpdateIndex(final TinkerEdge edge, final String key, final Object newValue, final Object oldValue) { final TinkerGraph graph = (TinkerGraph) edge.graph(); if (graph.edgeIndex != null) graph.edgeIndex.autoUpdate(key, newValue, oldValue, edge); }