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: Add confidence criteria to L/S/A business partner model #692

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputChildRequest
import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateDto
import org.eclipse.tractusx.bpdm.pool.api.model.*
import org.eclipse.tractusx.bpdm.pool.api.model.LogisticAddressDto
import java.time.LocalDateTime
import kotlin.reflect.KProperty
import org.eclipse.tractusx.bpdm.gate.api.model.AddressIdentifierDto as Gate_AddressIdentifierDto
import org.eclipse.tractusx.bpdm.gate.api.model.AddressStateDto as Gate_AddressStateDto
Expand All @@ -44,14 +45,24 @@ import org.eclipse.tractusx.bpdm.pool.api.model.LogisticAddressVerboseDto as Poo
import org.eclipse.tractusx.bpdm.pool.api.model.PhysicalPostalAddressDto as Pool_PhysicalPostalAddressDto1
import org.eclipse.tractusx.bpdm.pool.api.model.SiteStateDto as Pool_SiteStateDto

val dummyConfidenceCriteria = ConfidenceCriteriaDto(
sharedByOwner = false,
numberOfBusinessPartners = 1,
checkedByExternalDataSource = false,
lastConfidenceCheckAt = LocalDateTime.now(),
nextConfidenceCheckAt = LocalDateTime.now().plusDays(5),
confidenceLevel = 0
)

fun gateToPoolLegalEntity(gateDto: Gate_LegalEntityDto): Pool_LegalEntityDto {
return Pool_LegalEntityDto(
identifiers = gateDto.identifiers.map(::gateToPoolLegalEntityIdentifier),
legalName = gateDto.legalNameParts.firstOrNull() ?: "",
legalShortName = gateDto.legalShortName,
legalForm = gateDto.legalForm,
states = gateDto.states.map(::gateToPoolLegalEntityState),
classifications = gateDto.classifications.map(::gateToPoolLegalEntityClassification)
classifications = gateDto.classifications.map(::gateToPoolLegalEntityClassification),
confidenceCriteria = dummyConfidenceCriteria
)
}

