From b24cefbe8f20448d1144a891f38fdaf0fae2e0bd Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 25 May 2023 05:51:49 +0200 Subject: [PATCH 1/2] feat(api): #176 Remove Admin Level 2 - 4 from alternative address --- .../bpdm/common/dto/AddressIdentifierDto.kt | 4 +- .../bpdm/common/dto/AddressStateDto.kt | 8 ++-- .../bpdm/common/dto/AddressVersionDto.kt | 6 ++- .../common/dto/AlternativePostalAddressDto.kt | 3 ++ .../common/dto/AreaDistrictAlternativDto.kt | 36 ++++++++++++++++ .../bpdm/common/dto/AreaDistrictDto.kt | 41 ++++++++++++++++++ .../bpdm/common/dto/BasePostalAddressDto.kt | 17 +------- .../bpdm/common/dto/ClassificationDto.kt | 6 +-- .../bpdm/common/dto/FieldQualityRuleDto.kt | 8 ++-- .../bpdm/common/dto/GenericIdentifierDto.kt | 4 +- .../bpdm/common/dto/GeoCoordinateDto.kt | 9 ++-- .../common/dto/PhysicalPostalAddressDto.kt | 3 ++ .../bpdm/common/service/SaasMappings.kt | 22 +++++----- .../bpdm/gate/service/ResponseMappings.kt | 14 +++--- .../service/SaasDtoToSaasAddressMapping.kt | 43 ++++++++++++++++--- .../gate/service/SaasRequestMappingService.kt | 8 ++-- .../SaasDtoToSaasAddressMappingTest.kt | 33 +++++++------- .../tractusx/bpdm/gate/util/RequestValues.kt | 24 ++++++----- .../service/BusinessPartnerBuildService.kt | 16 +++---- .../pool/service/MetadataMappingService.kt | 18 ++++---- .../service/SaasAddressToDtoMappingTest.kt | 11 ++--- .../controller/AddressControllerSearchIT.kt | 2 +- .../tractusx/bpdm/pool/util/RequestValues.kt | 31 +++++++------ 23 files changed, 242 insertions(+), 125 deletions(-) create mode 100644 bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AreaDistrictAlternativDto.kt create mode 100644 bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AreaDistrictDto.kt diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressIdentifierDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressIdentifierDto.kt index 1799415a8..d93143b85 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressIdentifierDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressIdentifierDto.kt @@ -23,9 +23,9 @@ import io.swagger.v3.oas.annotations.media.Schema @Schema(name = "AddressIdentifier", description = "Identifier record for a logistic address") data class AddressIdentifierDto( - @Schema(description = "Value of the identifier") + @get:Schema(description = "Value of the identifier") val value: String, - @Schema(description = "Technical key of the type to which this identifier belongs to") + @get:Schema(description = "Technical key of the type to which this identifier belongs to") val type: String, ) \ No newline at end of file diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressStateDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressStateDto.kt index f0e9a0a06..1c092d215 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressStateDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressStateDto.kt @@ -25,15 +25,15 @@ import java.time.LocalDateTime @Schema(name = "AddressState", description = "Status record for a address") data class AddressStateDto( - @Schema(description = "Description of the status") + @get:Schema(description = "Description of the status") val description: String?, - @Schema(description = "Since when the status is/was valid") + @get:Schema(description = "Since when the status is/was valid") val validFrom: LocalDateTime?, - @Schema(description = "Until the status was valid, if applicable") + @get:Schema(description = "Until the status was valid, if applicable") val validTo: LocalDateTime?, - @Schema(description = "The type of this specified status") + @get:Schema(description = "The type of this specified status") val type: BusinessStateType ) \ No newline at end of file diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressVersionDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressVersionDto.kt index 3910ba0ac..71cae4f04 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressVersionDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AddressVersionDto.kt @@ -25,8 +25,10 @@ import org.eclipse.tractusx.bpdm.common.model.CharacterSet @Schema(name = "AddressVersion", description = "Localization record for an address") data class AddressVersionDto( - @Schema(description = "Character set in which the address is written", defaultValue = "UNDEFINED") + + @get:Schema(description = "Character set in which the address is written", defaultValue = "UNDEFINED") val characterSet: CharacterSet = CharacterSet.UNDEFINED, - @Schema(description = "Language in which the address is written", defaultValue = "undefined") + + @get:Schema(description = "Language in which the address is written", defaultValue = "undefined") val language: LanguageCode = LanguageCode.undefined ) \ No newline at end of file diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt index 6ef03b23f..251df9c25 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt @@ -37,4 +37,7 @@ data class AlternativePostalAddressDto( @field:JsonUnwrapped val baseAddress: BasePostalAddressDto, + + @field:JsonUnwrapped + val areaPart: AreaDistrictAlternativDto, ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AreaDistrictAlternativDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AreaDistrictAlternativDto.kt new file mode 100644 index 000000000..6fc6b3d5a --- /dev/null +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AreaDistrictAlternativDto.kt @@ -0,0 +1,36 @@ +/******************************************************************************* + * 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.common.dto + +import io.swagger.v3.oas.annotations.media.Schema + +@Schema(name = "AreaDistrictDto", description = "Record for administrativeAreaLevel and district part of an alternativ address") +data class AreaDistrictAlternativDto( + + @get:Schema(description = "Identifying code of the Region within the country (e.g. Bayern)") + val administrativeAreaLevel1: String? = null, + + @get:Schema(description = "Divides the city in several smaller areas") + val districtLevel1: String? = null, + + @get:Schema(description = "Divides the DistrictLevel1 in several smaller areas. Synonym: Subdistrict") + val districtLevel2: String? = null, + + ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AreaDistrictDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AreaDistrictDto.kt new file mode 100644 index 000000000..779539b0c --- /dev/null +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AreaDistrictDto.kt @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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.common.dto + +import io.swagger.v3.oas.annotations.media.Schema + +@Schema(name = "AreaDistrictDto", description = "Record for administrativeAreaLevel and district part of an address") +data class AreaDistrictDto( + + @get:Schema(description = "Identifying code of the Region within the country (e.g. Bayern)") + val administrativeAreaLevel1: String? = null, + + @get:Schema(description = "Further possibility to describe the region/address(e.g. County/Landkreis)") + val administrativeAreaLevel2: String? = null, + + @get:Schema(description = "Further possibility to describe the region/address(e.g. Township/Gemeinde)") + val administrativeAreaLevel3: String? = null, + + @get:Schema(description = "Divides the city in several smaller areas") + val districtLevel1: String? = null, + + @get:Schema(description = "Divides the DistrictLevel1 in several smaller areas. Synonym: Subdistrict") + val districtLevel2: String? = null, +) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BasePostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BasePostalAddressDto.kt index 151690b86..177075228 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BasePostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BasePostalAddressDto.kt @@ -31,27 +31,12 @@ data class BasePostalAddressDto( @get:Schema(description = "Describes the country") val country: CountryCode, - @get:Schema(description = "Identifying code of the Region within the country (e.g. Bayern)") - val administrativeAreaLevel1: String? = null, - - @get:Schema(description = "Further possibility to describe the region/address(e.g. County/Landkreis)") - val administrativeAreaLevel2: String? = null, - - @get:Schema(description = "Further possibility to describe the region/address(e.g. Township/Gemeinde)") - val administrativeAreaLevel3: String? = null, - @get:Schema(description = "A postal code, also known as postcode, PIN or ZIP Code") val postCode: String? = null, @get:Schema(description = "The city of the address (Synonym: Town, village, municipality)") val city: String, - - @get:Schema(description = "Divides the city in several smaller areas") - val districtLevel1: String? = null, - - @get:Schema(description = "Divides the DistrictLevel1 in several smaller areas. Synonym: Subdistrict") - val districtLevel2: String? = null, - + @get:Schema(description = "Address country") val street: StreetDto? = null, diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationDto.kt index 8fd044c45..37f44c96f 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationDto.kt @@ -24,12 +24,12 @@ import org.eclipse.tractusx.bpdm.common.model.ClassificationType @Schema(name = "Classification", description = "Classification record for a business partner") data class ClassificationDto( - @Schema(description = "Name of the classification") + @get:Schema(description = "Name of the classification") val value: String?, - @Schema(description = "Identifying code of the classification, if applicable") + @get:Schema(description = "Identifying code of the classification, if applicable") val code: String?, - @Schema(description = "Type of specified classification") + @get:Schema(description = "Type of specified classification") val type: ClassificationType ) \ No newline at end of file diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/FieldQualityRuleDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/FieldQualityRuleDto.kt index dc763bd67..dec35684d 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/FieldQualityRuleDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/FieldQualityRuleDto.kt @@ -25,15 +25,15 @@ import io.swagger.v3.oas.annotations.media.Schema @Schema(name = "FieldQualityRuleDto", description = "Rule for the quality level of an entity field ") data class FieldQualityRuleDto( - @Schema(description = "Path to the field") + @get:Schema(description = "Path to the field") val fieldPath: String, - @Schema(description = "Schema name of the entity the field belongs to") + @get:Schema(description = "Schema name of the entity the field belongs to") val schemaName: String?, - @Schema(description = "Country for wich the rule is valid") + @get:Schema(description = "Country for wich the rule is valid") val country: CountryCode, - @Schema(description = "Quality level of the field") + @get:Schema(description = "Quality level of the field") val qualityLevel: QualityLevel ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/GenericIdentifierDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/GenericIdentifierDto.kt index 4d4cce074..6aca92239 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/GenericIdentifierDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/GenericIdentifierDto.kt @@ -23,9 +23,9 @@ import io.swagger.v3.oas.annotations.media.Schema @Schema(name = "GenericIdentifier", description = "Identifier record for a generic business partner") data class GenericIdentifierDto( - @Schema(description = "Value of the identifier") + @get:Schema(description = "Value of the identifier") val value: String, - @Schema(description = "Technical key of the type to which this identifier belongs to") + @get:Schema(description = "Technical key of the type to which this identifier belongs to") val type: String ) \ No newline at end of file diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/GeoCoordinateDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/GeoCoordinateDto.kt index fb42aee46..aad1a6caa 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/GeoCoordinateDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/GeoCoordinateDto.kt @@ -23,10 +23,13 @@ import io.swagger.v3.oas.annotations.media.Schema @Schema(name = "GeoCoordinates", description = "Geo coordinates record for an address") data class GeoCoordinateDto( - @Schema(description = "Longitude coordinate") + + @get:Schema(description = "Longitude coordinate") val longitude: Float, - @Schema(description = "Latitude coordinate") + + @get:Schema(description = "Latitude coordinate") val latitude: Float, - @Schema(description = "Altitude, if applicable") + + @get:Schema(description = "Altitude, if applicable") val altitude: Float? = null ) \ No newline at end of file diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt index 83b6c6761..f2dcddb29 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt @@ -28,6 +28,9 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ @Schema(name = "PhysicalPostalAddress", description = "Physical Postal Address Part") data class PhysicalPostalAddressDto( + @field:JsonUnwrapped + val areaPart: AreaDistrictDto, + @field:JsonUnwrapped val baseAddress: BasePostalAddressDto, diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt index 277ed7c37..43eee7097 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt @@ -217,16 +217,18 @@ object SaasMappings { building = map.building(), floor = map.floor(), door = map.door(), - baseAddress = BasePostalAddressDto( - geographicCoordinates = map.geoCoordinates(), - city = city, - country = country, + areaPart = AreaDistrictDto( administrativeAreaLevel1 = map.adminAreaLevel1(), administrativeAreaLevel2 = map.adminAreaLevel2(), administrativeAreaLevel3 = null, - postCode = map.postcode(), districtLevel1 = map.districtLevel1(), districtLevel2 = map.districtLevel2(), + ), + baseAddress = BasePostalAddressDto( + geographicCoordinates = map.geoCoordinates(), + city = city, + country = country, + postCode = map.postcode(), street = toStreetDto(map), ) ) @@ -251,16 +253,16 @@ object SaasMappings { return AlternativePostalAddressDto( deliveryServiceNumber = deliveryServiceNumber, deliveryServiceType = deliveryServiceType, + areaPart = AreaDistrictAlternativDto( + administrativeAreaLevel1 = map.adminAreaLevel1(), + districtLevel1 = map.districtLevel1(), + districtLevel2 = map.districtLevel2(), + ), baseAddress = BasePostalAddressDto( geographicCoordinates = map.geoCoordinates(), city = city, country = country, - administrativeAreaLevel1 = map.adminAreaLevel1(), - administrativeAreaLevel2 = map.adminAreaLevel2(), - administrativeAreaLevel3 = null, postCode = map.postcode(), - districtLevel1 = map.districtLevel1(), - districtLevel2 = map.districtLevel2(), street = toStreetDto(map), ) ) 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 c5662eae7..b7e3af0b3 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 @@ -63,12 +63,10 @@ fun AlternativePostalAddressDto.toAlternativePostalAddressEntity(): AlternativeP geographicCoordinates = baseAddress.geographicCoordinates?.toGeographicCoordinateEntity(), country = baseAddress.country, administrativeAreaLevel1 = null, // TODO Add region mapping Logic - administrativeAreaLevel2 = baseAddress.administrativeAreaLevel2, - administrativeAreaLevel3 = baseAddress.administrativeAreaLevel3, postCode = baseAddress.postCode, city = baseAddress.city, - districtLevel1 = baseAddress.districtLevel1, - districtLevel2 = baseAddress.districtLevel2, + districtLevel1 = areaPart.districtLevel1, + districtLevel2 = areaPart.districtLevel2, street = baseAddress.street?.toStreetEntity(), deliveryServiceType = deliveryServiceType, deliveryServiceNumber = deliveryServiceNumber @@ -82,12 +80,12 @@ fun PhysicalPostalAddressDto.toPhysicalPostalAddressEntity(): PhysicalPostalAddr geographicCoordinates = baseAddress.geographicCoordinates?.toGeographicCoordinateEntity(), country = baseAddress.country, administrativeAreaLevel1 = null, // TODO Add region mapping Logic - administrativeAreaLevel2 = baseAddress.administrativeAreaLevel2, - administrativeAreaLevel3 = baseAddress.administrativeAreaLevel3, + administrativeAreaLevel2 = areaPart.administrativeAreaLevel2, + administrativeAreaLevel3 = areaPart.administrativeAreaLevel3, postCode = baseAddress.postCode, city = baseAddress.city, - districtLevel1 = baseAddress.districtLevel1, - districtLevel2 = baseAddress.districtLevel2, + districtLevel1 = areaPart.districtLevel1, + districtLevel2 = areaPart.districtLevel2, street = baseAddress.street?.toStreetEntity(), companyPostCode = companyPostCode, industrialZone = industrialZone, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMapping.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMapping.kt index 77ba63ef8..2a8764e1f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMapping.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMapping.kt @@ -37,15 +37,15 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto return CountrySaas(shortName = postalAdress.country, value = postalAdress.country.getName()) } - fun administrativeAreas(): Collection { + fun administrativeAreas(physicalAddress: PhysicalPostalAddressDto?): Collection { return listOfNotNull( - postalAdress.administrativeAreaLevel1?.let { + physicalAddress?.areaPart?.administrativeAreaLevel1?.let { AdministrativeAreaSaas( value = it, type = SaasAdministrativeAreaType.REGION.toSaasTypeDto() ) }, - postalAdress.administrativeAreaLevel2?.let { + physicalAddress?.areaPart?.administrativeAreaLevel2?.let { AdministrativeAreaSaas( value = it, type = SaasAdministrativeAreaType.COUNTY.toSaasTypeDto() @@ -55,6 +55,18 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto ) } + fun administrativeAreas(alternateAddress: AlternativePostalAddressDto?): Collection { + return listOfNotNull( + alternateAddress?.areaPart?.administrativeAreaLevel1?.let { + AdministrativeAreaSaas( + value = it, + type = SaasAdministrativeAreaType.REGION.toSaasTypeDto() + ) + }, + ) + } + + fun postcodes(physicalAddress: PhysicalPostalAddressDto?): Collection { return listOfNotNull( postalAdress.postCode?.let { @@ -72,18 +84,37 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto ) } - fun localities(): Collection { + fun localities(alternateAddress: AlternativePostalAddressDto?): Collection { + + return listOfNotNull( + LocalitySaas( + value = postalAdress.city, type = SaasLocalityType.CITY.toSaasTypeDto() + ), + alternateAddress?.areaPart?.districtLevel1?.let { + LocalitySaas( + value = it, type = SaasLocalityType.DISTRICT.toSaasTypeDto() + ) + }, + alternateAddress?.areaPart?.districtLevel2?.let { + LocalitySaas( + value = it, type = SaasLocalityType.QUARTER.toSaasTypeDto() + ) + } + ) + } + + fun localities(physicalAddress: PhysicalPostalAddressDto?): Collection { return listOfNotNull( LocalitySaas( value = postalAdress.city, type = SaasLocalityType.CITY.toSaasTypeDto() ), - postalAdress.districtLevel1?.let { + physicalAddress?.areaPart?.districtLevel1?.let { LocalitySaas( value = it, type = SaasLocalityType.DISTRICT.toSaasTypeDto() ) }, - postalAdress.districtLevel2?.let { + physicalAddress?.areaPart?.districtLevel2?.let { LocalitySaas( value = it, type = SaasLocalityType.QUARTER.toSaasTypeDto() ) 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 2fe8ac914..5eaa955fe 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 @@ -158,9 +158,9 @@ class SaasRequestMappingService( val mapping = SaasDtoToSaasAddressMapping(address.baseAddress) return AddressSaas( country = mapping.country(), - administrativeAreas = mapping.administrativeAreas(), + administrativeAreas = mapping.administrativeAreas(physicalAddress = address), postCodes = mapping.postcodes(physicalAddress = address), - localities = mapping.localities(), + localities = mapping.localities(physicalAddress = address), thoroughfares = mapping.thoroughfares(physicalAddress = address), premises = mapping.premises(physicalAddress = address), postalDeliveryPoints = emptyList(), @@ -173,9 +173,9 @@ class SaasRequestMappingService( val mapping = SaasDtoToSaasAddressMapping(address.baseAddress) return AddressSaas( country = mapping.country(), - administrativeAreas = mapping.administrativeAreas(), + administrativeAreas = mapping.administrativeAreas(alternateAddress = address), postCodes = mapping.postcodes(physicalAddress = null), - localities = mapping.localities(), + localities = mapping.localities(alternateAddress = address), thoroughfares = mapping.thoroughfares(physicalAddress = null), premises = mapping.premises(physicalAddress = null), postalDeliveryPoints = mapping.postalDeliveryPoints(alternativeAddress = address), diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMappingTest.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMappingTest.kt index 295f33113..0f684431f 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMappingTest.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMappingTest.kt @@ -20,13 +20,14 @@ class SaasDtoToSaasAddressMappingTest { val addressSaas = SaasValues.addressBusinessPartner1.addresses.first() val baseAddressDto = addressDto.physicalPostalAddress.baseAddress - assertThat(baseAddressDto.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, REGION)) - assertThat(baseAddressDto.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, COUNTY)) - assertThat(baseAddressDto.administrativeAreaLevel3).isEqualTo(null) + val areaPart = addressDto.physicalPostalAddress.areaPart + assertThat(areaPart.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, REGION)) + assertThat(areaPart.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, COUNTY)) + assertThat(areaPart.administrativeAreaLevel3).isEqualTo(null) assertThat(baseAddressDto.city).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.CITY)) assertThat(baseAddressDto.country).isEqualTo(addressSaas.country?.shortName) - assertThat(baseAddressDto.districtLevel1).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.DISTRICT)) - assertThat(baseAddressDto.districtLevel2).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.QUARTER)) + assertThat(areaPart.districtLevel1).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.DISTRICT)) + assertThat(areaPart.districtLevel2).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.QUARTER)) assertThat(baseAddressDto.geographicCoordinates?.latitude).isEqualTo(addressSaas.geographicCoordinates?.latitude) assertThat(baseAddressDto.geographicCoordinates?.longitude).isEqualTo(addressSaas.geographicCoordinates?.longitude) assertThat(baseAddressDto.postCode).isEqualTo(findValue(addressSaas.postCodes, SaasPostCodeType.REGULAR)) @@ -64,13 +65,14 @@ class SaasDtoToSaasAddressMappingTest { val addressSaas = SaasValues.addressBusinessPartner1.addresses.first() val baseAddressDto = addressDto.physicalPostalAddress.baseAddress - assertThat(baseAddressDto.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, REGION)) - assertThat(baseAddressDto.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, COUNTY)) - assertThat(baseAddressDto.administrativeAreaLevel3).isEqualTo(null) + val areaPart = addressDto.physicalPostalAddress.areaPart + assertThat(areaPart.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, REGION)) + assertThat(areaPart.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, COUNTY)) + assertThat(areaPart.administrativeAreaLevel3).isEqualTo(null) assertThat(baseAddressDto.city).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.CITY)) assertThat(baseAddressDto.country).isEqualTo(addressSaas.country?.shortName) - assertThat(baseAddressDto.districtLevel1).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.DISTRICT)) - assertThat(baseAddressDto.districtLevel2).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.QUARTER)) + assertThat(areaPart.districtLevel1).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.DISTRICT)) + assertThat(areaPart.districtLevel2).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.QUARTER)) assertThat(baseAddressDto.geographicCoordinates?.latitude).isEqualTo(addressSaas.geographicCoordinates?.latitude) assertThat(baseAddressDto.geographicCoordinates?.longitude).isEqualTo(addressSaas.geographicCoordinates?.longitude) assertThat(baseAddressDto.postCode).isEqualTo(findValue(addressSaas.postCodes, SaasPostCodeType.REGULAR)) @@ -92,13 +94,14 @@ class SaasDtoToSaasAddressMappingTest { val addressSaas = SaasValues.addressBusinessPartner2.addresses.first() val baseAddressDto = addressDto.physicalPostalAddress.baseAddress - assertThat(baseAddressDto.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, REGION)) - assertThat(baseAddressDto.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, COUNTY)) - assertThat(baseAddressDto.administrativeAreaLevel3).isEqualTo(null) + val areaPart = addressDto.physicalPostalAddress.areaPart + assertThat(areaPart.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, REGION)) + assertThat(areaPart.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, COUNTY)) + assertThat(areaPart.administrativeAreaLevel3).isEqualTo(null) assertThat(baseAddressDto.city).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.CITY)) assertThat(baseAddressDto.country).isEqualTo(addressSaas.country?.shortName) - assertThat(baseAddressDto.districtLevel1).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.DISTRICT)) - assertThat(baseAddressDto.districtLevel2).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.QUARTER)) + assertThat(areaPart.districtLevel1).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.DISTRICT)) + assertThat(areaPart.districtLevel2).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.QUARTER)) assertThat(baseAddressDto.geographicCoordinates?.latitude).isEqualTo(addressSaas.geographicCoordinates?.latitude) assertThat(baseAddressDto.geographicCoordinates?.longitude).isEqualTo(addressSaas.geographicCoordinates?.longitude) assertThat(baseAddressDto.postCode).isEqualTo(findValue(addressSaas.postCodes, SaasPostCodeType.REGULAR)) 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 3fbc9bfd0..f13dd6d8f 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 @@ -122,16 +122,18 @@ object RequestValues { building = CommonValues.building1, floor = CommonValues.floor1, door = CommonValues.door1, + areaPart = AreaDistrictDto( + administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_1, + administrativeAreaLevel2 = CommonValues.county1, + districtLevel1 = CommonValues.districtLevel1_1, + districtLevel2 = CommonValues.districtLevel2_1, + ), baseAddress = BasePostalAddressDto( geographicCoordinates = geoCoordinate1, country = CommonValues.country1, - administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_1, - administrativeAreaLevel2 = CommonValues.county1, postCode = CommonValues.postCode1, city = CommonValues.city1, - districtLevel1 = CommonValues.districtLevel1_1, - districtLevel2 = CommonValues.districtLevel2_1, - street = StreetDto(name= CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1) + street = StreetDto(name = CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1) ) ) @@ -140,16 +142,18 @@ object RequestValues { building = CommonValues.building2, floor = CommonValues.floor2, door = CommonValues.door2, + areaPart = AreaDistrictDto( + administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_2, + administrativeAreaLevel2 = CommonValues.county2, + districtLevel1 = CommonValues.districtLevel1_2, + districtLevel2 = CommonValues.districtLevel2_2, + ), baseAddress = BasePostalAddressDto( geographicCoordinates = geoCoordinate2, country = CommonValues.country2, - administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_2, - administrativeAreaLevel2 = CommonValues.county2, postCode = CommonValues.postCode2, city = CommonValues.city2, - districtLevel1 = CommonValues.districtLevel1_2, - districtLevel2 = CommonValues.districtLevel2_2, - street = StreetDto(name= CommonValues.street2, houseNumber = CommonValues.houseNumber2, direction = CommonValues.direction2), + street = StreetDto(name = CommonValues.street2, houseNumber = CommonValues.houseNumber2, direction = CommonValues.direction2), ) ) 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 61dda4cfa..6224cd34f 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 @@ -421,6 +421,7 @@ class BusinessPartnerBuildService( private fun createPhysicalAddress(physicalAddress: PhysicalPostalAddressDto, metadataMap: AddressMetadataMappingDto): PhysicalPostalAddress { val baseAddress = physicalAddress.baseAddress + val area = physicalAddress.areaPart return PhysicalPostalAddress( geographicCoordinates = baseAddress.geographicCoordinates?.let { toEntity(it) }, country = baseAddress.country, @@ -429,12 +430,12 @@ class BusinessPartnerBuildService( // metadataMap.regions[it] ?: throw BpdmNotFoundException(Region::class, it) // }, administrativeAreaLevel1 = null, - administrativeAreaLevel2 = baseAddress.administrativeAreaLevel2, - administrativeAreaLevel3 = baseAddress.administrativeAreaLevel3, + administrativeAreaLevel2 = area.administrativeAreaLevel2, + administrativeAreaLevel3 = area.administrativeAreaLevel3, postCode = baseAddress.postCode, city = baseAddress.city, - districtLevel1 = baseAddress.districtLevel1, - districtLevel2 = baseAddress.districtLevel2, + districtLevel1 = area.districtLevel1, + districtLevel2 = area.districtLevel2, street = baseAddress.street?.let { createStreet(it) }, companyPostCode = physicalAddress.companyPostCode, industrialZone = physicalAddress.industrialZone, @@ -446,6 +447,7 @@ class BusinessPartnerBuildService( private fun createAlternativeAddress(alternativeAddress: AlternativePostalAddressDto, metadataMap: AddressMetadataMappingDto): AlternativePostalAddress { val baseAddress = alternativeAddress.baseAddress + val area = alternativeAddress.areaPart return AlternativePostalAddress( geographicCoordinates = baseAddress.geographicCoordinates?.let { toEntity(it) }, country = baseAddress.country, @@ -454,12 +456,10 @@ class BusinessPartnerBuildService( // metadataMap.regions[it] ?: throw BpdmNotFoundException(Region::class, it) // }, administrativeAreaLevel1 = null, - administrativeAreaLevel2 = baseAddress.administrativeAreaLevel2, - administrativeAreaLevel3 = baseAddress.administrativeAreaLevel3, postCode = baseAddress.postCode, city = baseAddress.city, - districtLevel1 = baseAddress.districtLevel1, - districtLevel2 = baseAddress.districtLevel2, + districtLevel1 = area.districtLevel1, + districtLevel2 = area.districtLevel2, street = baseAddress.street?.let { createStreet(it) }, deliveryServiceType = alternativeAddress.deliveryServiceType, deliveryServiceNumber = alternativeAddress.deliveryServiceNumber diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataMappingService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataMappingService.kt index 369500bee..acbf3ce0f 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataMappingService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataMappingService.kt @@ -68,7 +68,7 @@ class MetadataMappingService( /** * Fetch [IdentifierType] referenced in [partners] and map them by their referenced keys */ - fun mapLegalEntityIdentifierTypes(partners: Collection): Map{ + fun mapLegalEntityIdentifierTypes(partners: Collection): Map { val technicalKeys = partners.flatMap { it.identifiers.map { id -> id.type } }.toSet() return mapIdentifierTypes(IdentifierLsaType.LEGAL_ENTITY, technicalKeys) } @@ -76,7 +76,7 @@ class MetadataMappingService( /** * Fetch [IdentifierType] referenced in [partners] and map them by their referenced keys */ - fun mapAddressIdentifierTypes(partners: Collection): Map{ + fun mapAddressIdentifierTypes(partners: Collection): Map { val technicalKeys = partners.flatMap { it.identifiers.map { id -> id.type } }.toSet() return mapIdentifierTypes(IdentifierLsaType.ADDRESS, technicalKeys) } @@ -84,13 +84,13 @@ class MetadataMappingService( /** * Fetch [LegalForm] referenced in [partners] and map them by their referenced keys */ - fun mapLegalForms(partners: Collection): Map{ + fun mapLegalForms(partners: Collection): Map { return mapLegalForms(partners.mapNotNull { it.legalForm }.toSet()) } fun mapAddressRegions(partners: Collection): Map { - val regionCodes = partners.mapNotNull { it.physicalPostalAddress.baseAddress.administrativeAreaLevel1 } - .plus(partners.mapNotNull { it.alternativePostalAddress?.baseAddress?.administrativeAreaLevel1 }) + val regionCodes = partners.mapNotNull { it.physicalPostalAddress.areaPart.administrativeAreaLevel1 } + .plus(partners.mapNotNull { it.alternativePostalAddress?.areaPart?.administrativeAreaLevel1 }) .toSet() return regionRepository.findByRegionCodeIn(regionCodes) @@ -101,21 +101,21 @@ class MetadataMappingService( } - private fun mapIdentifierTypes(lsaType: IdentifierLsaType, keys: Set): Map{ + private fun mapIdentifierTypes(lsaType: IdentifierLsaType, keys: Set): Map { val typeMap = identifierTypeRepository.findByLsaTypeAndTechnicalKeyIn(lsaType, keys).associateBy { it.technicalKey } assertKeysFound(keys, typeMap) return typeMap } - private fun mapLegalForms(keys: Set): Map{ + private fun mapLegalForms(keys: Set): Map { val typeMap = legalFormRepository.findByTechnicalKeyIn(keys).associateBy { it.technicalKey } assertKeysFound(keys, typeMap) return typeMap } - private inline fun assertKeysFound(keys: Set, typeMap: Map){ + private inline fun assertKeysFound(keys: Set, typeMap: Map) { val keysNotfound = keys.minus(typeMap.keys) - if(keysNotfound.isNotEmpty()) throw BpdmMultipleNotFoundException(T::class.simpleName!!, keysNotfound ) + if (keysNotfound.isNotEmpty()) throw BpdmMultipleNotFoundException(T::class.simpleName!!, keysNotfound) } } \ No newline at end of file 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 69d073a1d..058b2b21f 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 @@ -77,13 +77,14 @@ class SaasAddressToDtoMappingTest { private fun checkMappingDtoPhysicalAddress(physicalAddressDto: PhysicalPostalAddressDto, addressSaas: AddressSaas) { val baseAddressDto = physicalAddressDto.baseAddress - Assertions.assertThat(baseAddressDto.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, SaasAdministrativeAreaType.REGION)) - Assertions.assertThat(baseAddressDto.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, SaasAdministrativeAreaType.COUNTY)) - Assertions.assertThat(baseAddressDto.administrativeAreaLevel3).isEqualTo(null) + val areaDto = physicalAddressDto.areaPart + Assertions.assertThat(areaDto.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, SaasAdministrativeAreaType.REGION)) + Assertions.assertThat(areaDto.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, SaasAdministrativeAreaType.COUNTY)) + Assertions.assertThat(areaDto.administrativeAreaLevel3).isEqualTo(null) Assertions.assertThat(baseAddressDto.city).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.CITY)) Assertions.assertThat(baseAddressDto.country).isEqualTo(addressSaas.country?.shortName) - Assertions.assertThat(baseAddressDto.districtLevel1).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.DISTRICT)) - Assertions.assertThat(baseAddressDto.districtLevel2).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.QUARTER)) + Assertions.assertThat(areaDto.districtLevel1).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.DISTRICT)) + Assertions.assertThat(areaDto.districtLevel2).isEqualTo(findValue(addressSaas.localities, SaasLocalityType.QUARTER)) Assertions.assertThat(baseAddressDto.geographicCoordinates?.latitude).isEqualTo(addressSaas.geographicCoordinates?.latitude) Assertions.assertThat(baseAddressDto.geographicCoordinates?.longitude).isEqualTo(addressSaas.geographicCoordinates?.longitude) Assertions.assertThat(baseAddressDto.postCode).isEqualTo(findValue(addressSaas.postCodes, SaasPostCodeType.REGULAR)) 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 9efcfa6e9..35b9328b9 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 @@ -106,7 +106,7 @@ class AddressControllerSearchIT @Autowired constructor( ) ) val addressSearchRequest = AddressPartnerSearchRequest( - administrativeArea = RequestValues.addressPartnerCreate1.address.physicalPostalAddress.baseAddress.administrativeAreaLevel2 + administrativeArea = RequestValues.addressPartnerCreate1.address.physicalPostalAddress.areaPart.administrativeAreaLevel2 ) val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) 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 da9bfc1fb..6d19f9622 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 @@ -96,15 +96,17 @@ object RequestValues { building = CommonValues.building1, floor = CommonValues.floor1, door = CommonValues.door1, + areaPart = AreaDistrictDto( + administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_1, + administrativeAreaLevel2 = CommonValues.county1, + districtLevel1 = CommonValues.districtLevel1_1, + districtLevel2 = CommonValues.districtLevel2_1, + ), baseAddress = BasePostalAddressDto( geographicCoordinates = null, country = CommonValues.country1, - administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_1, - administrativeAreaLevel2 = CommonValues.county1, postCode = CommonValues.postCode1, city = CommonValues.city1, - districtLevel1 = CommonValues.districtLevel1_1, - districtLevel2 = CommonValues.districtLevel2_1, street = StreetDto(CommonValues.street1, CommonValues.houseNumber1), ) ) @@ -114,15 +116,17 @@ object RequestValues { building = CommonValues.building2, floor = CommonValues.floor2, door = CommonValues.door2, + areaPart = AreaDistrictDto( + administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_2, + administrativeAreaLevel2 = CommonValues.county2, + districtLevel1 = CommonValues.districtLevel1_2, + districtLevel2 = CommonValues.districtLevel2_2, + ), baseAddress = BasePostalAddressDto( geographicCoordinates = null, country = CommonValues.country2, - administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_2, - administrativeAreaLevel2 = CommonValues.county2, postCode = CommonValues.postCode2, city = CommonValues.city2, - districtLevel1 = CommonValues.districtLevel1_2, - districtLevel2 = CommonValues.districtLevel2_2, street = StreetDto(CommonValues.street2, CommonValues.houseNumber2), ) ) @@ -131,16 +135,17 @@ object RequestValues { industrialZone = CommonValues.industrialZone3, building = CommonValues.building3, floor = CommonValues.floor3, - door = CommonValues.door3, + door = CommonValues.door3, areaPart = AreaDistrictDto( + administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_3, + administrativeAreaLevel2 = CommonValues.county3, + districtLevel1 = CommonValues.districtLevel1_3, + districtLevel2 = CommonValues.districtLevel2_3, + ), baseAddress = BasePostalAddressDto( geographicCoordinates = null, country = CommonValues.country3, - administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_3, - administrativeAreaLevel2 = CommonValues.county3, postCode = CommonValues.postCode3, city = CommonValues.city3, - districtLevel1 = CommonValues.districtLevel1_3, - districtLevel2 = CommonValues.districtLevel2_3, street = StreetDto(CommonValues.street3, CommonValues.houseNumber3), ) ) From d97e7cb67510082eee196d37a39bdd2246249395 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 25 May 2023 06:13:00 +0200 Subject: [PATCH 2/2] feat(api): #176 Remove Admin Level 2 - 4 from alternative address - change order of Properties in DTO --- .../bpdm/common/dto/AlternativePostalAddressDto.kt | 12 ++++++------ .../bpdm/common/dto/PhysicalPostalAddressDto.kt | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt index 251df9c25..77efb8d65 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt @@ -29,15 +29,15 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ @Schema(name = "AlternativePostalAddress", description = "Alternative Postal Address Part") data class AlternativePostalAddressDto( - @get:Schema(description = "Describes the PO Box or private Bag number the delivery should be placed at.") - val deliveryServiceNumber: String = "", - - @get:Schema(description = "The type of this specified delivery") - val deliveryServiceType: DeliveryServiceType = DeliveryServiceType.PO_BOX, - @field:JsonUnwrapped val baseAddress: BasePostalAddressDto, @field:JsonUnwrapped val areaPart: AreaDistrictAlternativDto, + + @get:Schema(description = "Describes the PO Box or private Bag number the delivery should be placed at.") + val deliveryServiceNumber: String = "", + + @get:Schema(description = "The type of this specified delivery") + val deliveryServiceType: DeliveryServiceType = DeliveryServiceType.PO_BOX, ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt index f2dcddb29..9b4c67ac0 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt @@ -29,10 +29,10 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ data class PhysicalPostalAddressDto( @field:JsonUnwrapped - val areaPart: AreaDistrictDto, + val baseAddress: BasePostalAddressDto, @field:JsonUnwrapped - val baseAddress: BasePostalAddressDto, + val areaPart: AreaDistrictDto, @get:Schema(description = "A separate postal code for a company, also known as postcode, PIN or ZIP Code") val companyPostCode: String? = null,