提交 512cb936 编写于 作者: S Serge Rider

Merge remote-tracking branch 'origin/devel' into devel


Former-commit-id: 5f566e7e
......@@ -102,6 +102,7 @@ public class DTUIMessages extends NLS {
public static String stream_consumer_page_settings_title;
public static String stream_consumer_page_settings_description;
public static String stream_consumer_page_settings_item_text_none;
public static String stream_consumer_page_warning_not_enough_sources_chosen;
public static String data_transfer_task_configurator_group_label_export_tables;
public static String data_transfer_task_configurator_group_label_import_into;
......
......@@ -73,6 +73,7 @@ stream_consumer_page_output_tooltip_process_command_line = Process command line
stream_consumer_page_settings_title = Format settings
stream_consumer_page_settings_description = File format settings
stream_consumer_page_settings_item_text_none = <none>
stream_consumer_page_warning_not_enough_sources_chosen = Not enough source files chosen
data_transfer_task_configurator_group_label_export_tables = Export tables
data_transfer_task_configurator_group_label_import_into = Import into
data_transfer_task_configurator_table_column_text_object = Object
......
......@@ -243,12 +243,12 @@ public class DatabaseConsumerPageMapping extends ActiveWizardPage<DataTransferWi
@Override
public void widgetSelected(SelectionEvent e)
{
DatabaseMappingObject selectedMapping = getSelectedMapping();
DBPDataSourceContainer dataSourceContainer = selectedMapping.getTarget().getDataSource().getContainer();
if(!dataSourceContainer.hasModifyPermission(DBPDataSourcePermission.PERMISSION_EDIT_METADATA)) {
DBPDataSourceContainer dataSourceContainer = getDatabaseConsumerSettings().getContainerNode().getDataSourceContainer();
if (!dataSourceContainer.hasModifyPermission(DBPDataSourcePermission.PERMISSION_EDIT_METADATA)) {
UIUtils.showMessageBox(getShell(), DTMessages.data_transfer_wizard_restricted_title, NLS.bind(DTMessages.data_transfer_wizard_restricted_description, dataSourceContainer.getName()), SWT.ICON_WARNING);
return;
}
DatabaseMappingObject selectedMapping = getSelectedMapping();
showPreview(selectedMapping instanceof DatabaseMappingContainer ?
(DatabaseMappingContainer) selectedMapping :
((DatabaseMappingAttribute)selectedMapping).getParent());
......
......@@ -16,6 +16,7 @@
*/
package org.jkiss.dbeaver.tools.transfer.ui.pages.stream;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
......@@ -36,10 +37,7 @@ import org.jkiss.dbeaver.model.struct.DBSDataManipulator;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
import org.jkiss.dbeaver.tools.transfer.DataTransferPipe;
import org.jkiss.dbeaver.tools.transfer.DataTransferSettings;
import org.jkiss.dbeaver.tools.transfer.IDataTransferConsumer;
import org.jkiss.dbeaver.tools.transfer.IDataTransferSettings;
import org.jkiss.dbeaver.tools.transfer.*;
import org.jkiss.dbeaver.tools.transfer.database.DatabaseConsumerSettings;
import org.jkiss.dbeaver.tools.transfer.database.DatabaseMappingContainer;
import org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferConsumer;
......@@ -64,7 +62,6 @@ import java.util.List;
import java.util.Map;
public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWizard> {
private static final Log log = Log.getLog(StreamProducerPageSettings.class);
private PropertyTreeViewer propsEditor;
......@@ -79,7 +76,6 @@ public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWiz
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
SashForm settingsDivider = new SashForm(parent, SWT.VERTICAL);
......@@ -125,7 +121,7 @@ public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWiz
updatePageCompletion();
}
private boolean chooseSourceFile(DataTransferPipe pipe) {
private void chooseSourceFile(DataTransferPipe pipe) {
List<String> extensions = new ArrayList<>();
String extensionProp = CommonUtils.toString(propertySource.getPropertyValue(null, "extension"));
for (String ext : extensionProp.split(",")) {
......@@ -150,17 +146,16 @@ public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWiz
getWizard().getRunnableContext().run(true, true, initializer);
} catch (InvocationTargetException e) {
DBWorkbench.getPlatformUI().showError("Column mappings error", "Error reading column mappings from stream", e.getTargetException());
return false;
return;
} catch (InterruptedException e) {
// ignore
}
}
reloadPipes();
updatePageCompletion();
return false;
}
private boolean updateSingleConsumer(DBRProgressMonitor monitor, DataTransferPipe pipe, File file) {
private void updateSingleConsumer(DBRProgressMonitor monitor, DataTransferPipe pipe, File file) {
final StreamProducerSettings producerSettings = getWizard().getPageSettings(this, StreamProducerSettings.class);
StreamTransferProducer producer = new StreamTransferProducer(new StreamEntityMapping(file));
......@@ -183,13 +178,11 @@ public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWiz
((DatabaseConsumerSettings) consumerSettings).addDataMappings(getWizard().getRunnableContext(), producer.getDatabaseObject(), mapping);
}
return true;
}
private boolean updateMultiConsumers(DBRProgressMonitor monitor, DataTransferPipe pipe, File[] files) {
private void updateMultiConsumers(DBRProgressMonitor monitor, DataTransferPipe pipe, File[] files) {
final StreamProducerSettings producerSettings = getWizard().getPageSettings(this, StreamProducerSettings.class);
IDataTransferConsumer originalConsumer = pipe.getConsumer();
IDataTransferConsumer<?, ?> originalConsumer = pipe.getConsumer();
DataTransferSettings dtSettings = getWizard().getSettings();
List<DataTransferPipe> newPipes = new ArrayList<>(dtSettings.getDataPipes());
......@@ -197,7 +190,7 @@ public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWiz
for (File file : files) {
StreamTransferProducer producer = new StreamTransferProducer(new StreamEntityMapping(file));
IDataTransferConsumer consumer = new DatabaseTransferConsumer();
IDataTransferConsumer<?, ?> consumer = new DatabaseTransferConsumer();
DataTransferPipe singlePipe = new DataTransferPipe(producer, consumer);
try {
......@@ -232,18 +225,17 @@ public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWiz
dtSettings.setDataPipes(newPipes, true);
dtSettings.setPipeChangeRestricted(true);
return true;
}
private void updateItemData(TableItem item, DataTransferPipe pipe) {
if (pipe.getProducer() == null || pipe.getProducer().getObjectName() == null) {
if (isInvalidDataTransferNode(pipe.getProducer())) {
item.setImage(0, null);
item.setText(0, DTUIMessages.stream_consumer_page_settings_item_text_none);
} else {
item.setImage(0, DBeaverIcons.getImage(getProducerProcessor().getIcon()));
item.setText(0, String.valueOf(pipe.getProducer().getObjectName()));
}
if (pipe.getConsumer() == null) {
if (isInvalidDataTransferNode(pipe.getConsumer())) {
item.setImage(1, null);
item.setText(1, DTUIMessages.stream_consumer_page_settings_item_text_none);
} else {
......@@ -252,6 +244,10 @@ public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWiz
}
}
private boolean isInvalidDataTransferNode(final IDataTransferNode<?> node) {
return node == null || node.getObjectName() == null;
}
@Override
public void activatePage() {
// Initialize property editor
......@@ -319,12 +315,14 @@ public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWiz
@Override
protected boolean determinePageCompletion() {
for (DataTransferPipe pipe : getWizard().getSettings().getDataPipes()) {
if (pipe.getConsumer() == null || pipe.getProducer() == null) {
for (int i = 0; i < filesTable.getItemCount(); i++) {
final DataTransferPipe pipe = (DataTransferPipe) filesTable.getItem(i).getData();
if (isInvalidDataTransferNode(pipe.getConsumer()) || isInvalidDataTransferNode(pipe.getProducer())) {
setMessage(DTUIMessages.stream_consumer_page_warning_not_enough_sources_chosen, IMessageProvider.WARNING);
return false;
}
}
setMessage(null);
return true;
}
......@@ -376,6 +374,4 @@ public class StreamProducerPageSettings extends ActiveWizardPage<DataTransferWiz
}
return name.toString();
}
}
\ No newline at end of file
}
......@@ -494,7 +494,14 @@ public class MySQLTable extends MySQLTableBase implements DBPObjectStatistics
fkList.add(fk);
}
MySQLTableForeignKeyColumn fkColumnInfo = new MySQLTableForeignKeyColumn(fk, fkColumn, keySeq, pkColumn);
fk.addColumn(fkColumnInfo);
if (fk.hasColumn(fkColumnInfo)) {
// Known MySQL bug, metaData.getImportedKeys() can return duplicates
// https://bugs.mysql.com/bug.php?id=95280
log.debug("FK "+ fkName +" has already been added, skip");
}
else {
fk.addColumn(fkColumnInfo);
}
}
}
} finally {
......
......@@ -89,6 +89,20 @@ public class MySQLTableForeignKey extends JDBCTableForeignKey<MySQLTable, MySQLT
columns.add(column);
}
public boolean hasColumn(MySQLTableForeignKeyColumn column) {
if (columns != null) {
String columnName = column.getName();
String refName = column.getReferencedColumn().getName();
for (MySQLTableForeignKeyColumn col : columns) {
if (columnName.equals(col.getName()) &&
refName.equals(col.getReferencedColumn().getName())) {
return true;
}
}
}
return false;
}
@NotNull
@Override
public String getFullyQualifiedName(DBPEvaluationContext context)
......
......@@ -117,7 +117,9 @@ public class PostgreTableColumnManager extends SQLTableColumnManager<PostgreTabl
}
if (typeName.equals(PostgreConstants.TYPE_INTERVAL)) {
final String precision = postgreColumn.getIntervalTypeField();
sql.append(' ').append(precision);
if (!CommonUtils.isEmpty(precision)) {
sql.append(' ').append(precision);
}
if (scale >= 0 && scale < 7) {
sql.append('(').append(scale).append(')');
}
......
......@@ -74,7 +74,9 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
public SQLQueryParameterBindDialog(IWorkbenchPartSite site, SQLQuery query, List<SQLQueryParameter> parameters)
{
super(site.getShell());
setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.RESIZE | getDefaultOrientation());
if (!UIUtils.isInDialog()) {
setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.BORDER | SWT.RESIZE | getDefaultOrientation());
}
this.site = site;
StringWriter dummyWriter = new StringWriter();
this.queryContext = new SQLScriptContext(null, new DataSourceContextProvider(query.getDataSource()), null, dummyWriter, null);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册