Java Code Examples for org.apache.tinkerpop.gremlin.structure.util.ElementHelper#legalPropertyKeyValueArray()

The following examples show how to use org.apache.tinkerpop.gremlin.structure.util.ElementHelper#legalPropertyKeyValueArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TinkerHelper.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
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((long)idValue))
            throw Graph.Exceptions.edgeWithIdAlreadyExists(idValue);
    } else {
        idValue = graph.edgeIdManager.getNextId(graph);
    }

    edge = new TinkerEdge(graph, idValue, outVertex, label, inVertex);
    ElementHelper.attachProperties(edge, keyValues);
    graph.edges.put((long)edge.id(), edge);
    TinkerHelper.addOutEdge(outVertex, label, edge);
    TinkerHelper.addInEdge(inVertex, label, edge);
    return edge;

}
 
Example 2
Source File: TinkerHelper.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
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;

}
 
Example 3
Source File: TinkerGraph.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public Vertex addVertex(final Object... keyValues) {
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    Object idValue = vertexIdManager.convert(ElementHelper.getIdValue(keyValues).orElse(null));
    final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL);

    if (null != idValue) {
        if (this.vertices.containsKey(idValue))
            throw Exceptions.vertexWithIdAlreadyExists(idValue);
    } else {
        idValue = vertexIdManager.getNextId(this);
    }

    final Vertex vertex = new TinkerVertex(idValue, label, this);
    this.vertices.put(vertex.id(), vertex);

    ElementHelper.attachProperties(vertex, VertexProperty.Cardinality.list, keyValues);
    return vertex;
}
 
Example 4
Source File: Neo4JSession.java    From neo4j-gremlin-bolt with Apache License 2.0 6 votes vote down vote up
Neo4JVertex addVertex(Object... keyValues) {
    Objects.requireNonNull(keyValues, "keyValues cannot be null");
    // verify parameters are key/value pairs
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    // id cannot be present
    if (ElementHelper.getIdValue(keyValues).isPresent())
        throw Vertex.Exceptions.userSuppliedIdsNotSupported();
    // create vertex
    Neo4JVertex vertex = new Neo4JVertex(graph, this, vertexIdProvider, edgeIdProvider, Arrays.asList(ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL).split(Neo4JVertex.LabelDelimiter)));
    // add vertex to transient set (before processing properties to avoid having a transient vertex in update queue)
    transientVertices.add(vertex);
    // attach properties
    ElementHelper.attachProperties(vertex, keyValues);
    // check vertex has id
    Object id = vertex.id();
    if (id != null)
        transientVertexIndex.put(id, vertex);
    // return vertex
    return vertex;
}
 
Example 5
Source File: HBaseBulkLoader.java    From hgraphdb with Apache License 2.0 6 votes vote down vote up
public Vertex addVertex(final Object... keyValues) {
    try {
        ElementHelper.legalPropertyKeyValueArray(keyValues);
        Object idValue = ElementHelper.getIdValue(keyValues).orElse(null);
        final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL);

        idValue = HBaseGraphUtils.generateIdIfNeeded(idValue);
        long now = System.currentTimeMillis();
        HBaseVertex vertex = new HBaseVertex(graph, idValue, label, now, now,
                HBaseGraphUtils.propertiesToMap(keyValues));
        vertex.validate();

        Iterator<IndexMetadata> indices = vertex.getIndices(OperationType.WRITE);
        indexVertex(vertex, indices);

        Creator creator = new VertexWriter(graph, vertex);
        if (verticesMutator != null) verticesMutator.mutate(getMutationList(creator.constructInsertions()));

        return vertex;
    } catch (IOException e) {
        throw new HBaseGraphException(e);
    }
}
 
Example 6
Source File: SpecializedTinkerVertex.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Override
public <V> VertexProperty<V> property(VertexProperty.Cardinality cardinality, String key, V value, Object... keyValues) {
    if (this.removed) throw elementAlreadyRemoved(Vertex.class, id);
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    ElementHelper.validateProperty(key, value);
    synchronized (this) {
        this.modifiedSinceLastSerialization = true;
        final VertexProperty<V> vp = updateSpecificProperty(cardinality, key, value);
        TinkerHelper.autoUpdateIndex(this, key, value, null);
        return vp;
    }
}
 
