Search in sources :

Example 16 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, 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 17 with ExasolTableColumn

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

the class ExasolTableColumnManager method modifyDistKey.

private Collection<SQLDatabasePersistAction> modifyDistKey(DBRProgressMonitor monitor, ExasolTableColumn exasolColumn) throws DBException {
    ExasolTable table = (ExasolTable) exasolColumn.getParentObject();
    Collection<ExasolTableColumn> distKey = table.getDistributionKey(monitor);
    Collection<SQLDatabasePersistAction> commands = new ArrayList<SQLDatabasePersistAction>();
    if (table.getAdditionalInfo(monitor).getHasDistKey(monitor)) {
        commands.add(generateDropDist(exasolColumn));
    }
    if (!distKey.isEmpty())
        commands.add(generateCreateDist(distKey));
    return commands;
}
Also used : ArrayList(java.util.ArrayList) ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn) ExasolTable(org.jkiss.dbeaver.ext.exasol.model.ExasolTable) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 18 with ExasolTableColumn

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

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 19 with ExasolTableColumn

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

the class ExasolTableColumnManager method generateCreateDist.

private SQLDatabasePersistAction generateCreateDist(Collection<ExasolTableColumn> distKey) {
    ExasolTable table = null;
    Collection<String> names = new ArrayList<>();
    for (ExasolTableColumn c : distKey) {
        if (table == null)
            table = (ExasolTable) c.getParentObject();
        names.add(c.getName());
    }
    return new SQLDatabasePersistAction("Create Distribution Key", String.format(CREATE_DIST_KEY, table.getFullyQualifiedName(DBPEvaluationContext.DDL), CommonUtils.joinStrings(",", names)));
}
Also used : ArrayList(java.util.ArrayList) ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn) ExasolTable(org.jkiss.dbeaver.ext.exasol.model.ExasolTable) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 20 with ExasolTableColumn

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

the class ExasolIndexConfigurator method configureObject.

@Override
public ExasolTableIndex configureObject(DBRProgressMonitor monitor, Object container, ExasolTableIndex index) {
    return UITask.run(() -> {
        EditIndexPage editPage = new EditIndexPage("create index", index, Arrays.asList(new DBSIndexType("LOCAL", "LOCAL"), new DBSIndexType("GLOBAL", "GLOBAL")), false);
        if (!editPage.edit()) {
            return null;
        }
        index.setIndexType(editPage.getIndexType());
        int colIndex = 1;
        for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
            index.addColumn(new ExasolTableIndexColumn(index, (ExasolTableColumn) tableColumn, colIndex++));
        }
        index.setName(index.getIndexType().getName() + " INDEX " + index.getSimpleColumnString());
        return index;
    });
}
Also used : DBSIndexType(org.jkiss.dbeaver.model.struct.rdb.DBSIndexType) DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) ExasolTableColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn) ExasolTableIndexColumn(org.jkiss.dbeaver.ext.exasol.model.ExasolTableIndexColumn) EditIndexPage(org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)

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