From 47b85a20b599afdc5632737943393da64541bb51 Mon Sep 17 00:00:00 2001 From: ChetanT-System Date: Tue, 29 Aug 2023 12:30:25 +0530 Subject: [PATCH 1/2] - Feign Client changes updated for child aspect relationship --- .../facilitator/DigitalTwinsFacilitator.java | 11 ++++++----- .../gateways/external/DigitalTwinsFeignClient.java | 2 +- ...gitalTwinsAspectRelationShipCsvHandlerUseCase.java | 5 ++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/facilitator/DigitalTwinsFacilitator.java b/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/facilitator/DigitalTwinsFacilitator.java index 1c239f74f..d1c709b89 100644 --- a/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/facilitator/DigitalTwinsFacilitator.java +++ b/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/facilitator/DigitalTwinsFacilitator.java @@ -25,6 +25,7 @@ import java.util.Base64; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.eclipse.tractusx.sde.common.exception.ServiceException; import org.eclipse.tractusx.sde.digitaltwins.entities.request.CreateSubModelRequest; import org.eclipse.tractusx.sde.digitaltwins.entities.request.ShellDescriptorRequest; @@ -66,7 +67,7 @@ public List shellLookup(ShellLookupRequest request) throws ServiceExcept public List shellLookupFromDDTR(ShellLookupRequest request, String ddtrUrl, String edcBPN) throws ServiceException { - URI dtURL = (ddtrUrl == null || ddtrUrl.length() <= 0) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl); + URI dtURL = StringUtils.isAllEmpty(ddtrUrl) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl); List shellIds = List.of(); @@ -110,17 +111,17 @@ public List getShellDescriptorsWithSubmodelDetails(List List items = new ArrayList<>(); for (String shellId : shellIds) { - items.add(getShellDetailsById(shellId, ddtrUrl)); + items.add(getShellDetailsById(shellId, ddtrUrl, manufacturerId)); } return items; } - public ShellDescriptorResponse getShellDetailsById(String shellId, String ddtrUrl) { + public ShellDescriptorResponse getShellDetailsById(String shellId, String ddtrUrl, String edcBPN) { - URI dtURL = (ddtrUrl == null || ddtrUrl.length() <= 0) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl); + URI dtURL = StringUtils.isAllEmpty(ddtrUrl) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl); ResponseEntity shellDescriptorResponse = digitalTwinsFeignClient - .getShellDescriptorByShellId(dtURL, encodeShellIdBase64Utf8(shellId)); + .getShellDescriptorByShellId(dtURL, encodeShellIdBase64Utf8(shellId), edcBPN); return shellDescriptorResponse.getBody(); } diff --git a/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/gateways/external/DigitalTwinsFeignClient.java b/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/gateways/external/DigitalTwinsFeignClient.java index 03891020c..d7dbfadfb 100644 --- a/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/gateways/external/DigitalTwinsFeignClient.java +++ b/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/gateways/external/DigitalTwinsFeignClient.java @@ -52,7 +52,7 @@ public interface DigitalTwinsFeignClient { @GetMapping(path = "/shell-descriptors/{aasIdentifier}") ResponseEntity getShellDescriptorByShellId(URI url, - @PathVariable("aasIdentifier") String shellId); + @PathVariable("aasIdentifier") String shellId, @RequestHeader("Edc-Bpn") String edcBpn); @DeleteMapping(path = "/shell-descriptors/{aasIdentifier}") ResponseEntity deleteShell(URI url, @PathVariable("assetIds") String shellId); diff --git a/modules/sde-submodules/assembly-part-relationship/src/main/java/org/eclipse/tractusx/sde/submodels/apr/steps/DigitalTwinsAspectRelationShipCsvHandlerUseCase.java b/modules/sde-submodules/assembly-part-relationship/src/main/java/org/eclipse/tractusx/sde/submodels/apr/steps/DigitalTwinsAspectRelationShipCsvHandlerUseCase.java index fefd63157..cc5213c3c 100644 --- a/modules/sde-submodules/assembly-part-relationship/src/main/java/org/eclipse/tractusx/sde/submodels/apr/steps/DigitalTwinsAspectRelationShipCsvHandlerUseCase.java +++ b/modules/sde-submodules/assembly-part-relationship/src/main/java/org/eclipse/tractusx/sde/submodels/apr/steps/DigitalTwinsAspectRelationShipCsvHandlerUseCase.java @@ -209,8 +209,11 @@ private CreateSubModelRequest getCreateSubModelRequest(AspectRelationship aspect if (childshellIds.size() == 1) { ShellDescriptorResponse shellDescriptorResponse = digitalTwinfacilitaor - .getShellDetailsById(childshellIds.get(0), ddtUrl); + .getShellDetailsById(childshellIds.get(0), ddtUrl, aspectRelationShip.getChildManufacturerId()); childUUID = shellDescriptorResponse.getGlobalAssetId(); + log.debug(aspectRelationShip.getRowNumber() + ", " + ddtUrl + ", Child aspect found for " + + shellLookupRequest.toJsonString()); + break; } } From 545bb8fa3e424bf8e68cc7132d1c3b814d3f859f Mon Sep 17 00:00:00 2001 From: ChetanT-System Date: Tue, 29 Aug 2023 12:54:48 +0530 Subject: [PATCH 2/2] - changes for bpn String --- .../digitaltwins/facilitator/DigitalTwinsFacilitator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/facilitator/DigitalTwinsFacilitator.java b/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/facilitator/DigitalTwinsFacilitator.java index d1c709b89..c8594e00e 100644 --- a/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/facilitator/DigitalTwinsFacilitator.java +++ b/modules/sde-external-services/digital-twins/src/main/java/org/eclipse/tractusx/sde/digitaltwins/facilitator/DigitalTwinsFacilitator.java @@ -64,7 +64,7 @@ public List shellLookup(ShellLookupRequest request) throws ServiceExcept } @SneakyThrows - public List shellLookupFromDDTR(ShellLookupRequest request, String ddtrUrl, String edcBPN) + public List shellLookupFromDDTR(ShellLookupRequest request, String ddtrUrl, String edcBpn) throws ServiceException { URI dtURL = StringUtils.isAllEmpty(ddtrUrl) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl); @@ -73,7 +73,7 @@ public List shellLookupFromDDTR(ShellLookupRequest request, String ddtrU try { ResponseEntity response = digitalTwinsFeignClient.shellLookup(dtURL, - request.toJsonString(), edcBPN); + request.toJsonString(), edcBpn); ShellLookupResponse body = response.getBody(); if (response.getStatusCode() == HttpStatus.OK && body != null) { @@ -116,12 +116,12 @@ public List getShellDescriptorsWithSubmodelDetails(List return items; } - public ShellDescriptorResponse getShellDetailsById(String shellId, String ddtrUrl, String edcBPN) { + public ShellDescriptorResponse getShellDetailsById(String shellId, String ddtrUrl, String edcBpn) { URI dtURL = StringUtils.isAllEmpty(ddtrUrl) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl); ResponseEntity shellDescriptorResponse = digitalTwinsFeignClient - .getShellDescriptorByShellId(dtURL, encodeShellIdBase64Utf8(shellId), edcBPN); + .getShellDescriptorByShellId(dtURL, encodeShellIdBase64Utf8(shellId), edcBpn); return shellDescriptorResponse.getBody(); }