@Watched(prefix = "vertex") @Override @SuppressWarnings("unchecked") // (VertexProperty<V>) prop public <V> VertexProperty<V> property( VertexProperty.Cardinality cardinality, String key, V value, Object... objects) { if (objects.length != 0 && objects[0].equals(T.id)) { throw VertexProperty.Exceptions.userSuppliedIdsNotSupported(); } // TODO: extra props: objects if (objects.length != 0) { throw VertexProperty.Exceptions.metaPropertiesNotSupported(); } PropertyKey propertyKey = this.graph().propertyKey(key); // Check key in vertex label E.checkArgument(this.label.properties().contains(propertyKey.id()), "Invalid property '%s' for vertex label '%s'", key, this.label()); // Primary-Keys can only be set once if (this.schemaLabel().primaryKeys().contains(propertyKey.id())) { E.checkArgument(!this.hasProperty(propertyKey.id()), "Can't update primary key: '%s'", key); } return (VertexProperty<V>) this.addProperty(propertyKey, value, true); }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_MULTI_PROPERTIES, supported = false) public void shouldSupportMultiPropertyIfTheSameKeyCanBeAssignedMoreThanOnce() throws Exception { try { final Vertex v = graph.addVertex("name", "stephen", "name", "steve"); if (2 == IteratorUtils.count(v.properties())) fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), VertexFeatures.FEATURE_MULTI_PROPERTIES)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.multiPropertiesNotSupported(), ex); } }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false) public void shouldSupportUserSuppliedIdsOfTypeNumericLong() throws Exception { final long id = 123456l; // a graph can "allow" an id without internally supporting it natively and therefore doesn't need // to throw the exception assumeFalse(graph.features().vertex().properties().willAllowId(id)); try { final Vertex v = graph.addVertex(); v.property(VertexProperty.Cardinality.single, "test", "me", T.id, id); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex); } }
throw VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported();
if (id != null && id instanceof String == false) { throw VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported();
@Watched(prefix = "vertex") @Override @SuppressWarnings("unchecked") // (VertexProperty<V>) prop public <V> VertexProperty<V> property( VertexProperty.Cardinality cardinality, String key, V value, Object... objects) { if (objects.length != 0 && objects[0].equals(T.id)) { throw VertexProperty.Exceptions.userSuppliedIdsNotSupported(); } // TODO: extra props: objects if (objects.length != 0) { throw VertexProperty.Exceptions.metaPropertiesNotSupported(); } PropertyKey propertyKey = this.graph().propertyKey(key); // Check key in vertex label E.checkArgument(this.label.properties().contains(propertyKey.id()), "Invalid property '%s' for vertex label '%s'", key, this.label()); // Primary-Keys can only be set once if (this.schemaLabel().primaryKeys().contains(propertyKey.id())) { E.checkArgument(!this.hasProperty(propertyKey.id()), "Can't update primary key: '%s'", key); } return (VertexProperty<V>) this.addProperty(propertyKey, value, true); }
@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); } }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_ANY_IDS, supported = false) public void shouldSupportUserSuppliedIdsOfTypeAny() throws Exception { final Date id = new Date(); // a graph can "allow" an id without internally supporting it natively and therefore doesn't need // to throw the exception assumeFalse(graph.features().vertex().properties().willAllowId(id)); try { final Vertex v = graph.addVertex(); v.property(VertexProperty.Cardinality.single, "test", "me", T.id, id); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_ANY_IDS)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex); } }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_UUID_IDS, supported = false) public void shouldSupportUserSuppliedIdsOfTypeUuid() throws Exception { final UUID id = UUID.randomUUID(); // a graph can "allow" an id without internally supporting it natively and therefore doesn't need // to throw the exception assumeFalse(graph.features().vertex().properties().willAllowId(id)); try { final Vertex v = graph.addVertex(); v.property(VertexProperty.Cardinality.single, "test", "me", T.id, id); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_UUID_IDS)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex); } }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_STRING_IDS, supported = false) public void shouldSupportUserSuppliedIdsOfTypeString() throws Exception { final String id = "this-is-a-valid-id"; // a graph can "allow" an id without internally supporting it natively and therefore doesn't need // to throw the exception assumeFalse(graph.features().vertex().properties().willAllowId(id)); try { final Vertex v = graph.addVertex(); v.property(VertexProperty.Cardinality.single, "test", "me", T.id, id); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_STRING_IDS)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex); } }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false) public void shouldSupportUserSuppliedIdsOfTypeNumericLong() throws Exception { final long id = 123456l; // a graph can "allow" an id without internally supporting it natively and therefore doesn't need // to throw the exception assumeFalse(graph.features().vertex().properties().willAllowId(id)); try { final Vertex v = graph.addVertex(); v.property(VertexProperty.Cardinality.single, "test", "me", T.id, id); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex); } }
@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false) public void shouldSupportUserSuppliedIdsOfTypeNumericInt() throws Exception { final int id = 123456; // a graph can "allow" an id without internally supporting it natively and therefore doesn't need // to throw the exception assumeFalse(graph.features().vertex().properties().willAllowId(id)); try { final Vertex v = graph.addVertex(); v.property(VertexProperty.Cardinality.single, "test", "me", T.id, id); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex); } }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_META_PROPERTIES, supported = false) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_META_PROPERTIES) public void shouldSupportMetaPropertyIfPropertiesHaveAnIteratorViaVertexProperty() throws Exception { try { final Vertex v = graph.addVertex("name", "stephen"); v.property("name").properties(); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), VertexFeatures.FEATURE_META_PROPERTIES)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.metaPropertiesNotSupported(), ex); } } }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_META_PROPERTIES, supported = false) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_META_PROPERTIES) public void shouldSupportMetaPropertyIfPropertiesCanBePutOnPropertiesViaVertexProperty() throws Exception { try { final Vertex v = graph.addVertex("name", "stephen"); v.property("name").property("p", "on-property"); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), VertexFeatures.FEATURE_META_PROPERTIES)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.metaPropertiesNotSupported(), ex); } }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_META_PROPERTIES, supported = false) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_META_PROPERTIES) public void shouldSupportMetaPropertyIfPropertiesCanBePutOnProperties() throws Exception { try { final Vertex v = graph.addVertex(); v.property(VertexProperty.Cardinality.single, "name", "stephen", "p", "on-property"); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), VertexFeatures.FEATURE_META_PROPERTIES)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.metaPropertiesNotSupported(), ex); } }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_MULTI_PROPERTIES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_DUPLICATE_MULTI_PROPERTIES, supported = false) public void shouldSupportIdenticalMultiPropertyIfTheSameKeyCanBeAssignedSameValueMoreThanOnce() throws Exception { try { final Vertex v = graph.addVertex("name", "stephen", "name", "stephen"); if (2 == IteratorUtils.count(v.properties())) fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), VertexFeatures.FEATURE_DUPLICATE_MULTI_PROPERTIES)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.identicalMultiPropertiesNotSupported(), ex); } }
@Override public <U> Iterator<Property<U>> properties(String... propertyKeys) { throw metaPropertiesNotSupported(); }
@Override public <U> Property<U> property(final String key, final U value) { throw VertexProperty.Exceptions.multiPropertiesNotSupported(); }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = VertexFeatures.FEATURE_MULTI_PROPERTIES, supported = false) public void shouldSupportMultiPropertyIfTheSameKeyCanBeAssignedMoreThanOnce() throws Exception { try { final Vertex v = graph.addVertex("name", "stephen", "name", "steve"); if (2 == IteratorUtils.count(v.properties())) fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), VertexFeatures.FEATURE_MULTI_PROPERTIES)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.multiPropertiesNotSupported(), ex); } }
@Override public <U> Iterator<Property<U>> properties(String... propertyKeys) { throw VertexProperty.Exceptions.multiPropertiesNotSupported(); }