Skip to content

Commit

Permalink
feat(api): eclipse-tractusx#183 Gate API: Add Street Name Suffix and …
Browse files Browse the repository at this point in the history
…Prefix Fields

- add PhysicalPostalAddressGateResponse
  • Loading branch information
rainer-exxcellent committed Jun 2, 2023
1 parent 41f75e5 commit a7d4024
Show file tree
Hide file tree
Showing 19 changed files with 232 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(


Expand Down
Original file line number Diff line number Diff line change
@@ -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<AddressStateResponse> = emptyList(),

@ArraySchema(arraySchema = Schema(description = "All identifiers of the Address"))
val identifiers: Collection<AddressIdentifierResponse> = 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
)
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,7 +53,7 @@ class PoolClient(
return legalEntities
}

fun searchLegalAddresses(bpnLs: Collection<String>): Collection<LogisticAddressResponse> {
fun searchLegalAddresses(bpnLs: Collection<String>): Collection<LogisticAddressGateResponse> {
if (bpnLs.isEmpty()) return emptyList()

val legalAddresses = try {
Expand All @@ -61,7 +62,7 @@ class PoolClient(
.uri("/legal-entities/legal-addresses/search")
.bodyValue(objectMapper.writeValueAsString(bpnLs))
.retrieve()
.bodyToMono<Collection<LogisticAddressResponse>>()
.bodyToMono<Collection<LogisticAddressGateResponse>>()
.block()!!
} catch (e: Exception) {
throw PoolRequestException("Request to search legal addresses failed.", e)
Expand All @@ -86,7 +87,7 @@ class PoolClient(
return sites.content
}

fun searchMainAddresses(bpnSs: Collection<String>): Collection<LogisticAddressResponse> {
fun searchMainAddresses(bpnSs: Collection<String>): Collection<LogisticAddressGateResponse> {
if (bpnSs.isEmpty()) return emptyList()

val mainAddresses = try {
Expand All @@ -95,15 +96,15 @@ class PoolClient(
.uri("/sites/main-addresses/search")
.bodyValue(objectMapper.writeValueAsString(bpnSs))
.retrieve()
.bodyToMono<Collection<LogisticAddressResponse>>()
.bodyToMono<Collection<LogisticAddressGateResponse>>()
.block()!!
} catch (e: Exception) {
throw PoolRequestException("Request to main addresses of sites failed.", e)
}
return mainAddresses
}

fun searchAddresses(bpnAs: Collection<String>): Collection<LogisticAddressResponse> {
fun searchAddresses(bpnAs: Collection<String>): Collection<LogisticAddressGateResponse> {
if (bpnAs.isEmpty()) return emptyList()

val addresses = try {
Expand All @@ -112,7 +113,7 @@ class PoolClient(
.uri("/addresses/search")
.bodyValue(objectMapper.writeValueAsString(AddressPartnerBpnSearchRequest(addresses = bpnAs)))
.retrieve()
.bodyToMono<PageResponse<LogisticAddressResponse>>()
.bodyToMono<PageResponse<LogisticAddressGateResponse>>()
.block()!!
} catch (e: Exception) {
throw PoolRequestException("Request to search addresses failed.", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
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
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
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit a7d4024

Please sign in to comment.