Example 7
Source File: HBaseBulkLoader.java    From hgraphdb with Apache License 2.0 5 votes vote down vote up
public Edge addEdge(Vertex outVertex, Vertex inVertex, String label, Object... keyValues) {
    try {
        if (null == inVertex) throw Graph.Exceptions.argumentCanNotBeNull("inVertex");
        ElementHelper.validateLabel(label);
        ElementHelper.legalPropertyKeyValueArray(keyValues);
        Object idValue = ElementHelper.getIdValue(keyValues).orElse(null);

        idValue = HBaseGraphUtils.generateIdIfNeeded(idValue);
        long now = System.currentTimeMillis();
        HBaseEdge edge = new HBaseEdge(graph, idValue, label, now, now,
                HBaseGraphUtils.propertiesToMap(keyValues), inVertex, outVertex);
        edge.validate();

        Iterator<IndexMetadata> indices = edge.getIndices(OperationType.WRITE);
        indexEdge(edge, indices);

        EdgeIndexWriter writer = new EdgeIndexWriter(graph, edge, Constants.CREATED_AT);
        if (edgeIndicesMutator != null) edgeIndicesMutator.mutate(getMutationList(writer.constructInsertions()));

        Creator creator = new EdgeWriter(graph, edge);
        if (edgesMutator != null) edgesMutator.mutate(getMutationList(creator.constructInsertions()));

        return edge;
    } catch (IOException e) {
        throw new HBaseGraphException(e);
    }
}
 
Example 8
Source File: HBaseVertex.java    From hgraphdb with Apache License 2.0 5 votes vote down vote up
@Override
public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
    if (null == inVertex) throw Graph.Exceptions.argumentCanNotBeNull("inVertex");
    ElementHelper.validateLabel(label);
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    Object idValue = ElementHelper.getIdValue(keyValues).orElse(null);

    idValue = HBaseGraphUtils.generateIdIfNeeded(idValue);
    long now = System.currentTimeMillis();
    HBaseEdge newEdge = new HBaseEdge(graph, idValue, label, now, now, HBaseGraphUtils.propertiesToMap(keyValues), inVertex, this);
    newEdge.validate();
    newEdge.writeEdgeEndpoints();
    newEdge.writeToModel();

    invalidateEdgeCache();
    if (!isCached()) {
        HBaseVertex cachedVertex = (HBaseVertex) graph.findVertex(id, false);
        if (cachedVertex != null) cachedVertex.invalidateEdgeCache();
    }
    ((HBaseVertex) inVertex).invalidateEdgeCache();
    if (!((HBaseVertex) inVertex).isCached()) {
        HBaseVertex cachedInVertex = (HBaseVertex) graph.findVertex(inVertex.id(), false);
        if (cachedInVertex != null) cachedInVertex.invalidateEdgeCache();
    }

    Edge edge = graph.findOrCreateEdge(idValue);
    ((HBaseEdge) edge).copyFrom(newEdge);
    return edge;
}
 
Example 9
Source File: TinkerVertexProperty.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Use this constructor to construct {@link VertexProperty} instances for {@link TinkerGraph} where the {@code id}
 * can be explicitly set and validated against the expected data type.
 */
public TinkerVertexProperty(final Object id, final TinkerVertex vertex, final String key, final V value, final Object... propertyKeyValues) {
    super(id, key);
    this.allowNullPropertyValues = vertex.graph().features().vertex().properties().supportsNullPropertyValues();
    if (!allowNullPropertyValues && null == value)
        throw new IllegalArgumentException("value cannot be null as feature supportsNullPropertyValues is false");

    this.vertex = vertex;
    this.key = key;
    this.value = value;
    ElementHelper.legalPropertyKeyValueArray(propertyKeyValues);
    ElementHelper.attachProperties(this, propertyKeyValues);
}
 
Example 10
Source File: TinkerVertexProperty.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
/**
 * Use this constructor to construct {@link VertexProperty} instances for {@link TinkerGraph} where the {@code id}
 * can be explicitly set and validated against the expected data type.
 */
public TinkerVertexProperty(final Object id, final TinkerVertex vertex, final String key, final V value, final Object... propertyKeyValues) {
    super(id, key, vertex.tinkerGraph());
    this.vertex = vertex;
    this.key = key;
    this.value = value;
    ElementHelper.legalPropertyKeyValueArray(propertyKeyValues);
    ElementHelper.attachProperties(this, propertyKeyValues);
}
 
