Skip to content

Commit

Permalink
Merge pull request #690 from catenax-ng/feat/remove-state-description
Browse files Browse the repository at this point in the history
Feat: Remove state description
  • Loading branch information
nicoprow authored Dec 29, 2023
2 parents 0d670d5 + ab3006a commit 4fce272
Show file tree
Hide file tree
Showing 42 changed files with 53 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ fun gateToPoolLegalEntityState(gateDto: Gate_LegalEntityStateDto): Pool_LegalEnt
return Pool_LegalEntityStateDto(
validFrom = gateDto.validFrom,
validTo = gateDto.validTo,
type = gateDto.type,
description = gateDto.description
type = gateDto.type
)
}

Expand All @@ -84,8 +83,7 @@ fun gateToPoolSiteState(gateDto: Gate_SiteStateDto): Pool_SiteStateDto {
return Pool_SiteStateDto(
validFrom = gateDto.validFrom,
validTo = gateDto.validTo,
type = gateDto.type,
description = gateDto.description
type = gateDto.type
)
}

Expand All @@ -103,8 +101,7 @@ fun gateToPoolAddressState(gateDto: Gate_AddressStateDto): Pool_AddressStateDto
return Pool_AddressStateDto(
validFrom = gateDto.validFrom,
validTo = gateDto.validTo,
type = gateDto.type,
description = gateDto.description
type = gateDto.type
)
}

