use of org.jkiss.dbeaver.ext.mssql.model.SQLServerTableColumn 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;
});
}
use of org.jkiss.dbeaver.ext.mssql.model.SQLServerTableColumn 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;
});
}
use of org.jkiss.dbeaver.ext.mssql.model.SQLServerTableColumn in project dbeaver by dbeaver.
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;
});
}
use of org.jkiss.dbeaver.ext.mssql.model.SQLServerTableColumn in project dbeaver by dbeaver.
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;
});
}
Aggregations