Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/Pool API: Legal Entity Response should include Legal Address #223

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.media.Schema
data class LegalEntityDto(
@ArraySchema(arraySchema = Schema(description = "Additional identifiers (except BPN)", required = false))
val identifiers: Collection<LegalEntityIdentifierDto> = emptyList(),

@get:Schema(description = "Abbreviated name or shorthand")
val legalShortName: String?,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ data class LegalEntityResponse(
@ArraySchema(arraySchema = Schema(description = "Relations to other business partners"))
val relations: Collection<RelationResponse> = emptyList(),

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

@get:Schema(description = "The timestamp the business partner data was last indicated to be still current")
val currentness: Instant,

@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
)
val updatedAt: Instant,

)
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,18 @@

package org.eclipse.tractusx.bpdm.common.dto.response

import io.swagger.v3.oas.annotations.media.ArraySchema
import com.fasterxml.jackson.annotation.JsonUnwrapped
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.swagger.v3.oas.annotations.media.Schema
import java.time.Instant
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
@Schema(name = "PoolLegalEntityResponse", description = "Legal entity record")
data class PoolLegalEntityResponse(
@get:Schema(description = "Business Partner Number of this legal entity")
val bpnl: String,

@ArraySchema(arraySchema = Schema(description = "All identifiers of the business partner, including BPN information"))
val identifiers: Collection<LegalEntityIdentifierResponse> = emptyList(),

@get:Schema(description = "Legal name the partner goes by")
val legalName: String,

@get:Schema(description = "Abbreviated name or shorthand")
val legalShortName: String? = null,

@get:Schema(description = "Legal form of the business partner")
val legalForm: LegalFormResponse? = null,

@ArraySchema(arraySchema = Schema(description = "Business status"))
val states: Collection<LegalEntityStateResponse> = emptyList(),

@ArraySchema(arraySchema = Schema(description = "Classifications"))
val classifications: Collection<ClassificationResponse> = emptyList(),

@ArraySchema(arraySchema = Schema(description = "Relations to other business partners"))
val relations: Collection<RelationResponse> = emptyList(),

@get:Schema(description = "The timestamp the business partner data was last indicated to be still current")
val currentness: Instant,

@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
@field:JsonUnwrapped
val legalEntity: LegalEntityResponse,
)
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ object SaasMappings {
)
}

