Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synch #930

Merged
merged 14 commits into from
May 13, 2024
Merged

Synch #930

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ _**For better traceability add the corresponding GitHub issue number in each cha

## [Unreleased]

### Fixed

- Cleaning up BPNLs without policies. #533

### Changed

- BPN summary was removed from Job response #568
- Shells in Job response will contain all submodel descriptors returned by provider, instead filtered by aspect-type parameter. #510


## [5.1.1] - 2024-05-08

### Fixed
Expand All @@ -17,7 +27,6 @@ _**For better traceability add the corresponding GitHub issue number in each cha
### Added

- Cucumber test step definitions for Policy Store API (Happy Path) including some test helper utilities. #518


## [5.1.0] - 2024-05-06

Expand All @@ -34,8 +43,6 @@ _**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
7 changes: 1 addition & 6 deletions docs/src/api/irs-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,9 +1121,6 @@ components:
completed: 3
failed: 0
running: 0
bpnLookups:
completed: 3
failed: 0
relationships:
- catenaXId: urn:uuid:d9bec1c6-e47c-4d18-ba41-0a5fe8b7f447
linkedItem:
Expand Down Expand Up @@ -2154,7 +2151,7 @@ components:
additionalProperties: false
description: Container for a job with item graph.
example: |-
{"bpns"=[{"manufacturerId"="BPNL00000003AAXX", "manufacturerName"="AB CD"}], "job"={"completedOn"="2022-02-03T14:48:54.709Z", "createdOn"="2022-02-03T14:48:54.709Z", "exception"={"errorDetail"="Timeout while requesting Digital Registry", "exception"="IrsTimeoutException", "exceptionDate"="2022-02-03T14:48:54.709Z"}, "globalAssetId"="urn:uuid:6c311d29-5753-46d4-b32c-19b918ea93b0", "id"="e5347c88-a921-11ec-b909-0242ac120002", "lastModifiedOn"="2022-02-03T14:48:54.709Z", "parameter"={"aspects"=["SerialPart", "AddressAspect"], "auditContractNegotiation"=false, "bomLifecycle"="asBuilt", "collectAspects"=false, "depth"=1, "direction"="downward", "lookupBPNs"=false}, "startedOn"="2022-02-03T14:48:54.709Z", "state"="COMPLETED", "summary"={"asyncFetchedItems"={"completed"=3, "failed"=0, "running"=0}, "bpnLookups"={"completed"=3, "failed"=0}}}, "relationships"=[{"catenaXId"="urn:uuid:d9bec1c6-e47c-4d18-ba41-0a5fe8b7f447", "linkedItem"={"assembledOn"="2022-02-03T14:48:54.709Z", "childCatenaXId"="urn:uuid:a45a2246-f6e1-42da-b47d-5c3b58ed62e9", "hasAlternatives"=false, "lastModifiedOn"="2022-02-03T14:48:54.709Z", "lifecycleContext"="asBuilt", "quantity"={"measurementUnit"={"datatypeURI"="urn:bamm:io.openmanufacturing:meta-model:1.0.0#piece", "lexicalValue"="piece"}, "quantityNumber"=1}}}], "shells"=[{"contractAgreementId"="f253718e-a270-4367-901b-9d50d9bd8462", "payload"={"description"=[{"language"="en", "text"="The shell for a vehicle"}], "globalAssetId"="urn:uuid:a45a2246-f6e1-42da-b47d-5c3b58ed62e9", "id"="urn:uuid:882fc530-b69b-4707-95f6-5dbc5e9baaa8", "idShort"="future concept x", "specificAssetIds"=[{"name"="engineserialid", "value"="12309481209312"}], "submodelDescriptors"=[{"description"=[{"language"="en", "text"="Provides base vehicle information"}], "endpoints"=[{"interface"="HTTP", "protocolInformation"={"endpointProtocol"="HTTPS", "endpointProtocolVersion"=["1.0"], "href"="https://catena-x.net/vehicle/basedetails/", "subprotocol"="DSP", "subprotocolBody"="id=urn:uuid:c8159379-4613-48b8-ad52-6baed7afe923;dspEndpoint=https://irs-provider-controlplane3.dev.demo.catena-x.net", "subprotocolBodyEncoding"="plain"}}], "id"="urn:uuid:5d25a897-6571-4800-b98c-a3352fbf996d", "idShort"="SingleLevelBomAsPlanned", "semanticId"={"keys"=[{"type"="ExternalReference", "value"="urn:bamm:io.catenax.single_level_bom_as_planned:2.0.0#SingleLevelBomAsPlanned"}], "type"="ModelReference"}},
{"bpns"=[{"manufacturerId"="BPNL00000003AAXX", "manufacturerName"="AB CD"}], "job"={"completedOn"="2022-02-03T14:48:54.709Z", "createdOn"="2022-02-03T14:48:54.709Z", "exception"={"errorDetail"="Timeout while requesting Digital Registry", "exception"="IrsTimeoutException", "exceptionDate"="2022-02-03T14:48:54.709Z"}, "globalAssetId"="urn:uuid:6c311d29-5753-46d4-b32c-19b918ea93b0", "id"="e5347c88-a921-11ec-b909-0242ac120002", "lastModifiedOn"="2022-02-03T14:48:54.709Z", "parameter"={"aspects"=["SerialPart", "AddressAspect"], "auditContractNegotiation"=false, "bomLifecycle"="asBuilt", "collectAspects"=false, "depth"=1, "direction"="downward", "lookupBPNs"=false}, "startedOn"="2022-02-03T14:48:54.709Z", "state"="COMPLETED", "summary"={"asyncFetchedItems"={"completed"=3, "failed"=0, "running"=0}}}, "relationships"=[{"catenaXId"="urn:uuid:d9bec1c6-e47c-4d18-ba41-0a5fe8b7f447", "linkedItem"={"assembledOn"="2022-02-03T14:48:54.709Z", "childCatenaXId"="urn:uuid:a45a2246-f6e1-42da-b47d-5c3b58ed62e9", "hasAlternatives"=false, "lastModifiedOn"="2022-02-03T14:48:54.709Z", "lifecycleContext"="asBuilt", "quantity"={"measurementUnit"={"datatypeURI"="urn:bamm:io.openmanufacturing:meta-model:1.0.0#piece", "lexicalValue"="piece"}, "quantityNumber"=1}}}], "shells"=[{"contractAgreementId"="f253718e-a270-4367-901b-9d50d9bd8462", "payload"={"description"=[{"language"="en", "text"="The shell for a vehicle"}], "globalAssetId"="urn:uuid:a45a2246-f6e1-42da-b47d-5c3b58ed62e9", "id"="urn:uuid:882fc530-b69b-4707-95f6-5dbc5e9baaa8", "idShort"="future concept x", "specificAssetIds"=[{"name"="engineserialid", "value"="12309481209312"}], "submodelDescriptors"=[{"description"=[{"language"="en", "text"="Provides base vehicle information"}], "endpoints"=[{"interface"="HTTP", "protocolInformation"={"endpointProtocol"="HTTPS", "endpointProtocolVersion"=["1.0"], "href"="https://catena-x.net/vehicle/basedetails/", "subprotocol"="DSP", "subprotocolBody"="id=urn:uuid:c8159379-4613-48b8-ad52-6baed7afe923;dspEndpoint=https://irs-provider-controlplane3.dev.demo.catena-x.net", "subprotocolBodyEncoding"="plain"}}], "id"="urn:uuid:5d25a897-6571-4800-b98c-a3352fbf996d", "idShort"="SingleLevelBomAsPlanned", "semanticId"={"keys"=[{"type"="ExternalReference", "value"="urn:bamm:io.catenax.single_level_bom_as_planned:2.0.0#SingleLevelBomAsPlanned"}], "type"="ModelReference"}},
{"description"=[{"language"="en", "text"="Provides base vehicle information"}], "endpoints"=[{"interface"="HTTP", "protocolInformation"={"endpointProtocol"="HTTPS", "endpointProtocolVersion"=["1.0"], "href"="https://catena-x.net/vehicle/partdetails/", "subprotocol"="DSP", "subprotocolBody"="id=urn:uuid:c8159379-4613-48b8-ad52-6baed7afe923;dspEndpoint=https://irs-provider-controlplane3.dev.demo.catena-x.net", "subprotocolBodyEncoding"="plain"}}], "id"="urn:uuid:dae4d249-6d66-4818-b576-bf52f3b9ae90", "idShort"="vehicle part details", "semanticId"={"keys"=[{"type"="Submodel", "value"="urn:bamm:com.catenax.vehicle:0.1.1#PartDetails"}], "type"="ModelReference"}}]}}], "submodels"=[{"aspectType"="supply_chain_impacted", "contractAgreementId"="f253718e-a270-4367-901b-9d50d9bd8462", "identification"="urn:uuid:fc784d2a-5506-4e61-8e34-21600f8cdeff", "payload"={"supplyChainImpacted"="YES"}}], "tombstones"=[{"catenaXId"="urn:uuid:6c311d29-5753-46d4-b32c-19b918ea93b0", "endpointURL"="https://catena-x.net/vehicle/partdetails/", "processingError"={"errorDetail"="Details to reason of failure", "lastAttempt"="2022-02-03T14:48:54.709Z", "processStep"="SchemaValidation", "retryCounter"=0}}]}
properties:
bpns:
Expand Down Expand Up @@ -2754,8 +2751,6 @@ components:
properties:
asyncFetchedItems:
$ref: '#/components/schemas/AsyncFetchedItems'
bpnLookups:
$ref: '#/components/schemas/AsyncFetchedItems'
Tombstone:
type: object
additionalProperties: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ 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,6 @@
/**
* 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.
*/
@Slf4j
public class SubmodelDelegate extends AbstractDelegate {
Expand Down Expand Up @@ -86,21 +85,19 @@ 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);

shell.payload().setSubmodelDescriptors(filteredSubmodelDescriptorsByAspectType);

log.trace("Unfiltered SubmodelDescriptor: {}", aasSubmodelDescriptors);
log.trace("Filtered SubmodelDescriptor: {}", filteredSubmodelDescriptorsByAspectType);
}
});

return next(itemContainerBuilder, jobData, aasTransferProcess, itemId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.eclipse.tractusx.irs.component.BatchOrderResponse;
import org.eclipse.tractusx.irs.component.BatchResponse;
import org.eclipse.tractusx.irs.component.Bpn;
import org.eclipse.tractusx.irs.component.FetchedItems;
import org.eclipse.tractusx.irs.component.GlobalAssetIdentification;
import org.eclipse.tractusx.irs.component.Job;
import org.eclipse.tractusx.irs.component.JobErrorDetails;
Expand Down Expand Up @@ -284,7 +283,6 @@ private Example createCompleteEssJobResult() {
.completed(FETCHED_ITEMS_SIZE)
.failed(NO_RUNNING_OR_FAILED_ITEMS)
.build(),
FetchedItems.builder().completed(FETCHED_ITEMS_SIZE).failed(NO_RUNNING_OR_FAILED_ITEMS).build(),
SENT_NOTIFICATIONS_SIZE, SENT_NOTIFICATIONS_SIZE);
final Job job = essJobsJobs.getJob().toBuilder().summary(newSummary).build();
return toExample(essJobsJobs.toBuilder().job(job).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ private Jobs updateLastModified(final Jobs irsJob, final ZonedDateTime lastModif
private Jobs extendSummary(final Jobs irsJob) {
final Summary oldSummary = Optional.ofNullable(irsJob.getJob().getSummary()).orElse(Summary.builder().build());
final NotificationSummary newSummary = new NotificationSummary(oldSummary.getAsyncFetchedItems(),
oldSummary.getBpnLookups(),
new NotificationItems(unansweredNotifications.size() + answeredNotifications.size(),
answeredNotifications.size()));
final Job job = irsJob.getJob().toBuilder().summary(newSummary).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import lombok.Value;
import lombok.extern.jackson.Jacksonized;
import org.eclipse.tractusx.irs.component.AsyncFetchedItems;
import org.eclipse.tractusx.irs.component.FetchedItems;
import org.eclipse.tractusx.irs.component.Summary;

/**
Expand All @@ -42,15 +41,14 @@ public class NotificationSummary extends Summary {

private final NotificationItems notifications;

public NotificationSummary(final AsyncFetchedItems asyncFetchedItems, final FetchedItems bpnLookups,
final NotificationItems notificationItems) {
super(asyncFetchedItems, bpnLookups);
public NotificationSummary(final AsyncFetchedItems asyncFetchedItems, final NotificationItems notificationItems) {
super(asyncFetchedItems);
this.notifications = notificationItems;
}

public NotificationSummary(final AsyncFetchedItems asyncFetchedItems, final FetchedItems bpnLookups,
final Integer sentNotification, final Integer receivedNotification) {
super(asyncFetchedItems, bpnLookups);
public NotificationSummary(final AsyncFetchedItems asyncFetchedItems, final Integer sentNotification,
final Integer receivedNotification) {
super(asyncFetchedItems);
this.notifications = new NotificationItems(sentNotification, receivedNotification);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.eclipse.tractusx.irs.common.persistence.BlobPersistenceException;
import org.eclipse.tractusx.irs.component.AsyncFetchedItems;
import org.eclipse.tractusx.irs.component.Bpn;
import org.eclipse.tractusx.irs.component.FetchedItems;
import org.eclipse.tractusx.irs.component.Job;
import org.eclipse.tractusx.irs.component.JobHandle;
import org.eclipse.tractusx.irs.component.JobParameter;
Expand Down Expand Up @@ -295,7 +294,6 @@ private Summary buildSummary(final int completedTransfersSize, final int running
.running(runningSize)
.failed(tombstonesSize)
.build())
.bpnLookups(FetchedItems.builder().completed(0).failed(0).build())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ static RegisterJob jobRequest(final String globalAssetId, final String bpn, fina
.depth(depth)
.aspects(List.of(batchAspectName, singleLevelBomAsBuiltAspectName))
.collectAspects(true)
.lookupBPNs(true)
.direction(Direction.DOWNWARD)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void shouldFillItemContainerWithShellAndContractAgreementIdWhenAuditFlag() throw
}

@Test
void shouldFillItemContainerWithShellAndFilteredSubmodelDescriptorsWhenDepthReached() throws RegistryServiceException {
void shouldFillItemContainerWithShellAndSubmodelDescriptorsWhenDepthReached() throws RegistryServiceException {
// given
when(digitalTwinRegistryService.fetchShells(any())).thenReturn(
List.of(shell("", shellDescriptor(List.of(submodelDescriptorWithoutHref("any"))))));
Expand All @@ -99,7 +99,7 @@ void shouldFillItemContainerWithShellAndFilteredSubmodelDescriptorsWhenDepthReac
// then
assertThat(result).isNotNull();
assertThat(result.getShells()).isNotEmpty();
assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isEmpty();
assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isNotEmpty();
}

@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 shouldFilterSubmodelDescriptorsByAspectTypeFilter() {
void shouldNotFilterSubmodelDescriptorsByAspectTypeFilter() {
// given
final ItemContainer.ItemContainerBuilder itemContainerShellWithTwoSubmodels = ItemContainer.builder()
.shell(shell("", shellDescriptor(
Expand All @@ -85,7 +85,7 @@ void shouldFilterSubmodelDescriptorsByAspectTypeFilter() {

// then
assertThat(result).isNotNull();
assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isEmpty();
assertThat(result.getShells().get(0).payload().getSubmodelDescriptors()).isNotEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ void shouldReturnBadRequestWhenRegisterJobWithInvalidDirection(String invalidDir
"globalAssetId": "urn:uuid:c6d2d642-a055-4ddf-87e3-1a3b02c689e3",
"bpn": "BPNL00000000BJTL"
},
"direction": "<DIRECTION>",
"lookupBPNs": true
"direction": "<DIRECTION>"
}
""".replace("<DIRECTION>", invalidDirection))
.post("/irs/jobs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,6 @@ public static JobParameter jobParameterFilter() {
.build();
}

public static JobParameter jobParameterCollectBpns() {
return JobParameter.builder()
.depth(0)
.bomLifecycle(BomLifecycle.AS_BUILT)
.direction(Direction.DOWNWARD)
.aspects(List.of(serialPartAspectName, singleLevelBomAsBuiltAspectName))
.lookupBPNs(true)
.build();
}

public static JobParameter jobParameterAuditContractNegotiation() {
return JobParameter.builder()
.depth(5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ public void collectAspects(String collectAspects) {
registerBatchOrderBuilder.collectAspects(Boolean.parseBoolean(collectAspects));
}

@And("lookupBPNs {string}")
public void lookupBPNs(String lookupBPNs) {
registerJobBuilder.lookupBPNs(Boolean.parseBoolean(lookupBPNs));
registerBatchOrderBuilder.lookupBPNs(Boolean.parseBoolean(lookupBPNs));
}

@And("depth {int}")
public void depth(int depth) {
registerJobBuilder.depth(depth);
Expand Down Expand Up @@ -368,9 +362,6 @@ public void iCheckIfSummaryContainsCompletedAndFailedItems(String summary, int c
if ("summary".equals(summary)) {
assertThat(completedJob.getJob().getSummary().getAsyncFetchedItems().getCompleted()).isEqualTo(completed);
assertThat(completedJob.getJob().getSummary().getAsyncFetchedItems().getFailed()).isEqualTo(failed);
} else if ("bpn summary".equals(summary)) {
assertThat(completedJob.getJob().getSummary().getBpnLookups().getCompleted()).isEqualTo(completed);
assertThat(completedJob.getJob().getSummary().getBpnLookups().getFailed()).isEqualTo(failed);
}
}

Expand Down Expand Up @@ -437,11 +428,6 @@ public void directionIs(String direction) {
assertThat(completedJob.getJob().getParameter().getDirection()).isEqualTo(Direction.fromValue(direction));
}

@And("lookupBPNs is {string}")
public void lookupBPNsIs(String lookupBPNs) {
assertThat(completedJob.getJob().getParameter().isLookupBPNs()).isEqualTo(Boolean.valueOf(lookupBPNs));
}

@And("bomLifecycle is {string}")
public void bomLifecycleIs(String bomLifecycle) {
assertThat(completedJob.getJob().getParameter().getBomLifecycle()).isEqualTo(
Expand Down
Loading