NIFIREG-287: For Flow Difference objects of type PROPERTY_MODIFIED, PROPERTY_ADDED, PROPERTY_REMOVED, include the name of hte property as the fieldName.
This closes #201
diff --git a/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/FlowComparator.java b/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/FlowComparator.java
index 3835fec..84ffb2c 100644
--- a/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/FlowComparator.java
+++ b/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/FlowComparator.java
@@ -25,7 +25,7 @@
FlowComparison compare();
/**
- * Compares to versions of a Controller Service and returns the differences between them
+ * Compares two versions of a Controller Service and returns the differences between them
*
* @param serviceA the first Controller Service
* @param serviceB the second Controller Service
diff --git a/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java b/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
index c38faef..e583d99 100644
--- a/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
+++ b/nifi-registry-core/nifi-registry-flow-diff/src/main/java/org/apache/nifi/registry/flow/diff/StandardFlowComparator.java
@@ -191,9 +191,9 @@
}
if (valueA == null && valueB != null) {
- differences.add(difference(DifferenceType.PROPERTY_ADDED, componentA, componentB, displayName, valueA, valueB));
+ differences.add(difference(DifferenceType.PROPERTY_ADDED, componentA, componentB, key, displayName, valueA, valueB));
} else if (valueA != null && valueB == null) {
- differences.add(difference(DifferenceType.PROPERTY_REMOVED, componentA, componentB, displayName, valueA, valueB));
+ differences.add(difference(DifferenceType.PROPERTY_REMOVED, componentA, componentB, key, displayName, valueA, valueB));
} else if (valueA != null && !valueA.equals(valueB)) {
// If the property in Flow A references a Controller Service that is not available in the flow
// and the property in Flow B references a Controller Service that is available in its environment
@@ -210,7 +210,7 @@
}
}
- differences.add(difference(DifferenceType.PROPERTY_CHANGED, componentA, componentB, displayName, valueA, valueB));
+ differences.add(difference(DifferenceType.PROPERTY_CHANGED, componentA, componentB, key, displayName, valueA, valueB));
}
});
@@ -228,7 +228,7 @@
displayName = descriptor.getDisplayName() == null ? descriptor.getName() : descriptor.getDisplayName();
}
- differences.add(difference(DifferenceType.PROPERTY_ADDED, componentA, componentB, displayName, null, valueB));
+ differences.add(difference(DifferenceType.PROPERTY_ADDED, componentA, componentB, key, displayName, null, valueB));
}
});
}
@@ -376,7 +376,7 @@
return;
}
- differences.add(difference(type, componentA, componentB, null, valueA, valueB));
+ differences.add(difference(type, componentA, componentB, valueA, valueB));
}
private boolean isEmpty(final Collection<?> collection) {
@@ -397,17 +397,19 @@
}
private FlowDifference difference(final DifferenceType type, final VersionedComponent componentA, final VersionedComponent componentB,
- final Object valueA, final Object valueB) {
- return difference(type, componentA, componentB, null, valueA, valueB);
- }
-
- private FlowDifference difference(final DifferenceType type, final VersionedComponent componentA, final VersionedComponent componentB, final String fieldName,
final Object valueA, final Object valueB) {
- final String description = differenceDescriptor.describeDifference(type, flowA.getName(), flowB.getName(), componentA, componentB, fieldName, valueA, valueB);
+ final String description = differenceDescriptor.describeDifference(type, flowA.getName(), flowB.getName(), componentA, componentB, null, valueA, valueB);
return new StandardFlowDifference(type, componentA, componentB, valueA, valueB, description);
}
+ private FlowDifference difference(final DifferenceType type, final VersionedComponent componentA, final VersionedComponent componentB, final String fieldName, final String prettyPrintFieldName,
+ final Object valueA, final Object valueB) {
+
+ final String description = differenceDescriptor.describeDifference(type, flowA.getName(), flowB.getName(), componentA, componentB, prettyPrintFieldName, valueA, valueB);
+ return new StandardFlowDifference(type, componentA, componentB, fieldName, valueA, valueB, description);
+ }
+
private static interface ComponentComparator<T extends VersionedComponent> {
void compare(T componentA, T componentB, Set<FlowDifference> differences);