コード例 #1
0
  private boolean transferData(DBRProgressMonitor monitor, DataTransferPipe transferPipe) {
    IDataTransferProducer producer = transferPipe.getProducer();
    IDataTransferConsumer consumer = transferPipe.getConsumer();

    IDataTransferSettings consumerSettings = settings.getNodeSettings(consumer);

    setName(
        NLS.bind(
            CoreMessages.data_transfer_wizard_job_container_name,
            CommonUtils.truncateString(producer.getSourceObject().getName(), 200)));

    IDataTransferSettings nodeSettings = settings.getNodeSettings(producer);
    try {
      // consumer.initTransfer(producer.getSourceObject(), consumerSettings, );

      producer.transferData(monitor, consumer, nodeSettings);
      consumer.finishTransfer(monitor, false);
      return true;
    } catch (Exception e) {
      new DataTransferErrorJob(e).schedule();
      return false;
    }
  }
コード例 #2
0
  public DataTransferSettings(
      @Nullable IDataTransferProducer[] producers, @Nullable IDataTransferConsumer[] consumers) {
    dataPipes = new ArrayList<>();
    if (!ArrayUtils.isEmpty(producers) && !ArrayUtils.isEmpty(consumers)) {
      if (producers.length != consumers.length) {
        throw new IllegalArgumentException("Producers number must match consumers number");
      }
      // Make pipes
      for (int i = 0; i < producers.length; i++) {
        dataPipes.add(new DataTransferPipe(producers[i], consumers[i]));
      }
      consumerOptional = false;
    } else if (!ArrayUtils.isEmpty(producers)) {
      // Make pipes
      for (IDataTransferProducer source : producers) {
        dataPipes.add(new DataTransferPipe(source, null));
      }
      // Set default producer
      Class<? extends IDataTransferProducer> producerType =
          dataPipes.get(0).getProducer().getClass();
      DataTransferNodeDescriptor producerDesc =
          DataTransferRegistry.getInstance().getNodeByType(producerType);
      if (producerDesc != null) {
        selectProducer(producerDesc);
        consumerOptional = true;
      } else {
        UIUtils.showErrorDialog(
            null, "Can't find producer", "Can't find data propducer descriptor in registry");
      }
    } else if (!ArrayUtils.isEmpty(consumers)) {
      // Make pipes
      for (IDataTransferConsumer target : consumers) {
        dataPipes.add(new DataTransferPipe(null, target));
      }
      // Set default consumer
      Class<? extends IDataTransferConsumer> consumerType =
          dataPipes.get(0).getConsumer().getClass();
      DataTransferNodeDescriptor consumerDesc =
          DataTransferRegistry.getInstance().getNodeByType(consumerType);
      if (consumerDesc != null) {
        selectConsumer(consumerDesc, null);
        consumerOptional = false;
      } else {
        UIUtils.showErrorDialog(
            null, "Can't find producer", "Can't find data propducer descriptor in registry");
      }
    } else {
      throw new IllegalArgumentException("Producers or consumers must be specified");
    }

    Collection<Class<?>> objectTypes = getObjectTypes();
    List<DataTransferNodeDescriptor> nodes = new ArrayList<>();
    DataTransferRegistry registry = DataTransferRegistry.getInstance();
    if (ArrayUtils.isEmpty(producers)) {
      nodes.addAll(registry.getAvailableProducers(objectTypes));
    } else {
      for (IDataTransferProducer source : producers) {
        DataTransferNodeDescriptor node = registry.getNodeByType(source.getClass());
        if (node != null && !nodes.contains(node)) {
          nodes.add(node);
        }
      }
    }
    if (ArrayUtils.isEmpty(consumers)) {
      nodes.addAll(registry.getAvailableConsumers(objectTypes));
    } else {
      for (IDataTransferConsumer target : consumers) {
        DataTransferNodeDescriptor node = registry.getNodeByType(target.getClass());
        if (node != null && !nodes.contains(node)) {
          nodes.add(node);
          this.consumer = node;
        }
      }
    }
    for (DataTransferNodeDescriptor node : nodes) {
      addNodeSettings(node);
    }
  }