From 731df87f22d5028f044c3c6d5f34a3a6da4972ca Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Thu, 5 Sep 2019 15:05:42 -0400 Subject: [PATCH] NIFI-6626: Fixed the order of arguments passed to the ComponentDetails constructor when creating the Component Details for a connection. Also noticed that null fields are being added to the map when calling ComponentDetails.toMap() and this causes the UI to display these fields even though they have no value, so avoided populating the map with fields whose values are null This closes #3696 --- .../status/history/ComponentDetails.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/ComponentDetails.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/ComponentDetails.java index 68a79b91c9..e7a93fa1a6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/ComponentDetails.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/status/history/ComponentDetails.java @@ -58,7 +58,7 @@ public class ComponentDetails { } public static ComponentDetails forConnection(final String id, final String groupId, final String connectionName, final String sourceName, final String destinationName) { - return new ComponentDetails(id, groupId, connectionName, sourceName, destinationName, null, null); + return new ComponentDetails(id, groupId, connectionName, null, sourceName, destinationName, null); } public static ComponentDetails forProcessGroup(final ProcessGroupStatus status) { @@ -111,13 +111,19 @@ public class ComponentDetails { */ public Map toMap() { final Map map = new HashMap<>(); - map.put(ComponentStatusRepository.COMPONENT_DETAIL_ID, componentId); - map.put(ComponentStatusRepository.COMPONENT_DETAIL_GROUP_ID, groupId); - map.put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, componentName); - map.put(ComponentStatusRepository.COMPONENT_DETAIL_TYPE, componentType); - map.put(ComponentStatusRepository.COMPONENT_DETAIL_SOURCE_NAME, sourceName); - map.put(ComponentStatusRepository.COMPONENT_DETAIL_DESTINATION_NAME, destinationName); - map.put(ComponentStatusRepository.COMPONENT_DETAIL_URI, targetUri); + addToMap(map, ComponentStatusRepository.COMPONENT_DETAIL_ID, componentId); + addToMap(map, ComponentStatusRepository.COMPONENT_DETAIL_GROUP_ID, groupId); + addToMap(map, ComponentStatusRepository.COMPONENT_DETAIL_NAME, componentName); + addToMap(map, ComponentStatusRepository.COMPONENT_DETAIL_TYPE, componentType); + addToMap(map, ComponentStatusRepository.COMPONENT_DETAIL_SOURCE_NAME, sourceName); + addToMap(map, ComponentStatusRepository.COMPONENT_DETAIL_DESTINATION_NAME, destinationName); + addToMap(map, ComponentStatusRepository.COMPONENT_DETAIL_URI, targetUri); return map; } + + private void addToMap(final Map map, final String key, final String value) { + if (value != null) { + map.put(key, value); + } + } }