@Override public void removeProperty(Property property) { List<VertexProperty> props = this.properties.get(property.key()); props.remove(props.indexOf(property)); if (props.size() == 0) this.properties.remove(property.key()); PropertyQuery<UniElement> propertyQuery = new PropertyQuery<>(this, property, PropertyQuery.Action.Remove, null); this.graph.getControllerManager().getControllers(PropertyQuery.PropertyController.class).forEach(controller -> controller.property(propertyQuery)); }
private void validateProperties() { if (deferred) { DeferredVertexQuery query = new DeferredVertexQuery(Collections.singletonList(this), null, null, null, null); this.graph.getControllerManager().getControllers(DeferredVertexQuery.DeferredVertexController.class).forEach(deferredController -> deferredController.fetchProperties(query)); } }
@Override public void remove() { RemoveQuery<UniElement> removeQuery = new RemoveQuery<>(Arrays.asList(this), null); this.graph.getControllerManager().getControllers(RemoveQuery.RemoveController.class).forEach(controller -> controller.remove(removeQuery)); }
@Override public Edge addEdge(final String label, final Vertex vertex, final Object... keyValues) { if (null == vertex) throw Graph.Exceptions.argumentCanNotBeNull("vertex"); ElementHelper.legalPropertyKeyValueArray(keyValues); ElementHelper.validateLabel(label); Map<String, Object> stringObjectMap = ConversionUtils.asMap(keyValues); stringObjectMap.put(T.label.toString(), label); return graph.getControllerManager().getControllers(AddEdgeQuery.AddEdgeController.class).stream() .map(controller -> controller.addEdge(new AddEdgeQuery(this, vertex, new HashMap<>(stringObjectMap), null))) .filter(e -> e != null) .findFirst().get(); }
@Override public <V> VertexProperty<V> property(String key, V value) { UniVertexProperty vertexProperty = (UniVertexProperty) addPropertyLocal(key, value); PropertyQuery<UniVertex> propertyQuery = new PropertyQuery<UniVertex>(this, vertexProperty, PropertyQuery.Action.Add, null); graph.getControllerManager().getControllers(PropertyQuery.PropertyController.class).forEach(controller -> controller.property(propertyQuery)); return vertexProperty; }
@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 Iterator<Edge> edges(Direction direction, String... edgeLabels) { PredicatesHolder predicatesHolder = (edgeLabels.length == 0) ? PredicatesHolderFactory.empty() : PredicatesHolderFactory.predicate(new HasContainer(T.label.getAccessor(), P.within(edgeLabels))); SearchVertexQuery searchVertexQuery = new SearchVertexQuery(Edge.class, Arrays.asList(this), direction, predicatesHolder, -1, null, null, null, null); return graph.getControllerManager().getControllers(SearchVertexQuery.SearchVertexController.class).stream() .<Iterator<Edge>>map(controller -> controller.search(searchVertexQuery)) .flatMap(ConversionUtils::asStream) .iterator(); }
public void removeProperty(Property property) { getPropertiesMap().remove(property.key()); PropertyQuery<UniElement> propertyQuery = new PropertyQuery<>(this, property, PropertyQuery.Action.Remove, null); this.graph.getControllerManager().getControllers(PropertyQuery.PropertyController.class).forEach(controller -> controller.property(propertyQuery)); }
@Override public void apply(Traversal.Admin<?, ?> traversal) { UniGraph uniGraph = ((UniGraph) traversal.getGraph().get()); TraversalHelper.getStepsOfClass(EdgeOtherVertexStep.class, traversal).forEach(edgeOtherVertexStep -> { UniGraphEdgeOtherVertexStep uniGraphEdgeOtherVertexStep = new UniGraphEdgeOtherVertexStep(traversal, uniGraph, uniGraph.getControllerManager()); edgeOtherVertexStep.getLabels().forEach(uniGraphEdgeOtherVertexStep::addLabel); TraversalHelper.replaceStep(edgeOtherVertexStep, uniGraphEdgeOtherVertexStep, traversal); }); TraversalHelper.getStepsOfClass(EdgeVertexStep.class, traversal).forEach(edgeVertexStep -> { UniGraphEdgeVertexStep uniGraphEdgeVertexStep = new UniGraphEdgeVertexStep(traversal, edgeVertexStep.getDirection(), uniGraph, uniGraph.getControllerManager()); edgeVertexStep.getLabels().forEach(uniGraphEdgeVertexStep::addLabel); TraversalHelper.replaceStep(edgeVertexStep, uniGraphEdgeVertexStep, traversal); }); } }
@Override public void apply(Traversal.Admin<?, ?> traversal) { if(TraversalHelper.onGraphComputer(traversal)) return; Graph graph = traversal.getGraph().get(); if(!(graph instanceof UniGraph)) { return; } UniGraph uniGraph = (UniGraph) graph; TraversalHelper.getStepsOfClass(GraphStep.class, traversal).forEach(graphStep -> { final UniGraphStep<?,?> uniGraphStep = new UniGraphStep<>(graphStep, uniGraph.getControllerManager()); TraversalHelper.replaceStep(graphStep, uniGraphStep, traversal); PredicatesUtil.collectPredicates(uniGraphStep, traversal); }); } }
UniGraphVertexStep uniGraphVertexStep = new UniGraphVertexStep<>(vertexStep, uniGraph, uniGraph.getControllerManager()); TraversalHelper.replaceStep(vertexStep, uniGraphVertexStep, traversal); if (vertexStep.returnsEdge()) PredicatesUtil.collectPredicates(uniGraphVertexStep, traversal); traversalParent.getLocalChildren().forEach(child -> { if(TraversalHelper.stepIndex(vertexStep, child) != -1) { UniGraphVertexStep uniGraphVertexStep = new UniGraphVertexStep<>(vertexStep, uniGraph, uniGraph.getControllerManager()); TraversalHelper.replaceStep(vertexStep, uniGraphVertexStep, child); if (vertexStep.returnsEdge()) PredicatesUtil.collectPredicates(uniGraphVertexStep, child); traversalParent.getGlobalChildren().forEach(child -> { if(TraversalHelper.stepIndex(vertexStep, child) != -1) { UniGraphVertexStep uniGraphVertexStep = new UniGraphVertexStep<>(vertexStep, uniGraph, uniGraph.getControllerManager()); TraversalHelper.replaceStep(vertexStep, uniGraphVertexStep, child); if (vertexStep.returnsEdge()) PredicatesUtil.collectPredicates(uniGraphVertexStep, child); traversalParent.getLocalChildren().forEach(child1 -> { if(TraversalHelper.stepIndex(vertexStep, child1) != -1) { UniGraphVertexStep uniGraphVertexStep = new UniGraphVertexStep<>(vertexStep, uniGraph, uniGraph.getControllerManager()); TraversalHelper.replaceStep(vertexStep, uniGraphVertexStep, child1); if (vertexStep.returnsEdge()) PredicatesUtil.collectPredicates(uniGraphVertexStep, child1); traversalParent.getGlobalChildren().forEach(child1 -> { if(TraversalHelper.stepIndex(vertexStep, child1) != -1) { UniGraphVertexStep uniGraphVertexStep = new UniGraphVertexStep<>(vertexStep, uniGraph, uniGraph.getControllerManager()); TraversalHelper.replaceStep(vertexStep, uniGraphVertexStep, child1); if (vertexStep.returnsEdge()) PredicatesUtil.collectPredicates(uniGraphVertexStep, child1);