Search in sources :

Example 11 with DataTransferPipe

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();
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe)

Example 12 with DataTransferPipe

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();
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe)

Example 13 with DataTransferPipe

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();
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseTransferConsumer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferConsumer) DBSDataManipulator(org.jkiss.dbeaver.model.struct.DBSDataManipulator) DatabaseTransferProducer(org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer) DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe)

Example 14 with DataTransferPipe

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);
}
Also used : DBException(org.jkiss.dbeaver.DBException) DataTransferJob(org.jkiss.dbeaver.tools.transfer.DataTransferJob) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 15 with DataTransferPipe

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);
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe)

Aggregations

DataTransferPipe (org.jkiss.dbeaver.tools.transfer.DataTransferPipe)16 DataTransferSettings (org.jkiss.dbeaver.tools.transfer.DataTransferSettings)8 GridData (org.eclipse.swt.layout.GridData)4 DBException (org.jkiss.dbeaver.DBException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SashForm (org.eclipse.swt.custom.SashForm)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)2 DBSDataContainer (org.jkiss.dbeaver.model.struct.DBSDataContainer)2 DBSDataManipulator (org.jkiss.dbeaver.model.struct.DBSDataManipulator)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2 DataTransferJob (org.jkiss.dbeaver.tools.transfer.DataTransferJob)2 DatabaseTransferConsumer (org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferConsumer)2 DatabaseTransferProducer (org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferProducer)2 ActiveWizardPage (org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage)2