@Override public <V> V valueOrNull(PropertyKey key) { return (V)property(key.name()).orElse(null); }
@Override public <A> A valueOrNull(PropertyKey key) { return (A) property(key.name()).orElse(null); }
/** * Returns the <code>order</code> property of the given {@link Edge} that represents an {@link EReference} link. * * @param edge The edge to get the order property for. Must not be <code>null</code>. * @return The order, as an integer. If no order is set, -1 will be returned. */ public static int getEReferenceEdgeOrder(final Edge edge) { checkNotNull(edge, "Precondition violation - argument 'edge' must not be NULL!"); return (int) edge.property(E_PROP__ORDER).orElse(-1); }
@Override public String extractId(Element entityRepresentation) { return (String) entityRepresentation.property(__eid.name()).orElse(null); }
@Override public <V> V valueOrNull(PropertyKey key) { return (V)property(key.name()).orElse(null); }
public String extractContentHash(Element entityRepresentation) { return entityRepresentation.<String>property(Constants.Property.__contentHash.name()).orElse(null); }
public String extractSyncHash(Element entityRepresentation) { return entityRepresentation.<String>property(Constants.Property.__syncHash.name()).orElse(null); }
@Override public String extractIdentityHash(Element entityRepresentation) { return entityRepresentation.<String>property(Constants.Property.__identityHash.name()).orElse(null); }
return element.property(key).orElse(Tokens.NULL);
@Override public CanonicalPath extractCanonicalPath(Element entityRepresentation) { String cp = (String) entityRepresentation.property(__cp.name()).orElse(null); if (cp == null) { throw new IllegalArgumentException("Element is not representable using a canonical path. Element type is " + extractType(entityRepresentation).getSimpleName() + ", element id is '" + extractId(entityRepresentation) + "'."); } return CanonicalPath.fromString(cp); }
edge.keys().forEach(key -> edgeData.put(key, edge.property(key).orElse(null))); otherVertexMap.put(GraphResource.EDGE_DATA, edgeData);
static void moveIncomingEdges(Vertex vertex, Vertex duplicate, IndexHandler indexHandler) { for (Iterator<Edge> edges = vertex.edges(Direction.IN); edges.hasNext(); ) { Edge edge = edges.next(); if (edge.label().equals(VERSION_OF)) { continue; } Edge duplicateEdge = edge.outVertex().addEdge(edge.label(), duplicate); for (Iterator<Property<Object>> properties = edge.properties(); properties.hasNext(); ) { Property<Object> property = properties.next(); duplicateEdge.property(property.key(), property.value()); } if (duplicateEdge.<Boolean>property("isLatest").orElse(false)) { duplicateEdge.<String>property("tim_id") .ifPresent(p -> indexHandler.upsertIntoEdgeIdIndex(UUID.fromString(p), duplicateEdge)); } edge.remove(); } } }
static void moveOutgoingEdges(Vertex vertex, Vertex duplicate, IndexHandler indexHandler) { for (Iterator<Edge> edges = vertex.edges(Direction.OUT); edges.hasNext(); ) { Edge edge = edges.next(); if (edge.label().equals(VERSION_OF)) { continue; } Edge duplicateEdge = duplicate.addEdge(edge.label(), edge.inVertex()); for (Iterator<Property<Object>> properties = edge.properties(); properties.hasNext(); ) { Property<Object> property = properties.next(); duplicateEdge.property(property.key(), property.value()); } if (duplicateEdge.<Boolean>property("isLatest").orElse(false)) { duplicateEdge.<String>property("tim_id") .ifPresent(p -> indexHandler.upsertIntoEdgeIdIndex(UUID.fromString(p), duplicateEdge)); } edge.remove(); } }
@Override public Element relate(Element sourceEntity, Element targetEntity, String name, Map<String, Object> properties) { if (name == null) { throw new IllegalArgumentException("name == null"); } if (!(sourceEntity instanceof Vertex)) { throw new IllegalArgumentException("Source not a vertex."); } if (!(targetEntity instanceof Vertex)) { throw new IllegalArgumentException("Target not a vertex."); } Map<String, Object> props = properties == null ? Collections.emptyMap() : properties; Object[] keyValues = asKeyValues(props, __sourceType.name(), sourceEntity.property(__type.name()).value(), __targetType.name(), targetEntity.property(__type.name()).orElse(null), __sourceCp.name(), sourceEntity.property(__cp.name()).orElse(null), __targetCp.name(), targetEntity.property(__cp.name()).orElse(null), __sourceEid.name(), sourceEntity.property(__eid.name()).orElse(null), __targetEid.name(), targetEntity.property(__eid.name()).orElse(null)); Edge e = ((Vertex) sourceEntity).addEdge(name, (Vertex) targetEntity, keyValues); //these need the ID of the edge, so we need to set the props after the edge has been created e.property(__eid.name(), e.id().toString()); e.property(__cp.name(), CanonicalPath.of().relationship(e.id().toString()).get().toString()); return e; }
Object oldValue = this.property(key).orElse(null); if (oldValue != null && oldValue.equals(value)) { return;
Object oldValue = this.property(key).orElse(null); if (oldValue != null && oldValue.equals(value)) { return;