Search in sources :

Example 6 with FlowDifference

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();
}
Also used : FlowDifference(org.apache.nifi.registry.flow.diff.FlowDifference) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) StateMap(org.apache.nifi.components.state.StateMap) HashMap(java.util.HashMap)

Example 7 with FlowDifference

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());
}
Also used : VersionedComponent(org.apache.nifi.registry.flow.VersionedComponent) VersionedFlowDifference(org.apache.nifi.registry.diff.VersionedFlowDifference) FlowDifference(org.apache.nifi.registry.flow.diff.FlowDifference) HashMap(java.util.HashMap) ComponentDifferenceGroup(org.apache.nifi.registry.diff.ComponentDifferenceGroup)

Aggregations

FlowDifference (org.apache.nifi.registry.flow.diff.FlowDifference)7 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)5 HashMap (java.util.HashMap)4 VersionedComponent (org.apache.nifi.registry.flow.VersionedComponent)4 ComparableDataFlow (org.apache.nifi.registry.flow.diff.ComparableDataFlow)4 FlowComparator (org.apache.nifi.registry.flow.diff.FlowComparator)4 FlowComparison (org.apache.nifi.registry.flow.diff.FlowComparison)4 StandardComparableDataFlow (org.apache.nifi.registry.flow.diff.StandardComparableDataFlow)4 StandardFlowComparator (org.apache.nifi.registry.flow.diff.StandardFlowComparator)4 NiFiRegistryFlowMapper (org.apache.nifi.registry.flow.mapping.NiFiRegistryFlowMapper)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 List (java.util.List)3 Map (java.util.Map)3 StandardVersionControlInformation (org.apache.nifi.registry.flow.StandardVersionControlInformation)3 IOException (java.io.IOException)2 StandardCharsets (java.nio.charset.StandardCharsets)2 Collections (java.util.Collections)2 LinkedHashMap (java.util.LinkedHashMap)2