Skip to content

Commit

Permalink
feat(gate): rename business partner field 'isOwner' to 'is_own_compa…
Browse files Browse the repository at this point in the history
…ny_data'

 - adjust field name in DTOs
 - adjust field name in generic business partner entity
 - create a migration script
  • Loading branch information
nicoprow committed Oct 6, 2023
1 parent d881368 commit 97492ca
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ data class BusinessPartnerInputRequest(
override val classifications: Collection<ClassificationDto> = emptyList(),
override val roles: Collection<BusinessPartnerRole> = 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ data class BusinessPartnerOutputRequest(
override val classifications: Collection<ClassificationDto> = emptyList(),
override val roles: Collection<BusinessPartnerRole> = 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ data class BusinessPartnerInputDto(
override val classifications: Collection<ClassificationDto> = emptyList(),
override val roles: Collection<BusinessPartnerRole> = 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?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ data class BusinessPartnerOutputDto(
override val classifications: Collection<ClassificationDto> = emptyList(),
override val roles: Collection<BusinessPartnerRole> = 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE business_partners RENAME COLUMN is_owner TO is_own_company_data;
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 97492ca

Please sign in to comment.