Enhance Pagination Logic for Get All Submodels and Submodel Descriptors - #204
Closed
mm-kgi wants to merge 32 commits into
Closed
Enhance Pagination Logic for Get All Submodels and Submodel Descriptors#204mm-kgi wants to merge 32 commits into
mm-kgi wants to merge 32 commits into
Conversation
…pecific request keys
…hell descriptors with template mapping support
…th user-context aware caching and automated error mapping
…l descriptors with parallel processing
… in parallel execution
…ext aware key generation
…ion support - Updated SubmodelRepositoryService to implement pagination for submodel retrieval, including cursor handling. - Introduced SubmodelPageCursor to manage state across paginated requests. - Modified IPluginDataHandler and IPluginDataProvider interfaces to include pagination parameters. - Adjusted PluginDataHandler and PluginDataProvider implementations to support new pagination logic. - Enhanced unit tests for SubmodelRepositoryService to cover new pagination scenarios. - Added new tests for SubmodelPageCursor to ensure correct encoding and decoding behavior. - Updated existing tests in PluginDataHandler and PluginDataProvider to accommodate changes in method signatures.
… the two-field composite cursor design
… pagination support" This reverts commit 77a54fb.
…ion support Updated SubmodelRepositoryService to implement pagination for submodel retrieval, including cursor handling. Introduced SubmodelPageCursor to manage state across paginated requests. Modified IPluginDataHandler and IPluginDataProvider interfaces to include pagination parameters. Adjusted PluginDataHandler and PluginDataProvider implementations to support new pagination logic. Enhanced unit tests for SubmodelRepositoryService to cover new pagination scenarios. Added new tests for SubmodelPageCursor to ensure correct encoding and decoding behavior. Updated existing tests in PluginDataHandler and PluginDataProvider to accommodate changes in method signatures.
… SubmodelRepositoryService
Refactored `SubmodelDescriptorService` to introduce a two-field composite cursor pagination algorithm for efficient data retrieval. Updated `GetAllSubmodelDescriptorsAsync` to use the new pagination logic and include cursor metadata. Added helper methods `CollectSubmodelDescriptorPageAsync`, `ProcessShellBatch`, and `GetSubmodelIdsForShell` to support the new pagination mechanism. Introduced `PaginationState` and `SubmodelDescriptorPageResult` to manage pagination state. Updated test cases in `SubmodelDescriptorServiceTests` to validate the new pagination logic, including a new test method `GetAllSubmodelDescriptorsAsync_ResumesCorrectly_WithTwoFieldCompositeCursor`. Refactored `CreateShell` to support customizable test data. Removed the obsolete `ExtractDistinctSubmodelIds` method and added necessary `using` directives for additional namespaces.
…ce with pagination and associated test data fixtures
…ng semantic and shell descriptor data
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
Moves submodel pagination closer to shell metadata retrieval for repository and registry endpoints.
Changes:
- Adds composite submodel/AAS cursors and shared pagination state.
- Propagates pagination through plugin metadata APIs and parallelizes requests.
- Updates configuration, tests, and expected responses.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
SubmodelRepository/TestData/GetAllSubmodels_Expected.json |
Updates expected IDs and formatting. |
SubmodelRepository/TestData/GetAllSubmodels_ByIdShort_Expected.json |
Updates filtered response IDs. |
SubmodelRepository/TestData/GetAllSubmodels_By_SemanticId_Expected.json |
Updates semantic-filter response IDs. |
SubmodelRegistry/TestData/GetAllSubmodelDescriptors_WithLimitOne_Expected.json |
Updates composite cursor. |
SubmodelRegistry/TestData/GetAllSubmodelDescriptors_WithCursor_Expected.json |
Updates cursor-page expectations. |
TemplateManagementConfig.cs |
Raises default concurrency limit. |
PluginDataProvider.cs |
Adds paginated metadata requests and parallel data requests. |
PluginDataHandler.cs |
Propagates metadata pagination. |
CachedGetRequestClient.cs |
Adds framework imports. |
SubmodelPaginationCursor.cs |
Defines composite cursor encoding. |
appsettings.development.json |
Raises development concurrency limits. |
SubmodelRepositoryService.cs |
Implements early submodel pagination. |
SubmodelDescriptorService.cs |
Implements early descriptor pagination. |
SubmodelPagination.cs |
Adds shared pagination state. |
IPluginDataProvider.cs |
Extends provider pagination contract. |
IPluginDataHandler.cs |
Extends handler pagination contract. |
AssetIdSearchService.cs |
Adapts handler invocation. |
AasRepositoryService.cs |
Adapts handler invocation. |
PluginDataProviderTests.cs |
Updates provider tests. |
PluginDataHandlerTests.cs |
Updates handler tests. |
CachedGetRequestClientTests.cs |
Normalizes source encoding. |
SubmodelRepositoryServiceTests.cs |
Adds pagination-boundary tests. |
SubmodelDescriptorServiceTests.cs |
Adds composite-cursor tests. |
AssetIdSearchServiceTests.cs |
Updates pagination arguments. |
AasRepositoryServiceTests.cs |
Updates handler expectations. |
SubmodelDescriptorControllerTests.cs |
Updates repository mocks. |
Suppressed comments (1)
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/Shared/SubmodelPagination.cs:34
- This no longer preserves the previous global
Distinct()behavior: a submodel referenced by multiple shells is appended once per shell, so/submodelsand/submodel-descriptorscan return duplicates within or across pages. The prior regression test for shared submodel IDs was removed rather than adapted. Track IDs already emitted across the shell stream (with cursor state that remains valid across pages) before adding them.
for (var i = startIndex; i < submodelIds.Count; i++)
{
CollectedIds.Add(submodelIds[i]);
LastCollectedSubmodelId = submodelIds[i];
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…etFilteredMetadataAsync
… and improve null handling in related tests
|
Test & Coverage ReportTest Results Summary
Code CoverageUnit Tests Coverage
Minimum allowed line rate is Module Tests Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Overview
This PR enhances the pagination flow for the following endpoints:
GET /submodelsGET /submodel-descriptorsThe current implementation retrieves all Shell metadata from the Plugin, generates all Submodels/Submodel Descriptors, and only then applies pagination. This can result in unnecessary metadata retrieval and Submodel generation for large datasets.
This change introduces an improved pagination flow that performs pagination earlier in the processing pipeline while preserving the existing logical ordering and ensuring that no Submodels are skipped or duplicated.
Endpoints Covered
The same pagination approach is applied consistently to:
GET /submodelsGET /submodel-descriptorsThis ensures both endpoints follow the same cursor and ordering semantics.
Edge Cases
The implementation considers:
Validation
The implementation should be validated against scenarios including:
Summary
This PR improves pagination by moving pagination closer to the metadata retrieval stage while retaining Submodel-level pagination semantics.
The solution ensures that:
submodelIdandaasIdcursor handling is supported./submodelsand/submodel-descriptorsfollow consistent pagination behavior.