use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableUniqueKey in project dbeaver by dbeaver.
the class ExasolCreateForeignKeyDialog method handleRefTableSelect.
private void handleRefTableSelect(ISelection selection) {
DBNDatabaseNode refTableNode = null;
if (!selection.isEmpty() && selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) {
final Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof DBNDatabaseNode && ((DBNDatabaseNode) element).getObject() instanceof DBSTable && ((DBNDatabaseNode) element).getObject().isPersisted()) {
refTableNode = (DBNDatabaseNode) element;
}
}
if (refTableNode != null) {
if (refTableNode.getObject() == curRefTable) {
// The same selection
return;
} else {
curRefTable = (ExasolTable) refTableNode.getObject();
}
}
uniqueKeyCombo.removeAll();
try {
curConstraints = new ArrayList<>();
curConstraint = null;
if (refTableNode != null) {
final ExasolTable refTable = (ExasolTable) refTableNode.getObject();
DBeaverUI.runInProgressService(new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
// Cache own table columns
ownTable.getAttributes(monitor);
// Cache ref table columns
refTable.getAttributes(monitor);
// Get constraints
final Collection<? extends ExasolTableUniqueKey> constraints = refTable.getConstraints(monitor);
if (!CommonUtils.isEmpty(constraints)) {
for (ExasolTableUniqueKey constraint : constraints) {
if (constraint.getConstraintType().isUnique()) {
curConstraints.add(constraint);
}
}
}
} catch (DBException e) {
throw new InvocationTargetException(e);
}
}
});
}
for (DBSTableConstraint constraint : curConstraints) {
uniqueKeyCombo.add(constraint.getName());
}
uniqueKeyCombo.select(0);
uniqueKeyCombo.setEnabled(curConstraints.size() > 1);
if (curConstraints.size() == 1) {
curConstraint = curConstraints.get(0);
}
} catch (InvocationTargetException e) {
DBUserInterface.getInstance().showError(CoreMessages.dialog_struct_edit_fk_error_load_constraints_title, CoreMessages.dialog_struct_edit_fk_error_load_constraints_message, e.getTargetException());
} catch (InterruptedException e) {
// do nothing
}
handleUniqueKeySelect();
updatePageState();
}
use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableUniqueKey in project dbeaver by serge-rider.
the class ExasolPrimaryKeyManager method addObjectRenameActions.
@Override
protected void addObjectRenameActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
final ExasolTableUniqueKey key = command.getObject();
actions.add(new SQLDatabasePersistAction("Rename PK", "ALTER TABLE " + DBUtils.getObjectFullName(key.getTable(), DBPEvaluationContext.DDL) + " RENAME CONSTRAINT " + DBUtils.getQuotedIdentifier(key.getDataSource(), command.getOldName()) + " to " + DBUtils.getQuotedIdentifier(key.getDataSource(), command.getNewName())));
}
use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableUniqueKey in project dbeaver by dbeaver.
the class ExasolPrimaryKeyManager method addObjectRenameActions.
@Override
protected void addObjectRenameActions(List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
final ExasolTableUniqueKey key = command.getObject();
actions.add(new SQLDatabasePersistAction("Rename PK", "ALTER TABLE " + DBUtils.getObjectFullName(key.getTable(), DBPEvaluationContext.DDL) + " RENAME CONSTRAINT " + DBUtils.getQuotedIdentifier(key.getDataSource(), command.getOldName()) + " to " + DBUtils.getQuotedIdentifier(key.getDataSource(), command.getNewName())));
}
use of org.jkiss.dbeaver.ext.exasol.model.ExasolTableUniqueKey in project dbeaver by dbeaver.
the class ExasolPrimaryKeyManager method addObjectRenameActions.
@Override
protected void addObjectRenameActions(DBRProgressMonitor monitor, DBCExecutionContext executionContext, List<DBEPersistAction> actions, ObjectRenameCommand command, Map<String, Object> options) {
final ExasolTableUniqueKey key = command.getObject();
actions.add(new SQLDatabasePersistAction("Rename PK", "ALTER TABLE " + DBUtils.getObjectFullName(key.getTable(), DBPEvaluationContext.DDL) + " RENAME CONSTRAINT " + DBUtils.getQuotedIdentifier(key.getDataSource(), command.getOldName()) + " to " + DBUtils.getQuotedIdentifier(key.getDataSource(), command.getNewName())));
}
Aggregations