Search in sources :

Example 1 with SQLServerTableUniqueKeyColumn

use of org.jkiss.dbeaver.ext.mssql.model.SQLServerTableUniqueKeyColumn in project dbeaver by serge-rider.

the class SQLServerUniqueKeyConfigurator method configureObject.

@Override
public SQLServerTableUniqueKey configureObject(DBRProgressMonitor monitor, Object container, SQLServerTableUniqueKey primaryKey) {
    return UITask.run(() -> {
        EditConstraintPage editPage = new EditConstraintPage("Create constraint", primaryKey, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY });
        if (!editPage.edit()) {
            return null;
        }
        primaryKey.setConstraintType(editPage.getConstraintType());
        primaryKey.setName(editPage.getConstraintName());
        int colIndex = 1;
        for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
            primaryKey.addColumn(new SQLServerTableUniqueKeyColumn(primaryKey, (SQLServerTableColumn) tableColumn, colIndex++));
        }
        return primaryKey;
    });
}
Also used : SQLServerTableColumn(org.jkiss.dbeaver.ext.mssql.model.SQLServerTableColumn) DBSEntityAttribute(org.jkiss.dbeaver.model.struct.DBSEntityAttribute) SQLServerTableUniqueKeyColumn(org.jkiss.dbeaver.ext.mssql.model.SQLServerTableUniqueKeyColumn) EditConstraintPage(org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage)

Aggregations

SQLServerTableColumn (org.jkiss.dbeaver.ext.mssql.model.SQLServerTableColumn)1 SQLServerTableUniqueKeyColumn (org.jkiss.dbeaver.ext.mssql.model.SQLServerTableUniqueKeyColumn)1 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)1 EditConstraintPage (org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage)1