Search in sources :

Example 21 with ExasolTableColumn

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

the class ExasolTableIndexCache method fetchObjectRow.

@Override
protected ExasolTableIndexColumn[] fetchObjectRow(JDBCSession session, ExasolTable parent, ExasolTableIndex forObject, JDBCResultSet resultSet) throws SQLException, DBException {
    // ToDo: fix regex
    Matcher m = indexCols.matcher(JDBCUtils.safeGetString(resultSet, "REMARKS"));
    String[] colString;
    ArrayList<ExasolTableIndexColumn> indexCols = new ArrayList<ExasolTableIndexColumn>();
    if (m.find()) {
        colString = m.group(1).split(",");
        for (int i = 0; i < colString.length; i++) {
            ExasolTableColumn tableColumn = colString[i] == null ? null : parent.getAttribute(session.getProgressMonitor(), colString[i]);
            indexCols.add(new ExasolTableIndexColumn(forObject, tableColumn, i + 1));
        }
    }
    ExasolTableIndexColumn[] arrayIndexCols = new ExasolTableIndexColumn[indexCols.size()];
    arrayIndexCols = indexCols.toArray(arrayIndexCols);
    return arrayIndexCols;
}
Also used : Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn) ExasolTableIndexColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableIndexColumn)

Example 22 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, 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 23 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(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
    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)

Example 24 with ExasolTableColumn

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

the class ExasolTableColumnManager method addObjectCreateActions.

@Override
protected void addObjectCreateActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectCreateCommand command, Map<String, Object> options) {
    final ExasolTableColumn exasolColumn = command.getObject();
    // build nullability string
    String nullability = exasolColumn.isRequired() ? "NOT NULL" : "NULL";
    final String addSQL = DBUtils.getQuotedIdentifier(exasolColumn) + " " + exasolColumn.getFormatType() + " " + (exasolColumn.getDefaultValue() == null ? "" : " DEFAULT " + exasolColumn.getDefaultValue()) + " " + formatIdentiy(exasolColumn.isAutoGenerated(), exasolColumn.getIdentityValue()) + " " + nullability;
    actions.add(new SQLDatabasePersistAction("Add column", "ALTER TABLE " + exasolColumn.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " ADD COLUMN " + addSQL + " "));
    if (exasolColumn.isDistKey())
        try {
            modifyDistKey(monitor, exasolColumn);
        } catch (DBException e) {
            log.error("Failed to generate distribution key", e);
        }
}
Also used : DBException(org.jkiss.dbeaver.DBException) 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