diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PhysicalPostalAddressResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PhysicalPostalAddressResponse.kt index 05eca6e50..4e3a743a8 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PhysicalPostalAddressResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PhysicalPostalAddressResponse.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.common.dto.response import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto import org.eclipse.tractusx.bpdm.common.dto.StreetDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @@ -38,18 +39,6 @@ data class PhysicalPostalAddressResponse( @field:JsonUnwrapped val areaPart: AreaDistrictResponse, - @get:Schema(description = "A separate postal code for a company, also known as postcode, PIN or ZIP Code") - val companyPostalCode: String? = null, - - @get:Schema(description = "The practice of designating an area for industrial development") - val industrialZone: String? = null, - - @get:Schema(description = "Describes a specific building within the address") - val building: String? = null, - - @get:Schema(description = "Describes the floor/level the delivery shall take place") - val floor: String? = null, - - @get:Schema(description = "Describes the door/room/suite on the respective floor the delivery shall take place") - val door: String? = null, + @field:JsonUnwrapped + val basePhysicalAddress: BasePhysicalAddressDto ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt index 065a8ceef..b4214dba6 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt @@ -22,8 +22,8 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema( @@ -32,7 +32,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ ) data class AddressGateOutput( @field:JsonUnwrapped - val address: LogisticAddressResponse, + val address: LogisticAddressGateResponse, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt index 3fcd86c33..fcf1db486 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt @@ -24,8 +24,8 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema(name = "LegalEntityGateOutput", description = "Legal entity with references") @@ -37,7 +37,7 @@ data class LegalEntityGateOutput( val legalEntity: LegalEntityResponse, @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressResponse, + val legalAddress: LogisticAddressGateResponse, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt index 1926e3ed1..8d78e88d5 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt @@ -26,7 +26,7 @@ import org.eclipse.tractusx.bpdm.common.dto.AddressStateDto import org.eclipse.tractusx.bpdm.common.dto.AlternativePostalAddressDto -@Schema(name = "LogisticAddressDto", description = "Address record for a business partner") +@Schema(name = "LogisticAddressGateDto", description = "Address record for a business partner") data class LogisticAddressGateDto( @get:Schema( description = "Name of the logistic address of the business partner. This is not according to official\n" + diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt index 58e27b883..44946f3ce 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt @@ -28,7 +28,7 @@ import org.eclipse.tractusx.bpdm.common.dto.BasePostalAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "PhysicalPostalAddress", description = "Physical Postal Address Part") +@Schema(name = "PhysicalPostalAddressGateDto", description = "Physical Postal Address Part") data class PhysicalPostalAddressGateDto( @field:JsonUnwrapped diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt index fc91a87f2..581248acb 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt @@ -22,9 +22,9 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema(name = "SiteGateOutput", description = "Site with legal entity reference.") @@ -33,7 +33,7 @@ data class SiteGateOutput( val site: SiteResponse, @Schema(description = "Main address where this site resides") - val mainAddress: LogisticAddressResponse, + val mainAddress: LogisticAddressGateResponse, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt index 59358cf28..6e4dc4b35 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model import io.swagger.v3.oas.annotations.media.Schema -@Schema(name = "Street", description = "A public road in a city, town, or village, typically with houses and buildings on one or both sides.") +@Schema(name = "StreetGate", description = "A public road in a city, town, or village, typically with houses and buildings on one or both sides.") data class StreetGateDto( diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/LogisticAddressGateResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/LogisticAddressGateResponse.kt new file mode 100644 index 000000000..0056f4e0c --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/LogisticAddressGateResponse.kt @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.api.model.response + +import io.swagger.v3.oas.annotations.media.ArraySchema +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.response.AddressIdentifierResponse +import org.eclipse.tractusx.bpdm.common.dto.response.AddressStateResponse +import org.eclipse.tractusx.bpdm.common.dto.response.AlternativePostalAddressResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PhysicalPostalAddressResponse +import java.time.Instant + + +@Schema(name = "LogisticAddressGateResponse", description = "Logistic address ") +data class LogisticAddressGateResponse( + + @get:Schema(description = "Business Partner Number of this address") + val bpna: String, + + @get:Schema( + description = "Name of the logistic address of the business partner. This is not according to official\n" + + "registers but according to the name the uploading sharing member chooses." + ) + val name: String? = null, + + @ArraySchema(arraySchema = Schema(description = "Address status")) + val states: Collection = emptyList(), + + @ArraySchema(arraySchema = Schema(description = "All identifiers of the Address")) + val identifiers: Collection = emptyList(), + + @get:Schema(description = "Physical postal address") + val physicalPostalAddress: PhysicalPostalAddressResponse, + + @get:Schema(description = "Alternative postal address") + val alternativePostalAddress: AlternativePostalAddressResponse? = null, + + @get:Schema(description = "BPN of the related legal entity, if available") + val bpnLegalEntity: String?, + + @get:Schema(name = "isLegalAddress", description = "Flag if this is the legal address of its related legal entity") + val isLegalAddress: Boolean = false, + + @get:Schema(description = "BPN of the related site, if available") + val bpnSite: String?, + + @get:Schema(name = "isMainAddress", description = "Flag if this is the main address of its related site") + val isMainAddress: Boolean = false, + + @get:Schema(description = "The timestamp the business partner data was created") + val createdAt: Instant, + + @get:Schema(description = "The timestamp the business partner data was last updated") + val updatedAt: Instant +) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PhysicalPostalAddressGateResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PhysicalPostalAddressGateResponse.kt new file mode 100644 index 000000000..bca849ccf --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PhysicalPostalAddressGateResponse.kt @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.api.model.response + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto +import org.eclipse.tractusx.bpdm.common.dto.response.AreaDistrictResponse +import org.eclipse.tractusx.bpdm.common.dto.response.BasePostalAddressResponse +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import org.eclipse.tractusx.bpdm.gate.api.model.StreetGateDto + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema(name = "PhysicalPostalGateAddress", description = "Physical Postal Address Part") +data class PhysicalPostalAddressGateResponse( + + @field:JsonUnwrapped + val baseAddress: BasePostalAddressResponse, + + @get:Schema(description = "Street") + val street: StreetGateDto? = null, + + @field:JsonUnwrapped + val areaPart: AreaDistrictResponse, + + @field:JsonUnwrapped + val basePhysicalAddress: BasePhysicalAddressDto +) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index d5033a2ee..6c475eb5a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -20,13 +20,13 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties @@ -127,7 +127,7 @@ class AddressService( ) } - fun toAddressOutput(externalId: String, address: LogisticAddressResponse): AddressGateOutput { + fun toAddressOutput(externalId: String, address: LogisticAddressGateResponse): AddressGateOutput { return AddressGateOutput( address = address, externalId = externalId diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index f2aba3b24..876ff9cc5 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -21,13 +21,13 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry @@ -130,7 +130,7 @@ class LegalEntityService( ) } - fun toLegalEntityOutput(externalId: String, legalEntityPool: PoolLegalEntityResponse, legalAddress: LogisticAddressResponse): LegalEntityGateOutput = + fun toLegalEntityOutput(externalId: String, legalEntityPool: PoolLegalEntityResponse, legalAddress: LogisticAddressGateResponse): LegalEntityGateOutput = LegalEntityGateOutput( legalEntity = LegalEntityResponse( bpnl = legalEntityPool.legalEntity.bpnl, @@ -144,7 +144,7 @@ class LegalEntityService( createdAt = legalEntityPool.legalEntity.createdAt, updatedAt = legalEntityPool.legalEntity.updatedAt, ), - legalAddress = legalEntityPool.legalAddress, + legalAddress = legalAddress, legalNameParts = arrayOf(legalEntityPool.legalName), externalId = externalId ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/PoolClient.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/PoolClient.kt index 572dbd82b..9ed08fac2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/PoolClient.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/PoolClient.kt @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.eclipse.tractusx.bpdm.common.dto.request.AddressPartnerBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.response.* +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import org.eclipse.tractusx.bpdm.gate.exception.PoolRequestException import org.springframework.beans.factory.annotation.Qualifier import org.springframework.stereotype.Service @@ -52,7 +53,7 @@ class PoolClient( return legalEntities } - fun searchLegalAddresses(bpnLs: Collection): Collection { + fun searchLegalAddresses(bpnLs: Collection): Collection { if (bpnLs.isEmpty()) return emptyList() val legalAddresses = try { @@ -61,7 +62,7 @@ class PoolClient( .uri("/legal-entities/legal-addresses/search") .bodyValue(objectMapper.writeValueAsString(bpnLs)) .retrieve() - .bodyToMono>() + .bodyToMono>() .block()!! } catch (e: Exception) { throw PoolRequestException("Request to search legal addresses failed.", e) @@ -86,7 +87,7 @@ class PoolClient( return sites.content } - fun searchMainAddresses(bpnSs: Collection): Collection { + fun searchMainAddresses(bpnSs: Collection): Collection { if (bpnSs.isEmpty()) return emptyList() val mainAddresses = try { @@ -95,7 +96,7 @@ class PoolClient( .uri("/sites/main-addresses/search") .bodyValue(objectMapper.writeValueAsString(bpnSs)) .retrieve() - .bodyToMono>() + .bodyToMono>() .block()!! } catch (e: Exception) { throw PoolRequestException("Request to main addresses of sites failed.", e) @@ -103,7 +104,7 @@ class PoolClient( return mainAddresses } - fun searchAddresses(bpnAs: Collection): Collection { + fun searchAddresses(bpnAs: Collection): Collection { if (bpnAs.isEmpty()) return emptyList() val addresses = try { @@ -112,7 +113,7 @@ class PoolClient( .uri("/addresses/search") .bodyValue(objectMapper.writeValueAsString(AddressPartnerBpnSearchRequest(addresses = bpnAs))) .retrieve() - .bodyToMono>() + .bodyToMono>() .block()!! } catch (e: Exception) { throw PoolRequestException("Request to search addresses failed.", e) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index dd6d0509f..9def4a0c9 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -20,7 +20,6 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas @@ -28,6 +27,7 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties @@ -129,7 +129,7 @@ class SiteService( ) } - fun toSiteOutput(externalId: String, site: SiteResponse, mainAddress: LogisticAddressResponse) = + fun toSiteOutput(externalId: String, site: SiteResponse, mainAddress: LogisticAddressGateResponse) = SiteGateOutput( site = site, mainAddress = mainAddress, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 51d635632..e0c0fcf9c 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -20,12 +20,14 @@ package org.eclipse.tractusx.bpdm.gate.util import org.eclipse.tractusx.bpdm.common.dto.AddressIdentifierDto +import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.dto.StreetDto import org.eclipse.tractusx.bpdm.common.dto.response.* import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto import org.eclipse.tractusx.bpdm.common.service.toDto import org.eclipse.tractusx.bpdm.gate.api.model.* +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import java.time.Instant object ResponseValues { @@ -145,10 +147,12 @@ object ResponseValues { val geoCoordinate2 = GeoCoordinateDto(CommonValues.geoCoordinates2.first, CommonValues.geoCoordinates2.second) val address1 = PhysicalPostalAddressResponse( - industrialZone = CommonValues.industrialZone1, - building = CommonValues.building1, - floor = CommonValues.floor1, - door = CommonValues.door1, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone1, + building = CommonValues.building1, + floor = CommonValues.floor1, + door = CommonValues.door1 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region1, administrativeAreaLevel2 = CommonValues.county1, @@ -164,10 +168,12 @@ object ResponseValues { ) val address2 = PhysicalPostalAddressResponse( - industrialZone = CommonValues.industrialZone2, - building = CommonValues.building2, - floor = CommonValues.floor2, - door = CommonValues.door2, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone2, + building = CommonValues.building2, + floor = CommonValues.floor2, + door = CommonValues.door2 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region2, administrativeAreaLevel2 = CommonValues.county2, @@ -182,7 +188,7 @@ object ResponseValues { ) ) - val logisticAddress1 = LogisticAddressResponse( + val logisticAddress1 = LogisticAddressGateResponse( bpna = CommonValues.bpnAddress1, physicalPostalAddress = address1, bpnLegalEntity = CommonValues.bpn1, @@ -191,7 +197,7 @@ object ResponseValues { updatedAt = Instant.now() ) - val logisticAddress2 = LogisticAddressResponse( + val logisticAddress2 = LogisticAddressGateResponse( bpna = CommonValues.bpnAddress2, physicalPostalAddress = address2, bpnLegalEntity = CommonValues.bpn2, @@ -202,7 +208,14 @@ object ResponseValues { val legalEntityResponsePool1 = PoolLegalEntityResponse( legalName = CommonValues.name1, - legalAddress = logisticAddress1, + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnAddress1, + physicalPostalAddress = address1, + bpnLegalEntity = CommonValues.bpn1, + bpnSite = "BPNS0000000001XY", + createdAt = Instant.now(), + updatedAt = Instant.now() + ), legalEntity = LegalEntityResponse( bpnl = CommonValues.bpn1, identifiers = listOf(identifier1, identifier2), @@ -219,7 +232,14 @@ object ResponseValues { val legalEntityResponsePool2 = PoolLegalEntityResponse( legalName = CommonValues.name3, - legalAddress = logisticAddress2, + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnAddress2, + physicalPostalAddress = address2, + bpnLegalEntity = CommonValues.bpn2, + bpnSite = "BPNS0000000002XY", + createdAt = Instant.now(), + updatedAt = Instant.now() + ), legalEntity = LegalEntityResponse( bpnl = CommonValues.bpn2, identifiers = listOf(identifier3, identifier4), diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 42c648cf0..079ccaab6 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -184,11 +184,13 @@ fun PhysicalPostalAddress.toDto(): PhysicalPostalAddressResponse { administrativeAreaLevel3 = administrativeAreaLevel3, district = districtLevel1, ), - companyPostalCode = companyPostCode, - industrialZone = industrialZone, - building = building, - floor = floor, - door = door + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = companyPostCode, + industrialZone = industrialZone, + building = building, + floor = floor, + door = door + ) ) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt index 87172b868..df8dc497b 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt @@ -69,10 +69,11 @@ class SaasAddressToDtoMappingTest { Assertions.assertThat(streetDto?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction) Assertions.assertThat(streetDto?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName) - Assertions.assertThat(physicalAddressDto.industrialZone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name) - Assertions.assertThat(physicalAddressDto.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) - Assertions.assertThat(physicalAddressDto.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) - Assertions.assertThat(physicalAddressDto.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.industrialZone) + .isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) } private fun checkMappingDtoPhysicalAddress(physicalAddressDto: PhysicalPostalAddressDto, addressSaas: AddressSaas) { diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt index 01e05676c..6428224f2 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt @@ -204,7 +204,7 @@ class AddressControllerSearchIT @Autowired constructor( ) val addressSearchRequest = AddressPartnerSearchRequest( - premise = givenAddress1.physicalPostalAddress.building + premise = givenAddress1.physicalPostalAddress.basePhysicalAddress.building ) val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt index b1a2b696b..63951916b 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt @@ -132,7 +132,7 @@ class SuggestionControllerIT @Autowired constructor( expectedLegalEntityName ), Arguments.of( - expectedLegalAddress.physicalPostalAddress.building, + expectedLegalAddress.physicalPostalAddress.basePhysicalAddress.building, EndpointValues.CATENA_SUGGESTION_ADDRESS_PREMISE_PATH, expectedLegalEntityName ), @@ -157,7 +157,7 @@ class SuggestionControllerIT @Autowired constructor( Arguments.of(nonlatinLegalAddress.physicalPostalAddress.baseAddress.postalCode, EndpointValues.CATENA_SUGGESTION_ADDRESS_POST_CODE_PATH), Arguments.of(nonlatinLegalAddress.physicalPostalAddress.baseAddress.city, EndpointValues.CATENA_SUGGESTION_ADDRESS_LOCALITY_PATH), Arguments.of(nonlatinLegalAddress.physicalPostalAddress.street!!.name, EndpointValues.CATENA_SUGGESTION_ADDRESS_THOROUGHFARE_PATH), - Arguments.of(nonlatinLegalAddress.physicalPostalAddress.building, EndpointValues.CATENA_SUGGESTION_ADDRESS_PREMISE_PATH), + Arguments.of(nonlatinLegalAddress.physicalPostalAddress.basePhysicalAddress.building, EndpointValues.CATENA_SUGGESTION_ADDRESS_PREMISE_PATH), // TODO check alternativePostalAddress // Arguments.of(nonlatinLegalAddress.alternativePostalAddress!!.deliveryServiceNumber, EndpointValues.CATENA_SUGGESTION_ADDRESS_POSTAL_DELIVERY_POINT_PATH) ) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt index 138293ce5..2f410461b 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.pool.util +import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto import org.eclipse.tractusx.bpdm.common.dto.StreetDto import org.eclipse.tractusx.bpdm.common.dto.response.* import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto @@ -88,11 +89,13 @@ object ResponseValues { private val classification5 = ClassificationResponse(CommonValues.classification5, null, classificationType) private val address1 = PhysicalPostalAddressResponse( - companyPostalCode = CommonValues.postCode2, - industrialZone = CommonValues.industrialZone1, - building = CommonValues.building1, - floor = CommonValues.floor1, - door = CommonValues.door1, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = CommonValues.postCode2, + industrialZone = CommonValues.industrialZone1, + building = CommonValues.building1, + floor = CommonValues.floor1, + door = CommonValues.door1 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region1, administrativeAreaLevel2 = CommonValues.county1, @@ -108,10 +111,12 @@ object ResponseValues { ) private val address2 = PhysicalPostalAddressResponse( - industrialZone = CommonValues.industrialZone2, - building = CommonValues.building2, - floor = CommonValues.floor2, - door = CommonValues.door2, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone2, + building = CommonValues.building2, + floor = CommonValues.floor2, + door = CommonValues.door2 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region2, administrativeAreaLevel2 = CommonValues.county2, @@ -127,10 +132,12 @@ object ResponseValues { ) private val address3 = PhysicalPostalAddressResponse( - industrialZone = CommonValues.industrialZone3, - building = CommonValues.building3, - floor = CommonValues.floor3, - door = CommonValues.door3, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone3, + building = CommonValues.building3, + floor = CommonValues.floor3, + door = CommonValues.door3 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region3, administrativeAreaLevel2 = CommonValues.county3, @@ -257,11 +264,13 @@ object ResponseValues { legalAddress = LogisticAddressResponse( bpna = CommonValues.bpnA1, physicalPostalAddress = PhysicalPostalAddressResponse( - companyPostalCode = null, - industrialZone = null, - building = null, - floor = null, - door = null, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = null, administrativeAreaLevel2 = null, @@ -297,11 +306,13 @@ object ResponseValues { legalAddress = LogisticAddressResponse( bpna = CommonValues.bpnA1, physicalPostalAddress = PhysicalPostalAddressResponse( - companyPostalCode = null, - industrialZone = null, - building = null, - floor = null, - door = null, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = null, administrativeAreaLevel2 = null, @@ -337,11 +348,13 @@ object ResponseValues { legalAddress = LogisticAddressResponse( bpna = CommonValues.bpnA1, physicalPostalAddress = PhysicalPostalAddressResponse( - companyPostalCode = null, - industrialZone = null, - building = null, - floor = null, - door = null, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = null, administrativeAreaLevel2 = null,