Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Gate): Create or Update sharing states for existing business par… #356

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -113,6 +114,7 @@ class AddressPersistenceService(
gateAddressRepository.save(fullAddress)
}
}
sharingStateService.upsertSharingState(address.toSharingStateDTO(SharingStateType.Success))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -145,6 +146,7 @@ class LegalEntityPersistenceService(
saveChangelog(legalEntity.externalId, datatype)
}
}
sharingStateService.upsertSharingState(legalEntity.toSharingStateDTO(SharingStateType.Success))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, bpn = bpn)
}

fun SiteGateOutputRequest.toSharingStateDTO(sharingStateType: SharingStateType):SharingStateDto {

return SharingStateDto(LsaType.SITE,externalId, sharingStateType = sharingStateType,bpn = bpn)
}

fun LegalEntityGateOutputRequest.toSharingStateDTO(sharingStateType: SharingStateType):SharingStateDto {

return SharingStateDto(LsaType.LEGAL_ENTITY,externalId, sharingStateType = sharingStateType,bpn = bpn)
}


Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -144,6 +145,7 @@ class SitePersistenceService(
saveChangelog(site.externalId, datatype)
}
}
sharingStateService.upsertSharingState(site.toSharingStateDTO(SharingStateType.Success))
}
}

Expand Down