Skip to content

Commit

Permalink
Merge pull request #683 from catenax-ng/feat/generic-lsa-parts-orches…
Browse files Browse the repository at this point in the history
…trator

Feat(Orchestrator): Separate LSA attributes in generic business partner
  • Loading branch information
nicoprow authored Dec 21, 2023
2 parents 5147633 + 892338e commit 6356c8b
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.eclipse.tractusx.bpdm.common.dto

import com.fasterxml.jackson.annotation.JsonIgnore
import io.swagger.v3.oas.annotations.media.ArraySchema
import io.swagger.v3.oas.annotations.media.Schema

Expand All @@ -27,37 +28,82 @@ interface IBaseBusinessPartnerDto {
@get:ArraySchema(arraySchema = Schema(description = "The list of name parts to accommodate the different number of name fields in different systems."))
val nameParts: List<String>

@get:Schema(description = "Abbreviated name or shorthand.")
val shortName: String?

@get:ArraySchema(arraySchema = Schema(description = "The list of identifiers of the business partner. Sorted and duplicates removed by the service."))
val identifiers: Collection<IBusinessPartnerIdentifierDto>

@get:Schema(description = "The name according to official registers.")
@get:ArraySchema(arraySchema = Schema(description = "The list of (temporary) states of the business partner. Sorted and duplicates removed by the service."))
val states: Collection<IBusinessPartnerStateDto>

@get:ArraySchema(arraySchema = Schema(description = "Roles this business partner takes in relation to the sharing member. Sorted and duplicates removed by the service."))
val roles: Collection<BusinessPartnerRole>

val legalEntity: IBaseLegalEntityComponent

val site: IBaseSiteComponent

val address: IBaseAddressComponent

// Overrides to satisfy the base class but will be not shown on API level.
// That way other modules using this business partner are still backwards compatible and can be adapted one after another
// ToDo: Once all other BPDM module models and mappings are adapted, update the Base Interface and delete the overrides

val legalEntityBpn: String?
@JsonIgnore
get() = legalEntity.bpnL

val legalName: String?
@JsonIgnore
get() = legalEntity.legalName

@get:Schema(description = "Technical key of the legal form.")
val legalForm: String?
val shortName: String?
@JsonIgnore
get() = legalEntity.shortName

@get:ArraySchema(arraySchema = Schema(description = "The list of (temporary) states of the business partner. Sorted and duplicates removed by the service."))
val states: Collection<IBusinessPartnerStateDto>
val legalForm: String?
@JsonIgnore
get() = legalEntity.legalForm

@get:ArraySchema(arraySchema = Schema(description = "The list of classifications of the business partner, such as a specific industry. Sorted and duplicates removed by the service."))
val classifications: Collection<IBusinessPartnerClassificationDto>
@JsonIgnore
get() = legalEntity.classifications

@get:ArraySchema(arraySchema = Schema(description = "Roles this business partner takes in relation to the sharing member. Sorted and duplicates removed by the service."))
val roles: Collection<BusinessPartnerRole>
val siteBpn: String?
@JsonIgnore
get() = site.bpnS

val addressBpn: String?
@JsonIgnore
get() = address.bpnA

@get:Schema(description = "Address of the official seat of this business partner.")
val postalAddress: IBaseBusinessPartnerPostalAddressDto
@JsonIgnore
get() = address
}

interface IBaseLegalEntityComponent {

// TODO: rename to bpnL, bpnS, bpnA (breaking change!)
@get:Schema(description = "BPNL of the golden record legal entity this business partner refers to")
val legalEntityBpn: String?
val bpnL: String?

@get:Schema(description = "The name according to official registers.")
val legalName: String?

@get:Schema(description = "Abbreviated name or shorthand.")
val shortName: String?

@get:Schema(description = "Technical key of the legal form.")
val legalForm: String?

@get:ArraySchema(arraySchema = Schema(description = "The list of classifications of the business partner, such as a specific industry. Sorted and duplicates removed by the service."))
val classifications: Collection<IBusinessPartnerClassificationDto>
}

interface IBaseSiteComponent {
@get:Schema(description = "BPNS of the golden record site this business partner refers to")
val siteBpn: String?
val bpnS: String?
}

