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 PhysicalPostalAddressGateDto
  • Loading branch information
rainer-exxcellent authored and fabiodmota committed Jun 26, 2023
1 parent 71a87cc commit fbef164
Show file tree
Hide file tree
Showing 28 changed files with 446 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

package com.catenax.bpdm.bridge.dummy.dto

import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto

data class GateAddressInfo(
val address: LogisticAddressDto,
val address: LogisticAddressGateDto,
val externalId: String,
val legalEntityExternalId: String?,
val siteExternalId: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
package com.catenax.bpdm.bridge.dummy.dto

import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto
import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto

data class GateLegalEntityInfo(
val legalNameParts: Array<String> = emptyArray(),
val legalEntity: LegalEntityDto,
val legalAddress: LogisticAddressDto,
val legalAddress: LogisticAddressGateDto,
val externalId: String,
val bpn: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

package com.catenax.bpdm.bridge.dummy.dto

import org.eclipse.tractusx.bpdm.common.dto.SiteDto
import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateDto

data class GateSiteInfo(
val site: SiteDto,
val site: SiteGateDto,
val externalId: String,
val legalEntityExternalId: String,
val bpn: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import com.catenax.bpdm.bridge.dummy.dto.GateAddressInfo
import com.catenax.bpdm.bridge.dummy.dto.GateLegalEntityInfo
import com.catenax.bpdm.bridge.dummy.dto.GateSiteInfo
import mu.KotlinLogging
import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.dto.PhysicalPostalAddressDto
import org.eclipse.tractusx.bpdm.common.dto.SiteDto
import org.eclipse.tractusx.bpdm.common.dto.StreetDto
import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto
import org.eclipse.tractusx.bpdm.gate.api.model.PhysicalPostalAddressGateDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType
import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient
import org.eclipse.tractusx.bpdm.pool.api.model.request.*
Expand All @@ -37,11 +43,38 @@ class PoolUpdateService(

private val logger = KotlinLogging.logger { }

fun gateToPoolPhysicalAddress(gateDto: PhysicalPostalAddressGateDto): PhysicalPostalAddressDto {

return PhysicalPostalAddressDto(
baseAddress = gateDto.baseAddress,
areaPart = gateDto.areaPart,
basePhysicalAddress = gateDto.basePhysicalAddress,
street = StreetDto(
name = gateDto.street?.name,
houseNumber = gateDto.street?.houseNumber,
milestone = gateDto.street?.milestone,
direction = gateDto.street?.direction,
),
)
}

fun gateToPoolLogisticAddress(gateDto: LogisticAddressGateDto): LogisticAddressDto {

return LogisticAddressDto(
name = gateDto.name,
states = gateDto.states,
identifiers = gateDto.identifiers,
physicalPostalAddress = gateToPoolPhysicalAddress(gateDto.physicalPostalAddress),
alternativePostalAddress = gateDto.alternativePostalAddress
)
}


fun createLegalEntitiesInPool(entriesToCreate: Collection<GateLegalEntityInfo>): LegalEntityPartnerCreateResponseWrapper {
val createRequests = entriesToCreate.map {
LegalEntityPartnerCreateRequest(
legalEntity = it.legalEntity,
legalAddress = it.legalAddress,
legalAddress = gateToPoolLogisticAddress(it.legalAddress),
index = it.externalId,
legalName = it.legalNameParts[0]
)
Expand All @@ -55,7 +88,7 @@ class PoolUpdateService(
val updateRequests = entriesToUpdate.map {
LegalEntityPartnerUpdateRequest(
legalEntity = it.legalEntity,
legalAddress = it.legalAddress,
legalAddress = gateToPoolLogisticAddress(it.legalAddress),
bpnl = it.bpn!!,
legalName = it.legalNameParts[0]
)
Expand All @@ -73,7 +106,11 @@ class PoolUpdateService(
leParentBpnByExternalId[entry.legalEntityExternalId]
?.let { leParentBpn ->
SitePartnerCreateRequest(
site = entry.site,
site = SiteDto(
name = entry.site.name,
states = entry.site.states,
mainAddress = gateToPoolLogisticAddress(entry.site.mainAddress),
),
index = entry.externalId,
bpnlParent = leParentBpn
)
Expand All @@ -93,7 +130,11 @@ class PoolUpdateService(
fun updateSitesInPool(entriesToUpdate: Collection<GateSiteInfo>): SitePartnerUpdateResponseWrapper {
val updateRequests = entriesToUpdate.map {
SitePartnerUpdateRequest(
site = it.site,
site = SiteDto(
name = it.site.name,
states = it.site.states,
mainAddress = gateToPoolLogisticAddress(it.site.mainAddress),
),
bpns = it.bpn!!
)
}
Expand All @@ -110,7 +151,7 @@ class PoolUpdateService(
leParentBpnByExternalId[entry.legalEntityExternalId]
?.let { leParentBpn ->
AddressPartnerCreateRequest(
address = entry.address,
address = gateToPoolLogisticAddress(entry.address),
index = entry.externalId,
bpnParent = leParentBpn
)
Expand All @@ -124,7 +165,13 @@ class PoolUpdateService(
siteParentBpnByExternalId[entry.siteExternalId]
?.let { siteParentBpn ->
AddressPartnerCreateRequest(
address = entry.address,
address = LogisticAddressDto(
name = entry.address.name,
states = entry.address.states,
identifiers = entry.address.identifiers,
physicalPostalAddress = gateToPoolPhysicalAddress(entry.address.physicalPostalAddress),
alternativePostalAddress = entry.address.alternativePostalAddress
),
index = entry.externalId,
bpnParent = siteParentBpn
)
Expand All @@ -145,7 +192,13 @@ class PoolUpdateService(
fun updateAddressesInPool(entriesToUpdate: Collection<GateAddressInfo>): AddressPartnerUpdateResponseWrapper {
val updateRequests = entriesToUpdate.map {
AddressPartnerUpdateRequest(
address = it.address,
address = LogisticAddressDto(
name = it.address.name,
states = it.address.states,
identifiers = it.address.identifiers,
physicalPostalAddress = gateToPoolPhysicalAddress(it.address.physicalPostalAddress),
alternativePostalAddress = it.address.alternativePostalAddress
),
bpna = it.bpn!!
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "BasePhysicalAddressDto", description = "Address record for the basical physical address fields")
data class BasePhysicalAddressDto(

@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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ data class PhysicalPostalAddressDto(
@field:JsonUnwrapped
val areaPart: AreaDistrictDto,

@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 @@ -203,11 +203,13 @@ object SaasMappings {
}

return PhysicalPostalAddressDto(
companyPostalCode = map.companyPostCode(),
industrialZone = map.industrialZone(),
building = map.building(),
floor = map.floor(),
door = map.door(),
basePhysicalAddress = BasePhysicalAddressDto(
companyPostalCode = map.companyPostCode(),
industrialZone = map.industrialZone(),
building = map.building(),
floor = map.floor(),
door = map.door(),
),
areaPart = AreaDistrictDto(
administrativeAreaLevel1 = map.adminAreaLevel1(),
administrativeAreaLevel2 = map.adminAreaLevel2(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
Expand All @@ -32,7 +31,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ
)
data class AddressGateInputRequest(
@field:JsonUnwrapped
val address: LogisticAddressDto,
val address: LogisticAddressGateDto,

@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 @@ -22,8 +22,6 @@ 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.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer
import java.time.LocalDateTime

Expand All @@ -33,8 +31,9 @@ import java.time.LocalDateTime
"Only one of either legal entity or site external id can be set for an address."
)
data class AddressGateInputResponse(

@field:JsonUnwrapped
val address: LogisticAddressDto,
val address: LogisticAddressGateDto,

@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 @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model
import io.swagger.v3.oas.annotations.media.ArraySchema
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.GenericIdentifierDto
import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.dto.NameDto

data class BusinessPartnerCandidateDto(
Expand All @@ -36,5 +35,5 @@ data class BusinessPartnerCandidateDto(
val legalForm: String? = null,

@Schema(description = "Address of this partner")
val address: LogisticAddressDto
val address: LogisticAddressGateDto
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto
import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
Expand All @@ -35,7 +34,7 @@ data class LegalEntityGateInputRequest(
val legalEntity: LegalEntityDto,

@get:Schema(description = "Address of the official seat of this legal entity")
val legalAddress: LogisticAddressDto,
val legalAddress: LogisticAddressGateDto,

@Schema(description = "ID the record has in the external system where the record originates from", required = true)
val externalId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ 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.LegalEntityDto
import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer
import java.time.LocalDateTime

Expand All @@ -37,7 +36,7 @@ data class LegalEntityGateInputResponse(
val legalEntity: LegalEntityDto,

@get:Schema(description = "Address of the official seat of this legal entity")
val legalAddress: LogisticAddressDto,
val legalAddress: LogisticAddressGateDto,

@Schema(description = "ID the record has in the external system where the record originates from", required = true)
val externalId: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*******************************************************************************
* 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

import io.swagger.v3.oas.annotations.media.ArraySchema
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.AddressIdentifierDto
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")
data class LogisticAddressGateDto(
@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 = "Indicates if the LogisticAddress is \"Active\" or \"Inactive\"."))
val states: Collection<AddressStateDto> = emptyList(),

@ArraySchema(arraySchema = Schema(description = "List of identifiers"))
val identifiers: Collection<AddressIdentifierDto> = emptyList(),

@get:Schema(description = "Physical postal address")
val physicalPostalAddress: PhysicalPostalAddressGateDto,

@get:Schema(description = "Alternative postal address")
val alternativePostalAddress: AlternativePostalAddressDto? = null
)
Loading

0 comments on commit fbef164

Please sign in to comment.