Skip to content

Commit

Permalink
Revert "feat(impl):[#510] dont filter submodel descriptors"
Browse files Browse the repository at this point in the history
This reverts commit 3c07df8
  • Loading branch information
ds-jhartmann committed May 13, 2024
1 parent 75ad5f3 commit b525c19
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -86,19 +86,21 @@ public ItemContainer process(final ItemContainer.ItemContainerBuilder itemContai
final List<SubmodelDescriptor> aasSubmodelDescriptors = shell.payload().getSubmodelDescriptors();
log.info("Retrieved {} SubmodelDescriptor for itemId {}", aasSubmodelDescriptors.size(), itemId);

final List<SubmodelDescriptor> filteredSubmodelDescriptorsByAspectType = shell.payload()
.filterDescriptorsByAspectTypes(
jobData.getAspects());

if (jobData.isCollectAspects()) {
log.info("Collecting Submodels.");
final List<SubmodelDescriptor> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))))));
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ public Optional<String> findManufacturerId() {
.findFirst();
}

/**
* @param aspectTypes the aspect types which should be filtered by
* @return AssetAdministrationShellDescriptor with filtered submodel descriptors
*/
public AssetAdministrationShellDescriptor withFilteredSubmodelDescriptors(final List<String> aspectTypes) {
setSubmodelDescriptors(filterDescriptorsByAspectTypes(aspectTypes));
return this;
}

/**
* @param relationshipAspect filter for aspect type
* @return The filtered list of submodel addresses
Expand Down

0 comments on commit b525c19

Please sign in to comment.