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

Refactoring: Generic Business Partner DTO Locations #635

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.
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 @@ -20,8 +20,6 @@
package org.eclipse.tractusx.bpdm.cleaning.service


import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerIdentifierDto
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerStateDto
import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto
import org.eclipse.tractusx.orchestrator.api.model.*

Expand All @@ -36,13 +34,13 @@ fun BusinessPartnerGenericDto.toLegalEntityDto(bpnReferenceDto: BpnReferenceDto,
identifiers = identifiers.mapNotNull { it.toLegalEntityIdentifierDto() },
legalForm = legalForm,
states = states.mapNotNull { it.toLegalEntityState() },
classifications = classifications.map { it.toBusinessPartnerClassificationDto() },
classifications = classifications.map { it.toLegalEntityClassificationDto() },
legalAddress = legalAddress

)
}

fun ClassificationDto.toBusinessPartnerClassificationDto(): ClassificationDto {
fun BusinessPartnerClassificationDto.toLegalEntityClassificationDto(): ClassificationDto {

return ClassificationDto(code = code, type = type, value = value)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,16 @@
package org.eclipse.tractusx.bpdm.cleaning.testdata

import com.neovisionaries.i18n.CountryCode
import org.eclipse.tractusx.bpdm.cleaning.service.toBusinessPartnerClassificationDto
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.common.dto.*
import org.eclipse.tractusx.bpdm.common.dto.AddressType
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole
import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import org.eclipse.tractusx.bpdm.common.model.ClassificationType
import org.eclipse.tractusx.orchestrator.api.model.*
import org.eclipse.tractusx.orchestrator.api.model.LegalEntityDto
import org.eclipse.tractusx.orchestrator.api.model.LogisticAddressDto
import org.eclipse.tractusx.orchestrator.api.model.PhysicalPostalAddressDto
import org.eclipse.tractusx.orchestrator.api.model.SiteDto
import org.eclipse.tractusx.orchestrator.api.model.StreetDto
import java.time.LocalDateTime

/**
Expand Down Expand Up @@ -61,7 +58,7 @@ object CommonValues {
)
)
private val classifications = listOf(
ClassificationDto(
BusinessPartnerClassificationDto(
type = ClassificationType.NACE,
code = "Code1",
value = "Value1"
Expand Down Expand Up @@ -147,7 +144,7 @@ object CommonValues {
identifiers = identifiers.mapNotNull { it.toLegalEntityIdentifierDto() },
legalForm = legalForm,
states = states.mapNotNull { it.toLegalEntityState() },
classifications = classifications.map { it.toBusinessPartnerClassificationDto() }
classifications = classifications.map { it.toLegalEntityClassificationDto() }
)

val expectedSiteDto = SiteDto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

@Schema(description = AddressStateDescription.header)
interface IBaseAddressStateDto : IBusinessPartnerStateDto {
interface IBaseAddressStateDto : IBaseStateDto {

@get:Schema(description = AddressStateDescription.description)
override val description: String?

Expand All @@ -37,4 +38,4 @@ interface IBaseAddressStateDto : IBusinessPartnerStateDto {

@get:Schema(description = AddressStateDescription.type)
override val type: BusinessStateType
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ interface IBaseBusinessPartnerDto {
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<BusinessPartnerIdentifierDto>
val identifiers: Collection<IBusinessPartnerIdentifierDto>

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

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

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

@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<IBaseClassificationDto>
Expand All @@ -51,6 +51,7 @@ interface IBaseBusinessPartnerDto {
@get:Schema(description = "Address of the official seat of this business partner.")
val postalAddress: IBaseBusinessPartnerPostalAddressDto

// 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?

Expand All @@ -59,5 +60,4 @@ interface IBaseBusinessPartnerDto {

@get:Schema(description = "BPNA of the golden record address this business partner refers to")
val addressBpn: String?

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.ClassificationDescription
import org.eclipse.tractusx.bpdm.common.model.ClassificationType

@Schema(description = ClassificationDescription.header)
interface IBaseClassificationDto {

@get:Schema(description = ClassificationDescription.type)
val type: ClassificationType?

Expand All @@ -33,4 +33,4 @@ interface IBaseClassificationDto {

@get:Schema(description = ClassificationDescription.value)
val value: String?
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@

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

import io.swagger.v3.oas.annotations.media.Schema

interface IBaseIdentifierDto {
val value: String

val type: String
}
@get:Schema(description = "Technical key of the type to which this identifier belongs to")
val type: String?

@get:Schema(description = "Value of the identifier")
val value: String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

@Schema(description = LegalEntityStateDescription.header)
interface IBaseLegalEntityStateDto : IBusinessPartnerStateDto {
interface IBaseLegalEntityStateDto : IBaseStateDto {

@get:Schema(description = LegalEntityStateDescription.description)
override val description: String?

Expand All @@ -37,4 +38,4 @@ interface IBaseLegalEntityStateDto : IBusinessPartnerStateDto {

@get:Schema(description = LegalEntityStateDescription.type)
override val type: BusinessStateType
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

@Schema(description = SiteDescription.header)
interface IBaseSiteStateDto : IBusinessPartnerStateDto {
interface IBaseSiteStateDto : IBaseStateDto {

@get:Schema(description = SiteStateDescription.description)
override val description: String?

Expand All @@ -38,4 +39,4 @@ interface IBaseSiteStateDto : IBusinessPartnerStateDto {

@get:Schema(description = SiteStateDescription.type)
override val type: BusinessStateType
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,20 @@
package org.eclipse.tractusx.bpdm.common.dto

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityStateDescription
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

@Schema(description = LegalEntityStateDescription.header, requiredProperties = ["type"])
data class BusinessPartnerStateDto(
interface IBaseStateDto {

@get:Schema(description = "Date since when the status is/was valid.")
val validFrom: LocalDateTime?,
val validFrom: LocalDateTime?

@get:Schema(description = "Date until the status was valid, if applicable.")
val validTo: LocalDateTime?,
val validTo: LocalDateTime?

@get:Schema(description = "The type of this specified status.")
val type: BusinessStateType?,
val type: BusinessStateType?

@get:Schema(description = "Denotation of the status.")
val description: String?
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@

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

import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime
import io.swagger.v3.oas.annotations.media.Schema

interface IBusinessPartnerStateDto {
val description: String?
val validFrom: LocalDateTime?
val validTo: LocalDateTime?
val type: BusinessStateType
}
interface IBusinessPartnerIdentifierDto : IBaseIdentifierDto {

@get:Schema(description = "Body which issued the identifier")
val issuingBody: String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

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

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.ClassificationDescription
import org.eclipse.tractusx.bpdm.common.dto.IBaseClassificationDto
import org.eclipse.tractusx.bpdm.common.model.ClassificationType

@Schema(description = ClassificationDescription.header)
data class ClassificationBusinessPartnerDto(
data class BusinessPartnerClassificationDto(

@get:Schema(description = ClassificationDescription.type)
override val type: ClassificationType?,

@get:Schema(description = ClassificationDescription.code)
override val code: String?,

@get:Schema(description = ClassificationDescription.value)
override val value: String?
) : IBaseClassificationDto

) : IBaseClassificationDto
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

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

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.IBusinessPartnerIdentifierDto

@Schema(
description = "Identifier record for a business partner",
requiredProperties = ["type", "value"]
)
data class BusinessPartnerIdentifierDto(

@get:Schema(description = "Technical key of the type to which this identifier belongs to")
val type: String? = null,
override val type: String?,
override val value: String?,
override val issuingBody: String?

@get:Schema(description = "Value of the identifier")
val value: String? = null,

@get:Schema(description = "Body which issued the identifier")
val issuingBody: String?
)
) : IBusinessPartnerIdentifierDto
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@

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

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.AddressType
import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerPostalAddressDto

@Schema(description = "Postal address of a business partner")
data class BusinessPartnerPostalAddressDto(

override val addressType: AddressType? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@

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

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.AddressType
import org.eclipse.tractusx.bpdm.common.dto.AlternativePostalAddressDto
import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerPostalAddressDto
import org.eclipse.tractusx.bpdm.common.dto.IBaseStateDto
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

@Schema(description = "Postal address of a input business partner", requiredProperties = ["physicalPostalAddress"])
data class BusinessPartnerPostalAddressInputDto(
data class BusinessPartnerStateDto(

override val addressType: AddressType?,
override val physicalPostalAddress: PhysicalPostalAddressGateDto,
override val alternativePostalAddress: AlternativePostalAddressDto? = null
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType?,
override val description: String?

) : IBaseBusinessPartnerPostalAddressDto
) : IBaseStateDto
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,28 @@
package org.eclipse.tractusx.bpdm.gate.api.model.request

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerIdentifierDto
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole
import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerStateDto
import org.eclipse.tractusx.bpdm.common.dto.ClassificationBusinessPartnerDto
import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerPostalAddressDto
import org.eclipse.tractusx.bpdm.gate.api.model.IBaseBusinessPartnerGateDto
import org.eclipse.tractusx.bpdm.gate.api.model.*

@Schema(
description = "Generic business partner with external id",
requiredProperties = ["externalId"]
)
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<ClassificationBusinessPartnerDto> = 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 addressBpn: String? = null

) : IBaseBusinessPartnerGateDto
) : IBaseBusinessPartnerGateDto
Loading