mirror of https://github.com/apache/nifi.git
NIFI-10572: Allowing variables to be deleted between versions, and considering ancestor variable additions to be environmental
This closes #6474 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
11ff622882
commit
10a5e9194c
|
@ -1939,6 +1939,13 @@ public class StandardVersionedComponentSynchronizer implements VersionedComponen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If any variables were removed from the proposed flow, add those as null values to remove them from the variable registry.
|
||||||
|
for (final String existingVariableName : existingVariableMap.keySet()) {
|
||||||
|
if (!proposed.getVariables().containsKey(existingVariableName)) {
|
||||||
|
updatedVariableMap.put(existingVariableName, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
group.setVariables(updatedVariableMap);
|
group.setVariables(updatedVariableMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.nifi.flow.VersionedLabel;
|
||||||
import org.apache.nifi.flow.VersionedPort;
|
import org.apache.nifi.flow.VersionedPort;
|
||||||
import org.apache.nifi.flow.VersionedProcessGroup;
|
import org.apache.nifi.flow.VersionedProcessGroup;
|
||||||
import org.apache.nifi.flow.VersionedProcessor;
|
import org.apache.nifi.flow.VersionedProcessor;
|
||||||
|
import org.apache.nifi.groups.ProcessGroup;
|
||||||
import org.apache.nifi.processor.Relationship;
|
import org.apache.nifi.processor.Relationship;
|
||||||
import org.apache.nifi.registry.flow.diff.DifferenceType;
|
import org.apache.nifi.registry.flow.diff.DifferenceType;
|
||||||
import org.apache.nifi.registry.flow.diff.FlowDifference;
|
import org.apache.nifi.registry.flow.diff.FlowDifference;
|
||||||
|
@ -58,6 +59,7 @@ public class FlowDifferenceFilters {
|
||||||
public static boolean isEnvironmentalChange(final FlowDifference difference, final VersionedProcessGroup localGroup, final FlowManager flowManager) {
|
public static boolean isEnvironmentalChange(final FlowDifference difference, final VersionedProcessGroup localGroup, final FlowManager flowManager) {
|
||||||
return difference.getDifferenceType() == DifferenceType.BUNDLE_CHANGED
|
return difference.getDifferenceType() == DifferenceType.BUNDLE_CHANGED
|
||||||
|| isVariableValueChange(difference)
|
|| isVariableValueChange(difference)
|
||||||
|
|| isAncestorVariableAdded(difference, flowManager)
|
||||||
|| isRpgUrlChange(difference)
|
|| isRpgUrlChange(difference)
|
||||||
|| isAddedOrRemovedRemotePort(difference)
|
|| isAddedOrRemovedRemotePort(difference)
|
||||||
|| isPublicPortNameChange(difference)
|
|| isPublicPortNameChange(difference)
|
||||||
|
@ -322,6 +324,26 @@ public class FlowDifferenceFilters {
|
||||||
return flowDifference.getDifferenceType() == DifferenceType.VARIABLE_CHANGED;
|
return flowDifference.getDifferenceType() == DifferenceType.VARIABLE_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAncestorVariableAdded(final FlowDifference fd, final FlowManager flowManager) {
|
||||||
|
if (fd.getDifferenceType() == DifferenceType.VARIABLE_ADDED) {
|
||||||
|
if (fd.getComponentA() instanceof InstantiatedVersionedComponent) {
|
||||||
|
final InstantiatedVersionedComponent componentA = (InstantiatedVersionedComponent) fd.getComponentA();
|
||||||
|
final ProcessGroup processGroup = flowManager.getGroup(componentA.getInstanceIdentifier());
|
||||||
|
if (processGroup.getVariableRegistry().getVariableKey(fd.getFieldName().get()) == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (fd.getComponentB() instanceof InstantiatedVersionedComponent) {
|
||||||
|
final InstantiatedVersionedComponent componentB = (InstantiatedVersionedComponent) fd.getComponentB();
|
||||||
|
final ProcessGroup processGroup = flowManager.getGroup(componentB.getInstanceIdentifier());
|
||||||
|
if (processGroup.getVariableRegistry().getVariableKey(fd.getFieldName().get()) == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isRpgUrlChange(final FlowDifference flowDifference) {
|
public static boolean isRpgUrlChange(final FlowDifference flowDifference) {
|
||||||
return flowDifference.getDifferenceType() == DifferenceType.RPG_URL_CHANGED;
|
return flowDifference.getDifferenceType() == DifferenceType.RPG_URL_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue