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

fix(gate) Removed BPN Property from Gate #244

Merged
merged 2 commits into from
Jun 6, 2023
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 @@ -42,6 +42,4 @@ data class AddressGateInputRequest(
@Schema(description = "External id of the related site")
val siteExternalId: String? = null,

@Schema(description = "Business Partner Number")
val bpn: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ data class AddressGateInputResponse(
@Schema(description = "External id of the related site")
val siteExternalId: String? = null,

@Schema(description = "Business Partner Number")
val bpn: String? = null,

@Schema(description = "Time the sharing process was started according to SaaS")
val processStartedAt: LocalDateTime? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@ data class LegalEntityGateInputRequest(
@Schema(description = "ID the record has in the external system where the record originates from", required = true)
val externalId: String,

@Schema(description = "Business Partner Number")
val bpn: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ data class LegalEntityGateInputResponse(
@Schema(description = "ID the record has in the external system where the record originates from", required = true)
val externalId: String,

@Schema(description = "Business Partner Number")
val bpn: String?,

@Schema(description = "Time the sharing process was started according to SaaS")
val processStartedAt: LocalDateTime? = null,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,4 @@ data class SiteGateInputRequest(
@Schema(description = "External id of the related legal entity")
val legalEntityExternalId: String,

@Schema(description = "Business Partner Number")
val bpn: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ data class SiteGateInputResponse(
@Schema(description = "External id of the related legal entity")
val legalEntityExternalId: String,

@Schema(description = "Business Partner Number")
val bpn: String?,

@Schema(description = "Time the sharing process was started according to SaaS")
val processStartedAt: LocalDateTime? = null,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import java.time.Instant
)
class LegalEntity(
@Column(name = "bpn")
var bpn: String?,
var bpn: String? = null,

@Column(name = "externalId", nullable = false, unique = true)
var externalId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.eclipse.tractusx.bpdm.common.model.BaseEntity
)
class LogisticAddress(
@Column(name = "bpn")
var bpn: String?,
var bpn: String? = null,

@Column(name = "external_id", nullable = false, unique = true)
var externalId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.eclipse.tractusx.bpdm.common.model.BaseEntity
@Table(name = "sites")
class Site(
@Column(name = "bpn")
var bpn: String?,
var bpn: String? = null,

@Column(name = "name", nullable = false)
var name: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class AddressPersistenceService(
private fun updateAddress(address: LogisticAddress, changeAddress: AddressGateInputRequest, legalEntityRecord: LegalEntity?, siteRecord: Site?) {

address.name = changeAddress.address.name
address.bpn = changeAddress.bpn
address.externalId = changeAddress.externalId
address.legalEntity = legalEntityRecord
address.site = siteRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class LegalEntityPersistenceService(
legalEntityRequest: LegalEntityGateInputRequest,
logisticAddressRecord: LogisticAddress
): LegalEntity {
legalEntity.bpn = legalEntityRequest.bpn
legalEntity.externalId = legalEntityRequest.externalId
legalEntity.legalForm = legalEntityRequest.legalEntity.legalForm
legalEntity.legalName = Name(value = legalEntityRequest.legalNameParts[0], shortName = legalEntityRequest.legalEntity.legalShortName)
Expand All @@ -82,7 +81,6 @@ class LegalEntityPersistenceService(
private fun updateAddress(address: LogisticAddress, changeAddress: LogisticAddress) {

address.name = changeAddress.name
address.bpn = changeAddress.bpn
address.externalId = changeAddress.externalId
address.legalEntity = changeAddress.legalEntity
address.siteExternalId = changeAddress.siteExternalId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ private fun toValidSingleLegalEntity(legalEntity: LegalEntity): LegalEntityGateI
return LegalEntityGateInputResponse(
legalEntity = legalEntity.toLegalEntityDto(),
legalAddress = legalEntity.legalAddress.toLogisticAddressDto(),
bpn = legalEntity.bpn,
externalId = legalEntity.externalId
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import java.time.temporal.ChronoUnit
fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site?): LogisticAddress {

val logisticAddress = LogisticAddress(
bpn = bpn,
externalId = externalId,
siteExternalId = siteExternalId.toString(),
name = address.name,
Expand Down Expand Up @@ -117,10 +116,9 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity): Site {
)

val site = Site(
bpn = bpn,
name = site.name,
externalId = externalId,
legalEntity = legalEntity
legalEntity = legalEntity,
)

site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet())
Expand Down Expand Up @@ -150,7 +148,6 @@ fun LegalEntityGateInputRequest.toLegalEntity(): LegalEntity {
)

val legalEntity = LegalEntity(
bpn = bpn,
externalId = externalId,
currentness = createCurrentnessTimestamp(),
legalForm = legalEntity.legalForm,
Expand Down Expand Up @@ -198,7 +195,6 @@ fun LogisticAddress.toAddressGateInputResponse(logisticAddressPage: LogisticAddr
externalId = externalId,
legalEntityExternalId = legalEntity?.externalId,
siteExternalId = site?.externalId,
bpn = bpn,
processStartedAt = null //TODO Remove ?
)

Expand Down Expand Up @@ -323,7 +319,6 @@ fun LegalEntity.LegalEntityGateInputResponse(legalEntity: LegalEntity): LegalEnt
legalEntity = legalEntity.toLegalEntityDto(),
legalAddress = legalAddress.toLogisticAddressDto(),
externalId = legalEntity.externalId,
bpn = legalEntity.bpn,
processStartedAt = null
)
}
Expand All @@ -349,7 +344,6 @@ fun Site.toSiteGateInputResponse(sitePage: Site): SiteGateInputResponse {
site = sitePage.toSiteDto(),
externalId = externalId,
legalEntityExternalId = legalEntity.externalId,
bpn = bpn,
processStartedAt = null //TODO Remove this?
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SaasRequestMappingService(
externalId = request.externalId,
dataSource = saasConfigProperties.datasource,
types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.LEGAL_ENTITY.name)),
identifiers = toLegalEntityIdentifiersSaas(legalEntity.identifiers, request.bpn),
identifiers = toLegalEntityIdentifiersSaas(legalEntity.identifiers, ""),
names = toNamesSaas(request.legalNameParts[0]),
// TODO Only the first state is passed to SaaS, any others are ignored
status = legalEntity.states.map { it.toSaasModel() }.firstOrNull(),
Expand All @@ -57,7 +57,7 @@ class SaasRequestMappingService(
externalId = request.externalId,
dataSource = saasConfigProperties.datasource,
types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.ORGANIZATIONAL_UNIT.name)),
identifiers = toIdentifiersSaas(request.bpn),
identifiers = toIdentifiersSaas(""),
names = toNamesSaas(site.name),
status = site.states.map { it.toSaasModel() }.firstOrNull(),
// TODO Known issue: Name, state, BPN-A and identifiers of the main address are not transferred to SaaS yet!!
Expand All @@ -72,7 +72,7 @@ class SaasRequestMappingService(
externalId = request.externalId,
dataSource = saasConfigProperties.datasource,
types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.BP_ADDRESS.name)),
identifiers = toAddressIdentifiersSaas(address.identifiers, request.bpn),
identifiers = toAddressIdentifiersSaas(address.identifiers, ""),
names = toNamesSaas(address.name),
status = address.states.map { it.toSaasModel() }.firstOrNull(),
addresses = toAddressesSaasModel(address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class SitePersistenceService(

private fun updateSite(site: Site, updatedSite: SiteGateInputRequest, legalEntityRecord: LegalEntity) {

site.bpn = updatedSite.bpn
site.name = updatedSite.site.name
site.externalId = updatedSite.externalId
site.legalEntity = legalEntityRecord
Expand All @@ -85,7 +84,6 @@ class SitePersistenceService(
private fun updateAddress(address: LogisticAddress, changeAddress: LogisticAddress) {

address.name = changeAddress.name
address.bpn = changeAddress.bpn
address.externalId = changeAddress.externalId
address.legalEntity = changeAddress.legalEntity
address.siteExternalId = changeAddress.siteExternalId
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE bpdmgate.legal_entities ALTER COLUMN bpn DROP NOT NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -267,24 +267,24 @@ object RequestValues {
legalAddress = address1,
legalNameParts = arrayOf(CommonValues.name1),
externalId = CommonValues.externalId1,
bpn = CommonValues.bpn1

)

val legalEntityGateInputRequest2 = LegalEntityGateInputRequest(
legalEntity = legalEntity2,
legalAddress = address2,
legalNameParts = arrayOf(CommonValues.name3),
externalId = CommonValues.externalId2,
bpn = CommonValues.bpn2
)

)

val legalEntityGateInputRequest3 = LegalEntityGateInputRequest(
legalEntity = legalEntity3,
legalAddress = address3,
legalNameParts = arrayOf(CommonValues.name1),
externalId = CommonValues.externalId3,
bpn = CommonValues.bpn3
)

)

val site1 = SiteGateDto(
name = CommonValues.nameSite1,
Expand All @@ -302,15 +302,15 @@ object RequestValues {
site = site1,
externalId = CommonValues.externalIdSite1,
legalEntityExternalId = CommonValues.externalId1,
bpn = CommonValues.bpnSite1
)

)

val siteGateInputRequest2 = SiteGateInputRequest(
site = site2,
externalId = CommonValues.externalIdSite2,
legalEntityExternalId = CommonValues.externalId2,
bpn = CommonValues.bpnSite2
)

)

val addressGateInputRequest1 = AddressGateInputRequest(
address = address1.copy(
Expand All @@ -321,8 +321,8 @@ object RequestValues {
),
externalId = CommonValues.externalIdAddress1,
legalEntityExternalId = CommonValues.externalId1,
bpn = CommonValues.bpnAddress1
)

)

val addressGateInputRequest2 = AddressGateInputRequest(
address = address2.copy(
Expand All @@ -333,7 +333,7 @@ object RequestValues {
),
externalId = CommonValues.externalIdAddress2,
siteExternalId = CommonValues.externalIdSite1,
bpn = CommonValues.bpnAddress2
)

)

}
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,20 @@ object ResponseValues {
legalEntity = RequestValues.legalEntity1,
legalAddress = RequestValues.address1,
externalId = CommonValues.externalId1,
bpn = CommonValues.bpn1,
processStartedAt = SaasValues.modificationTime1,
)

val legalEntityGateInputResponse2 = LegalEntityGateInputResponse(
legalEntity = RequestValues.legalEntity2,
legalAddress = RequestValues.address2,
externalId = CommonValues.externalId2,
bpn = CommonValues.bpn2,
processStartedAt = SaasValues.modificationTime2,
)

val legalEntityGateInputResponse3 = LegalEntityGateInputResponse(
legalEntity = RequestValues.legalEntity3,
legalAddress = RequestValues.address3,
externalId = CommonValues.externalId3,
bpn = CommonValues.bpn3,
processStartedAt = null,
)

Expand All @@ -306,14 +303,12 @@ object ResponseValues {
legalEntity = RequestValues.legalEntity1,
legalAddress = RequestValues.address1,
externalId = CommonValues.externalId1,
bpn = CommonValues.bpn1,
processStartedAt = null
)
val newLegalEntityGateInputResponse2 = LegalEntityGateInputResponse(
legalEntity = RequestValues.legalEntity2,
legalAddress = RequestValues.address2,
externalId = CommonValues.externalId2,
bpn = CommonValues.bpn2,
processStartedAt = null,
)

Expand Down Expand Up @@ -352,15 +347,13 @@ object ResponseValues {
site = RequestValues.site1,
externalId = CommonValues.externalIdSite1,
legalEntityExternalId = CommonValues.externalId1,
bpn = CommonValues.bpnSite1,
processStartedAt = SaasValues.modificationTime1,
)

val siteGateInputResponse2 = SiteGateInputResponse(
site = RequestValues.site2,
externalId = CommonValues.externalIdSite2,
legalEntityExternalId = CommonValues.externalId2,
bpn = CommonValues.bpnSite2,
processStartedAt = SaasValues.modificationTime2,
)

Expand All @@ -369,15 +362,13 @@ object ResponseValues {
site = RequestValues.site1,
externalId = CommonValues.externalIdSite1,
legalEntityExternalId = CommonValues.externalId1,
bpn = CommonValues.bpnSite1,
processStartedAt = null,
)

val persistenceSiteGateInputResponse2 = SiteGateInputResponse(
site = RequestValues.site2,
externalId = CommonValues.externalIdSite2,
legalEntityExternalId = CommonValues.externalId2,
bpn = CommonValues.bpnSite2,
processStartedAt = null,
)

Expand All @@ -404,7 +395,6 @@ object ResponseValues {
),
externalId = CommonValues.externalIdAddress1,
legalEntityExternalId = CommonValues.externalId1,
bpn = CommonValues.bpnAddress1,
processStartedAt = SaasValues.modificationTime1,
)

Expand All @@ -419,7 +409,6 @@ object ResponseValues {
),
externalId = CommonValues.externalIdAddress2,
siteExternalId = CommonValues.externalIdSite1,
bpn = CommonValues.bpnAddress2,
processStartedAt = SaasValues.modificationTime2,
)

Expand All @@ -441,7 +430,6 @@ object ResponseValues {
),
externalId = CommonValues.externalIdAddress1,
legalEntityExternalId = null,
bpn = CommonValues.bpnAddress1,
processStartedAt = null,
)

Expand All @@ -453,7 +441,6 @@ object ResponseValues {
)
),
externalId = CommonValues.externalIdAddress2,
bpn = CommonValues.bpnAddress2,
siteExternalId = null,
processStartedAt = null,
)
Expand Down