use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class MetaImpl method getColumns.
@Override
@SuppressWarnings(value = "unchecked")
public Map<String, ColumnDef> getColumns(Entity entity) {
BeModelElement scheme = entity.getAvailableElement("Scheme");
if (scheme == null)
return new HashMap<>();
BeCaseInsensitiveCollection<ColumnDef> columns = (BeCaseInsensitiveCollection<ColumnDef>) ((TableDef) scheme).get("Columns");
return StreamSupport.stream(columns.spliterator(), false).collect(Utils.toLinkedMap(ColumnDef::getName, Function.identity()));
}
use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class DpsHelper method addTags.
private <T extends DynamicPropertySet> T addTags(T dps, BeModelElement modelElements, Collection<String> columnNames) {
Map<String, ColumnDef> columns = meta.getColumns(getEntity(modelElements));
for (String propertyName : columnNames) {
DynamicProperty property = dps.getProperty(propertyName);
ColumnDef columnDef = columns.get(property.getName());
if (columnDef != null)
addTags(property, columnDef);
}
return dps;
}
use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class PostgresTypeManagerTest method testJsonB.
@Test
public void testJsonB() {
TableDef def = createTable(Rdbms.POSTGRESQL);
ColumnDef col = addColumn(def, "rec", SqlColumnType.TYPE_BIGINT);
IndexDef idx = new IndexDef("recidx", def.getIndices());
DataElementUtils.save(idx);
IndexColumnDef ic = new IndexColumnDef("rec", idx);
DataElementUtils.save(ic);
assertEquals("DROP TABLE IF EXISTS \"table\";\n" + "CREATE TABLE \"table\" (\n" + "rec BIGINT NOT NULL);\n" + "CREATE INDEX recidx ON \"table\"(rec);\n", def.getDdl());
col.setTypeString(SqlColumnType.TYPE_JSONB);
assertEquals("DROP TABLE IF EXISTS \"table\";\n" + "CREATE TABLE \"table\" (\n" + "rec JSONB NOT NULL);\n" + "CREATE INDEX recidx ON \"table\" USING GIN (rec);\n", def.getDdl());
}
use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class BaseTypeManagerTest method addColumn.
protected ColumnDef addColumn(TableDef def, String name, String type) {
ColumnDef col = new ColumnDef(name, def.getColumns());
col.setTypeString(type);
DataElementUtils.save(col);
return col;
}
use of com.developmentontheedge.be5.metadata.model.ColumnDef in project be5 by DevelopmentOnTheEdge.
the class Db2TypeManagerTest method testTypes.
@Test
public void testTypes() throws ExtendedSqlException {
TableDef def = createTable(Rdbms.DB2);
addColumn(def, "a", SqlColumnType.TYPE_BLOB);
addColumn(def, "b", SqlColumnType.TYPE_BIGTEXT);
addColumn(def, "c", SqlColumnType.TYPE_UINT);
addColumn(def, "d", SqlColumnType.TYPE_UBIGINT);
addColumn(def, "e", SqlColumnType.TYPE_DATETIME);
assertEquals("BEGIN DECLARE CONTINUE HANDLER FOR SQLSTATE '42704' BEGIN END; EXECUTE IMMEDIATE 'DROP TABLE \"table\"'; END;\n" + "CREATE TABLE \"table\" (\n" + "A BLOB(16M) NOT NULL,\n" + "B CLOB(128K) NOT NULL,\n" + "C INT NOT NULL,\n" + "D BIGINT NOT NULL,\n" + "E TIMESTAMP NOT NULL);\n", def.getDdl());
TableDef def2 = (TableDef) def.clone(def.getOrigin(), def.getName());
ColumnDef col = addColumn(def2, "f", SqlColumnType.TYPE_KEY);
col.setAutoIncrement(true);
col.setPrimaryKey(true);
assertEquals("ALTER TABLE \"table\" ADD COLUMN F BIGINT GENERATED BY DEFAULT AS IDENTITY (NO CACHE) NOT NULL PRIMARY KEY;\n" + "CALL admin_cmd('REORG TABLE \"table\"');", def2.getDiffDdl(def, null));
assertEquals("ALTER TABLE \"table\" DROP COLUMN F;\n" + "CALL admin_cmd('REORG TABLE \"table\"');", def.getDiffDdl(def2, null));
}
Aggregations