Expand Down Expand Up @@ -93,7 +104,8 @@ fun gateToPoolLogisticAddress(gateDto: Gate_LogisticAddressDto): LogisticAddress
states = gateDto.states.map(::gateToPoolAddressState),
identifiers = gateDto.identifiers.map(::gateToPoolAddressIdentifier),
physicalPostalAddress = gateToPoolPhysicalAddress(gateDto.physicalPostalAddress),
alternativePostalAddress = gateDto.alternativePostalAddress?.let(::gateToPoolAlternativeAddress)
alternativePostalAddress = gateDto.alternativePostalAddress?.let(::gateToPoolAlternativeAddress),
confidenceCriteria = dummyConfidenceCriteria
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class PoolUpdateService(
name = entry.site.nameParts.firstOrNull() ?: "",
states = entry.site.states.map(::gateToPoolSiteState),
mainAddress = gateToPoolLogisticAddress(entry.mainAddress),
confidenceCriteria = dummyConfidenceCriteria
),
index = entry.externalId,
bpnlParent = leParentBpn
Expand All @@ -101,6 +102,7 @@ class PoolUpdateService(
name = it.site.nameParts.firstOrNull() ?: "",
states = it.site.states.map(::gateToPoolSiteState),
mainAddress = gateToPoolLogisticAddress(it.mainAddress),
confidenceCriteria = dummyConfidenceCriteria
),
bpns = it.bpn!!
)
Expand Down Expand Up @@ -141,7 +143,8 @@ class PoolUpdateService(
states = entry.address.states.map(::gateToPoolAddressState),
identifiers = entry.address.identifiers.map(::gateToPoolAddressIdentifier),
physicalPostalAddress = gateToPoolPhysicalAddress(entry.address.physicalPostalAddress),
alternativePostalAddress = entry.address.alternativePostalAddress?.let(::gateToPoolAlternativeAddress)
alternativePostalAddress = entry.address.alternativePostalAddress?.let(::gateToPoolAlternativeAddress),
confidenceCriteria = dummyConfidenceCriteria
),
index = entry.externalId,
bpnParent = siteParentBpn
Expand Down Expand Up @@ -181,7 +184,8 @@ class PoolUpdateService(
states = it.address.states.map(::gateToPoolAddressState),
identifiers = it.address.identifiers.map(::gateToPoolAddressIdentifier),
physicalPostalAddress = gateToPoolPhysicalAddress(it.address.physicalPostalAddress),
alternativePostalAddress = it.address.alternativePostalAddress?.let(::gateToPoolAlternativeAddress)
alternativePostalAddress = it.address.alternativePostalAddress?.let(::gateToPoolAlternativeAddress),
confidenceCriteria = dummyConfidenceCriteria
),
bpna = it.bpn!!
)
Expand All @@ -190,5 +194,4 @@ class PoolUpdateService(
return poolClient.addresses.updateAddresses(updateRequests)
.also { logger.info { "Pool accepted ${it.entityCount} updated addresses, ${it.errorCount} were refused" } }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ package org.eclipse.tractusx.bpdm.cleaning.service

import org.eclipse.tractusx.bpdm.common.dto.AddressType
import org.eclipse.tractusx.orchestrator.api.model.*
import java.time.LocalDateTime


val dummyConfidenceCriteria = ConfidenceCriteria(
sharedByOwner = false,
numberOfBusinessPartners = 1,
checkedByExternalDataSource = false,
lastConfidenceCheckAt = LocalDateTime.now(),
nextConfidenceCheckAt = LocalDateTime.now().plusDays(5),
confidenceLevel = 0
)

fun BusinessPartnerGenericDto.toLegalEntityDto(bpnReferenceDto: BpnReferenceDto, legalAddress: LogisticAddressDto): LegalEntityDto {

return LegalEntityDto(
Expand All @@ -35,8 +45,8 @@ fun BusinessPartnerGenericDto.toLegalEntityDto(bpnReferenceDto: BpnReferenceDto,
legalForm = legalEntity.legalForm,
states = states.mapNotNull { it.toLegalEntityState() },
classifications = legalEntity.classifications.map { it.toLegalEntityClassificationDto() },
legalAddress = legalAddress

legalAddress = legalAddress,
confidenceCriteria = dummyConfidenceCriteria
)
}

Expand Down Expand Up @@ -75,7 +85,8 @@ fun BusinessPartnerGenericDto.toLogisticAddressDto(bpnReferenceDto: BpnReference
states = emptyList(),
identifiers = emptyList(),
physicalPostalAddress = address.physicalPostalAddress,
alternativePostalAddress = address.alternativePostalAddress
alternativePostalAddress = address.alternativePostalAddress,
confidenceCriteria = dummyConfidenceCriteria
)
}

Expand All @@ -87,8 +98,8 @@ fun BusinessPartnerGenericDto.toSiteDto(bpnReferenceDto: BpnReferenceDto, siteAd
hasChanged = address.addressType in setOf(AddressType.SiteMainAddress, AddressType.LegalAndSiteMainAddress),
name = site.name,
states = states.mapNotNull { it.toSiteState() },
mainAddress = siteAddressReference

mainAddress = siteAddressReference,
confidenceCriteria = dummyConfidenceCriteria
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
package org.eclipse.tractusx.bpdm.cleaning.testdata

import com.neovisionaries.i18n.CountryCode
import org.eclipse.tractusx.bpdm.cleaning.service.toLegalEntityClassificationDto
import org.eclipse.tractusx.bpdm.cleaning.service.toLegalEntityIdentifierDto
import org.eclipse.tractusx.bpdm.cleaning.service.toLegalEntityState
import org.eclipse.tractusx.bpdm.cleaning.service.toSiteState
import org.eclipse.tractusx.bpdm.cleaning.service.*
import org.eclipse.tractusx.bpdm.common.dto.AddressType
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole
import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto
Expand Down Expand Up @@ -183,13 +180,15 @@ object CommonValues {
identifiers = identifiers.mapNotNull { it.toLegalEntityIdentifierDto() },
legalForm = legalForm,
states = states.mapNotNull { it.toLegalEntityState() },
classifications = classifications.map { it.toLegalEntityClassificationDto() }
classifications = classifications.map { it.toLegalEntityClassificationDto() },
confidenceCriteria = dummyConfidenceCriteria
)

val expectedSiteDto = SiteDto(
hasChanged = true,
name = siteName,
states = states.mapNotNull { it.toSiteState() },
confidenceCriteria = dummyConfidenceCriteria
)

val expectedLogisticAddressDto = LogisticAddressDto(
Expand All @@ -198,7 +197,8 @@ object CommonValues {
name = addressName,
states = emptyList(),
identifiers = emptyList(),
physicalPostalAddress = physicalPostalAddress
physicalPostalAddress = physicalPostalAddress,
confidenceCriteria = dummyConfidenceCriteria
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ interface IBaseLegalEntityDto {

@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.classifications, required = false))
val classifications: Collection<ILegalEntityClassificationDto>

val confidenceCriteria: IConfidenceCriteriaDto?
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ interface IBaseLogisticAddressDto {
// TODO OpenAPI description for complex field does not work!!
@get:Schema(description = LogisticAddressDescription.alternativePostalAddress)
val alternativePostalAddress: IBaseAlternativePostalAddressDto?

val confidenceCriteria: IConfidenceCriteriaDto?
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ interface IBaseSiteDto {

@get:ArraySchema(arraySchema = Schema(description = SiteDescription.states))
val states: Collection<ISiteStateDto>

val confidenceCriteria: IConfidenceCriteriaDto
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* 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.common.dto

import java.time.LocalDateTime

interface IConfidenceCriteriaDto {
val sharedByOwner: Boolean?
val checkedByExternalDataSource: Boolean?
val numberOfBusinessPartners: Int?
val lastConfidenceCheckAt: LocalDateTime?
val nextConfidenceCheckAt: LocalDateTime?
val confidenceLevel: Int?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* 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

import org.eclipse.tractusx.bpdm.common.dto.IConfidenceCriteriaDto
import java.time.LocalDateTime

data class ConfidenceCriteriaDto(
override val sharedByOwner: Boolean?,
override val checkedByExternalDataSource: Boolean?,
override val numberOfBusinessPartners: Int?,
override val lastConfidenceCheckAt: LocalDateTime?,
override val nextConfidenceCheckAt: LocalDateTime?,
override val confidenceLevel: Int?

) : IConfidenceCriteriaDto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ data class LegalEntityDto(
override val classifications: Collection<LegalEntityClassificationDto> = emptyList(),

@get:ArraySchema(arraySchema = Schema(description = CommonDescription.roles))
val roles: Collection<BusinessPartnerRole> = emptyList()
val roles: Collection<BusinessPartnerRole> = emptyList(),

override val confidenceCriteria: ConfidenceCriteriaDto? = null

) : IBaseLegalEntityDto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ data class LogisticAddressDto(
override val alternativePostalAddress: AlternativePostalAddressDto? = null,

@get:ArraySchema(arraySchema = Schema(description = LogisticAddressDescription.roles))
val roles: Collection<BusinessPartnerRole> = emptyList()
val roles: Collection<BusinessPartnerRole> = emptyList(),

override val confidenceCriteria: ConfidenceCriteriaDto? = null

) : IBaseLogisticAddressDto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* 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.orchestrator.api.model

import org.eclipse.tractusx.bpdm.common.dto.IConfidenceCriteriaDto
import java.time.LocalDateTime

data class ConfidenceCriteria(
override val sharedByOwner: Boolean? = null,
override val checkedByExternalDataSource: Boolean? = null,
override val numberOfBusinessPartners: Int? = null,
override val lastConfidenceCheckAt: LocalDateTime? = null,
override val nextConfidenceCheckAt: LocalDateTime? = null,
override val confidenceLevel: Int? = null
) : IConfidenceCriteriaDto
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ data class LegalEntityDto(

override val classifications: Collection<LegalEntityClassificationDto> = emptyList(),

val legalAddress: LogisticAddressDto? = null
val legalAddress: LogisticAddressDto? = null,

override val confidenceCriteria: ConfidenceCriteria = ConfidenceCriteria()

) : IBaseLegalEntityDto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ data class LogisticAddressDto(

override val physicalPostalAddress: PhysicalPostalAddressDto? = null,

override val alternativePostalAddress: AlternativePostalAddressDto? = null
override val alternativePostalAddress: AlternativePostalAddressDto? = null,

override val confidenceCriteria: ConfidenceCriteria = ConfidenceCriteria()

) : IBaseLogisticAddressDto
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ data class SiteDto(
override val name: String? = null,
override val states: Collection<SiteStateDto> = emptyList(),

val mainAddress: LogisticAddressDto? = null
val mainAddress: LogisticAddressDto? = null,

override val confidenceCriteria: ConfidenceCriteria = ConfidenceCriteria()

) : IBaseSiteDto