From ab0a7ab54f6785c172eabd46617fa4d8219151e2 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Tue, 4 Jul 2023 15:16:36 +0200 Subject: [PATCH 1/2] =?UTF-8?q?fix(api):=C2=A0=20API-Model:=20Rename=20DTO?= =?UTF-8?q?s=20#268=20-=20undo=20rename=20of=20Pool=20responses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tractusx/bpdm/pool/api/PoolAddressApi.kt | 2 +- .../tractusx/bpdm/pool/api/PoolBpnApi.kt | 4 +- .../bpdm/pool/api/PoolLegalEntityApi.kt | 4 +- .../bpdm/pool/api/PoolOpenSearchApi.kt | 6 +-- .../tractusx/bpdm/pool/api/PoolSaasApi.kt | 10 ++--- .../tractusx/bpdm/pool/api/PoolSiteApi.kt | 10 ++--- ...hResponse.kt => AddressMatchVerboseDto.kt} | 4 +- ...e.kt => AddressPartnerCreateVerboseDto.kt} | 4 +- ...Response.kt => BpnIdentifierMappingDto.kt} | 4 +- .../api/model/response/EntitiesWithErrors.kt | 20 ++++----- ...ppingResponse.kt => ImportIdMappingDto.kt} | 2 +- ...sResponse.kt => LegalAddressVerboseDto.kt} | 4 +- ...ponse.kt => LegalEntityMatchVerboseDto.kt} | 4 +- ... => LegalEntityPartnerCreateVerboseDto.kt} | 4 +- ...ssResponse.kt => MainAddressVerboseDto.kt} | 2 +- ...onse.kt => SitePartnerCreateVerboseDto.kt} | 4 +- ...ePoolResponse.kt => SitePoolVerboseDto.kt} | 4 +- .../response/{SyncResponse.kt => SyncDto.kt} | 2 +- .../component/opensearch/SearchService.kt | 8 ++-- .../impl/controller/OpenSearchController.kt | 6 +-- .../service/OpenSearchSyncStarterService.kt | 12 ++--- .../impl/service/SearchServiceImpl.kt | 8 ++-- .../mock/service/SearchServiceMock.kt | 8 ++-- .../bpdm/pool/controller/AddressController.kt | 4 +- .../bpdm/pool/controller/BpnController.kt | 4 +- .../pool/controller/LegalEntityController.kt | 8 ++-- .../bpdm/pool/controller/SiteController.kt | 10 ++--- ...ntryDto.kt => ChangelogEntryVerboseDto.kt} | 2 +- .../repository/AddressIdentifierRepository.kt | 6 +-- .../LegalEntityIdentifierRepository.kt | 6 +-- .../bpdm/pool/service/AddressService.kt | 8 ++-- .../service/BusinessPartnerBuildService.kt | 44 +++++++++++++------ .../service/BusinessPartnerFetchService.kt | 4 +- .../pool/service/PartnerChangelogService.kt | 6 +-- .../bpdm/pool/service/ResponseMappings.kt | 36 +++++++-------- .../tractusx/bpdm/pool/service/SiteService.kt | 6 +-- .../controller/OpenSearchControllerIT.kt | 4 +- .../pool/controller/AddressControllerIT.kt | 10 ++--- .../controller/AddressControllerSearchIT.kt | 10 ++--- .../controller/LegalEntityControllerIT.kt | 14 +++--- .../LegalEntityControllerSearchIT.kt | 16 +++---- .../bpdm/pool/controller/SiteControllerIT.kt | 28 ++++++------ .../bpdm/pool/util/BusinessPartnerTestDto.kt | 14 +++--- .../tractusx/bpdm/pool/util/ResponseValues.kt | 24 +++++----- .../tractusx/bpdm/pool/util/TestHelpers.kt | 10 ++--- 45 files changed, 214 insertions(+), 196 deletions(-) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{AddressMatchResponse.kt => AddressMatchVerboseDto.kt} (89%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{AddressPartnerCreateResponse.kt => AddressPartnerCreateVerboseDto.kt} (91%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{BpnIdentifierMappingResponse.kt => BpnIdentifierMappingDto.kt} (87%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{ImportIdMappingResponse.kt => ImportIdMappingDto.kt} (96%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{LegalAddressResponse.kt => LegalAddressVerboseDto.kt} (93%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{LegalEntityMatchResponse.kt => LegalEntityMatchVerboseDto.kt} (91%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{LegalEntityPartnerCreateResponse.kt => LegalEntityPartnerCreateVerboseDto.kt} (92%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{MainAddressResponse.kt => MainAddressVerboseDto.kt} (98%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{SitePartnerCreateResponse.kt => SitePartnerCreateVerboseDto.kt} (92%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{SitePoolResponse.kt => SitePoolVerboseDto.kt} (93%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/{SyncResponse.kt => SyncDto.kt} (98%) rename bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/{ChangelogEntryDto.kt => ChangelogEntryVerboseDto.kt} (96%) diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt index 8352ee895..cd36940e4 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt @@ -63,7 +63,7 @@ interface PoolAddressApi { fun getAddresses( @ParameterObject addressSearchRequest: AddressPartnerSearchRequest, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageResponse @Operation( summary = "Get address partners by bpna", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBpnApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBpnApi.kt index 09412c9de..4eacdc120 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBpnApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBpnApi.kt @@ -25,7 +25,7 @@ import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.pool.api.model.request.IdentifiersSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingDto import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.PostMapping @@ -57,5 +57,5 @@ interface PoolBpnApi { ) @PostMapping("/search") @PostExchange("/search") - fun findBpnsByIdentifiers(@RequestBody request: IdentifiersSearchRequest): ResponseEntity> + fun findBpnsByIdentifiers(@RequestBody request: IdentifiersSearchRequest): ResponseEntity> } \ No newline at end of file diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt index 27c593f41..d7735ca49 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt @@ -61,7 +61,7 @@ interface PoolLegalEntityApi { fun getLegalEntities( @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageResponse @Operation( summary = "Get legal entity business partner by identifier", @@ -181,7 +181,7 @@ interface PoolLegalEntityApi { fun searchLegalAddresses( @RequestBody bpnLs: Collection - ): Collection + ): Collection @Operation( summary = "Create new legal entity business partners", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolOpenSearchApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolOpenSearchApi.kt index 2046234c0..124f40618 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolOpenSearchApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolOpenSearchApi.kt @@ -24,7 +24,7 @@ import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses -import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncDto import org.springframework.http.MediaType import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.GetMapping @@ -53,7 +53,7 @@ interface PoolOpenSearchApi { ) @PostMapping("/business-partner") @PostExchange("/business-partner") - fun export(): SyncResponse + fun export(): SyncDto @Operation( summary = "Fetch information about the latest OpenSearch export", @@ -67,7 +67,7 @@ interface PoolOpenSearchApi { ) @GetMapping("/business-partner") @GetExchange("/business-partner") - fun getBusinessPartners(): SyncResponse + fun getBusinessPartners(): SyncDto @Operation( diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt index 1024debca..a060ed4ee 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt @@ -28,8 +28,8 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.ImportIdEntry import org.eclipse.tractusx.bpdm.pool.api.model.request.ImportIdFilterRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.ImportIdMappingResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.ImportIdMappingDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncDto import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.web.bind.annotation.GetMapping @@ -60,7 +60,7 @@ interface PoolSaasApi { ) @PostMapping("/business-partner/sync") @PostExchange("/business-partner/sync") - fun importBusinessPartners(): SyncResponse + fun importBusinessPartners(): SyncDto @Operation( summary = "Fetch information about the SaaS synchronization", @@ -74,7 +74,7 @@ interface PoolSaasApi { ) @GetMapping("/business-partner/sync") @GetExchange("/business-partner/sync") - fun getSyncStatus(): SyncResponse + fun getSyncStatus(): SyncDto @Operation( summary = "Filter Identifier Mappings by CX-Pool Identifiers", @@ -88,7 +88,7 @@ interface PoolSaasApi { ) @PostMapping("/identifier-mappings/filter") @PostExchange("/identifier-mappings/filter") - fun getImportEntries(@RequestBody importIdFilterRequest: ImportIdFilterRequest): ImportIdMappingResponse + fun getImportEntries(@RequestBody importIdFilterRequest: ImportIdFilterRequest): ImportIdMappingDto @Operation( summary = "Paginate Identifier Mappings by CX-Pool Identifiers", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt index c1c75f5a1..8f49ffba2 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt @@ -30,10 +30,10 @@ import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerUpdateRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateResponseWrapper import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerUpdateResponseWrapper -import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolVerboseDto import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.web.bind.annotation.* @@ -62,7 +62,7 @@ interface PoolSiteApi { fun searchMainAddresses( @RequestBody bpnS: Collection - ): Collection + ): Collection @Operation( summary = "Get site partners by bpn", @@ -79,7 +79,7 @@ interface PoolSiteApi { @GetExchange("/{bpn}") fun getSite( @Parameter(description = "Bpn value") @PathVariable bpn: String - ): SitePoolResponse + ): SitePoolVerboseDto @Operation( summary = "Search site partners by BPNs and/or parent BPNs", @@ -96,7 +96,7 @@ interface PoolSiteApi { fun searchSites( @RequestBody siteSearchRequest: SiteBpnSearchRequest, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageResponse @Operation( summary = "Create new site business partners", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressMatchResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressMatchVerboseDto.kt similarity index 89% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressMatchResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressMatchVerboseDto.kt index ff9b1e2b7..4d731d62a 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressMatchResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressMatchVerboseDto.kt @@ -23,8 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto -@Schema(name = "AddressMatchResponse", description = "Match with score for a business partner record of type address") -data class AddressMatchResponse( +@Schema(name = "AddressMatchVerboseDto", description = "Match with score for a business partner record of type address") +data class AddressMatchVerboseDto( @Schema(description = "Relative quality score of the match. The higher the better") val score: Float, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressPartnerCreateResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressPartnerCreateVerboseDto.kt similarity index 91% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressPartnerCreateResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressPartnerCreateVerboseDto.kt index 8b8d0f11d..179fdbeee 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressPartnerCreateResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/AddressPartnerCreateVerboseDto.kt @@ -26,8 +26,8 @@ import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "AddressPartnerCreateResponse", description = "Created business partners of type address") -data class AddressPartnerCreateResponse( +@Schema(name = "AddressPartnerCreateVerboseDto", description = "Created business partners of type address") +data class AddressPartnerCreateVerboseDto( @field:JsonUnwrapped val address: LogisticAddressVerboseDto, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BpnIdentifierMappingResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BpnIdentifierMappingDto.kt similarity index 87% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BpnIdentifierMappingResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BpnIdentifierMappingDto.kt index f5062a32a..450aeeaf2 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BpnIdentifierMappingResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BpnIdentifierMappingDto.kt @@ -21,8 +21,8 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response import io.swagger.v3.oas.annotations.media.Schema -@Schema(name = "BpnIdentifierMappingResponse", description = "Mapping of Business Partner Number to identifier value") -data class BpnIdentifierMappingResponse( +@Schema(name = "BpnIdentifierMappingDto", description = "Mapping of Business Partner Number to identifier value") +data class BpnIdentifierMappingDto( @Schema(description = "Value of the identifier") val idValue: String, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/EntitiesWithErrors.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/EntitiesWithErrors.kt index 063502889..5087d071f 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/EntitiesWithErrors.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/EntitiesWithErrors.kt @@ -40,45 +40,45 @@ open class EntitiesWithErrors( description = "Holds information about successfully and failed entities after the creating/updating of several objects" ) data class LegalEntityPartnerCreateResponseWrapper( - override val entities: Collection, + override val entities: Collection, override val errors: Collection> -) : EntitiesWithErrors(entities, errors) +) : EntitiesWithErrors(entities, errors) @Schema( name = "LegalEntityUpdateWrapper", description = "Holds information about successfully and failed entities after the creating/updating of several objects" ) data class LegalEntityPartnerUpdateResponseWrapper( - override val entities: Collection, + override val entities: Collection, override val errors: Collection> -) : EntitiesWithErrors(entities, errors) +) : EntitiesWithErrors(entities, errors) @Schema( name = "SiteCreateWrapper", description = "Holds information about successfully and failed entities after the creating/updating of several objects" ) data class SitePartnerCreateResponseWrapper( - override val entities: Collection, + override val entities: Collection, override val errors: Collection> -) : EntitiesWithErrors(entities, errors) +) : EntitiesWithErrors(entities, errors) @Schema( name = "SiteUpdateWrapper", description = "Holds information about successfully and failed entities after the creating/updating of several objects" ) data class SitePartnerUpdateResponseWrapper( - override val entities: Collection, + override val entities: Collection, override val errors: Collection> -) : EntitiesWithErrors(entities, errors) +) : EntitiesWithErrors(entities, errors) @Schema( name = "AddressCreateWrapper", description = "Holds information about successfully and failed entities after the creating/updating of several objects" ) data class AddressPartnerCreateResponseWrapper( - override val entities: Collection, + override val entities: Collection, override val errors: Collection> -) : EntitiesWithErrors(entities, errors) +) : EntitiesWithErrors(entities, errors) @Schema( name = "AddressUpdateWrapper", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ImportIdMappingResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ImportIdMappingDto.kt similarity index 96% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ImportIdMappingResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ImportIdMappingDto.kt index d5d50c68e..760fc746d 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ImportIdMappingResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ImportIdMappingDto.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response import org.eclipse.tractusx.bpdm.pool.api.model.ImportIdEntry -data class ImportIdMappingResponse( +data class ImportIdMappingDto( val entries: Collection, val notFound: Collection ) { diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalAddressResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalAddressVerboseDto.kt similarity index 93% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalAddressResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalAddressVerboseDto.kt index 912d22f41..50b32da7e 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalAddressResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalAddressVerboseDto.kt @@ -24,8 +24,8 @@ import org.eclipse.tractusx.bpdm.common.dto.response.AlternativePostalAddressVer import org.eclipse.tractusx.bpdm.common.dto.response.PhysicalPostalAddressVerboseDto import java.time.Instant -@Schema(name = "LegalAddressResponse", description = "Legal address for legal entity") -data class LegalAddressResponse( +@Schema(name = "LegalAddressVerboseDto", description = "Legal address for legal entity") +data class LegalAddressVerboseDto( @Schema(description = "Physical postal address") val physicalPostalAddress: PhysicalPostalAddressVerboseDto, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchVerboseDto.kt similarity index 91% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchVerboseDto.kt index bbc7b9855..c5cb88771 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchVerboseDto.kt @@ -27,8 +27,8 @@ import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "LegalEntityMatchResponse", description = "Match with score for a business partner record of type legal entity") -data class LegalEntityMatchResponse( +@Schema(name = "LegalEntityMatchVerboseDto", description = "Match with score for a business partner record of type legal entity") +data class LegalEntityMatchVerboseDto( @Schema(description = "Relative quality score of the match. The higher the better") val score: Float, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateVerboseDto.kt similarity index 92% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateVerboseDto.kt index 50906e634..831c28482 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateVerboseDto.kt @@ -27,8 +27,8 @@ import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "LegalEntityPartnerCreateResponse", description = "Created business partner of type legal entity") -data class LegalEntityPartnerCreateResponse( +@Schema(name = "LegalEntityPartnerCreateVerboseDto", description = "Created business partner of type legal entity") +data class LegalEntityPartnerCreateVerboseDto( @get:Schema(description = "Legal name the partner goes by") val legalName: String, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/MainAddressResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/MainAddressVerboseDto.kt similarity index 98% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/MainAddressResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/MainAddressVerboseDto.kt index a806d302c..2f5d6aaf5 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/MainAddressResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/MainAddressVerboseDto.kt @@ -25,7 +25,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PhysicalPostalAddressVerbos import java.time.Instant @Schema(name = "MainAddressResponse", description = "Main address for site") -data class MainAddressResponse( +data class MainAddressVerboseDto( @Schema(description = "Physical postal address") val physicalPostalAddress: PhysicalPostalAddressVerboseDto, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePartnerCreateResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePartnerCreateVerboseDto.kt similarity index 92% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePartnerCreateResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePartnerCreateVerboseDto.kt index e9511eb67..aa622599c 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePartnerCreateResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePartnerCreateVerboseDto.kt @@ -27,8 +27,8 @@ import org.eclipse.tractusx.bpdm.common.dto.response.SiteVerboseDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "SitePartnerCreateResponse", description = "Created business partner record of type site") -data class SitePartnerCreateResponse( +@Schema(name = "SitePartnerCreateVerboseDto", description = "Created business partner record of type site") +data class SitePartnerCreateVerboseDto( @field:JsonUnwrapped val site: SiteVerboseDto, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolVerboseDto.kt similarity index 93% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolVerboseDto.kt index bdb27a3b0..1b72a7908 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolVerboseDto.kt @@ -27,8 +27,8 @@ import org.eclipse.tractusx.bpdm.common.dto.response.SiteVerboseDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "SitePoolResponse", description = "Site with legal entity reference.") -data class SitePoolResponse( +@Schema(name = "SitePoolVerboseDto", description = "Site with legal entity reference.") +data class SitePoolVerboseDto( @field:JsonUnwrapped val site: SiteVerboseDto, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SyncResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SyncDto.kt similarity index 98% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SyncResponse.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SyncDto.kt index e4b7d049d..5ada46d2b 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SyncResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SyncDto.kt @@ -23,7 +23,7 @@ import org.eclipse.tractusx.bpdm.common.model.SyncStatus import org.eclipse.tractusx.bpdm.pool.api.model.SyncType import java.time.Instant -data class SyncResponse( +data class SyncDto( val type: SyncType, val status: SyncStatus, val count: Int = 0, diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt index 21773a578..1f10bcf8d 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt @@ -23,8 +23,8 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchVerboseDto /** * Provides search functionality on the Catena-x data for the BPDM system @@ -37,7 +37,7 @@ interface SearchService { fun searchLegalEntities( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse + ): PageResponse /** * Find addresses by matching their field values to [searchRequest] field query texts @@ -45,6 +45,6 @@ interface SearchService { fun searchAddresses( searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse + ): PageResponse } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/controller/OpenSearchController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/controller/OpenSearchController.kt index f6ba8112b..f7475a587 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/controller/OpenSearchController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/controller/OpenSearchController.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.controller import org.eclipse.tractusx.bpdm.pool.api.PoolOpenSearchApi -import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncDto import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service.OpenSearchSyncStarterService import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.RestController @@ -32,12 +32,12 @@ class OpenSearchController( ) : PoolOpenSearchApi { @PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getManageOpensearchAsRole())") - override fun export(): SyncResponse { + override fun export(): SyncDto { return openSearchSyncService.exportAsync() } @PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getManageOpensearchAsRole())") - override fun getBusinessPartners(): SyncResponse { + override fun getBusinessPartners(): SyncDto { return openSearchSyncService.getExportStatus() } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/OpenSearchSyncStarterService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/OpenSearchSyncStarterService.kt index 09a557c8c..f641c6796 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/OpenSearchSyncStarterService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/OpenSearchSyncStarterService.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.pool.api.model.SyncType -import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncDto import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.ADDRESS_PARTNER_INDEX_NAME import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.LEGAL_ENTITIES_INDEX_NAME import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.MAPPINGS_FILE_PATH_ADDRESSES @@ -59,21 +59,21 @@ class OpenSearchSyncStarterService( * Checks for changed records since the last export and exports those changes to OpenSearch */ @Scheduled(cron = "\${bpdm.opensearch.export-scheduler-cron-expr:-}", zone = "UTC") - fun export(): SyncResponse { + fun export(): SyncDto { return startExport(true) } /** * Non-blocking asynchronous variant of [export] */ - fun exportAsync(): SyncResponse { + fun exportAsync(): SyncDto { return startExport(false) } /** - * Fetch a [SyncResponse] about the state of the latest export + * Fetch a [SyncDto] about the state of the latest export */ - fun getExportStatus(): SyncResponse { + fun getExportStatus(): SyncDto { return syncRecordService.getOrCreateRecord(SyncType.OPENSEARCH).toDto() } @@ -150,7 +150,7 @@ class OpenSearchSyncStarterService( /** * Start export either asynchronously or synchronously depending on whether [inSync] */ - private fun startExport(inSync: Boolean): SyncResponse { + private fun startExport(inSync: Boolean): SyncDto { val record = syncRecordService.setSynchronizationStart(SyncType.OPENSEARCH) val response = record.toDto() diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt index ab634ef87..084ddd1b2 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt @@ -24,8 +24,8 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchVerboseDto import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.AddressDocSearchRepository import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.LegalEntityDocSearchRepository @@ -72,7 +72,7 @@ class SearchServiceImpl( override fun searchLegalEntities( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageResponse { val legalEntityPage = searchAndPreparePage(searchRequest, paginationRequest) businessPartnerFetchService.fetchLegalEntityDependencies(legalEntityPage.content.map { (_, legalEntity) -> legalEntity }.toSet()) @@ -86,7 +86,7 @@ class SearchServiceImpl( /** * @see SearchServiceImpl.searchLegalEntities */ - override fun searchAddresses(searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest): PageResponse { + override fun searchAddresses(searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest): PageResponse { val addressPage = searchAndPreparePage(searchRequest, paginationRequest) addressService.fetchLogisticAddressDependencies(addressPage.content.map { (_, address) -> address }.toSet()) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt index 0424415a1..2cb1a7e91 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt @@ -24,8 +24,8 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchVerboseDto import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService import org.eclipse.tractusx.bpdm.pool.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.pool.repository.LogisticAddressRepository @@ -52,7 +52,7 @@ class SearchServiceMock( override fun searchLegalEntities( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageResponse { val resultPage = legalEntityRepository.findAll(PageRequest.of(paginationRequest.page, paginationRequest.size)) @@ -65,7 +65,7 @@ class SearchServiceMock( * Ignores [searchRequest] and returns an unfiltered result of addresses in the database, * adding a default relevancy score to each entry */ - override fun searchAddresses(searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest): PageResponse { + override fun searchAddresses(searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest): PageResponse { val resultPage = logisticAddressRepository.findAll(PageRequest.of(paginationRequest.page, paginationRequest.size)) logger.info { "Mock search: Returning ${resultPage.size} addresses from database" } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt index 4c151a7e4..cdbf41d72 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt @@ -27,7 +27,7 @@ import org.eclipse.tractusx.bpdm.pool.api.PoolAddressApi import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerUpdateRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponseWrapper import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerUpdateResponseWrapper import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService @@ -47,7 +47,7 @@ class AddressController( override fun getAddresses( addressSearchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageResponse { return searchService.searchAddresses(addressSearchRequest, paginationRequest) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BpnController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BpnController.kt index d8993c23c..1aa1d006e 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BpnController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BpnController.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.eclipse.tractusx.bpdm.pool.api.PoolBpnApi import org.eclipse.tractusx.bpdm.pool.api.model.request.IdentifiersSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingDto import org.eclipse.tractusx.bpdm.pool.config.ControllerConfigProperties import org.eclipse.tractusx.bpdm.pool.service.BusinessPartnerFetchService import org.springframework.http.HttpStatus @@ -37,7 +37,7 @@ class BpnController( ) : PoolBpnApi { @PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getReadPoolPartnerDataAsRole())") - override fun findBpnsByIdentifiers(@RequestBody request: IdentifiersSearchRequest): ResponseEntity> { + override fun findBpnsByIdentifiers(@RequestBody request: IdentifiersSearchRequest): ResponseEntity> { if (request.idValues.size > controllerConfigProperties.searchRequestLimit) { return ResponseEntity(HttpStatus.BAD_REQUEST) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt index db2454f27..75f0321b3 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt @@ -29,8 +29,8 @@ import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchReq import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPartnerUpdateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalAddressResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalAddressVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerCreateResponseWrapper import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerUpdateResponseWrapper import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService @@ -62,7 +62,7 @@ class LegalEntityController( override fun getLegalEntities( bpSearchRequest: LegalEntityPropertiesSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageResponse { return searchService.searchLegalEntities( BusinessPartnerSearchRequest(bpSearchRequest), paginationRequest @@ -110,7 +110,7 @@ class LegalEntityController( @PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getReadPoolPartnerDataAsRole())") override fun searchLegalAddresses( bpnLs: Collection - ): Collection { + ): Collection { return addressService.findLegalAddresses(bpnLs) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt index 90ee9b9da..48833bf4f 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt @@ -25,10 +25,10 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.PoolSiteApi import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerUpdateRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateResponseWrapper import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerUpdateResponseWrapper -import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolVerboseDto import org.eclipse.tractusx.bpdm.pool.service.AddressService import org.eclipse.tractusx.bpdm.pool.service.BusinessPartnerBuildService import org.eclipse.tractusx.bpdm.pool.service.SiteService @@ -45,14 +45,14 @@ class SiteController( @PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getReadPoolPartnerDataAsRole())") override fun searchMainAddresses( bpnS: Collection - ): Collection { + ): Collection { return addressService.findMainAddresses(bpnS) } @PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getReadPoolPartnerDataAsRole())") override fun getSite( bpn: String - ): SitePoolResponse { + ): SitePoolVerboseDto { return siteService.findByBpn(bpn.uppercase()) } @@ -60,7 +60,7 @@ class SiteController( override fun searchSites( siteSearchRequest: SiteBpnSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageResponse { return siteService.findByPartnerBpns(siteSearchRequest, paginationRequest) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryDto.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryVerboseDto.kt similarity index 96% rename from bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryDto.kt rename to bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryVerboseDto.kt index 8034b62ab..d748110d6 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryDto.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryVerboseDto.kt @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.dto import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType -data class ChangelogEntryDto( +data class ChangelogEntryVerboseDto( val bpn: String, val changelogType: ChangelogType, val changelogSubject: ChangelogSubject diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/AddressIdentifierRepository.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/AddressIdentifierRepository.kt index 726729399..b661a1213 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/AddressIdentifierRepository.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/AddressIdentifierRepository.kt @@ -19,7 +19,7 @@ package org.eclipse.tractusx.bpdm.pool.repository -import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingDto import org.eclipse.tractusx.bpdm.pool.entity.AddressIdentifier import org.eclipse.tractusx.bpdm.pool.entity.IdentifierType import org.springframework.data.jpa.repository.Query @@ -31,7 +31,7 @@ interface AddressIdentifierRepository : CrudRepository @Query("SELECT DISTINCT i FROM AddressIdentifier i LEFT JOIN FETCH i.type WHERE i IN :identifiers") fun joinType(identifiers: Set): Set - @Query("SELECT new org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingResponse(i.value,i.address.bpn) FROM AddressIdentifier i WHERE i.type = :identifierType AND i.value in :values") - fun findBpnsByIdentifierTypeAndValues(identifierType: IdentifierType, values: Collection): Set + @Query("SELECT new org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingDto(i.value,i.address.bpn) FROM AddressIdentifier i WHERE i.type = :identifierType AND i.value in :values") + fun findBpnsByIdentifierTypeAndValues(identifierType: IdentifierType, values: Collection): Set } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/LegalEntityIdentifierRepository.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/LegalEntityIdentifierRepository.kt index b4e44645c..612c04383 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/LegalEntityIdentifierRepository.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/LegalEntityIdentifierRepository.kt @@ -19,7 +19,7 @@ package org.eclipse.tractusx.bpdm.pool.repository -import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingDto import org.eclipse.tractusx.bpdm.pool.entity.IdentifierType import org.eclipse.tractusx.bpdm.pool.entity.LegalEntityIdentifier import org.springframework.data.jpa.repository.Query @@ -31,7 +31,7 @@ interface LegalEntityIdentifierRepository : CrudRepository): Set - @Query("SELECT new org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingResponse(i.value,i.legalEntity.bpn) FROM LegalEntityIdentifier i WHERE i.type = :identifierType AND i.value in :values") - fun findBpnsByIdentifierTypeAndValues(identifierType: IdentifierType, values: Collection): Set + @Query("SELECT new org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingDto(i.value,i.legalEntity.bpn) FROM LegalEntityIdentifier i WHERE i.type = :identifierType AND i.value in :values") + fun findBpnsByIdentifierTypeAndValues(identifierType: IdentifierType, values: Collection): Set } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/AddressService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/AddressService.kt index 8e73766bf..1e8f07bf5 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/AddressService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/AddressService.kt @@ -25,8 +25,8 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalAddressResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalAddressVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressVerboseDto import org.eclipse.tractusx.bpdm.pool.entity.LogisticAddress import org.eclipse.tractusx.bpdm.pool.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.pool.repository.LogisticAddressRepository @@ -73,7 +73,7 @@ class AddressService( return addressPage.toDto(addressPage.content.map { it.toDto() }) } - fun findLegalAddresses(bpnLs: Collection): Collection { + fun findLegalAddresses(bpnLs: Collection): Collection { val legalEntities = legalEntityRepository.findDistinctByBpnIn(bpnLs) legalEntityRepository.joinLegalAddresses(legalEntities) val addresses = legalEntities.map { it.legalAddress } @@ -81,7 +81,7 @@ class AddressService( return addresses.map { it.toLegalAddressResponse() } } - fun findMainAddresses(bpnS: Collection): Collection { + fun findMainAddresses(bpnS: Collection): Collection { val sites = siteRepository.findDistinctByBpnIn(bpnS) siteRepository.joinAddresses(sites) val addresses = sites.map { it.mainAddress } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index 17fd80a40..a0bb7a505 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -27,7 +27,7 @@ import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType import org.eclipse.tractusx.bpdm.pool.api.model.request.* import org.eclipse.tractusx.bpdm.pool.api.model.response.* import org.eclipse.tractusx.bpdm.pool.dto.AddressMetadataMappingDto -import org.eclipse.tractusx.bpdm.pool.dto.ChangelogEntryDto +import org.eclipse.tractusx.bpdm.pool.dto.ChangelogEntryVerboseDto import org.eclipse.tractusx.bpdm.pool.dto.LegalEntityMetadataMappingDto import org.eclipse.tractusx.bpdm.pool.entity.* import org.eclipse.tractusx.bpdm.pool.repository.LegalEntityIdentifierRepository @@ -82,8 +82,14 @@ class BusinessPartnerBuildService( val legalEntities = legalEntityWithIndexByBpnMap.values.map { (legalEntity, _) -> legalEntity } - changelogService.createChangelogEntries(legalEntities.map { ChangelogEntryDto(it.bpn, ChangelogType.CREATE, ChangelogSubject.LEGAL_ENTITY) }) - changelogService.createChangelogEntries(legalEntities.map { ChangelogEntryDto(it.legalAddress.bpn, ChangelogType.CREATE, ChangelogSubject.ADDRESS) }) + changelogService.createChangelogEntries(legalEntities.map { ChangelogEntryVerboseDto(it.bpn, ChangelogType.CREATE, ChangelogSubject.LEGAL_ENTITY) }) + changelogService.createChangelogEntries(legalEntities.map { + ChangelogEntryVerboseDto( + it.legalAddress.bpn, + ChangelogType.CREATE, + ChangelogSubject.ADDRESS + ) + }) legalEntityRepository.saveAll(legalEntities) @@ -119,8 +125,8 @@ class BusinessPartnerBuildService( .associateBy { (site, _) -> site.bpn } val sites = siteWithIndexByBpnMap.values.map { (site, _) -> site } - changelogService.createChangelogEntries(sites.map { ChangelogEntryDto(it.bpn, ChangelogType.CREATE, ChangelogSubject.SITE) }) - changelogService.createChangelogEntries(sites.map { ChangelogEntryDto(it.mainAddress.bpn, ChangelogType.CREATE, ChangelogSubject.ADDRESS) }) + changelogService.createChangelogEntries(sites.map { ChangelogEntryVerboseDto(it.bpn, ChangelogType.CREATE, ChangelogSubject.SITE) }) + changelogService.createChangelogEntries(sites.map { ChangelogEntryVerboseDto(it.mainAddress.bpn, ChangelogType.CREATE, ChangelogSubject.ADDRESS) }) siteRepository.saveAll(sites) @@ -149,7 +155,13 @@ class BusinessPartnerBuildService( val addressResponses = createAddressesForSite(siteRequests, errors, metadataMap) .plus(createAddressesForLegalEntity(legalEntityRequests, errors, metadataMap)) - changelogService.createChangelogEntries(addressResponses.map { ChangelogEntryDto(it.address.bpna, ChangelogType.CREATE, ChangelogSubject.ADDRESS) }) + changelogService.createChangelogEntries(addressResponses.map { + ChangelogEntryVerboseDto( + it.address.bpna, + ChangelogType.CREATE, + ChangelogSubject.ADDRESS + ) + }) return AddressPartnerCreateResponseWrapper(addressResponses, errors) } @@ -180,8 +192,14 @@ class BusinessPartnerBuildService( updateLogisticAddress(it.legalAddress, request.legalAddress, addressMetadataMap) } - changelogService.createChangelogEntries(legalEntities.map { ChangelogEntryDto(it.bpn, ChangelogType.UPDATE, ChangelogSubject.LEGAL_ENTITY) }) - changelogService.createChangelogEntries(legalEntities.map { ChangelogEntryDto(it.legalAddress.bpn, ChangelogType.UPDATE, ChangelogSubject.ADDRESS) }) + changelogService.createChangelogEntries(legalEntities.map { ChangelogEntryVerboseDto(it.bpn, ChangelogType.UPDATE, ChangelogSubject.LEGAL_ENTITY) }) + changelogService.createChangelogEntries(legalEntities.map { + ChangelogEntryVerboseDto( + it.legalAddress.bpn, + ChangelogType.UPDATE, + ChangelogSubject.ADDRESS + ) + }) val validEntities = legalEntityRepository.saveAll(legalEntities).map { it.toUpsertDto(null) } @@ -202,8 +220,8 @@ class BusinessPartnerBuildService( ErrorInfo(SiteUpdateError.SiteNotFound, "Site $it not updated: BPNS not found", it) } - changelogService.createChangelogEntries(sites.map { ChangelogEntryDto(it.bpn, ChangelogType.UPDATE, ChangelogSubject.SITE) }) - changelogService.createChangelogEntries(sites.map { ChangelogEntryDto(it.mainAddress.bpn, ChangelogType.UPDATE, ChangelogSubject.ADDRESS) }) + changelogService.createChangelogEntries(sites.map { ChangelogEntryVerboseDto(it.bpn, ChangelogType.UPDATE, ChangelogSubject.SITE) }) + changelogService.createChangelogEntries(sites.map { ChangelogEntryVerboseDto(it.mainAddress.bpn, ChangelogType.UPDATE, ChangelogSubject.ADDRESS) }) val requestByBpnMap = requests.associateBy { it.bpns } sites.forEach { @@ -231,7 +249,7 @@ class BusinessPartnerBuildService( validAddresses.forEach { updateLogisticAddress(it, requestByBpnMap[it.bpn]!!.address, metadataMap) } - changelogService.createChangelogEntries(validAddresses.map { ChangelogEntryDto(it.bpn, ChangelogType.UPDATE, ChangelogSubject.ADDRESS) }) + changelogService.createChangelogEntries(validAddresses.map { ChangelogEntryVerboseDto(it.bpn, ChangelogType.UPDATE, ChangelogSubject.ADDRESS) }) val addressResponses = logisticAddressRepository.saveAll(validAddresses).map { it.toDto() } return AddressPartnerUpdateResponseWrapper(addressResponses, errors) @@ -249,7 +267,7 @@ class BusinessPartnerBuildService( requests: Collection, errors: MutableList>, metadataMap: AddressMetadataMappingDto - ): Collection { + ): Collection { fun findValidLegalEnities(requests: Collection): Map { val bpnLsToFetch = requests.map { it.bpnParent } @@ -281,7 +299,7 @@ class BusinessPartnerBuildService( requests: Collection, errors: MutableList>, metadataMap: AddressMetadataMappingDto - ): List { + ): List { val bpnsToFetch = requests.map { it.bpnParent } val siteByBpnMap = siteRepository diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt index 628cf14c5..dcc50b8f6 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.service import org.eclipse.tractusx.bpdm.common.dto.IdentifierLsaType import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityVerboseDto import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException -import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingDto import org.eclipse.tractusx.bpdm.pool.entity.IdentifierType import org.eclipse.tractusx.bpdm.pool.entity.LegalEntity import org.eclipse.tractusx.bpdm.pool.entity.LegalEntityIdentifier @@ -81,7 +81,7 @@ class BusinessPartnerFetchService( * Find bpn to identifier value mappings by [idValues] of [identifierTypeKey] */ @Transactional - fun findBpnsByIdentifiers(identifierTypeKey: String, lsaType: IdentifierLsaType, idValues: Collection): Set { + fun findBpnsByIdentifiers(identifierTypeKey: String, lsaType: IdentifierLsaType, idValues: Collection): Set { val identifierType = findIdentifierTypeOrThrow(identifierTypeKey, lsaType) return when (lsaType) { IdentifierLsaType.LEGAL_ENTITY -> legalEntityIdentifierRepository.findBpnsByIdentifierTypeAndValues(identifierType, idValues) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt index 05203b710..a7f0b8885 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject -import org.eclipse.tractusx.bpdm.pool.dto.ChangelogEntryDto +import org.eclipse.tractusx.bpdm.pool.dto.ChangelogEntryVerboseDto import org.eclipse.tractusx.bpdm.pool.entity.PartnerChangelogEntry import org.eclipse.tractusx.bpdm.pool.repository.PartnerChangelogEntryRepository import org.eclipse.tractusx.bpdm.pool.repository.PartnerChangelogEntryRepository.Specs.byBpnsIn @@ -49,7 +49,7 @@ class PartnerChangelogService( private val logger = KotlinLogging.logger { } @Transactional - fun createChangelogEntries(changelogEntries: Collection): List { + fun createChangelogEntries(changelogEntries: Collection): List { logger.debug { "Create ${changelogEntries.size} new change log entries" } val entities = changelogEntries.map { it.toEntity() } return partnerChangelogEntryRepository.saveAll(entities) @@ -81,7 +81,7 @@ class PartnerChangelogService( return page.toDto(page.content.map { it.toDto() }) } - private fun ChangelogEntryDto.toEntity(): PartnerChangelogEntry { + private fun ChangelogEntryVerboseDto.toEntity(): PartnerChangelogEntry { return PartnerChangelogEntry(this.changelogType, this.bpn, this.changelogSubject) } } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 3c56382d1..7fb31959c 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -32,8 +32,8 @@ fun Page.toDto(dtoContent: Collection): PageResponse { return PageResponse(this.totalElements, this.totalPages, this.number, this.numberOfElements, dtoContent) } -fun LegalEntity.toMatchDto(score: Float): LegalEntityMatchResponse { - return LegalEntityMatchResponse( +fun LegalEntity.toMatchDto(score: Float): LegalEntityMatchVerboseDto { + return LegalEntityMatchVerboseDto( score = score, legalEntity = this.toDto(), legalName = this.legalName.value, @@ -41,8 +41,8 @@ fun LegalEntity.toMatchDto(score: Float): LegalEntityMatchResponse { ) } -fun LegalEntity.toUpsertDto(entryId: String?): LegalEntityPartnerCreateResponse { - return LegalEntityPartnerCreateResponse( +fun LegalEntity.toUpsertDto(entryId: String?): LegalEntityPartnerCreateVerboseDto { + return LegalEntityPartnerCreateVerboseDto( legalEntity = toDto(), legalAddress = legalAddress.toDto(), index = entryId, @@ -134,8 +134,8 @@ fun LogisticAddress.toDto(): LogisticAddressVerboseDto { ) } -fun LogisticAddress.toLegalAddressResponse(): LegalAddressResponse { - return LegalAddressResponse( +fun LogisticAddress.toLegalAddressResponse(): LegalAddressVerboseDto { + return LegalAddressVerboseDto( physicalPostalAddress = physicalPostalAddress.toDto(), alternativePostalAddress = alternativePostalAddress?.toDto(), bpnLegalEntity = legalEntity?.bpn!!, @@ -144,8 +144,8 @@ fun LogisticAddress.toLegalAddressResponse(): LegalAddressResponse { ) } -fun LogisticAddress.toMainAddressResponse(): MainAddressResponse { - return MainAddressResponse( +fun LogisticAddress.toMainAddressResponse(): MainAddressVerboseDto { + return MainAddressVerboseDto( physicalPostalAddress = physicalPostalAddress.toDto(), alternativePostalAddress = alternativePostalAddress?.toDto(), bpnSite = site?.bpn!!, @@ -205,19 +205,19 @@ private fun Street.toDto(): StreetDto { ) } -fun LogisticAddress.toMatchDto(score: Float): AddressMatchResponse { - return AddressMatchResponse(score, this.toDto()) +fun LogisticAddress.toMatchDto(score: Float): AddressMatchVerboseDto { + return AddressMatchVerboseDto(score, this.toDto()) } -fun LogisticAddress.toCreateResponse(index: String?): AddressPartnerCreateResponse { - return AddressPartnerCreateResponse( +fun LogisticAddress.toCreateResponse(index: String?): AddressPartnerCreateVerboseDto { + return AddressPartnerCreateVerboseDto( address = toDto(), index = index ) } -fun Site.toUpsertDto(entryId: String?): SitePartnerCreateResponse { - return SitePartnerCreateResponse( +fun Site.toUpsertDto(entryId: String?): SitePartnerCreateVerboseDto { + return SitePartnerCreateVerboseDto( site = toDto(), mainAddress = mainAddress.toDto(), index = entryId @@ -235,8 +235,8 @@ fun Site.toDto(): SiteVerboseDto { ) } -fun Site.toPoolDto(): SitePoolResponse { - return SitePoolResponse( +fun Site.toPoolDto(): SitePoolVerboseDto { + return SitePoolVerboseDto( site = SiteVerboseDto( bpn, @@ -269,8 +269,8 @@ fun Relation.toDto(): RelationVerboseDto { ) } -fun SyncRecord.toDto(): SyncResponse { - return SyncResponse(type, status, count, progress, errorDetails, startedAt, finishedAt) +fun SyncRecord.toDto(): SyncDto { + return SyncDto(type, status, count, progress, errorDetails, startedAt, finishedAt) } fun PartnerChangelogEntry.toDto(): ChangelogEntryResponse { diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt index 240211a5e..57b128d77 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt @@ -24,7 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.SiteVerboseDto import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException -import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolVerboseDto import org.eclipse.tractusx.bpdm.pool.entity.Site import org.eclipse.tractusx.bpdm.pool.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.pool.repository.SiteRepository @@ -47,7 +47,7 @@ class SiteService( return page.toDto(page.content.map { it.toDto() }) } - fun findByPartnerBpns(siteSearchRequest: SiteBpnSearchRequest, paginationRequest: PaginationRequest): PageResponse { + fun findByPartnerBpns(siteSearchRequest: SiteBpnSearchRequest, paginationRequest: PaginationRequest): PageResponse { val partners = if (siteSearchRequest.legalEntities.isNotEmpty()) legalEntityRepository.findDistinctByBpnIn(siteSearchRequest.legalEntities) else emptyList() val sitePage = @@ -56,7 +56,7 @@ class SiteService( return sitePage.toDto(sitePage.content.map { it.toPoolDto() }) } - fun findByBpn(bpn: String): SitePoolResponse { + fun findByBpn(bpn: String): SitePoolVerboseDto { val site = siteRepository.findByBpn(bpn) ?: throw BpdmNotFoundException("Site", bpn) return site.toPoolDto() } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt index c07e37524..864dcfe3e 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt @@ -30,7 +30,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchVerboseDto import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service.OpenSearchSyncStarterService import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach @@ -204,7 +204,7 @@ class OpenSearchControllerIT @Autowired constructor( } - private fun searchBusinessPartnerByName(name: String): PageResponse { + private fun searchBusinessPartnerByName(name: String): PageResponse { return poolClient.legalEntities().getLegalEntities( LegalEntityPropertiesSearchRequest(name), diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt index b38f2f646..2dd5be046 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt @@ -28,7 +28,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressCreateError -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressUpdateError import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach @@ -424,14 +424,14 @@ class AddressControllerIT @Autowired constructor( testHelpers.assertErrorResponse(response.errors.last(), AddressUpdateError.AddressNotFound, secondInvalidBpn) } - private fun assertCreatedAddressesAreEqual(actuals: Collection, expected: Collection) { + private fun assertCreatedAddressesAreEqual(actuals: Collection, expected: Collection) { actuals.forEach { assertThat(it.address.bpna).matches(testHelpers.bpnAPattern) } testHelpers.assertRecursively(actuals) .ignoringFields( - AddressPartnerCreateResponse::address.name + "." + LogisticAddressVerboseDto::bpna.name, - AddressPartnerCreateResponse::address.name + "." + LogisticAddressVerboseDto::bpnLegalEntity.name, - AddressPartnerCreateResponse::address.name + "." + LogisticAddressVerboseDto::bpnSite.name + AddressPartnerCreateVerboseDto::address.name + "." + LogisticAddressVerboseDto::bpna.name, + AddressPartnerCreateVerboseDto::address.name + "." + LogisticAddressVerboseDto::bpnLegalEntity.name, + AddressPartnerCreateVerboseDto::address.name + "." + LogisticAddressVerboseDto::bpnSite.name ) .isEqualTo(expected) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt index 5c86f2f31..70147eb3d 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt @@ -25,7 +25,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchVerboseDto import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -103,7 +103,7 @@ class AddressControllerSearchIT @Autowired constructor( fun `search address via name`() { val expected = PageResponse( 1, 1, 0, 1, listOf( - AddressMatchResponse(0f, givenAddress1) + AddressMatchVerboseDto(0f, givenAddress1) ) ) @@ -124,7 +124,7 @@ class AddressControllerSearchIT @Autowired constructor( @Test fun `search address via name not found`() { val expected = PageResponse( - 0, 0, 0, 0, emptyList() + 0, 0, 0, 0, emptyList() ) @@ -137,9 +137,9 @@ class AddressControllerSearchIT @Autowired constructor( } - private fun assertPageEquals(actual: PageResponse, expected: PageResponse) { + private fun assertPageEquals(actual: PageResponse, expected: PageResponse) { testHelpers.assertRecursively(actual) - .ignoringFieldsMatchingRegexes(".*${AddressMatchResponse::score.name}") + .ignoringFieldsMatchingRegexes(".*${AddressMatchVerboseDto::score.name}") .isEqualTo(expected) } } \ No newline at end of file diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt index ab0d654e4..45bc8ef00 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt @@ -27,9 +27,9 @@ import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityVerboseDto import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalAddressResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalAddressVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityCreateError -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerCreateResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerCreateVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityUpdateError import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach @@ -475,7 +475,7 @@ class LegalEntityControllerIT @Autowired constructor( } - fun assertThatCreatedLegalEntitiesEqual(actuals: Collection, expected: Collection) { + fun assertThatCreatedLegalEntitiesEqual(actuals: Collection, expected: Collection) { val now = Instant.now() val justBeforeCreate = now.minusSeconds(2) actuals.forEach { assertThat(it.legalEntity.currentness).isBetween(justBeforeCreate, now) } @@ -488,8 +488,8 @@ class LegalEntityControllerIT @Autowired constructor( } fun assertThatModifiedLegalEntitiesEqual( - actuals: Collection, - expected: Collection + actuals: Collection, + expected: Collection ) { val now = Instant.now() val justBeforeCreate = now.minusSeconds(2) @@ -497,7 +497,7 @@ class LegalEntityControllerIT @Autowired constructor( testHelpers.assertRecursively(actuals) .ignoringFieldsOfTypes(Instant::class.java) - .ignoringFields(LegalEntityPartnerCreateResponse::index.name) + .ignoringFields(LegalEntityPartnerCreateVerboseDto::index.name) .isEqualTo(expected) } @@ -518,7 +518,7 @@ class LegalEntityControllerIT @Autowired constructor( throw IllegalArgumentException("Can't change case of string $value") } - private fun toLegalAddressResponse(it: LogisticAddressVerboseDto) = LegalAddressResponse( + private fun toLegalAddressResponse(it: LogisticAddressVerboseDto) = LegalAddressVerboseDto( physicalPostalAddress = it.physicalPostalAddress, alternativePostalAddress = it.alternativePostalAddress, bpnLegalEntity = it.bpnLegalEntity!!, diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt index 6a5f398d0..cc0393a60 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt @@ -27,7 +27,7 @@ import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchVerboseDto import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -99,8 +99,8 @@ class LegalEntityControllerSearchIT @Autowired constructor( val expected = PageResponse( 2, 1, 0, 2, listOf( - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner1, legalName = legalName1, legalAddress = legalAddress1), - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) + LegalEntityMatchVerboseDto(score = 0f, legalEntity = givenPartner1, legalName = legalName1, legalAddress = legalAddress1), + LegalEntityMatchVerboseDto(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) ) ) @@ -119,12 +119,12 @@ class LegalEntityControllerSearchIT @Autowired constructor( val expectedFirstPage = PageResponse( 2, 2, 0, 1, listOf( - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner1, legalName = legalName1, legalAddress = legalAddress1) + LegalEntityMatchVerboseDto(score = 0f, legalEntity = givenPartner1, legalName = legalName1, legalAddress = legalAddress1) ) ) val expectedSecondPage = PageResponse( 2, 2, 1, 1, listOf( - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) + LegalEntityMatchVerboseDto(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) ) ) @@ -165,7 +165,7 @@ class LegalEntityControllerSearchIT @Autowired constructor( // assertThat(foundPartners).isEmpty() // } - private fun searchBusinessPartnerBySiteName(siteName: String, page: Int, size: Int): PageResponse { + private fun searchBusinessPartnerBySiteName(siteName: String, page: Int, size: Int): PageResponse { val sitePropertiesSearchRequest = SitePropertiesSearchRequest(siteName) return poolClient.legalEntities().getLegalEntities( @@ -176,9 +176,9 @@ class LegalEntityControllerSearchIT @Autowired constructor( } - private fun assertPageEquals(actual: PageResponse, expected: PageResponse) { + private fun assertPageEquals(actual: PageResponse, expected: PageResponse) { testHelpers.assertRecursively(actual) - .ignoringFieldsMatchingRegexes(".*${LegalEntityMatchResponse::score.name}") + .ignoringFieldsMatchingRegexes(".*${LegalEntityMatchVerboseDto::score.name}") .isEqualTo(expected) } } \ No newline at end of file diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt index 0710d3ea0..014756651 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt @@ -26,8 +26,8 @@ import org.eclipse.tractusx.bpdm.common.dto.response.* import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.response.SiteCreateError -import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.SiteUpdateError import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach @@ -107,11 +107,11 @@ class SiteControllerIT @Autowired constructor( val siteSearchRequest = SiteBpnSearchRequest(emptyList(), listOf(bpnS1, bpnS2)) val searchResult = poolClient.sites().searchSites(siteSearchRequest, PaginationRequest()) - val expectedSiteWithReference1 = SitePoolResponse( + val expectedSiteWithReference1 = SitePoolVerboseDto( site = ResponseValues.site1.copy(bpnLegalEntity = bpnL), mainAddress = ResponseValues.addressPartner1.copy(isMainAddress = true, bpnSite = CommonValues.bpnS1) ) - val expectedSiteWithReference2 = SitePoolResponse( + val expectedSiteWithReference2 = SitePoolVerboseDto( site = ResponseValues.site2.copy(bpnLegalEntity = bpnL), mainAddress = ResponseValues.addressPartner2.copy(isMainAddress = true, bpnSite = CommonValues.bpnS2) ) @@ -119,7 +119,7 @@ class SiteControllerIT @Autowired constructor( testHelpers.assertRecursively(searchResult.content) .ignoringFieldsOfTypes(Instant::class.java) .ignoringFields( - SitePoolResponse::mainAddress.name + "." + LogisticAddressVerboseDto::bpna.name, + SitePoolVerboseDto::mainAddress.name + "." + LogisticAddressVerboseDto::bpna.name, ) .isEqualTo(listOf(expectedSiteWithReference1, expectedSiteWithReference2)) } @@ -154,17 +154,17 @@ class SiteControllerIT @Autowired constructor( val searchResult = poolClient.sites().searchSites(siteSearchRequest, PaginationRequest()) val expectedSiteWithReference1 = - SitePoolResponse( + SitePoolVerboseDto( site = ResponseValues.site1.copy(bpnLegalEntity = bpnL1), mainAddress = ResponseValues.addressPartner1.copy(isMainAddress = true, bpnSite = CommonValues.bpnS1) ) val expectedSiteWithReference2 = - SitePoolResponse( + SitePoolVerboseDto( site = ResponseValues.site2.copy(bpnLegalEntity = bpnL1), mainAddress = ResponseValues.addressPartner2.copy(isMainAddress = true, bpnSite = CommonValues.bpnS2) ) val expectedSiteWithReference3 = - SitePoolResponse( + SitePoolVerboseDto( site = ResponseValues.site3.copy(bpnLegalEntity = bpnL2), mainAddress = ResponseValues.addressPartner3.copy(isMainAddress = true, bpnSite = CommonValues.bpnS3) ) @@ -172,7 +172,7 @@ class SiteControllerIT @Autowired constructor( testHelpers.assertRecursively(searchResult.content) .ignoringFieldsOfTypes(Instant::class.java) .ignoringFields( - SitePoolResponse::mainAddress.name + "." + LogisticAddressVerboseDto::bpna.name, + SitePoolVerboseDto::mainAddress.name + "." + LogisticAddressVerboseDto::bpna.name, ) .isEqualTo(listOf(expectedSiteWithReference1, expectedSiteWithReference2, expectedSiteWithReference3)) } @@ -374,15 +374,15 @@ class SiteControllerIT @Autowired constructor( testHelpers.assertRecursively(response).isEqualTo(expected) } - private fun assertThatCreatedSitesEqual(actuals: Collection, expected: Collection) { + private fun assertThatCreatedSitesEqual(actuals: Collection, expected: Collection) { actuals.forEach { assertThat(it.site.bpns).matches(testHelpers.bpnSPattern) } testHelpers.assertRecursively(actuals) .ignoringFields( - SitePartnerCreateResponse::site.name + "." + SiteVerboseDto::bpns.name, - SitePartnerCreateResponse::site.name + "." + SiteVerboseDto::bpnLegalEntity.name, - SitePartnerCreateResponse::mainAddress.name + "." + LogisticAddressVerboseDto::bpna.name, - SitePartnerCreateResponse::mainAddress.name + "." + LogisticAddressVerboseDto::bpnSite.name + SitePartnerCreateVerboseDto::site.name + "." + SiteVerboseDto::bpns.name, + SitePartnerCreateVerboseDto::site.name + "." + SiteVerboseDto::bpnLegalEntity.name, + SitePartnerCreateVerboseDto::mainAddress.name + "." + LogisticAddressVerboseDto::bpna.name, + SitePartnerCreateVerboseDto::mainAddress.name + "." + LogisticAddressVerboseDto::bpnSite.name ) .isEqualTo(expected) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerTestDto.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerTestDto.kt index ba5345f64..1d1c7ee76 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerTestDto.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerTestDto.kt @@ -22,9 +22,9 @@ package org.eclipse.tractusx.bpdm.pool.util import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerCreateRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerCreateResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerCreateVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateVerboseDto data class LegalEntityStructureRequest( val legalEntity: LegalEntityPartnerCreateRequest, @@ -38,12 +38,12 @@ data class SiteStructureRequest( ) data class LegalEntityStructureResponse( - val legalEntity: LegalEntityPartnerCreateResponse, + val legalEntity: LegalEntityPartnerCreateVerboseDto, val siteStructures: List = emptyList(), - val addresses: List = emptyList() + val addresses: List = emptyList() ) data class SiteStructureResponse( - val site: SitePartnerCreateResponse, - val addresses: List = emptyList() + val site: SitePartnerCreateVerboseDto, + val addresses: List = emptyList() ) \ No newline at end of file diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt index 002b8bf78..03026caf6 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt @@ -24,9 +24,9 @@ import org.eclipse.tractusx.bpdm.common.dto.StreetDto import org.eclipse.tractusx.bpdm.common.dto.response.* import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameVerboseDto import org.eclipse.tractusx.bpdm.common.service.toDto -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerCreateResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerCreateVerboseDto +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateVerboseDto import java.time.Instant import java.time.LocalDateTime import java.time.ZoneOffset @@ -180,17 +180,17 @@ object ResponseValues { updatedAt = Instant.now() ) - val addressPartnerCreate1 = AddressPartnerCreateResponse( + val addressPartnerCreate1 = AddressPartnerCreateVerboseDto( address = addressPartner1, index = CommonValues.index1 ) - val addressPartnerCreate2 = AddressPartnerCreateResponse( + val addressPartnerCreate2 = AddressPartnerCreateVerboseDto( address = addressPartner2, index = CommonValues.index2 ) - val addressPartnerCreate3 = AddressPartnerCreateResponse( + val addressPartnerCreate3 = AddressPartnerCreateVerboseDto( address = addressPartner3, index = CommonValues.index3 ) @@ -222,7 +222,7 @@ object ResponseValues { updatedAt = CommonValues.now, ) - val siteUpsert1 = SitePartnerCreateResponse( + val siteUpsert1 = SitePartnerCreateVerboseDto( site = site1, mainAddress = addressPartner1.copy( bpnSite = site1.bpns, @@ -231,7 +231,7 @@ object ResponseValues { index = CommonValues.index1 ) - val siteUpsert2 = SitePartnerCreateResponse( + val siteUpsert2 = SitePartnerCreateVerboseDto( site = site2, mainAddress = addressPartner2.copy( bpnSite = site2.bpns, @@ -240,7 +240,7 @@ object ResponseValues { index = CommonValues.index2 ) - val siteUpsert3 = SitePartnerCreateResponse( + val siteUpsert3 = SitePartnerCreateVerboseDto( site = site3, mainAddress = addressPartner3.copy( bpnSite = site3.bpns, @@ -376,7 +376,7 @@ object ResponseValues { ) ) - val legalEntityUpsert1 = LegalEntityPartnerCreateResponse( + val legalEntityUpsert1 = LegalEntityPartnerCreateVerboseDto( legalName = CommonValues.name1, legalEntity = LegalEntityVerboseDto( bpnl = CommonValues.bpnL1, @@ -396,7 +396,7 @@ object ResponseValues { index = CommonValues.index1 ) - val legalEntityUpsert2 = LegalEntityPartnerCreateResponse( + val legalEntityUpsert2 = LegalEntityPartnerCreateVerboseDto( legalName = CommonValues.name3, legalEntity = LegalEntityVerboseDto( bpnl = CommonValues.bpnL2, @@ -415,7 +415,7 @@ object ResponseValues { index = CommonValues.index2 ) - val legalEntityUpsert3 = LegalEntityPartnerCreateResponse( + val legalEntityUpsert3 = LegalEntityPartnerCreateVerboseDto( legalName = CommonValues.name5, legalEntity = LegalEntityVerboseDto( bpnl = CommonValues.bpnL3, diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt index aba379684..27d9763ea 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt @@ -28,7 +28,7 @@ import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.IdentifiersSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ErrorCode import org.eclipse.tractusx.bpdm.pool.api.model.response.ErrorInfo -import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncDto import org.eclipse.tractusx.bpdm.pool.config.BpnConfigProperties import org.junit.Assert import org.junit.jupiter.api.assertThrows @@ -194,20 +194,20 @@ class TestHelpers( } - fun startSyncAndAwaitSuccess(client: WebTestClient, syncPath: String): SyncResponse { + fun startSyncAndAwaitSuccess(client: WebTestClient, syncPath: String): SyncDto { return startSyncAndAwaitResult(client, syncPath, SyncStatus.SUCCESS) } - fun startSyncAndAwaitError(client: WebTestClient, syncPath: String): SyncResponse { + fun startSyncAndAwaitError(client: WebTestClient, syncPath: String): SyncDto { return startSyncAndAwaitResult(client, syncPath, SyncStatus.ERROR) } - private fun startSyncAndAwaitResult(client: WebTestClient, syncPath: String, status: SyncStatus): SyncResponse { + private fun startSyncAndAwaitResult(client: WebTestClient, syncPath: String, status: SyncStatus): SyncDto { client.invokePostEndpointWithoutResponse(syncPath) //check for async import to finish several times val timeOutAt = Instant.now().plusMillis(ASYNC_TIMEOUT_IN_MS) - var syncResponse: SyncResponse + var syncResponse: SyncDto do { Thread.sleep(ASYNC_CHECK_INTERVAL_IN_MS) From adea00bb4a4046252542bf6adbc1580c238e8325 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Wed, 5 Jul 2023 08:05:30 +0200 Subject: [PATCH 2/2] fix(api): API-Model: Rename DTOs #268 - rename PageResponse --- .../response/{PageResponse.kt => PageDto.kt} | 2 +- .../tractusx/bpdm/gate/api/GateAddressApi.kt | 8 ++--- .../bpdm/gate/api/GateLegalEntityApi.kt | 8 ++--- .../bpdm/gate/api/GateSharingStateApi.kt | 4 +-- .../tractusx/bpdm/gate/api/GateSiteApi.kt | 8 ++--- .../bpdm/gate/controller/AddressController.kt | 8 ++--- .../gate/controller/LegalEntityController.kt | 8 ++--- .../gate/controller/SharingStateController.kt | 4 +-- .../bpdm/gate/controller/SiteController.kt | 8 ++--- .../bpdm/gate/service/AddressService.kt | 10 +++---- .../bpdm/gate/service/LegalEntityService.kt | 10 +++---- .../bpdm/gate/service/ResponseMappings.kt | 6 ++-- .../bpdm/gate/service/SharingStateService.kt | 4 +-- .../tractusx/bpdm/gate/service/SiteService.kt | 10 +++---- .../controller/AddressControllerInputIT.kt | 6 ++-- .../controller/AddressControllerOutputIT.kt | 6 ++-- .../LegalEntityControllerInputIT.kt | 6 ++-- .../LegalEntityControllerOutputIT.kt | 6 ++-- .../gate/controller/SiteControllerInputIT.kt | 6 ++-- .../gate/controller/SiteControllerOutputIT.kt | 6 ++-- .../tractusx/bpdm/pool/api/PoolAddressApi.kt | 6 ++-- .../bpdm/pool/api/PoolChangelogApi.kt | 4 +-- .../bpdm/pool/api/PoolLegalEntityApi.kt | 6 ++-- .../tractusx/bpdm/pool/api/PoolMetadataApi.kt | 6 ++-- .../tractusx/bpdm/pool/api/PoolSaasApi.kt | 4 +-- .../tractusx/bpdm/pool/api/PoolSiteApi.kt | 4 +-- .../component/opensearch/SearchService.kt | 6 ++-- .../impl/service/SearchServiceImpl.kt | 28 ++++++++--------- .../mock/service/SearchServiceMock.kt | 6 ++-- .../bpdm/pool/controller/AddressController.kt | 6 ++-- .../pool/controller/ChangelogController.kt | 4 +-- .../pool/controller/LegalEntityController.kt | 8 ++--- .../pool/controller/MetadataController.kt | 6 ++-- .../bpdm/pool/controller/SiteController.kt | 4 +-- .../bpdm/pool/service/AddressService.kt | 6 ++-- .../bpdm/pool/service/MetadataService.kt | 6 ++-- .../pool/service/PartnerChangelogService.kt | 4 +-- .../bpdm/pool/service/ResponseMappings.kt | 4 +-- .../tractusx/bpdm/pool/service/SiteService.kt | 6 ++-- .../controller/OpenSearchControllerIT.kt | 6 ++-- .../controller/AddressControllerSearchIT.kt | 8 ++--- .../pool/controller/ChangelogControllerIT.kt | 30 +++++++++---------- .../LegalEntityControllerSearchIT.kt | 12 ++++---- .../pool/controller/MetadataControllerIT.kt | 16 +++++----- 44 files changed, 165 insertions(+), 165 deletions(-) rename bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/{PageResponse.kt => PageDto.kt} (98%) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PageResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PageDto.kt similarity index 98% rename from bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PageResponse.kt rename to bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PageDto.kt index 832fbc594..7af36a271 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PageResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PageDto.kt @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.common.dto.response import io.swagger.v3.oas.annotations.media.Schema @Schema(description = "Paginated collection of results") -data class PageResponse( +data class PageDto( @get:Schema(description = "Total number of all results in all pages") val totalElements: Long, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt index e03f2b403..5bc449022 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt @@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse 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.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto 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 @@ -93,7 +93,7 @@ interface GateAddressApi { fun getAddressesByExternalIds( @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody externalIds: Collection - ): PageResponse + ): PageDto @Operation( @@ -108,7 +108,7 @@ interface GateAddressApi { ) @GetMapping("/input/addresses") @GetExchange("/input/addresses") - fun getAddresses(@ParameterObject @Valid paginationRequest: PaginationRequest): PageResponse + fun getAddresses(@ParameterObject @Valid paginationRequest: PaginationRequest): PageDto @Operation( summary = "Get page of addresses (Output)", @@ -125,7 +125,7 @@ interface GateAddressApi { fun getAddressesOutput( @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody(required = false) externalIds: Collection? - ): PageResponse + ): PageDto @Operation( summary = "Create or update output addresses.", diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt index 46d471f58..b7cb5013d 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt @@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse 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.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto 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.LegalEntityGateInputDto @@ -90,7 +90,7 @@ interface GateLegalEntityApi { fun getLegalEntitiesByExternalIds( @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody externalIds: Collection - ): PageResponse + ): PageDto @Operation( summary = "Get page of legal entities", @@ -104,7 +104,7 @@ interface GateLegalEntityApi { ) @GetMapping("/input/legal-entities") @GetExchange("/input/legal-entities") - fun getLegalEntities(@ParameterObject @Valid paginationRequest: PaginationRequest): PageResponse + fun getLegalEntities(@ParameterObject @Valid paginationRequest: PaginationRequest): PageDto @Operation( summary = "Get page of legal entities", @@ -121,7 +121,7 @@ interface GateLegalEntityApi { fun getLegalEntitiesOutput( @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody(required = false) externalIds: Collection? - ): PageResponse + ): PageDto @Operation( summary = "Create or update output legal entities.", diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt index 6a7048114..742b77cbd 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt @@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse 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.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.SharingStateDto import org.springdoc.core.annotations.ParameterObject @@ -54,7 +54,7 @@ interface GateSharingStateApi { @ParameterObject @Valid paginationRequest: PaginationRequest, @Parameter(description = "LSA Type") @RequestParam(required = false) lsaType: LsaType?, @Parameter(description = "External identifiers") @RequestParam(required = false) externalIds: Collection? - ): PageResponse + ): PageDto @Operation( summary = "Insert/update sharing state (including error info and BPN) for business partner with LSA type and external ID" diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt index bb1f6ad85..dac802541 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt @@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse 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.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto 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.SiteGateInputDto @@ -90,7 +90,7 @@ interface GateSiteApi { fun getSitesByExternalIds( @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody externalIds: Collection - ): PageResponse + ): PageDto @Operation( summary = "Get page of sites", @@ -104,7 +104,7 @@ interface GateSiteApi { ) @GetMapping("/input/sites") @GetExchange("/input/sites") - fun getSites(@ParameterObject @Valid paginationRequest: PaginationRequest): PageResponse + fun getSites(@ParameterObject @Valid paginationRequest: PaginationRequest): PageDto @Operation( summary = "Get page of sites", @@ -121,7 +121,7 @@ interface GateSiteApi { fun getSitesOutput( @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody(required = false) externalIds: Collection? - ): PageResponse + ): PageDto @Operation( summary = "Create or update output sites.", diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt index eea1a42b7..b8c64fad7 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.gate.api.GateAddressApi import org.eclipse.tractusx.bpdm.gate.api.model.request.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.AddressGateOutputRequest @@ -67,12 +67,12 @@ class AddressController( override fun getAddressesByExternalIds( paginationRequest: PaginationRequest, externalIds: Collection - ): PageResponse { + ): PageDto { return addressService.getAddresses(page = paginationRequest.page, size = paginationRequest.size, externalIds = externalIds) } @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") - override fun getAddresses(paginationRequest: PaginationRequest): PageResponse { + override fun getAddresses(paginationRequest: PaginationRequest): PageDto { return addressService.getAddresses(page = paginationRequest.page, size = paginationRequest.size) } @@ -80,7 +80,7 @@ class AddressController( override fun getAddressesOutput( paginationRequest: PaginationRequest, externalIds: Collection? - ): PageResponse { + ): PageDto { return addressService.getAddressesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt index 6c0913b57..cc02d5b67 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.gate.api.GateLegalEntityApi import org.eclipse.tractusx.bpdm.gate.api.model.request.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.LegalEntityGateOutputRequest @@ -57,12 +57,12 @@ class LegalEntityController( override fun getLegalEntitiesByExternalIds( paginationRequest: PaginationRequest, externalIds: Collection - ): PageResponse { + ): PageDto { return legalEntityService.getLegalEntities(page = paginationRequest.page, size = paginationRequest.size, externalIds = externalIds) } @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") - override fun getLegalEntities(paginationRequest: PaginationRequest): PageResponse { + override fun getLegalEntities(paginationRequest: PaginationRequest): PageDto { return legalEntityService.getLegalEntities(page = paginationRequest.page, size = paginationRequest.size) } @@ -70,7 +70,7 @@ class LegalEntityController( override fun getLegalEntitiesOutput( paginationRequest: PaginationRequest, externalIds: Collection? - ): PageResponse { + ): PageDto { return legalEntityService.getLegalEntitiesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt index b604f0444..3ca3314a4 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.controller import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.gate.api.GateSharingStateApi import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.SharingStateDto @@ -36,7 +36,7 @@ class SharingStateController( private val logger = KotlinLogging.logger { } @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") - override fun getSharingStates(paginationRequest: PaginationRequest, lsaType: LsaType?, externalIds: Collection?): PageResponse { + override fun getSharingStates(paginationRequest: PaginationRequest, lsaType: LsaType?, externalIds: Collection?): PageDto { return sharingStateService.findSharingStates(paginationRequest, lsaType, externalIds) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt index e55d8d2c0..39b06dc36 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.gate.api.GateSiteApi import org.eclipse.tractusx.bpdm.gate.api.model.request.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.SiteGateOutputRequest @@ -59,17 +59,17 @@ class SiteController( override fun getSitesByExternalIds( paginationRequest: PaginationRequest, externalIds: Collection - ): PageResponse { + ): PageDto { return siteService.getSites(page = paginationRequest.page, size = paginationRequest.size, externalIds = externalIds) } @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") - override fun getSites(paginationRequest: PaginationRequest): PageResponse { + override fun getSites(paginationRequest: PaginationRequest): PageDto { return siteService.getSites(page = paginationRequest.page, size = paginationRequest.size) } @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") - override fun getSitesOutput(paginationRequest: PaginationRequest, externalIds: Collection?): PageResponse { + override fun getSitesOutput(paginationRequest: PaginationRequest, externalIds: Collection?): PageDto { return siteService.getSitesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index c0f5b7c1d..9dc82ac0c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.LsaType @@ -46,7 +46,7 @@ class AddressService( ) { private val logger = KotlinLogging.logger { } - fun getAddresses(page: Int, size: Int, externalIds: Collection? = null): PageResponse { + fun getAddresses(page: Int, size: Int, externalIds: Collection? = null): PageDto { val logisticAddressPage = if (externalIds != null) { addressRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Input, PageRequest.of(page, size)) @@ -54,7 +54,7 @@ class AddressService( addressRepository.findByDataType(OutputInputEnum.Input, PageRequest.of(page, size)) } - return PageResponse( + return PageDto( page = page, totalElements = logisticAddressPage.totalElements, totalPages = logisticAddressPage.totalPages, @@ -81,7 +81,7 @@ class AddressService( /** * Get output addresses by fetching addresses from the database. */ - fun getAddressesOutput(externalIds: Collection? = null, page: Int, size: Int): PageResponse { + fun getAddressesOutput(externalIds: Collection? = null, page: Int, size: Int): PageDto { val logisticAddressPage = if (externalIds != null && externalIds.isNotEmpty()) { addressRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) @@ -89,7 +89,7 @@ class AddressService( addressRepository.findByDataType(OutputInputEnum.Output, PageRequest.of(page, size)) } - return PageResponse( + return PageDto( page = page, totalElements = logisticAddressPage.totalElements, totalPages = logisticAddressPage.totalPages, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index db0b11ad3..74f2a3eb2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.request.LegalEntityGateInputRequest @@ -64,7 +64,7 @@ class LegalEntityService( return toValidSingleLegalEntity(legalEntity) } - fun getLegalEntities(page: Int, size: Int, externalIds: Collection? = null): PageResponse { + fun getLegalEntities(page: Int, size: Int, externalIds: Collection? = null): PageDto { val legalEntitiesPage = if (externalIds != null) { legalEntityRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Input, PageRequest.of(page, size)) @@ -72,7 +72,7 @@ class LegalEntityService( legalEntityRepository.findByDataType(OutputInputEnum.Input, PageRequest.of(page, size)) } - return PageResponse( + return PageDto( page = page, totalElements = legalEntitiesPage.totalElements, totalPages = legalEntitiesPage.totalPages, @@ -84,7 +84,7 @@ class LegalEntityService( /** * Get output legal entities by first fetching legal entities from the database */ - fun getLegalEntitiesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { + fun getLegalEntitiesOutput(externalIds: Collection?, page: Int, size: Int): PageDto { val legalEntityPage = if (!externalIds.isNullOrEmpty()) { legalEntityRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) @@ -92,7 +92,7 @@ class LegalEntityService( legalEntityRepository.findByDataType(OutputInputEnum.Output, PageRequest.of(page, size)) } - return PageResponse( + return PageDto( page = page, totalElements = legalEntityPage.totalElements, totalPages = legalEntityPage.totalPages, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 6c35c1fc2..6e7f3ce47 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.* -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.api.model.request.* @@ -127,8 +127,8 @@ private fun StreetGateDto.toStreetEntity(): Street { ) } -fun Page.toDto(dtoContent: Collection): PageResponse { - return PageResponse(this.totalElements, this.totalPages, this.number, this.numberOfElements, dtoContent) +fun Page.toDto(dtoContent: Collection): PageDto { + return PageDto(this.totalElements, this.totalPages, this.number, this.numberOfElements, dtoContent) } // Site Mappers diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt index 06bd79115..1033d2634 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.SharingStateDto import org.eclipse.tractusx.bpdm.gate.entity.SharingState @@ -72,7 +72,7 @@ class SharingStateService(private val stateRepository: SharingStateRepository) { this.stateRepository.save(entity) } - fun findSharingStates(paginationRequest: PaginationRequest, lsaType: LsaType?, externalIds: Collection?): PageResponse { + fun findSharingStates(paginationRequest: PaginationRequest, lsaType: LsaType?, externalIds: Collection?): PageDto { val spec = Specification.allOf(byLsaType(lsaType), byExternalIdsIn(externalIds)) val pageRequest = PageRequest.of(paginationRequest.page, paginationRequest.size) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index a2caad1af..35e6d09d6 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.request.SiteGateInputRequest @@ -42,7 +42,7 @@ class SiteService( ) { private val logger = KotlinLogging.logger { } - fun getSites(page: Int, size: Int, externalIds: Collection? = null): PageResponse { + fun getSites(page: Int, size: Int, externalIds: Collection? = null): PageDto { val sitesPage = if (externalIds != null) { siteRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Input, PageRequest.of(page, size)) @@ -50,7 +50,7 @@ class SiteService( siteRepository.findByDataType(OutputInputEnum.Input, PageRequest.of(page, size)) } - return PageResponse( + return PageDto( page = page, totalElements = sitesPage.totalElements, totalPages = sitesPage.totalPages, @@ -74,7 +74,7 @@ class SiteService( /** * Get output sites by first fetching sites from the database */ - fun getSitesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { + fun getSitesOutput(externalIds: Collection?, page: Int, size: Int): PageDto { val sitePage = if (!externalIds.isNullOrEmpty()) { siteRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) @@ -82,7 +82,7 @@ class SiteService( siteRepository.findByDataType(OutputInputEnum.Output, PageRequest.of(page, size)) } - return PageResponse( + return PageDto( page = page, totalElements = sitePage.totalElements, totalPages = sitePage.totalPages, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerInputIT.kt index 6da4996d6..f65411071 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerInputIT.kt @@ -43,7 +43,7 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.util.* @@ -151,7 +151,7 @@ internal class AddressControllerInputIT @Autowired constructor( val pageResponse = gateClient.addresses().getAddresses(paginationValue) assertThat(pageResponse).isEqualTo( - PageResponse( + PageDto( totalElements = totalElements, totalPages = totalPages, page = pageValue, @@ -195,7 +195,7 @@ internal class AddressControllerInputIT @Autowired constructor( val pageResponse = gateClient.addresses().getAddressesByExternalIds(pagination, listExternalIds) assertThat(pageResponse).isEqualTo( - PageResponse( + PageDto( totalElements = totalElements, totalPages = totalPages, page = pageValue, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt index 8f153ee8c..e606158f0 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt @@ -43,7 +43,7 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository @@ -177,7 +177,7 @@ internal class AddressControllerOutputIT @Autowired constructor( val pageResponse = gateClient.addresses().getAddressesOutput(paginationValue, emptyList()) assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*processStartedAt*").isEqualTo( - PageResponse( + PageDto( totalElements = totalElements, totalPages = totalPages, page = pageValue, @@ -224,7 +224,7 @@ internal class AddressControllerOutputIT @Autowired constructor( val pageResponse = gateClient.addresses().getAddressesOutput(paginationValue, listOf(CommonValues.externalIdAddress1, CommonValues.externalIdAddress2)) assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*processStartedAt*").isEqualTo( - PageResponse( + PageDto( totalElements = totalElements, totalPages = totalPages, page = pageValue, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt index 49b077b31..5f90d8e0e 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt @@ -28,7 +28,7 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.model.request.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository @@ -221,7 +221,7 @@ internal class LegalEntityControllerInputIT @Autowired constructor( gateClient.legalEntities().upsertLegalEntities(legalEntities) val pageResponse = gateClient.legalEntities().getLegalEntities(paginationValue) - val expectedPage = PageResponse( + val expectedPage = PageDto( totalElements, totalPages, page, @@ -266,7 +266,7 @@ internal class LegalEntityControllerInputIT @Autowired constructor( val pageResponse = gateClient.legalEntities().getLegalEntitiesByExternalIds(paginationValue, listExternalIds) - val expectedPage = PageResponse( + val expectedPage = PageDto( totalElements, totalPages, page, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt index 0b9a614df..d43b4843a 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt @@ -24,7 +24,7 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository @@ -159,7 +159,7 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( val pageResponse = gateClient.legalEntities().getLegalEntitiesOutput(paginationValue, emptyList()) - val expectedPage = PageResponse( + val expectedPage = PageDto( totalElements, totalPages, page, @@ -209,7 +209,7 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( val pageResponse = gateClient.legalEntities().getLegalEntitiesOutput(paginationValue, listOf(CommonValues.externalId1, CommonValues.externalId2)) - val expectedPage = PageResponse( + val expectedPage = PageDto( totalElements, totalPages, page, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt index eb68d256c..92fed1d11 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt @@ -24,7 +24,7 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository import org.eclipse.tractusx.bpdm.gate.util.* @@ -142,7 +142,7 @@ internal class SiteControllerInputIT @Autowired constructor( val pageResponse = gateClient.sites().getSites(paginationValue) assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*").isEqualTo( - PageResponse( + PageDto( totalElements = totalElements, totalPages = totalPages, page = pageValue, @@ -192,7 +192,7 @@ internal class SiteControllerInputIT @Autowired constructor( val pageResponse = gateClient.sites().getSitesByExternalIds(paginationValue, externalIds) assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*").isEqualTo( - PageResponse( + PageDto( totalElements = totalElements, totalPages = totalPages, page = pageValue, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt index 786b098c6..858bd2608 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt @@ -24,7 +24,7 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository @@ -194,7 +194,7 @@ internal class SiteControllerOutputIT @Autowired constructor( val pageResponse = gateClient.sites().getSitesOutput(paginationValue, emptyList()) assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*", ".*processStartedAt*").isEqualTo( - PageResponse( + PageDto( totalElements = totalElements, totalPages = totalPages, page = pageValue, @@ -253,7 +253,7 @@ internal class SiteControllerOutputIT @Autowired constructor( val pageResponse = gateClient.sites().getSitesOutput(paginationValue, listOf(CommonValues.externalIdSite1, CommonValues.externalIdSite2)) assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*", ".*processStartedAt*").isEqualTo( - PageResponse( + PageDto( totalElements = totalElements, totalPages = totalPages, page = pageValue, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt index cd36940e4..83e1b927f 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt @@ -27,7 +27,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.common.dto.request.AddressPartnerBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerUpdateRequest @@ -63,7 +63,7 @@ interface PoolAddressApi { fun getAddresses( @ParameterObject addressSearchRequest: AddressPartnerSearchRequest, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageDto @Operation( summary = "Get address partners by bpna", @@ -97,7 +97,7 @@ interface PoolAddressApi { fun searchAddresses( @RequestBody addressSearchRequest: AddressPartnerBpnSearchRequest, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageDto @Operation( summary = "Create new address business partners", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolChangelogApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolChangelogApi.kt index e4347a15d..72741c84e 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolChangelogApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolChangelogApi.kt @@ -25,7 +25,7 @@ import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse import org.springdoc.core.annotations.ParameterObject @@ -56,5 +56,5 @@ interface PoolChangelogApi { fun getChangelogEntries( @RequestBody changelogSearchRequest: ChangelogSearchRequest, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageDto } \ No newline at end of file diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt index d7735ca49..0321c43c2 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt @@ -61,7 +61,7 @@ interface PoolLegalEntityApi { fun getLegalEntities( @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageDto @Operation( summary = "Get legal entity business partner by identifier", @@ -146,7 +146,7 @@ interface PoolLegalEntityApi { fun getSites( @Parameter(description = "Bpnl value") @PathVariable bpnl: String, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageDto @Operation( summary = "Get address partners of a legal entity", @@ -164,7 +164,7 @@ interface PoolLegalEntityApi { fun getAddresses( @Parameter(description = "Bpn value") @PathVariable bpnl: String, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageDto @Operation( summary = "Search Legal Addresses", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolMetadataApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolMetadataApi.kt index 89e230781..bfcca4c77 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolMetadataApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolMetadataApi.kt @@ -30,7 +30,7 @@ import org.eclipse.tractusx.bpdm.common.dto.IdentifierLsaType import org.eclipse.tractusx.bpdm.common.dto.IdentifierTypeDto import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LegalFormDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalFormRequest import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType @@ -86,7 +86,7 @@ interface PoolMetadataApi { @Parameter lsaType: IdentifierLsaType, @Parameter country: CountryCode? ): - PageResponse + PageDto @Operation( @@ -117,7 +117,7 @@ interface PoolMetadataApi { ) @GetMapping("/legal-forms") @GetExchange("/legal-forms") - fun getLegalForms(@ParameterObject paginationRequest: PaginationRequest): PageResponse + fun getLegalForms(@ParameterObject paginationRequest: PaginationRequest): PageDto @Operation( diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt index a060ed4ee..cfed789b4 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSaasApi.kt @@ -25,7 +25,7 @@ import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.ImportIdEntry import org.eclipse.tractusx.bpdm.pool.api.model.request.ImportIdFilterRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ImportIdMappingDto @@ -102,5 +102,5 @@ interface PoolSaasApi { ) @GetMapping("/identifier-mappings") @GetExchange("/identifier-mappings") - fun getImportEntries(@ParameterObject paginationRequest: PaginationRequest): PageResponse + fun getImportEntries(@ParameterObject paginationRequest: PaginationRequest): PageDto } \ No newline at end of file diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt index 8f49ffba2..c712338d8 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt @@ -27,7 +27,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerUpdateRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressVerboseDto @@ -96,7 +96,7 @@ interface PoolSiteApi { fun searchSites( @RequestBody siteSearchRequest: SiteBpnSearchRequest, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageDto @Operation( summary = "Create new site business partners", diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt index 1f10bcf8d..2f331aa19 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchVerboseDto @@ -37,7 +37,7 @@ interface SearchService { fun searchLegalEntities( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse + ): PageDto /** * Find addresses by matching their field values to [searchRequest] field query texts @@ -45,6 +45,6 @@ interface SearchService { fun searchAddresses( searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse + ): PageDto } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt index 084ddd1b2..d33ca4225 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchVerboseDto @@ -65,20 +65,20 @@ class SearchServiceImpl( * Uses the [searchRequest] to perform an OpenSearch query for business partners. * The BPNs of found partners are used to query the whole business partner records from the database. * The records are supplied with relevancy scores of the search hits and returned as a paginated result. - * In case BPNs found by OpenSearch can not be found in the database, the [PageResponse] properties are + * In case BPNs found by OpenSearch can not be found in the database, the [PageDto] properties are * adapted accordingly from the OpenSearch page information * */ override fun searchLegalEntities( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { val legalEntityPage = searchAndPreparePage(searchRequest, paginationRequest) businessPartnerFetchService.fetchLegalEntityDependencies(legalEntityPage.content.map { (_, legalEntity) -> legalEntity }.toSet()) return with(legalEntityPage) { - PageResponse(totalElements, totalPages, page, contentSize, + PageDto(totalElements, totalPages, page, contentSize, content.map { (score, legalEntity) -> legalEntity.toMatchDto(score) }) } } @@ -86,13 +86,13 @@ class SearchServiceImpl( /** * @see SearchServiceImpl.searchLegalEntities */ - override fun searchAddresses(searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest): PageResponse { + override fun searchAddresses(searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest): PageDto { val addressPage = searchAndPreparePage(searchRequest, paginationRequest) addressService.fetchLogisticAddressDependencies(addressPage.content.map { (_, address) -> address }.toSet()) return with(addressPage) { - PageResponse(totalElements, totalPages, page, contentSize, + PageDto(totalElements, totalPages, page, contentSize, content.map { (score, address) -> address.toMatchDto(score) }) } } @@ -100,7 +100,7 @@ class SearchServiceImpl( private fun searchAndPreparePage( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse> { + ): PageDto> { return if (searchRequest == BusinessPartnerSearchRequest.EmptySearchRequest) { paginateLegalEntities(paginationRequest) } else { @@ -111,7 +111,7 @@ class SearchServiceImpl( private fun searchAndPreparePage( searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse> { + ): PageDto> { return if (searchRequest == AddressPartnerSearchRequest.EmptySearchRequest) { paginateAddressPartner(paginationRequest) @@ -120,14 +120,14 @@ class SearchServiceImpl( } } - private fun paginateLegalEntities(paginationRequest: PaginationRequest): PageResponse> { + private fun paginateLegalEntities(paginationRequest: PaginationRequest): PageDto> { logger.debug { "Paginate database for legal entities" } val legalEntityPage = legalEntityRepository.findAll(PageRequest.of(paginationRequest.page, paginationRequest.size)) return legalEntityPage.toDto(legalEntityPage.content.map { Pair(0f, it) }) // assign 0 score as no search has been conducted } - private fun paginateAddressPartner(paginationRequest: PaginationRequest): PageResponse> { + private fun paginateAddressPartner(paginationRequest: PaginationRequest): PageDto> { logger.debug { "Paginate database for address partners" } val addressPage = logisticAddressRepository.findAll(PageRequest.of(paginationRequest.page, paginationRequest.size)) @@ -137,7 +137,7 @@ class SearchServiceImpl( private fun searchIndex( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse> { + ): PageDto> { logger.debug { "Search index for legal entities" } if (paginationRequest.page > openSearchConfigProperties.maxPage) @@ -162,13 +162,13 @@ class SearchServiceImpl( val totalHits = searchResult.totalHits!!.value - missingPartners.size val totalPages = ceil(totalHits.toDouble() / paginationRequest.size).toInt() - return PageResponse(totalHits, totalPages, paginationRequest.page, legalEntities.size, scoreLegalEntityPairs) + return PageDto(totalHits, totalPages, paginationRequest.page, legalEntities.size, scoreLegalEntityPairs) } private fun searchIndex( searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse> { + ): PageDto> { logger.debug { "Search index for addresses" } if (paginationRequest.page > openSearchConfigProperties.maxPage) @@ -193,7 +193,7 @@ class SearchServiceImpl( val totalHits = searchResult.totalHits!!.value - missingPartners.size val totalPages = ceil(totalHits.toDouble() / paginationRequest.size).toInt() - return PageResponse(totalHits, totalPages, paginationRequest.page, addresses.size, scoreAddressPairs) + return PageDto(totalHits, totalPages, paginationRequest.page, addresses.size, scoreAddressPairs) } } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt index 2cb1a7e91..01d37de84 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.mock.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchVerboseDto @@ -52,7 +52,7 @@ class SearchServiceMock( override fun searchLegalEntities( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { val resultPage = legalEntityRepository.findAll(PageRequest.of(paginationRequest.page, paginationRequest.size)) @@ -65,7 +65,7 @@ class SearchServiceMock( * Ignores [searchRequest] and returns an unfiltered result of addresses in the database, * adding a default relevancy score to each entry */ - override fun searchAddresses(searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest): PageResponse { + override fun searchAddresses(searchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest): PageDto { val resultPage = logisticAddressRepository.findAll(PageRequest.of(paginationRequest.page, paginationRequest.size)) logger.info { "Mock search: Returning ${resultPage.size} addresses from database" } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt index cdbf41d72..005e1a564 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.eclipse.tractusx.bpdm.common.dto.request.AddressPartnerBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.PoolAddressApi import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest @@ -47,7 +47,7 @@ class AddressController( override fun getAddresses( addressSearchRequest: AddressPartnerSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { return searchService.searchAddresses(addressSearchRequest, paginationRequest) } @@ -63,7 +63,7 @@ class AddressController( override fun searchAddresses( addressSearchRequest: AddressPartnerBpnSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { return addressService.findByPartnerAndSiteBpns(addressSearchRequest, paginationRequest) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogController.kt index d050825ae..d2453335e 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogController.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.PoolChangelogApi import org.eclipse.tractusx.bpdm.pool.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse @@ -40,7 +40,7 @@ class ChangelogController( override fun getChangelogEntries( changelogSearchRequest: ChangelogSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { changelogSearchRequest.bpns?.let { bpns -> if (bpns.size > controllerConfigProperties.searchRequestLimit) { diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt index 75f0321b3..e2beff0d1 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityVerboseDto import org.eclipse.tractusx.bpdm.common.dto.response.SiteVerboseDto import org.eclipse.tractusx.bpdm.pool.api.PoolLegalEntityApi @@ -62,7 +62,7 @@ class LegalEntityController( override fun getLegalEntities( bpSearchRequest: LegalEntityPropertiesSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { return searchService.searchLegalEntities( BusinessPartnerSearchRequest(bpSearchRequest), paginationRequest @@ -95,7 +95,7 @@ class LegalEntityController( override fun getSites( bpnl: String, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { return siteService.findByPartnerBpn(bpnl.uppercase(), paginationRequest.page, paginationRequest.size) } @@ -103,7 +103,7 @@ class LegalEntityController( override fun getAddresses( bpnl: String, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { return addressService.findByPartnerBpn(bpnl.uppercase(), paginationRequest.page, paginationRequest.size) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/MetadataController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/MetadataController.kt index 9442c7327..2369cdee9 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/MetadataController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/MetadataController.kt @@ -25,7 +25,7 @@ import org.eclipse.tractusx.bpdm.common.dto.IdentifierLsaType import org.eclipse.tractusx.bpdm.common.dto.IdentifierTypeDto import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LegalFormDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.PoolMetadataApi import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalFormRequest import org.eclipse.tractusx.bpdm.pool.service.MetadataService @@ -46,7 +46,7 @@ class MetadataController( } @PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getReadMetaDataAsRole())") - override fun getIdentifierTypes(paginationRequest: PaginationRequest, lsaType: IdentifierLsaType, country: CountryCode?): PageResponse { + override fun getIdentifierTypes(paginationRequest: PaginationRequest, lsaType: IdentifierLsaType, country: CountryCode?): PageDto { return metadataService.getIdentifierTypes(PageRequest.of(paginationRequest.page, paginationRequest.size), lsaType, country) } @@ -56,7 +56,7 @@ class MetadataController( } @PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getReadMetaDataAsRole())") - override fun getLegalForms(paginationRequest: PaginationRequest): PageResponse { + override fun getLegalForms(paginationRequest: PaginationRequest): PageDto { return metadataService.getLegalForms(PageRequest.of(paginationRequest.page, paginationRequest.size)) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt index 48833bf4f..075b291c1 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.PoolSiteApi import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerUpdateRequest @@ -60,7 +60,7 @@ class SiteController( override fun searchSites( siteSearchRequest: SiteBpnSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { return siteService.findByPartnerBpns(siteSearchRequest, paginationRequest) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/AddressService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/AddressService.kt index 1e8f07bf5..bbfd76954 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/AddressService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/AddressService.kt @@ -23,7 +23,7 @@ import jakarta.transaction.Transactional import org.eclipse.tractusx.bpdm.common.dto.request.AddressPartnerBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalAddressVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressVerboseDto @@ -40,7 +40,7 @@ class AddressService( private val legalEntityRepository: LegalEntityRepository, private val siteRepository: SiteRepository, ) { - fun findByPartnerBpn(bpn: String, pageIndex: Int, pageSize: Int): PageResponse { + fun findByPartnerBpn(bpn: String, pageIndex: Int, pageSize: Int): PageDto { if (!legalEntityRepository.existsByBpn(bpn)) { throw BpdmNotFoundException("Business Partner", bpn) } @@ -59,7 +59,7 @@ class AddressService( fun findByPartnerAndSiteBpns( searchRequest: AddressPartnerBpnSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageDto { val partners = if (searchRequest.legalEntities.isNotEmpty()) legalEntityRepository.findDistinctByBpnIn(searchRequest.legalEntities) else emptyList() val sites = if (searchRequest.sites.isNotEmpty()) siteRepository.findDistinctByBpnIn(searchRequest.sites) else emptyList() diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataService.kt index ea08377f7..25e997b91 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataService.kt @@ -26,7 +26,7 @@ import org.eclipse.tractusx.bpdm.common.dto.IdentifierLsaType import org.eclipse.tractusx.bpdm.common.dto.IdentifierTypeDto import org.eclipse.tractusx.bpdm.common.dto.QualityLevel import org.eclipse.tractusx.bpdm.common.dto.response.LegalFormDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalFormRequest import org.eclipse.tractusx.bpdm.pool.entity.FieldQualityRule import org.eclipse.tractusx.bpdm.pool.entity.IdentifierType @@ -70,7 +70,7 @@ class MetadataService( return identifierTypeRepository.save(entity).toDto() } - fun getIdentifierTypes(pageRequest: Pageable, lsaType: IdentifierLsaType, country: CountryCode? = null): PageResponse { + fun getIdentifierTypes(pageRequest: Pageable, lsaType: IdentifierLsaType, country: CountryCode? = null): PageDto { val spec = Specification.allOf( IdentifierTypeRepository.Specs.byLsaType(lsaType), IdentifierTypeRepository.Specs.byCountry(country) @@ -95,7 +95,7 @@ class MetadataService( return legalFormRepository.save(legalForm).toDto() } - fun getLegalForms(pageRequest: Pageable): PageResponse { + fun getLegalForms(pageRequest: Pageable): PageDto { val page = legalFormRepository.findAll(pageRequest) return page.toDto(page.content.map { it.toDto() }) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt index a7f0b8885..04a6eeb48 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.dto.ChangelogEntryVerboseDto import org.eclipse.tractusx.bpdm.pool.entity.PartnerChangelogEntry @@ -74,7 +74,7 @@ class PartnerChangelogService( fromTime: Instant?, pageIndex: Int, pageSize: Int - ): PageResponse { + ): PageDto { val spec = Specification.allOf(byBpnsIn(bpns), byLsaTypesIn(lsaTypes), byUpdatedGreaterThan(fromTime)) val pageRequest = PageRequest.of(pageIndex, pageSize, Sort.by(PartnerChangelogEntry::updatedAt.name).ascending()) val page = partnerChangelogEntryRepository.findAll(spec, pageRequest) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 7fb31959c..cc44f4adc 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -28,8 +28,8 @@ import org.eclipse.tractusx.bpdm.pool.entity.* import org.springframework.data.domain.Page -fun Page.toDto(dtoContent: Collection): PageResponse { - return PageResponse(this.totalElements, this.totalPages, this.number, this.numberOfElements, dtoContent) +fun Page.toDto(dtoContent: Collection): PageDto { + return PageDto(this.totalElements, this.totalPages, this.number, this.numberOfElements, dtoContent) } fun LegalEntity.toMatchDto(score: Float): LegalEntityMatchVerboseDto { diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt index 57b128d77..ec6a480af 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.service import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.common.dto.response.SiteVerboseDto import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolVerboseDto @@ -37,7 +37,7 @@ class SiteService( private val legalEntityRepository: LegalEntityRepository, private val addressService: AddressService ) { - fun findByPartnerBpn(bpn: String, pageIndex: Int, pageSize: Int): PageResponse { + fun findByPartnerBpn(bpn: String, pageIndex: Int, pageSize: Int): PageDto { if (!legalEntityRepository.existsByBpn(bpn)) { throw BpdmNotFoundException("Business Partner", bpn) } @@ -47,7 +47,7 @@ class SiteService( return page.toDto(page.content.map { it.toDto() }) } - fun findByPartnerBpns(siteSearchRequest: SiteBpnSearchRequest, paginationRequest: PaginationRequest): PageResponse { + fun findByPartnerBpns(siteSearchRequest: SiteBpnSearchRequest, paginationRequest: PaginationRequest): PageDto { val partners = if (siteSearchRequest.legalEntities.isNotEmpty()) legalEntityRepository.findDistinctByBpnIn(siteSearchRequest.legalEntities) else emptyList() val sitePage = diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt index 864dcfe3e..949a31919 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt @@ -26,7 +26,7 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest @@ -91,7 +91,7 @@ class OpenSearchControllerIT @Autowired constructor( testHelpers.truncateDbTables() openSearchSyncService.clearOpenSearch() - val importCollection = PageResponse( + val importCollection = PageDto( partnerDocs.size.toLong(), 1, 0, @@ -204,7 +204,7 @@ class OpenSearchControllerIT @Autowired constructor( } - private fun searchBusinessPartnerByName(name: String): PageResponse { + private fun searchBusinessPartnerByName(name: String): PageDto { return poolClient.legalEntities().getLegalEntities( LegalEntityPropertiesSearchRequest(name), diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt index 70147eb3d..d4dc41b39 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest @@ -101,7 +101,7 @@ class AddressControllerSearchIT @Autowired constructor( */ @Test fun `search address via name`() { - val expected = PageResponse( + val expected = PageDto( 1, 1, 0, 1, listOf( AddressMatchVerboseDto(0f, givenAddress1) ) @@ -123,7 +123,7 @@ class AddressControllerSearchIT @Autowired constructor( */ @Test fun `search address via name not found`() { - val expected = PageResponse( + val expected = PageDto( 0, 0, 0, 0, emptyList() ) @@ -137,7 +137,7 @@ class AddressControllerSearchIT @Autowired constructor( } - private fun assertPageEquals(actual: PageResponse, expected: PageResponse) { + private fun assertPageEquals(actual: PageDto, expected: PageDto) { testHelpers.assertRecursively(actual) .ignoringFieldsMatchingRegexes(".*${AddressMatchVerboseDto::score.name}") .isEqualTo(expected) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogControllerIT.kt index 5a90df1a1..4a6412af4 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogControllerIT.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.assertj.core.api.Assertions import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject @@ -99,7 +99,7 @@ class ChangelogControllerIT @Autowired constructor( ChangelogEntryResponse(bpnA2, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.ADDRESS) ) - val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + val expectedChangelog = PageDto(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) val actualChangelog = poolClient.changelogs().getChangelogEntries( ChangelogSearchRequest(), @@ -160,7 +160,7 @@ class ChangelogControllerIT @Autowired constructor( ChangelogEntryResponse(bpnMainAddress2, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.ADDRESS) ) - val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + val expectedChangelog = PageDto(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) val actualChangelog = poolClient.changelogs().getChangelogEntries( ChangelogSearchRequest(), @@ -218,7 +218,7 @@ class ChangelogControllerIT @Autowired constructor( ) - val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + val expectedChangelog = PageDto(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) val actualChangelog = poolClient.changelogs().getChangelogEntries( @@ -262,8 +262,8 @@ class ChangelogControllerIT @Autowired constructor( ChangelogEntryResponse(bpnL3, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY) ) - val expectedFirstPage = PageResponse(3, 2, 0, expectedEntriesFirstPage.size, expectedEntriesFirstPage) - val expectedSecondPage = PageResponse(3, 2, 1, expectedEntriesSecondPage.size, expectedEntriesSecondPage) + val expectedFirstPage = PageDto(3, 2, 0, expectedEntriesFirstPage.size, expectedEntriesFirstPage) + val expectedSecondPage = PageDto(3, 2, 1, expectedEntriesSecondPage.size, expectedEntriesSecondPage) val actualFirstPage = poolClient.changelogs().getChangelogEntries( @@ -320,9 +320,9 @@ class ChangelogControllerIT @Autowired constructor( ) val expectedLegalEntitiesPage = - PageResponse(expectedLegalEntityEntries.size.toLong(), 1, 0, expectedLegalEntityEntries.size, expectedLegalEntityEntries) - val expectedSitesPage = PageResponse(expectedSiteEntries.size.toLong(), 1, 0, expectedSiteEntries.size, expectedSiteEntries) - val expectedAddressesPage = PageResponse(expectedAddressEntries.size.toLong(), 1, 0, expectedAddressEntries.size, expectedAddressEntries) + PageDto(expectedLegalEntityEntries.size.toLong(), 1, 0, expectedLegalEntityEntries.size, expectedLegalEntityEntries) + val expectedSitesPage = PageDto(expectedSiteEntries.size.toLong(), 1, 0, expectedSiteEntries.size, expectedSiteEntries) + val expectedAddressesPage = PageDto(expectedAddressEntries.size.toLong(), 1, 0, expectedAddressEntries.size, expectedAddressEntries) val actualLegalEntityPage = poolClient.changelogs().getChangelogEntries( @@ -372,7 +372,7 @@ class ChangelogControllerIT @Autowired constructor( ChangelogEntryResponse(bpnL2, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY) ) - val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + val expectedChangelog = PageDto(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) val actualChangelog = poolClient.changelogs().getChangelogEntries( ChangelogSearchRequest(bpns = setOf(bpnL1, bpnL2)), @@ -417,7 +417,7 @@ class ChangelogControllerIT @Autowired constructor( ChangelogEntryResponse(bpnL2, ChangelogType.CREATE, timeAfterSecondInsert, ChangelogSubject.LEGAL_ENTITY) ) - val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + val expectedChangelog = PageDto(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) val actualChangelog = poolClient.changelogs().getChangelogEntries( ChangelogSearchRequest(fromTime = timeAfterFirstInsert, lsaTypes = setOf(ChangelogSubject.LEGAL_ENTITY)), @@ -444,15 +444,15 @@ class ChangelogControllerIT @Autowired constructor( } } - private fun checkEqual(expected: PageResponse) = - { actualResponse: PageResponse -> + private fun checkEqual(expected: PageDto) = + { actualResponse: PageDto -> testHelpers.assertRecursively(actualResponse).isEqualTo(expected) Unit } private fun validateChangelogResponse( - actual: PageResponse, - expected: PageResponse, + actual: PageDto, + expected: PageDto, timeBeforeInsert: Instant, timeAfterInsert: Instant ) { diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt index cc0393a60..fa3f93950 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityVerboseDto import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest @@ -96,7 +96,7 @@ class LegalEntityControllerSearchIT @Autowired constructor( @Test fun `search business partner with pagination, multiple items in page`() { - val expected = PageResponse( + val expected = PageDto( 2, 1, 0, 2, listOf( LegalEntityMatchVerboseDto(score = 0f, legalEntity = givenPartner1, legalName = legalName1, legalAddress = legalAddress1), @@ -117,12 +117,12 @@ class LegalEntityControllerSearchIT @Autowired constructor( @Test fun `search business partner with pagination, multiple pages`() { - val expectedFirstPage = PageResponse( + val expectedFirstPage = PageDto( 2, 2, 0, 1, listOf( LegalEntityMatchVerboseDto(score = 0f, legalEntity = givenPartner1, legalName = legalName1, legalAddress = legalAddress1) ) ) - val expectedSecondPage = PageResponse( + val expectedSecondPage = PageDto( 2, 2, 1, 1, listOf( LegalEntityMatchVerboseDto(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) ) @@ -165,7 +165,7 @@ class LegalEntityControllerSearchIT @Autowired constructor( // assertThat(foundPartners).isEmpty() // } - private fun searchBusinessPartnerBySiteName(siteName: String, page: Int, size: Int): PageResponse { + private fun searchBusinessPartnerBySiteName(siteName: String, page: Int, size: Int): PageDto { val sitePropertiesSearchRequest = SitePropertiesSearchRequest(siteName) return poolClient.legalEntities().getLegalEntities( @@ -176,7 +176,7 @@ class LegalEntityControllerSearchIT @Autowired constructor( } - private fun assertPageEquals(actual: PageResponse, expected: PageResponse) { + private fun assertPageEquals(actual: PageDto, expected: PageDto) { testHelpers.assertRecursively(actual) .ignoringFieldsMatchingRegexes(".*${LegalEntityMatchVerboseDto::score.name}") .isEqualTo(expected) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/MetadataControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/MetadataControllerIT.kt index 90bb82cd0..0e55766a2 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/MetadataControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/MetadataControllerIT.kt @@ -27,7 +27,7 @@ import org.eclipse.tractusx.bpdm.common.dto.IdentifierTypeDto import org.eclipse.tractusx.bpdm.common.dto.QualityLevel import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LegalFormDto -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PageDto import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalFormRequest @@ -55,7 +55,7 @@ import kotlin.math.ceil private typealias PostFunction = (client: WebTestClient, metaData: Any) -> Any private typealias PostFunctionWithoutExpectation = (client: WebTestClient, metaData: Any) -> WebTestClient.ResponseSpec -private typealias GetFunction = (client: WebTestClient, page: Int, size: Int) -> PageResponse +private typealias GetFunction = (client: WebTestClient, page: Int, size: Int) -> PageDto @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [Application::class, TestHelpers::class] @@ -87,7 +87,7 @@ class MetadataControllerIT @Autowired constructor( private fun postIdentifierType(client: WebTestClient, type: IdentifierTypeDto) = postMetadataSameResponseType(client, type, EndpointValues.CATENA_METADATA_IDENTIFIER_TYPE_PATH) - private fun getIdentifierTypes(client: WebTestClient, page: Int, size: Int): PageResponse = + private fun getIdentifierTypes(client: WebTestClient, page: Int, size: Int): PageDto = // getMetadata>(client, page, size, EndpointValues.CATENA_METADATA_IDENTIFIER_TYPE_PATH) client.invokeGetEndpoint( EndpointValues.CATENA_METADATA_IDENTIFIER_TYPE_PATH, @@ -102,7 +102,7 @@ class MetadataControllerIT @Autowired constructor( private fun postLegalForm(client: WebTestClient, type: LegalFormRequest) = postMetadata(client, type, EndpointValues.CATENA_METADATA_LEGAL_FORM_PATH) - private fun getLegalForms(client: WebTestClient, page: Int, size: Int): PageResponse = + private fun getLegalForms(client: WebTestClient, page: Int, size: Int): PageDto = // getMetadata>(client, page, size, EndpointValues.CATENA_METADATA_LEGAL_FORM_PATH) client.invokeGetEndpoint( EndpointValues.CATENA_METADATA_LEGAL_FORM_PATH, @@ -226,7 +226,7 @@ class MetadataControllerIT @Autowired constructor( metadata.forEach { postMetadata(webTestClient, it) } val returnedPage = getMetadataPage(webTestClient, 0, metadata.size) - val expectedPage = PageResponse(expected.size.toLong(), 1, 0, expected.size, expected) + val expectedPage = PageDto(expected.size.toLong(), 1, 0, expected.size, expected) assertThat(returnedPage).usingRecursiveComparison().ignoringCollectionOrder().isEqualTo(expectedPage) } @@ -282,7 +282,7 @@ class MetadataControllerIT @Autowired constructor( metadata.forEach { postMetadata(webTestClient, it) } val returnedPage = getMetadataPage(webTestClient, 0, metadata.size + 1) - val expectedPage = PageResponse(expected.size.toLong(), 1, 0, expected.size, expected) + val expectedPage = PageDto(expected.size.toLong(), 1, 0, expected.size, expected) assertThat(returnedPage).usingRecursiveComparison().ignoringCollectionOrder().isEqualTo(expectedPage) } @@ -298,7 +298,7 @@ class MetadataControllerIT @Autowired constructor( metadata.forEach { postMetadata(webTestClient, it) } val returnedPage = getMetadataPage(webTestClient, metadata.size, 1) - val expectedPage = PageResponse(expected.size.toLong(), expected.size, expected.size, 0, emptyList()) + val expectedPage = PageDto(expected.size.toLong(), expected.size, expected.size, 0, emptyList()) assertThat(returnedPage).usingRecursiveComparison().ignoringCollectionOrder().isEqualTo(expectedPage) } @@ -340,7 +340,7 @@ class MetadataControllerIT @Autowired constructor( identifierType3.toDto() ) - val result = webTestClient.invokeGetEndpoint>( + val result = webTestClient.invokeGetEndpoint>( EndpointValues.CATENA_METADATA_IDENTIFIER_TYPE_PATH, Pair("lsaType", IdentifierLsaType.LEGAL_ENTITY.name), Pair("country", CountryCode.PL.alpha2)