use of org.apache.nifi.registry.flow.diff.FlowDifference in project nifi by apache.
the class DtoFactory method createComponentDifferenceDtos.
public Set<ComponentDifferenceDTO> createComponentDifferenceDtos(final FlowComparison comparison) {
final Map<ComponentDifferenceDTO, List<DifferenceDTO>> differencesByComponent = new HashMap<>();
for (final FlowDifference difference : comparison.getDifferences()) {
// Ignore these as local differences for now because we can't do anything with it
if (difference.getDifferenceType() == DifferenceType.BUNDLE_CHANGED) {
continue;
}
// Ignore differences for adding remote ports
if (FlowDifferenceFilters.isAddedOrRemovedRemotePort(difference)) {
continue;
}
final ComponentDifferenceDTO componentDiff = createComponentDifference(difference);
final List<DifferenceDTO> differences = differencesByComponent.computeIfAbsent(componentDiff, key -> new ArrayList<>());
final DifferenceDTO dto = new DifferenceDTO();
dto.setDifferenceType(difference.getDifferenceType().getDescription());
dto.setDifference(difference.getDescription());
differences.add(dto);
}
for (final Map.Entry<ComponentDifferenceDTO, List<DifferenceDTO>> entry : differencesByComponent.entrySet()) {
entry.getKey().setDifferences(entry.getValue());
}
return differencesByComponent.keySet();
}
use of org.apache.nifi.registry.flow.diff.FlowDifference in project nifi-registry by apache.
the class RegistryService method getStringComponentDifferenceGroupMap.
/**
* Group the differences in the comparison by component
* @param flowDifferences The differences to group together by component
* @return A set of componentDifferenceGroups where each entry contains a set of differences specific to that group
*/
private Set<ComponentDifferenceGroup> getStringComponentDifferenceGroupMap(Set<FlowDifference> flowDifferences) {
Map<String, ComponentDifferenceGroup> differenceGroups = new HashMap<>();
for (FlowDifference diff : flowDifferences) {
ComponentDifferenceGroup group;
// A component may only exist on only one version for new/removed components
VersionedComponent component = ObjectUtils.firstNonNull(diff.getComponentA(), diff.getComponentB());
if (differenceGroups.containsKey(component.getIdentifier())) {
group = differenceGroups.get(component.getIdentifier());
} else {
group = DataModelMapper.map(component);
differenceGroups.put(component.getIdentifier(), group);
}
group.getDifferences().add(DataModelMapper.map(diff));
}
return differenceGroups.values().stream().collect(Collectors.toSet());
}
Aggregations