use of org.umlg.sqlg.structure.topology.Topology in project sqlg by pietermartin.
the class TestSchema method testEnsureSchema.
@Test
public void testEnsureSchema() {
Topology mgr = this.sqlgGraph.getTopology();
this.sqlgGraph.addVertex(T.label, "A.A");
this.sqlgGraph.tx().commit();
Assert.assertTrue(mgr.getSchema(this.sqlgGraph.getSqlDialect().getPublicSchema()).isPresent());
Assert.assertTrue(mgr.getSchema("A").isPresent());
Assert.assertNotNull(mgr.ensureSchemaExist("A"));
Assert.assertFalse(mgr.getSchema("B").isPresent());
Assert.assertNotNull(mgr.ensureSchemaExist("B"));
Assert.assertTrue(mgr.getSchema("B").isPresent());
this.sqlgGraph.tx().commit();
Assert.assertTrue(mgr.getSchema("B").isPresent());
}
use of org.umlg.sqlg.structure.topology.Topology in project sqlg by pietermartin.
the class TestSchema method testExistingSchema.
@Test
public void testExistingSchema() throws SQLException {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsSchemaIfNotExists());
String schema = "A";
Connection c = this.sqlgGraph.tx().getConnection();
try (Statement ps = c.createStatement()) {
ps.executeUpdate("create schema " + this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(schema));
}
c.commit();
Topology mgr = this.sqlgGraph.getTopology();
Assert.assertFalse(mgr.getSchema("A").isPresent());
this.sqlgGraph.addVertex(T.label, schema + ".A");
this.sqlgGraph.tx().commit();
Assert.assertTrue(mgr.getSchema("A").isPresent());
}
use of org.umlg.sqlg.structure.topology.Topology in project sqlg by pietermartin.
the class TestTopology method testAddColumns.
@Test
public void testAddColumns() {
// Create Schema
Topology topology = sqlgGraph.getTopology();
topology.ensureSchemaExist("TEST");
Map<String, Object> columns = new HashMap<>();
columns.put("Test1", "");
columns.put("Test2", "");
// Add a vertex and remove to create columns
Vertex v = sqlgGraph.addVertex("TEST" + "." + "TEST_Table", columns);
v.remove();
sqlgGraph.tx().commit();
columns = new HashMap<>();
columns.put("Test1", "T1");
columns.put("Test2", "T2");
// Add the data
Vertex vv = sqlgGraph.addVertex("TEST" + "." + "TEST_Table", columns);
sqlgGraph.tx().commit();
// Simulating second load
// Remove the whole table label
Optional<VertexLabel> tableVertexLabel = sqlgGraph.getTopology().getVertexLabel("TEST", "TEST_Table");
if (tableVertexLabel.isPresent()) {
tableVertexLabel.get().remove(false);
}
columns = new HashMap<>();
columns.put("Test1", "");
columns.put("Test2", "");
columns.put("Test3", "");
// Add a vertex with more columns than previously had
v = sqlgGraph.addVertex("TEST" + "." + "TEST_Table", columns);
v.remove();
sqlgGraph.tx().commit();
}
Aggregations