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 1cc1fef71..3a86b4e53 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 @@ -33,33 +33,38 @@ fun BusinessPartnerGenericDto.toLegalEntityDto(bpnReferenceDto: BpnReferenceDto, hasChanged = true, legalName = nameParts.joinToString(" "), legalShortName = shortName, - identifiers = identifiers.map { it.toLegalEntityIdentifierDto() }, + identifiers = identifiers.mapNotNull { it.toLegalEntityIdentifierDto() }, legalForm = legalForm, - states = states.map { it.toLegalEntityState() }, + states = states.mapNotNull { it.toLegalEntityState() }, classifications = classifications.map { it.toBusinessPartnerClassificationDto() }, legalAddress = legalAddress ) } -fun ClassificationDto.toBusinessPartnerClassificationDto(): BusinessPartnerClassificationDto { +fun ClassificationDto.toBusinessPartnerClassificationDto(): ClassificationDto { - return BusinessPartnerClassificationDto(code = code, type = type, value = value) + return ClassificationDto(code = code, type = type, value = value) } -fun BusinessPartnerIdentifierDto.toLegalEntityIdentifierDto(): LegalEntityIdentifierDto { +fun BusinessPartnerIdentifierDto.toLegalEntityIdentifierDto(): LegalEntityIdentifierDto? { + + return value?.let { value -> + type?.let { type -> + LegalEntityIdentifierDto(value = value, type = type, issuingBody = issuingBody) + } + } - return LegalEntityIdentifierDto(value = value, type = type, issuingBody = issuingBody) } -fun BusinessPartnerStateDto.toLegalEntityState(): LegalEntityState { +fun BusinessPartnerStateDto.toLegalEntityState(): LegalEntityState? { - return LegalEntityState(description, validFrom, validTo, type) + return type?.let { LegalEntityState(description, validFrom, validTo, it) } } -fun BusinessPartnerStateDto.toSiteState(): SiteStateDto { +fun BusinessPartnerStateDto.toSiteState(): SiteStateDto? { - return SiteStateDto(description, validFrom, validTo, type) + return type?.let { SiteStateDto(description, validFrom, validTo, it) } } fun BusinessPartnerGenericDto.toLogisticAddressDto(bpnReferenceDto: BpnReferenceDto): @@ -82,7 +87,7 @@ fun BusinessPartnerGenericDto.toSiteDto(bpnReferenceDto: BpnReferenceDto, legalN bpnSReference = bpnReferenceDto, hasChanged = true, name = legalName, - states = states.map { it.toSiteState() }, + states = states.mapNotNull { it.toSiteState() }, mainAddress = siteAddressReference ) 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 3cb5b8f1c..a263c8d64 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 @@ -144,16 +144,16 @@ object CommonValues { hasChanged = true, legalName = nameParts.joinToString(" "), legalShortName = shortName, - identifiers = identifiers.map { it.toLegalEntityIdentifierDto() }, + identifiers = identifiers.mapNotNull { it.toLegalEntityIdentifierDto() }, legalForm = legalForm, - states = states.map { it.toLegalEntityState() }, + states = states.mapNotNull { it.toLegalEntityState() }, classifications = classifications.map { it.toBusinessPartnerClassificationDto() } ) val expectedSiteDto = SiteDto( hasChanged = true, name = nameParts.joinToString(" "), - states = states.map { it.toSiteState() }, + states = states.mapNotNull { it.toSiteState() }, ) val expectedLogisticAddressDto = LogisticAddressDto( diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerIdentifierDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerIdentifierDto.kt index 6b700c5f7..8bc6508b9 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerIdentifierDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerIdentifierDto.kt @@ -28,10 +28,10 @@ import io.swagger.v3.oas.annotations.media.Schema data class BusinessPartnerIdentifierDto( @get:Schema(description = "Technical key of the type to which this identifier belongs to") - val type: String, + val type: String? = null, @get:Schema(description = "Value of the identifier") - val value: String, + val value: String? = null, @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/BusinessPartnerStateDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BusinessPartnerStateDto.kt index b7ad2c0f9..7684bdfbe 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/BusinessPartnerStateDto.kt @@ -34,7 +34,7 @@ data class BusinessPartnerStateDto( 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/ClassificationBusinessPartnerDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationBusinessPartnerDto.kt new file mode 100644 index 000000000..daa42f032 --- /dev/null +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/ClassificationBusinessPartnerDto.kt @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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 +import org.eclipse.tractusx.bpdm.common.dto.openapidescription.ClassificationDescription +import org.eclipse.tractusx.bpdm.common.model.ClassificationType + +@Schema(description = ClassificationDescription.header) +data class ClassificationBusinessPartnerDto( + + @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 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 24ac73e4f..0cbb78138 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 @@ -40,7 +40,7 @@ interface IBaseBusinessPartnerDto { 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 + val classifications: Collection @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 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 570a3f32b..3f07224b8 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 @@ -26,7 +26,7 @@ import org.eclipse.tractusx.bpdm.common.model.ClassificationType @Schema(description = ClassificationDescription.header) interface IBaseClassificationDto { @get:Schema(description = ClassificationDescription.type) - val type: ClassificationType + val type: ClassificationType? @get:Schema(description = ClassificationDescription.code) val code: 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 bb32084aa..24214d09b 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 @@ -23,7 +23,7 @@ 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.ClassificationBusinessPartnerDto import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerPostalAddressDto import org.eclipse.tractusx.bpdm.gate.api.model.IBaseBusinessPartnerGateDto @@ -38,7 +38,7 @@ data class BusinessPartnerInputRequest( override val identifiers: Collection = emptyList(), 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, @@ -46,4 +46,4 @@ data class BusinessPartnerInputRequest( override val bpnS: String? = null, override val bpnA: String? = null, -) : IBaseBusinessPartnerGateDto + ) : 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 46ba2fb2e..c15a54459 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 @@ -23,7 +23,7 @@ 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.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 @@ -41,7 +41,7 @@ data class BusinessPartnerInputDto( override val identifiers: Collection = emptyList(), 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 362941083..83510ed54 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,10 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.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.bpdm.common.dto.GeoCoordinateDto +import org.eclipse.tractusx.bpdm.common.dto.* 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 @@ -51,7 +48,7 @@ class BusinessPartnerMappings { identifiers = entity.identifiers.map(::toIdentifierDto), legalForm = entity.legalForm, states = entity.states.map(::toStateDto), - classifications = entity.classifications.map(::toClassificationDto), + classifications = entity.classifications.map(::toClassificationNullableDto), roles = entity.roles, postalAddress = toPostalAddressDto(entity.postalAddress), isOwnCompanyData = entity.isOwnCompanyData, @@ -91,9 +88,9 @@ class BusinessPartnerMappings { externalId = dto.externalId, nameParts = dto.nameParts.toMutableList(), roles = dto.roles.toSortedSet(), - identifiers = dto.identifiers.map(::toIdentifier).toSortedSet(), - states = dto.states.map(::toState).toSortedSet(), - classifications = dto.classifications.map(::toClassification).toSortedSet(), + identifiers = dto.identifiers.mapNotNull(::toIdentifier).toSortedSet(), + states = dto.states.mapNotNull(::toState).toSortedSet(), + classifications = dto.classifications.mapNotNull(::toClassification).toSortedSet(), shortName = dto.shortName, legalForm = dto.legalForm, isOwnCompanyData = dto.isOwnCompanyData, @@ -113,9 +110,9 @@ class BusinessPartnerMappings { externalId = dto.externalId, nameParts = dto.nameParts.toMutableList(), roles = dto.roles.toSortedSet(), - identifiers = dto.identifiers.map(::toIdentifier).toSortedSet(), - states = dto.states.map(::toState).toSortedSet(), - classifications = dto.classifications.map(::toClassification).toSortedSet(), + identifiers = dto.identifiers.mapNotNull(::toIdentifier).toSortedSet(), + states = dto.states.mapNotNull(::toState).toSortedSet(), + classifications = dto.classifications.map(::toClassificationOutput).toSortedSet(), shortName = dto.shortName, legalForm = dto.legalForm, isOwnCompanyData = dto.isOwnCompanyData, @@ -242,18 +239,29 @@ class BusinessPartnerMappings { BusinessPartnerIdentifierDto(type = entity.type, value = entity.value, issuingBody = entity.issuingBody) private fun toIdentifier(dto: BusinessPartnerIdentifierDto) = - Identifier(type = dto.type, value = dto.value, issuingBody = dto.issuingBody) + dto.type?.let { type -> + dto.value?.let { value -> + Identifier(type = type, value = value, issuingBody = dto.issuingBody) + } + } private fun toStateDto(entity: State) = BusinessPartnerStateDto(type = entity.type, validFrom = entity.validFrom, validTo = entity.validTo, description = entity.description) private fun toState(dto: BusinessPartnerStateDto) = - State(type = dto.type, validFrom = dto.validFrom, validTo = dto.validTo, description = dto.description) + 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) - private fun toClassification(dto: ClassificationDto) = + + private fun toClassification(dto: ClassificationBusinessPartnerDto) = + 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) = 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 485336479..8b2a45ff3 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 @@ -134,9 +134,9 @@ class OrchestratorMappings( externalId = externalId, nameParts = entity.nameParts.toMutableList(), shortName = entity.shortName, - identifiers = entity.identifiers.map { toIdentifier(it) }.toSortedSet(), + identifiers = entity.identifiers.mapNotNull { toIdentifier(it) }.toSortedSet(), legalForm = entity.legalForm, - states = entity.states.map { toState(it) }.toSortedSet(), + states = entity.states.mapNotNull { toState(it) }.toSortedSet(), classifications = entity.classifications.map { toClassification(it) }.toSortedSet(), roles = entity.roles.toSortedSet(), postalAddress = toPostalAddress(entity.postalAddress), @@ -147,10 +147,14 @@ class OrchestratorMappings( ) private fun toIdentifier(dto: BusinessPartnerIdentifierDto) = - Identifier(type = dto.type, value = dto.value, issuingBody = dto.issuingBody) + dto.type?.let { type -> + dto.value?.let { value -> + Identifier(type = type, value = value, issuingBody = dto.issuingBody) + } + } private fun toState(dto: BusinessPartnerStateDto) = - State(type = dto.type, validFrom = dto.validFrom, validTo = dto.validTo, description = dto.description) + dto.type?.let { State(type = it, validFrom = dto.validFrom, validTo = dto.validTo, description = dto.description) } private fun toClassification(dto: ClassificationDto) = Classification(type = dto.type, code = dto.code, value = dto.value) 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 b0b3d173e..8adfb4e54 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 @@ -24,10 +24,7 @@ import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerIdentifierDto -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerStateDto -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerType -import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto +import org.eclipse.tractusx.bpdm.common.dto.* 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 @@ -329,7 +326,7 @@ class BusinessPartnerControllerIT @Autowired constructor( identifiers = request.identifiers.toSortedSet(identifierDtoComparator), legalForm = request.legalForm, states = request.states.toSortedSet(stateDtoComparator), - classifications = request.classifications.toSortedSet(classificationDtoComparator), + classifications = request.classifications.toSortedSet(classificationDtoOutputComparator), roles = request.roles.toSortedSet(), postalAddress = request.postalAddress, isOwnCompanyData = request.isOwnCompanyData, @@ -360,7 +357,14 @@ class BusinessPartnerControllerIT @Autowired constructor( .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 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 81ff49943..23098d950 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 = ClassificationDto( + val bpClassification1 = ClassificationBusinessPartnerDto( type = ClassificationType.NACE, code = "code1", value = "Sale of motor vehicles" ) - val bpClassification2 = ClassificationDto( + val bpClassification2 = ClassificationBusinessPartnerDto( type = ClassificationType.NACE, code = "code2", value = "Data processing, hosting and related activities" ) - val bpClassification3 = ClassificationDto( + val bpClassification3 = ClassificationBusinessPartnerDto( type = ClassificationType.NACE, code = "code3", value = "Other information service activities" ) - val bpClassification4 = ClassificationDto( + val bpClassification4 = ClassificationBusinessPartnerDto( type = ClassificationType.NACE, code = "code4", value = "Financial and insurance activities" ) - val bpClassificationChina = ClassificationDto( + val bpClassificationChina = ClassificationBusinessPartnerDto( type = ClassificationType.NACE, code = "code3", value = "北京市" @@ -200,25 +200,49 @@ object BusinessPartnerVerboseValues { type = businessStateType2 ) + val bpClassification1Dto = ClassificationDto( + type = ClassificationType.NACE, + code = "code1", + value = "Sale of motor vehicles" + ) + + val bpClassification2Dto = ClassificationDto( + type = ClassificationType.NACE, + code = "code2", + value = "Data processing, hosting and related activities" + ) + + val bpClassification3Dto = ClassificationDto( + type = ClassificationType.NACE, + code = "code3", + value = "Other information service activities" + ) + + val bpClassification4Dto = ClassificationDto( + type = ClassificationType.NACE, + code = "code4", + value = "Financial and insurance activities" + ) + val legalEntity1 = LegalEntityDto( legalShortName = "short1", legalForm = "LF1", states = listOf(legalEntityBusinessStatus1), - classifications = listOf(bpClassification1, bpClassification2), + classifications = listOf(bpClassification1Dto, bpClassification2Dto), ) val legalEntity2 = LegalEntityDto( legalShortName = "short3", legalForm = "LF2", states = listOf(legalEntityBusinessStatus2), - classifications = listOf(bpClassification3, bpClassification4), + classifications = listOf(bpClassification3Dto, bpClassification4Dto), ) val legalEntity3 = LegalEntityDto( legalShortName = "short1", legalForm = "LF1", states = listOf(legalEntityBusinessStatus1), - classifications = listOf(bpClassification1, bpClassification2), + classifications = listOf(bpClassification1Dto, bpClassification2Dto), ) val leBusinessStatus1 = LegalEntityStateVerboseDto( diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/LegalEntityDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/LegalEntityDto.kt index 8a625ca95..423f41b8c 100644 --- a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/LegalEntityDto.kt +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/LegalEntityDto.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.orchestrator.api.model import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto import org.eclipse.tractusx.bpdm.common.dto.IBaseLegalEntityDto import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityDescription @@ -42,7 +43,7 @@ data class LegalEntityDto( override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), + override val classifications: Collection = emptyList(), val legalAddress: LogisticAddressDto? = 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 221e83739..63af3e65d 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 @@ -367,12 +367,12 @@ object BusinessPartnerTestValues { ), ), classifications = listOf( - BusinessPartnerClassificationDto( + ClassificationDto( type = ClassificationType.SIC, code = "Classification Code 1", value = "Classification Value 1" ), - BusinessPartnerClassificationDto( + ClassificationDto( type = ClassificationType.NACE, code = "Classification Code 2", value = "Classification Value 2" @@ -406,7 +406,7 @@ object BusinessPartnerTestValues { ) ), classifications = listOf( - BusinessPartnerClassificationDto( + ClassificationDto( type = ClassificationType.SIC, code = "Classification Code 2", value = "Classification Value 2" diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index 6b294c3a6..e7dbe507a 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -544,7 +544,7 @@ class BusinessPartnerBuildService( ) } - fun toLegalEntityClassification(dto: IBaseClassificationDto, partner: LegalEntity): LegalEntityClassification { + fun toLegalEntityClassification(dto: ClassificationDto, partner: LegalEntity): LegalEntityClassification { return LegalEntityClassification( value = dto.value, code = dto.code,