You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2019/06/25 17:51:27 UTC

[nifi-registry] branch master updated: NIFIREG-287: For Flow Difference objects of type PROPERTY_MODIFIED, PROPERTY_ADDED, PROPERTY_REMOVED, include the name of hte property as the fieldName.

This is an automated email from the ASF dual-hosted git repository.

mcgilman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-registry.git


The following commit(s) were added to refs/heads/master by this push:
     new f3b82a7  NIFIREG-287: For Flow Difference objects of type PROPERTY_MODIFIED, PROPERTY_ADDED, PROPERTY_REMOVED, include the name of hte property as the fieldName.
f3b82a7 is described below

commit f3b82a7b8dab3737d9b9ca1dc8028d4e9d7108fa
Author: Mark Payne <ma...@hotmail.com>
AuthorDate: Fri Jun 21 12:16:06 2019 -0400

    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
---
 .../nifi/registry/flow/diff/FlowComparator.java    |  2 +-
 .../registry/flow/diff/StandardFlowComparator.java | 24 ++++++++++++----------
 2 files changed, 14 insertions(+), 12 deletions(-)

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 @@ public interface FlowComparator {
     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 @@ public class StandardFlowComparator implements FlowComparator {
             }
 
             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 @@ public class StandardFlowComparator implements FlowComparator {
                     }
                 }
 
-                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 @@ public class StandardFlowComparator implements FlowComparator {
                     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 @@ public class StandardFlowComparator implements FlowComparator {
             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 @@ public class StandardFlowComparator implements FlowComparator {
     }
 
     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);