Search in sources :

Example 1 with GenericTableIndex

use of org.jkiss.dbeaver.ext.generic.model.GenericTableIndex in project dbeaver by dbeaver.

the class HiveIndexManager method addObjectDeleteActions.

@Override
protected void addObjectDeleteActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectDeleteCommand command, Map<String, Object> options) {
    GenericTableIndex tableIndex = command.getObject();
    actions.add(new SQLDatabasePersistAction("Drop index table", "DROP INDEX " + tableIndex.getName() + " ON " + // $NON-NLS-2$
    tableIndex.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL)));
}
Also used : GenericTableIndex(org.jkiss.dbeaver.ext.generic.model.GenericTableIndex) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 2 with GenericTableIndex

use of org.jkiss.dbeaver.ext.generic.model.GenericTableIndex 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 3 with GenericTableIndex

use of org.jkiss.dbeaver.ext.generic.model.GenericTableIndex in project dbeaver by serge-rider.

the class HiveIndexManager method addObjectDeleteActions.

@Override
protected void addObjectDeleteActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectDeleteCommand command, Map<String, Object> options) {
    GenericTableIndex tableIndex = command.getObject();
    actions.add(new SQLDatabasePersistAction("Drop index table", "DROP INDEX " + tableIndex.getName() + " ON " + // $NON-NLS-2$
    tableIndex.getTable().getFullyQualifiedName(DBPEvaluationContext.DDL)));
}
Also used : GenericTableIndex(org.jkiss.dbeaver.ext.generic.model.GenericTableIndex) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 4 with GenericTableIndex

use of org.jkiss.dbeaver.ext.generic.model.GenericTableIndex in project dbeaver by serge-rider.

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)

Aggregations

GenericTableIndex (org.jkiss.dbeaver.ext.generic.model.GenericTableIndex)4 GenericTableBase (org.jkiss.dbeaver.ext.generic.model.GenericTableBase)2 GenericTableIndexColumn (org.jkiss.dbeaver.ext.generic.model.GenericTableIndexColumn)2 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)2 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)2 DBSIndexType (org.jkiss.dbeaver.model.struct.rdb.DBSIndexType)2 EditIndexPage (org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)2