use of org.jkiss.dbeaver.tools.transfer.database.DatabaseConsumerSettings in project dbeaver by serge-rider.
the class DatabaseConsumerPageLoadSettings method createControl.
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite composite = UIUtils.createComposite(parent, 1);
final DatabaseConsumerSettings settings = getSettings();
{
loadSettings = UIUtils.createControlGroup(composite, DTUIMessages.database_consumer_wizard_name, 2, GridData.FILL_HORIZONTAL, 0);
transferAutoGeneratedColumns = UIUtils.createCheckbox(loadSettings, DTUIMessages.database_consumer_wizard_transfer_checkbox_label, DTUIMessages.database_consumer_wizard_transfer_checkbox_tooltip, settings.isTransferAutoGeneratedColumns(), 2);
transferAutoGeneratedColumns.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setTransferAutoGeneratedColumns(transferAutoGeneratedColumns.getSelection());
}
});
truncateTargetTable = UIUtils.createCheckbox(loadSettings, DTUIMessages.database_consumer_wizard_truncate_checkbox_label, DTUIMessages.database_consumer_wizard_truncate_checkbox_description, settings.isTruncateBeforeLoad(), 2);
truncateTargetTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (truncateTargetTable.getSelection() && !confirmDataTruncate()) {
truncateTargetTable.setSelection(false);
return;
}
settings.setTruncateBeforeLoad(truncateTargetTable.getSelection());
}
});
UIUtils.createControlLabel(loadSettings, DTUIMessages.database_consumer_wizard_on_duplicate_key_insert_method_text);
onDuplicateKeyInsertMethods = new Combo(loadSettings, SWT.DROP_DOWN | SWT.READ_ONLY);
onDuplicateKeyInsertMethods.setLayoutData(new GridData(GridData.FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false, 1, 1));
Link urlLabel = UIUtils.createLink(loadSettings, "<a href=\"" + REPLACE_METHOD_LINK + "\">" + DTUIMessages.database_consumer_wizard_link_label_replace_method_wiki + "</a>", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
UIUtils.launchProgram(REPLACE_METHOD_LINK);
}
});
urlLabel.setLayoutData(new GridData(GridData.FILL, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 2, 1));
}
{
Group performanceSettings = UIUtils.createControlGroup(composite, DTUIMessages.database_consumer_wizard_performance_group_label, 4, GridData.FILL_HORIZONTAL, 0);
final Button newConnectionCheckbox = UIUtils.createCheckbox(performanceSettings, DTMessages.data_transfer_wizard_output_checkbox_new_connection, null, settings.isOpenNewConnections(), 4);
newConnectionCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setOpenNewConnections(newConnectionCheckbox.getSelection());
}
});
final Button useTransactionsCheck = UIUtils.createCheckbox(performanceSettings, DTUIMessages.database_consumer_wizard_transactions_checkbox_label, null, settings.isUseTransactions(), 4);
useTransactionsCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setUseTransactions(useTransactionsCheck.getSelection());
}
});
final Spinner commitAfterEdit = UIUtils.createLabelSpinner(performanceSettings, DTUIMessages.database_consumer_wizard_commit_spinner_label, settings.getCommitAfterRows(), 1, Integer.MAX_VALUE);
commitAfterEdit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setCommitAfterRows(commitAfterEdit.getSelection());
}
});
commitAfterEdit.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 3, 1));
final Button useBatchCheck = UIUtils.createCheckbox(performanceSettings, DTUIMessages.database_consumer_wizard_disable_import_batches_label, DTUIMessages.database_consumer_wizard_disable_import_batches_description, settings.isDisableUsingBatches(), 4);
useBatchCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setDisableUsingBatches(useBatchCheck.getSelection());
}
});
}
{
Group generalSettings = UIUtils.createControlGroup(composite, DTUIMessages.database_consumer_wizard_general_group_label, 4, GridData.FILL_HORIZONTAL, 0);
final Button showTableCheckbox = UIUtils.createCheckbox(generalSettings, DTUIMessages.database_consumer_wizard_table_checkbox_label, null, settings.isOpenTableOnFinish(), 4);
showTableCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setOpenTableOnFinish(showTableCheckbox.getSelection());
}
});
final Button showFinalMessageCheckbox = UIUtils.createCheckbox(generalSettings, DTUIMessages.database_consumer_wizard_final_message_checkbox_label, null, getWizard().getSettings().isShowFinalMessage(), 4);
showFinalMessageCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getWizard().getSettings().setShowFinalMessage(showFinalMessageCheckbox.getSelection());
}
});
}
setControl(composite);
}
use of org.jkiss.dbeaver.tools.transfer.database.DatabaseConsumerSettings in project dbeaver by serge-rider.
the class DatabaseConsumerPageLoadSettings method loadSettings.
private void loadSettings() {
DatabaseConsumerSettings settings = getSettings();
if (settings.isTruncateBeforeLoad() && !confirmDataTruncate()) {
truncateTargetTable.setSelection(false);
settings.setTruncateBeforeLoad(false);
}
loadInsertMethods();
}
use of org.jkiss.dbeaver.tools.transfer.database.DatabaseConsumerSettings in project dbeaver by serge-rider.
the class StreamProducerPageSettings method updateMultiConsumers.
private void updateMultiConsumers(DBRProgressMonitor monitor, DataTransferPipe pipe, File[] files) {
final StreamProducerSettings producerSettings = getWizard().getPageSettings(this, StreamProducerSettings.class);
IDataTransferConsumer<?, ?> originalConsumer = pipe.getConsumer();
DataTransferSettings dtSettings = getWizard().getSettings();
List<DataTransferPipe> newPipes = new ArrayList<>(dtSettings.getDataPipes());
newPipes.remove(pipe);
for (File file : files) {
StreamTransferProducer producer = new StreamTransferProducer(new StreamEntityMapping(file));
IDataTransferConsumer<?, ?> consumer = new DatabaseTransferConsumer();
DataTransferPipe singlePipe = new DataTransferPipe(producer, consumer);
try {
singlePipe.initPipe(dtSettings, newPipes.size(), newPipes.size());
} catch (DBException e) {
log.error(e);
continue;
}
newPipes.add(singlePipe);
producerSettings.updateProducerSettingsFromStream(monitor, producer, dtSettings);
IDataTransferSettings consumerSettings = dtSettings.getNodeSettings(dtSettings.getConsumer());
if (consumerSettings instanceof DatabaseConsumerSettings) {
DatabaseConsumerSettings dcs = (DatabaseConsumerSettings) consumerSettings;
if (originalConsumer != null && originalConsumer.getTargetObjectContainer() instanceof DBSObject) {
DBNDatabaseNode containerNode = DBNUtils.getNodeByObject(monitor, (DBSObject) originalConsumer.getTargetObjectContainer(), false);
if (containerNode != null) {
dcs.setContainerNode(containerNode);
}
}
DatabaseMappingContainer mapping = new DatabaseMappingContainer(dcs, producer.getDatabaseObject());
// mapping.setTarget(null);
mapping.setTargetName(generateTableName(producer.getInputFile()));
dcs.addDataMappings(getWizard().getRunnableContext(), producer.getDatabaseObject(), mapping);
}
}
dtSettings.setDataPipes(newPipes, false);
dtSettings.setPipeChangeRestricted(true);
}
use of org.jkiss.dbeaver.tools.transfer.database.DatabaseConsumerSettings in project dbeaver by serge-rider.
the class StreamProducerPageSettings method deactivatePage.
@Override
public void deactivatePage() {
// Save settings.
// It is a producer so it must prepare data for consumers
// Save processor properties
propsEditor.saveEditorValues();
Map<String, Object> processorProperties = propertySource.getPropertiesWithDefaults();
DataTransferSettings dtSettings = getWizard().getSettings();
dtSettings.setProcessorProperties(processorProperties);
final StreamProducerSettings producerSettings = getWizard().getPageSettings(this, StreamProducerSettings.class);
if (producerSettings != null) {
producerSettings.setProcessorProperties(processorProperties);
}
// Update column mappings for database consumers
IDataTransferSettings consumerSettings = getWizard().getSettings().getNodeSettings(getWizard().getSettings().getConsumer());
try {
getWizard().getRunnableContext().run(true, true, monitor -> {
for (DataTransferPipe pipe : dtSettings.getDataPipes()) {
if (pipe.getProducer() instanceof StreamTransferProducer) {
StreamTransferProducer producer = (StreamTransferProducer) pipe.getProducer();
producerSettings.updateProducerSettingsFromStream(monitor, producer, dtSettings);
if (consumerSettings instanceof DatabaseConsumerSettings) {
DatabaseMappingContainer mapping = ((DatabaseConsumerSettings) consumerSettings).getDataMapping(producer.getDatabaseObject());
if (mapping != null) {
mapping.getAttributeMappings(monitor);
}
}
}
}
});
} catch (InvocationTargetException e) {
DBWorkbench.getPlatformUI().showError("Error updating stream settings", "Error updating settings", e.getTargetException());
} catch (InterruptedException e) {
// ignore
}
super.deactivatePage();
}
Aggregations