Search in sources :

Example 1 with DataTransferRegistry

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry in project dbeaver by serge-rider.

the class DataTransferSettings method setDataPipes.

public void setDataPipes(List<DataTransferPipe> dataPipes, boolean isExport) {
    this.dataPipes = dataPipes;
    // Now determine main producer and consumer and processor
    DataTransferRegistry registry = DataTransferRegistry.getInstance();
    this.consumerOptional = isExport;
    this.producerOptional = !isExport;
    // Don't update producer and consumer if it's not required (#9687)
    if (!nodeUpdateRestricted) {
        this.producer = null;
        this.consumer = null;
        if (!dataPipes.isEmpty()) {
            DataTransferPipe pipe = dataPipes.get(0);
            this.producer = pipe.getProducer() == null ? null : registry.getNodeByType(pipe.getProducer().getClass());
            this.consumer = pipe.getConsumer() == null ? null : registry.getNodeByType(pipe.getConsumer().getClass());
        }
    }
    DataTransferProcessorDescriptor savedProcessor = this.processor;
    if (this.consumerOptional && this.consumer != null) {
        this.selectConsumer(this.consumer, savedProcessor, false);
    }
    if (this.producerOptional && this.producer != null) {
        this.selectProducer(this.producer, savedProcessor, false);
    }
    // Collect objects
    initObjects.clear();
    for (DataTransferPipe pipe : dataPipes) {
        DBSObject object = isExport ? pipe.getProducer().getDatabaseObject() : pipe.getConsumer().getDatabaseObject();
        if (object != null) {
            initObjects.add(object);
        }
    }
}
Also used : DataTransferRegistry(org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Example 2 with DataTransferRegistry

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry in project dbeaver by serge-rider.

the class DataTransferSettings method initializePipes.

private void initializePipes(@Nullable Collection<IDataTransferProducer> producers, @Nullable Collection<IDataTransferConsumer> consumers, boolean isExport) {
    this.initProducers = producers == null ? null : producers.toArray(new IDataTransferProducer[0]);
    this.initConsumers = consumers == null ? null : consumers.toArray(new IDataTransferConsumer[0]);
    this.dataPipes = new ArrayList<>();
    this.initObjects.clear();
    this.consumerOptional = false;
    this.producerOptional = false;
    DataTransferRegistry registry = DataTransferRegistry.getInstance();
    if (!ArrayUtils.isEmpty(initProducers) && !ArrayUtils.isEmpty(initConsumers)) {
        // Processor belongs to non-database nodes anyway
        if (initProducers.length != initConsumers.length) {
            throw new IllegalArgumentException("Producers number must match consumers number");
        }
        // Make pipes
        for (int i = 0; i < initProducers.length; i++) {
            if (initProducers[i].getDatabaseObject() != null)
                initObjects.add(initProducers[i].getDatabaseObject());
            dataPipes.add(new DataTransferPipe(initProducers[i], initConsumers[i]));
        }
        // initProducers[0] instanceof IDataTransferNodePrimary;
        consumerOptional = isExport;
        // initConsumers[0] instanceof IDataTransferNodePrimary;
        producerOptional = !isExport;
        if (producerOptional && consumerOptional) {
            // Both producer and consumer set are primary
            // This may happen when task was saved for db-> settings
            // Leave only optional consumer then
            producerOptional = false;
        }
    } else if (!ArrayUtils.isEmpty(initProducers)) {
        // Make pipes
        for (IDataTransferProducer source : initProducers) {
            if (source.getDatabaseObject() != null)
                initObjects.add(source.getDatabaseObject());
            dataPipes.add(new DataTransferPipe(source, null));
        }
        // Set default producer
        Class<? extends IDataTransferProducer> producerType = dataPipes.get(0).getProducer().getClass();
        DataTransferNodeDescriptor producerDesc = registry.getNodeByType(producerType);
        if (producerDesc != null) {
            selectProducer(producerDesc);
            consumerOptional = true;
        } else {
            DBWorkbench.getPlatformUI().showError(DTMessages.data_transfer_settings_title_find_producer, DTMessages.data_transfer_settings_message_find_data_producer);
        }
    } else if (!ArrayUtils.isEmpty(initConsumers)) {
        // Make pipes
        for (IDataTransferConsumer target : initConsumers) {
            if (target.getDatabaseObject() != null)
                initObjects.add(target.getDatabaseObject());
            dataPipes.add(new DataTransferPipe(null, target));
        }
        // Set default consumer
        Class<? extends IDataTransferConsumer> consumerType = dataPipes.get(0).getConsumer().getClass();
        DataTransferNodeDescriptor consumerDesc = registry.getNodeByType(consumerType);
        if (consumerDesc != null) {
            selectConsumer(consumerDesc, null, false);
            consumerOptional = false;
        } else {
            DBWorkbench.getPlatformUI().showError(DTMessages.data_transfer_settings_title_find_consumer, DTMessages.data_transfer_settings_message_find_data_consumer);
        }
        producerOptional = true;
    } else {
        consumerOptional = true;
        producerOptional = true;
    }
    if (!ArrayUtils.isEmpty(initConsumers)) {
        for (IDataTransferConsumer target : initConsumers) {
            DataTransferNodeDescriptor node = registry.getNodeByType(target.getClass());
            if (node != null) {
                this.consumer = node;
            }
        }
    }
}
Also used : DataTransferRegistry(org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)

Example 3 with DataTransferRegistry

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry in project dbeaver by serge-rider.

the class DataTransferWizard method loadSettings.

void loadSettings() {
    // Load node settings
    Collection<DBSObject> objectTypes = settings.getSourceObjects();
    List<DataTransferNodeDescriptor> nodes = new ArrayList<>();
    DataTransferRegistry registry = DataTransferRegistry.getInstance();
    if (ArrayUtils.isEmpty(settings.getInitProducers())) {
        nodes.addAll(registry.getAvailableProducers(objectTypes));
    } else {
        for (IDataTransferProducer source : settings.getInitProducers()) {
            DataTransferNodeDescriptor node = registry.getNodeByType(source.getClass());
            if (node != null && !nodes.contains(node)) {
                nodes.add(node);
            }
        }
    }
    if (ArrayUtils.isEmpty(settings.getInitConsumers())) {
        nodes.addAll(registry.getAvailableConsumers(objectTypes));
    } else {
        for (IDataTransferConsumer target : settings.getInitConsumers()) {
            DataTransferNodeDescriptor node = registry.getNodeByType(target.getClass());
            if (node != null && !nodes.contains(node)) {
                nodes.add(node);
            }
        }
    }
    boolean settingsChanged = nodeSettings.size() != nodes.size();
    if (!settingsChanged) {
        List<NodePageSettings> nsList = new ArrayList<>(nodeSettings.values());
        for (int i = 0; i < nodeSettings.size(); i++) {
            if (nsList.get(i).sourceNode != nodes.get(i)) {
                settingsChanged = true;
                break;
            }
        }
    }
    if (settingsChanged) {
        nodeSettings.clear();
        for (DataTransferNodeDescriptor node : nodes) {
            addNodeSettings(node);
        }
    }
    updateWizardTitle();
}
Also used : DataTransferRegistry(org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)

Example 4 with DataTransferRegistry

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry in project dbeaver by dbeaver.

the class DataTransferWizard method loadSettings.

void loadSettings() {
    // Load node settings
    Collection<DBSObject> objectTypes = settings.getSourceObjects();
    List<DataTransferNodeDescriptor> nodes = new ArrayList<>();
    DataTransferRegistry registry = DataTransferRegistry.getInstance();
    if (ArrayUtils.isEmpty(settings.getInitProducers())) {
        nodes.addAll(registry.getAvailableProducers(objectTypes));
    } else {
        for (IDataTransferProducer source : settings.getInitProducers()) {
            DataTransferNodeDescriptor node = registry.getNodeByType(source.getClass());
            if (node != null && !nodes.contains(node)) {
                nodes.add(node);
            }
        }
    }
    if (ArrayUtils.isEmpty(settings.getInitConsumers())) {
        nodes.addAll(registry.getAvailableConsumers(objectTypes));
    } else {
        for (IDataTransferConsumer target : settings.getInitConsumers()) {
            DataTransferNodeDescriptor node = registry.getNodeByType(target.getClass());
            if (node != null && !nodes.contains(node)) {
                nodes.add(node);
            }
        }
    }
    boolean settingsChanged = nodeSettings.size() != nodes.size();
    if (!settingsChanged) {
        List<NodePageSettings> nsList = new ArrayList<>(nodeSettings.values());
        for (int i = 0; i < nodeSettings.size(); i++) {
            if (nsList.get(i).sourceNode != nodes.get(i)) {
                settingsChanged = true;
                break;
            }
        }
    }
    if (settingsChanged) {
        nodeSettings.clear();
        for (DataTransferNodeDescriptor node : nodes) {
            addNodeSettings(node);
        }
    }
    updateWizardTitle();
}
Also used : DataTransferRegistry(org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)

Example 5 with DataTransferRegistry

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry in project dbeaver by dbeaver.

the class DataTransferSettings method setDataPipes.

public void setDataPipes(List<DataTransferPipe> dataPipes, boolean isExport) {
    this.dataPipes = dataPipes;
    // Now determine main producer and consumer and processor
    DataTransferRegistry registry = DataTransferRegistry.getInstance();
    this.consumerOptional = isExport;
    this.producerOptional = !isExport;
    // Don't update producer and consumer if it's not required (#9687)
    if (!nodeUpdateRestricted) {
        this.producer = null;
        this.consumer = null;
        if (!dataPipes.isEmpty()) {
            DataTransferPipe pipe = dataPipes.get(0);
            this.producer = pipe.getProducer() == null ? null : registry.getNodeByType(pipe.getProducer().getClass());
            this.consumer = pipe.getConsumer() == null ? null : registry.getNodeByType(pipe.getConsumer().getClass());
        }
    }
    DataTransferProcessorDescriptor savedProcessor = this.processor;
    if (this.consumerOptional && this.consumer != null) {
        this.selectConsumer(this.consumer, savedProcessor, false);
    }
    if (this.producerOptional && this.producer != null) {
        this.selectProducer(this.producer, savedProcessor, false);
    }
    // Collect objects
    initObjects.clear();
    for (DataTransferPipe pipe : dataPipes) {
        DBSObject object = isExport ? pipe.getProducer().getDatabaseObject() : pipe.getConsumer().getDatabaseObject();
        if (object != null) {
            initObjects.add(object);
        }
    }
}
Also used : DataTransferRegistry(org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Aggregations

DataTransferRegistry (org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry)6 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)4 DataTransferNodeDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)4 DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)2