From 844a35b4126e0f84fc51cc880d45517ba5a22400 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Wed, 28 Jun 2023 16:46:34 +0100 Subject: [PATCH 1/5] fix(gate): Added Roles for Legal Entities. Fixed AdminLevel1 mapping. Added more Street Suffixes and corrected the mapping. Fixed unit tests to account with AdminLvl1 map --- .../bpdm/gate/api/model/StreetGateDto.kt | 2 +- .../tractusx/bpdm/gate/entity/LegalEntity.kt | 3 + .../bpdm/gate/entity/LegalEntityRoles.kt | 65 +++++++++++++++++++ .../bpdm/gate/entity/PhysicalPostalAddress.kt | 4 ++ .../tractusx/bpdm/gate/entity/Street.kt | 17 ++++- .../service/LegalEntityPersistenceService.kt | 2 + .../bpdm/gate/service/LegalEntityService.kt | 1 + .../bpdm/gate/service/ResponseMappings.kt | 34 +++++++--- .../migration/V4_0_0_5__add_roles_table.sql | 25 +++++++ .../tractusx/bpdm/gate/util/RequestValues.kt | 4 +- 10 files changed, 142 insertions(+), 15 deletions(-) create mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt create mode 100644 bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt index 6e4dc4b35..9d5d84293 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt @@ -35,7 +35,7 @@ data class StreetGateDto( val name: String? = null, @get:Schema(description = "Describes the name suffix of the Street.") - val NameSuffix: String? = null, + val nameSuffix: String? = null, @get:Schema(description = "Describes the additional name suffix of the Street.") val additionalNameSuffix: String? = null, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt index fbaf4e8ce..71133fce8 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt @@ -57,6 +57,9 @@ class LegalEntity( @JoinColumn(name = "legal_address_id", nullable = false) lateinit var legalAddress: LogisticAddress + @OneToMany(mappedBy = "legalEntity", cascade = [CascadeType.ALL], orphanRemoval = true) + val roles: MutableSet = mutableSetOf() + @OneToMany(mappedBy = "legalEntity", cascade = [CascadeType.ALL], orphanRemoval = true) val addresses: MutableSet = mutableSetOf() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt new file mode 100644 index 000000000..e3b196c1c --- /dev/null +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt @@ -0,0 +1,65 @@ +/******************************************************************************* + * 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 + ******************************************************************************/ + +/******************************************************************************* + * 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.gate.entity + +import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerRole + +@Entity +@Table(name = "roles") +class LegalEntityRoles( + + @ManyToOne + @JoinColumn(name = "legal_entity_id", nullable = false) + var legalEntity: LegalEntity, + +// @ManyToOne +// @JoinColumn(name = "address_id", nullable = true) +// var address: LogisticAddress?, +// +// @ManyToOne +// @JoinColumn(name = "site_id", nullable = true) +// var site: Site?, + + @Column(name = "role_name", nullable = false) + @Enumerated(EnumType.STRING) + val roleName: BusinessPartnerRole + +) : BaseEntity() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt index 27ad5de05..fcc582e9f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt @@ -75,6 +75,10 @@ class PhysicalPostalAddress( @AttributeOverride(name = "houseNumber", column = Column(name = "phy_street_number")) @AttributeOverride(name = "milestone", column = Column(name = "phy_street_milestone")) @AttributeOverride(name = "direction", column = Column(name = "phy_street_direction")) + @AttributeOverride(name = "namePrefix", column = Column(name = "phy_name_prefix")) + @AttributeOverride(name = "additionalNamePrefix", column = Column(name = "phy_additional_name_prefix")) + @AttributeOverride(name = "nameSuffix", column = Column(name = "phy_name_suffix")) + @AttributeOverride(name = "additionalNameSuffix", column = Column(name = "phy_additional_name_suffix")) val street: Street? = null, // specific for PhysicalPostalAddress diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Street.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Street.kt index f045adab8..6ebe70ba8 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Street.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Street.kt @@ -37,5 +37,18 @@ class Street( val milestone: String? = null, @Column - val direction: String? = null -) \ No newline at end of file + val direction: String? = null, + + @Column + val namePrefix: String? = null, + + @Column + val additionalNamePrefix: String? = null, + + @Column + val nameSuffix: String? = null, + + @Column + val additionalNameSuffix: String? = null, + + ) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index fa1f26479..6efc426db 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -90,6 +90,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) + legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity @@ -156,6 +157,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) + legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 697f466bf..da858877c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -121,6 +121,7 @@ private fun toValidSingleLegalEntity(legalEntity: LegalEntity): LegalEntityGateI return LegalEntityGateInputResponse( legalEntity = legalEntity.toLegalEntityDto(), legalNameParts = getNamePartValuesToList(legalEntity.nameParts), + roles = legalEntity.roles.map { it.roleName }, legalAddress = legalEntity.legalAddress.toAddressGateInputResponse(legalEntity.legalAddress), externalId = legalEntity.externalId ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index a360892ba..b4876ecf0 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -22,10 +22,7 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.* import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum -import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto -import org.eclipse.tractusx.bpdm.gate.api.model.PhysicalPostalAddressGateDto -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateDto -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.* import org.eclipse.tractusx.bpdm.gate.api.model.response.* import org.eclipse.tractusx.bpdm.gate.entity.* @@ -79,7 +76,7 @@ fun AlternativePostalAddressDto.toAlternativePostalAddressEntity(): AlternativeP return AlternativePostalAddress( geographicCoordinates = baseAddress.geographicCoordinates?.toGeographicCoordinateEntity(), country = baseAddress.country, - administrativeAreaLevel1 = null, // TODO Add region mapping Logic + administrativeAreaLevel1 = areaPart.administrativeAreaLevel1, postCode = baseAddress.postalCode, city = baseAddress.city, deliveryServiceType = deliveryServiceType, @@ -94,7 +91,7 @@ fun PhysicalPostalAddressGateDto.toPhysicalPostalAddressEntity(): PhysicalPostal return PhysicalPostalAddress( geographicCoordinates = baseAddress.geographicCoordinates?.toGeographicCoordinateEntity(), country = baseAddress.country, - administrativeAreaLevel1 = null, // TODO Add region mapping Logic + administrativeAreaLevel1 = areaPart.administrativeAreaLevel1, administrativeAreaLevel2 = areaPart.administrativeAreaLevel2, administrativeAreaLevel3 = areaPart.administrativeAreaLevel3, postCode = baseAddress.postalCode, @@ -115,11 +112,16 @@ fun GeoCoordinateDto.toGeographicCoordinateEntity(): GeographicCoordinate { } private fun StreetGateDto.toStreetEntity(): Street { + return Street( name = name, houseNumber = houseNumber, milestone = milestone, - direction = direction + direction = direction, + namePrefix = namePrefix, + additionalNamePrefix = additionalNamePrefix, + nameSuffix = nameSuffix, + additionalNameSuffix = additionalNameSuffix ) } @@ -203,6 +205,7 @@ fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalE legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) + legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity) }) legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, datatype) @@ -229,6 +232,7 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) + legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) legalEntity.legalAddress = addressOutputRequest.toAddressGateOutput(legalEntity, null, datatype) @@ -237,6 +241,10 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal } +fun toLegalEntityRoles(role: BusinessPartnerRole, legalEntity: LegalEntity): LegalEntityRoles { + return LegalEntityRoles(legalEntity, role) +} + fun toEntityState(dto: LegalEntityStateDto, legalEntity: LegalEntity): LegalEntityState { return LegalEntityState(dto.officialDenotation, dto.validFrom, dto.validTo, dto.type, legalEntity) } @@ -303,7 +311,7 @@ fun AlternativePostalAddress.toAlternativePostalAddressDto(): AlternativePostalA ) val areaDistrictAlternativDto = AreaDistrictAlternativDto( - administrativeAreaLevel1 = null // TODO Add region mapping Logic + administrativeAreaLevel1 = administrativeAreaLevel1 ) return AlternativePostalAddressDto( @@ -326,7 +334,7 @@ fun PhysicalPostalAddress.toPhysicalPostalAddress(): PhysicalPostalAddressGateDt ) val areaDistrictDto = AreaDistrictDto( - administrativeAreaLevel1 = null, // TODO Add region mapping Logic + administrativeAreaLevel1 = administrativeAreaLevel1, administrativeAreaLevel2 = administrativeAreaLevel2, administrativeAreaLevel3 = administrativeAreaLevel3, district = districtLevel1 @@ -352,11 +360,16 @@ fun GeographicCoordinate.toGeographicCoordinateDto(): GeoCoordinateDto { } private fun Street.toStreetDto(): StreetGateDto { + return StreetGateDto( name = name, houseNumber = houseNumber, milestone = milestone, - direction = direction + direction = direction, + namePrefix = namePrefix, + additionalNamePrefix = additionalNamePrefix, + nameSuffix = nameSuffix, + additionalNameSuffix = additionalNameSuffix ) } @@ -385,6 +398,7 @@ fun LegalEntity.toLegalEntityGateInputResponse(legalEntity: LegalEntity): LegalE return LegalEntityGateInputResponse( legalEntity = legalEntity.toLegalEntityDto(), legalAddress = legalAddress.toAddressGateInputResponse(legalAddress), + roles = roles.map { it.roleName }, externalId = legalEntity.externalId, legalNameParts = getNamePartValuesToList(nameParts) ) diff --git a/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql b/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql new file mode 100644 index 000000000..75e5eb26c --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql @@ -0,0 +1,25 @@ +CREATE TABLE roles ( + id BIGINT NOT NULL, + created_at TIMESTAMP WITH time zone NOT NULL, + updated_at TIMESTAMP WITH time zone NOT NULL, + uuid UUID NOT NULL, + address_id BIGINT NULL, + site_id BIGINT NULL, + legal_entity_id BIGINT NULL, + role_name VARCHAR(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE INDEX legal_entity_roles ON roles (legal_entity_id); + +ALTER TABLE IF EXISTS roles ADD CONSTRAINT uuid_roles_uk UNIQUE (uuid); + +ALTER TABLE IF EXISTS roles +ADD CONSTRAINT fk_legal_entity_roles FOREIGN KEY (legal_entity_id) REFERENCES legal_entities; + +ALTER TABLE logistic_addresses +ADD COLUMN IF NOT EXISTS phy_name_prefix VARCHAR(255), +ADD COLUMN IF NOT EXISTS phy_additional_name_prefix VARCHAR(255), +ADD COLUMN IF NOT EXISTS phy_name_suffix VARCHAR(255), +ADD COLUMN IF NOT EXISTS phy_additional_name_suffix VARCHAR(255); + diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index d974e3463..5e6e37cc3 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -183,7 +183,7 @@ object RequestValues { door = CommonValues.door1, ), areaPart = AreaDistrictDto( - administrativeAreaLevel1 = null, + administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_1, administrativeAreaLevel2 = CommonValues.county1, district = CommonValues.district1, ), @@ -204,7 +204,7 @@ object RequestValues { door = CommonValues.door2, ), areaPart = AreaDistrictDto( - administrativeAreaLevel1 = null, + administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_2, administrativeAreaLevel2 = CommonValues.county2, district = CommonValues.district2, ), From 3d2a01661b54c16c840cf3dc8d65966439e93b3a Mon Sep 17 00:00:00 2001 From: alexsilva Date: Thu, 29 Jun 2023 13:51:05 +0100 Subject: [PATCH 2/5] fix(gate): Added Roles for Sites --- .../tractusx/bpdm/gate/entity/LegalEntityRoles.kt | 10 +++++----- .../org/eclipse/tractusx/bpdm/gate/entity/Site.kt | 3 +++ .../gate/service/LegalEntityPersistenceService.kt | 4 ++-- .../tractusx/bpdm/gate/service/ResponseMappings.kt | 12 ++++++++---- .../bpdm/gate/service/SitePersistenceService.kt | 2 ++ .../db/migration/V4_0_0_5__add_roles_table.sql | 1 + 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt index e3b196c1c..c9c708f0c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt @@ -48,15 +48,15 @@ class LegalEntityRoles( @ManyToOne @JoinColumn(name = "legal_entity_id", nullable = false) - var legalEntity: LegalEntity, + var legalEntity: LegalEntity?, // @ManyToOne // @JoinColumn(name = "address_id", nullable = true) // var address: LogisticAddress?, -// -// @ManyToOne -// @JoinColumn(name = "site_id", nullable = true) -// var site: Site?, + + @ManyToOne + @JoinColumn(name = "site_id", nullable = true) + var site: Site?, @Column(name = "role_name", nullable = false) @Enumerated(EnumType.STRING) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt index 1c6a082f6..9b38af095 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt @@ -48,6 +48,9 @@ class Site( @OneToMany(mappedBy = "site", cascade = [CascadeType.ALL], orphanRemoval = true) val addresses: MutableSet = mutableSetOf() + @OneToMany(mappedBy = "site", cascade = [CascadeType.ALL], orphanRemoval = true) + val roles: MutableSet = mutableSetOf() + @ManyToOne(fetch = FetchType.LAZY, cascade = [CascadeType.ALL]) @JoinColumn(name = "main_address_id", nullable = false) lateinit var mainAddress: LogisticAddress diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 6efc426db..5647b2fc7 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -90,7 +90,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity) }) + legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity, null) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity @@ -157,7 +157,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity) }) + legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity, null) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index b4876ecf0..0e759d111 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -145,6 +145,7 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputIn ) site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) + site.roles.addAll(this.site.roles.map { toLegalEntityRoles(it, null, site) }) site.nameParts.addAll(this.site.nameParts.map { toNameParts(it, null, site, null) }.toSet()) site.mainAddress = addressInputRequest.toAddressGate(null, site, datatype) @@ -170,6 +171,8 @@ fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputI site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) site.nameParts.addAll(this.site.nameParts.map { toNameParts(it, null, site, null) }.toSet()) + legalEntity.roles.addAll(this.site.roles.map { toLegalEntityRoles(it, null, site) }) + site.mainAddress = addressOutputRequest.toAddressGateOutput(null, site, datatype) return site @@ -205,7 +208,7 @@ fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalE legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity) }) + legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity, null) }) legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, datatype) @@ -232,7 +235,7 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) - legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity) }) + legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity, null) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) legalEntity.legalAddress = addressOutputRequest.toAddressGateOutput(legalEntity, null, datatype) @@ -241,8 +244,8 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal } -fun toLegalEntityRoles(role: BusinessPartnerRole, legalEntity: LegalEntity): LegalEntityRoles { - return LegalEntityRoles(legalEntity, role) +fun toLegalEntityRoles(role: BusinessPartnerRole, legalEntity: LegalEntity?, site: Site?): LegalEntityRoles { + return LegalEntityRoles(legalEntity, site, role) } fun toEntityState(dto: LegalEntityStateDto, legalEntity: LegalEntity): LegalEntityState { @@ -408,6 +411,7 @@ fun LegalEntity.toLegalEntityGateInputResponse(legalEntity: LegalEntity): LegalE fun Site.toSiteDto(): SiteGateDto { return SiteGateDto( + roles = roles.map { it.roleName }, nameParts = getNamePartValues(nameParts), states = mapToDtoSitesStates(states) ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 6c513dad0..aa38bb740 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -93,6 +93,7 @@ class SitePersistenceService( site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) site.nameParts.replace(updatedSite.site.nameParts.map { toNameParts(it, null, site, null) }) + site.roles.replace(updatedSite.site.roles.map { toLegalEntityRoles(it, null, site) }) } @@ -150,6 +151,7 @@ class SitePersistenceService( site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) site.nameParts.replace(updatedSite.site.nameParts.map { toNameParts(it, null, site, null) }) + site.roles.replace(updatedSite.site.roles.map { toLegalEntityRoles(it, null, site) }) } } \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql b/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql index 75e5eb26c..632fc8bc1 100644 --- a/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql +++ b/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql @@ -15,6 +15,7 @@ CREATE INDEX legal_entity_roles ON roles (legal_entity_id); ALTER TABLE IF EXISTS roles ADD CONSTRAINT uuid_roles_uk UNIQUE (uuid); ALTER TABLE IF EXISTS roles +ADD CONSTRAINT fk_sites_roles FOREIGN KEY (site_id) REFERENCES sites, ADD CONSTRAINT fk_legal_entity_roles FOREIGN KEY (legal_entity_id) REFERENCES legal_entities; ALTER TABLE logistic_addresses From 4688999ca04bb5fe762b2a110b69341d60a02cc4 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Fri, 30 Jun 2023 13:49:01 +0100 Subject: [PATCH 3/5] fix(gate): Added roles for Addresses with mappings for persistence --- .../tractusx/bpdm/gate/entity/LegalEntityRoles.kt | 6 +++--- .../tractusx/bpdm/gate/entity/LogisticAddress.kt | 3 +++ .../gate/service/AddressPersistenceService.kt | 2 ++ .../gate/service/LegalEntityPersistenceService.kt | 5 +++-- .../bpdm/gate/service/ResponseMappings.kt | 15 +++++++++------ .../bpdm/gate/service/SitePersistenceService.kt | 6 ++++-- .../db/migration/V4_0_0_5__add_roles_table.sql | 1 + 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt index c9c708f0c..f0fac167d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt @@ -50,9 +50,9 @@ class LegalEntityRoles( @JoinColumn(name = "legal_entity_id", nullable = false) var legalEntity: LegalEntity?, -// @ManyToOne -// @JoinColumn(name = "address_id", nullable = true) -// var address: LogisticAddress?, + @ManyToOne + @JoinColumn(name = "address_id", nullable = true) + var address: LogisticAddress?, @ManyToOne @JoinColumn(name = "site_id", nullable = true) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt index 1c102d84f..01d97a924 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt @@ -63,4 +63,7 @@ class LogisticAddress( @OneToMany(mappedBy = "address", cascade = [CascadeType.ALL], orphanRemoval = true) val nameParts: MutableSet = mutableSetOf() + + @OneToMany(mappedBy = "address", cascade = [CascadeType.ALL], orphanRemoval = true) + val roles: MutableSet = mutableSetOf() } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index eadb1a728..df8797c30 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -75,6 +75,7 @@ class AddressPersistenceService( address.states.replace(changeAddress.address.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.address.nameParts.map { toNameParts(it, address, null, null) }) + address.roles.replace(changeAddress.address.roles.map { toLegalEntityRoles(it, null, null, address) }) } @@ -116,6 +117,7 @@ class AddressPersistenceService( address.states.replace(changeAddress.address.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.address.nameParts.map { toNameParts(it, address, null, null) }) + address.roles.replace(changeAddress.address.roles.map { toLegalEntityRoles(it, null, null, address) }) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 5647b2fc7..90a33645a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -90,7 +90,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity, null) }) + legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity, null, null) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity @@ -107,6 +107,7 @@ class LegalEntityPersistenceService( address.states.replace(changeAddress.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.nameParts.map { toNameParts(it.namePart, address, null, null) }) + address.roles.replace(changeAddress.roles.map { toLegalEntityRoles(it.roleName, null, null, address) }) } @@ -157,7 +158,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity, null) }) + legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity, null, null) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 0e759d111..e4aa5c273 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -41,6 +41,7 @@ fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site? logisticAddress.states.addAll(this.address.states.map { toEntityAddress(it, logisticAddress) }.toSet()) logisticAddress.nameParts.addAll(this.address.nameParts.map { toNameParts(it, logisticAddress, null, null) }.toSet()) + logisticAddress.roles.addAll(this.address.roles.map { toLegalEntityRoles(it, null, null, logisticAddress) }.toSet()) return logisticAddress } @@ -59,6 +60,7 @@ fun AddressGateOutputRequest.toAddressGateOutput(legalEntity: LegalEntity?, site logisticAddress.states.addAll(this.address.states.map { toEntityAddress(it, logisticAddress) }.toSet()) logisticAddress.nameParts.addAll(this.address.nameParts.map { toNameParts(it, logisticAddress, null, null) }.toSet()) + logisticAddress.roles.addAll(this.address.roles.map { toLegalEntityRoles(it, null, null, logisticAddress) }.toSet()) return logisticAddress } @@ -145,8 +147,8 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputIn ) site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) - site.roles.addAll(this.site.roles.map { toLegalEntityRoles(it, null, site) }) site.nameParts.addAll(this.site.nameParts.map { toNameParts(it, null, site, null) }.toSet()) + site.roles.addAll(this.site.roles.map { toLegalEntityRoles(it, null, site, null) }) site.mainAddress = addressInputRequest.toAddressGate(null, site, datatype) @@ -171,7 +173,7 @@ fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputI site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) site.nameParts.addAll(this.site.nameParts.map { toNameParts(it, null, site, null) }.toSet()) - legalEntity.roles.addAll(this.site.roles.map { toLegalEntityRoles(it, null, site) }) + legalEntity.roles.addAll(this.site.roles.map { toLegalEntityRoles(it, null, site, null) }) site.mainAddress = addressOutputRequest.toAddressGateOutput(null, site, datatype) @@ -208,7 +210,7 @@ fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalE legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity, null) }) + legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity, null, null) }) legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, datatype) @@ -235,7 +237,7 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) - legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity, null) }) + legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity, null, null) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) legalEntity.legalAddress = addressOutputRequest.toAddressGateOutput(legalEntity, null, datatype) @@ -244,8 +246,8 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal } -fun toLegalEntityRoles(role: BusinessPartnerRole, legalEntity: LegalEntity?, site: Site?): LegalEntityRoles { - return LegalEntityRoles(legalEntity, site, role) +fun toLegalEntityRoles(role: BusinessPartnerRole, legalEntity: LegalEntity?, site: Site?, address: LogisticAddress?): LegalEntityRoles { + return LegalEntityRoles(legalEntity, address, site, role) } fun toEntityState(dto: LegalEntityStateDto, legalEntity: LegalEntity): LegalEntityState { @@ -283,6 +285,7 @@ fun LogisticAddress.toLogisticAddressDto(): LogisticAddressGateDto { val logisticAddress = LogisticAddressGateDto( nameParts = getNamePartValues(nameParts), states = mapToDtoStates(states), + roles = roles.map { it.roleName }, physicalPostalAddress = physicalPostalAddress.toPhysicalPostalAddress(), alternativePostalAddress = alternativePostalAddress?.toAlternativePostalAddressDto(), ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index aa38bb740..9ebee3ae4 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -93,7 +93,7 @@ class SitePersistenceService( site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) site.nameParts.replace(updatedSite.site.nameParts.map { toNameParts(it, null, site, null) }) - site.roles.replace(updatedSite.site.roles.map { toLegalEntityRoles(it, null, site) }) + site.roles.replace(updatedSite.site.roles.map { toLegalEntityRoles(it, null, site, null) }) } @@ -106,6 +106,8 @@ class SitePersistenceService( address.states.replace(changeAddress.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.nameParts.map { toNameParts(it.namePart, address, null, null) }) + address.roles.replace(changeAddress.roles.map { toLegalEntityRoles(it.roleName, null, null, address) }) + } fun toEntityAddress(dto: AddressState, address: LogisticAddress): AddressState { @@ -151,7 +153,7 @@ class SitePersistenceService( site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) site.nameParts.replace(updatedSite.site.nameParts.map { toNameParts(it, null, site, null) }) - site.roles.replace(updatedSite.site.roles.map { toLegalEntityRoles(it, null, site) }) + site.roles.replace(updatedSite.site.roles.map { toLegalEntityRoles(it, null, site, null) }) } } \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql b/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql index 632fc8bc1..8e4a47c6b 100644 --- a/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql +++ b/bpdm-gate/src/main/resources/db/migration/V4_0_0_5__add_roles_table.sql @@ -16,6 +16,7 @@ ALTER TABLE IF EXISTS roles ADD CONSTRAINT uuid_roles_uk UNIQUE (uuid); ALTER TABLE IF EXISTS roles ADD CONSTRAINT fk_sites_roles FOREIGN KEY (site_id) REFERENCES sites, +ADD CONSTRAINT fk_addresses_roles FOREIGN KEY (address_id) REFERENCES logistic_addresses, ADD CONSTRAINT fk_legal_entity_roles FOREIGN KEY (legal_entity_id) REFERENCES legal_entities; ALTER TABLE logistic_addresses From ba2b32b182d4b9aca4e0bd95d8f8c7738806b576 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Mon, 3 Jul 2023 15:26:26 +0100 Subject: [PATCH 4/5] fix(gate): Added logic for distinct roles persisted --- .../bpdm/gate/service/AddressPersistenceService.kt | 4 ++-- .../gate/service/LegalEntityPersistenceService.kt | 6 +++--- .../tractusx/bpdm/gate/service/ResponseMappings.kt | 13 +++++++------ .../bpdm/gate/service/SitePersistenceService.kt | 6 +++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index df8797c30..45d7d3587 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -75,7 +75,7 @@ class AddressPersistenceService( address.states.replace(changeAddress.address.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.address.nameParts.map { toNameParts(it, address, null, null) }) - address.roles.replace(changeAddress.address.roles.map { toLegalEntityRoles(it, null, null, address) }) + address.roles.replace(changeAddress.address.roles.distinct().map { toLegalEntityRoles(it, null, null, address) }) } @@ -117,7 +117,7 @@ class AddressPersistenceService( address.states.replace(changeAddress.address.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.address.nameParts.map { toNameParts(it, address, null, null) }) - address.roles.replace(changeAddress.address.roles.map { toLegalEntityRoles(it, null, null, address) }) + address.roles.replace(changeAddress.address.roles.distinct().map { toLegalEntityRoles(it, null, null, address) }) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 90a33645a..3a7890656 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -90,7 +90,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity, null, null) }) + legalEntity.roles.replace(legalEntityRequest.roles.distinct().map { toLegalEntityRoles(it, legalEntity, null, null) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity @@ -107,7 +107,7 @@ class LegalEntityPersistenceService( address.states.replace(changeAddress.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.nameParts.map { toNameParts(it.namePart, address, null, null) }) - address.roles.replace(changeAddress.roles.map { toLegalEntityRoles(it.roleName, null, null, address) }) + address.roles.replace(changeAddress.roles.distinct().map { toLegalEntityRoles(it.roleName, null, null, address) }) } @@ -158,7 +158,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.replace(legalEntityRequest.roles.map { toLegalEntityRoles(it, legalEntity, null, null) }) + legalEntity.roles.replace(legalEntityRequest.roles.distinct().map { toLegalEntityRoles(it, legalEntity, null, null) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index e4aa5c273..0328ed68f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -41,7 +41,7 @@ fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site? logisticAddress.states.addAll(this.address.states.map { toEntityAddress(it, logisticAddress) }.toSet()) logisticAddress.nameParts.addAll(this.address.nameParts.map { toNameParts(it, logisticAddress, null, null) }.toSet()) - logisticAddress.roles.addAll(this.address.roles.map { toLegalEntityRoles(it, null, null, logisticAddress) }.toSet()) + logisticAddress.roles.addAll(this.address.roles.distinct().map { toLegalEntityRoles(it, null, null, logisticAddress) }.toSet()) return logisticAddress } @@ -60,7 +60,7 @@ fun AddressGateOutputRequest.toAddressGateOutput(legalEntity: LegalEntity?, site logisticAddress.states.addAll(this.address.states.map { toEntityAddress(it, logisticAddress) }.toSet()) logisticAddress.nameParts.addAll(this.address.nameParts.map { toNameParts(it, logisticAddress, null, null) }.toSet()) - logisticAddress.roles.addAll(this.address.roles.map { toLegalEntityRoles(it, null, null, logisticAddress) }.toSet()) + logisticAddress.roles.addAll(this.address.roles.distinct().map { toLegalEntityRoles(it, null, null, logisticAddress) }.toSet()) return logisticAddress } @@ -148,7 +148,7 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputIn site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) site.nameParts.addAll(this.site.nameParts.map { toNameParts(it, null, site, null) }.toSet()) - site.roles.addAll(this.site.roles.map { toLegalEntityRoles(it, null, site, null) }) + site.roles.addAll(this.site.roles.distinct().map { toLegalEntityRoles(it, null, site, null) }) site.mainAddress = addressInputRequest.toAddressGate(null, site, datatype) @@ -173,7 +173,7 @@ fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputI site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) site.nameParts.addAll(this.site.nameParts.map { toNameParts(it, null, site, null) }.toSet()) - legalEntity.roles.addAll(this.site.roles.map { toLegalEntityRoles(it, null, site, null) }) + site.roles.addAll(this.site.roles.distinct().map { toLegalEntityRoles(it, null, site, null) }) site.mainAddress = addressOutputRequest.toAddressGateOutput(null, site, datatype) @@ -210,7 +210,7 @@ fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalE legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity, null, null) }) + legalEntity.roles.addAll(this.roles.distinct().map { toLegalEntityRoles(it, legalEntity, null, null) }) legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, datatype) @@ -237,7 +237,7 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) - legalEntity.roles.addAll(this.roles.map { toLegalEntityRoles(it, legalEntity, null, null) }) + legalEntity.roles.addAll(this.roles.distinct().map { toLegalEntityRoles(it, legalEntity, null, null) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) legalEntity.legalAddress = addressOutputRequest.toAddressGateOutput(legalEntity, null, datatype) @@ -470,6 +470,7 @@ fun LegalEntity.toLegalEntityGateOutputResponse(legalEntity: LegalEntity): Legal legalNameParts = getNamePartValues(legalEntity.nameParts), externalId = legalEntity.externalId, bpn = legalEntity.bpn!!, + roles = roles.map { it.roleName }, legalAddress = legalAddress.toAddressGateOutputResponse(legalAddress) ) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 9ebee3ae4..b989cd1d6 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -93,7 +93,7 @@ class SitePersistenceService( site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) site.nameParts.replace(updatedSite.site.nameParts.map { toNameParts(it, null, site, null) }) - site.roles.replace(updatedSite.site.roles.map { toLegalEntityRoles(it, null, site, null) }) + site.roles.replace(updatedSite.site.roles.distinct().map { toLegalEntityRoles(it, null, site, null) }) } @@ -106,7 +106,7 @@ class SitePersistenceService( address.states.replace(changeAddress.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.nameParts.map { toNameParts(it.namePart, address, null, null) }) - address.roles.replace(changeAddress.roles.map { toLegalEntityRoles(it.roleName, null, null, address) }) + address.roles.replace(changeAddress.roles.distinct().map { toLegalEntityRoles(it.roleName, null, null, address) }) } @@ -153,7 +153,7 @@ class SitePersistenceService( site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) site.nameParts.replace(updatedSite.site.nameParts.map { toNameParts(it, null, site, null) }) - site.roles.replace(updatedSite.site.roles.map { toLegalEntityRoles(it, null, site, null) }) + site.roles.replace(updatedSite.site.roles.distinct().map { toLegalEntityRoles(it, null, site, null) }) } } \ No newline at end of file From d3c1c415dc97e0d331548c4cb6df2f645fd0fb97 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Tue, 4 Jul 2023 13:48:09 +0100 Subject: [PATCH 5/5] fix(gate): Name refactoring --- .../tractusx/bpdm/gate/entity/LegalEntity.kt | 2 +- .../tractusx/bpdm/gate/entity/LogisticAddress.kt | 2 +- .../entity/{LegalEntityRoles.kt => Roles.kt} | 2 +- .../eclipse/tractusx/bpdm/gate/entity/Site.kt | 2 +- .../gate/service/AddressPersistenceService.kt | 4 ++-- .../service/LegalEntityPersistenceService.kt | 6 +++--- .../bpdm/gate/service/ResponseMappings.kt | 16 ++++++++-------- .../bpdm/gate/service/SitePersistenceService.kt | 6 +++--- 8 files changed, 20 insertions(+), 20 deletions(-) rename bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/{LegalEntityRoles.kt => Roles.kt} (99%) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt index 71133fce8..d3d69858c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt @@ -58,7 +58,7 @@ class LegalEntity( lateinit var legalAddress: LogisticAddress @OneToMany(mappedBy = "legalEntity", cascade = [CascadeType.ALL], orphanRemoval = true) - val roles: MutableSet = mutableSetOf() + val roles: MutableSet = mutableSetOf() @OneToMany(mappedBy = "legalEntity", cascade = [CascadeType.ALL], orphanRemoval = true) val addresses: MutableSet = mutableSetOf() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt index 01d97a924..40583a029 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt @@ -65,5 +65,5 @@ class LogisticAddress( val nameParts: MutableSet = mutableSetOf() @OneToMany(mappedBy = "address", cascade = [CascadeType.ALL], orphanRemoval = true) - val roles: MutableSet = mutableSetOf() + val roles: MutableSet = mutableSetOf() } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Roles.kt similarity index 99% rename from bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt rename to bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Roles.kt index f0fac167d..afd0f7651 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityRoles.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Roles.kt @@ -44,7 +44,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerRole @Entity @Table(name = "roles") -class LegalEntityRoles( +class Roles( @ManyToOne @JoinColumn(name = "legal_entity_id", nullable = false) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt index 9b38af095..979e6150d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt @@ -49,7 +49,7 @@ class Site( val addresses: MutableSet = mutableSetOf() @OneToMany(mappedBy = "site", cascade = [CascadeType.ALL], orphanRemoval = true) - val roles: MutableSet = mutableSetOf() + val roles: MutableSet = mutableSetOf() @ManyToOne(fetch = FetchType.LAZY, cascade = [CascadeType.ALL]) @JoinColumn(name = "main_address_id", nullable = false) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index 45d7d3587..750429e34 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -75,7 +75,7 @@ class AddressPersistenceService( address.states.replace(changeAddress.address.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.address.nameParts.map { toNameParts(it, address, null, null) }) - address.roles.replace(changeAddress.address.roles.distinct().map { toLegalEntityRoles(it, null, null, address) }) + address.roles.replace(changeAddress.address.roles.distinct().map { toRoles(it, null, null, address) }) } @@ -117,7 +117,7 @@ class AddressPersistenceService( address.states.replace(changeAddress.address.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.address.nameParts.map { toNameParts(it, address, null, null) }) - address.roles.replace(changeAddress.address.roles.distinct().map { toLegalEntityRoles(it, null, null, address) }) + address.roles.replace(changeAddress.address.roles.distinct().map { toRoles(it, null, null, address) }) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 3a7890656..0395803fa 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -90,7 +90,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.replace(legalEntityRequest.roles.distinct().map { toLegalEntityRoles(it, legalEntity, null, null) }) + legalEntity.roles.replace(legalEntityRequest.roles.distinct().map { toRoles(it, legalEntity, null, null) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity @@ -107,7 +107,7 @@ class LegalEntityPersistenceService( address.states.replace(changeAddress.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.nameParts.map { toNameParts(it.namePart, address, null, null) }) - address.roles.replace(changeAddress.roles.distinct().map { toLegalEntityRoles(it.roleName, null, null, address) }) + address.roles.replace(changeAddress.roles.distinct().map { toRoles(it.roleName, null, null, address) }) } @@ -158,7 +158,7 @@ class LegalEntityPersistenceService( legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.replace(legalEntityRequest.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.replace(legalEntityRequest.roles.distinct().map { toLegalEntityRoles(it, legalEntity, null, null) }) + legalEntity.roles.replace(legalEntityRequest.roles.distinct().map { toRoles(it, legalEntity, null, null) }) legalEntity.legalAddress = logisticAddressRecord legalEntity.legalAddress.legalEntity = legalEntity diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 0328ed68f..eb30fb6d9 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -41,7 +41,7 @@ fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site? logisticAddress.states.addAll(this.address.states.map { toEntityAddress(it, logisticAddress) }.toSet()) logisticAddress.nameParts.addAll(this.address.nameParts.map { toNameParts(it, logisticAddress, null, null) }.toSet()) - logisticAddress.roles.addAll(this.address.roles.distinct().map { toLegalEntityRoles(it, null, null, logisticAddress) }.toSet()) + logisticAddress.roles.addAll(this.address.roles.distinct().map { toRoles(it, null, null, logisticAddress) }.toSet()) return logisticAddress } @@ -60,7 +60,7 @@ fun AddressGateOutputRequest.toAddressGateOutput(legalEntity: LegalEntity?, site logisticAddress.states.addAll(this.address.states.map { toEntityAddress(it, logisticAddress) }.toSet()) logisticAddress.nameParts.addAll(this.address.nameParts.map { toNameParts(it, logisticAddress, null, null) }.toSet()) - logisticAddress.roles.addAll(this.address.roles.distinct().map { toLegalEntityRoles(it, null, null, logisticAddress) }.toSet()) + logisticAddress.roles.addAll(this.address.roles.distinct().map { toRoles(it, null, null, logisticAddress) }.toSet()) return logisticAddress } @@ -148,7 +148,7 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputIn site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) site.nameParts.addAll(this.site.nameParts.map { toNameParts(it, null, site, null) }.toSet()) - site.roles.addAll(this.site.roles.distinct().map { toLegalEntityRoles(it, null, site, null) }) + site.roles.addAll(this.site.roles.distinct().map { toRoles(it, null, site, null) }) site.mainAddress = addressInputRequest.toAddressGate(null, site, datatype) @@ -173,7 +173,7 @@ fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputI site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) site.nameParts.addAll(this.site.nameParts.map { toNameParts(it, null, site, null) }.toSet()) - site.roles.addAll(this.site.roles.distinct().map { toLegalEntityRoles(it, null, site, null) }) + site.roles.addAll(this.site.roles.distinct().map { toRoles(it, null, site, null) }) site.mainAddress = addressOutputRequest.toAddressGateOutput(null, site, datatype) @@ -210,7 +210,7 @@ fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalE legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) - legalEntity.roles.addAll(this.roles.distinct().map { toLegalEntityRoles(it, legalEntity, null, null) }) + legalEntity.roles.addAll(this.roles.distinct().map { toRoles(it, legalEntity, null, null) }) legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, datatype) @@ -237,7 +237,7 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) - legalEntity.roles.addAll(this.roles.distinct().map { toLegalEntityRoles(it, legalEntity, null, null) }) + legalEntity.roles.addAll(this.roles.distinct().map { toRoles(it, legalEntity, null, null) }) legalEntity.nameParts.addAll(this.legalNameParts.map { toNameParts(it, null, null, legalEntity) }) legalEntity.legalAddress = addressOutputRequest.toAddressGateOutput(legalEntity, null, datatype) @@ -246,8 +246,8 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal } -fun toLegalEntityRoles(role: BusinessPartnerRole, legalEntity: LegalEntity?, site: Site?, address: LogisticAddress?): LegalEntityRoles { - return LegalEntityRoles(legalEntity, address, site, role) +fun toRoles(role: BusinessPartnerRole, legalEntity: LegalEntity?, site: Site?, address: LogisticAddress?): Roles { + return Roles(legalEntity, address, site, role) } fun toEntityState(dto: LegalEntityStateDto, legalEntity: LegalEntity): LegalEntityState { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index b989cd1d6..890882445 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -93,7 +93,7 @@ class SitePersistenceService( site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) site.nameParts.replace(updatedSite.site.nameParts.map { toNameParts(it, null, site, null) }) - site.roles.replace(updatedSite.site.roles.distinct().map { toLegalEntityRoles(it, null, site, null) }) + site.roles.replace(updatedSite.site.roles.distinct().map { toRoles(it, null, site, null) }) } @@ -106,7 +106,7 @@ class SitePersistenceService( address.states.replace(changeAddress.states.map { toEntityAddress(it, address) }) address.nameParts.replace(changeAddress.nameParts.map { toNameParts(it.namePart, address, null, null) }) - address.roles.replace(changeAddress.roles.distinct().map { toLegalEntityRoles(it.roleName, null, null, address) }) + address.roles.replace(changeAddress.roles.distinct().map { toRoles(it.roleName, null, null, address) }) } @@ -153,7 +153,7 @@ class SitePersistenceService( site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) site.nameParts.replace(updatedSite.site.nameParts.map { toNameParts(it, null, site, null) }) - site.roles.replace(updatedSite.site.roles.distinct().map { toLegalEntityRoles(it, null, site, null) }) + site.roles.replace(updatedSite.site.roles.distinct().map { toRoles(it, null, site, null) }) } } \ No newline at end of file