From c9e60d0b5d1c1b9c3fe31ed5e9c05f3e03ac5276 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Wed, 26 Jul 2023 12:25:48 +0100 Subject: [PATCH 1/3] feat(Gate): Create or Update sharing states for existing business partners --- .../request/LegalEntityGateOutputRequest.kt | 19 ------------------- .../gate/service/AddressPersistenceService.kt | 2 ++ .../service/LegalEntityPersistenceService.kt | 2 ++ .../bpdm/gate/service/ResponseMappings.kt | 15 +++++++++++++++ .../gate/service/SitePersistenceService.kt | 2 ++ 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/LegalEntityGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/LegalEntityGateOutputRequest.kt index 9a65bc37f..45b47e796 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/LegalEntityGateOutputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/LegalEntityGateOutputRequest.kt @@ -17,25 +17,6 @@ * 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.api.model.request import com.fasterxml.jackson.annotation.JsonUnwrapped 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 4368616f1..bbf669e98 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 @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.gate.service import jakarta.transaction.Transactional import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace +import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType import org.eclipse.tractusx.bpdm.gate.api.model.request.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.AddressGateOutputRequest import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity @@ -113,6 +114,7 @@ class AddressPersistenceService( gateAddressRepository.save(fullAddress) } } + sharingStateService.upsertSharingState(address.toSharingStateDTO(SharingStateType.Success)) } } 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 52ec40a4d..832ab6487 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 @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType import org.eclipse.tractusx.bpdm.gate.api.model.request.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.LegalEntityGateOutputRequest import org.eclipse.tractusx.bpdm.gate.entity.AddressState @@ -145,6 +146,7 @@ class LegalEntityPersistenceService( saveChangelog(legalEntity.externalId, datatype) } } + sharingStateService.upsertSharingState(legalEntity.toSharingStateDTO(SharingStateType.Success)) } } 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 eed503e2e..fa50b53d8 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 @@ -514,4 +514,19 @@ fun LegalEntityGateInputRequest.toSharingStateDTO():SharingStateDto { return SharingStateDto(LsaType.LEGAL_ENTITY,externalId) } +fun AddressGateOutputRequest.toSharingStateDTO(sharingStateType: SharingStateType):SharingStateDto { + + return SharingStateDto(LsaType.ADDRESS,externalId, sharingStateType = sharingStateType) +} + +fun SiteGateOutputRequest.toSharingStateDTO(sharingStateType: SharingStateType):SharingStateDto { + + return SharingStateDto(LsaType.SITE,externalId, sharingStateType = sharingStateType) +} + +fun LegalEntityGateOutputRequest.toSharingStateDTO(sharingStateType: SharingStateType):SharingStateDto { + + return SharingStateDto(LsaType.LEGAL_ENTITY,externalId, sharingStateType = sharingStateType) +} + 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 2a795ca64..4d49bde8c 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 @@ -23,6 +23,7 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType import org.eclipse.tractusx.bpdm.gate.api.model.request.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.entity.* @@ -144,6 +145,7 @@ class SitePersistenceService( saveChangelog(site.externalId, datatype) } } + sharingStateService.upsertSharingState(site.toSharingStateDTO(SharingStateType.Success)) } } From 7c436bf5974b9f88b1830ee652c6beec38d45fb3 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 27 Jul 2023 13:54:07 +0100 Subject: [PATCH 2/3] feat(bridge): Delete setting the sharing state after writing output --- .../bridge/dummy/service/GateUpdateService.kt | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt index 9991a3cb5..ce681f28e 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt @@ -52,9 +52,6 @@ class GateUpdateService( putLegalEntityOutput( buildLegalEntityGateOutputRequest(requestEntry, entity) ) - upsertSharingState( - buildSuccessSharingStateDto(LsaType.LEGAL_ENTITY, externalId, entity.legalEntity.bpnl, true) - ) } for (errorInfo in responseWrapper.errors) { val externalId = errorInfo.entityKey @@ -78,9 +75,6 @@ class GateUpdateService( putLegalEntityOutput( buildLegalEntityGateOutputRequest(requestEntry, entity) ) - upsertSharingState( - buildSuccessSharingStateDto(LsaType.LEGAL_ENTITY, externalId, bpn, false) - ) } for (errorInfo in responseWrapper.errors) { val bpn = errorInfo.entityKey @@ -102,9 +96,6 @@ class GateUpdateService( putSiteOutput( buildSiteGateOutputRequest(requestEntry, entity) ) - upsertSharingState( - buildSuccessSharingStateDto(LsaType.SITE, externalId, entity.site.bpns, true) - ) } for (errorInfo in responseWrapper.errors) { val externalId = errorInfo.entityKey @@ -127,9 +118,6 @@ class GateUpdateService( putSiteOutput( buildSiteGateOutputRequest(requestEntry, entity) ) - upsertSharingState( - buildSuccessSharingStateDto(LsaType.SITE, externalId, bpn, false) - ) } for (errorInfo in responseWrapper.errors) { val bpn = errorInfo.entityKey @@ -151,9 +139,6 @@ class GateUpdateService( putAddressOutput( buildAddressGateOutputRequest(requestEntry, entity.address) ) - upsertSharingState( - buildSuccessSharingStateDto(LsaType.ADDRESS, externalId, entity.address.bpna, true) - ) } for (errorInfo in responseWrapper.errors) { val externalId = errorInfo.entityKey @@ -176,9 +161,6 @@ class GateUpdateService( putAddressOutput( buildAddressGateOutputRequest(requestEntry, entity) ) - upsertSharingState( - buildSuccessSharingStateDto(LsaType.ADDRESS, externalId, bpn, false) - ) } for (errorInfo in responseWrapper.errors) { val bpn = errorInfo.entityKey From a41a0f20cbf77c2c5605eb7b13111505041bf324 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Mon, 31 Jul 2023 16:52:52 +0100 Subject: [PATCH 3/3] feat(Gate): Add bpn when sharing state is persisted --- .../eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 fa50b53d8..a3f553c78 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 @@ -516,17 +516,17 @@ fun LegalEntityGateInputRequest.toSharingStateDTO():SharingStateDto { fun AddressGateOutputRequest.toSharingStateDTO(sharingStateType: SharingStateType):SharingStateDto { - return SharingStateDto(LsaType.ADDRESS,externalId, sharingStateType = sharingStateType) + return SharingStateDto(LsaType.ADDRESS,externalId, sharingStateType = sharingStateType, bpn = bpn) } fun SiteGateOutputRequest.toSharingStateDTO(sharingStateType: SharingStateType):SharingStateDto { - return SharingStateDto(LsaType.SITE,externalId, sharingStateType = sharingStateType) + return SharingStateDto(LsaType.SITE,externalId, sharingStateType = sharingStateType,bpn = bpn) } fun LegalEntityGateOutputRequest.toSharingStateDTO(sharingStateType: SharingStateType):SharingStateDto { - return SharingStateDto(LsaType.LEGAL_ENTITY,externalId, sharingStateType = sharingStateType) + return SharingStateDto(LsaType.LEGAL_ENTITY,externalId, sharingStateType = sharingStateType,bpn = bpn) }