public JanusGraphVertex addVertex(Object... keyValues) { ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent() && !((StandardJanusGraph) getGraph()).getConfiguration().allowVertexIdSetting()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); Object labelValue = null; for (int i = 0; i < keyValues.length; i = i + 2) {
public TitanVertex addVertex(Object... keyValues) { ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); Object labelValue = null; for (int i = 0; i < keyValues.length; i = i + 2) {
@Override public Vertex addVertex(final Object... keyValues) { ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); this.tx().readWrite(); final Neo4jVertex vertex = new Neo4jVertex(this.baseGraph.createNode(ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL).split(Neo4jVertex.LABEL_DELIMINATOR)), this); ElementHelper.attachProperties(vertex, keyValues); return vertex; }
throw Vertex.Exceptions.userSuppliedIdsNotSupported();
throw Vertex.Exceptions.userSuppliedIdsNotSupported();
throw Vertex.Exceptions.userSuppliedIdsNotSupported();
public TitanVertex addVertex(Object... keyValues) { ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); Object labelValue = null; for (int i = 0; i < keyValues.length; i = i + 2) {
throw Vertex.Exceptions.userSuppliedIdsNotSupported();
@Override public <V> DuctileVertexProperty<V> property(Cardinality cardinality, String key, V value, Object... keyValues) { if (cardinality != VertexProperty.Cardinality.single) { throw VertexProperty.Exceptions.multiPropertiesNotSupported(); } if (keyValues.length > 0) { throw VertexProperty.Exceptions.metaPropertiesNotSupported(); } ElementHelper.validateProperty(key, value); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); graph().tx().readWrite(); try { if (value == null) { getBaseVertex().removeProperty(key); } else { getBaseVertex().setProperty(key, value); } return new DuctileVertexProperty<V>(this, key, value); } catch (final IllegalArgumentException iae) { throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value); } }
@Override public Edge addEdge(String label, Vertex inVertex, Object... keyValues) { if (inVertex == null) throw new IllegalArgumentException("destination vertex is null"); checkArgument(!isNullOrEmpty(label), "label is invalid"); ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); if (Graph.Hidden.isHidden(label)) throw Element.Exceptions.labelCanNotBeAHiddenKey(label); graph.createEdgeClass(label); this.graph.tx().readWrite(); OEdge oEdge = getRawElement().addEdge(((OrientVertex) inVertex).getRawElement(), label); final OrientEdge edge = graph.elementFactory().wrapEdge(oEdge); edge.property(keyValues); edge.save(); return edge; }
@Override public DuctileVertex addVertex(Object... keyValues) { ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); tx().readWrite(); DuctileDBVertex vertex = baseGraph.addVertex(); String[] labels = ElementHelper.getLabelValue(keyValues).orElse("").split(DuctileVertex.LABEL_DELIMINATOR); for (String label : labels) { if (!label.isEmpty()) { vertex.addType(label); } } DuctileVertex ductileVertex = new DuctileVertex(vertex, this); ElementHelper.attachProperties(ductileVertex, keyValues); return ductileVertex; }
@Override public Vertex addVertex(Object... keyValues) { this.tx().readWrite(); return executeWithConnectionCheck(() -> { makeActive(); ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); String label = ElementHelper.getLabelValue(keyValues).orElse(OClass.VERTEX_CLASS_NAME); OrientVertex vertex = elementFactory().createVertex(label); vertex.property(keyValues); vertex.save(); return vertex; }); }
@Override public Vertex addVertex(final Object... keyValues) { ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); this.tx().readWrite(); final Neo4jVertex vertex = new Neo4jVertex(this.baseGraph.createNode(ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL).split(Neo4jVertex.LABEL_DELIMINATOR)), this); ElementHelper.attachProperties(vertex, keyValues); return vertex; }
@Override public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) { ElementHelper.validateProperty(key, value); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); this.graph.tx().readWrite(); return this.graph.trait.setVertexProperty(this, cardinality, key, value, keyValues); }
@Test @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS, supported = false) public void shouldSupportUserSuppliedIdsIfAnIdCanBeAssignedToVertex() throws Exception { try { graph.addVertex(T.id, graphProvider.convertId(99999943835l, Vertex.class)); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_USER_SUPPLIED_IDS)); } catch (Exception e) { validateException(Vertex.Exceptions.userSuppliedIdsNotSupported(), e); } }
public void property(Object... keyValues) { ElementHelper.legalPropertyKeyValueArray(keyValues); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); // copied from ElementHelper.attachProperties // can't use ElementHelper here because we only want to save the // document at the very end for (int i = 0; i < keyValues.length; i = i + 2) { if (!keyValues[i].equals(T.id) && !keyValues[i].equals(T.label)) property((String) keyValues[i], keyValues[i + 1], false); } getRawElement().save(); }
@Override public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) { ElementHelper.validateProperty(key, value); if (ElementHelper.getIdValue(keyValues).isPresent()) throw Vertex.Exceptions.userSuppliedIdsNotSupported(); this.graph.tx().readWrite(); return this.graph.trait.setVertexProperty(this, cardinality, key, value, keyValues); }
@Test @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS, supported = false) public void shouldSupportUserSuppliedIdsIfAnIdCanBeAssignedToVertex() throws Exception { try { graph.addVertex(T.id, graphProvider.convertId(99999943835l, Vertex.class)); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_USER_SUPPLIED_IDS)); } catch (Exception e) { validateException(Vertex.Exceptions.userSuppliedIdsNotSupported(), e); } }