diff --git a/docs/src/api/irs-v1.0.yaml b/docs/src/api/irs-v1.0.yaml index 41020f877c..95d5cc3028 100644 --- a/docs/src/api/irs-v1.0.yaml +++ b/docs/src/api/irs-v1.0.yaml @@ -84,7 +84,7 @@ paths: application/json: examples: complete: - $ref: '#/components/examples/complete-job-result' + $ref: '#/components/examples/complete-ess-job-result' schema: $ref: '#/components/schemas/Jobs' description: Return job with item graph for the requested id. @@ -939,6 +939,111 @@ components: orderId: f253718e-a270-4367-901b-9d50d9bd8462 startedOn: 2022-02-03T14:48:54.709Z totalJobs: 1 + complete-ess-job-result: + value: + 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 + owner: "" + parameter: + aspects: + - SerialPart + - AddressAspect + 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 + 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.0 + shells: + - description: + - language: en + text: The shell for a vehicle + globalAssetId: urn:uuid:a45a2246-f6e1-42da-b47d-5c3b58ed62e9 + id: 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/ + id: 4a738a24-b7d8-4989-9cd6-387772f40565 + idShort: vehicle base details + semanticId: + keys: + - type: Submodel + value: urn:bamm:com.catenax.vehicle:0.1.1 + 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/ + id: 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 + 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 complete-job-list-processing-state: value: content: @@ -1056,7 +1161,7 @@ components: - catenaXId: urn:uuid:6c311d29-5753-46d4-b32c-19b918ea93b0 endpointURL: https://catena-x.net/vehicle/partdetails/ processingError: - errorDetail: Details to reason of Failure + errorDetail: Details to reason of failure lastAttempt: 2022-02-03T14:48:54.709Z processStep: SchemaValidation retryCounter: 0 @@ -1236,7 +1341,7 @@ components: - catenaXId: urn:uuid:6c311d29-5753-46d4-b32c-19b918ea93b0 endpointURL: https://catena-x.net/vehicle/partdetails/ processingError: - errorDetail: Details to reason of Failure + errorDetail: Details to reason of failure lastAttempt: 2022-02-03T14:48:54.709Z processStep: SchemaValidation retryCounter: 0 diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/OpenApiExamples.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/OpenApiExamples.java index f1e95ed425..f08666c5c0 100644 --- a/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/OpenApiExamples.java +++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/configuration/OpenApiExamples.java @@ -29,10 +29,12 @@ import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.examples.Example; +import org.eclipse.tractusx.ess.service.NotificationSummary; import org.eclipse.tractusx.irs.component.AsyncFetchedItems; import org.eclipse.tractusx.irs.component.BatchResponse; import org.eclipse.tractusx.irs.component.BatchOrderResponse; 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; @@ -84,6 +86,13 @@ public class OpenApiExamples { private static final String GLOBAL_ASSET_ID = "urn:uuid:6c311d29-5753-46d4-b32c-19b918ea93b0"; private static final String SUBMODEL_IDENTIFICATION = "urn:uuid:fc784d2a-5506-4e61-8e34-21600f8cdeff"; private static final String JOB_HANDLE_ID_1 = "6c311d29-5753-46d4-b32c-19b918ea93b0"; + private static final String EXAMPLE_BPN = "BPNL00000003AAXX"; + private static final String SUPPLY_CHAIN_IMPACTED_ASPECT_TYPE = "supply_chain_impacted"; + private static final String SUPPLY_CHAIN_IMPACTED_KEY = "supplyChainImpacted"; + private static final String SUPPLY_CHAIN_IMPACTER_RESULT = "YES"; + private static final int FETCHED_ITEMS_SIZE = 3; + private static final int NO_RUNNING_OR_FAILED_ITEMS = 0; + private static final int SENT_NOTIFICATIONS_SIZE = 6; public void createExamples(final Components components) { components.addExamples("job-handle", toExample(createJobHandle(JOB_HANDLE_ID_1))); @@ -110,6 +119,7 @@ public void createExamples(final Components components) { .withStatusCode(HttpStatus.NOT_FOUND) .build())); components.addExamples("complete-job-result", createCompleteJobResult()); + components.addExamples("complete-ess-job-result", createCompleteEssJobResult()); components.addExamples("complete-order-result", createCompleteOrderResult()); components.addExamples("complete-batch-result", createCompleteBatchResult()); components.addExamples("job-result-without-uncompleted-result-tree", createJobResultWithoutTree()); @@ -242,6 +252,44 @@ private Example createCompleteJobResult() { .build()); } + private Example createCompleteEssJobResult() { + final Jobs essJobsJobs = Jobs.builder() + .job(Job.builder() + .id(UUID.fromString(JOB_ID)) + .globalAssetId(createGAID(GLOBAL_ASSET_ID)) + .state(JobState.COMPLETED) + .owner("") + .createdOn(EXAMPLE_ZONED_DATETIME) + .startedOn(EXAMPLE_ZONED_DATETIME) + .lastModifiedOn(EXAMPLE_ZONED_DATETIME) + .completedOn(EXAMPLE_ZONED_DATETIME) + .owner("") + .summary(createSummary()) + .parameter(createJobParameter()) + .exception(createJobException()) + .build()) + .relationships(List.of(createRelationship())) + .shells(List.of(createShell())) + .tombstone(createTombstone()) + .submodel(createEssSubmodel()) + .bpn(Bpn.withManufacturerId(EXAMPLE_BPN).updateManufacturerName("AB CD")) + .build(); + final NotificationSummary newSummary = new NotificationSummary( + AsyncFetchedItems.builder().running(NO_RUNNING_OR_FAILED_ITEMS).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()); + } + + private Submodel createEssSubmodel() { + return Submodel.builder() + .aspectType(SUPPLY_CHAIN_IMPACTED_ASPECT_TYPE) + .identification(SUBMODEL_IDENTIFICATION) + .payload(Map.of(SUPPLY_CHAIN_IMPACTED_KEY, SUPPLY_CHAIN_IMPACTER_RESULT)) + .build(); + } + private Example createCompleteOrderResult() { return toExample(BatchOrderResponse.builder() .orderId(UUID_ID) @@ -317,7 +365,7 @@ private Tombstone createTombstone() { .endpointURL("https://catena-x.net/vehicle/partdetails/") .processingError(ProcessingError.builder() .withProcessStep(ProcessStep.SCHEMA_VALIDATION) - .withErrorDetail("Details to reason of Failure") + .withErrorDetail("Details to reason of failure") .withLastAttempt(EXAMPLE_ZONED_DATETIME) .withRetryCounter(0) .build()) diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssController.java b/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssController.java index b71f5bb944..35c615ecf3 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssController.java +++ b/irs-ess/src/main/java/org/eclipse/tractusx/ess/controller/EssController.java @@ -119,7 +119,7 @@ public JobHandle registerBPNInvestigation(final @Valid @RequestBody RegisterBpnI content = { @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = Jobs.class), examples = @ExampleObject(name = "complete", - ref = "#/components/examples/complete-job-result")) + ref = "#/components/examples/complete-ess-job-result")) }), @ApiResponse(responseCode = "400", description = "Return job failed.", content = { @Content(mediaType = APPLICATION_JSON_VALUE, diff --git a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/NotificationSummary.java b/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/NotificationSummary.java index 683e61ba1d..4c58c35ee8 100644 --- a/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/NotificationSummary.java +++ b/irs-ess/src/main/java/org/eclipse/tractusx/ess/service/NotificationSummary.java @@ -46,6 +46,12 @@ public NotificationSummary(final AsyncFetchedItems asyncFetchedItems, final Fetc super(asyncFetchedItems, bpnLookups); this.notifications = notificationItems; } + + public NotificationSummary(final AsyncFetchedItems asyncFetchedItems, final FetchedItems bpnLookups, + final Integer sentNotification, final Integer receivedNotification) { + super(asyncFetchedItems, bpnLookups); + this.notifications = new NotificationItems(sentNotification, receivedNotification); + } } /**