diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f75840c42..87ff6988ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,6 @@ _**For better traceability add the corresponding GitHub issue number in each cha ## [Unreleased] - ## Added - Added endpoint for dedicated removal of policy from BPNL. #559 @@ -34,6 +33,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha - Cucumber test step definitions for Policy Store API (Happy Path) including some test helper utilities. #518 + ## [5.1.0] - 2024-05-06 ### Changed @@ -49,6 +49,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha - Update bouncycastle to 1.78 to fix CVE's. - Fixed validation of json-schemas - IRS is creating tombstone instead collecting Submodel payload, when it not passes validation of schema #522 + ## [5.0.0] - 2024-04-16 ### Added diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/DigitalTwinDelegate.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/DigitalTwinDelegate.java index dbec718442..5601a2f3ad 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/DigitalTwinDelegate.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/DigitalTwinDelegate.java @@ -74,6 +74,11 @@ public ItemContainer process(final ItemContainer.ItemContainerBuilder itemContai // DigitalTwinRegistryKey here .findFirst().orElseThrow(); + if (!expectedDepthOfTreeIsNotReached(jobData.getDepth(), aasTransferProcess.getDepth())) { + // filter submodel descriptors if next delegate will not be executed + shell.payload().withFilteredSubmodelDescriptors(jobData.getAspects()); + } + itemContainerBuilder.shell( jobData.isAuditContractNegotiation() ? shell : shell.withoutContractAgreementId()); } catch (final RegistryServiceException | RuntimeException e) { diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegate.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegate.java index fad0fc436f..c273f003c1 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegate.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegate.java @@ -55,7 +55,7 @@ /** * Builds submodels array for AAShell from previous steps. * All submodels are being retrieved from EDC's components. - * Additionally, submodel descriptors from shell are being filtered to requested aspect types. + * Additionally submodel descriptors from shell are being filtered to requested aspect types. */ @Slf4j public class SubmodelDelegate extends AbstractDelegate { @@ -86,19 +86,21 @@ public ItemContainer process(final ItemContainer.ItemContainerBuilder itemContai final List aasSubmodelDescriptors = shell.payload().getSubmodelDescriptors(); log.info("Retrieved {} SubmodelDescriptor for itemId {}", aasSubmodelDescriptors.size(), itemId); + final List filteredSubmodelDescriptorsByAspectType = shell.payload() + .filterDescriptorsByAspectTypes( + jobData.getAspects()); + if (jobData.isCollectAspects()) { log.info("Collecting Submodels."); - final List filteredSubmodelDescriptorsByAspectType = shell.payload() - .filterDescriptorsByAspectTypes( - jobData.getAspects()); - filteredSubmodelDescriptorsByAspectType.forEach(submodelDescriptor -> itemContainerBuilder.submodels( getSubmodels(submodelDescriptor, itemContainerBuilder, itemId.getGlobalAssetId(), itemId.getBpn(), jobData.isAuditContractNegotiation()))); - - log.trace("Unfiltered SubmodelDescriptor: {}", aasSubmodelDescriptors); - log.trace("Filtered SubmodelDescriptor: {}", filteredSubmodelDescriptorsByAspectType); } + log.trace("Unfiltered SubmodelDescriptor: {}", aasSubmodelDescriptors); + log.trace("Filtered SubmodelDescriptor: {}", filteredSubmodelDescriptorsByAspectType); + + shell.payload().setSubmodelDescriptors(filteredSubmodelDescriptorsByAspectType); + }); return next(itemContainerBuilder, jobData, aasTransferProcess, itemId); diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/DigitalTwinDelegateTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/DigitalTwinDelegateTest.java index 25b9a78cc9..7a33d5c224 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/DigitalTwinDelegateTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/DigitalTwinDelegateTest.java @@ -86,7 +86,7 @@ void shouldFillItemContainerWithShellAndContractAgreementIdWhenAuditFlag() throw } @Test - void shouldFillItemContainerWithShellAndSubmodelDescriptorsWhenDepthReached() throws RegistryServiceException { + void shouldFillItemContainerWithShellAndFilteredSubmodelDescriptorsWhenDepthReached() throws RegistryServiceException { // given when(digitalTwinRegistryService.fetchShells(any())).thenReturn( List.of(shell("", shellDescriptor(List.of(submodelDescriptorWithoutHref("any")))))); @@ -99,7 +99,7 @@ void shouldFillItemContainerWithShellAndSubmodelDescriptorsWhenDepthReached() th // then assertThat(result).isNotNull(); assertThat(result.getShells()).isNotEmpty(); - assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isNotEmpty(); + assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isEmpty(); } @Test diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegateTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegateTest.java index b54b746d96..f96b066866 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegateTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/aaswrapper/job/delegate/SubmodelDelegateTest.java @@ -68,7 +68,7 @@ class SubmodelDelegateTest { jsonValidatorService, new JsonUtil(), connectorEndpointsService); @Test - void shouldNotFilterSubmodelDescriptorsByAspectTypeFilter() { + void shouldFilterSubmodelDescriptorsByAspectTypeFilter() { // given final ItemContainer.ItemContainerBuilder itemContainerShellWithTwoSubmodels = ItemContainer.builder() .shell(shell("", shellDescriptor( @@ -85,7 +85,7 @@ void shouldNotFilterSubmodelDescriptorsByAspectTypeFilter() { // then assertThat(result).isNotNull(); - assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isNotEmpty(); + assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isEmpty(); } @Test diff --git a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/assetadministrationshell/AssetAdministrationShellDescriptor.java b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/assetadministrationshell/AssetAdministrationShellDescriptor.java index 2c8d28110d..f9c29d5329 100644 --- a/irs-models/src/main/java/org/eclipse/tractusx/irs/component/assetadministrationshell/AssetAdministrationShellDescriptor.java +++ b/irs-models/src/main/java/org/eclipse/tractusx/irs/component/assetadministrationshell/AssetAdministrationShellDescriptor.java @@ -96,6 +96,15 @@ public Optional findManufacturerId() { .findFirst(); } + /** + * @param aspectTypes the aspect types which should be filtered by + * @return AssetAdministrationShellDescriptor with filtered submodel descriptors + */ + public AssetAdministrationShellDescriptor withFilteredSubmodelDescriptors(final List aspectTypes) { + setSubmodelDescriptors(filterDescriptorsByAspectTypes(aspectTypes)); + return this; + } + /** * @param relationshipAspect filter for aspect type * @return The filtered list of submodel addresses