From 9e0847b82fbedb0e1256a174f412b953535c9a0a Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 15:14:59 +0200 Subject: [PATCH] feat(Gate): replace name with name parts collection in site DTO --- .../org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt | 4 ++-- .../eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt | 6 +++--- .../tractusx/bpdm/gate/service/SaasRequestMappingService.kt | 2 +- .../tractusx/bpdm/gate/service/SitePersistenceService.kt | 4 ++-- .../org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt index 923c06e23..bf13404b8 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt @@ -25,8 +25,8 @@ import org.eclipse.tractusx.bpdm.common.dto.SiteStateDto @Schema(name = "Site", description = "Site record") data class SiteGateDto( - @get:Schema(description = "Site name") - val name: String, + @get:Schema(description = "Parts that make up the name of that site") + val nameParts: Collection = emptyList(), @ArraySchema(arraySchema = Schema(description = "Business status")) val states: Collection = emptyList(), diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 0ef169973..612bb1511 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -138,7 +138,7 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputIn ) val site = Site( - name = site.name, + name = site.nameParts.firstOrNull()?: "", externalId = externalId, legalEntity = legalEntity, dataType = datatype @@ -160,7 +160,7 @@ fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputI val site = Site( bpn = bpn, - name = site.name, + name = site.nameParts.firstOrNull()?: "", externalId = externalId, legalEntity = legalEntity, dataType = datatype @@ -399,7 +399,7 @@ fun LegalEntity.LegalEntityGateInputResponse(legalEntity: LegalEntity): LegalEnt fun Site.toSiteDto(): SiteGateDto { return SiteGateDto( - name = name, + nameParts = if(name.isEmpty()) emptyList() else listOf(name), states = mapToDtoSitesStates(states), mainAddress = mainAddress.toLogisticAddressDto() ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt index 4ec11ebc4..0f7e00275 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt @@ -58,7 +58,7 @@ class SaasRequestMappingService( dataSource = saasConfigProperties.datasource, types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.ORGANIZATIONAL_UNIT.name)), identifiers = toIdentifiersSaas(""), - names = toNamesSaas(site.name), + names = toNamesSaas(site.nameParts.firstOrNull()), status = site.states.map { it.toSaasModel() }.firstOrNull(), // TODO Known issue: Name, state, BPN-A and identifiers of the main address are not transferred to SaaS yet!! addresses = toAddressesSaasModel(site.mainAddress) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 24ac1b644..9cb3895c6 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -77,7 +77,7 @@ class SitePersistenceService( private fun updateSite(site: Site, updatedSite: SiteGateInputRequest, legalEntityRecord: LegalEntity) { - site.name = updatedSite.site.name + site.name = updatedSite.site.nameParts.firstOrNull() ?: "" site.externalId = updatedSite.externalId site.legalEntity = legalEntityRecord site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) @@ -138,7 +138,7 @@ class SitePersistenceService( private fun updateSiteOutput(site: Site, updatedSite: SiteGateOutputRequest, legalEntityRecord: LegalEntity) { site.bpn = updatedSite.bpn - site.name = updatedSite.site.name + site.name = updatedSite.site.nameParts.firstOrNull() ?: "" site.externalId = updatedSite.externalId site.legalEntity = legalEntityRecord site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index d7d4dcb9b..2c5fb5d1d 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -287,13 +287,13 @@ object RequestValues { ) val site1 = SiteGateDto( - name = CommonValues.nameSite1, + nameParts = listOf(CommonValues.nameSite1), states = listOf(siteBusinessStatus1), mainAddress = address1 ) val site2 = SiteGateDto( - name = CommonValues.nameSite2, + nameParts = listOf(CommonValues.nameSite2), states = listOf(siteBusinessStatus2), mainAddress = address2 )