use of org.jkiss.dbeaver.tools.transfer.DataTransferPipe in project dbeaver by dbeaver.
the class DatabaseConsumerPageMapping method showPreview.
private void showPreview(DatabaseMappingContainer mappingContainer) {
DataTransferPipe pipe = getPipe(mappingContainer);
DataTransferSettings dtSettings = getWizard().getSettings();
PreviewMappingDialog previewDialog = new PreviewMappingDialog(getShell(), pipe, mappingContainer, dtSettings);
previewDialog.open();
}
use of org.jkiss.dbeaver.tools.transfer.DataTransferPipe in project dbeaver by dbeaver.
the class DatabaseProducerPageInputObjects method activatePage.
@Override
public void activatePage() {
// final DatabaseProducerSettings settings = getWizard().getPageSettings(this, DatabaseProducerSettings.class);
DataTransferSettings settings = getWizard().getSettings();
mappingTable.removeAll();
for (DataTransferPipe pipe : settings.getDataPipes()) {
TableItem item = new TableItem(mappingTable, SWT.NONE);
item.setData(pipe);
updateItemData(item, pipe);
}
updatePageCompletion();
}
use of org.jkiss.dbeaver.tools.transfer.DataTransferPipe in project dbeaver by dbeaver.
the class DatabaseProducerPageInputObjects method autoAssignMappings.
private void autoAssignMappings(List<DBSObject> containerObjects) {
boolean chooseConsumer = getWizard().getSettings().isConsumerOptional();
for (TableItem item : mappingTable.getItems()) {
DataTransferPipe pipe = (DataTransferPipe) item.getData();
if ((chooseConsumer && (pipe.getConsumer() == null || pipe.getConsumer().getDatabaseObject() == null)) || (!chooseConsumer && (pipe.getProducer() == null || pipe.getProducer().getDatabaseObject() == null))) {
DBSObject objectToMap = chooseConsumer ? pipe.getProducer().getDatabaseObject() : pipe.getConsumer().getDatabaseObject();
if (objectToMap == null) {
continue;
}
DBSObject object = DBUtils.findObject(containerObjects, objectToMap.getName());
if (object != null) {
if (chooseConsumer) {
if (object instanceof DBSDataManipulator) {
pipe.setConsumer(new DatabaseTransferConsumer((DBSDataManipulator) object));
}
} else {
if (object instanceof DBSDataContainer) {
pipe.setProducer(new DatabaseTransferProducer((DBSDataContainer) object));
}
}
updateItemData(item, pipe);
}
}
}
updatePageCompletion();
}
use of org.jkiss.dbeaver.tools.transfer.DataTransferPipe in project dbeaver by dbeaver.
the class DTTaskHandlerTransfer method executeWithSettings.
public void executeWithSettings(@NotNull DBRRunnableContext runnableContext, DBTTask task, @NotNull Locale locale, @NotNull Log log, @NotNull DBTTaskExecutionListener listener, DataTransferSettings settings) throws DBException {
// Start consumers
listener.taskStarted(settings);
List<DataTransferPipe> dataPipes = settings.getDataPipes();
try {
runnableContext.run(true, false, monitor -> {
monitor.beginTask("Initialize pipes", dataPipes.size());
try {
for (int i = 0; i < dataPipes.size(); i++) {
DataTransferPipe pipe = dataPipes.get(i);
pipe.initPipe(settings, i, dataPipes.size());
pipe.getConsumer().startTransfer(monitor);
monitor.worked(1);
}
} catch (DBException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
});
} catch (InvocationTargetException e) {
throw new DBException("Error starting data transfer", e.getTargetException());
} catch (InterruptedException e) {
return;
}
// Schedule jobs for data providers
int totalJobs = settings.getDataPipes().size();
if (totalJobs > settings.getMaxJobCount()) {
totalJobs = settings.getMaxJobCount();
}
Throwable error = null;
for (int i = 0; i < totalJobs; i++) {
DataTransferJob job = new DataTransferJob(settings, task, locale, log, listener);
try {
runnableContext.run(true, true, job);
} catch (InvocationTargetException e) {
error = e.getTargetException();
} catch (InterruptedException e) {
break;
}
listener.subTaskFinished(error);
}
listener.taskFinished(settings, error);
}
use of org.jkiss.dbeaver.tools.transfer.DataTransferPipe in project dbeaver by serge-rider.
the class DatabaseProducerPageInputObjects method createControl.
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite composite = UIUtils.createComposite(parent, 1);
DataTransferSettings settings = getWizard().getSettings();
{
Group tablesGroup = UIUtils.createControlGroup(composite, DTMessages.data_transfer_wizard_mappings_name, 3, GridData.FILL_BOTH, 0);
mappingTable = new Table(tablesGroup, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
mappingTable.setLayoutData(new GridData(GridData.FILL_BOTH));
mappingTable.setHeaderVisible(true);
mappingTable.setLinesVisible(true);
UIUtils.createTableColumn(mappingTable, SWT.LEFT, DTUIMessages.data_transfer_wizard_final_column_source);
UIUtils.createTableColumn(mappingTable, SWT.LEFT, DTUIMessages.data_transfer_wizard_final_column_target);
mappingTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (mappingTable.getSelectionIndex() < 0) {
return;
}
TableItem item = mappingTable.getItem(mappingTable.getSelectionIndex());
DataTransferPipe pipe = (DataTransferPipe) item.getData();
if (chooseEntity(pipe)) {
updateItemData(item, pipe);
updatePageCompletion();
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
UIUtils.asyncExec(() -> UIUtils.packColumns(mappingTable, true));
}
{
Composite controlGroup = UIUtils.createComposite(composite, 1);
Button autoAssignButton = new Button(controlGroup, SWT.PUSH);
autoAssignButton.setImage(DBeaverIcons.getImage(UIIcon.ASTERISK));
autoAssignButton.setText(DTMessages.data_transfer_db_consumer_auto_assign);
autoAssignButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
autoAssignMappings();
}
});
}
setControl(composite);
}
Aggregations