interface IBaseAddressComponent : IBaseBusinessPartnerPostalAddressDto {
@get:Schema(description = "BPNA of the golden record address this business partner refers to")
val addressBpn: String?
}
val bpnA: String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@

package org.eclipse.tractusx.bpdm.gate.api.model

import com.fasterxml.jackson.annotation.JsonIgnore
import io.swagger.v3.oas.annotations.media.ArraySchema
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerDto
import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerPostalAddressDto
import org.eclipse.tractusx.bpdm.common.dto.IBusinessPartnerClassificationDto
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription

interface IBaseBusinessPartnerGateDto : IBaseBusinessPartnerDto {
Expand All @@ -34,74 +30,5 @@ interface IBaseBusinessPartnerGateDto : IBaseBusinessPartnerDto {

@get:Schema(description = "True if the sharing member declares itself as the owner of the business partner.")
val isOwnCompanyData: Boolean

val legalEntity: IBaseLegalEntityComponent

val site: IBaseSiteComponent

val address: IBaseAddressComponent

// Overrides to satisfy the base class but will be not shown on API level.
// That way we inherit from the base but keep the Gate model changes separate from now
// ToDo: Once all other BPDM module models are adapted, update the Base Interface and delete the overrides

override val legalEntityBpn: String?
@JsonIgnore
get() = legalEntity.bpnL

override val legalName: String?
@JsonIgnore
get() = legalEntity.legalName

override val shortName: String?
@JsonIgnore
get() = legalEntity.shortName

override val legalForm: String?
@JsonIgnore
get() = legalEntity.legalForm

override val classifications: Collection<IBusinessPartnerClassificationDto>
@JsonIgnore
get() = legalEntity.classifications

override val siteBpn: String?
@JsonIgnore
get() = site.bpnS

override val addressBpn: String?
@JsonIgnore
get() = address.bpnA

override val postalAddress: IBaseBusinessPartnerPostalAddressDto
@JsonIgnore
get() = address
}

interface IBaseLegalEntityComponent {

@get:Schema(description = "BPNL of the golden record legal entity this business partner refers to")
val bpnL: String?

@get:Schema(description = "The name according to official registers.")
val legalName: String?

@get:Schema(description = "Abbreviated name or shorthand.")
val shortName: String?

@get:Schema(description = "Technical key of the legal form.")
val legalForm: String?

@get:ArraySchema(arraySchema = Schema(description = "The list of classifications of the business partner, such as a specific industry. Sorted and duplicates removed by the service."))
val classifications: Collection<IBusinessPartnerClassificationDto>
}

interface IBaseSiteComponent {
@get:Schema(description = "BPNS of the golden record site this business partner refers to")
val bpnS: String?
}

interface IBaseAddressComponent : IBaseBusinessPartnerPostalAddressDto {
@get:Schema(description = "BPNA of the golden record address this business partner refers to")
val bpnA: String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
package org.eclipse.tractusx.bpdm.gate.api.model.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.AddressType
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole
import org.eclipse.tractusx.bpdm.common.dto.*
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription
import org.eclipse.tractusx.bpdm.gate.api.model.*
import java.time.Instant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
package org.eclipse.tractusx.bpdm.gate.api.model.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.AddressType
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole
import org.eclipse.tractusx.bpdm.common.dto.*
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription
import org.eclipse.tractusx.bpdm.gate.api.model.*
import java.time.Instant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,120 @@

package org.eclipse.tractusx.orchestrator.api.model

import com.fasterxml.jackson.annotation.JsonIgnore
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole
import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerDto
import org.eclipse.tractusx.bpdm.common.dto.*


@Schema(
description = "Generic business partner with external id"
)
data class BusinessPartnerGenericDto(

override val nameParts: List<String> = emptyList(),
override val shortName: String? = null,
override val identifiers: Collection<BusinessPartnerIdentifierDto> = emptyList(),
override val legalName: String? = null,
override val legalForm: String? = null,
override val states: Collection<BusinessPartnerStateDto> = emptyList(),
override val classifications: Collection<BusinessPartnerClassificationDto> = emptyList(),
override val roles: Collection<BusinessPartnerRole> = emptyList(),
override val postalAddress: PostalAddressDto = PostalAddressDto(),
override val legalEntityBpn: String? = null,
override val siteBpn: String? = null,
override val addressBpn: String? = null,

override val legalEntity: LegalEntityComponent = LegalEntityComponent(),
override val site: SiteComponent = SiteComponent(),
override val address: AddressComponent = AddressComponent(),
@get:Schema(description = "The BPNL of the company sharing and claiming this business partner as its own")
val ownerBpnL: String? = null
) : IBaseBusinessPartnerDto {
// Backwards compatibility so changes to this DTO can be done one module at a time
constructor(
nameParts: List<String> = emptyList(),
shortName: String? = null,
identifiers: Collection<BusinessPartnerIdentifierDto> = emptyList(),
legalName: String? = null,
legalForm: String? = null,
states: Collection<BusinessPartnerStateDto> = emptyList(),
classifications: Collection<BusinessPartnerClassificationDto> = emptyList(),
roles: Collection<BusinessPartnerRole> = emptyList(),
postalAddress: PostalAddressDto = PostalAddressDto(),
legalEntityBpn: String? = null,
siteBpn: String? = null,
addressBpn: String? = null,
ownerBpnL: String? = null
) : this(
nameParts = nameParts,
identifiers = identifiers,
states = states,
roles = roles,
ownerBpnL = ownerBpnL,
legalEntity = LegalEntityComponent(
bpnL = legalEntityBpn,
legalName = legalName,
shortName = shortName,
legalForm = legalForm,
classifications = classifications
),
site = SiteComponent(
bpnS = siteBpn
),
address = AddressComponent(
bpnA = addressBpn,
addressType = postalAddress.addressType,
physicalPostalAddress = postalAddress.physicalPostalAddress,
alternativePostalAddress = postalAddress.alternativePostalAddress
)
)

override val classifications: Collection<BusinessPartnerClassificationDto>
@JsonIgnore
get() = legalEntity.classifications

override val postalAddress: PostalAddressDto
@JsonIgnore
get() = PostalAddressDto(address.addressType, address.physicalPostalAddress, address.alternativePostalAddress)

fun copy(
nameParts: List<String> = this.nameParts,
shortName: String? = this.shortName,
identifiers: Collection<BusinessPartnerIdentifierDto> = this.identifiers,
legalName: String? = this.legalName,
legalForm: String? = this.legalForm,
states: Collection<BusinessPartnerStateDto> = this.states,
classifications: Collection<BusinessPartnerClassificationDto> = this.classifications,
roles: Collection<BusinessPartnerRole> = this.roles,
postalAddress: PostalAddressDto = this.postalAddress,
legalEntityBpn: String? = this.legalEntityBpn,
siteBpn: String? = this.siteBpn,
addressBpn: String? = this.addressBpn,
ownerBpnL: String? = this.ownerBpnL
) = BusinessPartnerGenericDto(
nameParts,
shortName,
identifiers,
legalName,
legalForm,
states,
classifications,
roles,
postalAddress,
legalEntityBpn,
siteBpn,
addressBpn,
ownerBpnL
)
}

data class LegalEntityComponent(
override val bpnL: String? = null,
override val legalName: String? = null,
override val shortName: String? = null,
override val legalForm: String? = null,
override val classifications: Collection<BusinessPartnerClassificationDto> = emptyList()
) : IBaseLegalEntityComponent

data class SiteComponent(
override val bpnS: String? = null
) : IBaseSiteComponent

data class AddressComponent(
override val bpnA: String? = null,
override val addressType: AddressType? = null,
override val physicalPostalAddress: PhysicalPostalAddressDto? = null,
override val alternativePostalAddress: AlternativePostalAddressDto? = null
) : IBaseAddressComponent


) : IBaseBusinessPartnerDto
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,11 @@ class GoldenRecordTaskControllerIT @Autowired constructor(

// resolve task again
val businessPartnerFull2 = businessPartnerFull1.copy(
generic = businessPartnerFull1.generic.copy(
legalEntityBpn = "BPNL-test"
)
generic = with(businessPartnerFull1.generic) {
copy(
legalEntity = legalEntity.copy(bpnL = "BPNL-test")
)
}
)
val resultEntry2 = TaskStepResultEntryDto(
taskId = taskId,
Expand Down
Loading

0 comments on commit 6356c8b

Please sign in to comment.