Example 11
Source File: Neo4JSession.java    From neo4j-gremlin-bolt with Apache License 2.0 5 votes vote down vote up
Neo4JEdge addEdge(String label, Neo4JVertex out, Neo4JVertex in, Object... keyValues) {
    Objects.requireNonNull(label, "label cannot be null");
    Objects.requireNonNull(out, "out cannot be null");
    Objects.requireNonNull(in, "in cannot be null");
    Objects.requireNonNull(keyValues, "keyValues cannot be null");
    // validate label
    ElementHelper.validateLabel(label);
    // verify parameters are key/value pairs
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    // id cannot be present
    if (ElementHelper.getIdValue(keyValues).isPresent())
        throw Vertex.Exceptions.userSuppliedIdsNotSupported();
    // create edge
    Neo4JEdge edge = new Neo4JEdge(graph, this, edgeIdProvider, label, out, in);
    // register transient edge (before processing properties to avoid having a transient edge in update queue)
    transientEdges.add(edge);
    // attach properties
    ElementHelper.attachProperties(edge, keyValues);
    // register transient edge with adjacent vertices
    out.addOutEdge(edge);
    in.addInEdge(edge);
    // check edge has id
    Object id = edge.id();
    if (id != null)
        transientEdgeIndex.put(id, edge);
    // return edge
    return edge;
}
 
Example 12
Source File: Neo4jGraph.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 13
Source File: Neo4jVertex.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
    if (null == inVertex) throw Graph.Exceptions.argumentCanNotBeNull("inVertex");
    ElementHelper.validateLabel(label);
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (ElementHelper.getIdValue(keyValues).isPresent())
        throw Edge.Exceptions.userSuppliedIdsNotSupported();

    this.graph.tx().readWrite();
    final Neo4jNode node = (Neo4jNode) this.baseElement;
    final Neo4jEdge edge = new Neo4jEdge(node.connectTo(((Neo4jVertex) inVertex).getBaseVertex(), label), this.graph);
    ElementHelper.attachProperties(edge, keyValues);
    return edge;
}
 
Example 14
Source File: StarGraph.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
Edge addOutEdge(final String label, final Vertex inVertex, final Object... keyValues) {
    ElementHelper.validateLabel(label);
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (null == this.outEdges)
        this.outEdges = new HashMap<>();
    List<Edge> outE = this.outEdges.get(label);
    if (null == outE) {
        outE = new ArrayList<>();
        this.outEdges.put(label, outE);
    }
    final StarEdge outEdge = new StarOutEdge(ElementHelper.getIdValue(keyValues).orElse(nextId()), label, inVertex.id());
    ElementHelper.attachProperties(outEdge, keyValues);
    outE.add(outEdge);
    return outEdge;
}
 
Example 15
Source File: StarGraph.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
Edge addInEdge(final String label, final Vertex outVertex, final Object... keyValues) {
    ElementHelper.validateLabel(label);
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (null == this.inEdges)
        this.inEdges = new HashMap<>();
    List<Edge> inE = this.inEdges.get(label);
    if (null == inE) {
        inE = new ArrayList<>();
        this.inEdges.put(label, inE);
    }
    final StarEdge inEdge = new StarInEdge(ElementHelper.getIdValue(keyValues).orElse(nextId()), label, outVertex.id());
    ElementHelper.attachProperties(inEdge, keyValues);
    inE.add(inEdge);
    return inEdge;
}
 
Example 16
Source File: StarGraph.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, V value, final Object... keyValues) {
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (null == this.vertexProperties)
        this.vertexProperties = new HashMap<>();
    final List<VertexProperty> list = cardinality.equals(VertexProperty.Cardinality.single) ? new ArrayList<>(1) : this.vertexProperties.getOrDefault(key, new ArrayList<>());
    final VertexProperty<V> vertexProperty = new StarVertexProperty<>(ElementHelper.getIdValue(keyValues).orElse(nextId()), key, value);
    ElementHelper.attachProperties(vertexProperty, keyValues);
    list.add(vertexProperty);
    this.vertexProperties.put(key, list);
    return vertexProperty;
}
 
Example 17
Source File: TinkerVertexProperty.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
/**
 * This constructor will not validate the ID type against the {@link Graph}.  It will always just use a
 * {@code Long} for its identifier.  This is useful for constructing a {@link VertexProperty} for usage
 * with {@link TinkerGraphComputerView}.
 */
