/** * Called via {@link Schema#ensureEdgeLabelExist(String, VertexLabel, VertexLabel, Map)} * This is called when the {@link EdgeLabel} does not exist and needs to be created. * * @param edgeLabelName The edge's label. * @param inVertexLabel The edge's in vertex. * @param properties The edge's properties. * @return The new EdgeLabel. */ EdgeLabel addEdgeLabel( String edgeLabelName, VertexLabel inVertexLabel, Map<String, PropertyType> properties) { return addEdgeLabel(edgeLabelName, inVertexLabel, properties, new ListOrderedSet<>()); }
/** * Called via {@link Schema#ensureEdgeLabelExist(String, VertexLabel, VertexLabel, Map)} * This is called when the {@link EdgeLabel} does not exist and needs to be created. * * @param edgeLabelName The edge's label. * @param inVertexLabel The edge's in vertex. * @param properties The edge's properties. * @return The new EdgeLabel. */ EdgeLabel addEdgeLabel( String edgeLabelName, VertexLabel inVertexLabel, Map<String, PropertyType> properties) { return addEdgeLabel(edgeLabelName, inVertexLabel, properties, new ListOrderedSet<>()); }
@SuppressWarnings("OptionalGetWithoutIsPresent") private EdgeLabel createEdgeLabel( final String edgeLabelName, final VertexLabel outVertexLabel, final VertexLabel inVertexLabel, final Map<String, PropertyType> columns, final ListOrderedSet<String> identifiers) { Preconditions.checkArgument(this.topology.isSqlWriteLockHeldByCurrentThread(), "Lock must be held by the thread to call createEdgeLabel"); Preconditions.checkArgument(!edgeLabelName.startsWith(EDGE_PREFIX), "edgeLabelName may not start with " + EDGE_PREFIX); Preconditions.checkState(!this.isSqlgSchema(), "createEdgeLabel may not be called for \"%s\"", SQLG_SCHEMA); Schema inVertexSchema = inVertexLabel.getSchema(); //Edge may not already exist. Preconditions.checkState(!getEdgeLabel(edgeLabelName).isPresent(), "BUG: Edge \"%s\" already exists!", edgeLabelName); SchemaTable foreignKeyOut = SchemaTable.of(this.name, outVertexLabel.getLabel()); SchemaTable foreignKeyIn = SchemaTable.of(inVertexSchema.name, inVertexLabel.getLabel()); TopologyManager.addEdgeLabel(this.sqlgGraph, this.getName(), EDGE_PREFIX + edgeLabelName, foreignKeyOut, foreignKeyIn, columns, identifiers); if (this.sqlgGraph.getSqlDialect().needsSchemaCreationPrecommit()) { try { this.sqlgGraph.tx().getConnection().commit(); } catch (SQLException e) { throw new RuntimeException(e); } } return outVertexLabel.addEdgeLabel(edgeLabelName, inVertexLabel, columns, identifiers); }
@SuppressWarnings("OptionalGetWithoutIsPresent") private EdgeLabel createEdgeLabel( final String edgeLabelName, final VertexLabel outVertexLabel, final VertexLabel inVertexLabel, final Map<String, PropertyType> columns, final ListOrderedSet<String> identifiers) { Preconditions.checkArgument(this.topology.isSqlWriteLockHeldByCurrentThread(), "Lock must be held by the thread to call createEdgeLabel"); Preconditions.checkArgument(!edgeLabelName.startsWith(EDGE_PREFIX), "edgeLabelName may not start with " + EDGE_PREFIX); Preconditions.checkState(!this.isSqlgSchema(), "createEdgeLabel may not be called for \"%s\"", SQLG_SCHEMA); Schema inVertexSchema = inVertexLabel.getSchema(); //Edge may not already exist. Preconditions.checkState(!getEdgeLabel(edgeLabelName).isPresent(), "BUG: Edge \"%s\" already exists!", edgeLabelName); SchemaTable foreignKeyOut = SchemaTable.of(this.name, outVertexLabel.getLabel()); SchemaTable foreignKeyIn = SchemaTable.of(inVertexSchema.name, inVertexLabel.getLabel()); TopologyManager.addEdgeLabel(this.sqlgGraph, this.getName(), EDGE_PREFIX + edgeLabelName, foreignKeyOut, foreignKeyIn, columns, identifiers); if (this.sqlgGraph.getSqlDialect().needsSchemaCreationPrecommit()) { try { this.sqlgGraph.tx().getConnection().commit(); } catch (SQLException e) { throw new RuntimeException(e); } } return outVertexLabel.addEdgeLabel(edgeLabelName, inVertexLabel, columns, identifiers); }