Search in sources :

Example 11 with ExasolTableColumn

use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by dbeaver.

the class ExasolTableColumnManager method addObjectModifyActions.

// -----
// Alter
// -----
@Override
protected void addObjectModifyActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actionList, ObjectChangeCommand command, Map<String, Object> options) {
    ExasolTableColumn exasolColumn = command.getObject();
    Map<Object, Object> props = command.getProperties();
    if (props.containsKey("defaultValue") || props.containsKey("dataType") || props.containsKey("scale") || props.containsKey("maxLength") || props.containsKey("autoGenerated") || props.containsKey("identityValue") || props.containsKey("required")) {
        // build nullability string
        String nullability = "";
        if (exasolColumn.isOriRequired() != null && exasolColumn.isOriRequired() != exasolColumn.isRequired())
            nullability = exasolColumn.isRequired() ? "NOT NULL" : "NULL";
        final String deltaSQL = DBUtils.getQuotedIdentifier(exasolColumn) + " " + exasolColumn.getFormatType() + " " + (exasolColumn.getDefaultValue() == null ? "" : " DEFAULT " + exasolColumn.getDefaultValue()) + " " + formatIdentiy(exasolColumn.isAutoGenerated(), exasolColumn.getIdentityValue()) + " " + nullability;
        if (!deltaSQL.isEmpty()) {
            String sqlAlterColumn = String.format(SQL_ALTER, exasolColumn.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL), deltaSQL);
            actionList.add(new SQLDatabasePersistAction(CMD_ALTER, sqlAlterColumn));
        }
    }
    // Comment
    DBEPersistAction commentAction = buildCommentAction(exasolColumn);
    if (commentAction != null) {
        actionList.add(commentAction);
    }
    if (command.getProperties().containsKey("distKey")) {
        try {
            actionList.addAll(modifyDistKey(monitor, exasolColumn));
        } catch (DBException e) {
            log.error("Failed to modify distkey settings", e);
        }
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBEPersistAction(org.jkiss.dbeaver.model.edit.DBEPersistAction) ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 12 with ExasolTableColumn

use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by dbeaver.

the class ExasolTableColumnManager method createDatabaseObject.

// ------
// Create
// ------
@Override
protected ExasolTableColumn createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, Object container, Object copyFrom, Map<String, Object> options) {
    ExasolTableColumn column = new ExasolTableColumn((ExasolTableBase) container);
    column.setName(getNewColumnName(monitor, context, (ExasolTableBase) container));
    return column;
}
Also used : ExasolTableBase(org.jkiss.dbeaver.ext.exasol.model.ExasolTableBase) ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn)

Example 13 with ExasolTableColumn

use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by dbeaver.

the class ExasolTablePartitionColumnCache method getAllObjects.

@Override
public Collection<ExasolTablePartitionColumn> getAllObjects(DBRProgressMonitor monitor, ExasolTable owner) throws DBException {
    if (tablePartitionColumns.isEmpty() && !super.fullCache) {
        for (ExasolTableColumn col : owner.getAttributes(monitor)) {
            if (col.getPartitionKeyOrdinalPosition() != null) {
                tablePartitionColumns.add(new ExasolTablePartitionColumn(owner, col, col.getPartitionKeyOrdinalPosition().intValue()));
            }
        }
        sortPartitionColumns();
        super.setCache(tablePartitionColumns);
    }
    return tablePartitionColumns;
}
Also used : ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn) ExasolTablePartitionColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTablePartitionColumn)

Example 14 with ExasolTableColumn

use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by serge-rider.

the class ExasolTableColumnManager method createDatabaseObject.

// ------
// Create
// ------
@Override
protected ExasolTableColumn createDatabaseObject(DBRProgressMonitor monitor, DBECommandContext context, ExasolTableBase parent, Object copyFrom) {
    ExasolTableColumn column = new ExasolTableColumn(parent);
    column.setName(getNewColumnName(monitor, context, parent));
    return column;
}
Also used : ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn)

Example 15 with ExasolTableColumn

use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn in project dbeaver by serge-rider.

the class ExasolTableColumnManager method addObjectRenameActions.

@Override
protected void addObjectRenameActions(List<DBEPersistAction> actions, ObjectRenameCommand command) {
    final ExasolTableColumn column = command.getObject();
    actions.add(new SQLDatabasePersistAction("Rename column", "ALTER TABLE " + column.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " RENAME COLUMN " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getOldName()) + " TO " + DBUtils.getQuotedIdentifier(column.getDataSource(), command.getNewName())));
}
Also used : ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Aggregations

ExasolTableColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn)24 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)14 ArrayList (java.util.ArrayList)6 DBException (org.jkiss.dbeaver.DBException)4 ExasolTable (org.jkiss.dbeaver.ext.exasol.model.ExasolTable)4 ExasolTableIndexColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTableIndexColumn)4 DBEPersistAction (org.jkiss.dbeaver.model.edit.DBEPersistAction)4 Matcher (java.util.regex.Matcher)2 ExasolTableBase (org.jkiss.dbeaver.ext.exasol.model.ExasolTableBase)2 ExasolTablePartitionColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTablePartitionColumn)2 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2 DBSIndexType (org.jkiss.dbeaver.model.struct.rdb.DBSIndexType)2 EditIndexPage (org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)2