public TinkerVertexProperty(final TinkerVertex vertex, final String key, final V value, final Object... propertyKeyValues) {
    super(vertex.tinkerGraph().vertexPropertyIdManager.getNextId(vertex.tinkerGraph()), key, vertex.tinkerGraph());
    this.vertex = vertex;
    this.key = key;
    this.value = value;
    ElementHelper.legalPropertyKeyValueArray(propertyKeyValues);
    ElementHelper.attachProperties(this, propertyKeyValues);
}
 
Example 18
Source File: SqlgVertex.java    From sqlg with MIT License 5 votes vote down vote up
private Edge addEdgeInternal(boolean complete, String label, Vertex inVertex, Object... keyValues) {
    if (null == inVertex) throw Graph.Exceptions.argumentCanNotBeNull("vertex");
    if (this.removed) {
        throw new IllegalStateException(String.format("Vertex with id %s was removed.", id().toString()));
    }

    ElementHelper.validateLabel(label);

    Preconditions.checkArgument(!label.contains("."), String.format("Edge label may not contain a '.' , the edge will be stored in the schema of the owning vertex. label = %s", label));

    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (ElementHelper.getIdValue(keyValues).isPresent())
        throw Edge.Exceptions.userSuppliedIdsNotSupported();

    List<String> previousBatchModeKeys;
    if (complete) {
        previousBatchModeKeys = this.sqlgGraph.tx().getBatchManager().getStreamingBatchModeEdgeKeys();
    } else {
        previousBatchModeKeys = Collections.emptyList();
    }
    Triple<Map<String, PropertyType>, Map<String, Object>, Map<String, Object>> keyValueMapTriple = SqlgUtil.validateVertexKeysValues(this.sqlgGraph.getSqlDialect(), keyValues, previousBatchModeKeys);
    if (!complete && keyValueMapTriple.getRight().size() != keyValueMapTriple.getMiddle().size()) {
        throw Property.Exceptions.propertyValueCanNotBeNull();
    }
    final Pair<Map<String, Object>, Map<String, Object>> keyValueMapPair = Pair.of(keyValueMapTriple.getMiddle(), keyValueMapTriple.getRight());
    final Map<String, PropertyType> columns = keyValueMapTriple.getLeft();
    Optional<VertexLabel> outVertexLabelOptional = this.sqlgGraph.getTopology().getVertexLabel(this.schema, this.table);
    Optional<VertexLabel> inVertexLabelOptional = this.sqlgGraph.getTopology().getVertexLabel(((SqlgVertex) inVertex).schema, ((SqlgVertex) inVertex).table);
    Preconditions.checkState(outVertexLabelOptional.isPresent(), "Out VertexLabel must be present. Not found for %s", this.schema + "." + this.table);
    Preconditions.checkState(inVertexLabelOptional.isPresent(), "In VertexLabel must be present. Not found for %s", ((SqlgVertex) inVertex).schema + "." + ((SqlgVertex) inVertex).table);

    this.sqlgGraph.getTopology().threadWriteLock();

    //noinspection OptionalGetWithoutIsPresent
    EdgeLabel edgeLabel = this.sqlgGraph.getTopology().ensureEdgeLabelExist(label, outVertexLabelOptional.get(), inVertexLabelOptional.get(), columns);
    if (!edgeLabel.hasIDPrimaryKey()) {
        Preconditions.checkArgument(columns.keySet().containsAll(edgeLabel.getIdentifiers()), "identifiers must be present %s", edgeLabel.getIdentifiers());
    }
    return new SqlgEdge(this.sqlgGraph, complete, this.schema, label, (SqlgVertex) inVertex, this, keyValueMapPair);
}
 
