Ejemplo n.º 1
0
 private void addNodeSettings(DataTransferNodeDescriptor node) {
   if (node == null) {
     return;
   }
   Class<? extends IDataTransferNode> nodeClass = node.getNodeClass();
   if (nodeSettings.containsKey(nodeClass)) {
     return;
   }
   try {
     nodeSettings.put(nodeClass, new NodeSettings(node));
   } catch (DBException e) {
     log.error("Can't add node '" + node.getId() + "'", e);
   }
 }
Ejemplo n.º 2
0
  void saveTo(IDialogSettings dialogSettings) {
    dialogSettings.put("maxJobCount", maxJobCount);
    // Save nodes' settings
    for (Map.Entry<Class, NodeSettings> entry : nodeSettings.entrySet()) {
      IDialogSettings nodeSection =
          DialogSettings.getOrCreateSection(dialogSettings, entry.getKey().getSimpleName());
      entry.getValue().settings.saveSettings(nodeSection);
    }

    if (producer != null) {
      dialogSettings.put("producer", producer.getId());
    }
    if (consumer != null) {
      dialogSettings.put("consumer", consumer.getId());
    }
    if (processor != null) {
      dialogSettings.put("processor", processor.getId());
    }

    // Save processors' properties
    IDialogSettings processorsSection =
        DialogSettings.getOrCreateSection(dialogSettings, "processors");
    for (DataTransferProcessorDescriptor procDescriptor : processorPropsHistory.keySet()) {
      IDialogSettings procSettings =
          DialogSettings.getOrCreateSection(processorsSection, procDescriptor.getId());
      procSettings.put("@node", procDescriptor.getNode().getId());
      Map<Object, Object> props = processorPropsHistory.get(procDescriptor);
      if (props != null) {
        StringBuilder propNames = new StringBuilder();
        for (Map.Entry<Object, Object> prop : props.entrySet()) {
          propNames.append(prop.getKey()).append(',');
        }
        procSettings.put("@propNames", propNames.toString());
        for (Map.Entry<Object, Object> prop : props.entrySet()) {
          procSettings.put(
              CommonUtils.toString(prop.getKey()), CommonUtils.toString(prop.getValue()));
        }
      }
    }
  }
Ejemplo n.º 3
0
 void selectConsumer(
     DataTransferNodeDescriptor consumer, DataTransferProcessorDescriptor processor) {
   this.consumer = consumer;
   this.processor = processor;
   if (consumer != null && processor != null) {
     if (!processorPropsHistory.containsKey(processor)) {
       processorPropsHistory.put(processor, new HashMap<>());
     }
   }
   // Configure pipes
   for (DataTransferPipe pipe : dataPipes) {
     if (consumer != null) {
       try {
         pipe.setConsumer((IDataTransferConsumer) consumer.createNode());
       } catch (DBException e) {
         log.error(e);
         pipe.setConsumer(null);
       }
     } else {
       pipe.setConsumer(null);
     }
   }
 }
Ejemplo n.º 4
0
 private NodeSettings(DataTransferNodeDescriptor sourceNode) throws DBException {
   this.sourceNode = sourceNode;
   this.settings = sourceNode.createSettings();
   this.pages = sourceNode.createWizardPages();
 }
Ejemplo n.º 5
0
  void loadFrom(IRunnableContext runnableContext, IDialogSettings dialogSettings) {
    try {
      maxJobCount = dialogSettings.getInt("maxJobCount");
    } catch (NumberFormatException e) {
      maxJobCount = DEFAULT_THREADS_NUM;
    }
    String producerId = dialogSettings.get("producer");
    if (!CommonUtils.isEmpty(producerId)) {
      DataTransferNodeDescriptor producerNode =
          DataTransferRegistry.getInstance().getNodeById(producerId);
      if (producerNode != null) {
        this.producer = producerNode;
      }
    }

    if (consumerOptional) {
      DataTransferNodeDescriptor savedConsumer = null;
      String consumerId = dialogSettings.get("consumer");
      if (!CommonUtils.isEmpty(consumerId)) {
        DataTransferNodeDescriptor consumerNode =
            DataTransferRegistry.getInstance().getNodeById(consumerId);
        if (consumerNode != null) {
          savedConsumer = consumerNode;
        }
      }

      DataTransferProcessorDescriptor savedProcessor = null;
      if (savedConsumer != null) {
        String processorId = dialogSettings.get("processor");
        if (!CommonUtils.isEmpty(processorId)) {
          savedProcessor = savedConsumer.getProcessor(processorId);
        }
      }
      if (savedConsumer != null) {
        selectConsumer(savedConsumer, savedProcessor);
      }
    }

    // Load nodes' settings
    for (Map.Entry<Class, NodeSettings> entry : nodeSettings.entrySet()) {
      IDialogSettings nodeSection =
          DialogSettings.getOrCreateSection(dialogSettings, entry.getKey().getSimpleName());
      entry.getValue().settings.loadSettings(runnableContext, this, nodeSection);
    }
    IDialogSettings processorsSection = dialogSettings.getSection("processors");
    if (processorsSection != null) {
      for (IDialogSettings procSection : ArrayUtils.safeArray(processorsSection.getSections())) {
        String processorId = procSection.getName();
        String nodeId = procSection.get("@node");
        String propNamesId = procSection.get("@propNames");
        DataTransferNodeDescriptor node = DataTransferRegistry.getInstance().getNodeById(nodeId);
        if (node != null) {
          Map<Object, Object> props = new HashMap<>();
          DataTransferProcessorDescriptor nodeProcessor = node.getProcessor(processorId);
          if (nodeProcessor != null) {
            for (String prop : CommonUtils.splitString(propNamesId, ',')) {
              props.put(prop, procSection.get(prop));
            }
            processorPropsHistory.put(nodeProcessor, props);
            NodeSettings nodeSettings = this.nodeSettings.get(node.getNodeClass());
            if (nodeSettings != null) {}
          }
        }
      }
    }
  }
Ejemplo n.º 6
0
 private boolean isPageValid(IWizardPage page, DataTransferNodeDescriptor node) {
   NodeSettings nodeSettings = node == null ? null : this.nodeSettings.get(node.getNodeClass());
   return nodeSettings != null && ArrayUtils.contains(nodeSettings.pages, page);
 }