From b83b2bdcfb28c4de431bf68c264dadbfed54aff2 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 25 May 2023 15:33:19 +0200 Subject: [PATCH] feat(api): #172 Rename BPN fields - rename controlles paths --- .../bridge/dummy/service/PoolUpdateService.kt | 2 +- .../tractusx/bpdm/pool/api/PoolAddressApi.kt | 12 ++++---- .../bpdm/pool/api/PoolLegalEntityApi.kt | 28 +++++++++---------- .../model/request/SitePartnerCreateRequest.kt | 2 +- .../saas/service/SaasToRequestMapper.kt | 8 +----- .../bpdm/pool/controller/AddressController.kt | 6 ++-- .../pool/controller/LegalEntityController.kt | 15 +++++----- .../service/BusinessPartnerBuildService.kt | 8 +++--- .../bpdm/pool/controller/SiteControllerIT.kt | 12 ++++---- .../tractusx/bpdm/pool/util/RequestValues.kt | 6 ++-- .../tractusx/bpdm/pool/util/TestHelpers.kt | 2 +- 11 files changed, 48 insertions(+), 53 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index 2daab39d4..c9241e1a9 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -71,7 +71,7 @@ class PoolUpdateService( SitePartnerCreateRequest( site = entry.site, index = entry.externalId, - bpnParent = leParentBpn + bpnlParent = leParentBpn ) } } diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt index 34eca8eba..94cf60416 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt @@ -66,20 +66,20 @@ interface PoolAddressApi { ): PageResponse @Operation( - summary = "Get address partners by bpn", + summary = "Get address partners by bpna", description = "Get business partners of type address by bpn-a ignoring case." ) @ApiResponses( value = [ - ApiResponse(responseCode = "200", description = "Found address with specified bpn"), + ApiResponse(responseCode = "200", description = "Found address with specified bpna"), ApiResponse(responseCode = "400", description = "On malformed request parameters", content = [Content()]), - ApiResponse(responseCode = "404", description = "No address found under specified bpn", content = [Content()]) + ApiResponse(responseCode = "404", description = "No address found under specified bpna", content = [Content()]) ] ) - @GetMapping("/{bpn}") - @GetExchange("/{bpn}") + @GetMapping("/{bpna}") + @GetExchange("/{bpna}") fun getAddress( - @Parameter(description = "Bpn value") @PathVariable bpn: String + @Parameter(description = "Bpn value") @PathVariable bpna: String ): LogisticAddressResponse @Operation( diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt index 7a42eb5a1..826b8bb17 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt @@ -95,19 +95,19 @@ interface PoolLegalEntityApi { @Operation( summary = "Confirms that the data of a legal entity business partner is still up to date.", description = "Confirms that the data of a business partner is still up to date " + - "by saving the current timestamp at the time this POST-request is made as this business partner's \"currentness\". Ignores case of bpn." + "by saving the current timestamp at the time this POST-request is made as this business partner's \"currentness\". Ignores case of bpnl." ) @ApiResponses( value = [ ApiResponse(responseCode = "200", description = "Business partner's \"currentness\" successfully updated"), ApiResponse(responseCode = "400", description = "On malformed request parameters", content = [Content()]), - ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) + ApiResponse(responseCode = "404", description = "No business partner found for specified bpnl", content = [Content()]) ] ) - @PostMapping("/{bpn}/confirm-up-to-date") - @PostExchange("/{bpn}/confirm-up-to-date") + @PostMapping("/{bpnl}/confirm-up-to-date") + @PostExchange("/{bpnl}/confirm-up-to-date") fun setLegalEntityCurrentness( - @Parameter(description = "Bpn value") @PathVariable bpn: String + @Parameter(description = "Bpnl value") @PathVariable bpnl: String ) @Operation( @@ -134,19 +134,19 @@ interface PoolLegalEntityApi { @Operation( summary = "Get site partners of a legal entity", - description = "Get business partners of type site belonging to a business partner of type legal entity, identified by the business partner's bpn ignoring case." + description = "Get business partners of type site belonging to a business partner of type legal entity, identified by the business partner's bpnl ignoring case." ) @ApiResponses( value = [ - ApiResponse(responseCode = "200", description = "The sites for the specified bpn"), + ApiResponse(responseCode = "200", description = "The sites for the specified bpnl"), ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), - ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) + ApiResponse(responseCode = "404", description = "No business partner found for specified bpnl", content = [Content()]) ] ) - @GetMapping("/{bpn}/sites") - @GetExchange("/{bpn}/sites") + @GetMapping("/{bpnl}/sites") + @GetExchange("/{bpnl}/sites") fun getSites( - @Parameter(description = "Bpn value") @PathVariable bpn: String, + @Parameter(description = "Bpnl value") @PathVariable bpnl: String, @ParameterObject paginationRequest: PaginationRequest ): PageResponse @@ -161,10 +161,10 @@ interface PoolLegalEntityApi { ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) ] ) - @GetMapping("/{bpn}/addresses") - @GetExchange("/{bpn}/addresses") + @GetMapping("/{bpnl}/addresses") + @GetExchange("/{bpnl}/addresses") fun getAddresses( - @Parameter(description = "Bpn value") @PathVariable bpn: String, + @Parameter(description = "Bpn value") @PathVariable bpnl: String, @ParameterObject paginationRequest: PaginationRequest ): PageResponse diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerCreateRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerCreateRequest.kt index bd7026f8f..015bcaacc 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerCreateRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerCreateRequest.kt @@ -32,7 +32,7 @@ data class SitePartnerCreateRequest( val site: SiteDto, @Schema(description = "Business Partner Number of the legal entity this site belongs to") - val bpnParent: String, + val bpnlParent: String, @Schema(description = "User defined index to conveniently match this entry to the corresponding entry in the response") val index: String? diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/SaasToRequestMapper.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/SaasToRequestMapper.kt index 63b4ead2b..1afff54d8 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/SaasToRequestMapper.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/SaasToRequestMapper.kt @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.pool.component.saas.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.IdentifierLsaType import org.eclipse.tractusx.bpdm.common.dto.IdentifierTypeDto -import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.dto.saas.LegalFormSaas import org.eclipse.tractusx.bpdm.common.dto.saas.TypeKeyNameUrlSaas @@ -74,7 +73,7 @@ class SaasToRequestMapper { fun toSiteCreateRequest(partnerWithParent: BusinessPartnerWithParentBpn): SitePartnerCreateRequest { return SitePartnerCreateRequest( site = partnerWithParent.partner.toSiteDto(), - bpnParent = partnerWithParent.parentBpn, + bpnlParent = partnerWithParent.parentBpn, index = partnerWithParent.partner.externalId ) } @@ -138,11 +137,6 @@ class SaasToRequestMapper { } } - - fun toRequest(idType: TypeKeyNameUrlSaas): TypeKeyNameDto { - return TypeKeyNameDto(idType.technicalKey!!, idType.name ?: "") - } - fun toRequest(legalForm: LegalFormSaas, partner: BusinessPartnerSaas): LegalFormRequest { return LegalFormRequest( technicalKey = legalForm.technicalKey!!, diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt index 3b0304eec..759cef975 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt @@ -52,9 +52,9 @@ class AddressController( } override fun getAddress( - bpn: String + bpna: String ): LogisticAddressResponse { - return addressService.findByBpn(bpn.uppercase()) + return addressService.findByBpn(bpna.uppercase()) } override fun searchAddresses( @@ -68,7 +68,7 @@ class AddressController( override fun createAddresses( requests: Collection - ): AddressPartnerCreateResponseWrapper { + ): AddressPartnerCreateResponseWrapper { return businessPartnerBuildService.createAddresses(requests) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt index a719f2572..d45367950 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt @@ -72,8 +72,8 @@ class LegalEntityController( } - override fun setLegalEntityCurrentness(bpn: String) { - businessPartnerBuildService.setBusinessPartnerCurrentness(bpn.uppercase()) + override fun setLegalEntityCurrentness(bpnl: String) { + businessPartnerBuildService.setBusinessPartnerCurrentness(bpnl.uppercase()) } override fun searchSites( @@ -86,18 +86,18 @@ class LegalEntityController( } override fun getSites( - bpn: String, + bpnl: String, paginationRequest: PaginationRequest ): PageResponse { - return siteService.findByPartnerBpn(bpn.uppercase(), paginationRequest.page, paginationRequest.size) + return siteService.findByPartnerBpn(bpnl.uppercase(), paginationRequest.page, paginationRequest.size) } override fun getAddresses( - bpn: String, + bpnl: String, paginationRequest: PaginationRequest ): PageResponse { - return addressService.findByPartnerBpn(bpn.uppercase(), paginationRequest.page, paginationRequest.size) + return addressService.findByPartnerBpn(bpnl.uppercase(), paginationRequest.page, paginationRequest.size) } @@ -114,7 +114,8 @@ class LegalEntityController( return businessPartnerBuildService.createLegalEntities(businessPartners) } - override fun updateBusinessPartners(businessPartners: Collection + override fun updateBusinessPartners( + businessPartners: Collection ): LegalEntityPartnerUpdateResponseWrapper { return businessPartnerBuildService.updateLegalEntities(businessPartners) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index e79abebab..9e9745ee8 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -95,12 +95,12 @@ class BusinessPartnerBuildService( fun createSites(requests: Collection): SitePartnerCreateResponseWrapper { logger.info { "Create ${requests.size} new sites" } - val legalEntities = legalEntityRepository.findDistinctByBpnIn(requests.map { it.bpnParent }) + val legalEntities = legalEntityRepository.findDistinctByBpnIn(requests.map { it.bpnlParent }) val legalEntityMap = legalEntities.associateBy { it.bpn } - val (validRequests, invalidRequests) = requests.partition { legalEntityMap[it.bpnParent] != null } + val (validRequests, invalidRequests) = requests.partition { legalEntityMap[it.bpnlParent] != null } val errors = invalidRequests.map { - ErrorInfo(SiteCreateError.LegalEntityNotFound, "Site not created: parent legal entity ${it.bpnParent} not found", it.index) + ErrorInfo(SiteCreateError.LegalEntityNotFound, "Site not created: parent legal entity ${it.bpnlParent} not found", it.index) } val addressMetadataMap = metadataMappingService.mapRequests(validRequests.map { it.site.mainAddress }) @@ -110,7 +110,7 @@ class BusinessPartnerBuildService( val siteWithIndexByBpnMap = validRequests .mapIndexed { i, request -> - val legalEntity = legalEntityMap[request.bpnParent]!! + val legalEntity = legalEntityMap[request.bpnlParent]!! val site = createSite(request.site, bpnSs[i], legalEntity) site.mainAddress = createLogisticAddress(request.site.mainAddress, bpnAs[i], site, addressMetadataMap) Pair(site, request.index) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt index 1942544b2..3a5fffdf3 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt @@ -170,9 +170,9 @@ class SiteControllerIT @Autowired constructor( val expected = listOf(ResponseValues.siteUpsert1, ResponseValues.siteUpsert2, ResponseValues.siteUpsert3) val toCreate = listOf( - RequestValues.siteCreate1.copy(bpnParent = bpnL1), - RequestValues.siteCreate2.copy(bpnParent = bpnL2), - RequestValues.siteCreate3.copy(bpnParent = bpnL2) + RequestValues.siteCreate1.copy(bpnlParent = bpnL1), + RequestValues.siteCreate2.copy(bpnlParent = bpnL2), + RequestValues.siteCreate3.copy(bpnlParent = bpnL2) ) val response = poolClient.sites().createSite(toCreate) @@ -200,9 +200,9 @@ class SiteControllerIT @Autowired constructor( val expected = listOf(ResponseValues.siteUpsert1, ResponseValues.siteUpsert2) val toCreate = listOf( - RequestValues.siteCreate1.copy(bpnParent = bpnL1), - RequestValues.siteCreate2.copy(bpnParent = bpnL2), - RequestValues.siteCreate3.copy(bpnParent = "NONEXISTENT") + RequestValues.siteCreate1.copy(bpnlParent = bpnL1), + RequestValues.siteCreate2.copy(bpnlParent = bpnL2), + RequestValues.siteCreate3.copy(bpnlParent = "NONEXISTENT") ) val response = poolClient.sites().createSite(toCreate) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt index a0d2e8f0b..605574f83 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt @@ -219,7 +219,7 @@ object RequestValues { mainAddress = logisticAddress1 ), index = CommonValues.index1, - bpnParent = legalEntityUpdate1.bpnl + bpnlParent = legalEntityUpdate1.bpnl ) val siteCreate2 = SitePartnerCreateRequest( @@ -229,7 +229,7 @@ object RequestValues { mainAddress = logisticAddress2 ), index = CommonValues.index2, - bpnParent = legalEntityUpdate2.bpnl + bpnlParent = legalEntityUpdate2.bpnl ) val siteCreate3 = SitePartnerCreateRequest( @@ -239,7 +239,7 @@ object RequestValues { mainAddress = logisticAddress3 ), index = CommonValues.index3, - bpnParent = legalEntityUpdate3.bpnl + bpnlParent = legalEntityUpdate3.bpnl ) val siteUpdate1 = SitePartnerUpdateRequest( diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt index a25065158..d20ac1f90 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt @@ -109,7 +109,7 @@ class TestHelpers( val assignedSiteRequests = partnerStructures.flatMap { it.siteStructures.map { site -> - site.site.copy(bpnParent = indexedLegalEntities[it.legalEntity.index]!!.legalEntity.bpnl) + site.site.copy(bpnlParent = indexedLegalEntities[it.legalEntity.index]!!.legalEntity.bpnl) } } val sitesWithErrorsResponse = poolClient.sites().createSite(assignedSiteRequests)