Skip to content

Enhance Pagination Logic for Get All Submodels and Submodel Descriptors - #207

Open
mm-kgi wants to merge 34 commits into
developfrom
1511-submodel-pagination-enhancement
Open

Enhance Pagination Logic for Get All Submodels and Submodel Descriptors#207
mm-kgi wants to merge 34 commits into
developfrom
1511-submodel-pagination-enhancement

Conversation

@mm-kgi

@mm-kgi mm-kgi commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR enhances the pagination flow for the following endpoints:

  • GET /submodels
  • GET /submodel-descriptors

The 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 /submodels
  • GET /submodel-descriptors

This ensures both endpoints follow the same cursor and ordering semantics.

Edge Cases

The implementation considers:

  • Cursor pointing to a Submodel in the middle of a Shell.
  • Shells containing different numbers of Submodels.
  • Partially processed Shells.
  • Multiple Shell Templates.
  • Cursor pointing to the last Submodel of a Shell.
  • Transition from one Shell to the next.
  • Ensuring no duplicate or skipped Submodels across pages.

Validation

The implementation should be validated against scenarios including:

  • Cursor within the first Shell.
  • Cursor at the last Submodel of a Shell.
  • Cursor across multiple Shells.
  • Multiple Shell Templates.
  • Different numbers of Submodels per Shell.
  • Small and large page sizes.
  • First page without a cursor.
  • Subsequent pages using the returned cursor.
  • Ensuring consecutive pages contain no duplicates or missing Submodels.

Summary

This PR improves pagination by moving pagination closer to the metadata retrieval stage while retaining Submodel-level pagination semantics.

The solution ensures that:

  • Plugin metadata retrieval is paginated.
  • submodelId and aasId cursor handling is supported.
  • Ordering is preserved.
  • Submodels are neither skipped nor duplicated.
  • Multiple Shell Templates are supported.
  • Both /submodels and /submodel-descriptors follow consistent pagination behavior.
  • Large datasets can be processed more efficiently.

mm-kgi and others added 30 commits July 23, 2026 12:53
…hell descriptors with template mapping support
…th user-context aware caching and automated error mapping
…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.
…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.
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
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@mm-kgi mm-kgi changed the title 1511 submodel pagination enhancement Enhance Pagination Logic for Get All Submodels and Submodel Descriptors Aug 26, 2026
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Test & Coverage Report

Test Results Summary

Metric Count
✅ Passed 1689
❌ Failed 0
⏭️ Skipped 0

View Detailed Test Results


Code Coverage

Unit Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 92% 78% 2402
Summary 92% (3816 / 4154) 78% (1580 / 2037) 2402

Minimum allowed line rate is 80%

Module Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 62% 42% 2402
Summary 62% (2584 / 4154) 42% (863 / 2037) 2402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants