simonbence commented on code in PR #8670:
URL: https://github.com/apache/nifi/pull/8670#discussion_r1624156802


##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java:
##########
@@ -2104,6 +2203,24 @@ public Response getVersions(
         return 
generateOkResponse(versionedFlowSnapshotMetadataSetEntity).build();
     }
 
+    private static FlowComparisonEntity limitDifferences(final 
FlowComparisonEntity original, final int offset, final int limit) {
+        final List<ComponentDifferenceDTO> limited = 
PaginationHelper.paginateByContainedItems(
+                original.getComponentDifferences(), offset, limit, 
ComponentDifferenceDTO::getDifferences, FlowResource::limitDifferences);
+        final FlowComparisonEntity result = new FlowComparisonEntity();
+        result.setComponentDifferences(new HashSet<>(limited));
+        return result;
+    }
+
+    private static ComponentDifferenceDTO limitDifferences(final 
ComponentDifferenceDTO original, final List<DifferenceDTO> partial) {
+        final ComponentDifferenceDTO result = new ComponentDifferenceDTO();
+        result.setComponentType(original.getComponentType());
+        result.setComponentId(original.getComponentId());
+        result.setComponentName(original.getComponentName());
+        result.setProcessGroupId(original.getProcessGroupId());
+        result.setDifferences(partial);
+        return result;
+    }

Review Comment:
   A significant difference from the `Local Changes` is that, we have a bigger 
chance to have more changed components, so I would expect more situation where 
we reach the limit of the first page (which is 1000, similar to the limitations 
of the `Local Changes`). 
   
   As of this I do not find it unlikely that we want to support pagination in 
the long run. As for now, I aim to serve the first page only, but I wanted to 
provide an implementation which will be a good basis for furher changes if we 
want to allow pagination in the future.
   
   Upon the start of this improvement, I reached out to @markap14 in order to 
ask his opinion about the possible support of pagination within the API (which 
would either result an extension of the current entity or adding a new one) and 
he voted against to touch the API for now.
   
   The solution I provided looked to satisfy this expectation as well (next to 
the expectations from the original purpose) and provides enough option for 
later adjustments. With this, if based on the community's experience the 
pagination will be a more significant need, we can add it easily, even without 
NiFi REST API changes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to