use of org.jkiss.dbeaver.model.virtual.DBVEntityConstraint in project dbeaver by serge-rider.
the class ValidateUniqueKeyUsageDialog method useAllColumns.
private static boolean useAllColumns(Shell shell, ResultSetViewer viewer) {
// Use all columns
final DBDRowIdentifier identifier = viewer.getVirtualEntityIdentifier();
DBVEntityConstraint constraint = (DBVEntityConstraint) identifier.getUniqueKey();
List<DBSEntityAttribute> uniqueColumns = new ArrayList<>();
for (DBDAttributeBinding binding : viewer.getModel().getAttributes()) {
if (binding.getEntityAttribute() != null) {
uniqueColumns.add(binding.getEntityAttribute());
}
}
if (uniqueColumns.isEmpty()) {
UIUtils.showErrorDialog(shell, "Use All Columns", "No valid columns found for unique key");
return false;
}
constraint.setAttributes(uniqueColumns);
try {
identifier.reloadAttributes(VoidProgressMonitor.INSTANCE, viewer.getModel().getAttributes());
} catch (DBException e) {
UIUtils.showErrorDialog(shell, "Use All Columns", "Can't reload unique columns", e);
return false;
}
return true;
}
use of org.jkiss.dbeaver.model.virtual.DBVEntityConstraint in project dbeaver by serge-rider.
the class ValidateUniqueKeyUsageDialog method useAllColumns.
private static boolean useAllColumns(ResultSetViewer viewer) {
// Use all columns
final DBDRowIdentifier identifier = viewer.getVirtualEntityIdentifier();
DBVEntityConstraint constraint = (DBVEntityConstraint) identifier.getUniqueKey();
List<DBSEntityAttribute> uniqueColumns = new ArrayList<>();
for (DBDAttributeBinding binding : viewer.getModel().getAttributes()) {
if (binding.getEntityAttribute() != null) {
uniqueColumns.add(binding.getEntityAttribute());
}
}
if (uniqueColumns.isEmpty()) {
DBWorkbench.getPlatformUI().showError("Use All Columns", "No valid columns found for unique key");
return false;
}
constraint.setAttributes(uniqueColumns);
constraint.setUseAllColumns(true);
try {
identifier.reloadAttributes(new VoidProgressMonitor(), viewer.getModel().getAttributes());
} catch (DBException e) {
DBWorkbench.getPlatformUI().showError("Use All Columns", "Can't reload unique columns", e);
return false;
}
return true;
}
use of org.jkiss.dbeaver.model.virtual.DBVEntityConstraint in project dbeaver by dbeaver.
the class ValidateUniqueKeyUsageDialog method useAllColumns.
private static boolean useAllColumns(Shell shell, ResultSetViewer viewer) {
// Use all columns
final DBDRowIdentifier identifier = viewer.getVirtualEntityIdentifier();
DBVEntityConstraint constraint = (DBVEntityConstraint) identifier.getUniqueKey();
List<DBSEntityAttribute> uniqueColumns = new ArrayList<>();
for (DBDAttributeBinding binding : viewer.getModel().getAttributes()) {
if (binding.getEntityAttribute() != null) {
uniqueColumns.add(binding.getEntityAttribute());
}
}
if (uniqueColumns.isEmpty()) {
DBUserInterface.getInstance().showError("Use All Columns", "No valid columns found for unique key");
return false;
}
constraint.setAttributes(uniqueColumns);
try {
identifier.reloadAttributes(new VoidProgressMonitor(), viewer.getModel().getAttributes());
} catch (DBException e) {
DBUserInterface.getInstance().showError("Use All Columns", "Can't reload unique columns", e);
return false;
}
return true;
}
use of org.jkiss.dbeaver.model.virtual.DBVEntityConstraint in project dbeaver by serge-rider.
the class VirtualUniqueKeyEditAction method isEnabled.
@Override
public boolean isEnabled() {
DBVEntity vEntity = resultSetViewer.getModel().getVirtualEntity(false);
DBVEntityConstraint vConstraint = vEntity == null ? null : vEntity.getBestIdentifier();
return vConstraint != null && (define != vConstraint.hasAttributes());
}
Aggregations