Search in sources :

Example 6 with StreamProducerSettings

use of org.jkiss.dbeaver.tools.transfer.stream.StreamProducerSettings 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();
}
Also used : StreamTransferProducer(org.jkiss.dbeaver.tools.transfer.stream.StreamTransferProducer) StreamProducerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamProducerSettings) DatabaseConsumerSettings(org.jkiss.dbeaver.tools.transfer.database.DatabaseConsumerSettings) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseMappingContainer(org.jkiss.dbeaver.tools.transfer.database.DatabaseMappingContainer) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

DatabaseConsumerSettings (org.jkiss.dbeaver.tools.transfer.database.DatabaseConsumerSettings)6 DatabaseMappingContainer (org.jkiss.dbeaver.tools.transfer.database.DatabaseMappingContainer)6 StreamProducerSettings (org.jkiss.dbeaver.tools.transfer.stream.StreamProducerSettings)6 StreamTransferProducer (org.jkiss.dbeaver.tools.transfer.stream.StreamTransferProducer)6 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)4 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)4 StreamEntityMapping (org.jkiss.dbeaver.tools.transfer.stream.StreamEntityMapping)4 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 DBException (org.jkiss.dbeaver.DBException)2 DBSDataManipulator (org.jkiss.dbeaver.model.struct.DBSDataManipulator)2 DatabaseTransferConsumer (org.jkiss.dbeaver.tools.transfer.database.DatabaseTransferConsumer)2