diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerDto.kt index 7b0d463aa..eb487f2cf 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerDto.kt @@ -53,4 +53,13 @@ interface IBaseBusinessPartnerDto { @get:Schema(name = "isOwner", description = "True if the sharing member declares itself as the owner of the business partner.") val isOwner: Boolean + + @get:Schema(description = "BPNL") + val bpnL: String? + + @get:Schema(description = "BPNS") + val bpnS: String? + + @get:Schema(description = "BPNA") + val bpnA: String? } diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt index 1e6ae8a08..b86a317e9 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt @@ -41,6 +41,10 @@ data class BusinessPartnerInputRequest( @get:Schema(description = "Address of the official seat of this business partner.") val postalAddress: BusinessPartnerPostalAddressInputDto, - override val isOwner: Boolean = false + override val isOwner: Boolean = false, + + override val bpnL: String? = null, + override val bpnS: String? = null, + override val bpnA: String? = null ) : IBaseBusinessPartnerDto diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerInputDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerInputDto.kt index f7a7062c4..e783523ba 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerInputDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerInputDto.kt @@ -42,10 +42,14 @@ data class BusinessPartnerInputDto( override val isOwner: Boolean, + override val bpnL: String?, + override val bpnS: String?, + override val bpnA: String?, + @get:Schema(description = CommonDescription.createdAt) val createdAt: Instant, @get:Schema(description = CommonDescription.updatedAt) - val updatedAt: Instant, + val updatedAt: Instant - ) : IBaseBusinessPartnerDto +) : IBaseBusinessPartnerDto diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerOutputDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerOutputDto.kt index e736caa79..b1490aa9e 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerOutputDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerOutputDto.kt @@ -42,19 +42,14 @@ data class BusinessPartnerOutputDto( override val isOwner: Boolean, - @get:Schema(description = "BPNA") - val bpna: String, - - @get:Schema(description = "BPNS") - val bpns: String?, - - @get:Schema(description = "BPNL") - val bpnl: String, + override val bpnL: String, + override val bpnS: String?, + override val bpnA: String, @get:Schema(description = CommonDescription.createdAt) val createdAt: Instant, @get:Schema(description = CommonDescription.updatedAt) - val updatedAt: Instant, + val updatedAt: Instant - ) : IBaseBusinessPartnerDto +) : IBaseBusinessPartnerDto diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt index 516187ba4..a09524564 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt @@ -43,13 +43,16 @@ class BusinessPartnerMappings { externalId = entity.externalId, nameParts = entity.nameParts, shortName = entity.shortName, - legalForm = entity.legalForm, identifiers = entity.identifiers.map(::toIdentifierDto), + legalForm = entity.legalForm, states = entity.states.map(::toStateDto), classifications = entity.classifications.map(::toClassificationDto), roles = entity.roles, postalAddress = toPostalAddressInputDto(entity.postalAddress), - isOwner = entity.isOwner ?: false, // TODO should be mandatory in entity + isOwner = entity.isOwner, + bpnL = entity.bpnL, + bpnS = entity.bpnS, + bpnA = entity.bpnA, createdAt = entity.createdAt, updatedAt = entity.updatedAt ) @@ -60,16 +63,16 @@ class BusinessPartnerMappings { externalId = entity.externalId, nameParts = entity.nameParts, shortName = entity.shortName, - legalForm = entity.legalForm, identifiers = entity.identifiers.map(::toIdentifierDto), + legalForm = entity.legalForm, states = entity.states.map(::toStateDto), classifications = entity.classifications.map(::toClassificationDto), roles = entity.roles, postalAddress = toPostalAddressOutputDto(entity.postalAddress), - isOwner = entity.isOwner ?: false, // TODO should be mandatory in entity - bpnl = entity.bpnL ?: throw NullPointerException("bpnL is null"), - bpns = entity.bpnS, - bpna = entity.bpnA ?: throw NullPointerException("bpnA is null"), + isOwner = entity.isOwner, + bpnL = entity.bpnL ?: throw NullPointerException("bpnL is null"), + bpnS = entity.bpnS, + bpnA = entity.bpnA ?: throw NullPointerException("bpnA is null"), createdAt = entity.createdAt, updatedAt = entity.updatedAt ) @@ -87,9 +90,9 @@ class BusinessPartnerMappings { shortName = dto.shortName, legalForm = dto.legalForm, isOwner = dto.isOwner, - bpnL = null, - bpnS = null, - bpnA = null, + bpnL = dto.bpnL, + bpnS = dto.bpnS, + bpnA = dto.bpnA, postalAddress = toPostalAddress(dto.postalAddress) ) } @@ -103,6 +106,9 @@ class BusinessPartnerMappings { entity.shortName = dto.shortName entity.legalForm = dto.legalForm entity.isOwner = dto.isOwner + entity.bpnL = dto.bpnL + entity.bpnS = dto.bpnS + entity.bpnA = dto.bpnA updatePostalAddress(entity.postalAddress, dto.postalAddress) } @@ -122,7 +128,7 @@ class BusinessPartnerMappings { private fun toPostalAddress(dto: BusinessPartnerPostalAddressInputDto) = PostalAddress( - addressType = dto.addressType ?: AddressType.AdditionalAddress, // TODO should be optional in entity + addressType = dto.addressType, physicalPostalAddress = dto.physicalPostalAddress.let(::toPhysicalPostalAddress), alternativePostalAddress = dto.alternativePostalAddress?.let(::toAlternativePostalAddress) )