Example 19
Source File: SpecializedTinkerVertex.java    From tinkergraph-gremlin with Apache License 2.0 4 votes vote down vote up
@Override
    public Edge addEdge(final String label, Vertex inVertex, final Object... keyValues) {
        if (graph.isClosed()) {
            throw new IllegalStateException("cannot add more elements, graph is closed");
        }
        if (null == inVertex) {
            throw Graph.Exceptions.argumentCanNotBeNull("inVertex");
        }
        VertexRef<TinkerVertex> inVertexRef = null;
        if (inVertex instanceof VertexRef) {
            inVertexRef = (VertexRef) inVertex;
            inVertex = inVertexRef.get();
        }
        if (this.removed) {
            throw elementAlreadyRemoved(Vertex.class, this.id);
        }
        if (!allowedOutEdgeLabels().contains(label)) {
            throw new IllegalArgumentException(getClass().getName() + " doesn't allow outgoing edges with label=" + label);
        }
        if (!((SpecializedTinkerVertex) inVertex).allowedInEdgeLabels().contains(label)) {
            throw new IllegalArgumentException(inVertex.getClass().getName() + " doesn't allow incoming edges with label=" + label);
        }
        ElementHelper.legalPropertyKeyValueArray(keyValues);

        if (graph.specializedEdgeFactoryByLabel.containsKey(label)) {
            SpecializedElementFactory.ForEdge factory = graph.specializedEdgeFactoryByLabel.get(label);
            Long idValue = (Long) graph.edgeIdManager.convert(ElementHelper.getIdValue(keyValues).orElse(null));
            if (null != idValue) {
                if (graph.edges.containsKey(idValue))
                    throw Graph.Exceptions.edgeWithIdAlreadyExists(idValue);
            } else {
                idValue = (Long) graph.edgeIdManager.getNextId(graph);
            }
            graph.currentId.set(Long.max(idValue, graph.currentId.get()));

            // TODO hold link to vertexRef locally so we don't need the following lookup
            VertexRef<TinkerVertex> outVertexRef = (VertexRef<TinkerVertex>) graph.vertices.get(id);
            final SpecializedTinkerEdge underlying = factory.createEdge(idValue, graph, outVertexRef, inVertexRef);
            final Edge edge;
            if (graph.ondiskOverflowEnabled) {
                edge = factory.createEdgeRef(underlying);
            } else {
                edge = factory.createEdge(idValue, graph, outVertexRef, inVertexRef);
            }
            ElementHelper.attachProperties(edge, keyValues);
            graph.edges.put((long)edge.id(), edge);
            graph.getElementsByLabel(graph.edgesByLabel, label).add(edge);

//            acquireModificationLock();
            storeOutEdge(edge);
            ((SpecializedTinkerVertex) inVertex).storeInEdge(edge);
//            releaseModificationLock();
            modifiedSinceLastSerialization = true;
            return edge;
        } else { // edge label not registered for a specialized factory, treating as generic edge
            throw new IllegalArgumentException(
                "this instance of TinkerGraph uses specialized elements, but doesn't have a factory for label " + label
                    + ". Mixing specialized and generic elements is not (yet) supported");
        }
    }
 
Example 20
Source File: ArangoDBVertex.java    From arangodb-tinkerpop-provider with Apache License 2.0 4 votes vote down vote up
@Override
public <V> VertexProperty<V> property(
	Cardinality cardinality,
	String key,
	V value,
	Object... keyValues) {
	logger.debug("setting vertex property {} = {} ({})", key, value, keyValues);
	ElementHelper.validateProperty(key, value);
	ElementHelper.legalPropertyKeyValueArray(keyValues);
	Optional<Object> idValue = ElementHelper.getIdValue(keyValues);
	String id = null;
	if (idValue.isPresent()) {
		if (graph.features().vertex().willAllowId(idValue.get())) {
			id = idValue.get().toString();
			if (id.toString().contains("/")) {
        		String fullId = id.toString();
        		String[] parts = fullId.split("/");
        		// The collection name is the last part of the full name
        		String[] collectionParts = parts[0].split("_");
				String collectionName = collectionParts[collectionParts.length-1];
				if (collectionName.contains(ArangoDBGraph.ELEMENT_PROPERTIES_COLLECTION)) {
        			id = parts[1];
        			
        		}
        	}
	        Matcher m = ArangoDBUtil.DOCUMENT_KEY.matcher((String)id);
			if (!m.matches()) {
				throw new ArangoDBGraphException(String.format("Given id (%s) has unsupported characters.", id));
	    	}
		}
		else {
			throw VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported();
		}
		int idIndex = 0;
           for (int i = 0; i < keyValues.length; i+=2) {
               if (keyValues[i] == T.id) {
                   idIndex = i;
                   break;
               }
           }
           keyValues = ArrayUtils.remove(keyValues, idIndex);
           keyValues = ArrayUtils.remove(keyValues, idIndex);
	}
       final Optional<VertexProperty<V>> optionalVertexProperty = ElementHelper.stageVertexProperty(this, cardinality, key, value, keyValues);
       if (optionalVertexProperty.isPresent()) return optionalVertexProperty.get();
       

       ArangoDBVertexProperty<V> p = ArangoDBUtil.createArangoDBVertexProperty(id, key, value, this);
       ElementHelper.attachProperties(p, keyValues);
	return p;
}