From 325869199c8b0ab99949e8b44ab52a0b5554ca38 Mon Sep 17 00:00:00 2001 From: Martin Kaeser Date: Wed, 22 Nov 2023 12:59:27 +0100 Subject: [PATCH] Refactoring: Business Partner DTO Locations --- .../service/GenericBusinessPartnerMappings.kt | 6 +-- .../bpdm/cleaning/testdata/CommonValues.kt | 15 +++---- .../bpdm/common/dto/IBaseAddressStateDto.kt | 5 ++- .../common/dto/IBaseBusinessPartnerDto.kt | 8 ++-- .../bpdm/common/dto/IBaseClassificationDto.kt | 4 +- .../bpdm/common/dto/IBaseIdentifierDto.kt | 11 +++-- .../common/dto/IBaseLegalEntityStateDto.kt | 5 ++- .../bpdm/common/dto/IBaseSiteStateDto.kt | 5 ++- ...essPartnerStateDto.kt => IBaseStateDto.kt} | 12 +++--- ...to.kt => IBusinessPartnerIdentifierDto.kt} | 14 +++---- .../model/BusinessPartnerClassificationDto.kt | 16 +++---- .../model}/BusinessPartnerIdentifierDto.kt | 20 +++------ .../model/BusinessPartnerPostalAddressDto.kt | 2 - ...InputDto.kt => BusinessPartnerStateDto.kt} | 19 ++++----- .../request/BusinessPartnerInputRequest.kt | 13 +++--- .../request/BusinessPartnerOutputRequest.kt | 14 +++---- .../model/response/BusinessPartnerInputDto.kt | 9 ++-- .../response/BusinessPartnerOutputDto.kt | 9 ++-- .../gate/service/BusinessPartnerMappings.kt | 25 +++-------- .../bpdm/gate/service/OrchestratorMappings.kt | 42 +++++++++---------- .../controller/BusinessPartnerControllerIT.kt | 18 ++++---- .../gate/util/BusinessPartnerGenericValues.kt | 11 +++-- .../gate/util/BusinessPartnerVerboseValues.kt | 14 +++---- .../model/BusinessPartnerClassificationDto.kt | 3 ++ .../api/model/BusinessPartnerGenericDto.kt | 13 ++++-- .../api/model/BusinessPartnerIdentifierDto.kt | 30 +++++++++++++ .../api/model/BusinessPartnerStateDto.kt | 33 +++++++++++++++ .../api/model/PostalAddressDto.kt | 1 + .../testdata/BusinessPartnerTestValues.kt | 21 ++++------ 29 files changed, 207 insertions(+), 191 deletions(-) rename bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/{BusinessPartnerStateDto.kt => IBaseStateDto.kt} (81%) rename bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/{IBusinessPartnerStateDto.kt => IBusinessPartnerIdentifierDto.kt} (78%) rename bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationBusinessPartnerDto.kt => bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerClassificationDto.kt (68%) rename {bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto => bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model}/BusinessPartnerIdentifierDto.kt (64%) rename bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/{BusinessPartnerPostalAddressInputDto.kt => BusinessPartnerStateDto.kt} (59%) create mode 100644 bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerIdentifierDto.kt create mode 100644 bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerStateDto.kt diff --git a/bpdm-cleaning-service-dummy/src/main/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/GenericBusinessPartnerMappings.kt b/bpdm-cleaning-service-dummy/src/main/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/GenericBusinessPartnerMappings.kt index 3a86b4e53..391a3059f 100644 --- a/bpdm-cleaning-service-dummy/src/main/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/GenericBusinessPartnerMappings.kt +++ b/bpdm-cleaning-service-dummy/src/main/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/GenericBusinessPartnerMappings.kt @@ -20,8 +20,6 @@ package org.eclipse.tractusx.bpdm.cleaning.service -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerIdentifierDto -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerStateDto import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto import org.eclipse.tractusx.orchestrator.api.model.* @@ -36,13 +34,13 @@ fun BusinessPartnerGenericDto.toLegalEntityDto(bpnReferenceDto: BpnReferenceDto, identifiers = identifiers.mapNotNull { it.toLegalEntityIdentifierDto() }, legalForm = legalForm, states = states.mapNotNull { it.toLegalEntityState() }, - classifications = classifications.map { it.toBusinessPartnerClassificationDto() }, + classifications = classifications.map { it.toLegalEntityClassificationDto() }, legalAddress = legalAddress ) } -fun ClassificationDto.toBusinessPartnerClassificationDto(): ClassificationDto { +fun BusinessPartnerClassificationDto.toLegalEntityClassificationDto(): ClassificationDto { return ClassificationDto(code = code, type = type, value = value) } diff --git a/bpdm-cleaning-service-dummy/src/test/kotlin/org/eclipse/tractusx/bpdm/cleaning/testdata/CommonValues.kt b/bpdm-cleaning-service-dummy/src/test/kotlin/org/eclipse/tractusx/bpdm/cleaning/testdata/CommonValues.kt index eb5679963..955cb130e 100644 --- a/bpdm-cleaning-service-dummy/src/test/kotlin/org/eclipse/tractusx/bpdm/cleaning/testdata/CommonValues.kt +++ b/bpdm-cleaning-service-dummy/src/test/kotlin/org/eclipse/tractusx/bpdm/cleaning/testdata/CommonValues.kt @@ -20,19 +20,16 @@ package org.eclipse.tractusx.bpdm.cleaning.testdata import com.neovisionaries.i18n.CountryCode -import org.eclipse.tractusx.bpdm.cleaning.service.toBusinessPartnerClassificationDto +import org.eclipse.tractusx.bpdm.cleaning.service.toLegalEntityClassificationDto import org.eclipse.tractusx.bpdm.cleaning.service.toLegalEntityIdentifierDto import org.eclipse.tractusx.bpdm.cleaning.service.toLegalEntityState import org.eclipse.tractusx.bpdm.cleaning.service.toSiteState -import org.eclipse.tractusx.bpdm.common.dto.* +import org.eclipse.tractusx.bpdm.common.dto.AddressType +import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole +import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.model.BusinessStateType import org.eclipse.tractusx.bpdm.common.model.ClassificationType import org.eclipse.tractusx.orchestrator.api.model.* -import org.eclipse.tractusx.orchestrator.api.model.LegalEntityDto -import org.eclipse.tractusx.orchestrator.api.model.LogisticAddressDto -import org.eclipse.tractusx.orchestrator.api.model.PhysicalPostalAddressDto -import org.eclipse.tractusx.orchestrator.api.model.SiteDto -import org.eclipse.tractusx.orchestrator.api.model.StreetDto import java.time.LocalDateTime /** @@ -61,7 +58,7 @@ object CommonValues { ) ) private val classifications = listOf( - ClassificationDto( + BusinessPartnerClassificationDto( type = ClassificationType.NACE, code = "Code1", value = "Value1" @@ -147,7 +144,7 @@ object CommonValues { identifiers = identifiers.mapNotNull { it.toLegalEntityIdentifierDto() }, legalForm = legalForm, states = states.mapNotNull { it.toLegalEntityState() }, - classifications = classifications.map { it.toBusinessPartnerClassificationDto() } + classifications = classifications.map { it.toLegalEntityClassificationDto() } ) val expectedSiteDto = SiteDto( diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseAddressStateDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseAddressStateDto.kt index 66a7b174c..5e08a565f 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseAddressStateDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseAddressStateDto.kt @@ -25,7 +25,8 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType import java.time.LocalDateTime @Schema(description = AddressStateDescription.header) -interface IBaseAddressStateDto : IBusinessPartnerStateDto { +interface IBaseAddressStateDto : IBaseStateDto { + @get:Schema(description = AddressStateDescription.description) override val description: String? @@ -37,4 +38,4 @@ interface IBaseAddressStateDto : IBusinessPartnerStateDto { @get:Schema(description = AddressStateDescription.type) override val type: BusinessStateType -} \ No newline at end of file +} diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseBusinessPartnerDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseBusinessPartnerDto.kt index 13fd9fdd2..48aa6a450 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseBusinessPartnerDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseBusinessPartnerDto.kt @@ -31,16 +31,16 @@ interface IBaseBusinessPartnerDto { val shortName: String? @get:ArraySchema(arraySchema = Schema(description = "The list of identifiers of the business partner. Sorted and duplicates removed by the service.")) - val identifiers: Collection + val identifiers: Collection - @get:Schema(description = "") //TODO Add Description + @get:Schema(description = "The name according to official registers.") val legalName: String? @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. Sorted and duplicates removed by the service.")) - val states: Collection + val states: Collection @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 @@ -51,6 +51,7 @@ interface IBaseBusinessPartnerDto { @get:Schema(description = "Address of the official seat of this business partner.") val postalAddress: IBaseBusinessPartnerPostalAddressDto + // TODO: rename to bpnL, bpnS, bpnA (breaking change!) @get:Schema(description = "BPNL of the golden record legal entity this business partner refers to") val legalEntityBpn: String? @@ -59,5 +60,4 @@ interface IBaseBusinessPartnerDto { @get:Schema(description = "BPNA of the golden record address this business partner refers to") val addressBpn: String? - } diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseClassificationDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseClassificationDto.kt index 3f07224b8..7e6acb52c 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseClassificationDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseClassificationDto.kt @@ -23,8 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.openapidescription.ClassificationDescription import org.eclipse.tractusx.bpdm.common.model.ClassificationType -@Schema(description = ClassificationDescription.header) interface IBaseClassificationDto { + @get:Schema(description = ClassificationDescription.type) val type: ClassificationType? @@ -33,4 +33,4 @@ interface IBaseClassificationDto { @get:Schema(description = ClassificationDescription.value) val value: String? -} \ No newline at end of file +} diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseIdentifierDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseIdentifierDto.kt index d1bff3c6f..d8a1b7b70 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseIdentifierDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseIdentifierDto.kt @@ -19,8 +19,13 @@ package org.eclipse.tractusx.bpdm.common.dto +import io.swagger.v3.oas.annotations.media.Schema + interface IBaseIdentifierDto { - val value: String - val type: String -} \ No newline at end of file + @get:Schema(description = "Technical key of the type to which this identifier belongs to") + val type: String? + + @get:Schema(description = "Value of the identifier") + val value: String? +} diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseLegalEntityStateDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseLegalEntityStateDto.kt index 8ba5cd94f..8cf495e2f 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseLegalEntityStateDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseLegalEntityStateDto.kt @@ -25,7 +25,8 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType import java.time.LocalDateTime @Schema(description = LegalEntityStateDescription.header) -interface IBaseLegalEntityStateDto : IBusinessPartnerStateDto { +interface IBaseLegalEntityStateDto : IBaseStateDto { + @get:Schema(description = LegalEntityStateDescription.description) override val description: String? @@ -37,4 +38,4 @@ interface IBaseLegalEntityStateDto : IBusinessPartnerStateDto { @get:Schema(description = LegalEntityStateDescription.type) override val type: BusinessStateType -} \ No newline at end of file +} diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseSiteStateDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseSiteStateDto.kt index 4a97fba3a..58a385584 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseSiteStateDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseSiteStateDto.kt @@ -26,7 +26,8 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType import java.time.LocalDateTime @Schema(description = SiteDescription.header) -interface IBaseSiteStateDto : IBusinessPartnerStateDto { +interface IBaseSiteStateDto : IBaseStateDto { + @get:Schema(description = SiteStateDescription.description) override val description: String? @@ -38,4 +39,4 @@ interface IBaseSiteStateDto : IBusinessPartnerStateDto { @get:Schema(description = SiteStateDescription.type) override val type: BusinessStateType -} \ No newline at end of file +} diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerStateDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseStateDto.kt similarity index 81% rename from bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerStateDto.kt rename to bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseStateDto.kt index 7684bdfbe..86ee85b8f 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerStateDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseStateDto.kt @@ -20,22 +20,20 @@ package org.eclipse.tractusx.bpdm.common.dto import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityStateDescription import org.eclipse.tractusx.bpdm.common.model.BusinessStateType import java.time.LocalDateTime -@Schema(description = LegalEntityStateDescription.header, requiredProperties = ["type"]) -data class BusinessPartnerStateDto( +interface IBaseStateDto { @get:Schema(description = "Date since when the status is/was valid.") - val validFrom: LocalDateTime?, + val validFrom: LocalDateTime? @get:Schema(description = "Date until the status was valid, if applicable.") - val validTo: LocalDateTime?, + val validTo: LocalDateTime? @get:Schema(description = "The type of this specified status.") - val type: BusinessStateType?, + val type: BusinessStateType? @get:Schema(description = "Denotation of the status.") val description: String? -) +} diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBusinessPartnerStateDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBusinessPartnerIdentifierDto.kt similarity index 78% rename from bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBusinessPartnerStateDto.kt rename to bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBusinessPartnerIdentifierDto.kt index b83c65c41..11126d45d 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBusinessPartnerStateDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBusinessPartnerIdentifierDto.kt @@ -19,12 +19,10 @@ package org.eclipse.tractusx.bpdm.common.dto -import org.eclipse.tractusx.bpdm.common.model.BusinessStateType -import java.time.LocalDateTime +import io.swagger.v3.oas.annotations.media.Schema -interface IBusinessPartnerStateDto { - val description: String? - val validFrom: LocalDateTime? - val validTo: LocalDateTime? - val type: BusinessStateType -} \ No newline at end of file +interface IBusinessPartnerIdentifierDto : IBaseIdentifierDto { + + @get:Schema(description = "Body which issued the identifier") + val issuingBody: String? +} diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationBusinessPartnerDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerClassificationDto.kt similarity index 68% rename from bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationBusinessPartnerDto.kt rename to bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerClassificationDto.kt index daa42f032..9ff59ddf0 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationBusinessPartnerDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerClassificationDto.kt @@ -17,21 +17,15 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.common.dto +package org.eclipse.tractusx.bpdm.gate.api.model -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.openapidescription.ClassificationDescription +import org.eclipse.tractusx.bpdm.common.dto.IBaseClassificationDto import org.eclipse.tractusx.bpdm.common.model.ClassificationType -@Schema(description = ClassificationDescription.header) -data class ClassificationBusinessPartnerDto( +data class BusinessPartnerClassificationDto( - @get:Schema(description = ClassificationDescription.type) override val type: ClassificationType?, - - @get:Schema(description = ClassificationDescription.code) override val code: String?, - - @get:Schema(description = ClassificationDescription.value) override val value: String? -) : IBaseClassificationDto \ No newline at end of file + +) : IBaseClassificationDto diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerIdentifierDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerIdentifierDto.kt similarity index 64% rename from bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerIdentifierDto.kt rename to bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerIdentifierDto.kt index 8bc6508b9..0b2cb184c 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerIdentifierDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerIdentifierDto.kt @@ -17,22 +17,14 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.common.dto +package org.eclipse.tractusx.bpdm.gate.api.model -import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.IBusinessPartnerIdentifierDto -@Schema( - description = "Identifier record for a business partner", - requiredProperties = ["type", "value"] -) data class BusinessPartnerIdentifierDto( - @get:Schema(description = "Technical key of the type to which this identifier belongs to") - val type: String? = null, + override val type: String?, + override val value: String?, + override val issuingBody: String? - @get:Schema(description = "Value of the identifier") - val value: String? = null, - - @get:Schema(description = "Body which issued the identifier") - val issuingBody: String? -) +) : IBusinessPartnerIdentifierDto diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerPostalAddressDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerPostalAddressDto.kt index 78a46f5bd..6e56a96ab 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerPostalAddressDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerPostalAddressDto.kt @@ -19,11 +19,9 @@ package org.eclipse.tractusx.bpdm.gate.api.model -import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.AddressType import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerPostalAddressDto -@Schema(description = "Postal address of a business partner") data class BusinessPartnerPostalAddressDto( override val addressType: AddressType? = null, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerPostalAddressInputDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerStateDto.kt similarity index 59% rename from bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerPostalAddressInputDto.kt rename to bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerStateDto.kt index 5e1437342..b15c62d0a 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerPostalAddressInputDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerStateDto.kt @@ -19,16 +19,15 @@ package org.eclipse.tractusx.bpdm.gate.api.model -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.AddressType -import org.eclipse.tractusx.bpdm.common.dto.AlternativePostalAddressDto -import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerPostalAddressDto +import org.eclipse.tractusx.bpdm.common.dto.IBaseStateDto +import org.eclipse.tractusx.bpdm.common.model.BusinessStateType +import java.time.LocalDateTime -@Schema(description = "Postal address of a input business partner", requiredProperties = ["physicalPostalAddress"]) -data class BusinessPartnerPostalAddressInputDto( +data class BusinessPartnerStateDto( - override val addressType: AddressType?, - override val physicalPostalAddress: PhysicalPostalAddressGateDto, - override val alternativePostalAddress: AlternativePostalAddressDto? = null + override val validFrom: LocalDateTime?, + override val validTo: LocalDateTime?, + override val type: BusinessStateType?, + override val description: String? -) : IBaseBusinessPartnerPostalAddressDto +) : IBaseStateDto 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 0f4b5e44d..03447caaa 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 @@ -20,18 +20,15 @@ package org.eclipse.tractusx.bpdm.gate.api.model.request import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerIdentifierDto import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerStateDto -import org.eclipse.tractusx.bpdm.common.dto.ClassificationBusinessPartnerDto -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerPostalAddressDto -import org.eclipse.tractusx.bpdm.gate.api.model.IBaseBusinessPartnerGateDto +import org.eclipse.tractusx.bpdm.gate.api.model.* @Schema( description = "Generic business partner with external id", requiredProperties = ["externalId"] ) data class BusinessPartnerInputRequest( + override val externalId: String, override val nameParts: List = emptyList(), override val shortName: String? = null, @@ -39,12 +36,12 @@ data class BusinessPartnerInputRequest( override val legalName: String? = null, override val legalForm: String? = null, override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), + override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), override val postalAddress: BusinessPartnerPostalAddressDto = BusinessPartnerPostalAddressDto(), override val isOwnCompanyData: Boolean = false, override val legalEntityBpn: String? = null, override val siteBpn: String? = null, - override val addressBpn: String? = null, + override val addressBpn: String? = null - ) : IBaseBusinessPartnerGateDto +) : IBaseBusinessPartnerGateDto diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerOutputRequest.kt index cb48a241d..1a1666b98 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerOutputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerOutputRequest.kt @@ -20,17 +20,13 @@ package org.eclipse.tractusx.bpdm.gate.api.model.request import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerIdentifierDto import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerStateDto -import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerPostalAddressDto -import org.eclipse.tractusx.bpdm.gate.api.model.IBaseBusinessPartnerGateDto +import org.eclipse.tractusx.bpdm.gate.api.model.* @Schema( description = "Generic business partner with external id", - requiredProperties = ["externalId", "postalAddress"] + requiredProperties = ["externalId"] ) data class BusinessPartnerOutputRequest( @@ -41,12 +37,12 @@ data class BusinessPartnerOutputRequest( override val legalName: String? = null, override val legalForm: String? = null, override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), + override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), override val postalAddress: BusinessPartnerPostalAddressDto = BusinessPartnerPostalAddressDto(), override val isOwnCompanyData: Boolean = false, override val legalEntityBpn: String? = null, override val siteBpn: String? = null, - override val addressBpn: String? = null, + override val addressBpn: String? = null - ) : IBaseBusinessPartnerGateDto \ No newline at end of file +) : IBaseBusinessPartnerGateDto 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 65a90b4fe..2533140c5 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 @@ -20,13 +20,9 @@ package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerIdentifierDto import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerStateDto -import org.eclipse.tractusx.bpdm.common.dto.ClassificationBusinessPartnerDto import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerPostalAddressDto -import org.eclipse.tractusx.bpdm.gate.api.model.IBaseBusinessPartnerGateDto +import org.eclipse.tractusx.bpdm.gate.api.model.* import java.time.Instant @@ -35,6 +31,7 @@ import java.time.Instant requiredProperties = ["externalId", "postalAddress"] ) data class BusinessPartnerInputDto( + override val externalId: String, override val nameParts: List = emptyList(), override val shortName: String?, @@ -42,7 +39,7 @@ data class BusinessPartnerInputDto( override val legalName: String? = null, override val legalForm: String? = null, override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), + override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), override val postalAddress: BusinessPartnerPostalAddressDto, override val isOwnCompanyData: Boolean, 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 0cf6decac..fbb2470c8 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 @@ -20,13 +20,9 @@ package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerIdentifierDto import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerStateDto -import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerPostalAddressDto -import org.eclipse.tractusx.bpdm.gate.api.model.IBaseBusinessPartnerGateDto +import org.eclipse.tractusx.bpdm.gate.api.model.* import java.time.Instant @Schema( @@ -34,6 +30,7 @@ import java.time.Instant requiredProperties = ["externalId", "postalAddress", "bpnL", "bpnA"] ) data class BusinessPartnerOutputDto( + override val externalId: String, override val nameParts: List = emptyList(), override val shortName: String?, @@ -41,7 +38,7 @@ data class BusinessPartnerOutputDto( override val legalName: String? = null, override val legalForm: String? = null, override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), + override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), override val postalAddress: BusinessPartnerPostalAddressDto, override val isOwnCompanyData: Boolean, 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 f1447b7e4..fd1410f15 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 @@ -19,13 +19,10 @@ package org.eclipse.tractusx.bpdm.gate.service -import org.eclipse.tractusx.bpdm.common.dto.* +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.gate.api.model.AlternativePostalAddressGateDto -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerPostalAddressDto -import org.eclipse.tractusx.bpdm.gate.api.model.PhysicalPostalAddressGateDto -import org.eclipse.tractusx.bpdm.gate.api.model.StreetGateDto +import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerInputDto @@ -49,7 +46,7 @@ class BusinessPartnerMappings { legalName = entity.legalName, legalForm = entity.legalForm, states = entity.states.map(::toStateDto), - classifications = entity.classifications.map(::toClassificationNullableDto), + classifications = entity.classifications.map(::toClassificationDto), roles = entity.roles, postalAddress = toPostalAddressDto(entity.postalAddress), isOwnCompanyData = entity.isOwnCompanyData, @@ -115,7 +112,7 @@ class BusinessPartnerMappings { roles = dto.roles.toSortedSet(), identifiers = dto.identifiers.mapNotNull(::toIdentifier).toSortedSet(), states = dto.states.mapNotNull(::toState).toSortedSet(), - classifications = dto.classifications.map(::toClassificationOutput).toSortedSet(), + classifications = dto.classifications.mapNotNull(::toClassification).toSortedSet(), shortName = dto.shortName, legalName = dto.legalName, legalForm = dto.legalForm, @@ -255,25 +252,15 @@ class BusinessPartnerMappings { private fun toState(dto: BusinessPartnerStateDto) = dto.type?.let { State(type = it, validFrom = dto.validFrom, validTo = dto.validTo, description = dto.description) } - private fun toClassificationNullableDto(entity: Classification) = - ClassificationBusinessPartnerDto(type = entity.type, code = entity.code, value = entity.value) - private fun toClassificationDto(entity: Classification) = - ClassificationDto(type = entity.type, code = entity.code, value = entity.value) - + BusinessPartnerClassificationDto(type = entity.type, code = entity.code, value = entity.value) - private fun toClassification(dto: ClassificationBusinessPartnerDto) = + private fun toClassification(dto: BusinessPartnerClassificationDto) = dto.type?.let { Classification(type = it, code = dto.code, value = dto.value) } - private fun toClassificationOutput(dto: ClassificationDto) = - Classification(type = dto.type, code = dto.code, value = dto.value) - private fun toGeoCoordinateDto(entity: GeographicCoordinate) = GeoCoordinateDto(latitude = entity.latitude, longitude = entity.longitude, altitude = entity.altitude) - private fun toGeographicCoordinate(dto: GeoCoordinateDto) = GeographicCoordinate(latitude = dto.latitude, longitude = dto.longitude, altitude = dto.altitude) - - } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OrchestratorMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OrchestratorMappings.kt index 27e6286c8..21b273000 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OrchestratorMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OrchestratorMappings.kt @@ -20,9 +20,6 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerIdentifierDto -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerStateDto -import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.model.StageType import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType @@ -40,6 +37,7 @@ class OrchestratorMappings( private val bpnConfigProperties: BpnConfigProperties ) { private val logger = KotlinLogging.logger { } + fun toBusinessPartnerGenericDto(entity: BusinessPartner) = BusinessPartnerGenericDto( nameParts = entity.nameParts, shortName = entity.shortName, @@ -57,7 +55,7 @@ class OrchestratorMappings( ) private fun toClassificationDto(entity: Classification) = - ClassificationDto(type = entity.type, code = entity.code, value = entity.value) + BusinessPartnerClassificationDto(type = entity.type, code = entity.code, value = entity.value) private fun toPostalAddressDto(entity: PostalAddress) = PostalAddressDto( @@ -131,20 +129,20 @@ class OrchestratorMappings( } //Mapping BusinessPartnerGenericDto from to BusinessPartner - fun toBusinessPartner(entity: BusinessPartnerGenericDto, externalId: String) = BusinessPartner( + fun toBusinessPartner(dto: BusinessPartnerGenericDto, externalId: String) = BusinessPartner( externalId = externalId, - nameParts = entity.nameParts.toMutableList(), - shortName = entity.shortName, - identifiers = entity.identifiers.mapNotNull { toIdentifier(it) }.toSortedSet(), - legalName = entity.legalName, - legalForm = entity.legalForm, - states = entity.states.mapNotNull { toState(it) }.toSortedSet(), - classifications = entity.classifications.map { toClassification(it) }.toSortedSet(), - roles = entity.roles.toSortedSet(), - postalAddress = toPostalAddress(entity.postalAddress), - bpnL = entity.legalEntityBpn, - bpnS = entity.siteBpn, - bpnA = entity.addressBpn, + nameParts = dto.nameParts.toMutableList(), + shortName = dto.shortName, + identifiers = dto.identifiers.mapNotNull { toIdentifier(it) }.toSortedSet(), + legalName = dto.legalName, + legalForm = dto.legalForm, + states = dto.states.mapNotNull { toState(it) }.toSortedSet(), + classifications = dto.classifications.map { toClassification(it) }.toSortedSet(), + roles = dto.roles.toSortedSet(), + postalAddress = toPostalAddress(dto.postalAddress), + bpnL = dto.legalEntityBpn, + bpnS = dto.siteBpn, + bpnA = dto.addressBpn, stage = StageType.Output ) @@ -158,14 +156,14 @@ class OrchestratorMappings( private fun toState(dto: BusinessPartnerStateDto) = dto.type?.let { State(type = it, validFrom = dto.validFrom, validTo = dto.validTo, description = dto.description) } - private fun toClassification(dto: ClassificationDto) = + private fun toClassification(dto: BusinessPartnerClassificationDto) = Classification(type = dto.type, code = dto.code, value = dto.value) - private fun toPostalAddress(entity: PostalAddressDto) = + private fun toPostalAddress(dto: PostalAddressDto) = PostalAddress( - addressType = entity.addressType, - physicalPostalAddress = entity.physicalPostalAddress?.let(::toPhysicalPostalAddress), - alternativePostalAddress = entity.alternativePostalAddress?.let(this::toAlternativePostalAddress) + addressType = dto.addressType, + physicalPostalAddress = dto.physicalPostalAddress?.let(::toPhysicalPostalAddress), + alternativePostalAddress = dto.alternativePostalAddress?.let(this::toAlternativePostalAddress) ) private fun toPhysicalPostalAddress(dto: PhysicalPostalAddressDto) = diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt index 3a33ad2c5..91279a515 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt @@ -29,6 +29,9 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.exception.BpdmNullMappingException import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerClassificationDto +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerIdentifierDto +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerStateDto import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerOutputRequest @@ -328,7 +331,7 @@ class BusinessPartnerControllerIT @Autowired constructor( legalName = request.legalName, legalForm = request.legalForm, states = request.states.toSortedSet(stateDtoComparator), - classifications = request.classifications.toSortedSet(classificationDtoOutputComparator), + classifications = request.classifications.toSortedSet(classificationDtoComparator), roles = request.roles.toSortedSet(), postalAddress = request.postalAddress, isOwnCompanyData = request.isOwnCompanyData, @@ -355,21 +358,16 @@ class BusinessPartnerControllerIT @Autowired constructor( BusinessPartnerIdentifierDto::value, BusinessPartnerIdentifierDto::issuingBody ) + val stateDtoComparator = compareBy(nullsFirst(), BusinessPartnerStateDto::validFrom) // here null means MIN .thenBy(nullsLast(), BusinessPartnerStateDto::validTo) // here null means MAX .thenBy(BusinessPartnerStateDto::type) .thenBy(BusinessPartnerStateDto::description) val classificationDtoComparator = compareBy( - ClassificationBusinessPartnerDto::type, - ClassificationBusinessPartnerDto::code, - ClassificationBusinessPartnerDto::value - ) - - val classificationDtoOutputComparator = compareBy( - ClassificationDto::type, - ClassificationDto::code, - ClassificationDto::value + BusinessPartnerClassificationDto::type, + BusinessPartnerClassificationDto::code, + BusinessPartnerClassificationDto::value ) private fun mockOrchestratorApi() { diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerGenericValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerGenericValues.kt index 502169b27..284f4f783 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerGenericValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerGenericValues.kt @@ -20,14 +20,13 @@ package org.eclipse.tractusx.bpdm.gate.util import com.neovisionaries.i18n.CountryCode -import org.eclipse.tractusx.bpdm.common.dto.* +import org.eclipse.tractusx.bpdm.common.dto.AddressType +import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole +import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.model.BusinessStateType import org.eclipse.tractusx.bpdm.common.model.ClassificationType import org.eclipse.tractusx.bpdm.common.model.DeliveryServiceType import org.eclipse.tractusx.orchestrator.api.model.* -import org.eclipse.tractusx.orchestrator.api.model.AlternativePostalAddressDto -import org.eclipse.tractusx.orchestrator.api.model.PhysicalPostalAddressDto -import org.eclipse.tractusx.orchestrator.api.model.StreetDto import java.time.LocalDateTime object BusinessPartnerGenericMockValues { @@ -65,12 +64,12 @@ object BusinessPartnerGenericMockValues { ) ), classifications = listOf( - ClassificationDto( + BusinessPartnerClassificationDto( type = ClassificationType.NACE, code = "code-1-cleaned", value = "value-1-cleaned" ), - ClassificationDto( + BusinessPartnerClassificationDto( type = ClassificationType.NAF, code = "code-2-cleaned", value = "value-2-cleaned" diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerVerboseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerVerboseValues.kt index 9191eb6ef..2cd8982b2 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerVerboseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerVerboseValues.kt @@ -156,31 +156,31 @@ object BusinessPartnerVerboseValues { name = CountryCode.US.getName() ) - val bpClassification1 = ClassificationBusinessPartnerDto( + val bpClassification1 = BusinessPartnerClassificationDto( type = ClassificationType.NACE, code = "code1", value = "Sale of motor vehicles" ) - val bpClassification2 = ClassificationBusinessPartnerDto( + val bpClassification2 = BusinessPartnerClassificationDto( type = ClassificationType.NACE, code = "code2", value = "Data processing, hosting and related activities" ) - val bpClassification3 = ClassificationBusinessPartnerDto( + val bpClassification3 = BusinessPartnerClassificationDto( type = ClassificationType.NACE, code = "code3", value = "Other information service activities" ) - val bpClassification4 = ClassificationBusinessPartnerDto( + val bpClassification4 = BusinessPartnerClassificationDto( type = ClassificationType.NACE, code = "code4", value = "Financial and insurance activities" ) - val bpClassificationChina = ClassificationBusinessPartnerDto( + val bpClassificationChina = BusinessPartnerClassificationDto( type = ClassificationType.NACE, code = "code3", value = "北京市" @@ -835,12 +835,12 @@ object BusinessPartnerVerboseValues { ), ), classifications = listOf( - ClassificationDto( + BusinessPartnerClassificationDto( type = ClassificationType.NACE, code = "code-1-cleaned", value = "value-1-cleaned" ), - ClassificationDto( + BusinessPartnerClassificationDto( type = ClassificationType.NAF, code = "code-2-cleaned", value = "value-2-cleaned" diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerClassificationDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerClassificationDto.kt index 7caed1955..ed39e39cc 100644 --- a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerClassificationDto.kt +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerClassificationDto.kt @@ -19,10 +19,13 @@ package org.eclipse.tractusx.orchestrator.api.model +import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.IBaseClassificationDto import org.eclipse.tractusx.bpdm.common.model.ClassificationType +@Schema(requiredProperties = ["type"]) data class BusinessPartnerClassificationDto( + override val type: ClassificationType, override val code: String?, override val value: String? diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerGenericDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerGenericDto.kt index b6eecb6f3..043f7368b 100644 --- a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerGenericDto.kt +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerGenericDto.kt @@ -20,17 +20,22 @@ package org.eclipse.tractusx.orchestrator.api.model import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.* +import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole +import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerDto +@Schema( + description = "Generic business partner with external id" +) data class BusinessPartnerGenericDto( + override val nameParts: List = emptyList(), override val shortName: String? = null, override val identifiers: Collection = emptyList(), override val legalName: String? = null, override val legalForm: String? = null, override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), + override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), override val postalAddress: PostalAddressDto = PostalAddressDto(), override val legalEntityBpn: String? = null, @@ -38,6 +43,6 @@ data class BusinessPartnerGenericDto( override val addressBpn: String? = null, @get:Schema(description = "The BPNL of the company sharing and claiming this business partner as its own") - val ownerBpnL: String? = null, + val ownerBpnL: String? = null - ) : IBaseBusinessPartnerDto +) : IBaseBusinessPartnerDto diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerIdentifierDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerIdentifierDto.kt new file mode 100644 index 000000000..907cb92b8 --- /dev/null +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerIdentifierDto.kt @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.orchestrator.api.model + +import org.eclipse.tractusx.bpdm.common.dto.IBusinessPartnerIdentifierDto + +data class BusinessPartnerIdentifierDto( + + override val type: String?, + override val value: String?, + override val issuingBody: String? + +) : IBusinessPartnerIdentifierDto diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerStateDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerStateDto.kt new file mode 100644 index 000000000..cb4222986 --- /dev/null +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/BusinessPartnerStateDto.kt @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.orchestrator.api.model + +import org.eclipse.tractusx.bpdm.common.dto.IBaseStateDto +import org.eclipse.tractusx.bpdm.common.model.BusinessStateType +import java.time.LocalDateTime + +data class BusinessPartnerStateDto( + + override val validFrom: LocalDateTime?, + override val validTo: LocalDateTime?, + override val type: BusinessStateType?, + override val description: String? + +) : IBaseStateDto diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/PostalAddressDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/PostalAddressDto.kt index 0909c11cf..a480b0800 100644 --- a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/PostalAddressDto.kt +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/PostalAddressDto.kt @@ -23,6 +23,7 @@ import org.eclipse.tractusx.bpdm.common.dto.AddressType import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerPostalAddressDto data class PostalAddressDto( + override val addressType: AddressType? = null, override val physicalPostalAddress: PhysicalPostalAddressDto? = null, override val alternativePostalAddress: AlternativePostalAddressDto? = null diff --git a/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/testdata/BusinessPartnerTestValues.kt b/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/testdata/BusinessPartnerTestValues.kt index 1b1d7a87a..7b59dedee 100644 --- a/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/testdata/BusinessPartnerTestValues.kt +++ b/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/testdata/BusinessPartnerTestValues.kt @@ -20,21 +20,14 @@ package org.eclipse.tractusx.bpdm.orchestrator.testdata import com.neovisionaries.i18n.CountryCode -import org.eclipse.tractusx.bpdm.common.dto.* +import org.eclipse.tractusx.bpdm.common.dto.AddressType +import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole +import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto +import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.model.BusinessStateType import org.eclipse.tractusx.bpdm.common.model.ClassificationType import org.eclipse.tractusx.bpdm.common.model.DeliveryServiceType import org.eclipse.tractusx.orchestrator.api.model.* -import org.eclipse.tractusx.orchestrator.api.model.AddressIdentifierDto -import org.eclipse.tractusx.orchestrator.api.model.AddressStateDto -import org.eclipse.tractusx.orchestrator.api.model.AlternativePostalAddressDto -import org.eclipse.tractusx.orchestrator.api.model.LegalEntityDto -import org.eclipse.tractusx.orchestrator.api.model.LegalEntityIdentifierDto -import org.eclipse.tractusx.orchestrator.api.model.LogisticAddressDto -import org.eclipse.tractusx.orchestrator.api.model.PhysicalPostalAddressDto -import org.eclipse.tractusx.orchestrator.api.model.SiteDto -import org.eclipse.tractusx.orchestrator.api.model.SiteStateDto -import org.eclipse.tractusx.orchestrator.api.model.StreetDto import java.time.LocalDateTime /** @@ -76,12 +69,12 @@ object BusinessPartnerTestValues { ) ), classifications = listOf( - ClassificationDto( + BusinessPartnerClassificationDto( type = ClassificationType.NACE, code = "code-1", value = "value-1" ), - ClassificationDto( + BusinessPartnerClassificationDto( type = ClassificationType.NAF, code = "code-2", value = "value-2" @@ -158,7 +151,7 @@ object BusinessPartnerTestValues { ) ), classifications = listOf( - ClassificationDto( + BusinessPartnerClassificationDto( type = ClassificationType.SIC, code = "code-2", value = "value-2"