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..b9bf812f5 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 @@ -30,27 +30,36 @@ interface IBaseBusinessPartnerDto { @get:Schema(description = CommonDescription.externalId) val externalId: String - @get:Schema(description = "") + @get:ArraySchema(arraySchema = Schema(description = "The list of name parts to accommodate the different number of name fields in different systems.")) val nameParts: List - @get:Schema(description = "Abbreviated name or shorthand") + @get:Schema(description = "Abbreviated name or shorthand.") val shortName: String? - @get:ArraySchema(arraySchema = Schema(description = "The list of identifiers of the business partner.")) + @get:ArraySchema(arraySchema = Schema(description = "The list of identifiers of the business partner. Sorted and duplicates removed by the service.")) val identifiers: Collection @get:Schema(description = "Technical key of the legal form.") val legalForm: String? - @get:ArraySchema(arraySchema = Schema(description = "The list of (temporary) states of the business partner.")) + @get:ArraySchema(arraySchema = Schema(description = "The list of (temporary) states of the business partner. Sorted and duplicates removed by the service.")) val states: Collection - @get:ArraySchema(arraySchema = Schema(description = "The list of classifications of the legal entity, such as a specific industry.")) + @get:ArraySchema(arraySchema = Schema(description = "The list of classifications of the business partner, such as a specific industry. Sorted and duplicates removed by the service.")) val classifications: Collection - @get:ArraySchema(arraySchema = Schema(description = CommonDescription.roles)) + @get:ArraySchema(arraySchema = Schema(description = "Roles this business partner takes in relation to the sharing member. Sorted and duplicates removed by the service.")) val roles: Collection @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..e4559e855 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 @@ -26,7 +26,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.* import java.time.Instant -@Schema(description = "Generic business partner output with external id", requiredProperties = ["externalId", "postalAddress", "bpna", "bpnl"]) +@Schema(description = "Generic business partner output with external id", requiredProperties = ["externalId", "postalAddress", "bpnL", "bpnA"]) data class BusinessPartnerOutputDto( override val externalId: String, override val nameParts: List = emptyList(), @@ -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..fe0aa93f1 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 @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.AlternativePostalAddressDto import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto +import org.eclipse.tractusx.bpdm.common.exception.BpdmNullMappingException import org.eclipse.tractusx.bpdm.common.model.StageType import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.* @@ -43,13 +44,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 +64,18 @@ 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 BpdmNullMappingException(BusinessPartner::class, BusinessPartnerOutputDto::class, BusinessPartner::bpnL, entity.externalId), + bpnS = entity.bpnS, + bpnA = entity.bpnA + ?: throw BpdmNullMappingException(BusinessPartner::class, BusinessPartnerOutputDto::class, BusinessPartner::bpnA, entity.externalId), createdAt = entity.createdAt, updatedAt = entity.updatedAt ) @@ -87,9 +93,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 +109,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 +131,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) )