/** * Finds all {@link ProcessGroupDTO}s in the given {@link FlowSnippetDTO}. * @param snippet containing the child {@link ProcessGroupDTO}s to be returned * @return List of child {@link ProcessGroupDTO}s found in the given {@link FlowSnippetDTO}. */ public static List<ProcessGroupDTO> findAllProcessGroups(FlowSnippetDTO snippet) { final List<ProcessGroupDTO> allProcessGroups = new ArrayList<>(snippet.getProcessGroups()); for (final ProcessGroupDTO childGroup : snippet.getProcessGroups()) { allProcessGroups.addAll(findAllProcessGroups(childGroup.getContents())); } return allProcessGroups; }
public static void verifyNoVersionControlConflicts(final FlowSnippetDTO snippetContents, final ProcessGroup destination) { final List<VersionControlInformationDTO> vcis = new ArrayList<>(); for (final ProcessGroupDTO childGroup : snippetContents.getProcessGroups()) { findAllVersionControlInfo(childGroup, vcis); } verifyNoDuplicateVersionControlInfoDtos(destination, vcis); }
private static void findAllVersionControlInfo(final ProcessGroupDTO dto, final List<VersionControlInformationDTO> found) { final VersionControlInformationDTO vci = dto.getVersionControlInformation(); if (vci != null) { found.add(vci); } final FlowSnippetDTO contents = dto.getContents(); if (contents != null) { for (final ProcessGroupDTO child : contents.getProcessGroups()) { findAllVersionControlInfo(child, found); } } }
/** * Recursively finds all ConnectionDTO's * * @param group group * @return connection dtos */ private Set<ConnectionDTO> findAllConnections(final ProcessGroupDTO group) { final Set<ConnectionDTO> conns = new HashSet<>(); conns.addAll(group.getContents().getConnections()); for (final ProcessGroupDTO childGroup : group.getContents().getProcessGroups()) { conns.addAll(findAllConnections(childGroup)); } return conns; }
private static boolean isEmpty(final ProcessGroupDTO dto) { if (dto == null) { return true; } final FlowSnippetDTO contents = dto.getContents(); if (contents == null) { return true; } return CollectionUtils.isEmpty(contents.getProcessors()) && CollectionUtils.isEmpty(contents.getConnections()) && CollectionUtils.isEmpty(contents.getFunnels()) && CollectionUtils.isEmpty(contents.getLabels()) && CollectionUtils.isEmpty(contents.getOutputPorts()) && CollectionUtils.isEmpty(contents.getProcessGroups()) && CollectionUtils.isEmpty(contents.getProcessors()) && CollectionUtils.isEmpty(contents.getRemoteProcessGroups()); }
private void verifyProcessorsInSnippet(final FlowSnippetDTO templateContents, final Map<String, Set<BundleCoordinate>> supportedTypes) { if (templateContents.getProcessors() != null) { templateContents.getProcessors().forEach(processor -> { if (processor.getBundle() == null) { throw new IllegalArgumentException("Processor bundle must be specified."); } if (supportedTypes.containsKey(processor.getType())) { verifyBundleInSnippet(processor.getBundle(), supportedTypes.get(processor.getType())); } else { throw new IllegalStateException("Invalid Processor Type: " + processor.getType()); } }); } if (templateContents.getProcessGroups() != null) { templateContents.getProcessGroups().forEach(processGroup -> verifyProcessorsInSnippet(processGroup.getContents(), supportedTypes)); } }
private void verifyControllerServicesInSnippet(final FlowSnippetDTO templateContents, final Map<String, Set<BundleCoordinate>> supportedTypes) { if (templateContents.getControllerServices() != null) { templateContents.getControllerServices().forEach(controllerService -> { if (supportedTypes.containsKey(controllerService.getType())) { if (controllerService.getBundle() == null) { throw new IllegalArgumentException("Controller Service bundle must be specified."); } verifyBundleInSnippet(controllerService.getBundle(), supportedTypes.get(controllerService.getType())); } else { throw new IllegalStateException("Invalid Controller Service Type: " + controllerService.getType()); } }); } if (templateContents.getProcessGroups() != null) { templateContents.getProcessGroups().forEach(processGroup -> verifyControllerServicesInSnippet(processGroup.getContents(), supportedTypes)); } }
for (final ProcessGroupDTO childGroup : dto.getProcessGroups()) { allConns.addAll(findAllConnections(childGroup));
components.addAll(contents.getOutputPorts()); if (contents.getProcessGroups() != null) { components.addAll(contents.getProcessGroups());
.map(port -> port.getId()) .forEach(id -> identifiers.add(id)); snippet.getProcessGroups().stream() .map(group -> group.getId()) .forEach(id -> identifiers.add(id));
private void updateControllerServiceIdentifiers(final FlowSnippetDTO snippet, final Map<String, String> serviceIdMap) { final Set<ProcessorDTO> processors = snippet.getProcessors(); if (processors != null) { for (final ProcessorDTO processor : processors) { updateControllerServiceIdentifiers(processor.getConfig(), serviceIdMap); } } for (final ProcessGroupDTO processGroupDto : snippet.getProcessGroups()) { updateControllerServiceIdentifiers(processGroupDto.getContents(), serviceIdMap); } }
private void lookupSensitiveProperties(final FlowSnippetDTO snippet) { // ensure that contents have been specified if (snippet != null) { // go through each processor if specified if (snippet.getProcessors() != null) { lookupSensitiveProcessorProperties(snippet.getProcessors()); } if (snippet.getControllerServices() != null) { lookupSensitiveControllerServiceProperties(snippet.getControllerServices()); } // go through each process group if specified if (snippet.getProcessGroups() != null) { for (final ProcessGroupDTO group : snippet.getProcessGroups()) { lookupSensitiveProperties(group.getContents()); } } } }
final Map<String, ProcessGroupDTO> childGroupMap = contents.getProcessGroups().stream() .collect(Collectors.toMap(childGroupDto -> childGroupDto.getId(), childGroupDto -> childGroupDto));
if (snippetContents.getProcessGroups() != null) { for (final ProcessGroupDTO groupDTO : snippetContents.getProcessGroups()) {
dto.getProcessGroups().add(createProcessGroupDto(childGroup, recurse)); } else { dto.getProcessGroups().add(createConciseProcessGroupDto(childGroup));
if (snippet.getProcessGroups() != null) { snippet.getProcessGroups().stream().forEach(group -> createTemporaryProcessorsAndControllerServices(group.getContents(), processors, controllerServices, extensionManager));
/** * Discovers the compatible bundle details for the components in the specified snippet. * * @param snippet the snippet */ private void discoverCompatibleBundles(final FlowSnippetDTO snippet) { if (snippet.getProcessors() != null) { snippet.getProcessors().forEach(processor -> { final BundleCoordinate coordinate = serviceFacade.getCompatibleBundle(processor.getType(), processor.getBundle()); processor.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion())); }); } if (snippet.getControllerServices() != null) { snippet.getControllerServices().forEach(controllerService -> { final BundleCoordinate coordinate = serviceFacade.getCompatibleBundle(controllerService.getType(), controllerService.getBundle()); controllerService.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion())); }); } if (snippet.getProcessGroups() != null) { snippet.getProcessGroups().forEach(processGroup -> { discoverCompatibleBundles(processGroup.getContents()); }); } }
private static void scrubSnippet(final FlowSnippetDTO snippet) { // ensure that contents have been specified if (snippet != null) { // go through each processor if specified if (snippet.getProcessors() != null) { scrubProcessors(snippet.getProcessors()); } // go through each connection if specified if (snippet.getConnections() != null) { scrubConnections(snippet.getConnections()); } // go through each remote process group if specified if (snippet.getRemoteProcessGroups() != null) { scrubRemoteProcessGroups(snippet.getRemoteProcessGroups()); } // go through each process group if specified if (snippet.getProcessGroups() != null) { scrubProcessGroups(snippet.getProcessGroups()); } // go through each controller service if specified if (snippet.getControllerServices() != null) { scrubControllerServices(snippet.getControllerServices()); } } }
for (final ProcessGroupDTO processGroup : snippet.getProcessGroups()) { actions.add(generateAuditRecord(processGroup.getId(), processGroup.getName(), Component.ProcessGroup, Operation.Add, timestamp));
rollbackClonedPolicy(ResourceFactory.getComponentResource(ResourceType.RemoteProcessGroup, remoteProcessGroupDTO.getId(), remoteProcessGroupDTO.getName())); }); snippet.getProcessGroups().forEach(processGroupDTO -> { rollbackClonedPolicy(ResourceFactory.getComponentResource(ResourceType.ProcessGroup, processGroupDTO.getId(), processGroupDTO.getName()));