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(api): API-Model: Rename DTOs #268 Step2 #318

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 @@ -43,7 +43,7 @@ class GateQueryService(
fun getChangedExternalIdsByLsaType(modifiedAfter: Instant?): Map<LsaType, Set<String>> {
var page = 0
var totalPages: Int
val content = mutableListOf<ChangelogResponse>()
val content = mutableListOf<ChangelogGateDto>()

do {
val pageResponse = gateClient.changelog().getInputChangelog(
Expand Down Expand Up @@ -138,13 +138,13 @@ class GateQueryService(
.mapValues { it.value.bpn!! }
}

private fun getLegalEntitiesInput(externalIds: Set<String>): Collection<LegalEntityGateInputResponse> {
private fun getLegalEntitiesInput(externalIds: Set<String>): Collection<LegalEntityGateInputDto> {
if (externalIds.isEmpty()) {
return emptyList()
}

var page = 0
val validContent = mutableListOf<LegalEntityGateInputResponse>()
val validContent = mutableListOf<LegalEntityGateInputDto>()

do {
val pageResponse = gateClient.legalEntities().getLegalEntitiesByExternalIds(
Expand All @@ -159,13 +159,13 @@ class GateQueryService(
return validContent
}

private fun getSitesInput(externalIds: Set<String>): Collection<SiteGateInputResponse> {
private fun getSitesInput(externalIds: Set<String>): Collection<SiteGateInputDto> {
if (externalIds.isEmpty()) {
return emptyList()
}

var page = 0
val validContent = mutableListOf<SiteGateInputResponse>()
val validContent = mutableListOf<SiteGateInputDto>()

do {
val pageResponse = gateClient.sites().getSitesByExternalIds(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.common.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto

@Schema(name = "AddressIdentifierVerboseDto", description = "Identifier record of a logistic address")
data class AddressIdentifierVerboseDto(
Expand All @@ -29,5 +29,5 @@ data class AddressIdentifierVerboseDto(
val value: String,

@get:Schema(description = "Type of the identifier")
val type: TypeKeyNameDto<String>,
val type: TypeKeyNameVerboseDto<String>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.common.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

Expand All @@ -37,5 +37,5 @@ data class AddressStateVerboseDto(
val validTo: LocalDateTime?,

@get:Schema(description = "The type of this status")
val type: TypeKeyNameDto<BusinessStateType>
val type: TypeKeyNameVerboseDto<BusinessStateType>
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.common.dto.response
import com.neovisionaries.i18n.CountryCode
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto

@Schema(name = "BasePostalAddressVerboseDto", description = "Address record of a business partner")
data class BasePostalAddressVerboseDto(
Expand All @@ -31,7 +31,7 @@ data class BasePostalAddressVerboseDto(
val geographicCoordinates: GeoCoordinateDto? = null,

@get:Schema(description = "Describes the full name of the country")
val country: TypeKeyNameDto<CountryCode>,
val country: TypeKeyNameVerboseDto<CountryCode>,

@get:Schema(description = "A postal code, also known as postcode, PIN or ZIP Code")
val postalCode: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.common.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto
import org.eclipse.tractusx.bpdm.common.model.ClassificationType

@Schema(name = "ClassificationVerboseDto", description = "Classification record of a business partner")
Expand All @@ -33,5 +33,5 @@ data class ClassificationVerboseDto(
val code: String? = null,

@get:Schema(description = "Type of specified classification")
val type: TypeKeyNameDto<ClassificationType>
val type: TypeKeyNameVerboseDto<ClassificationType>
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.common.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto

@Schema(name = "LegalEntityIdentifierVerboseDto", description = "Identifier record of a legal entity")
data class LegalEntityIdentifierVerboseDto(
Expand All @@ -29,7 +29,7 @@ data class LegalEntityIdentifierVerboseDto(
val value: String,

@get:Schema(description = "Type of the identifier")
val type: TypeKeyNameDto<String>,
val type: TypeKeyNameVerboseDto<String>,

@get:Schema(description = "Body which issued the identifier")
val issuingBody: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.common.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

Expand All @@ -37,5 +37,5 @@ data class LegalEntityStateVerboseDto(
val validTo: LocalDateTime?,

@get:Schema(description = "The type of this status")
val type: TypeKeyNameDto<BusinessStateType>
val type: TypeKeyNameVerboseDto<BusinessStateType>
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import io.swagger.v3.oas.annotations.media.Schema
import java.time.Instant


@Schema(name = "LogisticAddressResponse", description = "Logistic address ")
data class LogisticAddressResponse(
@Schema(name = "LogisticAddressVerboseDto", description = "Logistic address ")
data class LogisticAddressVerboseDto(

@get:Schema(description = "Business Partner Number of this address")
val bpna: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ data class PoolLegalEntityVerboseDto(
val legalEntity: LegalEntityVerboseDto,

@get:Schema(description = "Address of the official seat of this legal entity")
val legalAddress: LogisticAddressResponse,
val legalAddress: LogisticAddressVerboseDto,
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
package org.eclipse.tractusx.bpdm.common.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto
import org.eclipse.tractusx.bpdm.common.model.RelationType
import java.time.LocalDateTime

@Schema(name = "RelationVerboseDto", description = "Directed relation between two business partners")
data class RelationVerboseDto(

@get:Schema(description = "Type of relation like predecessor or ownership relation")
val type: TypeKeyNameDto<RelationType>,
val type: TypeKeyNameVerboseDto<RelationType>,

@get:Schema(description = "BPN of partner which is the source of the relation")
val startBpn: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.common.dto.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

Expand All @@ -37,5 +37,5 @@ data class SiteStateVerboseDto(
val validTo: LocalDateTime?,

@get:Schema(description = "The type of this status")
val type: TypeKeyNameDto<BusinessStateType>
val type: TypeKeyNameVerboseDto<BusinessStateType>
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.common.dto.response.type
import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "Named type uniquely identified by its technical key")
data class TypeKeyNameDto<T>(
data class TypeKeyNameVerboseDto<T>(
@Schema(description = "Unique key of this type for reference")
val technicalKey: T,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ package org.eclipse.tractusx.bpdm.common.service

import com.neovisionaries.i18n.CountryCode
import com.neovisionaries.i18n.LanguageCode
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameUrlDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto
import org.eclipse.tractusx.bpdm.common.model.NamedType
import org.eclipse.tractusx.bpdm.common.model.NamedUrlType

fun <T : NamedUrlType> T.toDto(): TypeKeyNameUrlDto<T> {
return TypeKeyNameUrlDto(this, getTypeName(), getUrl())
}

fun <T : NamedType> T.toDto(): TypeKeyNameDto<T> {
return TypeKeyNameDto(this, getTypeName())
fun <T : NamedType> T.toDto(): TypeKeyNameVerboseDto<T> {
return TypeKeyNameVerboseDto(this, getTypeName())
}

fun LanguageCode.toDto(): TypeKeyNameDto<LanguageCode> {
return TypeKeyNameDto(this, getName())
fun LanguageCode.toDto(): TypeKeyNameVerboseDto<LanguageCode> {
return TypeKeyNameVerboseDto(this, getName())
}

fun CountryCode.toDto(): TypeKeyNameDto<CountryCode> {
return TypeKeyNameDto(this, getName())
fun CountryCode.toDto(): TypeKeyNameVerboseDto<CountryCode> {
return TypeKeyNameVerboseDto(this, getName())
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.gate.api.model.request.AddressGateInputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.request.AddressGateOutputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.response.AddressGateInputResponse
import org.eclipse.tractusx.bpdm.gate.api.model.response.AddressGateOutputResponse
import org.eclipse.tractusx.bpdm.gate.api.model.response.AddressGateOutputDto
import org.springdoc.core.annotations.ParameterObject
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
Expand Down Expand Up @@ -125,7 +125,7 @@ interface GateAddressApi {
fun getAddressesOutput(
@ParameterObject @Valid paginationRequest: PaginationRequest,
@RequestBody(required = false) externalIds: Collection<String>?
): PageResponse<AddressGateOutputResponse>
): PageResponse<AddressGateOutputDto>

@Operation(
summary = "Create or update output addresses.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses
import jakarta.validation.Valid
import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest
import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse
import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogGateDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse
import org.springdoc.core.annotations.ParameterObject
import org.springframework.http.MediaType
Expand Down Expand Up @@ -54,7 +54,7 @@ interface GateChangelogApi {
fun getInputChangelog(
@ParameterObject @Valid paginationRequest: PaginationRequest,
@RequestBody searchRequest: ChangeLogSearchRequest
): PageChangeLogResponse<ChangelogResponse>
): PageChangeLogResponse<ChangelogGateDto>


@Operation(
Expand All @@ -72,5 +72,5 @@ interface GateChangelogApi {
fun getOutputChangelog(
@ParameterObject @Valid paginationRequest: PaginationRequest,
@RequestBody searchRequest: ChangeLogSearchRequest
): PageChangeLogResponse<ChangelogResponse>
): PageChangeLogResponse<ChangelogGateDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.gate.api.model.request.LegalEntityGateInputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.request.LegalEntityGateOutputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.response.LegalEntityGateInputResponse
import org.eclipse.tractusx.bpdm.gate.api.model.response.LegalEntityGateInputDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.LegalEntityGateOutputResponse
import org.springdoc.core.annotations.ParameterObject
import org.springframework.http.MediaType
Expand Down Expand Up @@ -73,7 +73,7 @@ interface GateLegalEntityApi {
)
@GetMapping("/input/legal-entities/{externalId}")
@GetExchange("/input/legal-entities/{externalId}")
fun getLegalEntityByExternalId(@Parameter(description = "External identifier") @PathVariable externalId: String): LegalEntityGateInputResponse
fun getLegalEntityByExternalId(@Parameter(description = "External identifier") @PathVariable externalId: String): LegalEntityGateInputDto

@Operation(
summary = "Get page of legal-entities filtered by a collection of externalIds",
Expand All @@ -90,7 +90,7 @@ interface GateLegalEntityApi {
fun getLegalEntitiesByExternalIds(
@ParameterObject @Valid paginationRequest: PaginationRequest,
@RequestBody externalIds: Collection<String>
): PageResponse<LegalEntityGateInputResponse>
): PageResponse<LegalEntityGateInputDto>

@Operation(
summary = "Get page of legal entities",
Expand All @@ -104,7 +104,7 @@ interface GateLegalEntityApi {
)
@GetMapping("/input/legal-entities")
@GetExchange("/input/legal-entities")
fun getLegalEntities(@ParameterObject @Valid paginationRequest: PaginationRequest): PageResponse<LegalEntityGateInputResponse>
fun getLegalEntities(@ParameterObject @Valid paginationRequest: PaginationRequest): PageResponse<LegalEntityGateInputDto>

@Operation(
summary = "Get page of legal entities",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.gate.api.model.request.SiteGateInputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.request.SiteGateOutputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.response.SiteGateInputResponse
import org.eclipse.tractusx.bpdm.gate.api.model.response.SiteGateInputDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.SiteGateOutputResponse
import org.springdoc.core.annotations.ParameterObject
import org.springframework.http.MediaType
Expand Down Expand Up @@ -73,7 +73,7 @@ interface GateSiteApi {
)
@GetMapping("/input/sites/{externalId}")
@GetExchange("/input/sites/{externalId}")
fun getSiteByExternalId(@Parameter(description = "External identifier") @PathVariable externalId: String): SiteGateInputResponse
fun getSiteByExternalId(@Parameter(description = "External identifier") @PathVariable externalId: String): SiteGateInputDto

@Operation(
summary = "Get page of sites filtered by a collection of externalIds",
Expand All @@ -90,7 +90,7 @@ interface GateSiteApi {
fun getSitesByExternalIds(
@ParameterObject @Valid paginationRequest: PaginationRequest,
@RequestBody externalIds: Collection<String>
): PageResponse<SiteGateInputResponse>
): PageResponse<SiteGateInputDto>

@Operation(
summary = "Get page of sites",
Expand All @@ -104,7 +104,7 @@ interface GateSiteApi {
)
@GetMapping("/input/sites")
@GetExchange("/input/sites")
fun getSites(@ParameterObject @Valid paginationRequest: PaginationRequest): PageResponse<SiteGateInputResponse>
fun getSites(@ParameterObject @Valid paginationRequest: PaginationRequest): PageResponse<SiteGateInputDto>

@Operation(
summary = "Get page of sites",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
@Schema(
name = "AddressGateOutputResponse", description = "Address with legal entity or site references. " +
name = "AddressGateOutputDto", description = "Address with legal entity or site references. " +
"Only one of either legal entity or site external id can be set for an address."
)
data class AddressGateOutputResponse(
data class AddressGateOutputDto(

@field:JsonUnwrapped
val address: LogisticAddressGateDto,
Expand Down
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.gate.api.model.LsaType
import java.time.Instant

@Schema(name = "ChangelogResponse", description = "Changelog entry for a business partner")
data class ChangelogResponse(
@Schema(name = "ChangelogGateDto", description = "Changelog entry for a business partner")
data class ChangelogGateDto(
@Schema(description = "External ID of the changelog entry")
val externalId: String,
@Schema(description = "The type of the change")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ
import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerRole

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
@Schema(name = "LegalEntityGateInputResponse", description = "Legal entity with external id")
data class LegalEntityGateInputResponse(
@Schema(name = "LegalEntityGateInputDto", description = "Legal entity with external id")
data class LegalEntityGateInputDto(

val legalNameParts: List<String> = emptyList(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ data class LegalEntityGateOutputResponse(
val roles: Collection<BusinessPartnerRole> = emptyList(),

@get:Schema(description = "Address of the official seat of this legal entity")
val legalAddress: AddressGateOutputResponse,
val legalAddress: AddressGateOutputDto,

@Schema(description = "ID the record has in the external system where the record originates from", required = true)
val externalId: String,
Expand Down
Loading