Skip to content

Commit

Permalink
release(CountryRisk): Release negotiation page for env
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiodmota committed Apr 22, 2024
1 parent 316fc26 commit f8c258d
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 139 deletions.
9 changes: 8 additions & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<org.projectlombok.version>1.18.28</org.projectlombok.version>
<liquibase.version>4.26.0</liquibase.version>
<liquibase-hibernate5.version>4.25.1</liquibase-hibernate5.version>
<spring-boot.version>3.2.3</spring-boot.version>
<spring-boot.version>3.2.5</spring-boot.version>
<org.zalando.problem-spring-web>0.26.0</org.zalando.problem-spring-web>
<org.springdoc.springdoc-openapi-ui>2.1.0</org.springdoc.springdoc-openapi-ui>
<org.springframework.cloud>4.1.1</org.springframework.cloud>
Expand Down Expand Up @@ -93,6 +93,13 @@
<version>${org.owasp.antisamy}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>6.1.6</version>
</dependency>


</dependencies>

</dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
********************************************************************************/
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;
Expand Down Expand Up @@ -71,17 +69,15 @@ public class RequestLogicService {

@Cacheable(value = "vas-bpdm", key = "{#root.methodName , {#roles}}", unless = "#result == null")
public List<BusinessPartnerDTO> handleRequestsToBpdm(List<String> roles) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'roles' is never used.
List<BusinessPartnerDTO> finalDtoList = getMockBusinessPartnerDTOs();
//if (sequentialRequestsEnabled) {
// finalDtoList.addAll(handleSequentialRequests());
// } else {
// finalDtoList.addAll(handleNonSequentialRequests());
// }
return getMockBusinessPartnerDTOs();
List<BusinessPartnerDTO> finalDtoList = new ArrayList<>();
if (sequentialRequestsEnabled) {
finalDtoList.addAll(handleSequentialRequests());
} else {
finalDtoList.addAll(handleNonSequentialRequests());
}
return finalDtoList;
}



