Search in sources :

Example 1 with DB2IndexColumn

use of org.jkiss.dbeaver.ext.db2.model.DB2IndexColumn 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)

Example 2 with DB2IndexColumn

use of org.jkiss.dbeaver.ext.db2.model.DB2IndexColumn in project dbeaver by serge-rider.

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

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 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)2 EditIndexPage (org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)2