/** * 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()); } }
/** * 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); }
/** * 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); }