private List<BusinessPartnerDTO> handleSequentialRequests() {
List<BusinessPartnerDTO> finalDtoList = new ArrayList<>();

Expand Down Expand Up @@ -136,22 +132,24 @@ private List<BusinessPartnerDTO> handleNonSequentialRequests() {

log.info("Starting process to fetch external business partners from legal entity on pool.");
List<String> bpnlList = getBpnsByAddressType(map, AddressType.LegalAddress);
httpEntity = createHttpEntity(bpnlList);
Map<String, List<String>> legalEntityBody = new HashMap<>();
legalEntityBody.put("bpnLs", bpnlList);
httpEntity = createHttpEntity(legalEntityBody);
List<PoolLegalEntityDto> poolLegalEntityDtos = invokeService.executeRequest("pool", bpdmLegalUrl, HttpMethod.POST, httpEntity, JsonMappingUtils::mapToListOfPoolLegalEntityDto).block();
log.info("Processed business partners from legal entity on pool, list size {}", poolLegalEntityDtos.size());

log.info("Starting process to fetch external business partners from site on pool.");
List<String> bpnsList = getBpnsByAddressType(map, AddressType.SiteMainAddress);
Map<String, List<String>> sitesBody = new HashMap<>();
sitesBody.put("sites", bpnsList);
sitesBody.put("siteBpns", bpnsList);
httpEntity = createHttpEntity(sitesBody);
List<PoolSiteDto> poolSiteDtos = invokeService.executeRequest("pool", bpdmSiteUrl, HttpMethod.POST, httpEntity, JsonMappingUtils::mapJsonToListOfPoolSiteDto).block();
log.info("Processed business partners from site on pool, list size {}", poolSiteDtos.size());

log.info("Starting process to fetch external business partners from address on pool.");
List<String> bpnaList = getBpnsByAddressType(map, AddressType.AdditionalAddress);
Map<String, List<String>> addressesBody = new HashMap<>();
addressesBody.put("addresses", bpnaList);
addressesBody.put("addressBpns", bpnaList);
httpEntity = createHttpEntity(addressesBody);

List<PoolAddressDto> poolAddressDtos = invokeService.executeRequest("pool", bpdmAddressUrl, HttpMethod.POST, httpEntity, JsonMappingUtils::mapJsonToListOfPoolAddressDto).block();
Expand Down Expand Up @@ -203,75 +201,6 @@ public List<String> getBpnsByAddressType(Map<AddressType, Map<String, Collection
}


public List<BusinessPartnerDTO> 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<BusinessPartnerDTO> businessPartnerDTOList = new ArrayList<>();
try {
businessPartnerDTOList = objectMapper.readValue(json, new TypeReference<List<BusinessPartnerDTO>>(){});
} catch (Exception e) {
e.printStackTrace();
}
return businessPartnerDTOList;
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ public static List<GateBusinessPartnerOutputDto> mapContentToListOfBusinessPartn
}
}
public static List<PoolLegalEntityDto> mapToListOfPoolLegalEntityDto(String jsonResponse) {

try {
return objectMapper.readValue(jsonResponse, new TypeReference<>() {
});
JsonNode rootNode = objectMapper.readTree(jsonResponse);
JsonNode contentNode = rootNode.path("content");
return objectMapper.readValue(contentNode.toString(), new TypeReference<List<PoolLegalEntityDto>>() {});
} catch (Exception e) {
throw new RuntimeException("Error mapping JSON to List<PoolLegalEntityDto>", e);
}
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -191,62 +191,93 @@ public static void mocKConnectionToBpdmGateLegalEntity(WireMockServer mockServer
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", APPLICATION_JSON_VALUE)
.withBody("[\n" +
.withBody("{\n" +
" \"totalElements\": 1,\n" +
" \"totalPages\": 1,\n" +
" \"page\": 1,\n" +
" \"contentSize\": 1,\n" +
" \"content\": [\n" +
" {\n" +
" \"legalName\": \"Showcase Business Partner Address\",\n" +
" \"bpnl\": \"BPNL00000007QZG8\",\n" +
" \"identifiers\": [],\n" +
" \"legalShortName\": null,\n" +
" \"legalForm\": null,\n" +
" \"bpnl\": \"BPNL00000007QZG8\",\n" +
" \"legalName\": \"Showcase Business Partner Address\",\n" +
" \"legalShortName\": null,\n" +
" \"legalForm\": {\n" +
" \"technicalKey\": \"UNKNOWN\",\n" +
" \"name\": null,\n" +
" \"abbreviation\": null\n" +
" },\n" +
" \"identifiers\": [],\n" +
" \"states\": [],\n" +
" \"relations\": [],\n" +
" \"currentness\": \"2023-11-29T10:59:00.034673Z\",\n" +
" \"confidenceCriteria\": {\n" +
" \"sharedByOwner\": true,\n" +
" \"checkedByExternalDataSource\": false,\n" +
" \"numberOfSharingMembers\": 0,\n" +
" \"lastConfidenceCheckAt\": \"2023-11-29T10:59:00.034673Z\",\n" +
" \"nextConfidenceCheckAt\": \"2024-11-29T10:59:00.034673Z\",\n" +
" \"confidenceLevel\": 1\n" +
" },\n" +
" \"isCatenaXMemberData\": true,\n" +
" \"createdAt\": \"2023-11-29T10:59:00.047537Z\",\n" +
" \"updatedAt\": \"2023-11-29T10:59:00.047543Z\",\n" +
" \"legalAddress\": {\n" +
" \"bpna\": \"BPNA000000007BT8\",\n" +
" \"name\": \"Showcase Business Partner Address\",\n" +
" \"states\": [],\n" +
" \"classifications\": [],\n" +
" \"relations\": [],\n" +
" \"currentness\": \"2023-11-29T10:59:00.034673Z\",\n" +
" \"createdAt\": \"2023-11-29T10:59:00.047537Z\",\n" +
" \"updatedAt\": \"2023-11-29T10:59:00.047543Z\",\n" +
" \"legalAddress\": {\n" +
" \"bpna\": \"BPNA000000007BT8\",\n" +
" \"name\": \"Showcase Business Partner Address\",\n" +
" \"states\": [],\n" +
" \"identifiers\": [],\n" +
" \"physicalPostalAddress\": {\n" +
" \"geographicCoordinates\": null,\n" +
" \"country\": {\n" +
" \"technicalKey\": \"DE\",\n" +
" \"name\": \"Germany\"\n" +
" },\n" +
" \"administrativeAreaLevel1\": {\n" +
" \"countryCode\": \"DE\",\n" +
" \"regionCode\": \"DE-BW\",\n" +
" \"regionName\": \"Baden-Wurttemberg\"\n" +
" },\n" +
" \"administrativeAreaLevel2\": null,\n" +
" \"administrativeAreaLevel3\": null,\n" +
" \"postalCode\": \"77777\",\n" +
" \"city\": \"City X\",\n" +
" \"district\": \"\",\n" +
" \"street\": {\n" +
" \"name\": \"Base Street\",\n" +
" \"houseNumber\": \"3\",\n" +
" \"milestone\": \"\",\n" +
" \"direction\": \"\"\n" +
" },\n" +
" \"companyPostalCode\": null,\n" +
" \"industrialZone\": null,\n" +
" \"building\": null,\n" +
" \"floor\": null,\n" +
" \"door\": null\n" +
" },\n" +
" \"alternativePostalAddress\": null,\n" +
" \"bpnLegalEntity\": \"BPNL00000007QZG8\",\n" +
" \"isLegalAddress\": true,\n" +
" \"bpnSite\": null,\n" +
" \"isMainAddress\": false,\n" +
" \"createdAt\": \"2023-11-29T10:59:00.045497Z\",\n" +
" \"updatedAt\": \"2023-11-29T10:59:00.059879Z\"\n" +
" }\n" +
" \"identifiers\": [],\n" +
" \"physicalPostalAddress\": {\n" +
" \"geographicCoordinates\": null,\n" +
" \"country\": {\n" +
" \"technicalKey\": \"DE\",\n" +
" \"name\": \"Germany\"\n" +
" },\n" +
" \"administrativeAreaLevel1\": {\n" +
" \"countryCode\": \"DE\",\n" +
" \"regionCode\": \"DE-BW\",\n" +
" \"regionName\": \"Baden-Wurttemberg\"\n" +
" },\n" +
" \"administrativeAreaLevel2\": null,\n" +
" \"administrativeAreaLevel3\": null,\n" +
" \"postalCode\": \"77777\",\n" +
" \"city\": \"City X\",\n" +
" \"district\": \"\",\n" +
" \"street\": {\n" +
" \"name\": \"Base Street\",\n" +
" \"houseNumber\": \"3\",\n" +
" \"houseNumberSupplement\": null,\n" +
" \"milestone\": \"\",\n" +
" \"direction\": \"\",\n" +
" \"namePrefix\": null,\n" +
" \"additionalNamePrefix\": null,\n" +
" \"nameSuffix\": null,\n" +
" \"additionalNameSuffix\": null\n" +
" },\n" +
" \"companyPostalCode\": null,\n" +
" \"industrialZone\": null,\n" +
" \"building\": null,\n" +
" \"floor\": null,\n" +
" \"door\": null\n" +
" },\n" +
" \"alternativePostalAddress\": null,\n" +
" \"bpnLegalEntity\": \"BPNL00000007QZG8\",\n" +
" \"bpnSite\": null,\n" +
" \"isCatenaXMemberData\": true,\n" +
" \"createdAt\": \"2023-11-29T10:59:00.045497Z\",\n" +
" \"updatedAt\": \"2023-11-29T10:59:00.059879Z\",\n" +
" \"confidenceCriteria\": {\n" +
" \"sharedByOwner\": true,\n" +
" \"checkedByExternalDataSource\": false,\n" +
" \"numberOfSharingMembers\": 0,\n" +
" \"lastConfidenceCheckAt\": \"2023-11-29T10:59:00.045497Z\",\n" +
" \"nextConfidenceCheckAt\": \"2024-11-29T10:59:00.045497Z\",\n" +
" \"confidenceLevel\": 1\n" +
" },\n" +
" \"addressType\": \"LegalAndSiteMainAddress\"\n" +
" }\n" +
" }\n" +
"]")));
" ]\n" +
"}\n")));
}


Expand Down

0 comments on commit f8c258d

Please sign in to comment.