From 97492cae81f09ddad7c9ea777cba24421e5b371e Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 6 Oct 2023 13:51:39 +0200 Subject: [PATCH] feat(gate): rename business partner field 'isOwner' to 'is_own_company_data' - adjust field name in DTOs - adjust field name in generic business partner entity - create a migration script --- .../api/model/IBaseBusinessPartnerGateDto.kt | 2 +- .../request/BusinessPartnerInputRequest.kt | 2 +- .../request/BusinessPartnerOutputRequest.kt | 2 +- .../model/response/BusinessPartnerInputDto.kt | 2 +- .../model/response/BusinessPartnerOutputDto.kt | 2 +- .../bpdm/gate/entity/generic/BusinessPartner.kt | 4 ++-- .../gate/service/BusinessPartnerMappings.kt | 8 ++++---- .../bpdm/gate/service/BusinessPartnerService.kt | 2 +- .../V4_1_0_0__rename_is_owner_column.sql | 1 + .../controller/BusinessPartnerControllerIT.kt | 9 ++++++--- .../gate/entity/generic/BusinessPartnerIT.kt | 17 +++++++++++------ .../gate/util/BusinessPartnerVerboseValues.kt | 4 ++-- 12 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 bpdm-gate/src/main/resources/db/migration/V4_1_0_0__rename_is_owner_column.sql diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerGateDto.kt index 7380a043a..714b20c8a 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerGateDto.kt @@ -29,5 +29,5 @@ interface IBaseBusinessPartnerGateDto : IBaseBusinessPartnerDto { val externalId: String @get:Schema(name = "isOwner", description = "True if the sharing member declares itself as the owner of the business partner.") - val isOwner: Boolean + val isOwnCompanyData: Boolean } 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 b11aa7612..bb32084aa 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt @@ -41,7 +41,7 @@ data class BusinessPartnerInputRequest( override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), override val postalAddress: BusinessPartnerPostalAddressDto = BusinessPartnerPostalAddressDto(), - override val isOwner: Boolean = false, + override val isOwnCompanyData: Boolean = false, override val bpnL: String? = null, override val bpnS: String? = null, override val bpnA: String? = null, 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 ca206b9ef..192d8138e 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 @@ -43,7 +43,7 @@ data class BusinessPartnerOutputRequest( override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), override val postalAddress: BusinessPartnerPostalAddressDto = BusinessPartnerPostalAddressDto(), - override val isOwner: Boolean = false, + override val isOwnCompanyData: Boolean = false, override val bpnL: String? = null, override val bpnS: String? = null, override val bpnA: String? = null, 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 7a3c7bbdc..46ba2fb2e 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 @@ -44,7 +44,7 @@ data class BusinessPartnerInputDto( override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), override val postalAddress: BusinessPartnerPostalAddressDto, - override val isOwner: Boolean, + override val isOwnCompanyData: Boolean, override val bpnL: String?, override val bpnS: String?, override val bpnA: String?, 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 be53e9cbb..13b1d815b 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 @@ -43,7 +43,7 @@ data class BusinessPartnerOutputDto( override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), override val postalAddress: BusinessPartnerPostalAddressDto, - override val isOwner: Boolean, + override val isOwnCompanyData: Boolean, override val bpnL: String, override val bpnS: String?, override val bpnA: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartner.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartner.kt index 1dc3bf63b..7bc692a46 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartner.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartner.kt @@ -62,8 +62,8 @@ class BusinessPartner( @Column(name = "legal_form") var legalForm: String? = null, - @Column(name = "is_owner") - var isOwner: Boolean = false, + @Column(name = "is_own_company_data", nullable = false) + var isOwnCompanyData: Boolean = false, @Column(name = "bpnl") var bpnL: String? = null, 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 3f0eb5514..3566e600a 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 @@ -54,7 +54,7 @@ class BusinessPartnerMappings { classifications = entity.classifications.map(::toClassificationDto), roles = entity.roles, postalAddress = toPostalAddressDto(entity.postalAddress), - isOwner = entity.isOwner, + isOwnCompanyData = entity.isOwnCompanyData, bpnL = entity.bpnL, bpnS = entity.bpnS, bpnA = entity.bpnA, @@ -74,7 +74,7 @@ class BusinessPartnerMappings { classifications = entity.classifications.map(::toClassificationDto), roles = entity.roles, postalAddress = toPostalAddressDto(entity.postalAddress), - isOwner = entity.isOwner, + isOwnCompanyData = entity.isOwnCompanyData, bpnL = entity.bpnL ?: throw BpdmNullMappingException(BusinessPartner::class, BusinessPartnerOutputDto::class, BusinessPartner::bpnL, entity.externalId), bpnS = entity.bpnS, @@ -96,7 +96,7 @@ class BusinessPartnerMappings { classifications = dto.classifications.map(::toClassification).toSortedSet(), shortName = dto.shortName, legalForm = dto.legalForm, - isOwner = dto.isOwner, + isOwnCompanyData = dto.isOwnCompanyData, bpnL = dto.bpnL, bpnS = dto.bpnS, bpnA = dto.bpnA, @@ -118,7 +118,7 @@ class BusinessPartnerMappings { classifications = dto.classifications.map(::toClassification).toSortedSet(), shortName = dto.shortName, legalForm = dto.legalForm, - isOwner = dto.isOwner, + isOwnCompanyData = dto.isOwnCompanyData, bpnL = dto.bpnL, bpnS = dto.bpnS, bpnA = dto.bpnA, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerService.kt index c3a8249af..4c0111cdf 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerService.kt @@ -161,7 +161,7 @@ class BusinessPartnerService( stage = fromPartner.stage shortName = fromPartner.shortName legalForm = fromPartner.legalForm - isOwner = fromPartner.isOwner + isOwnCompanyData = fromPartner.isOwnCompanyData bpnL = fromPartner.bpnL bpnS = fromPartner.bpnS bpnA = fromPartner.bpnA diff --git a/bpdm-gate/src/main/resources/db/migration/V4_1_0_0__rename_is_owner_column.sql b/bpdm-gate/src/main/resources/db/migration/V4_1_0_0__rename_is_owner_column.sql new file mode 100644 index 000000000..ae74bc117 --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V4_1_0_0__rename_is_owner_column.sql @@ -0,0 +1 @@ +ALTER TABLE business_partners RENAME COLUMN is_owner TO is_own_company_data; \ No newline at end of file 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 00818d500..f9efcc9cf 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 @@ -27,8 +27,11 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerInputDto -import org.eclipse.tractusx.bpdm.gate.util.* -import org.junit.jupiter.api.Assertions.* +import org.eclipse.tractusx.bpdm.gate.util.BusinessPartnerNonVerboseValues +import org.eclipse.tractusx.bpdm.gate.util.BusinessPartnerVerboseValues +import org.eclipse.tractusx.bpdm.gate.util.DbTestHelpers +import org.eclipse.tractusx.bpdm.gate.util.PostgreSQLContextInitializer +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired @@ -198,7 +201,7 @@ class BusinessPartnerControllerIT @Autowired constructor( classifications = request.classifications.toSortedSet(classificationDtoComparator), roles = request.roles.toSortedSet(), postalAddress = request.postalAddress, - isOwner = request.isOwner, + isOwnCompanyData = request.isOwnCompanyData, bpnL = request.bpnL, bpnS = request.bpnS, bpnA = request.bpnA, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartnerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartnerIT.kt index 06763b12c..fa5bbce08 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartnerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartnerIT.kt @@ -38,20 +38,25 @@ package org.eclipse.tractusx.bpdm.gate.entity.generic -import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import com.neovisionaries.i18n.CountryCode import org.eclipse.tractusx.bpdm.common.dto.AddressType import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole -import org.eclipse.tractusx.bpdm.common.model.* +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.bpdm.common.model.StageType import org.eclipse.tractusx.bpdm.gate.entity.AlternativePostalAddress import org.eclipse.tractusx.bpdm.gate.entity.GeographicCoordinate import org.eclipse.tractusx.bpdm.gate.entity.PhysicalPostalAddress import org.eclipse.tractusx.bpdm.gate.entity.Street -import org.eclipse.tractusx.bpdm.gate.repository.generic.* -import org.eclipse.tractusx.bpdm.gate.util.* -import org.junit.jupiter.api.Assertions.* +import org.eclipse.tractusx.bpdm.gate.repository.generic.BusinessPartnerRepository +import org.eclipse.tractusx.bpdm.gate.repository.generic.PostalAddressRepository +import org.eclipse.tractusx.bpdm.gate.util.DbTestHelpers +import org.eclipse.tractusx.bpdm.gate.util.PostgreSQLContextInitializer +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -153,7 +158,7 @@ internal class BusinessPartnerIT @Autowired constructor( nameParts = mutableListOf("testNameParts", "testNameParts2", "testNameParts3", "testNameParts4", "testNameParts5"), shortName = "testShortName", legalForm = "testLegalForm", - isOwner = true, + isOwnCompanyData = true, bpnA = "testAddressBpn", bpnL = "testLegalEntityBpn", bpnS = "testSiteBpn", 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 511bec9b3..603680ff9 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 @@ -339,7 +339,7 @@ object BusinessPartnerVerboseValues { nameParts = listOf("Business Partner Name", "Company ABC AG", "Another Organisation Corp", "Catena Test Name"), shortName = "short1", legalForm = "Limited Liability Company", - isOwner = true, + isOwnCompanyData = true, identifiers = listOf(bpIdentifier1, bpIdentifier2, bpIdentifier3), classifications = listOf(bpClassification1, bpClassification2, bpClassification3), states = listOf(bpState1, bpState2), @@ -732,7 +732,7 @@ object BusinessPartnerVerboseValues { nameParts = listOf("好公司 合伙制企业"), shortName = "short3", legalForm = "股份有限", - isOwner = true, + isOwnCompanyData = true, identifiers = listOf( bpIdentifier1, bpIdentifier2, bpIdentifier1 ), // duplicate, but they are elimnated