@Test @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = VertexPropertyFeatures.FEATURE_USER_SUPPLIED_IDS, supported = false) public void shouldSupportUserSuppliedIdsIfAnIdCanBeAssigned() throws Exception { try { final Vertex v = graph.addVertex(); v.property(VertexProperty.Cardinality.single, "name", "me", T.id, graphProvider.convertId(99999943835l, VertexProperty.class)); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), VertexPropertyFeatures.FEATURE_USER_SUPPLIED_IDS)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.userSuppliedIdsNotSupported(), ex); } }
@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 @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = VertexPropertyFeatures.FEATURE_USER_SUPPLIED_IDS, supported = false) public void shouldSupportUserSuppliedIdsIfAnIdCanBeAssigned() throws Exception { try { final Vertex v = graph.addVertex(); v.property(VertexProperty.Cardinality.single, "name", "me", T.id, graphProvider.convertId(99999943835l, VertexProperty.class)); fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), VertexPropertyFeatures.FEATURE_USER_SUPPLIED_IDS)); } catch (Exception ex) { validateException(VertexProperty.Exceptions.userSuppliedIdsNotSupported(), ex); } }
@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 <U> Property<U> property(String key, U value) { if (T.id.equals(key)) throw VertexProperty.Exceptions.userSuppliedIdsNotSupported(); ODocument metadata = getMetadataDocument(); metadata.field(key, value); return new OrientVertexPropertyProperty<>(key, value, this); }
@Override public <V> VertexProperty<V> property(final String key, final V value, final Object... keyValues) { VertexProperty<V> vertexProperty = this.property(key, value); if (ElementHelper.getIdValue(keyValues).isPresent()) throw VertexProperty.Exceptions.userSuppliedIdsNotSupported(); ElementHelper.legalPropertyKeyValueArray(keyValues); ElementHelper.attachProperties(vertexProperty, keyValues); return vertexProperty; }