Search in sources :

Example 1 with ExasolTableIndexColumn

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

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 2 with ExasolTableIndexColumn

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

Aggregations

ExasolTableColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTableColumn)2 ExasolTableIndexColumn (org.jkiss.dbeaver.ext.exasol.model.ExasolTableIndexColumn)2 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)1 DBSIndexType (org.jkiss.dbeaver.model.struct.rdb.DBSIndexType)1 EditIndexPage (org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage)1