Expand Down Expand Up @@ -175,7 +172,7 @@ fun poolToGateLegalEntity(legalEntity: LegalEntityVerboseDto): Gate_LegalEntityD
}
val states = legalEntity.states.map {
Gate_LegalEntityStateDto(
description = it.description,
description = null,
validFrom = it.validFrom,
validTo = it.validTo,
type = it.typeVerbose.technicalKey
Expand All @@ -201,7 +198,7 @@ fun poolToGateLegalEntity(legalEntity: LegalEntityVerboseDto): Gate_LegalEntityD
fun poolToGateSite(site: SiteVerboseDto): SiteGateDto {
val states = site.states.map {
Gate_SiteStateDto(
description = it.description,
description = null,
validFrom = it.validFrom,
validTo = it.validTo,
type = it.typeVerbose.technicalKey
Expand All @@ -223,7 +220,7 @@ fun poolToGateAddressChild(address: Pool_LogisticAddressVerboseDto): AddressGate
fun poolToGateLogisticAddress(address: Pool_LogisticAddressVerboseDto): Gate_LogisticAddressDto {
val states = address.states.map {
Gate_AddressStateDto(
description = it.description,
description = null,
validFrom = it.validFrom,
validTo = it.validTo,
type = it.typeVerbose.technicalKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ class BridgeSyncIT @Autowired constructor(

private fun assertEqualSite(gateVersion: SiteGateInputRequest, poolVersion: SiteWithMainAddressVerboseDto) {
assertThat(poolVersion.site.name).isEqualTo(gateVersion.site.nameParts.first())
assertThat(poolVersion.site.states.map { it.description }).isEqualTo(gateVersion.site.states.map { it.description })
assertThat(poolVersion.mainAddress.physicalPostalAddress.street?.name).isEqualTo(gateVersion.mainAddress.physicalPostalAddress.street?.name)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ fun BusinessPartnerIdentifierDto.toLegalEntityIdentifierDto(): LegalEntityIdenti

fun BusinessPartnerStateDto.toLegalEntityState(): LegalEntityStateDto? {

return type?.let { LegalEntityStateDto(description, validFrom, validTo, it) }
return type?.let { LegalEntityStateDto(validFrom, validTo, it) }
}

fun BusinessPartnerStateDto.toSiteState(): SiteStateDto? {

return type?.let { SiteStateDto(description, validFrom, validTo, it) }
return type?.let { SiteStateDto(validFrom, validTo, it) }
}

fun BusinessPartnerGenericDto.toLogisticAddressDto(bpnReferenceDto: BpnReferenceDto):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ object CommonValues {
BusinessPartnerStateDto(
validFrom = LocalDateTime.now(),
validTo = LocalDateTime.now().plusDays(10),
type = BusinessStateType.ACTIVE,
description = "ActiveState"
type = BusinessStateType.ACTIVE
)
)
private val classifications = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import java.time.LocalDateTime
@Schema(description = AddressStateDescription.header)
interface IAddressStateDto : IBaseStateDto {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,4 @@ interface IBaseStateDto {

@get:Schema(description = "The type of this specified status.")
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 @@ -27,9 +27,6 @@ import java.time.LocalDateTime
@Schema(description = LegalEntityStateDescription.header)
interface ILegalEntityStateDto : IBaseStateDto {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ import java.time.LocalDateTime
@Schema(description = SiteDescription.header)
interface ISiteStateDto : IBaseStateDto {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import java.time.LocalDateTime
@Schema(description = AddressStateDescription.header)
data class AddressStateDto(

override val description: String?,
val description: String?,
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ data class BusinessPartnerStateDto(

override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType?,
override val description: String?
override val type: BusinessStateType?

) : IBusinessPartnerStateDto
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import java.time.LocalDateTime
@Schema(description = LegalEntityStateDescription.header)
data class LegalEntityStateDto(

override val description: String?,
val description: String?,
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import java.time.LocalDateTime
@Schema(description = SiteStateDescription.header)
data class SiteStateDto(

override val description: String?,
val description: String?,
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ data class State(

@Column(name = "type", nullable = false)
@Enumerated(EnumType.STRING)
var type: BusinessStateType,

@Column(name = "description")
var description: String?
var type: BusinessStateType

) : Comparable<State> {

Expand All @@ -49,6 +46,5 @@ data class State(
compareBy(nullsFirst(), State::validFrom) // here null means MIN
.thenBy(nullsLast(), State::validTo) // here null means MAX
.thenBy(State::type)
.thenBy(State::description)
.compare(this, other)
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ class BusinessPartnerMappings {
}

private fun toStateDto(entity: State) =
BusinessPartnerStateDto(type = entity.type, validFrom = entity.validFrom, validTo = entity.validTo, description = entity.description)
BusinessPartnerStateDto(type = entity.type, validFrom = entity.validFrom, validTo = entity.validTo)

private fun toState(dto: BusinessPartnerStateDto) =
dto.type?.let { State(type = it, validFrom = dto.validFrom, validTo = dto.validTo, description = dto.description) }
dto.type?.let { State(type = it, validFrom = dto.validFrom, validTo = dto.validTo) }

private fun toClassificationDto(entity: Classification) =
BusinessPartnerClassificationDto(type = entity.type, code = entity.code, value = entity.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ class BusinessPartnerService(
toState.apply {
validFrom = fromState.validFrom
validTo = fromState.validTo
description = fromState.description
type = fromState.type
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class OrchestratorMappings(
)

private fun toStateDto(entity: State) =
BusinessPartnerStateDto(type = entity.type, validFrom = entity.validFrom, validTo = entity.validTo, description = entity.description)
BusinessPartnerStateDto(type = entity.type, validFrom = entity.validFrom, validTo = entity.validTo)

private fun toIdentifierDto(entity: Identifier) =
BusinessPartnerIdentifierDto(type = entity.type, value = entity.value, issuingBody = entity.issuingBody)
Expand Down Expand Up @@ -173,7 +173,7 @@ class OrchestratorMappings(
}

private fun toState(dto: BusinessPartnerStateDto) =
dto.type?.let { State(type = it, validFrom = dto.validFrom, validTo = dto.validTo, description = dto.description) }
dto.type?.let { State(type = it, validFrom = dto.validFrom, validTo = dto.validTo) }

private fun toClassification(dto: BusinessPartnerClassificationDto) =
Classification(type = dto.type, code = dto.code, value = dto.value)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE business_partners_states
DROP COLUMN description;
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ class BusinessPartnerControllerIT @Autowired constructor(
val stateDtoComparator = compareBy(nullsFirst(), BusinessPartnerStateDto::validFrom) // here null means MIN
.thenBy(nullsLast(), BusinessPartnerStateDto::validTo) // here null means MAX
.thenBy(BusinessPartnerStateDto::type)
.thenBy(BusinessPartnerStateDto::description)

val classificationDtoComparator = compareBy(
BusinessPartnerClassificationDto::type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ internal class BusinessPartnerIT @Autowired constructor(

private fun createState(): State {
return State(
description = "Active",
type = BusinessStateType.ACTIVE,
validFrom = LocalDateTime.now(),
validTo = LocalDateTime.now().plusDays(365)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ object BusinessPartnerGenericValues {
BusinessPartnerStateDto(
validFrom = LocalDateTime.of(2020, 9, 22, 15, 50),
validTo = LocalDateTime.of(2023, 10, 23, 16, 40),
type = BusinessStateType.INACTIVE,
description = "business-state-description-1"
type = BusinessStateType.INACTIVE
),
BusinessPartnerStateDto(
validFrom = LocalDateTime.of(2000, 8, 21, 14, 30),
validTo = LocalDateTime.of(2020, 9, 22, 15, 50),
type = BusinessStateType.ACTIVE,
description = "business-state-description-2"
type = BusinessStateType.ACTIVE
)
),
roles = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,13 @@ object BusinessPartnerVerboseValues {
val bpState1 = BusinessPartnerStateDto(
validFrom = businessStatusValidFrom1,
validTo = businessStatusValidUntil1,
type = BusinessStateType.ACTIVE,
description = businessStatusDescription1
type = BusinessStateType.ACTIVE
)

val bpState2 = BusinessPartnerStateDto(
validFrom = businessStatusValidFrom2,
validTo = businessStatusValidUntil2,
type = BusinessStateType.INACTIVE,
description = businessStatusDescription2
type = BusinessStateType.INACTIVE
)

val bpIdentifier1 = BusinessPartnerIdentifierDto(
Expand Down Expand Up @@ -716,14 +714,12 @@ object BusinessPartnerVerboseValues {
BusinessPartnerStateDto(
validFrom = LocalDateTime.of(2020, 9, 22, 15, 50),
validTo = LocalDateTime.of(2023, 10, 23, 16, 40),
type = BusinessStateType.INACTIVE,
description = "business-state-description-1"
type = BusinessStateType.INACTIVE
),
BusinessPartnerStateDto(
validFrom = LocalDateTime.of(2000, 8, 21, 14, 30),
validTo = LocalDateTime.of(2020, 9, 22, 15, 50),
type = BusinessStateType.ACTIVE,
description = "business-state-description-2"
type = BusinessStateType.ACTIVE
)
),
roles = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

data class AddressStateDto(
override val description: String?,
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ data class BusinessPartnerStateDto(

override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType?,
override val description: String?
override val type: BusinessStateType?

) : IBusinessPartnerStateDto
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

data class LegalEntityStateDto(

override val description: String?,
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

data class SiteStateDto(

override val description: String?,
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType
Expand Down
Loading

0 comments on commit 4fce272

Please sign in to comment.