Search in sources :

Example 6 with DbColId

use of ch.ehi.sqlgen.repository.DbColId in project ili2db by claeis.

the class GeneratorMsSql method visitColumn.

@Override
public void visitColumn(DbTable dbTab, DbColumn column) throws IOException {
    String type = "";
    if (column instanceof DbColBoolean) {
        type = "BIT";
    } else if (column instanceof DbColDateTime) {
        type = "DATETIME";
    } else if (column instanceof DbColDate) {
        type = "DATE";
    } else if (column instanceof DbColTime) {
        type = "TIME";
    } else if (column instanceof DbColDecimal) {
        DbColDecimal col = (DbColDecimal) column;
        type = "DECIMAL(" + Integer.toString(col.getSize()) + "," + Integer.toString(col.getPrecision()) + ")";
    } else if (column instanceof DbColGeometry) {
        type = "GEOMETRY";
    } else if (column instanceof DbColId) {
        type = "BIGINT";
    } else if (column instanceof DbColUuid) {
        type = "VARCHAR(36)";
    } else if (column instanceof DbColNumber) {
        DbColNumber col = (DbColNumber) column;
        type = "NUMERIC(" + Integer.toString(col.getSize()) + ")";
    } else if (column instanceof DbColVarchar) {
        int colsize = ((DbColVarchar) column).getSize();
        if (colsize != DbColVarchar.UNLIMITED)
            type = "VARCHAR(" + Integer.toString(colsize) + ")";
        else
            type = "VARCHAR(MAX)";
    } else {
        type = "VARCHAR(MAX)";
    }
    String isNull = column.isNotNull() ? "NOT NULL" : "NULL";
    if (column.isPrimaryKey()) {
        isNull = "PRIMARY KEY";
    }
    String sep = " ";
    String defaultValue = "";
    if (column.getDefaultValue() != null) {
        defaultValue = sep + "DEFAULT (" + column.getDefaultValue() + ")";
        sep = " ";
    }
    String name = column.getName();
    out.write(getIndent() + colSep + "[" + name + "] " + type + " " + isNull + defaultValue + newline());
    colSep = ",";
}
Also used : DbColBoolean(ch.ehi.sqlgen.repository.DbColBoolean) DbColGeometry(ch.ehi.sqlgen.repository.DbColGeometry) DbColVarchar(ch.ehi.sqlgen.repository.DbColVarchar) DbColTime(ch.ehi.sqlgen.repository.DbColTime) DbColDecimal(ch.ehi.sqlgen.repository.DbColDecimal) DbColDateTime(ch.ehi.sqlgen.repository.DbColDateTime) DbColId(ch.ehi.sqlgen.repository.DbColId) DbColUuid(ch.ehi.sqlgen.repository.DbColUuid) DbColNumber(ch.ehi.sqlgen.repository.DbColNumber) DbColDate(ch.ehi.sqlgen.repository.DbColDate)

Example 7 with DbColId

use of ch.ehi.sqlgen.repository.DbColId in project ili2db by claeis.

the class AbstractRecordConverter method addKeyCol.

public DbColId addKeyCol(DbTable table) {
    DbColId dbColId = new DbColId();
    dbColId.setName(colT_ID);
    dbColId.setNotNull(true);
    dbColId.setPrimaryKey(true);
    if (table.isRequiresSequence()) {
        dbColId.setDefaultValue(idGen.getDefaultValueSql());
    }
    table.addColumn(dbColId);
    return dbColId;
}
Also used : DbColId(ch.ehi.sqlgen.repository.DbColId)

Aggregations

DbColId (ch.ehi.sqlgen.repository.DbColId)7 DbColVarchar (ch.ehi.sqlgen.repository.DbColVarchar)5 ViewableWrapper (ch.ehi.ili2db.mapping.ViewableWrapper)3 DbColBoolean (ch.ehi.sqlgen.repository.DbColBoolean)3 DbColGeometry (ch.ehi.sqlgen.repository.DbColGeometry)3 DbTable (ch.ehi.sqlgen.repository.DbTable)3 DbTableName (ch.ehi.sqlgen.repository.DbTableName)3 AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)3 BasketType (ch.interlis.ili2c.metamodel.BasketType)3 BlackboxType (ch.interlis.ili2c.metamodel.BlackboxType)3 CompositionType (ch.interlis.ili2c.metamodel.CompositionType)3 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)3 NumericType (ch.interlis.ili2c.metamodel.NumericType)3 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)3 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)3 TextType (ch.interlis.ili2c.metamodel.TextType)3 Viewable (ch.interlis.ili2c.metamodel.Viewable)3 DbColDate (ch.ehi.sqlgen.repository.DbColDate)2 DbColDateTime (ch.ehi.sqlgen.repository.DbColDateTime)2 DbColDecimal (ch.ehi.sqlgen.repository.DbColDecimal)2