Search in sources :

Example 1 with EditIndexPage

use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by serge-rider.

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)

Example 2 with EditIndexPage

use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by serge-rider.

the class SQLServerIndexConfigurator method configureObject.

@Override
public SQLServerTableIndex configureObject(DBRProgressMonitor monitor, Object container, SQLServerTableIndex index) {
    return UITask.run(() -> {
        EditIndexPage editPage = new EditIndexPage("Create index", index, Arrays.asList(SQLSERVER_INDEX_TYPES));
        if (!editPage.edit()) {
            return null;
        }
        index.setUnique(editPage.isUnique());
        index.setIndexType(editPage.getIndexType());
        index.setDescription(editPage.getDescription());
        StringBuilder idxName = new StringBuilder(64);
        idxName.append(CommonUtils.escapeIdentifier(index.getTable().getName()));
        int colIndex = 1;
        for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
            if (colIndex == 1) {
                idxName.append("_").append(CommonUtils.escapeIdentifier(tableColumn.getName()));
            }
            index.addColumn(new SQLServerTableIndexColumn(index, 0, (SQLServerTableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC))));
        }
        idxName.append("_IDX");
        index.setName(DBObjectNameCaseTransformer.transformObjectName(index, idxName.toString()));
        return index;
    });
}
Also used : SQLServerTableIndexColumn(org.jkiss.dbeaver.ext.mssql.model.SQLServerTableIndexColumn) SQLServerTableColumn(org.jkiss.dbeaver.ext.mssql.model.SQLServerTableColumn) DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) EditIndexPage(org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)

Example 3 with EditIndexPage

use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by dbeaver.

the class OracleIndexConfigurator method configureObject.

@Override
public OracleTableIndex configureObject(DBRProgressMonitor monitor, Object container, OracleTableIndex index) {
    return UITask.run(() -> {
        EditIndexPage editPage = new EditIndexPage(OracleUIMessages.edit_oracle_index_manager_dialog_title, index, Collections.singletonList(DBSIndexType.OTHER));
        if (!editPage.edit()) {
            return null;
        }
        StringBuilder idxName = new StringBuilder(64);
        // $NON-NLS-1$
        idxName.append(CommonUtils.escapeIdentifier(index.getTable().getName())).append("_").append(CommonUtils.escapeIdentifier(editPage.getSelectedAttributes().iterator().next().getName())).append(// $NON-NLS-1$
        "_IDX");
        index.setName(DBObjectNameCaseTransformer.transformName(index.getDataSource(), idxName.toString()));
        index.setUnique(editPage.isUnique());
        index.setIndexType(editPage.getIndexType());
        int colIndex = 1;
        for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
            index.addColumn(new OracleTableIndexColumn(index, (OracleTableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC)), null));
        }
        return index;
    });
}
Also used : DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) OracleTableColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn) OracleTableIndexColumn(org.jkiss.dbeaver.ext.oracle.model.OracleTableIndexColumn) EditIndexPage(org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)

Example 4 with EditIndexPage

use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by dbeaver.

the class GenericTableIndexConfigurator method configureObject.

@Override
public GenericTableIndex configureObject(DBRProgressMonitor monitor, Object table, GenericTableIndex index) {
    GenericTableBase tableBase = (GenericTableBase) table;
    boolean supportUniqueIndexes = tableBase.supportUniqueIndexes();
    Collection<DBSIndexType> tableIndexTypes = tableBase.getTableIndexTypes();
    return new UITask<GenericTableIndex>() {

        @Override
        protected GenericTableIndex runTask() {
            EditIndexPage editPage = new EditIndexPage("Create index", index, tableIndexTypes, supportUniqueIndexes);
            if (!editPage.edit()) {
                return null;
            }
            index.setIndexType(editPage.getIndexType());
            StringBuilder idxName = new StringBuilder(64);
            idxName.append(CommonUtils.escapeIdentifier(index.getTable().getName()));
            int colIndex = 1;
            for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
                if (colIndex == 1) {
                    idxName.append("_").append(CommonUtils.escapeIdentifier(tableColumn.getName()));
                }
                index.addColumn(new GenericTableIndexColumn(index, (GenericTableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC))));
            }
            idxName.append("_IDX");
            index.setName(DBObjectNameCaseTransformer.transformObjectName(index, idxName.toString()));
            index.setUnique(editPage.isUnique());
            return index;
        }
    }.execute();
}
Also used : DBSIndexType(org.jkiss.dbeaver.model.struct.rdb.DBSIndexType) DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) GenericTableIndexColumn(org.jkiss.dbeaver.ext.generic.model.GenericTableIndexColumn) GenericTableBase(org.jkiss.dbeaver.ext.generic.model.GenericTableBase) GenericTableIndex(org.jkiss.dbeaver.ext.generic.model.GenericTableIndex) EditIndexPage(org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)

Example 5 with EditIndexPage

use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by dbeaver.

the class DB2IndexConfigurator method configureObject.

@Override
public DB2Index configureObject(DBRProgressMonitor monitor, Object container, DB2Index index) {
    return UITask.run(() -> {
        DB2TableBase table = (DB2TableBase) container;
        EditIndexPage editPage = new EditIndexPage(DB2Messages.edit_db2_index_manager_dialog_title, index, IX_TYPES);
        if (!editPage.edit()) {
            return null;
        }
        String tableName = CommonUtils.escapeIdentifier(table.getName());
        String colName = CommonUtils.escapeIdentifier(editPage.getSelectedAttributes().iterator().next().getName());
        String indexBaseName = String.format(CONS_IX_NAME, tableName, colName);
        String indexName = DBObjectNameCaseTransformer.transformName(table.getDataSource(), indexBaseName);
        index.setName(indexName);
        index.setIndexType(editPage.getIndexType());
        index.setUniqueRule(editPage.isUnique() ? DB2UniqueRule.U : DB2UniqueRule.D);
        int colIndex = 1;
        for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
            index.addColumn(new DB2IndexColumn(index, (DB2TableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC))));
        }
        return index;
    });
}
Also used : DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) DB2TableBase(org.jkiss.dbeaver.ext.db2.model.DB2TableBase) DB2TableColumn(org.jkiss.dbeaver.ext.db2.model.DB2TableColumn) DB2IndexColumn(org.jkiss.dbeaver.ext.db2.model.DB2IndexColumn) EditIndexPage(org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)

Aggregations

DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)10 EditIndexPage (org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)10 DBSIndexType (org.jkiss.dbeaver.model.struct.rdb.DBSIndexType)4 DB2IndexColumn (org.jkiss.dbeaver.ext.db2.model.DB2IndexColumn)2 DB2TableBase (org.jkiss.dbeaver.ext.db2.model.DB2TableBase)2 DB2TableColumn (org.jkiss.dbeaver.ext.db2.model.DB2TableColumn)2 ExasolTableColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn)2 ExasolTableIndexColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTableIndexColumn)2 GenericTableBase (org.jkiss.dbeaver.ext.generic.model.GenericTableBase)2 GenericTableIndex (org.jkiss.dbeaver.ext.generic.model.GenericTableIndex)2 GenericTableIndexColumn (org.jkiss.dbeaver.ext.generic.model.GenericTableIndexColumn)2 SQLServerTableColumn (org.jkiss.dbeaver.ext.mssql.model.SQLServerTableColumn)2 SQLServerTableIndexColumn (org.jkiss.dbeaver.ext.mssql.model.SQLServerTableIndexColumn)2 OracleTableColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableColumn)2 OracleTableIndexColumn (org.jkiss.dbeaver.ext.oracle.model.OracleTableIndexColumn)2