Skip to content

Commit

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

feat(Gate): separate L/S/A attributes in generic business partner model
  • Loading branch information
nicoprow authored Dec 15, 2023
2 parents 4f6bc2a + 30751a7 commit 5147633
Show file tree
Hide file tree
Showing 10 changed files with 352 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@

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 @@ -30,4 +34,74 @@ 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 @@ -21,7 +21,12 @@ package org.eclipse.tractusx.bpdm.gate.api.model.request

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole
import org.eclipse.tractusx.bpdm.gate.api.model.*
import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerIdentifierDto
import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerStateDto
import org.eclipse.tractusx.bpdm.gate.api.model.IBaseBusinessPartnerGateDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.AddressComponentInputDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.LegalEntityComponentInputDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.SiteComponentInputDto

@Schema(
description = "Generic business partner with external id",
Expand All @@ -31,17 +36,12 @@ data class BusinessPartnerInputRequest(

override val externalId: String,
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: BusinessPartnerPostalAddressDto = BusinessPartnerPostalAddressDto(),
override val isOwnCompanyData: Boolean = false,
override val legalEntityBpn: String? = null,
override val siteBpn: String? = null,
override val addressBpn: String? = null
override val legalEntity: LegalEntityComponentInputDto = LegalEntityComponentInputDto(),
override val site: SiteComponentInputDto = SiteComponentInputDto(),
override val address: AddressComponentInputDto = AddressComponentInputDto()

) : IBaseBusinessPartnerGateDto

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +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.openapidescription.CommonDescription
import org.eclipse.tractusx.bpdm.gate.api.model.*
Expand All @@ -28,24 +29,19 @@ import java.time.Instant

@Schema(
description = "Generic business partner with external id",
requiredProperties = ["externalId", "postalAddress"]
requiredProperties = ["externalId", "postalAddress", "bpnL", "bpnA"]
)
data class BusinessPartnerInputDto(

override val externalId: String,
override val nameParts: List<String> = emptyList(),
override val shortName: String?,
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: BusinessPartnerPostalAddressDto,
override val isOwnCompanyData: Boolean,
override val legalEntityBpn: String?,
override val siteBpn: String?,
override val addressBpn: String?,
override val isOwnCompanyData: Boolean = false,
override val legalEntity: LegalEntityComponentInputDto = LegalEntityComponentInputDto(),
override val site: SiteComponentInputDto = SiteComponentInputDto(),
override val address: AddressComponentInputDto = AddressComponentInputDto(),

@get:Schema(description = CommonDescription.createdAt)
val createdAt: Instant,
Expand All @@ -54,3 +50,22 @@ data class BusinessPartnerInputDto(
val updatedAt: Instant

) : IBaseBusinessPartnerGateDto

data class LegalEntityComponentInputDto(
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 SiteComponentInputDto(
override val bpnS: String? = null
) : IBaseSiteComponent

data class AddressComponentInputDto(
override val bpnA: String? = null,
override val addressType: AddressType? = null,
override val physicalPostalAddress: PhysicalPostalAddressDto = PhysicalPostalAddressDto(),
override val alternativePostalAddress: AlternativePostalAddressDto = AlternativePostalAddressDto()
) : IBaseAddressComponent
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,27 @@
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.openapidescription.CommonDescription
import org.eclipse.tractusx.bpdm.gate.api.model.*
import java.time.Instant

@Schema(
description = "Generic business partner output with external id",
requiredProperties = ["externalId", "postalAddress", "bpnL", "bpnA"]
requiredProperties = ["externalId"]
)
data class BusinessPartnerOutputDto(

override val externalId: String,
override val nameParts: List<String> = emptyList(),
override val shortName: String?,
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: BusinessPartnerPostalAddressDto,
override val isOwnCompanyData: Boolean,
override val legalEntityBpn: String,
override val siteBpn: String?,
override val addressBpn: String,
override val isOwnCompanyData: Boolean = false,
override val legalEntity: LegalEntityComponentOutputDto,
override val site: SiteComponentOutputDto = SiteComponentOutputDto(),
override val address: AddressComponentOutputDto,

@get:Schema(description = CommonDescription.createdAt)
val createdAt: Instant,
Expand All @@ -53,3 +49,33 @@ data class BusinessPartnerOutputDto(
val updatedAt: Instant

) : IBaseBusinessPartnerGateDto

@Schema(
description = "Legal Entity properties of business partner output data",
requiredProperties = ["bpnL"]
)
data class LegalEntityComponentOutputDto(
override val bpnL: String,
override val legalName: String? = null,
override val shortName: String? = null,
override val legalForm: String? = null,
override val classifications: Collection<BusinessPartnerClassificationDto> = emptyList()
) : IBaseLegalEntityComponent

@Schema(
description = "Site properties of business partner output data"
)
data class SiteComponentOutputDto(
override val bpnS: String? = null
) : IBaseSiteComponent

@Schema(
description = "Address properties of business partner output data",
requiredProperties = ["bpnA"]
)
data class AddressComponentOutputDto(
override val bpnA: String,
override val addressType: AddressType? = null,
override val physicalPostalAddress: PhysicalPostalAddressDto = PhysicalPostalAddressDto(),
override val alternativePostalAddress: AlternativePostalAddressDto = AlternativePostalAddressDto()
) : IBaseAddressComponent
Loading

0 comments on commit 5147633

Please sign in to comment.