private fun BusinessPartnerSaas.toNameDto(): SassNameDto? {
fun BusinessPartnerSaas.toNameDto(): SassNameDto? {
if (names.size > 1) {
logger.warn { "Business Partner with ID $externalId has more than one name" }
}
Expand Down Expand Up @@ -292,7 +292,7 @@ object SaasMappings {
)
}

private data class SassNameDto(
data class SassNameDto(
val value: String,
val shortName: String?
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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.LegalEntityDto
Expand All @@ -31,7 +30,7 @@ data class LegalEntityGateInputRequest(

val legalNameParts: Array<String> = emptyArray(),

@field:JsonUnwrapped
@Schema(description = "legal Enity")
val legalEntity: LegalEntityDto,

@Schema(description = "ID the record has in the external system where the record originates from", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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.response.LegalEntityResponse
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
Expand All @@ -36,9 +35,6 @@ data class LegalEntityGateOutput(
@field:JsonUnwrapped
val legalEntity: LegalEntityResponse,

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

@Schema(description = "ID the record has in the external system where the record originates from")
val externalId: String
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ 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.PoolLegalEntityResponse
import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas
import org.eclipse.tractusx.bpdm.common.dto.saas.FetchResponse
import org.eclipse.tractusx.bpdm.common.exception.BpdmMappingException
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
Expand Down Expand Up @@ -99,7 +96,7 @@ class LegalEntityService(

//Search entries in the pool with BPNs found in the local mirror
val bpnSet = partnersWithLocalBpn.map { it.bpn }.toSet()
val legalEntitiesByBpnMap = poolClient.searchLegalEntities(bpnSet).associateBy { it.bpnl }
val legalEntitiesByBpnMap = poolClient.searchLegalEntities(bpnSet).associateBy { it.legalEntity.bpnl }
val legalAddressesByBpnMap = poolClient.searchLegalAddresses(bpnSet).associateBy { it.bpnLegalEntity }

if (bpnSet.size > legalEntitiesByBpnMap.size) {
Expand Down Expand Up @@ -136,19 +133,19 @@ class LegalEntityService(
fun toLegalEntityOutput(externalId: String, legalEntityPool: PoolLegalEntityResponse, legalAddress: LogisticAddressResponse): LegalEntityGateOutput =
LegalEntityGateOutput(
legalEntity = LegalEntityResponse(
bpnl = legalEntityPool.bpnl,
identifiers = legalEntityPool.identifiers,
legalShortName = legalEntityPool.legalShortName,
legalForm = legalEntityPool.legalForm,
states = legalEntityPool.states,
classifications = legalEntityPool.classifications,
relations = legalEntityPool.relations,
currentness = legalEntityPool.currentness,
createdAt = legalEntityPool.createdAt,
updatedAt = legalEntityPool.updatedAt,
bpnl = legalEntityPool.legalEntity.bpnl,
identifiers = legalEntityPool.legalEntity.identifiers,
legalShortName = legalEntityPool.legalEntity.legalShortName,
legalForm = legalEntityPool.legalEntity.legalForm,
states = legalEntityPool.legalEntity.states,
classifications = legalEntityPool.legalEntity.classifications,
relations = legalEntityPool.legalEntity.relations,
currentness = legalEntityPool.legalEntity.currentness,
createdAt = legalEntityPool.legalEntity.createdAt,
updatedAt = legalEntityPool.legalEntity.updatedAt,
legalAddress = legalEntityPool.legalEntity.legalAddress,
),
legalNameParts = arrayOf(legalEntityPool.legalName),
legalAddress = legalAddress,
externalId = externalId
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class LegalEntityControllerInputIT @Autowired constructor(
private val webTestClient: WebTestClient,
private val objectMapper: ObjectMapper,
val gateClient: GateClient,
private val legalEntityRepository: LegalEntityRepository
private val legalEntityRepository: LegalEntityRepository,
) {
companion object {
@RegisterExtension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,29 +201,36 @@ object ResponseValues {
)

val legalEntityResponsePool1 = PoolLegalEntityResponse(
bpnl = CommonValues.bpn1,
identifiers = listOf(identifier1, identifier2),
legalShortName = CommonValues.shortName1,
legalName = CommonValues.name1,
legalForm = legalForm1,
states = listOf(leBusinessStatus1),
classifications = listOf(classification1, classification2),
currentness = CommonValues.now,
createdAt = CommonValues.now,
updatedAt = CommonValues.now
LegalEntityResponse(
bpnl = CommonValues.bpn1,
identifiers = listOf(identifier1, identifier2),
legalShortName = CommonValues.shortName1,
legalForm = legalForm1,
states = listOf(leBusinessStatus1),
classifications = listOf(classification1, classification2),
currentness = CommonValues.now,
createdAt = CommonValues.now,
updatedAt = CommonValues.now,
legalAddress = logisticAddress1
)

)

val legalEntityResponsePool2 = PoolLegalEntityResponse(
bpnl = CommonValues.bpn2,
identifiers = listOf(identifier3, identifier4),
legalShortName = CommonValues.shortName3,
legalName = CommonValues.name3,
legalForm = legalForm2,
states = listOf(leBusinessStatus2),
classifications = listOf(classification3, classification4),
currentness = CommonValues.now,
createdAt = CommonValues.now,
updatedAt = CommonValues.now
LegalEntityResponse(
bpnl = CommonValues.bpn2,
identifiers = listOf(identifier3, identifier4),
legalShortName = CommonValues.shortName3,
legalForm = legalForm2,
states = listOf(leBusinessStatus2),
classifications = listOf(classification3, classification4),
currentness = CommonValues.now,
createdAt = CommonValues.now,
updatedAt = CommonValues.now,
legalAddress = logisticAddress2
)
)

val legalEntityResponseGate1 = LegalEntityResponse(
Expand All @@ -235,7 +242,8 @@ object ResponseValues {
classifications = listOf(classification1, classification2),
currentness = CommonValues.now,
createdAt = CommonValues.now,
updatedAt = CommonValues.now
updatedAt = CommonValues.now,
legalAddress = logisticAddress1,
)

val legalEntityResponseGate2 = LegalEntityResponse(
Expand All @@ -247,7 +255,8 @@ object ResponseValues {
classifications = listOf(classification3, classification4),
currentness = CommonValues.now,
createdAt = CommonValues.now,
updatedAt = CommonValues.now
updatedAt = CommonValues.now,
legalAddress = logisticAddress2,
)

val legalEntityGateInputResponse1 = LegalEntityGateInputResponse(
Expand Down Expand Up @@ -288,14 +297,12 @@ object ResponseValues {
val legalEntityGateOutput1 = LegalEntityGateOutput(
legalEntity = legalEntityResponseGate1,
legalNameParts = arrayOf(CommonValues.name1),
legalAddress = logisticAddress1,
externalId = CommonValues.externalId1
)

val legalEntityGateOutput2 = LegalEntityGateOutput(
legalEntity = legalEntityResponseGate2,
legalNameParts = arrayOf(CommonValues.name3),
legalAddress = logisticAddress2,
externalId = CommonValues.externalId2
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ


@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
@Schema(name = "LegalEntityUpdateRequest", description = "Request for updating a business partner record of type legal entity")
@Schema(name = "LegalEntityPartnerUpdateRequest", description = "Request for updating a business partner record of type legal entity")
data class LegalEntityPartnerUpdateRequest(
@Schema(description = "Business Partner Number")
val bpnl: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ package org.eclipse.tractusx.bpdm.pool.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.response.LegalEntityResponse
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse
import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

Expand All @@ -32,8 +32,11 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ
data class BusinessPartnerResponse(
val uuid: String,

@get:Schema(description = "Legal name the partner goes by")
val legalName: String,

@field:JsonUnwrapped
val legalEntity: PoolLegalEntityResponse,
val legalEntity: LegalEntityResponse,

val addresses: Collection<LogisticAddressResponse>,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@

package org.eclipse.tractusx.bpdm.pool.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.response.PoolLegalEntityResponse
import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
@Schema(name = "LegalEntityMatchResponse", description = "Match with score for a business partner record of type legal entity")
data class LegalEntityMatchResponse(
@Schema(description = "Relative quality score of the match. The higher the better")
val score: Float,

@Schema(description = "Matched legal entity business partner record")
val legalEntity: PoolLegalEntityResponse
@get:Schema(description = "Legal name the partner goes by")
val legalName: String,

@field:JsonUnwrapped
val legalEntity: LegalEntityResponse
)
Loading