Search in sources :

Example 16 with DataTransferProcessorDescriptor

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

the class DataTransferPagePipes method loadProducers.

private void loadProducers() {
    DataTransferSettings settings = getWizard().getSettings();
    Collection<DBSObject> objects = settings.getSourceObjects();
    List<TransferTarget> transferTargets = new ArrayList<>();
    for (DataTransferNodeDescriptor producer : DataTransferRegistry.getInstance().getAvailableProducers(objects)) {
        Collection<DataTransferProcessorDescriptor> processors = producer.getAvailableProcessors(objects);
        if (CommonUtils.isEmpty(processors)) {
            transferTargets.add(new TransferTarget(producer, null));
        } else {
            for (DataTransferProcessorDescriptor processor : processors) {
                transferTargets.add(new TransferTarget(producer, processor));
            }
        }
    }
    nodesTable.setInput(transferTargets);
}
Also used : DataTransferSettings(org.jkiss.dbeaver.tools.transfer.DataTransferSettings) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ArrayList(java.util.ArrayList) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Example 17 with DataTransferProcessorDescriptor

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

the class ResultSetHandlerOpenWith method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IResultSetController resultSet = ResultSetHandlerMain.getActiveResultSet(HandlerUtil.getActivePart(event));
    if (resultSet == null) {
        return null;
    }
    DataTransferProcessorDescriptor processor = getActiveProcessor(event.getParameter(PARAM_PROCESSOR_ID));
    if (processor == null) {
        return null;
    }
    switch(event.getCommand().getId()) {
        case CMD_OPEN_WITH:
            openResultsWith(resultSet, processor);
            break;
    }
    return null;
}
Also used : DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Example 18 with DataTransferProcessorDescriptor

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

the class ResultSetHandlerCopyAs method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IResultSetController resultSet = ResultSetHandlerMain.getActiveResultSet(HandlerUtil.getActivePart(event));
    if (resultSet == null) {
        return null;
    }
    DataTransferProcessorDescriptor processor = getActiveProcessor(event.getParameter(PARAM_PROCESSOR_ID));
    if (processor == null) {
        return null;
    }
    switch(event.getCommand().getId()) {
        case CMD_COPY_AS:
            openResultsWith(resultSet, processor);
            break;
    }
    return null;
}
Also used : DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Example 19 with DataTransferProcessorDescriptor

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

the class DataTransferPipe method initPipe.

public void initPipe(DataTransferSettings settings, int pipeIndex, int totalPipes) throws DBException {
    if (consumer == null || producer == null) {
        throw new DBException("Empty pipe");
    }
    IDataTransferSettings consumerSettings = settings.getNodeSettings(settings.getConsumer());
    DataTransferProcessorDescriptor processorDescriptor = settings.getProcessor();
    IDataTransferProcessor processor = processorDescriptor == null ? null : processorDescriptor.getInstance();
    IDataTransferConsumer.TransferParameters parameters = new IDataTransferConsumer.TransferParameters(processorDescriptor != null && processorDescriptor.isBinaryFormat(), processorDescriptor != null && processorDescriptor.isHTMLFormat());
    parameters.orderNumber = pipeIndex;
    parameters.totalConsumers = totalPipes;
    parameters.startTimestamp = new Date();
    consumer.initTransfer(producer.getDatabaseObject(), consumerSettings, parameters, processor, processor == null ? null : settings.getProcessorProperties());
}
Also used : DBException(org.jkiss.dbeaver.DBException) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor) Date(java.util.Date)

Example 20 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor 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

DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)34 DataTransferNodeDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)16 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)10 DBException (org.jkiss.dbeaver.DBException)6 ArrayList (java.util.ArrayList)4 CommandContributionItem (org.eclipse.ui.menus.CommandContributionItem)4 CommandContributionItemParameter (org.eclipse.ui.menus.CommandContributionItemParameter)4 DBPPropertyDescriptor (org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)4 PropertySourceCustom (org.jkiss.dbeaver.runtime.properties.PropertySourceCustom)4 DataTransferSettings (org.jkiss.dbeaver.tools.transfer.DataTransferSettings)4 Collection (java.util.Collection)2 Date (java.util.Date)2 Color (org.eclipse.swt.graphics.Color)2 IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)2 DBPImage (org.jkiss.dbeaver.model.DBPImage)2 DBPObject (org.jkiss.dbeaver.model.DBPObject)2 DBCException (org.jkiss.dbeaver.model.exec.DBCException)2 MonitorRunnableContext (org.jkiss.dbeaver.model.runtime.MonitorRunnableContext)2 DataTransferRegistry (org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry)2 StreamConsumerSettings (org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings)2