public static void addSchema(SqlgGraph sqlgGraph, String schema) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { sqlgGraph.addVertex( T.label, SQLG_SCHEMA + "." + SQLG_SCHEMA_SCHEMA, "name", schema, CREATED_ON, LocalDateTime.now() ); } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void addSchema(SqlgGraph sqlgGraph, String schema) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { sqlgGraph.addVertex( T.label, SQLG_SCHEMA + "." + SQLG_SCHEMA_SCHEMA, "name", schema, CREATED_ON, LocalDateTime.now() ); } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void addVertexColumn(SqlgGraph sqlgGraph, String schema, String prefixedTable, Map.Entry<String, PropertyType> column) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { Preconditions.checkArgument(prefixedTable.startsWith(VERTEX_PREFIX), "prefixedTable must be for a vertex. prefixedTable = " + prefixedTable); GraphTraversalSource traversalSource = sqlgGraph.topology(); List<Vertex> vertices = traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_SCHEMA) .has("name", schema) .out(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .has("name", prefixedTable.substring(VERTEX_PREFIX.length())) .toList(); if (vertices.size() == 0) { throw new IllegalStateException("Found no vertex for " + schema + "." + prefixedTable); } if (vertices.size() > 1) { throw new IllegalStateException("Found more than one vertex for " + schema + "." + prefixedTable); } Vertex vertex = vertices.get(0); Vertex property = sqlgGraph.addVertex( T.label, SQLG_SCHEMA + "." + SQLG_SCHEMA_PROPERTY, "name", column.getKey(), "type", column.getValue().name(), CREATED_ON, LocalDateTime.now() ); vertex.addEdge(SQLG_SCHEMA_VERTEX_PROPERTIES_EDGE, property); } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void addVertexColumn(SqlgGraph sqlgGraph, String schema, String prefixedTable, Map.Entry<String, PropertyType> column) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { Preconditions.checkArgument(prefixedTable.startsWith(VERTEX_PREFIX), "prefixedTable must be for a vertex. prefixedTable = " + prefixedTable); GraphTraversalSource traversalSource = sqlgGraph.topology(); List<Vertex> vertices = traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_SCHEMA) .has("name", schema) .out(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .has("name", prefixedTable.substring(VERTEX_PREFIX.length())) .toList(); if (vertices.size() == 0) { throw new IllegalStateException("Found no vertex for " + schema + "." + prefixedTable); } if (vertices.size() > 1) { throw new IllegalStateException("Found more than one vertex for " + schema + "." + prefixedTable); } Vertex vertex = vertices.get(0); Vertex property = sqlgGraph.addVertex( T.label, SQLG_SCHEMA + "." + SQLG_SCHEMA_PROPERTY, "name", column.getKey(), "type", column.getValue().name(), CREATED_ON, LocalDateTime.now() ); vertex.addEdge(SQLG_SCHEMA_VERTEX_PROPERTIES_EDGE, property); } finally { sqlgGraph.tx().batchMode(batchModeType); } }
static void addEdgeColumn(SqlgGraph sqlgGraph, String schema, String prefixedTable, Map.Entry<String, PropertyType> column, ListOrderedSet<String> identifiers) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { Preconditions.checkArgument(prefixedTable.startsWith(EDGE_PREFIX), "prefixedTable must be for an edge. prefixedTable = " + prefixedTable);
public static void addLabelToEdge(SqlgGraph sqlgGraph, Vertex edgeVertex, String schema, String prefixedTable, boolean in, SchemaTable foreignKey) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology();
static void addEdgeColumn(SqlgGraph sqlgGraph, String schema, String prefixedTable, Map.Entry<String, PropertyType> column, ListOrderedSet<String> identifiers) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { Preconditions.checkArgument(prefixedTable.startsWith(EDGE_PREFIX), "prefixedTable must be for an edge. prefixedTable = " + prefixedTable);
public static void removeVertexColumn(SqlgGraph sqlgGraph, String schema, String prefixedTable, String column) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { Preconditions.checkArgument(prefixedTable.startsWith(VERTEX_PREFIX), "prefixedTable must be for a vertex. prefixedTable = " + prefixedTable); GraphTraversalSource traversalSource = sqlgGraph.topology(); traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_SCHEMA) .has("name", schema) .out(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .has("name", prefixedTable.substring(VERTEX_PREFIX.length())) .out(SQLG_SCHEMA_VERTEX_PROPERTIES_EDGE) .has("name", column) .drop().iterate(); } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void removeVertexColumn(SqlgGraph sqlgGraph, String schema, String prefixedTable, String column) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { Preconditions.checkArgument(prefixedTable.startsWith(VERTEX_PREFIX), "prefixedTable must be for a vertex. prefixedTable = " + prefixedTable); GraphTraversalSource traversalSource = sqlgGraph.topology(); traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_SCHEMA) .has("name", schema) .out(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .has("name", prefixedTable.substring(VERTEX_PREFIX.length())) .out(SQLG_SCHEMA_VERTEX_PROPERTIES_EDGE) .has("name", column) .drop().iterate(); } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void removeEdgeColumn(SqlgGraph sqlgGraph, String schema, String prefixedTable, String column) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { Preconditions.checkArgument(prefixedTable.startsWith(EDGE_PREFIX), "prefixedTable must be for an edge. prefixedTable = " + prefixedTable); GraphTraversalSource traversalSource = sqlgGraph.topology(); traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_EDGE_LABEL) .has("name", prefixedTable.substring(EDGE_PREFIX.length())) .as("a") .in(SQLG_SCHEMA_OUT_EDGES_EDGE) .in(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .has("name", schema) .select("a") .out(SQLG_SCHEMA_EDGE_PROPERTIES_EDGE) .has("name", column) .drop().iterate(); } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void removeEdgeColumn(SqlgGraph sqlgGraph, String schema, String prefixedTable, String column) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { Preconditions.checkArgument(prefixedTable.startsWith(EDGE_PREFIX), "prefixedTable must be for an edge. prefixedTable = " + prefixedTable); GraphTraversalSource traversalSource = sqlgGraph.topology(); traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_EDGE_LABEL) .has("name", prefixedTable.substring(EDGE_PREFIX.length())) .as("a") .in(SQLG_SCHEMA_OUT_EDGES_EDGE) .in(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .has("name", schema) .select("a") .out(SQLG_SCHEMA_EDGE_PROPERTIES_EDGE) .has("name", column) .drop().iterate(); } finally { sqlgGraph.tx().batchMode(batchModeType); } }
static void removeGlobalUniqueIndex(SqlgGraph sqlgGraph, String globalUniqueIndexName) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology(); List<Vertex> uniquePropertyConstraints = traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_GLOBAL_UNIQUE_INDEX) .has("name", globalUniqueIndexName) .toList(); if (uniquePropertyConstraints.size() > 0) { traversalSource.V(uniquePropertyConstraints.get(0)) .out(SQLG_SCHEMA_GLOBAL_UNIQUE_INDEX_PROPERTY_EDGE) .drop() .iterate(); traversalSource.V(uniquePropertyConstraints.get(0)) .drop() .iterate(); } } finally { sqlgGraph.tx().batchMode(batchModeType); } }
static void removeGlobalUniqueIndex(SqlgGraph sqlgGraph, String globalUniqueIndexName) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology(); List<Vertex> uniquePropertyConstraints = traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_GLOBAL_UNIQUE_INDEX) .has("name", globalUniqueIndexName) .toList(); if (uniquePropertyConstraints.size() > 0) { traversalSource.V(uniquePropertyConstraints.get(0)) .out(SQLG_SCHEMA_GLOBAL_UNIQUE_INDEX_PROPERTY_EDGE) .drop() .iterate(); traversalSource.V(uniquePropertyConstraints.get(0)) .drop() .iterate(); } } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void removeVertexLabel(SqlgGraph sqlgGraph, VertexLabel vertexLabel) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology(); List<Vertex> schemas = traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + Topology.SQLG_SCHEMA_SCHEMA) .has("name", vertexLabel.getSchema().getName()) .toList(); if (schemas.size() > 0) { Vertex schemaVertex = schemas.get(0); List<Vertex> vertices = traversalSource.V(schemaVertex) .out(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .has(SQLG_SCHEMA_VERTEX_LABEL_NAME, vertexLabel.getLabel()) .toList(); if (vertices.size() > 0) { Vertex vertex = vertices.get(0); traversalSource.V(vertex) .out(SQLG_SCHEMA_VERTEX_PROPERTIES_EDGE) .drop().iterate(); vertex.remove(); } } } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void removeVertexLabel(SqlgGraph sqlgGraph, VertexLabel vertexLabel) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology(); List<Vertex> schemas = traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + Topology.SQLG_SCHEMA_SCHEMA) .has("name", vertexLabel.getSchema().getName()) .toList(); if (schemas.size() > 0) { Vertex schemaVertex = schemas.get(0); List<Vertex> vertices = traversalSource.V(schemaVertex) .out(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .has(SQLG_SCHEMA_VERTEX_LABEL_NAME, vertexLabel.getLabel()) .toList(); if (vertices.size() > 0) { Vertex vertex = vertices.get(0); traversalSource.V(vertex) .out(SQLG_SCHEMA_VERTEX_PROPERTIES_EDGE) .drop().iterate(); vertex.remove(); } } } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void removeEdgeLabel(SqlgGraph sqlgGraph, EdgeLabel edge) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology(); List<Vertex> edges = traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_SCHEMA) .has("name", edge.getSchema().getName()) .out(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .out(SQLG_SCHEMA_OUT_EDGES_EDGE) .has("name", edge.getName()).toList(); if (edges.size() > 0) { Vertex edgeV = edges.get(0); traversalSource.V(edgeV) .out(SQLG_SCHEMA_EDGE_PROPERTIES_EDGE) .drop() .iterate(); traversalSource.V(edgeV) .drop() .iterate(); } } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void removeEdgeLabel(SqlgGraph sqlgGraph, EdgeLabel edge) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology(); List<Vertex> edges = traversalSource.V() .hasLabel(SQLG_SCHEMA + "." + SQLG_SCHEMA_SCHEMA) .has("name", edge.getSchema().getName()) .out(SQLG_SCHEMA_SCHEMA_VERTEX_EDGE) .out(SQLG_SCHEMA_OUT_EDGES_EDGE) .has("name", edge.getName()).toList(); if (edges.size() > 0) { Vertex edgeV = edges.get(0); traversalSource.V(edgeV) .out(SQLG_SCHEMA_EDGE_PROPERTIES_EDGE) .drop() .iterate(); traversalSource.V(edgeV) .drop() .iterate(); } } finally { sqlgGraph.tx().batchMode(batchModeType); } }
public static void removePartition(SqlgGraph sqlgGraph, Partition partition) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology();
public static void removePartition(SqlgGraph sqlgGraph, Partition partition) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology();
public static void removeIndex(SqlgGraph sqlgGraph, Index index) { BatchManager.BatchModeType batchModeType = flushAndSetTxToNone(sqlgGraph); try { GraphTraversalSource traversalSource = sqlgGraph.topology();