コード例 #1
0
ファイル: Flow.java プロジェクト: tmx11/weka
  /**
   * Rename a Step.
   *
   * @param oldName the name of the Step to rename
   * @param newName the new name to use
   * @throws WekaException if the named Step is not part of this flow
   */
  public synchronized void renameStep(String oldName, String newName) throws WekaException {

    if (!m_flowSteps.containsKey(oldName)) {
      throw new WekaException("Step " + oldName + " does not seem to be part of the flow!");
    }

    StepManagerImpl toRename = m_flowSteps.remove(oldName);
    toRename.getManagedStep().setName(newName);
    m_flowSteps.put(newName, toRename);
  }
コード例 #2
0
ファイル: Flow.java プロジェクト: tmx11/weka
  /**
   * Get a list of potential start points in this Flow. Potential start points are those steps that
   * have no incoming connections.
   *
   * @return a list of potential start points
   */
  public List<StepManagerImpl> findPotentialStartPoints() {
    List<StepManagerImpl> startPoints = new ArrayList<StepManagerImpl>();

    // potential start points will have no incoming connections...
    for (Map.Entry<String, StepManagerImpl> e : m_flowSteps.entrySet()) {
      StepManagerImpl candidate = e.getValue();
      if (candidate.getIncomingConnections().size() == 0) {
        startPoints.add(candidate);
      }
    }

    return startPoints;
  }
コード例 #3
0
ファイル: Flow.java プロジェクト: tmx11/weka
  /**
   * Connect the supplied source and target steps using the given connectionType. The connection
   * will be successful only if both source and target are actually part of this Flow, and the
   * target is able to accept the connection at this time.
   *
   * @param source the StepManager for the source step
   * @param target the StepManager for the target step
   * @param connectionType the connection type to use
   * @param force true to force the connection (i.e. even if the target step says it can accept the
   *     connection type at this time)
   * @return true if the connection was successful
   */
  public synchronized boolean connectSteps(
      StepManagerImpl source, StepManagerImpl target, String connectionType, boolean force) {
    boolean connSuccessful = false;
    // make sure we contain both these steps!
    if (findStep(source.getName()) == source && findStep(target.getName()) == target) {

      // this takes care of ensuring that the target can accept
      // the connection at this time and the creation of the
      // incoming connection on the target
      connSuccessful = source.addOutgoingConnection(connectionType, target, force);
    }
    return connSuccessful;
  }
コード例 #4
0
ファイル: Flow.java プロジェクト: tmx11/weka
  /**
   * Remove the supplied Step from this flow
   *
   * @param manager the StepManager of the Step to remove
   * @throws WekaException if the step is not part of this flow
   */
  public synchronized void removeStep(StepManagerImpl manager) throws WekaException {
    // int ID = manager.getManagedStep().hashCode();

    if (!m_flowSteps.containsKey(manager.getManagedStep().getName())) {
      throw new WekaException(
          "Step " + manager.getManagedStep().getName() + " does not seem to be part of the flow!");
    }

    m_flowSteps.remove(manager.getManagedStep().getName());
    manager.clearAllConnections();
    // remove from the map & disconnect from other steps!
    for (Map.Entry<String, StepManagerImpl> e : m_flowSteps.entrySet()) {
      e.getValue().disconnectStep(manager.getManagedStep());
    }
  }
コード例 #5
0
ファイル: Flow.java プロジェクト: tmx11/weka
  /**
   * Add the given Step to this flow
   *
   * @param manager the StepManager containing the Step to add
   */
  public synchronized void addStep(StepManagerImpl manager) {
    // int ID = manager.getManagedStep().hashCode();

    // scan for steps that already have the same name as the step being added
    String toAddName = manager.getManagedStep().getName();
    if (toAddName != null && toAddName.length() > 0) {

      boolean exactMatch = false;
      int maxCopyNum = 1;
      for (Map.Entry<String, StepManagerImpl> e : m_flowSteps.entrySet()) {
        String compName = e.getValue().getManagedStep().getName();
        if (toAddName.equals(compName)) {
          exactMatch = true;
        } else {
          if (compName.startsWith(toAddName)) {
            String num = compName.replace(toAddName, "");
            try {
              int compNum = Integer.parseInt(num);
              if (compNum > maxCopyNum) {
                maxCopyNum = compNum;
              }
            } catch (NumberFormatException ex) {
            }
          }
        }
      }

      if (exactMatch) {
        maxCopyNum++;
        toAddName += "" + maxCopyNum;
        manager.getManagedStep().setName(toAddName);
      }
    }

    m_flowSteps.put(toAddName, manager);
  }
コード例 #6
0
ファイル: Flow.java プロジェクト: tmx11/weka
 /**
  * Rename the supplied step with the supplied name
  *
  * @param step the StepManager of the Step to rename
  * @param newName the new name to give the step
  * @throws WekaException if the Step is not part of this Flow.
  */
 public synchronized void renameStep(StepManagerImpl step, String newName) throws WekaException {
   renameStep(step.getName(), newName);
 }