diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/ShareDTOs/InputSharingBusinessPartnerDTO.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/ShareDTOs/InputSharingBusinessPartnerDTO.java index f7f1142..d881157 100644 --- a/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/ShareDTOs/InputSharingBusinessPartnerDTO.java +++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/dto/ShareDTOs/InputSharingBusinessPartnerDTO.java @@ -38,7 +38,7 @@ public class InputSharingBusinessPartnerDTO implements Serializable { @Schema(example = "BPN-NUMBER") private String bpn; - @Schema(example = "Portugal") + @Schema(example = "PT") private String country; diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/RequestLogicService.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/RequestLogicService.java index d2db769..6453b42 100644 --- a/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/RequestLogicService.java +++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/RequestLogicService.java @@ -19,6 +19,8 @@ ********************************************************************************/ package org.eclipse.tractusx.valueaddedservice.service.logic; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.valueaddedservice.domain.enumeration.AddressType; import org.eclipse.tractusx.valueaddedservice.domain.enumeration.BusinessPartnerRole; @@ -69,13 +71,13 @@ public class RequestLogicService { @Cacheable(value = "vas-bpdm", key = "{#root.methodName , {#roles}}", unless = "#result == null") public List handleRequestsToBpdm(List roles) { - List finalDtoList = new ArrayList<>(); - if (sequentialRequestsEnabled) { - finalDtoList.addAll(handleSequentialRequests()); - } else { - finalDtoList.addAll(handleNonSequentialRequests()); - } - return finalDtoList; + List finalDtoList = getMockBusinessPartnerDTOs(); + //if (sequentialRequestsEnabled) { + // finalDtoList.addAll(handleSequentialRequests()); + // } else { + // finalDtoList.addAll(handleNonSequentialRequests()); + // } + return getMockBusinessPartnerDTOs(); } private List handleSequentialRequests() { @@ -202,6 +204,75 @@ public List getBpnsByAddressType(Map getMockBusinessPartnerDTOs() { + String json = "[\n" + + " {\n" + + " \"id\": 1,\n" + + " \"bpn\": \"BPN-0001\",\n" + + " \"legalName\": \"Divape Company\",\n" + + " \"street\": \"1st Avenue\",\n" + + " \"houseNumber\": \"100A\",\n" + + " \"zipCode\": \"633104\",\n" + + " \"city\": \"Covilhã\",\n" + + " \"country\": \"ES\",\n" + + " \"longitude\": \"107.6185727\",\n" + + " \"latitude\": \"-6.6889038\",\n" + + " \"supplier\": false,\n" + + " \"customer\": true\n" + + " },\n" + + " {\n" + + " \"id\": 2,\n" + + " \"bpn\": \"BPN-0002\",\n" + + " \"legalName\": \"Innovatech Solutions\",\n" + + " \"street\": \"Tech Park Rd\",\n" + + " \"houseNumber\": \"20B\",\n" + + " \"zipCode\": \"500010\",\n" + + " \"city\": \"Lisbon\",\n" + + " \"country\": \"DE\",\n" + + " \"longitude\": \"108.123456\",\n" + + " \"latitude\": \"-7.123456\",\n" + + " \"supplier\": true,\n" + + " \"customer\": false\n" + + " },\n" + + " {\n" + + " \"id\": 3,\n" + + " \"bpn\": \"BPN-0004\",\n" + + " \"legalName\": \"Innovatech Solutions Made Up\",\n" + + " \"street\": \"Tech Park Rd\",\n" + + " \"houseNumber\": \"20B\",\n" + + " \"zipCode\": \"500010\",\n" + + " \"city\": \"Paris\",\n" + + " \"country\": \"FR\",\n" + + " \"longitude\": \"108.123456\",\n" + + " \"latitude\": \"-7.123456\",\n" + + " \"supplier\": false,\n" + + " \"customer\": false\n" + + " },\n" + + " {\n" + + " \"id\": 3,\n" + + " \"bpn\": \"BPN-0003\",\n" + + " \"legalName\": \"Eco Friendly Packaging\",\n" + + " \"street\": \"Greenway Dr\",\n" + + " \"houseNumber\": \"5\",\n" + + " \"zipCode\": \"755004\",\n" + + " \"city\": \"Porto\",\n" + + " \"country\": \"PT\",\n" + + " \"longitude\": \"106.654321\",\n" + + " \"latitude\": \"-5.654321\",\n" + + " \"supplier\": true,\n" + + " \"customer\": true\n" + + " }\n" + + "]"; + + ObjectMapper objectMapper = new ObjectMapper(); + List businessPartnerDTOList = new ArrayList<>(); + try { + businessPartnerDTOList = objectMapper.readValue(json, new TypeReference>(){}); + } catch (Exception e) { + e.printStackTrace(); + } + return businessPartnerDTOList; + } diff --git a/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/ShareLogicService.java b/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/ShareLogicService.java index 9d7bfe3..6897c61 100644 --- a/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/ShareLogicService.java +++ b/src/main/java/org/eclipse/tractusx/valueaddedservice/service/logic/ShareLogicService.java @@ -96,7 +96,7 @@ private ShareDTO setShareDTO(InputSharingBusinessPartnerDTO bp, List da shareDTO.setBpn(bp.getBpn()); shareDTO.setCountry(bp.getCountry()); dataDTOS.forEach(dataDTO -> { - if(Objects.equals(dataDTO.getCountry(), bp.getCountry())){ + if(Objects.equals(dataDTO.getIso2(), bp.getCountry())){ ShareRatingDTO shareRatingDTO = new ShareRatingDTO(); shareRatingDTO.setDataSourceName(dataDTO.getDataSourceName()); shareRatingDTO.setScore(dataDTO.getScore());