/** * Find a unique processor name for the supplied Dataflow, based upon the * preferred name. If needed, an underscore and a numeric suffix is added to * the preferred name, and incremented until it is unique, starting from 2. * (The original being 'number 1') * <p> * Note that this method checks the uniqueness against the names of all * {@link NamedWorkflowEntity}s, including {@link Merge}s. * <p> * Although not strictly needed by Taverna, for added user friendliness the * case of the existing port names are ignored when checking for uniqueness. * * @param preferredName * the preferred name for the Processor * @param dataflow * the dataflow for which the Processor name needs to be unique * @return A unique processor name */ public static String uniqueProcessorName(String preferredName, Dataflow dataflow) { Set<String> existingNames = new HashSet<String>(); for (NamedWorkflowEntity entity : dataflow .getEntities(NamedWorkflowEntity.class)) { existingNames.add(entity.getLocalName().toLowerCase()); } return uniqueObjectName(preferredName, existingNames); }
List<? extends Processor> allProcessors = dataflow.getEntities(Processor.class);