diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/DtoConversionHelper.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/DtoConversionHelper.kt index 4707d5087..ae913dcbd 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/DtoConversionHelper.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/DtoConversionHelper.kt @@ -169,7 +169,7 @@ fun poolToGateLegalEntity(legalEntity: LegalEntityVerboseDto): Gate_LegalEntityD val identifiers = legalEntity.identifiers.map { Gate_LegalEntityIdentifierDto( value = it.value, - type = it.type.technicalKey, + type = it.typeVerbose.technicalKey, issuingBody = it.issuingBody ) } @@ -178,12 +178,12 @@ fun poolToGateLegalEntity(legalEntity: LegalEntityVerboseDto): Gate_LegalEntityD description = it.description, validFrom = it.validFrom, validTo = it.validTo, - type = it.type.technicalKey + type = it.typeVerbose.technicalKey ) } val classifications = legalEntity.classifications.map { Gate_LegalEntityClassificationDto( - type = it.type.technicalKey, + type = it.typeVerbose.technicalKey, code = it.code, value = it.value ) @@ -191,7 +191,7 @@ fun poolToGateLegalEntity(legalEntity: LegalEntityVerboseDto): Gate_LegalEntityD return Gate_LegalEntityDto( legalNameParts = listOfNotNull(legalEntity.legalName), legalShortName = legalEntity.legalShortName, - legalForm = legalEntity.legalForm?.technicalKey, + legalForm = legalEntity.legalFormVerbose?.technicalKey, identifiers = identifiers, states = states, classifications = classifications diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityClassificationVerboseDto.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityClassificationVerboseDto.kt index 86f0c9d28..db84cd86e 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityClassificationVerboseDto.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityClassificationVerboseDto.kt @@ -19,7 +19,10 @@ package org.eclipse.tractusx.bpdm.pool.api.model +import com.fasterxml.jackson.annotation.JsonIgnore +import com.fasterxml.jackson.annotation.JsonProperty import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.ILegalEntityClassificationDto import org.eclipse.tractusx.bpdm.common.dto.TypeKeyNameVerboseDto import org.eclipse.tractusx.bpdm.common.dto.openapidescription.ClassificationDescription import org.eclipse.tractusx.bpdm.common.model.ClassificationType @@ -27,13 +30,16 @@ import org.eclipse.tractusx.bpdm.common.model.ClassificationType @Schema(description = ClassificationDescription.header) data class LegalEntityClassificationVerboseDto( - @get:Schema(description = ClassificationDescription.value) - val value: String? = null, + override val value: String? = null, + override val code: String? = null, - @get:Schema(description = ClassificationDescription.code) - val code: String? = null, - - // TODO OpenAPI description for complex field does not work!! + @field:JsonProperty("type") @get:Schema(description = ClassificationDescription.type) - val type: TypeKeyNameVerboseDto -) + val typeVerbose: TypeKeyNameVerboseDto + +) : ILegalEntityClassificationDto { + + @get:JsonIgnore + override val type: ClassificationType + get() = typeVerbose.technicalKey +} diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityIdentifierVerboseDto.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityIdentifierVerboseDto.kt index 2a818f175..607e32dbb 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityIdentifierVerboseDto.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityIdentifierVerboseDto.kt @@ -19,20 +19,27 @@ package org.eclipse.tractusx.bpdm.pool.api.model +import com.fasterxml.jackson.annotation.JsonIgnore +import com.fasterxml.jackson.annotation.JsonProperty import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.ILegalEntityIdentifierDto import org.eclipse.tractusx.bpdm.common.dto.TypeKeyNameVerboseDto import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityIdentifierDescription @Schema(description = LegalEntityIdentifierDescription.header) data class LegalEntityIdentifierVerboseDto( - @get:Schema(description = LegalEntityIdentifierDescription.value) - val value: String, + override val value: String, - // TODO OpenAPI description for complex field does not work!! + @field:JsonProperty("type") @get:Schema(description = LegalEntityIdentifierDescription.type) - val type: TypeKeyNameVerboseDto, + val typeVerbose: TypeKeyNameVerboseDto, - @get:Schema(description = LegalEntityIdentifierDescription.issuingBody) - val issuingBody: String? = null -) + override val issuingBody: String? = null + +) : ILegalEntityIdentifierDto { + + @get:JsonIgnore + override val type: String + get() = typeVerbose.technicalKey +} diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityStateVerboseDto.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityStateVerboseDto.kt index 2da56ee10..8a34f5b84 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityStateVerboseDto.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityStateVerboseDto.kt @@ -19,7 +19,10 @@ package org.eclipse.tractusx.bpdm.pool.api.model +import com.fasterxml.jackson.annotation.JsonIgnore +import com.fasterxml.jackson.annotation.JsonProperty import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.ILegalEntityStateDto import org.eclipse.tractusx.bpdm.common.dto.TypeKeyNameVerboseDto import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityStateDescription import org.eclipse.tractusx.bpdm.common.model.BusinessStateType @@ -28,16 +31,17 @@ import java.time.LocalDateTime @Schema(description = LegalEntityStateDescription.header) data class LegalEntityStateVerboseDto( - @get:Schema(description = LegalEntityStateDescription.description) - val description: String?, + override val description: String?, + override val validFrom: LocalDateTime?, + override val validTo: LocalDateTime?, - @get:Schema(description = LegalEntityStateDescription.validFrom) - val validFrom: LocalDateTime?, + @field:JsonProperty("type") + @get:Schema(description = LegalEntityStateDescription.type) + val typeVerbose: TypeKeyNameVerboseDto - @get:Schema(description = LegalEntityStateDescription.validTo) - val validTo: LocalDateTime?, +) : ILegalEntityStateDto { - // TODO OpenAPI description for complex field does not work!! - @get:Schema(description = LegalEntityStateDescription.type) - val type: TypeKeyNameVerboseDto -) \ No newline at end of file + @get:JsonIgnore + override val type: BusinessStateType + get() = typeVerbose.technicalKey +} diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityVerboseDto.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityVerboseDto.kt index cd2a3114f..702135afc 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityVerboseDto.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LegalEntityVerboseDto.kt @@ -19,8 +19,11 @@ package org.eclipse.tractusx.bpdm.pool.api.model +import com.fasterxml.jackson.annotation.JsonIgnore +import com.fasterxml.jackson.annotation.JsonProperty import io.swagger.v3.oas.annotations.media.ArraySchema import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.IBaseLegalEntityDto import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityDescription import java.time.Instant @@ -34,21 +37,15 @@ data class LegalEntityVerboseDto( @get:Schema(description = LegalEntityDescription.legalName) val legalName: String, - @get:Schema(description = LegalEntityDescription.legalShortName) - val legalShortName: String? = null, + override val legalShortName: String? = null, + @field:JsonProperty("legalForm") @get:Schema(description = LegalEntityDescription.legalForm) - val legalForm: LegalFormDto? = null, + val legalFormVerbose: LegalFormDto? = null, - // TODO OpenAPI description for complex field does not work!! - @get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.identifiers)) - val identifiers: Collection = emptyList(), - - @get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.states)) - val states: Collection = emptyList(), - - @get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.classifications)) - val classifications: Collection = emptyList(), + override val identifiers: Collection = emptyList(), + override val states: Collection = emptyList(), + override val classifications: Collection = emptyList(), @get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.relations)) val relations: Collection = emptyList(), @@ -60,5 +57,11 @@ data class LegalEntityVerboseDto( val createdAt: Instant, @get:Schema(description = CommonDescription.updatedAt) - val updatedAt: Instant, -) + val updatedAt: Instant + +) : IBaseLegalEntityDto { + + @get:JsonIgnore + override val legalForm: String? + get() = legalFormVerbose?.technicalKey +} diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 1b91fa3e9..e723f6fdb 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -61,7 +61,7 @@ fun LegalEntity.toDto(): LegalEntityVerboseDto { bpnl = bpn, legalName = legalName.value, legalShortName = legalName.shortName, - legalForm = legalForm?.toDto(), + legalFormVerbose = legalForm?.toDto(), identifiers = identifiers.map { it.toDto() }, states = states.map { it.toDto() }, classifications = classifications.map { it.toDto() }, diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt index 3673046f5..885ed3532 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt @@ -615,7 +615,7 @@ class LegalEntityControllerIT @Autowired constructor( .first() // search for first val identifierToFind = expected.identifiers.first() - val response = poolClient.legalEntities.getLegalEntity(identifierToFind.value, identifierToFind.type.technicalKey).legalEntity + val response = poolClient.legalEntities.getLegalEntity(identifierToFind.value, identifierToFind.typeVerbose.technicalKey).legalEntity assertThat(response) .usingRecursiveComparison() @@ -645,7 +645,7 @@ class LegalEntityControllerIT @Autowired constructor( var identifierToFind = expected.identifiers.first() identifierToFind = identifierToFind.copy(value = changeCase(identifierToFind.value)) - val response = poolClient.legalEntities.getLegalEntity(identifierToFind.value, identifierToFind.type.technicalKey).legalEntity + val response = poolClient.legalEntities.getLegalEntity(identifierToFind.value, identifierToFind.typeVerbose.technicalKey).legalEntity assertThat(response) .usingRecursiveComparison() diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt index 928139c66..6b8fa0754 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt @@ -554,7 +554,7 @@ class TaskStepFetchAndReserveServiceTest @Autowired constructor( val verboseLegalEntity = verboseRequest.legalEntity assertThat(verboseLegalEntity.legalShortName).isEqualTo(legalEntity?.legalShortName) - assertThat(verboseLegalEntity.legalForm?.technicalKey).isEqualTo(legalEntity?.legalForm) + assertThat(verboseLegalEntity.legalFormVerbose?.technicalKey).isEqualTo(legalEntity?.legalForm) compareStates(verboseLegalEntity.states, legalEntity?.states) compareClassifications(verboseLegalEntity.classifications, legalEntity?.classifications) compareIdentifiers(verboseLegalEntity.identifiers, legalEntity?.identifiers) @@ -636,11 +636,11 @@ class TaskStepFetchAndReserveServiceTest @Autowired constructor( val sortedVerboseStates = statesVerbose.sortedBy { it.description } val sortedStates = states!!.sortedBy { it.description } sortedVerboseStates.indices.forEach { - assertThat(sortedVerboseStates[it].type.technicalKey.name).isEqualTo(sortedStates[it].type.name) + assertThat(sortedVerboseStates[it].typeVerbose.technicalKey.name).isEqualTo(sortedStates[it].type.name) assertThat(sortedVerboseStates[it]).usingRecursiveComparison() .withEqualsForFields(isEqualToIgnoringMilliseconds(), "validTo") .withEqualsForFields(isEqualToIgnoringMilliseconds(), "validFrom") - .ignoringFields("type") + .ignoringFields("typeVerbose") .isEqualTo(sortedStates[it]) } } @@ -673,12 +673,12 @@ class TaskStepFetchAndReserveServiceTest @Autowired constructor( ) { assertThat(classificationsVerbose.size).isEqualTo(classifications?.size ?: 0) - val sortedVerboseClassifications = classificationsVerbose.sortedBy { it.type.name } + val sortedVerboseClassifications = classificationsVerbose.sortedBy { it.typeVerbose.name } val sortedClassifications = classifications!!.sortedBy { it.type.name } sortedVerboseClassifications.indices.forEach { - assertThat(sortedVerboseClassifications[it].type.technicalKey.name).isEqualTo(sortedClassifications[it].type.name) + assertThat(sortedVerboseClassifications[it].typeVerbose.technicalKey.name).isEqualTo(sortedClassifications[it].type.name) assertThat(sortedVerboseClassifications[it]).usingRecursiveComparison() - .ignoringFields("type") + .ignoringFields("typeVerbose") .isEqualTo(sortedClassifications[it]) } } @@ -686,14 +686,13 @@ class TaskStepFetchAndReserveServiceTest @Autowired constructor( fun compareIdentifiers(identifiersVerbose: Collection, identifiers: Collection?) { assertThat(identifiersVerbose.size).isEqualTo(identifiers?.size ?: 0) - val sortedVerboseIdentifiers = identifiersVerbose.sortedBy { it.type.name } + val sortedVerboseIdentifiers = identifiersVerbose.sortedBy { it.typeVerbose.name } val sortedIdentifiers = identifiers!!.sortedBy { it.type } sortedVerboseIdentifiers.indices.forEach { - assertThat(sortedVerboseIdentifiers[it].type.technicalKey).isEqualTo(sortedIdentifiers[it].type) + assertThat(sortedVerboseIdentifiers[it].typeVerbose.technicalKey).isEqualTo(sortedIdentifiers[it].type) assertThat(sortedVerboseIdentifiers[it]).usingRecursiveComparison() - .ignoringFields("type").isEqualTo(sortedIdentifiers[it]) + .ignoringFields("typeVerbose").isEqualTo(sortedIdentifiers[it]) } } - } \ No newline at end of file diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerVerboseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerVerboseValues.kt index f8071faf6..c047bb3fc 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerVerboseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerVerboseValues.kt @@ -249,7 +249,7 @@ object BusinessPartnerVerboseValues { LegalEntityVerboseDto( bpnl = "BPNL000000000001", legalName = "Business Partner Name", - legalForm = legalForm1, + legalFormVerbose = legalForm1, identifiers = listOf(identifier1), states = listOf(leStatus1), classifications = listOf(classification1, classification2), @@ -286,7 +286,7 @@ object BusinessPartnerVerboseValues { LegalEntityVerboseDto( bpnl = "BPNL0000000001YN", legalName = "Another Organisation Corp", - legalForm = legalForm2, + legalFormVerbose = legalForm2, identifiers = listOf(identifier2), states = listOf(leStatus2), classifications = listOf(classification3, classification4), @@ -323,7 +323,7 @@ object BusinessPartnerVerboseValues { LegalEntityVerboseDto( bpnl = "BPNL0000000002XY", legalName = "好公司 合伙制企业", - legalForm = legalForm3, + legalFormVerbose = legalForm3, identifiers = listOf(identifier3), states = listOf(leStatus3), classifications = listOf(classification5), @@ -360,7 +360,7 @@ object BusinessPartnerVerboseValues { legalEntity = LegalEntityVerboseDto( bpnl = "BPNL000000000001", legalName = "Business Partner Name", - legalForm = legalForm1, + legalFormVerbose = legalForm1, identifiers = listOf(LegalEntityIdentifierVerboseDto("ID-XYZ", identifierType1, "Agency X")), states = listOf(leStatus1), classifications = listOf(classification1, classification2), @@ -379,7 +379,7 @@ object BusinessPartnerVerboseValues { legalEntity = LegalEntityVerboseDto( bpnl = "BPNL0000000001YN", legalName = "Another Organisation Corp", - legalForm = legalForm2, + legalFormVerbose = legalForm2, identifiers = listOf(LegalEntityIdentifierVerboseDto("Another ID Value", identifierType2, "Body Y")), states = listOf(leStatus2), classifications = listOf(classification3, classification4), @@ -398,7 +398,7 @@ object BusinessPartnerVerboseValues { legalEntity = LegalEntityVerboseDto( bpnl = "BPNL0000000002XY", legalName = "好公司 合伙制企业", - legalForm = legalForm3, + legalFormVerbose = legalForm3, identifiers = listOf(LegalEntityIdentifierVerboseDto("An ID Value", identifierType3, "Official Z")), states = listOf(leStatus3), classifications = listOf(classification5), @@ -417,7 +417,7 @@ object BusinessPartnerVerboseValues { legalEntity = LegalEntityVerboseDto( bpnl = "BPNL000000000001", legalName = "Business Partner Name", - legalForm = legalForm1, + legalFormVerbose = legalForm1, identifiers = listOf( LegalEntityIdentifierVerboseDto("ID-XYZ", identifierType1, "Agency X"), LegalEntityIdentifierVerboseDto("Another ID Value", identifierType2, "Body Y")