From 3ecd495e75b083dd7ab0e337d7546655983bc2da Mon Sep 17 00:00:00 2001 From: alexsilva Date: Thu, 16 Mar 2023 12:07:18 +0000 Subject: [PATCH 01/16] feat(Gate): Creating ChangelogController objects and entity --- bpdm-gate/flyway.conf | 4 ++ bpdm-gate/pom.xml | 27 +++++++++ .../gate/controller/ChangelogController.kt | 60 +++++++++++++++++++ .../tractusx/bpdm/gate/dto/ChangelogDto.kt | 28 +++++++++ .../tractusx/bpdm/gate/entity/BaseEntity.kt | 47 +++++++++++++++ .../bpdm/gate/entity/ChangelogEntity.kt | 39 ++++++++++++ .../bpdm/gate/service/ChangelogService.kt | 41 +++++++++++++ .../src/main/resources/application.properties | 15 +++++ 8 files changed, 261 insertions(+) create mode 100644 bpdm-gate/flyway.conf create mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt create mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/ChangelogDto.kt create mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt create mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt create mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt diff --git a/bpdm-gate/flyway.conf b/bpdm-gate/flyway.conf new file mode 100644 index 000000000..45496bc9c --- /dev/null +++ b/bpdm-gate/flyway.conf @@ -0,0 +1,4 @@ +flyway.url=jdbc:postgresql://localhost:5432/bpdm +flyway.user=bpdm +flyway.password=${BPDM_DB_PASS} +flyway.schemas=bpdm-gate \ No newline at end of file diff --git a/bpdm-gate/pom.xml b/bpdm-gate/pom.xml index 14bbbf1ed..8d76add59 100644 --- a/bpdm-gate/pom.xml +++ b/bpdm-gate/pom.xml @@ -34,6 +34,11 @@ 4.0.0-SNAPSHOT + + 42.5.1 + 8.5.12 + + ${project.groupId} @@ -92,6 +97,23 @@ org.springdoc springdoc-openapi-starter-common + + org.postgresql + postgresql + ${postgres.version} + runtime + + + + org.flywaydb + flyway-core + ${flyway.version} + + + org.springframework.boot + spring-boot-starter-data-jpa + + io.github.microutils kotlin-logging-jvm @@ -161,6 +183,11 @@ org.jetbrains.kotlin kotlin-maven-plugin + + org.flywaydb + flyway-maven-plugin + ${flyway.version} + diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt new file mode 100644 index 000000000..83e5cc50b --- /dev/null +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.controller + +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.Parameter +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.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.service.ChangelogService +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam +import java.time.Instant + + +@RequestMapping("/api/catena/business-partners/changelog") +class ChangelogController ( + private val changelogService: ChangelogService + ) { + + @Operation( + summary = "Get business partner changelog entries by list external id, from timestamp or LSA type", + description = "Get business partner changelog entries by list external id, from timestamp or LSA type" + ) + @ApiResponses( + value = [ + ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), + ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), + ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) + ] + ) + @GetMapping + fun getChangelogEntries( + @RequestBody externalIds: Collection, + @Parameter(description = "From Time") @RequestParam fromTime: Instant, + @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType + ) { + return changelogService.getChangeLog() + } +} \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/ChangelogDto.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/ChangelogDto.kt new file mode 100644 index 000000000..01036f22a --- /dev/null +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/ChangelogDto.kt @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.dto + +import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType + + +data class ChangelogDto( + val externalId: String, + val lsaType: LsaType +) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt new file mode 100644 index 000000000..49e764bfa --- /dev/null +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.entity + +import jakarta.persistence.* +import org.hibernate.annotations.CreationTimestamp +import org.hibernate.annotations.UpdateTimestamp +import java.time.Instant +import java.time.temporal.ChronoUnit +import java.util.* + +@MappedSuperclass +abstract class BaseEntity( + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bpdm_sequence") + @SequenceGenerator(name = "bpdm_sequence", sequenceName = "bpdm_sequence", allocationSize = 1) + @Column(name = "id", nullable = false, updatable = false, insertable = false) + val id: Long = 0, + + @Column(name = "uuid", nullable = false, updatable = false, unique = true, columnDefinition = "uuid") + val uuid: UUID = UUID.randomUUID(), + + @Column(updatable = false, nullable = false, name = "CREATED_AT") + @CreationTimestamp + val createdAt: Instant = Instant.now().truncatedTo(ChronoUnit.MICROS), + + @Column(nullable = false, name = "UPDATED_AT") + @UpdateTimestamp + val updatedAt: Instant = Instant.now().truncatedTo(ChronoUnit.MICROS) +) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt new file mode 100644 index 000000000..072325199 --- /dev/null +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.entity + +import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType + + +@Entity +@Table(name = "changelog_entries") +class ChangelogEntity ( + + @Column(name = "externalId", nullable = false, updatable = false) + val externalId: String, + @Enumerated(EnumType.STRING) + @Column(name = "lsa_type", nullable = false, updatable = false) + val lsaType: LsaType + +) : BaseEntity() + + + diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt new file mode 100644 index 000000000..0e12f2619 --- /dev/null +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.service + +import mu.KotlinLogging +import org.eclipse.tractusx.bpdm.gate.dto.ChangelogDto +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional + +@Service +class ChangelogService { + private val logger = KotlinLogging.logger { } + + @Transactional + fun createChangelog(changelogDto: ChangelogDto) { + + } + + + fun getChangeLog() { + + } + +} \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/application.properties b/bpdm-gate/src/main/resources/application.properties index 5a0ac1b74..bb995e44e 100644 --- a/bpdm-gate/src/main/resources/application.properties +++ b/bpdm-gate/src/main/resources/application.properties @@ -58,6 +58,21 @@ bpdm.gate-security.pool-security-enabled=false bpdm.pool.base-url=http://localhost:8080/api/catena #No security on default bpdm.security.enabled=false +#Datasource configuration +bpdm.datasource.host=localhost +spring.datasource.url=jdbc:postgresql://${bpdm.datasource.host}:5432/bpdm +spring.datasource.driverClassName=org.postgresql.Driver +spring.datasource.username=bpdm +spring.datasource.password= +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.properties.hibernate.default_schema=bpdm-gate +#Send updates and inserts out in batches to decrease network connections to the database +spring.jpa.properties.hibernate.jdbc.batch_size=16 +spring.jpa.properties.hibernate.order_updates=true +spring.jpa.properties.hibernate.order_inserts=true +#Flyway configuration +spring.flyway.enabled=true +spring.flyway.schemas=bpdm-gate From 55a85fa813ee6c2cc24692350c7aea87c2057811 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 16 Mar 2023 16:01:25 +0000 Subject: [PATCH 02/16] feat(Gate): Adding Service and repository for changelog entity --- .../gate/controller/ChangelogController.kt | 8 ++--- .../gate/repository/ChangelogRepository.kt | 30 +++++++++++++++++++ .../bpdm/gate/service/ChangelogService.kt | 11 +++++-- 3 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 83e5cc50b..18a74657e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -51,10 +51,10 @@ class ChangelogController ( ) @GetMapping fun getChangelogEntries( - @RequestBody externalIds: Collection, - @Parameter(description = "From Time") @RequestParam fromTime: Instant, - @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType + @RequestBody externalIds: Collection?, + @Parameter(description = "From Time") @RequestParam fromTime: Instant?, + @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType? ) { - return changelogService.getChangeLog() + return changelogService.getChangeLog(externalIds,fromTime,lsaType) } } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt new file mode 100644 index 000000000..22b19e658 --- /dev/null +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.repository + +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.springframework.data.jpa.repository.JpaRepository + +interface ChangelogRepository : JpaRepository { + + fun findAllByExternalIdIn(externalIds: Collection): List + + +} \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 0e12f2619..40d29ade3 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -21,11 +21,14 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.gate.dto.ChangelogDto +import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional +import java.time.Instant @Service -class ChangelogService { +class ChangelogService (private val changelogRepository: ChangelogRepository) { private val logger = KotlinLogging.logger { } @Transactional @@ -34,8 +37,10 @@ class ChangelogService { } - fun getChangeLog() { - + fun getChangeLog(externalIds: Collection?, fromTime: Instant?, lsaType: LsaType?) { + if(fromTime == null && lsaType == null && externalIds!!.isEmpty() ){ + changelogRepository.findAllByExternalIdIn(externalIds!!) + } } } \ No newline at end of file From 7e9bab9cdf1476edd2809973346d937364d2239e Mon Sep 17 00:00:00 2001 From: alexsilva Date: Thu, 16 Mar 2023 16:39:25 +0000 Subject: [PATCH 03/16] feat(gate): added flyway changelog table creation --- .../db/migration/V0_0_1_0__create_changelog_table.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql diff --git a/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql b/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql new file mode 100644 index 000000000..f75516bcd --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql @@ -0,0 +1,10 @@ +CREATE SEQUENCE IF NOT EXISTS bpdm_gate_sequence START WITH 1 INCREMENT BY 1; + +CREATE TABLE changelog +( + id BIGINT NOT NULL, + updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL, + businessPartner_type VARCHAR(255) NOT NULL, + CONSTRAINT pk_changelog PRIMARY KEY (id) +); + From 012d93de2bd64e23128ccd5a5a354f5fef15bc83 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Thu, 16 Mar 2023 17:00:22 +0000 Subject: [PATCH 04/16] feat(Gate): Creating ChangelogController objects and entity --- .../bpdm/gate/controller/ChangelogController.kt | 8 ++++---- .../bpdm/gate/repository/ChangelogRepository.kt | 12 ++++++++---- .../tractusx/bpdm/gate/service/ChangelogService.kt | 11 +++-------- bpdm-gate/src/main/resources/application.properties | 2 +- .../migration/V0_0_1_0__create_changelog_table.sql | 6 ++++-- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 18a74657e..83e5cc50b 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -51,10 +51,10 @@ class ChangelogController ( ) @GetMapping fun getChangelogEntries( - @RequestBody externalIds: Collection?, - @Parameter(description = "From Time") @RequestParam fromTime: Instant?, - @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType? + @RequestBody externalIds: Collection, + @Parameter(description = "From Time") @RequestParam fromTime: Instant, + @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType ) { - return changelogService.getChangeLog(externalIds,fromTime,lsaType) + return changelogService.getChangeLog() } } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index 22b19e658..65b77ed67 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -21,10 +21,14 @@ package org.eclipse.tractusx.bpdm.gate.repository import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.springframework.data.jpa.repository.JpaRepository +import java.time.Instant -interface ChangelogRepository : JpaRepository { - - fun findAllByExternalIdIn(externalIds: Collection): List +interface ChangelogRepository : JpaRepository { -} \ No newline at end of file + fun findAllByExternalIdInAndBusinessPartnerTypeAndCreatedAtGreaterThanEqual( + externalIds: Collection, + businessPartnerType: String?, + createdAt: Instant? + ): List +} diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 40d29ade3..0e12f2619 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -21,14 +21,11 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.gate.dto.ChangelogDto -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType -import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional -import java.time.Instant @Service -class ChangelogService (private val changelogRepository: ChangelogRepository) { +class ChangelogService { private val logger = KotlinLogging.logger { } @Transactional @@ -37,10 +34,8 @@ class ChangelogService (private val changelogRepository: ChangelogRepository) { } - fun getChangeLog(externalIds: Collection?, fromTime: Instant?, lsaType: LsaType?) { - if(fromTime == null && lsaType == null && externalIds!!.isEmpty() ){ - changelogRepository.findAllByExternalIdIn(externalIds!!) - } + fun getChangeLog() { + } } \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/application.properties b/bpdm-gate/src/main/resources/application.properties index bb995e44e..0964d386d 100644 --- a/bpdm-gate/src/main/resources/application.properties +++ b/bpdm-gate/src/main/resources/application.properties @@ -20,7 +20,7 @@ bpdm.name=@project.name@ bpdm.description=@project.description@ bpdm.version=@project.version@ #Change default port since 8080 is reserved for pool -server.port=8081 +server.port=8082 #Logging Configuration bpdm.logging.unknown-user=Anonymous #Configuration specific to the service logic diff --git a/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql b/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql index f75516bcd..d40f71731 100644 --- a/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql +++ b/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql @@ -1,10 +1,12 @@ CREATE SEQUENCE IF NOT EXISTS bpdm_gate_sequence START WITH 1 INCREMENT BY 1; -CREATE TABLE changelog +CREATE TABLE changelog_entries ( id BIGINT NOT NULL, + external_id VARCHAR(255) NOT NULL, + created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL, - businessPartner_type VARCHAR(255) NOT NULL, + business_partner_type VARCHAR(255) NOT NULL, CONSTRAINT pk_changelog PRIMARY KEY (id) ); From 8abc1af3cb1afbc4e4b7d244a354ec560b5347e9 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 16 Mar 2023 16:01:25 +0000 Subject: [PATCH 05/16] feat(Gate): Adding Service and repository for changelog entity --- .../bpdm/gate/controller/ChangelogController.kt | 8 ++++---- .../bpdm/gate/repository/ChangelogRepository.kt | 12 ++++-------- .../tractusx/bpdm/gate/service/ChangelogService.kt | 11 ++++++++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 83e5cc50b..18a74657e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -51,10 +51,10 @@ class ChangelogController ( ) @GetMapping fun getChangelogEntries( - @RequestBody externalIds: Collection, - @Parameter(description = "From Time") @RequestParam fromTime: Instant, - @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType + @RequestBody externalIds: Collection?, + @Parameter(description = "From Time") @RequestParam fromTime: Instant?, + @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType? ) { - return changelogService.getChangeLog() + return changelogService.getChangeLog(externalIds,fromTime,lsaType) } } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index 65b77ed67..22b19e658 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -21,14 +21,10 @@ package org.eclipse.tractusx.bpdm.gate.repository import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.springframework.data.jpa.repository.JpaRepository -import java.time.Instant - interface ChangelogRepository : JpaRepository { - fun findAllByExternalIdInAndBusinessPartnerTypeAndCreatedAtGreaterThanEqual( - externalIds: Collection, - businessPartnerType: String?, - createdAt: Instant? - ): List -} + fun findAllByExternalIdIn(externalIds: Collection): List + + +} \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 0e12f2619..40d29ade3 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -21,11 +21,14 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.gate.dto.ChangelogDto +import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional +import java.time.Instant @Service -class ChangelogService { +class ChangelogService (private val changelogRepository: ChangelogRepository) { private val logger = KotlinLogging.logger { } @Transactional @@ -34,8 +37,10 @@ class ChangelogService { } - fun getChangeLog() { - + fun getChangeLog(externalIds: Collection?, fromTime: Instant?, lsaType: LsaType?) { + if(fromTime == null && lsaType == null && externalIds!!.isEmpty() ){ + changelogRepository.findAllByExternalIdIn(externalIds!!) + } } } \ No newline at end of file From 5b7bc53833bcb42a69a0afe04a1f83ede2666869 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Thu, 16 Mar 2023 16:39:25 +0000 Subject: [PATCH 06/16] feat(gate): added flyway changelog table creation --- .../gate/controller/ChangelogController.kt | 23 +++++++++++-------- .../tractusx/bpdm/gate/entity/BaseEntity.kt | 4 ++-- .../bpdm/gate/entity/ChangelogEntity.kt | 6 ++--- .../gate/repository/ChangelogRepository.kt | 12 ++++++---- .../bpdm/gate/service/ChangelogService.kt | 18 +++++++++------ .../V0_0_1_0__create_changelog_table.sql | 7 ++++-- 6 files changed, 43 insertions(+), 27 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 18a74657e..9d667679c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -25,14 +25,12 @@ 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.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.service.ChangelogService -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.* import java.time.Instant - +@RestController @RequestMapping("/api/catena/business-partners/changelog") class ChangelogController ( private val changelogService: ChangelogService @@ -49,12 +47,19 @@ class ChangelogController ( ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) ] ) - @GetMapping + @PostMapping("/search") fun getChangelogEntries( - @RequestBody externalIds: Collection?, @Parameter(description = "From Time") @RequestParam fromTime: Instant?, - @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType? + @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType?, + @RequestBody externalIds: Collection? = emptyList() + ): List { + return changelogService.getChangeLog(externalIds!!,lsaType, fromTime) + } + + @PostMapping + fun createChangelogEntries( + @Parameter(description = "externalId") @RequestParam externalId: String ) { - return changelogService.getChangeLog(externalIds,fromTime,lsaType) + return changelogService.createChangelog(externalId) } } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt index 49e764bfa..4ae28339e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt @@ -29,8 +29,8 @@ import java.util.* @MappedSuperclass abstract class BaseEntity( @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bpdm_sequence") - @SequenceGenerator(name = "bpdm_sequence", sequenceName = "bpdm_sequence", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bpdm_gate_sequence") + @SequenceGenerator(name = "bpdm_gate_sequence", sequenceName = "bpdm_gate_sequence", allocationSize = 1) @Column(name = "id", nullable = false, updatable = false, insertable = false) val id: Long = 0, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt index 072325199..ad06194de 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt @@ -27,11 +27,11 @@ import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType @Table(name = "changelog_entries") class ChangelogEntity ( - @Column(name = "externalId", nullable = false, updatable = false) + @Column(name = "external_id", nullable = false, updatable = false) val externalId: String, @Enumerated(EnumType.STRING) - @Column(name = "lsa_type", nullable = false, updatable = false) - val lsaType: LsaType + @Column(name = "business_partner_type", nullable = false, updatable = false) + val businessPartnerType: LsaType ) : BaseEntity() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index 22b19e658..65b77ed67 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -21,10 +21,14 @@ package org.eclipse.tractusx.bpdm.gate.repository import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.springframework.data.jpa.repository.JpaRepository +import java.time.Instant -interface ChangelogRepository : JpaRepository { - - fun findAllByExternalIdIn(externalIds: Collection): List +interface ChangelogRepository : JpaRepository { -} \ No newline at end of file + fun findAllByExternalIdInAndBusinessPartnerTypeAndCreatedAtGreaterThanEqual( + externalIds: Collection, + businessPartnerType: String?, + createdAt: Instant? + ): List +} diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 40d29ade3..5affd0efb 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -20,8 +20,8 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.gate.dto.ChangelogDto import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -32,15 +32,19 @@ class ChangelogService (private val changelogRepository: ChangelogRepository) { private val logger = KotlinLogging.logger { } @Transactional - fun createChangelog(changelogDto: ChangelogDto) { - + fun createChangelog(externalId: String) { + val changelogEntity = ChangelogEntity(externalId,LsaType.Address) + changelogRepository.save(changelogEntity) } - fun getChangeLog(externalIds: Collection?, fromTime: Instant?, lsaType: LsaType?) { - if(fromTime == null && lsaType == null && externalIds!!.isEmpty() ){ - changelogRepository.findAllByExternalIdIn(externalIds!!) - } + fun getChangeLog(externalIds: Collection, lsaType: LsaType?, fromTime: Instant?): List { + return changelogRepository.findAllByExternalIdInAndBusinessPartnerTypeAndCreatedAtGreaterThanEqual( + externalIds = externalIds, + businessPartnerType = lsaType.toString(), + createdAt = fromTime + ) } + } \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql b/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql index d40f71731..54fe89271 100644 --- a/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql +++ b/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql @@ -3,10 +3,13 @@ CREATE SEQUENCE IF NOT EXISTS bpdm_gate_sequence START WITH 1 INCREMENT BY 1; CREATE TABLE changelog_entries ( id BIGINT NOT NULL, - external_id VARCHAR(255) NOT NULL, + uuid UUID NOT NULL, + external_id VARCHAR(255) NOT NULL, created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP WITHOUT TIME ZONE NOT NULL, - business_partner_type VARCHAR(255) NOT NULL, + business_partner_type VARCHAR(255) NOT NULL, CONSTRAINT pk_changelog PRIMARY KEY (id) ); +ALTER TABLE changelog_entries + ADD CONSTRAINT uc_changelog_entries_uuid UNIQUE (uuid); \ No newline at end of file From 806656d76f55b315f746244f64234afa3491ac70 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Fri, 17 Mar 2023 14:38:10 +0000 Subject: [PATCH 07/16] fix(gate): added pagination in the changelog controller. Moved BaseEntity to common module --- bpdm-common/pom.xml | 5 +++ .../tractusx/bpdm/common/model}/BaseEntity.kt | 2 +- .../gate/controller/ChangelogController.kt | 9 ++++- .../gate/dto/request/PaginationRequest.kt | 40 +++++++++++++++++++ .../bpdm/gate/entity/ChangelogEntity.kt | 1 + .../gate/repository/ChangelogRepository.kt | 7 +++- .../bpdm/gate/service/ChangelogService.kt | 8 +++- 7 files changed, 65 insertions(+), 7 deletions(-) rename {bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity => bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model}/BaseEntity.kt (97%) create mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationRequest.kt diff --git a/bpdm-common/pom.xml b/bpdm-common/pom.xml index d3e5bafeb..f4fe973c2 100644 --- a/bpdm-common/pom.xml +++ b/bpdm-common/pom.xml @@ -77,6 +77,11 @@ jackson-module-kotlin + + org.springframework.boot + spring-boot-starter-data-jpa + + org.springframework.boot spring-boot-starter-test diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/BaseEntity.kt similarity index 97% rename from bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt rename to bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/BaseEntity.kt index 4ae28339e..aa0328a87 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/BaseEntity.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/BaseEntity.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.entity +package org.eclipse.tractusx.bpdm.common.model import jakarta.persistence.* import org.hibernate.annotations.CreationTimestamp diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 9d667679c..a645cd0a2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -24,9 +24,13 @@ import io.swagger.v3.oas.annotations.Parameter 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 jakarta.validation.Valid +import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.service.ChangelogService +import org.springdoc.core.annotations.ParameterObject +import org.springframework.data.domain.Page import org.springframework.web.bind.annotation.* import java.time.Instant @@ -49,11 +53,12 @@ class ChangelogController ( ) @PostMapping("/search") fun getChangelogEntries( + @ParameterObject @Valid paginationRequest: PaginationRequest, @Parameter(description = "From Time") @RequestParam fromTime: Instant?, @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType?, @RequestBody externalIds: Collection? = emptyList() - ): List { - return changelogService.getChangeLog(externalIds!!,lsaType, fromTime) + ): Page { + return changelogService.getChangeLog(externalIds!!,lsaType, fromTime, paginationRequest.page, paginationRequest.size) } @PostMapping diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationRequest.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationRequest.kt new file mode 100644 index 000000000..ceef2d2ae --- /dev/null +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationRequest.kt @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.dto.request + +import io.swagger.v3.oas.annotations.Parameter +import io.swagger.v3.oas.annotations.media.Schema +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.PositiveOrZero + +@Schema(name = "PaginationRequest", description = "Defines pagination information for requesting collection results") +data class PaginationRequest ( + @field:Parameter( + description = "Number of page to get results from", schema = + Schema(defaultValue = "0")) + @field:PositiveOrZero + val page: Int=0, + @field:Parameter(description = "Size of each page", schema = + Schema(defaultValue = "10")) + @field:Min(0) + @field:Max(100) + val size: Int=10 +) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt index ad06194de..1738c2b48 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index 65b77ed67..f1cb6f285 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -20,6 +20,8 @@ package org.eclipse.tractusx.bpdm.gate.repository import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.springframework.data.domain.Page +import org.springframework.data.domain.Pageable import org.springframework.data.jpa.repository.JpaRepository import java.time.Instant @@ -29,6 +31,7 @@ interface ChangelogRepository : JpaRepository { fun findAllByExternalIdInAndBusinessPartnerTypeAndCreatedAtGreaterThanEqual( externalIds: Collection, businessPartnerType: String?, - createdAt: Instant? - ): List + createdAt: Instant?, + pageable: Pageable + ): Page } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 5affd0efb..c431d09b3 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -23,6 +23,8 @@ import mu.KotlinLogging import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository +import org.springframework.data.domain.Page +import org.springframework.data.domain.PageRequest import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import java.time.Instant @@ -38,11 +40,13 @@ class ChangelogService (private val changelogRepository: ChangelogRepository) { } - fun getChangeLog(externalIds: Collection, lsaType: LsaType?, fromTime: Instant?): List { + fun getChangeLog(externalIds: Collection, lsaType: LsaType?, fromTime: Instant?, page: Int, pageSize: Int ): Page { + return changelogRepository.findAllByExternalIdInAndBusinessPartnerTypeAndCreatedAtGreaterThanEqual( externalIds = externalIds, businessPartnerType = lsaType.toString(), - createdAt = fromTime + createdAt = fromTime, + pageable = PageRequest.of(page, pageSize) ) } From 644eee930ba7cea8b5fe247b4fb984a3f5ff1ac0 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 17 Mar 2023 15:18:01 +0000 Subject: [PATCH 08/16] fix/feat(gate): added two new apis (ExternalID and fromTime / LSAType and fromTime), renamed sequence generator on BaseEntity to match both schemas. Moved BaseEntity from pool to common module feat(Gate): Add new code for repo and response dto and logic --- .../common}/dto/request/PaginationRequest.kt | 2 +- .../tractusx/bpdm/common/model/BaseEntity.kt | 23 ++++++++- .../gate/controller/ChangelogController.kt | 38 +++++++++++---- .../request/PaginationStartAfterRequest.kt | 2 +- .../dto/response/PageChangeLogResponse.kt | 36 +++++++------- .../bpdm/gate/exception/GateErrorCodes.kt | 5 ++ .../gate/repository/ChangelogRepository.kt | 11 ++++- .../bpdm/gate/service/ChangelogService.kt | 42 +++++++++++++++-- .../V0_0_1_0__create_changelog_table.sql | 2 +- .../tractusx/bpdm/pool/api/PoolAddressApi.kt | 3 ++ .../bpdm/pool/api/PoolBusinessPartnerApi.kt | 2 +- .../bpdm/pool/api/PoolLegalEntityApi.kt | 1 + .../tractusx/bpdm/pool/api/PoolMetadataApi.kt | 2 +- .../tractusx/bpdm/pool/api/PoolSaasApi.kt | 2 +- .../tractusx/bpdm/pool/api/PoolSiteApi.kt | 2 +- .../bpdm/pool/api/PoolSuggestionApi.kt | 2 +- .../component/opensearch/SearchService.kt | 3 +- .../impl/service/SearchServiceImpl.kt | 2 +- .../mock/service/SearchServiceMock.kt | 2 +- .../saas/controller/SaasController.kt | 2 +- .../saas/service/ImportStarterService.kt | 2 +- .../bpdm/pool/controller/AddressController.kt | 3 +- .../controller/BusinessPartnerController.kt | 2 +- .../BusinessPartnerLegacyController.kt | 6 ++- .../pool/controller/LegalEntityController.kt | 1 + .../pool/controller/MetadataController.kt | 2 +- .../bpdm/pool/controller/SiteController.kt | 2 +- .../pool/controller/SuggestionController.kt | 6 ++- .../tractusx/bpdm/pool/entity/Address.kt | 1 + .../bpdm/pool/entity/AddressPartner.kt | 1 + .../bpdm/pool/entity/AdministrativeArea.kt | 1 + .../tractusx/bpdm/pool/entity/BankAccount.kt | 1 + .../tractusx/bpdm/pool/entity/BaseEntity.kt | 47 ------------------- .../bpdm/pool/entity/BaseNamedEntity.kt | 1 + .../bpdm/pool/entity/BusinessStatus.kt | 1 + .../bpdm/pool/entity/Classification.kt | 1 + .../bpdm/pool/entity/ConfigurationEntry.kt | 1 + .../bpdm/pool/entity/CountryIdentifierType.kt | 1 + .../tractusx/bpdm/pool/entity/Identifier.kt | 1 + .../bpdm/pool/entity/IdentifierStatus.kt | 1 + .../bpdm/pool/entity/IdentifierType.kt | 1 + .../tractusx/bpdm/pool/entity/ImportEntry.kt | 1 + .../tractusx/bpdm/pool/entity/IssuingBody.kt | 1 + .../tractusx/bpdm/pool/entity/LegalEntity.kt | 1 + .../tractusx/bpdm/pool/entity/LegalForm.kt | 1 + .../bpdm/pool/entity/LegalFormCategory.kt | 1 + .../tractusx/bpdm/pool/entity/Locality.kt | 1 + .../eclipse/tractusx/bpdm/pool/entity/Name.kt | 1 + .../bpdm/pool/entity/PartnerChangelogEntry.kt | 1 + .../tractusx/bpdm/pool/entity/PostCode.kt | 1 + .../bpdm/pool/entity/PostalDeliveryPoint.kt | 1 + .../tractusx/bpdm/pool/entity/Premise.kt | 1 + .../tractusx/bpdm/pool/entity/Relation.kt | 1 + .../eclipse/tractusx/bpdm/pool/entity/Role.kt | 1 + .../eclipse/tractusx/bpdm/pool/entity/Site.kt | 1 + .../tractusx/bpdm/pool/entity/SyncRecord.kt | 1 + .../tractusx/bpdm/pool/entity/Thoroughfare.kt | 1 + .../bpdm/pool/service/AddressService.kt | 2 +- .../tractusx/bpdm/pool/service/SiteService.kt | 2 +- .../opensearch/InvalidIndexStartupIT.kt | 6 +-- .../opensearch/ValidIndexStartupIT.kt | 3 +- .../controller/OpenSearchControllerIT.kt | 2 +- .../saas/controller/SaasControllerImportIT.kt | 6 ++- .../pool/controller/AddressControllerIT.kt | 7 +-- .../controller/AddressControllerSearchIT.kt | 2 +- .../LegalEntityControllerSearchIT.kt | 5 +- .../pool/controller/MetadataControllerIT.kt | 2 +- .../bpdm/pool/controller/SiteControllerIT.kt | 3 +- .../tractusx/bpdm/pool/util/TestHelpers.kt | 1 + 69 files changed, 205 insertions(+), 119 deletions(-) rename {bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate => bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common}/dto/request/PaginationRequest.kt (96%) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/PaginationRequest.kt => bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt (51%) delete mode 100644 bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BaseEntity.kt diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationRequest.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/request/PaginationRequest.kt similarity index 96% rename from bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationRequest.kt rename to bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/request/PaginationRequest.kt index ceef2d2ae..2d28e34aa 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationRequest.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/request/PaginationRequest.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto.request +package org.eclipse.tractusx.bpdm.common.dto.request import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.media.Schema diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/BaseEntity.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/BaseEntity.kt index aa0328a87..c42e1c8c9 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/BaseEntity.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/BaseEntity.kt @@ -17,6 +17,25 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + package org.eclipse.tractusx.bpdm.common.model import jakarta.persistence.* @@ -29,8 +48,8 @@ import java.util.* @MappedSuperclass abstract class BaseEntity( @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bpdm_gate_sequence") - @SequenceGenerator(name = "bpdm_gate_sequence", sequenceName = "bpdm_gate_sequence", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bpdm_sequence") + @SequenceGenerator(name = "bpdm_sequence", sequenceName = "bpdm_sequence", allocationSize = 1) @Column(name = "id", nullable = false, updatable = false, insertable = false) val id: Long = 0, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index a645cd0a2..140ea6ab0 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -25,12 +25,13 @@ 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 jakarta.validation.Valid -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.service.ChangelogService import org.springdoc.core.annotations.ParameterObject -import org.springframework.data.domain.Page import org.springframework.web.bind.annotation.* import java.time.Instant @@ -41,8 +42,8 @@ class ChangelogController ( ) { @Operation( - summary = "Get business partner changelog entries by list external id, from timestamp or LSA type", - description = "Get business partner changelog entries by list external id, from timestamp or LSA type" + summary = "Get business partner changelog entries by list external id, from timestamp", + description = "Get business partner changelog entries by list external id, from timestamp" ) @ApiResponses( value = [ @@ -52,13 +53,32 @@ class ChangelogController ( ] ) @PostMapping("/search") - fun getChangelogEntries( + fun getChangelogEntriesExternalId( @ParameterObject @Valid paginationRequest: PaginationRequest, - @Parameter(description = "From Time") @RequestParam fromTime: Instant?, - @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType?, + @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam fromTime: Instant? , @RequestBody externalIds: Collection? = emptyList() - ): Page { - return changelogService.getChangeLog(externalIds!!,lsaType, fromTime, paginationRequest.page, paginationRequest.size) + ): PageChangeLogResponse { + return changelogService.getChangeLogByExternalId(externalIds!!,fromTime,paginationRequest.page,paginationRequest.size) + } + + @Operation( + summary = "Get business partner changelog entries by timestamp or LSA type", + description = "Get business partner changelog entries by from timestamp or LSA type" + ) + @ApiResponses( + value = [ + ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), + ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), + ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) + ] + ) + @PostMapping("/filter") + fun getChangelogEntriesLsaType( + @ParameterObject @Valid paginationRequest: PaginationRequest, + @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam fromTime: Instant?, + @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType? + ): PageResponse { + return changelogService.getChangeLogByLsaType(lsaType,fromTime,paginationRequest.page,paginationRequest.size) } @PostMapping diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt index c1fdd4742..d71ef6462 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt @@ -30,7 +30,7 @@ data class PaginationStartAfterRequest( description = "Value used to indicate which page to retrieve. When this value is not provided, the first page is returned." + "The nextStartAfter value from the response can then be used to request subsequent pages." ) - val startAfter: String?, + val startAfter: String? = "0", @field:Parameter( description = "Size of each page", schema = Schema(defaultValue = "10") diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/PaginationRequest.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt similarity index 51% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/PaginationRequest.kt rename to bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt index 71f506b5e..2fd90d84f 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/PaginationRequest.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt @@ -17,24 +17,26 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.pool.api.model.request +package org.eclipse.tractusx.bpdm.gate.dto.response -import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.media.Schema -import jakarta.validation.constraints.Max -import jakarta.validation.constraints.Min -import jakarta.validation.constraints.PositiveOrZero +import org.eclipse.tractusx.bpdm.gate.exception.ChangeLogOutputError -@Schema(name = "PaginationRequest", description = "Defines pagination information for requesting collection results") -data class PaginationRequest ( - @field:Parameter( - description = "Number of page to get results from", schema = - Schema(defaultValue = "0")) - @field:PositiveOrZero - val page: Int=0, - @field:Parameter(description = "Size of each page", schema = - Schema(defaultValue = "10")) - @field:Min(0) - @field:Max(100) - val size: Int=10 +@Schema(description = "Paginated collection of results") +data class PageChangeLogResponse( + @Schema(description = "Total number of all results in all pages") + val totalElements: Long, + @Schema(description = "Total number pages") + val totalPages: Int, + @Schema(description = "Current page number") + val page: Int, + @Schema(description = "Number of results in the page") + val contentSize: Int, + @Schema(description = "Collection of results in the page") + val content: Collection, + @Schema(description = "Number of entries in the page that have been omitted due to being invalid (error or still pending)") + val invalidEntries: Int, + @Schema(description = "Infos about the entries with errors") + val errors: Collection>, ) + diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt index 677a4db7b..dcebbabee 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt @@ -33,3 +33,8 @@ enum class BusinessPartnerOutputError : ErrorCode { SharingTimeout, BpnNotInPool } + +@Schema(description = "ChangeLogOutputError") +enum class ChangeLogOutputError : ErrorCode { + ExternalIdNotFound, +} diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index f1cb6f285..dcf023960 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.repository +import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable @@ -28,10 +29,16 @@ import java.time.Instant interface ChangelogRepository : JpaRepository { - fun findAllByExternalIdInAndBusinessPartnerTypeAndCreatedAtGreaterThanEqual( + fun findAllByExternalIdInAndCreatedAtGreaterThanEqual( externalIds: Collection, - businessPartnerType: String?, createdAt: Instant?, pageable: Pageable ): Page + + fun findAllByBusinessPartnerTypeAndCreatedAtGreaterThanEqual( + businessPartnerType: LsaType?, + createdAt: Instant?, + pageable: Pageable + ): Page + } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index c431d09b3..a38d917e1 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -20,10 +20,13 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging +import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository -import org.springframework.data.domain.Page import org.springframework.data.domain.PageRequest import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -39,16 +42,47 @@ class ChangelogService (private val changelogRepository: ChangelogRepository) { changelogRepository.save(changelogEntity) } + fun getChangeLogByExternalId(externalIds: Collection, fromTime: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { - fun getChangeLog(externalIds: Collection, lsaType: LsaType?, fromTime: Instant?, page: Int, pageSize: Int ): Page { - return changelogRepository.findAllByExternalIdInAndBusinessPartnerTypeAndCreatedAtGreaterThanEqual( + val pageResponse = changelogRepository.findAllByExternalIdInAndCreatedAtGreaterThanEqual( externalIds = externalIds, - businessPartnerType = lsaType.toString(), createdAt = fromTime, pageable = PageRequest.of(page, pageSize) ) + + val errorInfoList = externalIds.filterNot { id -> + pageResponse.content.any { it.externalId == id } + }.map { + ErrorInfo( + ChangeLogOutputError.ExternalIdNotFound, + "$it not found", + "externalId not found" + ) + } + + return PageChangeLogResponse(page = page, totalElements = pageResponse.totalElements, + totalPages = pageResponse.totalPages, + contentSize = pageResponse.content.size, + content = pageResponse.content, + invalidEntries = errorInfoList.size, + errors = errorInfoList + ) } + fun getChangeLogByLsaType(lsaType: LsaType?, fromTime: Instant?, page: Int, pageSize: Int): PageResponse { + + + val pageResponse = changelogRepository.findAllByBusinessPartnerTypeAndCreatedAtGreaterThanEqual( + businessPartnerType = lsaType, + createdAt = fromTime, + pageable = PageRequest.of(page, pageSize) + ) + return PageResponse(page = page, totalElements = pageResponse.totalElements, + totalPages = pageResponse.totalPages, + contentSize = pageResponse.content.size, + content = pageResponse.content, + ) + } } \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql b/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql index 54fe89271..3b5f94bb4 100644 --- a/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql +++ b/bpdm-gate/src/main/resources/db/migration/V0_0_1_0__create_changelog_table.sql @@ -1,4 +1,4 @@ -CREATE SEQUENCE IF NOT EXISTS bpdm_gate_sequence START WITH 1 INCREMENT BY 1; +CREATE SEQUENCE IF NOT EXISTS bpdm_sequence START WITH 1 INCREMENT BY 1; CREATE TABLE changelog_entries ( 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 ed23b1ed8..25eafeaec 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 @@ -32,6 +32,9 @@ import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequ import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerUpdateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.* +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt index e31e640b0..437652f04 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt @@ -27,7 +27,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.response.PageResponse -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.web.bind.annotation.GetMapping 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 6cd27357c..469b21476 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 @@ -26,6 +26,7 @@ import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.media.Schema 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.* import org.eclipse.tractusx.bpdm.pool.api.model.request.* import org.eclipse.tractusx.bpdm.pool.api.model.response.* 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 720ddc531..a10013ce5 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.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameUrlDto import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalFormRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.CountryIdentifierTypeResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.web.bind.annotation.* 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 8ac09a0df..fa724f758 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,7 +28,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses 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.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ImportIdMappingResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.SyncResponse import org.springdoc.core.annotations.ParameterObject 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 3eda756d9..8eec7472a 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,7 +30,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.response.MainAddressSearchResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.SitePartnerSearchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest 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.SitePartnerCreateResponseWrapper diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt index 5902b9e9f..979ee11f9 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt @@ -25,7 +25,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.SuggestionResponse import org.springdoc.core.annotations.ParameterObject 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 3d4a1b82c..8e7c8e370 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 @@ -19,15 +19,14 @@ 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.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.SuggestionResponse - import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.SuggestionType /** 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 ba61f0b61..840c5572b 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 @@ -22,10 +22,10 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.readValue 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.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse 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 66bc6f36a..c65ce1f26 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 @@ -20,10 +20,10 @@ 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.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasController.kt index f2446c160..af768aef3 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasController.kt @@ -19,11 +19,11 @@ package org.eclipse.tractusx.bpdm.pool.component.saas.controller +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.PoolSaasApi 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.request.PaginationRequest 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.component.saas.config.SaasAdapterConfigProperties diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/ImportStarterService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/ImportStarterService.kt index f50b486e7..6e7a9d522 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/ImportStarterService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/ImportStarterService.kt @@ -20,10 +20,10 @@ package org.eclipse.tractusx.bpdm.pool.component.saas.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.pool.api.model.ImportIdEntry import org.eclipse.tractusx.bpdm.pool.api.model.SyncType -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest 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.repository.ImportEntryRepository 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 010599a20..116b9a9b6 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 @@ -20,13 +20,14 @@ 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.AddressPartnerResponse import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerSearchResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse 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.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponseWrapper import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerUpdateResponseWrapper diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt index 773bbf307..30a646585 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt @@ -19,9 +19,9 @@ 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.pool.api.PoolBusinessPartnerApi -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse import org.eclipse.tractusx.bpdm.pool.config.ControllerConfigProperties import org.eclipse.tractusx.bpdm.pool.exception.BpdmRequestSizeException diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt index 4351906ba..78067bb85 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt @@ -25,8 +25,12 @@ import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.media.Schema 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.pool.api.model.request.* +import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest +import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest +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.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerResponse import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService 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 86c2346a6..56df2379d 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 @@ -19,6 +19,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.* import org.eclipse.tractusx.bpdm.pool.api.PoolLegalEntityApi import org.eclipse.tractusx.bpdm.pool.api.model.request.* 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 533b6a6e4..39fd5b3fb 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 @@ -20,13 +20,13 @@ package org.eclipse.tractusx.bpdm.pool.controller import com.neovisionaries.i18n.CountryCode +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LegalFormResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameUrlDto import org.eclipse.tractusx.bpdm.pool.api.PoolMetadataApi import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalFormRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.CountryIdentifierTypeResponse import org.eclipse.tractusx.bpdm.pool.service.MetadataService import org.springframework.data.domain.PageRequest 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 cbaea1e93..25aed9b35 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 @@ -19,12 +19,12 @@ 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.MainAddressSearchResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.SitePartnerSearchResponse import org.eclipse.tractusx.bpdm.pool.api.PoolSiteApi -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest 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.SitePartnerCreateResponseWrapper diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionController.kt index 93e6acb25..db500a607 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionController.kt @@ -19,9 +19,13 @@ 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.pool.api.PoolSuggestionApi -import org.eclipse.tractusx.bpdm.pool.api.model.request.* +import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest +import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest +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.SuggestionResponse import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.SuggestionType diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Address.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Address.kt index 8b7350972..54762139f 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Address.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Address.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.CountryCode import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.AddressType +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table( diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AddressPartner.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AddressPartner.kt index 46bc68cb7..1dfc8d1fc 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AddressPartner.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AddressPartner.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table( diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AdministrativeArea.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AdministrativeArea.kt index 86e7be49e..571bcbfd6 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AdministrativeArea.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AdministrativeArea.kt @@ -23,6 +23,7 @@ import com.neovisionaries.i18n.CountryCode import com.neovisionaries.i18n.LanguageCode import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.AdministrativeAreaType +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table( diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BankAccount.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BankAccount.kt index f10c35e69..b66a9b219 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BankAccount.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BankAccount.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.CurrencyCode import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table( diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BaseEntity.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BaseEntity.kt deleted file mode 100644 index bc462108e..000000000 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BaseEntity.kt +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.pool.entity - -import jakarta.persistence.* -import org.hibernate.annotations.CreationTimestamp -import org.hibernate.annotations.UpdateTimestamp -import java.time.Instant -import java.time.temporal.ChronoUnit -import java.util.* - -@MappedSuperclass -abstract class BaseEntity( - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bpdm_sequence") - @SequenceGenerator(name = "bpdm_sequence", sequenceName = "bpdm_sequence", allocationSize = 1) - @Column(name = "id", nullable = false, updatable = false, insertable = false) - val id: Long = 0, - - @Column(name = "uuid", nullable = false, updatable = false, unique = true, columnDefinition = "uuid") - val uuid: UUID = UUID.randomUUID(), - - @Column(updatable = false, nullable = false, name = "CREATED_AT") - @CreationTimestamp - val createdAt: Instant = Instant.now().truncatedTo(ChronoUnit.MICROS), - - @Column(nullable = false, name = "UPDATED_AT") - @UpdateTimestamp - val updatedAt: Instant = Instant.now().truncatedTo(ChronoUnit.MICROS) -) \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BaseNamedEntity.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BaseNamedEntity.kt index e8f27de18..bdb2fd5fd 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BaseNamedEntity.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BaseNamedEntity.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.Column import jakarta.persistence.MappedSuperclass +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @MappedSuperclass abstract class BaseNamedEntity( diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BusinessStatus.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BusinessStatus.kt index c5c57ca7c..c1cfcbbc5 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BusinessStatus.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/BusinessStatus.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.BusinessStatusType import java.time.LocalDateTime diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Classification.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Classification.kt index 8d17ee80c..6ee5d6647 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Classification.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Classification.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.ClassificationType @Entity diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/ConfigurationEntry.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/ConfigurationEntry.kt index ce0c28b88..4be789114 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/ConfigurationEntry.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/ConfigurationEntry.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Table +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "configuration_entries") diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/CountryIdentifierType.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/CountryIdentifierType.kt index 33cd96309..3e8884c96 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/CountryIdentifierType.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/CountryIdentifierType.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.CountryCode import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity /** * Represents valid identifier types for a country diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Identifier.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Identifier.kt index 2cbe35ab0..a71e6b9db 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Identifier.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Identifier.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table( diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IdentifierStatus.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IdentifierStatus.kt index 046cd4eb8..e39c61da0 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IdentifierStatus.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IdentifierStatus.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Table +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "identifier_status") diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IdentifierType.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IdentifierType.kt index 85f54f152..20bebaa3c 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IdentifierType.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IdentifierType.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Table +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "identifier_types") diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/ImportEntry.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/ImportEntry.kt index 4b6b7fb36..896619dbf 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/ImportEntry.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/ImportEntry.kt @@ -23,6 +23,7 @@ import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Index import jakarta.persistence.Table +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table( diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IssuingBody.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IssuingBody.kt index a3e692f1c..24c520b15 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IssuingBody.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/IssuingBody.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Table +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "issuing_bodies") diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalEntity.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalEntity.kt index d85fb7ed8..a026f4358 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalEntity.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalEntity.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.BusinessPartnerType import java.time.Instant diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalForm.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalForm.kt index 8a4fd0b9b..24d2ebc3a 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalForm.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalForm.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.LanguageCode import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "legal_forms") diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalFormCategory.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalFormCategory.kt index 244e151d8..6da07cc3b 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalFormCategory.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LegalFormCategory.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Table +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "legal_form_categories") diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Locality.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Locality.kt index e8309fed5..d621c4570 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Locality.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Locality.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.LanguageCode import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.LocalityType @Entity diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Name.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Name.kt index e8dc0178f..362022e32 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Name.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Name.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.LanguageCode import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.NameType @Entity diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PartnerChangelogEntry.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PartnerChangelogEntry.kt index abf027eef..b2e734025 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PartnerChangelogEntry.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PartnerChangelogEntry.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType @Entity diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PostCode.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PostCode.kt index 5485195e2..0b717ec9e 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PostCode.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PostCode.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.CountryCode import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.PostCodeType @Entity diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PostalDeliveryPoint.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PostalDeliveryPoint.kt index 38608f3ee..68863017d 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PostalDeliveryPoint.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PostalDeliveryPoint.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.LanguageCode import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.PostalDeliveryPointType @Entity diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Premise.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Premise.kt index 764380d01..632fa12ff 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Premise.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Premise.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.LanguageCode import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.PremiseType @Entity diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Relation.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Relation.kt index 40d72d3cf..90fda9f25 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Relation.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Relation.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.RelationClass import org.eclipse.tractusx.bpdm.common.model.RelationType import java.time.LocalDateTime diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Role.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Role.kt index 136aeb482..515b2f137 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Role.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Role.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.Table +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "roles") diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Site.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Site.kt index ce45e279d..44bca8665 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Site.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Site.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "sites") diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/SyncRecord.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/SyncRecord.kt index 03e2dc684..cb2046e78 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/SyncRecord.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/SyncRecord.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.pool.api.model.SyncStatus import org.eclipse.tractusx.bpdm.pool.api.model.SyncType import java.time.Instant diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Thoroughfare.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Thoroughfare.kt index a785ffe30..cba16d9d5 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Thoroughfare.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/Thoroughfare.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import com.neovisionaries.i18n.LanguageCode import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.ThoroughfareType @Entity 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 5c7d7474a..9e4551875 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 @@ -21,9 +21,9 @@ package org.eclipse.tractusx.bpdm.pool.service 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.* import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.entity.Address import org.eclipse.tractusx.bpdm.pool.entity.AddressPartner import org.eclipse.tractusx.bpdm.pool.repository.AddressPartnerRepository 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 e2e66662e..66d355563 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 @@ -19,12 +19,12 @@ 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.SitePartnerResponse import org.eclipse.tractusx.bpdm.common.dto.response.SitePartnerSearchResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.entity.Site import org.eclipse.tractusx.bpdm.pool.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.pool.repository.SiteRepository diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/InvalidIndexStartupIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/InvalidIndexStartupIT.kt index 754deddec..2003ef552 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/InvalidIndexStartupIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/InvalidIndexStartupIT.kt @@ -22,12 +22,11 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch 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.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.LEGAL_ENTITIES_INDEX_NAME import org.eclipse.tractusx.bpdm.pool.util.* @@ -130,7 +129,8 @@ class InvalidIndexStartupIT @Autowired constructor( LegalEntityPropertiesSearchRequest.EmptySearchRequest , AddressPropertiesSearchRequest.EmptySearchRequest , SitePropertiesSearchRequest.EmptySearchRequest - , PaginationRequest()) + , PaginationRequest() + ) assertThat(searchResult.content).isNotEmpty assertThat(searchResult.contentSize).isEqualTo(1) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/ValidIndexStartupIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/ValidIndexStartupIT.kt index 6c5590791..64f16e9cf 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/ValidIndexStartupIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/ValidIndexStartupIT.kt @@ -22,12 +22,11 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions - +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest 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.AddressPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.MethodOrderer 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 131994d45..db2f8f59c 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 @@ -24,13 +24,13 @@ import com.github.tomakehurst.wiremock.client.WireMock 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.saas.PagedResponseSaas 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.AddressPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest 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.component.opensearch.impl.service.OpenSearchSyncStarterService diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasControllerImportIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasControllerImportIT.kt index 1e37b55cb..6fe4cd92f 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasControllerImportIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasControllerImportIT.kt @@ -26,6 +26,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension import com.github.tomakehurst.wiremock.stubbing.Scenario import org.assertj.core.api.Assertions.assertThat 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.request.SiteBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerSearchResponse import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityPartnerResponse @@ -34,7 +35,6 @@ import org.eclipse.tractusx.bpdm.common.dto.response.SitePartnerSearchResponse import org.eclipse.tractusx.bpdm.common.dto.saas.* 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.PaginationRequest import org.eclipse.tractusx.bpdm.pool.component.saas.config.SaasAdapterConfigProperties import org.eclipse.tractusx.bpdm.pool.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.pool.repository.ImportEntryRepository @@ -585,7 +585,9 @@ class SaasControllerImportIT @Autowired constructor( private fun getLegalEntities(bpns: Collection): Collection = poolClient.legalEntities().searchSites(bpns).body!! - private fun getSites(bpns: Collection): PageResponse = poolClient.sites().searchSites(SiteBpnSearchRequest(sites = bpns),PaginationRequest()) + private fun getSites(bpns: Collection): PageResponse = poolClient.sites().searchSites(SiteBpnSearchRequest(sites = bpns), + PaginationRequest() + ) private fun getAddresses(bpns: Collection): PageResponse = poolClient.addresses().searchAddresses(AddressPartnerBpnSearchRequest(addresses = bpns), PaginationRequest()) 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 eae9b27de..07678dee8 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 @@ -23,6 +23,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.AddressPartnerBpnSearchRequest +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.AddressBpnResponse import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerSearchResponse import org.eclipse.tractusx.bpdm.pool.Application @@ -184,7 +185,7 @@ class AddressControllerIT @Autowired constructor( val searchRequest = AddressPartnerBpnSearchRequest(listOf(bpnL1, bpnL2), emptyList()) - val searchResult = poolClient.addresses().searchAddresses(searchRequest,PaginationRequest()) + val searchResult = poolClient.addresses().searchAddresses(searchRequest, PaginationRequest()) searchResult.content.sortedByDescending { it.bpnLegalEntity } // need revert val expectedAddress1 = ResponseValues.addressPartner1 @@ -237,7 +238,7 @@ class AddressControllerIT @Autowired constructor( val bpnS2 = createdStructures[1].siteStructures[0].site.bpn val searchRequest = AddressPartnerBpnSearchRequest(emptyList(), listOf(bpnS1, bpnS2)) - val searchResult = poolClient.addresses().searchAddresses(searchRequest,PaginationRequest()) + val searchResult = poolClient.addresses().searchAddresses(searchRequest, PaginationRequest()) searchResult.content.sortedByDescending { it.bpnLegalEntity } // need revert val expectedAddressWithReferences1 = AddressPartnerSearchResponse(ResponseValues.addressPartner1, null, bpnS1) @@ -424,6 +425,6 @@ class AddressControllerIT @Autowired constructor( private fun requestAddressesOfLegalEntity(bpn: String) = - poolClient.legalEntities().getAddresses(bpn,PaginationRequest()) + poolClient.legalEntities().getAddresses(bpn, PaginationRequest()) } \ No newline at end of file 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 cc0fdf840..a52ec2f81 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 @@ -19,13 +19,13 @@ package org.eclipse.tractusx.bpdm.pool.controller +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerResponse import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerSearchResponse 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.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach 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 5fe4d6a26..894fff6c6 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 @@ -20,13 +20,13 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.assertj.core.api.Assertions.assertThat +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityPartnerResponse 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.AddressPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest 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.util.* @@ -163,7 +163,8 @@ class LegalEntityControllerSearchIT @Autowired constructor( val sitePropertiesSearchRequest = SitePropertiesSearchRequest(siteName) return poolClient.legalEntities().getLegalEntities(LegalEntityPropertiesSearchRequest.EmptySearchRequest, - AddressPropertiesSearchRequest.EmptySearchRequest,sitePropertiesSearchRequest,PaginationRequest(page, size)) + AddressPropertiesSearchRequest.EmptySearchRequest,sitePropertiesSearchRequest, PaginationRequest(page, size) + ) } 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 31f4bd760..26a341be7 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 @@ -21,13 +21,13 @@ package org.eclipse.tractusx.bpdm.pool.controller import com.neovisionaries.i18n.CountryCode import org.assertj.core.api.Assertions.assertThat +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LegalFormResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameUrlDto import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalFormRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.CountryIdentifierTypeResponse import org.eclipse.tractusx.bpdm.pool.entity.CountryIdentifierType import org.eclipse.tractusx.bpdm.pool.entity.IdentifierType 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 97aa67125..d6b0d56b9 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 @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.assertj.core.api.Assertions.assertThat +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.MainAddressSearchResponse import org.eclipse.tractusx.bpdm.common.dto.response.SitePartnerSearchResponse @@ -352,6 +353,6 @@ class SiteControllerIT @Autowired constructor( private fun requestSite(bpnSite: String) = poolClient.sites().getSite(bpnSite) - private fun requestSitesOfLegalEntity(bpn: String) = poolClient.legalEntities().getSites(bpn,PaginationRequest()) + private fun requestSitesOfLegalEntity(bpn: String) = poolClient.legalEntities().getSites(bpn, PaginationRequest()) } \ No newline at end of file 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 14fd069d3..6578ea146 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 @@ -26,6 +26,7 @@ import jakarta.persistence.EntityManager import jakarta.persistence.EntityManagerFactory import org.assertj.core.api.Assertions import org.assertj.core.api.RecursiveComparisonAssert +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.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas From d547ffb1a5171d0cafca380a88fed86f3e3053fb Mon Sep 17 00:00:00 2001 From: alexsilva Date: Mon, 20 Mar 2023 16:30:19 +0000 Subject: [PATCH 09/16] fix(gate): changed api logic, to return values in case no fromTime value was specified --- .../gate/repository/ChangelogRepository.kt | 14 +++++++ .../bpdm/gate/service/ChangelogService.kt | 38 ++++++++++++------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index dcf023960..5f5222226 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -29,12 +29,26 @@ import java.time.Instant interface ChangelogRepository : JpaRepository { + //Query for ExternalID only + fun findAllByExternalIdIn( + externalIds: Collection, + pageable: Pageable + ): Page + + //Query for ExternalID and fromTime Parameter fun findAllByExternalIdInAndCreatedAtGreaterThanEqual( externalIds: Collection, createdAt: Instant?, pageable: Pageable ): Page + //Query for BusinessPartnerType only + fun findAllByBusinessPartnerType( + businessPartnerType: LsaType?, + pageable: Pageable + ): Page + + //Query for BusinessPartnerType and fromTime Parameter fun findAllByBusinessPartnerTypeAndCreatedAtGreaterThanEqual( businessPartnerType: LsaType?, createdAt: Instant?, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index a38d917e1..728e0ca1f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.service -import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType @@ -34,7 +33,6 @@ import java.time.Instant @Service class ChangelogService (private val changelogRepository: ChangelogRepository) { - private val logger = KotlinLogging.logger { } @Transactional fun createChangelog(externalId: String) { @@ -44,12 +42,18 @@ class ChangelogService (private val changelogRepository: ChangelogRepository) { fun getChangeLogByExternalId(externalIds: Collection, fromTime: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { - - val pageResponse = changelogRepository.findAllByExternalIdInAndCreatedAtGreaterThanEqual( - externalIds = externalIds, - createdAt = fromTime, - pageable = PageRequest.of(page, pageSize) - ) + val pageResponse = changelogRepository.run { + val pageable = PageRequest.of(page, pageSize) + if (fromTime == null) { + findAllByExternalIdIn(externalIds = externalIds, pageable = pageable) + } else { + findAllByExternalIdInAndCreatedAtGreaterThanEqual( + externalIds = externalIds, + createdAt = fromTime, + pageable = pageable + ) + } + } val errorInfoList = externalIds.filterNot { id -> pageResponse.content.any { it.externalId == id } @@ -72,12 +76,18 @@ class ChangelogService (private val changelogRepository: ChangelogRepository) { fun getChangeLogByLsaType(lsaType: LsaType?, fromTime: Instant?, page: Int, pageSize: Int): PageResponse { - - val pageResponse = changelogRepository.findAllByBusinessPartnerTypeAndCreatedAtGreaterThanEqual( - businessPartnerType = lsaType, - createdAt = fromTime, - pageable = PageRequest.of(page, pageSize) - ) + val pageResponse = changelogRepository.run { + val pageable = PageRequest.of(page, pageSize) + if (fromTime == null) { + findAllByBusinessPartnerType(businessPartnerType = lsaType, pageable = pageable) + } else { + findAllByBusinessPartnerTypeAndCreatedAtGreaterThanEqual( + businessPartnerType = lsaType, + createdAt = fromTime, + pageable = pageable + ) + } + } return PageResponse(page = page, totalElements = pageResponse.totalElements, totalPages = pageResponse.totalPages, From 02bf41702c39014addc846492ec878800a176cd7 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Tue, 21 Mar 2023 09:48:36 +0000 Subject: [PATCH 10/16] Fix(Gate): Fix not accepting empty externalIds list , missing logic --- .../gate/controller/ChangelogController.kt | 17 +++++------ .../gate/repository/ChangelogRepository.kt | 6 ++++ .../bpdm/gate/service/ChangelogService.kt | 29 +++++++++---------- .../tractusx/bpdm/pool/api/PoolAddressApi.kt | 4 +++ .../bpdm/pool/controller/AddressController.kt | 1 + .../pool/controller/AddressControllerIT.kt | 1 - .../bpdm/pool/controller/SiteControllerIT.kt | 1 - 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 140ea6ab0..78a6c18bd 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -25,6 +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 jakarta.validation.Valid +import jakarta.validation.constraints.NotEmpty import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType @@ -32,11 +33,13 @@ import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.service.ChangelogService import org.springdoc.core.annotations.ParameterObject +import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.* import java.time.Instant @RestController @RequestMapping("/api/catena/business-partners/changelog") +@Validated class ChangelogController ( private val changelogService: ChangelogService ) { @@ -55,12 +58,11 @@ class ChangelogController ( @PostMapping("/search") fun getChangelogEntriesExternalId( @ParameterObject @Valid paginationRequest: PaginationRequest, - @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam fromTime: Instant? , - @RequestBody externalIds: Collection? = emptyList() + @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam(required = false) fromTime: Instant?, + @RequestBody(required = true) @NotEmpty(message = "Input externalIds list cannot be empty.") externalIds: Collection ): PageChangeLogResponse { - return changelogService.getChangeLogByExternalId(externalIds!!,fromTime,paginationRequest.page,paginationRequest.size) + return changelogService.getChangeLogByExternalId(externalIds,fromTime,paginationRequest.page,paginationRequest.size) } - @Operation( summary = "Get business partner changelog entries by timestamp or LSA type", description = "Get business partner changelog entries by from timestamp or LSA type" @@ -81,10 +83,5 @@ class ChangelogController ( return changelogService.getChangeLogByLsaType(lsaType,fromTime,paginationRequest.page,paginationRequest.size) } - @PostMapping - fun createChangelogEntries( - @Parameter(description = "externalId") @RequestParam externalId: String - ) { - return changelogService.createChangelog(externalId) - } + } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index 5f5222226..6d08d4535 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -48,6 +48,12 @@ interface ChangelogRepository : JpaRepository { pageable: Pageable ): Page + //Query for fromTime Parameter only + fun findAllByCreatedAtGreaterThanEqual( + createdAt: Instant?, + pageable: Pageable + ): Page + //Query for BusinessPartnerType and fromTime Parameter fun findAllByBusinessPartnerTypeAndCreatedAtGreaterThanEqual( businessPartnerType: LsaType?, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 728e0ca1f..126d7a984 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -28,29 +28,22 @@ import org.eclipse.tractusx.bpdm.gate.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.data.domain.PageRequest import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional import java.time.Instant @Service -class ChangelogService (private val changelogRepository: ChangelogRepository) { +class ChangelogService(private val changelogRepository: ChangelogRepository) { + - @Transactional - fun createChangelog(externalId: String) { - val changelogEntity = ChangelogEntity(externalId,LsaType.Address) - changelogRepository.save(changelogEntity) - } fun getChangeLogByExternalId(externalIds: Collection, fromTime: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { val pageResponse = changelogRepository.run { val pageable = PageRequest.of(page, pageSize) if (fromTime == null) { - findAllByExternalIdIn(externalIds = externalIds, pageable = pageable) + changelogRepository.findAllByExternalIdIn(externalIds, pageable) } else { - findAllByExternalIdInAndCreatedAtGreaterThanEqual( - externalIds = externalIds, - createdAt = fromTime, - pageable = pageable + changelogRepository.findAllByExternalIdInAndCreatedAtGreaterThanEqual( + externalIds, fromTime, pageable ) } } @@ -65,7 +58,8 @@ class ChangelogService (private val changelogRepository: ChangelogRepository) { ) } - return PageChangeLogResponse(page = page, totalElements = pageResponse.totalElements, + return PageChangeLogResponse( + page = page, totalElements = pageResponse.totalElements, totalPages = pageResponse.totalPages, contentSize = pageResponse.content.size, content = pageResponse.content, @@ -78,8 +72,12 @@ class ChangelogService (private val changelogRepository: ChangelogRepository) { val pageResponse = changelogRepository.run { val pageable = PageRequest.of(page, pageSize) - if (fromTime == null) { + if (fromTime == null && lsaType == null) { + findAll(pageable) + } else if (fromTime == null ) { findAllByBusinessPartnerType(businessPartnerType = lsaType, pageable = pageable) + } else if ( lsaType == null) { + findAllByCreatedAtGreaterThanEqual(createdAt = fromTime, pageable = pageable) } else { findAllByBusinessPartnerTypeAndCreatedAtGreaterThanEqual( businessPartnerType = lsaType, @@ -89,7 +87,8 @@ class ChangelogService (private val changelogRepository: ChangelogRepository) { } } - return PageResponse(page = page, totalElements = pageResponse.totalElements, + return PageResponse( + page = page, totalElements = pageResponse.totalElements, totalPages = pageResponse.totalPages, contentSize = pageResponse.content.size, content = pageResponse.content, 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 25eafeaec..f06cf9e4e 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 @@ -25,6 +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.AddressPartnerBpnSearchRequest +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerSearchResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerCreateRequest @@ -35,6 +36,9 @@ import org.eclipse.tractusx.bpdm.pool.api.model.response.* import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponseWrapper +import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerUpdateResponseWrapper import org.springdoc.core.annotations.ParameterObject import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange 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 116b9a9b6..2f0f95371 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,6 +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.AddressPartnerResponse +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerSearchResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.PoolAddressApi 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 07678dee8..99c6be32c 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,6 @@ import org.eclipse.tractusx.bpdm.common.dto.response.AddressBpnResponse import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerSearchResponse import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient -import org.eclipse.tractusx.bpdm.pool.api.model.request.PaginationRequest 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.AddressUpdateError 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 d6b0d56b9..ce3081adb 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,7 +26,6 @@ import org.eclipse.tractusx.bpdm.common.dto.response.MainAddressSearchResponse import org.eclipse.tractusx.bpdm.common.dto.response.SitePartnerSearchResponse 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.PaginationRequest 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.SiteUpdateError From 65cf34b22912d764b1d238dd9ccf96209100ff73 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Wed, 22 Mar 2023 11:21:01 +0000 Subject: [PATCH 11/16] fix(gate/gate-api): changelog record is created when PUT endpoints are invoked, creation of API interface for changelogController, minor fixes --- .../bpdm/gate/api/GateChangelogApi.kt | 84 +++++++++++++++++++ .../bpdm/gate/api/entity/ChangelogEntity.kt | 39 +++++++++ .../bpdm/gate/api/exception/GateErrorCodes.kt | 5 ++ .../model/response/PageChangeLogResponse.kt | 42 ++++++++++ .../gate/controller/ChangelogController.kt | 47 ++--------- .../request/PaginationStartAfterRequest.kt | 2 +- .../dto/response/PageChangeLogResponse.kt | 2 +- .../bpdm/gate/service/AddressService.kt | 10 ++- .../bpdm/gate/service/ChangelogService.kt | 4 +- .../bpdm/gate/service/LegalEntityService.kt | 9 ++ .../tractusx/bpdm/gate/service/SiteService.kt | 11 ++- .../src/main/resources/application.properties | 2 +- 12 files changed, 207 insertions(+), 50 deletions(-) create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/entity/ChangelogEntity.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt new file mode 100644 index 000000000..dce913b9e --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt @@ -0,0 +1,84 @@ + +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.api + +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.Parameter +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 jakarta.validation.Valid +import jakarta.validation.constraints.NotEmpty +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse +import org.springdoc.core.annotations.ParameterObject +import org.springframework.web.bind.annotation.* +import org.springframework.web.service.annotation.HttpExchange +import org.springframework.web.service.annotation.PostExchange +import java.time.Instant + +@RequestMapping("/api/catena/business-partners/changelog") +@HttpExchange("/api/catena/business-partners/changelog") +interface GateChangelogApi { + + + @Operation( + summary = "Get business partner changelog entries by list external id, from timestamp", + description = "Get business partner changelog entries by list external id, from timestamp" + ) + @ApiResponses( + value = [ + ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), + ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), + ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) + ] + ) + @PostMapping("/search") + @PostExchange("/search") + fun getChangelogEntriesExternalId( + @ParameterObject @Valid paginationRequest: PaginationRequest, + @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam(required = false) fromTime: Instant?, + @RequestBody(required = true) @NotEmpty(message = "Input externalIds list cannot be empty.") externalIds: Collection + ): PageChangeLogResponse + + @Operation( + summary = "Get business partner changelog entries by timestamp or LSA type", + description = "Get business partner changelog entries by from timestamp or LSA type" + ) + @ApiResponses( + value = [ + ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), + ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), + ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) + ] + ) + @PostMapping("/filter") + @PostExchange("/filter") + fun getChangelogEntriesLsaType( + @ParameterObject @Valid paginationRequest: PaginationRequest, + @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam fromTime: Instant?, + @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType? + ): PageResponse + +} \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/entity/ChangelogEntity.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/entity/ChangelogEntity.kt new file mode 100644 index 000000000..f74fea513 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/entity/ChangelogEntity.kt @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.entity +import jakarta.persistence.* +import org.eclipse.tractusx.bpdm.common.model.BaseEntity +import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType + + +@Entity +@Table(name = "changelog_entries") +class ChangelogEntity ( + + @Column(name = "external_id", nullable = false, updatable = false) + val externalId: String, + @Enumerated(EnumType.STRING) + @Column(name = "business_partner_type", nullable = false, updatable = false) + val businessPartnerType: LsaType + +) : BaseEntity() + + + diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/exception/GateErrorCodes.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/exception/GateErrorCodes.kt index 0898932b9..9cf123d79 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/exception/GateErrorCodes.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/exception/GateErrorCodes.kt @@ -33,3 +33,8 @@ enum class BusinessPartnerOutputError : ErrorCode { SharingTimeout, BpnNotInPool, } + +@Schema(description = "ChangeLogOutputError") +enum class ChangeLogOutputError : ErrorCode { + ExternalIdNotFound, +} diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt new file mode 100644 index 000000000..e935d16fe --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.dto.response + +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.gate.exception.ChangeLogOutputError + +@Schema(description = "Paginated collection of results") +data class PageChangeLogResponse( + @Schema(description = "Total number of all results in all pages") + val totalElements: Long, + @Schema(description = "Total number pages") + val totalPages: Int, + @Schema(description = "Current page number") + val page: Int, + @Schema(description = "Number of results in the page") + val contentSize: Int, + @Schema(description = "Collection of results in the page") + val content: Collection, + @Schema(description = "Number of entries in the page that have been omitted due to being invalid (error)") + val invalidEntries: Int, + @Schema(description = "Infos about the entries with errors") + val errors: Collection>, +) + diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 78a6c18bd..6eec32a86 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -19,66 +19,29 @@ package org.eclipse.tractusx.bpdm.gate.controller -import io.swagger.v3.oas.annotations.Operation -import io.swagger.v3.oas.annotations.Parameter -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 jakarta.validation.Valid -import jakarta.validation.constraints.NotEmpty import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.api.GateChangelogApi import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.service.ChangelogService -import org.springdoc.core.annotations.ParameterObject import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.* import java.time.Instant @RestController -@RequestMapping("/api/catena/business-partners/changelog") @Validated class ChangelogController ( private val changelogService: ChangelogService - ) { + ) : GateChangelogApi { - @Operation( - summary = "Get business partner changelog entries by list external id, from timestamp", - description = "Get business partner changelog entries by list external id, from timestamp" - ) - @ApiResponses( - value = [ - ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), - ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), - ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) - ] - ) - @PostMapping("/search") - fun getChangelogEntriesExternalId( - @ParameterObject @Valid paginationRequest: PaginationRequest, - @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam(required = false) fromTime: Instant?, - @RequestBody(required = true) @NotEmpty(message = "Input externalIds list cannot be empty.") externalIds: Collection + override fun getChangelogEntriesExternalId(paginationRequest: PaginationRequest, fromTime: Instant?, externalIds: Collection ): PageChangeLogResponse { return changelogService.getChangeLogByExternalId(externalIds,fromTime,paginationRequest.page,paginationRequest.size) } - @Operation( - summary = "Get business partner changelog entries by timestamp or LSA type", - description = "Get business partner changelog entries by from timestamp or LSA type" - ) - @ApiResponses( - value = [ - ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), - ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), - ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) - ] - ) - @PostMapping("/filter") - fun getChangelogEntriesLsaType( - @ParameterObject @Valid paginationRequest: PaginationRequest, - @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam fromTime: Instant?, - @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType? + + override fun getChangelogEntriesLsaType(paginationRequest: PaginationRequest, fromTime: Instant?, lsaType: LsaType? ): PageResponse { return changelogService.getChangeLogByLsaType(lsaType,fromTime,paginationRequest.page,paginationRequest.size) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt index d71ef6462..c1fdd4742 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt @@ -30,7 +30,7 @@ data class PaginationStartAfterRequest( description = "Value used to indicate which page to retrieve. When this value is not provided, the first page is returned." + "The nextStartAfter value from the response can then be used to request subsequent pages." ) - val startAfter: String? = "0", + val startAfter: String?, @field:Parameter( description = "Size of each page", schema = Schema(defaultValue = "10") diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt index 2fd90d84f..e935d16fe 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt @@ -34,7 +34,7 @@ data class PageChangeLogResponse( val contentSize: Int, @Schema(description = "Collection of results in the page") val content: Collection, - @Schema(description = "Number of entries in the page that have been omitted due to being invalid (error or still pending)") + @Schema(description = "Number of entries in the page that have been omitted due to being invalid (error)") val invalidEntries: Int, @Schema(description = "Infos about the entries with errors") val errors: Collection>, 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 1d6c6f9c0..6673a1b2d 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 @@ -31,8 +31,10 @@ import org.eclipse.tractusx.bpdm.gate.dto.AddressGateOutput import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.exception.SaasInvalidRecordException import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.stereotype.Service @Service @@ -43,7 +45,8 @@ class AddressService( private val saasClient: SaasClient, private val poolClient: PoolClient, private val bpnConfigProperties: BpnConfigProperties, - private val typeMatchingService: TypeMatchingService + private val typeMatchingService: TypeMatchingService, + private val changelogRepository: ChangelogRepository ) { private val logger = KotlinLogging.logger { } @@ -148,6 +151,11 @@ class AddressService( * - Upserting the new relations */ fun upsertAddresses(addresses: Collection) { + + addresses.forEach { address -> + changelogRepository.save(ChangelogEntity(address.externalId, LsaType.Address)) + } + val addressesSaas = toSaasModels(addresses) saasClient.upsertAddresses(addressesSaas) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 126d7a984..75a438716 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -20,10 +20,10 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.data.domain.PageRequest @@ -33,8 +33,6 @@ import java.time.Instant @Service class ChangelogService(private val changelogRepository: ChangelogRepository) { - - fun getChangeLogByExternalId(externalIds: Collection, fromTime: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { val pageResponse = changelogRepository.run { 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 537c63c6a..99b9f7d8b 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 @@ -29,8 +29,11 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateOutput +import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.stereotype.Service @Service @@ -40,11 +43,17 @@ class LegalEntityService( private val outputSaasMappingService: OutputSaasMappingService, private val saasClient: SaasClient, private val poolClient: PoolClient, + private val changelogRepository: ChangelogRepository ) { private val logger = KotlinLogging.logger { } fun upsertLegalEntities(legalEntities: Collection) { + + legalEntities.forEach { legalEntity -> + changelogRepository.save(ChangelogEntity(legalEntity.externalId, LsaType.LegalEntity)) + } + val legalEntitiesSaas = legalEntities.map { saasRequestMappingService.toSaasModel(it) } saasClient.upsertLegalEntities(legalEntitiesSaas) } 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 58348dfbc..b0d7e9b78 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 @@ -30,10 +30,13 @@ import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.SiteGateOutput +import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.exception.SaasInvalidRecordException import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.stereotype.Service @Service @@ -43,7 +46,8 @@ class SiteService( private val outputSaasMappingService: OutputSaasMappingService, private val saasClient: SaasClient, private val poolClient: PoolClient, - private val bpnConfigProperties: BpnConfigProperties + private val bpnConfigProperties: BpnConfigProperties, + private val changelogRepository: ChangelogRepository ) { private val logger = KotlinLogging.logger { } @@ -136,6 +140,11 @@ class SiteService( * - Upserting the new relations */ fun upsertSites(sites: Collection) { + + sites.forEach { site -> + changelogRepository.save(ChangelogEntity(site.externalId, LsaType.Site)) + } + val sitesSaas = toSaasModels(sites) saasClient.upsertSites(sitesSaas) diff --git a/bpdm-gate/src/main/resources/application.properties b/bpdm-gate/src/main/resources/application.properties index 0964d386d..bb995e44e 100644 --- a/bpdm-gate/src/main/resources/application.properties +++ b/bpdm-gate/src/main/resources/application.properties @@ -20,7 +20,7 @@ bpdm.name=@project.name@ bpdm.description=@project.description@ bpdm.version=@project.version@ #Change default port since 8080 is reserved for pool -server.port=8082 +server.port=8081 #Logging Configuration bpdm.logging.unknown-user=Anonymous #Configuration specific to the service logic From de3a707c0d27d5737ed8b736d91fd5d7898bb06a Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Wed, 22 Mar 2023 13:28:19 +0000 Subject: [PATCH 12/16] Fix(Gate): Fix port and use specifications on querys --- .../gate/repository/ChangelogRepository.kt | 65 ++++++++++--------- .../bpdm/gate/service/ChangelogService.kt | 43 ++++-------- 2 files changed, 49 insertions(+), 59 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index 6d08d4535..7a46e589e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -21,44 +21,49 @@ package org.eclipse.tractusx.bpdm.gate.repository import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity -import org.springframework.data.domain.Page -import org.springframework.data.domain.Pageable +import org.springframework.data.jpa.domain.Specification import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.jpa.repository.JpaSpecificationExecutor import java.time.Instant -interface ChangelogRepository : JpaRepository { +interface ChangelogRepository : JpaRepository , JpaSpecificationExecutor { - //Query for ExternalID only - fun findAllByExternalIdIn( - externalIds: Collection, - pageable: Pageable - ): Page + object Specs { - //Query for ExternalID and fromTime Parameter - fun findAllByExternalIdInAndCreatedAtGreaterThanEqual( - externalIds: Collection, - createdAt: Instant?, - pageable: Pageable - ): Page + /** + * Restrict to entries with any one of the given ExternalIds; ignore if null + */ + fun byExternalIdsIn(externalIds: Collection) = + Specification { root, _, _ -> - //Query for BusinessPartnerType only - fun findAllByBusinessPartnerType( - businessPartnerType: LsaType?, - pageable: Pageable - ): Page + externalIds.let { + root.get(ChangelogEntity::externalId.name).`in`(externalIds.map { externalId -> externalId }) + } + + } + + /** + * Restrict to entries created at or after the given instant; ignore if null + */ + fun byCreatedAtGreaterThan(createdAt: Instant?) = + Specification { root, _, builder -> + createdAt?.let { + builder.greaterThanOrEqualTo(root.get(ChangelogEntity::createdAt.name), createdAt) + } + } + + /** + * Restrict to entries for the LsaType; ignore if null + */ + fun byLsaType(lsaType: LsaType?) = + Specification { root, _, builder -> + lsaType?.let { + builder.equal(root.get(ChangelogEntity::businessPartnerType.name),lsaType) + } + } + } - //Query for fromTime Parameter only - fun findAllByCreatedAtGreaterThanEqual( - createdAt: Instant?, - pageable: Pageable - ): Page - //Query for BusinessPartnerType and fromTime Parameter - fun findAllByBusinessPartnerTypeAndCreatedAtGreaterThanEqual( - businessPartnerType: LsaType?, - createdAt: Instant?, - pageable: Pageable - ): Page } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 75a438716..e80bafe95 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -20,31 +20,29 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byCreatedAtGreaterThan +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byExternalIdsIn +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byLsaType import org.springframework.data.domain.PageRequest +import org.springframework.data.jpa.domain.Specification import org.springframework.stereotype.Service import java.time.Instant @Service class ChangelogService(private val changelogRepository: ChangelogRepository) { - fun getChangeLogByExternalId(externalIds: Collection, fromTime: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { + fun getChangeLogByExternalId(externalIds: Collection, createdAt: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { + + val spec = Specification.allOf(byExternalIdsIn(externalIds = externalIds),byCreatedAtGreaterThan(createdAt = createdAt)) + val pageable = PageRequest.of(page, pageSize) + val pageResponse = changelogRepository.findAll(spec,pageable) - val pageResponse = changelogRepository.run { - val pageable = PageRequest.of(page, pageSize) - if (fromTime == null) { - changelogRepository.findAllByExternalIdIn(externalIds, pageable) - } else { - changelogRepository.findAllByExternalIdInAndCreatedAtGreaterThanEqual( - externalIds, fromTime, pageable - ) - } - } val errorInfoList = externalIds.filterNot { id -> pageResponse.content.any { it.externalId == id } @@ -66,24 +64,11 @@ class ChangelogService(private val changelogRepository: ChangelogRepository) { ) } - fun getChangeLogByLsaType(lsaType: LsaType?, fromTime: Instant?, page: Int, pageSize: Int): PageResponse { + fun getChangeLogByLsaType(lsaType: LsaType?, createdAt: Instant?, page: Int, pageSize: Int): PageResponse { - val pageResponse = changelogRepository.run { - val pageable = PageRequest.of(page, pageSize) - if (fromTime == null && lsaType == null) { - findAll(pageable) - } else if (fromTime == null ) { - findAllByBusinessPartnerType(businessPartnerType = lsaType, pageable = pageable) - } else if ( lsaType == null) { - findAllByCreatedAtGreaterThanEqual(createdAt = fromTime, pageable = pageable) - } else { - findAllByBusinessPartnerTypeAndCreatedAtGreaterThanEqual( - businessPartnerType = lsaType, - createdAt = fromTime, - pageable = pageable - ) - } - } + val spec = Specification.allOf(byCreatedAtGreaterThan(createdAt = createdAt), byLsaType(lsaType)) + val pageable = PageRequest.of(page, pageSize) + val pageResponse = changelogRepository.findAll(spec,pageable) return PageResponse( page = page, totalElements = pageResponse.totalElements, From 5a0b1b315c46f37ef07b39c2ff1a821a34f87031 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Wed, 22 Mar 2023 15:25:44 +0000 Subject: [PATCH 13/16] fix(gate/gate-api): Added GateChangelogApi to GateClient , removal and change of package and imports --- .../tractusx/bpdm/gate/api/GateAddressApi.kt | 8 +-- .../bpdm/gate/api/GateBusinessPartnerApi.kt | 2 +- .../bpdm/gate/api/GateChangelogApi.kt | 10 +-- .../bpdm/gate/api/GateLegalEntityApi.kt | 8 +-- .../tractusx/bpdm/gate/api/GateSiteApi.kt | 8 +-- .../bpdm/gate/api/client/GateClient.kt | 7 +- .../bpdm/gate/api/client/GateClientImpl.kt | 8 +-- .../bpdm/gate/api/exception/GateErrorCodes.kt | 2 +- .../request/PaginationStartAfterRequest.kt | 2 +- .../api/model/response/ChangelogResponse.kt | 23 +++---- .../bpdm/gate/api/model/response/ErrorInfo.kt | 2 +- .../model/response/PageChangeLogResponse.kt | 5 +- .../api/model/response/PageOutputResponse.kt | 5 +- .../model/response/PageStartAfterResponse.kt | 2 +- .../api/model/response/TypeMatchResponse.kt | 12 +++- .../api/model/response/ValidationResponse.kt | 2 +- .../bpdm/gate/controller/AddressController.kt | 11 ++- .../controller/BusinessPartnerController.kt | 2 +- .../gate/controller/ChangelogController.kt | 28 ++++---- .../gate/controller/LegalEntityController.kt | 48 ++----------- .../bpdm/gate/controller/SiteController.kt | 10 +-- .../tractusx/bpdm/gate/dto/ChangelogDto.kt | 28 -------- .../request/PaginationStartAfterRequest.kt | 41 ------------ .../bpdm/gate/dto/response/ErrorInfo.kt | 2 +- .../dto/response/PageChangeLogResponse.kt | 42 ------------ .../gate/dto/response/PageOutputResponse.kt | 39 ----------- .../dto/response/PageStartAfterResponse.kt | 34 ---------- .../gate/dto/response/TypeMatchResponse.kt | 32 --------- .../bpdm/gate/entity/ChangelogEntity.kt | 4 +- .../bpdm/gate/exception/GateErrorCodes.kt | 1 + .../model/SharingStatusEvaluationResult.kt | 2 +- .../gate/repository/ChangelogRepository.kt | 7 +- .../bpdm/gate/service/AddressService.kt | 11 +-- .../bpdm/gate/service/ChangelogService.kt | 45 ++++++++----- .../bpdm/gate/service/LegalEntityService.kt | 6 +- .../gate/service/OutputSaasMappingService.kt | 2 +- .../bpdm/gate/service/ResponseMappings.kt | 29 ++++---- .../tractusx/bpdm/gate/service/SiteService.kt | 6 +- .../bpdm/gate/service/TypeMatchingService.kt | 24 +++---- .../bpdm/gate/service/ValidationService.kt | 4 +- .../controller/AddressControllerInputIT.kt | 67 +++++++++---------- .../controller/AddressControllerOutputIT.kt | 6 +- .../controller/BusinessPartnerControllerIT.kt | 24 +++---- .../LegalEntityControllerInputIT.kt | 52 +++++++------- .../LegalEntityControllerOutputIT.kt | 6 +- .../gate/controller/SiteControllerInputIT.kt | 51 +++++++------- .../gate/controller/SiteControllerOutputIT.kt | 10 +-- 47 files changed, 268 insertions(+), 512 deletions(-) rename bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ValidationResponse.kt => bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt (66%) delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/ChangelogDto.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageOutputResponse.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageStartAfterResponse.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/TypeMatchResponse.kt rename bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/entity/ChangelogEntity.kt => bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt (59%) 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 2ea201c4a..14252f87e 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 @@ -28,10 +28,10 @@ import jakarta.validation.Valid import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.AddressGateOutput -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt index 2370a63f9..be1c13523 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt @@ -24,7 +24,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.gate.dto.BusinessPartnerCandidateDto -import org.eclipse.tractusx.bpdm.gate.dto.response.TypeMatchResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt index dce913b9e..a9a1011dc 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt @@ -29,9 +29,9 @@ import jakarta.validation.Valid import jakarta.validation.constraints.NotEmpty import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType -import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.HttpExchange @@ -60,7 +60,7 @@ interface GateChangelogApi { @ParameterObject @Valid paginationRequest: PaginationRequest, @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam(required = false) fromTime: Instant?, @RequestBody(required = true) @NotEmpty(message = "Input externalIds list cannot be empty.") externalIds: Collection - ): PageChangeLogResponse + ): PageChangeLogResponse @Operation( summary = "Get business partner changelog entries by timestamp or LSA type", @@ -79,6 +79,6 @@ interface GateChangelogApi { @ParameterObject @Valid paginationRequest: PaginationRequest, @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam fromTime: Instant?, @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType? - ): PageResponse + ): PageResponse } \ No newline at end of file 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 f53aa4e75..206ffccf6 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 @@ -28,10 +28,10 @@ import jakarta.validation.Valid import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateOutput -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* 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 0e1a32f37..08cb9e8ee 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 @@ -28,10 +28,10 @@ import jakarta.validation.Valid import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.SiteGateOutput -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClient.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClient.kt index 47c0b2458..526c53d82 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClient.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClient.kt @@ -19,10 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.api.client -import org.eclipse.tractusx.bpdm.gate.api.GateAddressApi -import org.eclipse.tractusx.bpdm.gate.api.GateBusinessPartnerApi -import org.eclipse.tractusx.bpdm.gate.api.GateLegalEntityApi -import org.eclipse.tractusx.bpdm.gate.api.GateSiteApi +import org.eclipse.tractusx.bpdm.gate.api.* interface GateClient { @@ -34,4 +31,6 @@ interface GateClient { fun sites(): GateSiteApi + fun changelog(): GateChangelogApi + } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClientImpl.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClientImpl.kt index 2ac33cd0d..c1a0757fc 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClientImpl.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClientImpl.kt @@ -20,10 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.api.client import org.eclipse.tractusx.bpdm.common.service.ParameterObjectArgumentResolver -import org.eclipse.tractusx.bpdm.gate.api.GateAddressApi -import org.eclipse.tractusx.bpdm.gate.api.GateBusinessPartnerApi -import org.eclipse.tractusx.bpdm.gate.api.GateLegalEntityApi -import org.eclipse.tractusx.bpdm.gate.api.GateSiteApi +import org.eclipse.tractusx.bpdm.gate.api.* import org.springframework.web.reactive.function.client.WebClient import org.springframework.web.reactive.function.client.support.WebClientAdapter import org.springframework.web.service.invoker.HttpServiceProxyFactory @@ -43,6 +40,7 @@ class GateClientImpl( private val gateClientBusinessPartner by lazy { httpServiceProxyFactory.createClient(GateBusinessPartnerApi::class.java) } private val gateClientLegalEntity by lazy { httpServiceProxyFactory.createClient(GateLegalEntityApi::class.java) } private val gateClientSite by lazy { httpServiceProxyFactory.createClient(GateSiteApi::class.java) } + private val gateClientChangelog by lazy { httpServiceProxyFactory.createClient(GateChangelogApi::class.java) } override fun addresses() = gateClientAddress @@ -52,6 +50,8 @@ class GateClientImpl( override fun sites() = gateClientSite + override fun changelog() = gateClientChangelog + } diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/exception/GateErrorCodes.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/exception/GateErrorCodes.kt index 9cf123d79..8a45163c7 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/exception/GateErrorCodes.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/exception/GateErrorCodes.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.exception +package org.eclipse.tractusx.bpdm.gate.api.exception import io.swagger.v3.oas.annotations.media.Schema diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/PaginationStartAfterRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/PaginationStartAfterRequest.kt index c1fdd4742..c3972bb99 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/PaginationStartAfterRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/PaginationStartAfterRequest.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto.request +package org.eclipse.tractusx.bpdm.gate.api.model.request import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.media.Schema diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ValidationResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt similarity index 66% rename from bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ValidationResponse.kt rename to bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt index eb5c4322d..c51583e8a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ValidationResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt @@ -1,3 +1,4 @@ + /******************************************************************************* * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation * @@ -17,19 +18,17 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto.response +package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema +import java.time.Instant -@Schema(description = "Contains overall result of a sharing process validation request") -data class ValidationResponse( - @Schema(description = "Overall status of the result of the validation") - val status: ValidationStatus, - @Schema(description = "All found validation errors of this record") - val errors: Collection +@Schema(name = "ChangelogResponse", description = "Changelog entry for a business partner") +data class ChangelogResponse( + @Schema(description = "External ID of the changelog entry") + val externalId: String, + @Schema(description = "The type of the change") + val businessPartnerType: LsaType, + @Schema(description = "The timestamp of the operation") + val createdAt: Instant ) - -enum class ValidationStatus { - OK, - ERROR -} \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ErrorInfo.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ErrorInfo.kt index 26374b1c3..415c014b2 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ErrorInfo.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ErrorInfo.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.dto.response import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.gate.exception.ErrorCode +import org.eclipse.tractusx.bpdm.gate.api.exception.ErrorCode @Schema(title = "ErrorInfo", description = "Holds information about failures") data class ErrorInfo( diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt index e935d16fe..4f73895ba 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt @@ -17,10 +17,11 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto.response +package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.gate.exception.ChangeLogOutputError +import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError +import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo @Schema(description = "Paginated collection of results") data class PageChangeLogResponse( diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageOutputResponse.kt index bb0ff4d4b..011645b72 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageOutputResponse.kt @@ -17,10 +17,11 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto.response +package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.gate.exception.BusinessPartnerOutputError +import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError +import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo @Schema(description = "Paginated collection of results") data class PageOutputResponse( diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageStartAfterResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageStartAfterResponse.kt index 07dea81c7..b465826a3 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageStartAfterResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageStartAfterResponse.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto.response +package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/TypeMatchResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/TypeMatchResponse.kt index 987ef442b..6c4716602 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/TypeMatchResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/TypeMatchResponse.kt @@ -17,16 +17,22 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto.response +package org.eclipse.tractusx.bpdm.gate.api.model.response data class TypeMatchResponse( val score: Float, - val type: LsaType + val type: OptionalLsaType ) -enum class LsaType { +enum class OptionalLsaType { LegalEntity, Site, Address, None } + +enum class LsaType { + LegalEntity, + Site, + Address +} diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ValidationResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ValidationResponse.kt index eb5c4322d..b1ff38577 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ValidationResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ValidationResponse.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto.response +package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema 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 4fdd6689b..910b1a11e 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,21 +20,20 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.gate.api.GateAddressApi - import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.AddressGateOutput -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.service.AddressService import org.eclipse.tractusx.bpdm.gate.service.ValidationService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.RestController @RestController class AddressController( diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt index 5c70ef459..95eace32d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.gate.api.GateBusinessPartnerApi import org.eclipse.tractusx.bpdm.gate.dto.BusinessPartnerCandidateDto -import org.eclipse.tractusx.bpdm.gate.dto.response.TypeMatchResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse import org.eclipse.tractusx.bpdm.gate.exception.BpdmInvalidPartnerException import org.eclipse.tractusx.bpdm.gate.service.TypeMatchingService import org.springframework.web.bind.annotation.RestController diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 6eec32a86..deb2391d8 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -22,28 +22,30 @@ 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.gate.api.GateChangelogApi -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType -import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse import org.eclipse.tractusx.bpdm.gate.service.ChangelogService import org.springframework.validation.annotation.Validated -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.RestController import java.time.Instant @RestController @Validated -class ChangelogController ( - private val changelogService: ChangelogService - ) : GateChangelogApi { +class ChangelogController( + private val changelogService: ChangelogService +) : GateChangelogApi { - override fun getChangelogEntriesExternalId(paginationRequest: PaginationRequest, fromTime: Instant?, externalIds: Collection - ): PageChangeLogResponse { - return changelogService.getChangeLogByExternalId(externalIds,fromTime,paginationRequest.page,paginationRequest.size) + override fun getChangelogEntriesExternalId( + paginationRequest: PaginationRequest, fromTime: Instant?, externalIds: Collection + ): PageChangeLogResponse { + return changelogService.getChangeLogByExternalId(externalIds, fromTime, paginationRequest.page, paginationRequest.size) } - override fun getChangelogEntriesLsaType(paginationRequest: PaginationRequest, fromTime: Instant?, lsaType: LsaType? - ): PageResponse { - return changelogService.getChangeLogByLsaType(lsaType,fromTime,paginationRequest.page,paginationRequest.size) + override fun getChangelogEntriesLsaType( + paginationRequest: PaginationRequest, fromTime: Instant?, lsaType: LsaType? + ): PageResponse { + return changelogService.getChangeLogByLsaType(lsaType, fromTime, paginationRequest.page, 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 1dd38a197..83a7a58b2 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 @@ -17,44 +17,6 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.gate.api.GateLegalEntityApi @@ -63,15 +25,15 @@ import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateOutput -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.service.LegalEntityService import org.eclipse.tractusx.bpdm.gate.service.ValidationService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.RestController @RestController class LegalEntityController( 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 5946539e9..9d8311958 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 @@ -25,15 +25,15 @@ import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.SiteGateOutput -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.service.SiteService import org.eclipse.tractusx.bpdm.gate.service.ValidationService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.RestController @RestController class SiteController( diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/ChangelogDto.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/ChangelogDto.kt deleted file mode 100644 index 01036f22a..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/ChangelogDto.kt +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType - - -data class ChangelogDto( - val externalId: String, - val lsaType: LsaType -) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt deleted file mode 100644 index c1fdd4742..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/request/PaginationStartAfterRequest.kt +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto.request - -import io.swagger.v3.oas.annotations.Parameter -import io.swagger.v3.oas.annotations.media.Schema -import jakarta.validation.constraints.Max -import jakarta.validation.constraints.Min - -@Schema(name = "PaginationStartAfterRequest", description = "Defines pagination information for requesting collection results") -data class PaginationStartAfterRequest( - @field:Parameter( - description = "Value used to indicate which page to retrieve. When this value is not provided, the first page is returned." + - "The nextStartAfter value from the response can then be used to request subsequent pages." - ) - val startAfter: String?, - @field:Parameter( - description = "Size of each page", schema = - Schema(defaultValue = "10") - ) - @field:Min(1) - @field:Max(100) - val limit: Int = 10 -) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ErrorInfo.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ErrorInfo.kt index 26374b1c3..415c014b2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ErrorInfo.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ErrorInfo.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.dto.response import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.gate.exception.ErrorCode +import org.eclipse.tractusx.bpdm.gate.api.exception.ErrorCode @Schema(title = "ErrorInfo", description = "Holds information about failures") data class ErrorInfo( diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt deleted file mode 100644 index e935d16fe..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageChangeLogResponse.kt +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto.response - -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.gate.exception.ChangeLogOutputError - -@Schema(description = "Paginated collection of results") -data class PageChangeLogResponse( - @Schema(description = "Total number of all results in all pages") - val totalElements: Long, - @Schema(description = "Total number pages") - val totalPages: Int, - @Schema(description = "Current page number") - val page: Int, - @Schema(description = "Number of results in the page") - val contentSize: Int, - @Schema(description = "Collection of results in the page") - val content: Collection, - @Schema(description = "Number of entries in the page that have been omitted due to being invalid (error)") - val invalidEntries: Int, - @Schema(description = "Infos about the entries with errors") - val errors: Collection>, -) - diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageOutputResponse.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageOutputResponse.kt deleted file mode 100644 index bb0ff4d4b..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageOutputResponse.kt +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto.response - -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.gate.exception.BusinessPartnerOutputError - -@Schema(description = "Paginated collection of results") -data class PageOutputResponse( - @Schema(description = "Total number of all results in all pages") - val total: Int, - @Schema(description = "Value to be used as startAfter in request for next page. Value is only sent if more data exists for a next page.") - val nextStartAfter: String?, - @Schema(description = "Collection of results in the page") - val content: Collection, - @Schema(description = "Number of entries in the page that have been omitted due to being invalid (error or still pending)") - val invalidEntries: Int, - @Schema(description = "External ids of the entries which are still pending") - val pending: Collection, - @Schema(description = "Infos about the entries with errors") - val errors: Collection>, -) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageStartAfterResponse.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageStartAfterResponse.kt deleted file mode 100644 index 07dea81c7..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/PageStartAfterResponse.kt +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto.response - -import io.swagger.v3.oas.annotations.media.Schema - -@Schema(description = "Paginated collection of results") -data class PageStartAfterResponse( - @Schema(description = "Total number of all results in all pages") - val total: Int, - @Schema(description = "Value to be used as startAfter in request for next page. Value is only sent if more data exists for a next page.") - val nextStartAfter: String?, - @Schema(description = "Collection of results in the page") - val content: Collection, - @Schema(description = "Number of entries in the page that have been omitted due to being invalid") - val invalidEntries: Int -) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/TypeMatchResponse.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/TypeMatchResponse.kt deleted file mode 100644 index 987ef442b..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/TypeMatchResponse.kt +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto.response - -data class TypeMatchResponse( - val score: Float, - val type: LsaType -) - -enum class LsaType { - LegalEntity, - Site, - Address, - None -} diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt index 1738c2b48..9eaa43fe3 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt @@ -21,12 +21,12 @@ package org.eclipse.tractusx.bpdm.gate.entity import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.BaseEntity -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType @Entity @Table(name = "changelog_entries") -class ChangelogEntity ( +class ChangelogEntity( @Column(name = "external_id", nullable = false, updatable = false) val externalId: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt index dcebbabee..75bcf768c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.exception import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.gate.api.exception.ErrorCode /** * For every combination of possible errors a separate enum class is defined extending this marker interface. diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/model/SharingStatusEvaluationResult.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/model/SharingStatusEvaluationResult.kt index 47eb89efc..8988fa728 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/model/SharingStatusEvaluationResult.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/model/SharingStatusEvaluationResult.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.model import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.exception.BusinessPartnerOutputError +import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError data class SharingStatusEvaluationResult( val validExternalIds: Collection, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index 7a46e589e..aade6279e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -19,7 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.repository -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.springframework.data.jpa.domain.Specification import org.springframework.data.jpa.repository.JpaRepository @@ -27,7 +27,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor import java.time.Instant -interface ChangelogRepository : JpaRepository , JpaSpecificationExecutor { +interface ChangelogRepository : JpaRepository, JpaSpecificationExecutor { object Specs { @@ -59,11 +59,10 @@ interface ChangelogRepository : JpaRepository , JpaSpecif fun byLsaType(lsaType: LsaType?) = Specification { root, _, builder -> lsaType?.let { - builder.equal(root.get(ChangelogEntity::businessPartnerType.name),lsaType) + builder.equal(root.get(ChangelogEntity::businessPartnerType.name), lsaType) } } } - } 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 6673a1b2d..3c191e31f 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 @@ -28,9 +28,10 @@ import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.AddressGateOutput -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.exception.SaasInvalidRecordException import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException @@ -252,8 +253,8 @@ class AddressService( val parentType = parentId?.let { saasClient.getBusinessPartner(it).businessPartner }?.let { typeMatchingService.determineType(it) } return when (parentType) { - LsaType.LegalEntity -> inputSaasMappingService.toInputAddress(partner, parentId, null) - LsaType.Site -> inputSaasMappingService.toInputAddress(partner, null, parentId) + OptionalLsaType.LegalEntity -> inputSaasMappingService.toInputAddress(partner, parentId, null) + OptionalLsaType.Site -> inputSaasMappingService.toInputAddress(partner, null, parentId) else -> throw SaasInvalidRecordException(parentId) } } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index e80bafe95..c81a2dce3 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -20,11 +20,11 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType -import org.eclipse.tractusx.bpdm.gate.dto.response.PageChangeLogResponse -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity -import org.eclipse.tractusx.bpdm.gate.exception.ChangeLogOutputError +import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse +import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byCreatedAtGreaterThan import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byExternalIdsIn @@ -37,15 +37,19 @@ import java.time.Instant @Service class ChangelogService(private val changelogRepository: ChangelogRepository) { - fun getChangeLogByExternalId(externalIds: Collection, createdAt: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { + fun getChangeLogByExternalId(externalIds: Collection, createdAt: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { - val spec = Specification.allOf(byExternalIdsIn(externalIds = externalIds),byCreatedAtGreaterThan(createdAt = createdAt)) + val spec = Specification.allOf(byExternalIdsIn(externalIds = externalIds), byCreatedAtGreaterThan(createdAt = createdAt)) val pageable = PageRequest.of(page, pageSize) - val pageResponse = changelogRepository.findAll(spec,pageable) + val pageResponse = changelogRepository.findAll(spec, pageable) + val pageDto = pageResponse.map { + it.toGateDto() + } + val errorInfoList = externalIds.filterNot { id -> - pageResponse.content.any { it.externalId == id } + pageDto.content.any { it.externalId == id } }.map { ErrorInfo( ChangeLogOutputError.ExternalIdNotFound, @@ -55,26 +59,31 @@ class ChangelogService(private val changelogRepository: ChangelogRepository) { } return PageChangeLogResponse( - page = page, totalElements = pageResponse.totalElements, - totalPages = pageResponse.totalPages, - contentSize = pageResponse.content.size, - content = pageResponse.content, + page = page, totalElements = pageDto.totalElements, + totalPages = pageDto.totalPages, + contentSize = pageDto.content.size, + content = pageDto.content, invalidEntries = errorInfoList.size, errors = errorInfoList ) } - fun getChangeLogByLsaType(lsaType: LsaType?, createdAt: Instant?, page: Int, pageSize: Int): PageResponse { + fun getChangeLogByLsaType(lsaType: LsaType?, createdAt: Instant?, page: Int, pageSize: Int): PageResponse { val spec = Specification.allOf(byCreatedAtGreaterThan(createdAt = createdAt), byLsaType(lsaType)) val pageable = PageRequest.of(page, pageSize) - val pageResponse = changelogRepository.findAll(spec,pageable) + val pageResponse = changelogRepository.findAll(spec, pageable) + + val pageDto = pageResponse.map { + it.toGateDto() + } return PageResponse( - page = page, totalElements = pageResponse.totalElements, - totalPages = pageResponse.totalPages, - contentSize = pageResponse.content.size, - content = pageResponse.content, + page = page, + totalElements = pageDto.totalElements, + totalPages = pageDto.totalPages, + contentSize = pageDto.content.size, + content = pageDto.content, ) } } \ No newline at end of file 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 99b9f7d8b..059805785 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 @@ -29,9 +29,9 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateOutput -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.stereotype.Service diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OutputSaasMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OutputSaasMappingService.kt index 94293839c..1c7eb02e2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OutputSaasMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OutputSaasMappingService.kt @@ -27,7 +27,7 @@ import org.eclipse.tractusx.bpdm.common.dto.saas.isError import org.eclipse.tractusx.bpdm.common.service.SaasMappings import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.exception.BusinessPartnerOutputError +import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError import org.eclipse.tractusx.bpdm.gate.filterNotNullKeys import org.eclipse.tractusx.bpdm.gate.model.BusinessPartnerSaasWithBpn import org.eclipse.tractusx.bpdm.gate.model.BusinessPartnerSaasWithExternalId diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/entity/ChangelogEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt similarity index 59% rename from bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/entity/ChangelogEntity.kt rename to bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index f74fea513..89b446420 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/entity/ChangelogEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -17,23 +17,24 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.entity -import jakarta.persistence.* -import org.eclipse.tractusx.bpdm.common.model.BaseEntity -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType +package org.eclipse.tractusx.bpdm.gate.service +import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse +import org.springframework.data.domain.Page -@Entity -@Table(name = "changelog_entries") -class ChangelogEntity ( - @Column(name = "external_id", nullable = false, updatable = false) - val externalId: String, - @Enumerated(EnumType.STRING) - @Column(name = "business_partner_type", nullable = false, updatable = false) - val businessPartnerType: LsaType - -) : BaseEntity() +fun Page.toDto(dtoContent: Collection): PageResponse { + return PageResponse(this.totalElements, this.totalPages, this.number, this.numberOfElements, dtoContent) +} +fun ChangelogEntity.toGateDto(): ChangelogResponse { + return ChangelogResponse( + externalId, + businessPartnerType, + createdAt + ) +} 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 b0d7e9b78..5c87f2b9e 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 @@ -30,9 +30,9 @@ import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.dto.SiteGateOutput -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.exception.SaasInvalidRecordException import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt index 326b685e5..5d59b4171 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt @@ -25,8 +25,8 @@ import org.eclipse.tractusx.bpdm.common.dto.saas.ReferenceDataLookupRequestSaas import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.eclipse.tractusx.bpdm.gate.config.TypeMatchConfigProperties import org.eclipse.tractusx.bpdm.gate.dto.BusinessPartnerCandidateDto -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType -import org.eclipse.tractusx.bpdm.gate.dto.response.TypeMatchResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse import org.springframework.stereotype.Service @Service @@ -55,10 +55,10 @@ class TypeMatchingService( val bestOverall = response.values.maxOfOrNull { it.matchingProfile.matchingScores.overall.value } ?: 0f return if (bestOverall >= typeMatchConfigProperties.legalEntityThreshold) - TypeMatchResponse(bestOverall, LsaType.LegalEntity) + TypeMatchResponse(bestOverall, OptionalLsaType.LegalEntity) else - TypeMatchResponse(1f - bestOverall, LsaType.None) + TypeMatchResponse(1f - bestOverall, OptionalLsaType.None) } @@ -70,20 +70,20 @@ class TypeMatchingService( val typeGroups = parents.groupBy { determineType(it) } typeGroups.keys - .filterNot { it == LsaType.LegalEntity || it == LsaType.Site } + .filterNot { it == OptionalLsaType.LegalEntity || it == OptionalLsaType.Site } .forEach { invalidGroup -> typeGroups[invalidGroup]!!.forEach { logger.warn { "Business Partner with ID ${it.id} is parent with invalid type $invalidGroup" } } } - return Pair(typeGroups[LsaType.LegalEntity] ?: emptyList(), typeGroups[LsaType.Site] ?: emptyList()) + return Pair(typeGroups[OptionalLsaType.LegalEntity] ?: emptyList(), typeGroups[OptionalLsaType.Site] ?: emptyList()) } - fun determineType(partner: BusinessPartnerSaas): LsaType { + fun determineType(partner: BusinessPartnerSaas): OptionalLsaType { if (partner.types.isEmpty()) { logger.warn { "Partner with ID ${partner.id} does not have any type" } - return LsaType.None + return OptionalLsaType.None } if (partner.types.size > 1) { @@ -92,10 +92,10 @@ class TypeMatchingService( val partnerType = partner.types.first() return when (partnerType.technicalKey) { - saasConfigProperties.legalEntityType -> LsaType.LegalEntity - saasConfigProperties.siteType -> LsaType.Site - saasConfigProperties.addressType -> LsaType.Address - else -> LsaType.None + saasConfigProperties.legalEntityType -> OptionalLsaType.LegalEntity + saasConfigProperties.siteType -> OptionalLsaType.Site + saasConfigProperties.addressType -> OptionalLsaType.Address + else -> OptionalLsaType.None } } } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt index 07acc4a96..c1dcfb3d1 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt @@ -27,8 +27,8 @@ import org.eclipse.tractusx.bpdm.common.service.ValidationMapper import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationStatus +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus import org.springframework.stereotype.Service /** 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 7c6e3b17b..231af23f8 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 @@ -46,10 +46,10 @@ import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationStatus +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_RELATIONS_PATH @@ -175,10 +175,10 @@ internal class AddressControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.addresses().getAddressByExternalId("NONEXISTENT_BPN") - }catch (e: WebClientResponseException){ - assertEquals(HttpStatus.NOT_FOUND,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.NOT_FOUND, e.statusCode) } } @@ -193,9 +193,9 @@ internal class AddressControllerInputIT @Autowired constructor( .willReturn(badRequest()) ) - try{ + try { gateClient.addresses().getAddressByExternalId(SaasValues.legalEntityRequest1.externalId.toString()) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() Assertions.assertTrue(statusCodeValue in 500..599) @@ -228,9 +228,9 @@ internal class AddressControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.addresses().getAddressByExternalId(SaasValues.addressBusinessPartnerWithRelations1.externalId.toString()) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() Assertions.assertTrue(statusCodeValue in 500..599) @@ -414,9 +414,9 @@ internal class AddressControllerInputIT @Autowired constructor( .willReturn(badRequest()) ) - try{ + try { gateClient.addresses().getAddresses(PaginationStartAfterRequest("")) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() Assertions.assertTrue(statusCodeValue in 500..599) @@ -431,12 +431,12 @@ internal class AddressControllerInputIT @Autowired constructor( @Test fun `get addresses, pagination limit exceeded`() { - val paginationRequest = PaginationStartAfterRequest( "" ,limit = 999999) + val paginationRequest = PaginationStartAfterRequest("", limit = 999999) - try{ + try { gateClient.addresses().getAddresses(paginationRequest) - }catch (e: WebClientResponseException){ - assertEquals(HttpStatus.BAD_REQUEST,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } } @@ -605,17 +605,18 @@ internal class AddressControllerInputIT @Autowired constructor( ) - try{ + try { gateClient.addresses().upsertAddresses(addresses) - }catch (e: WebClientResponseException){ - assertEquals(HttpStatus.OK,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.OK, e.statusCode) } val upsertAddressesRequest = wireMockServer.deserializeMatchedRequests(stubMappingUpsertAddresses, objectMapper).single() assertThat(upsertAddressesRequest.businessPartners).containsExactlyInAnyOrderElementsOf(expectedAddresses) // check that "delete relations" was called in SaaS as expected - val deleteRelationsRequestSaas = wireMockServer.deserializeMatchedRequests(stubMappingDeleteRelations, objectMapper).single() + val deleteRelationsRequestSaas = + wireMockServer.deserializeMatchedRequests(stubMappingDeleteRelations, objectMapper).single() assertThat(deleteRelationsRequestSaas.relations).containsExactlyInAnyOrderElementsOf(expectedDeletedRelations) val upsertRelationsRequest = wireMockServer.deserializeMatchedRequests(stubMappingUpsertRelations, objectMapper).single() @@ -652,10 +653,10 @@ internal class AddressControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.addresses().upsertAddresses(addresses) - }catch (e: WebClientResponseException){ - assertEquals(HttpStatus.BAD_REQUEST,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } } @@ -696,12 +697,6 @@ internal class AddressControllerInputIT @Autowired constructor( assertEquals(HttpStatus.BAD_REQUEST,e.statusCode) } - /*webTestClient.put().uri(GATE_API_INPUT_ADDRESSES_PATH) - .contentType(MediaType.APPLICATION_JSON) - .bodyValue(objectMapper.writeValueAsString(addresses)) - .exchange() - .expectStatus() - .isBadRequest*/ } /** @@ -717,10 +712,10 @@ internal class AddressControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.addresses().upsertAddresses(addresses) - }catch (e: WebClientResponseException){ - assertEquals(HttpStatus.BAD_REQUEST,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } } @@ -738,10 +733,10 @@ internal class AddressControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.addresses().upsertAddresses(addresses) - }catch (e: WebClientResponseException){ - assertEquals(HttpStatus.BAD_REQUEST,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } } 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 28088256d..a0a425fa3 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 @@ -47,10 +47,10 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.exception.BusinessPartnerOutputError +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError import org.eclipse.tractusx.bpdm.gate.util.CommonValues import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt index b27ff6f5c..ad7dd4155 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt @@ -46,8 +46,8 @@ import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.config.TypeMatchConfigProperties -import org.eclipse.tractusx.bpdm.gate.dto.response.LsaType -import org.eclipse.tractusx.bpdm.gate.dto.response.TypeMatchResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse import org.eclipse.tractusx.bpdm.gate.util.EndpointValues import org.eclipse.tractusx.bpdm.gate.util.RequestValues import org.junit.jupiter.api.Assertions.assertEquals @@ -101,7 +101,7 @@ class BusinessPartnerControllerIT @Autowired constructor( } val expectedScore = typeMatchConfigProperties.legalEntityThreshold - val expected = TypeMatchResponse(expectedScore, LsaType.LegalEntity) + val expected = TypeMatchResponse(expectedScore, OptionalLsaType.LegalEntity) setLookupMockResponse(expectedScore) @@ -126,7 +126,7 @@ class BusinessPartnerControllerIT @Autowired constructor( } val mockedScore = (typeMatchConfigProperties.legalEntityThreshold - 1.0f).coerceAtLeast(0.0f) - val expected = TypeMatchResponse(1f - mockedScore, LsaType.None) + val expected = TypeMatchResponse(1f - mockedScore, OptionalLsaType.None) setLookupMockResponse(mockedScore) @@ -152,10 +152,10 @@ class BusinessPartnerControllerIT @Autowired constructor( setLookupMockResponse(0.5f) - try{ + try { gateClient.businessPartners().determineLsaType(givenCandidate) - }catch (e: WebClientResponseException){ - assertEquals(HttpStatus.OK,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.OK, e.statusCode) } } @@ -177,10 +177,10 @@ class BusinessPartnerControllerIT @Autowired constructor( setLookupMockResponse(0.5f) - try{ + try { gateClient.businessPartners().determineLsaType(givenCandidate) - }catch (e: WebClientResponseException){ - assertEquals(HttpStatus.OK,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.OK, e.statusCode) } } @@ -202,9 +202,9 @@ class BusinessPartnerControllerIT @Autowired constructor( setLookupMockResponse(0.5f) - try{ + try { gateClient.businessPartners().determineLsaType(givenCandidate) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() assertTrue(statusCodeValue in 400..499) 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 cfb414fed..374f83be0 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 @@ -30,10 +30,10 @@ import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationStatus +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus import org.eclipse.tractusx.bpdm.gate.util.EndpointValues import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.GATE_API_INPUT_LEGAL_ENTITIES_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH @@ -110,10 +110,10 @@ internal class LegalEntityControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.legalEntities().upsertLegalEntities(legalEntities) - }catch (e: WebClientResponseException){ - assertEquals(HttpStatus.OK,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.OK, e.statusCode) } val body = wireMockServer.allServeEvents.single().request.bodyAsString @@ -152,10 +152,10 @@ internal class LegalEntityControllerInputIT @Autowired constructor( RequestValues.legalEntityGateInputRequest1.copy(externalId = "external-2") ) - try{ + try { gateClient.legalEntities().upsertLegalEntities(legalEntities) - } catch (e: WebClientResponseException){ - assertEquals(HttpStatus.BAD_REQUEST,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } } @@ -170,10 +170,10 @@ internal class LegalEntityControllerInputIT @Autowired constructor( RequestValues.legalEntityGateInputRequest1.copy() ) - try{ + try { gateClient.legalEntities().upsertLegalEntities(legalEntities) - } catch (e: WebClientResponseException){ - assertEquals(HttpStatus.BAD_REQUEST,e.statusCode) + } catch (e: WebClientResponseException) { + assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } } @@ -194,9 +194,9 @@ internal class LegalEntityControllerInputIT @Autowired constructor( .willReturn(badRequest()) ) - try{ + try { gateClient.legalEntities().upsertLegalEntities(legalEntities) - } catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() assertTrue(statusCodeValue in 500..599) @@ -256,9 +256,9 @@ internal class LegalEntityControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.legalEntities().getLegalEntityByExternalId("nonexistent-externalid123") - } catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { assertEquals(HttpStatus.NOT_FOUND, e.statusCode) } @@ -275,9 +275,9 @@ internal class LegalEntityControllerInputIT @Autowired constructor( .willReturn(badRequest()) ) - try{ + try { gateClient.legalEntities().getLegalEntityByExternalId(SaasValues.legalEntityRequest1.externalId.toString()) - } catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() assertTrue(statusCodeValue in 500..599) @@ -310,9 +310,9 @@ internal class LegalEntityControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.legalEntities().getLegalEntityByExternalId(SaasValues.legalEntityRequest1.externalId.toString()) - } catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() assertTrue(statusCodeValue in 500..599) @@ -442,10 +442,10 @@ internal class LegalEntityControllerInputIT @Autowired constructor( .willReturn(badRequest()) ) - try{ + try { val paginationValue = PaginationStartAfterRequest("") gateClient.legalEntities().getLegalEntities(paginationValue) - } catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() assertTrue(statusCodeValue in 500..599) @@ -464,10 +464,10 @@ internal class LegalEntityControllerInputIT @Autowired constructor( @Test fun `get legal entities, pagination limit exceeded`() { - try{ + try { val paginationValue = PaginationStartAfterRequest("", 999999) gateClient.legalEntities().getLegalEntities(paginationValue) - } catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } @@ -497,7 +497,7 @@ internal class LegalEntityControllerInputIT @Autowired constructor( ) ) - val actualResponse = gateClient.legalEntities().validateLegalEntity(legalEntity) + val actualResponse = gateClient.legalEntities().validateLegalEntity(legalEntity) val expectedResponse = ValidationResponse(ValidationStatus.OK, emptyList()) 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 2f42e60f6..4891d7dee 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 @@ -27,10 +27,10 @@ import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.exception.BusinessPartnerOutputError +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError import org.eclipse.tractusx.bpdm.gate.util.CommonValues import org.eclipse.tractusx.bpdm.gate.util.EndpointValues import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH 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 af606343f..128c4dbb7 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 @@ -27,10 +27,10 @@ import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ValidationStatus +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_DELETE_RELATIONS_PATH @@ -121,9 +121,9 @@ internal class SiteControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.sites().getSiteByExternalId("nonexistent-externalid123") - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { assertEquals(HttpStatus.NOT_FOUND, e.statusCode) } @@ -140,9 +140,9 @@ internal class SiteControllerInputIT @Autowired constructor( .willReturn(badRequest()) ) - try{ + try { gateClient.sites().getSiteByExternalId(SaasValues.legalEntityRequest1.externalId.toString()) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() assertTrue(statusCodeValue in 500..599) @@ -175,9 +175,9 @@ internal class SiteControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.sites().getSiteByExternalId(SaasValues.siteBusinessPartnerWithRelations1.externalId.toString()) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() assertTrue(statusCodeValue in 500..599) @@ -227,7 +227,7 @@ internal class SiteControllerInputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter,limit) + val paginationValue = PaginationStartAfterRequest(startAfter, limit) val pageResponse = gateClient.sites().getSites(paginationValue) assertThat(pageResponse).isEqualTo( @@ -285,7 +285,7 @@ internal class SiteControllerInputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter,limit) + val paginationValue = PaginationStartAfterRequest(startAfter, limit) val pageResponse = gateClient.sites().getSites(paginationValue) assertThat(pageResponse).isEqualTo( @@ -309,20 +309,16 @@ internal class SiteControllerInputIT @Autowired constructor( .willReturn(badRequest()) ) - val paginationValue = PaginationStartAfterRequest("",10) + val paginationValue = PaginationStartAfterRequest("", 10) - try{ + try { gateClient.sites().getSites(paginationValue) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { val statusCode: HttpStatusCode = e.statusCode val statusCodeValue: Int = statusCode.value() assertTrue(statusCodeValue in 500..599) } -// webTestClient.get().uri(GATE_API_INPUT_SITES_PATH) -// .exchange() -// .expectStatus() -// .is5xxServerError } /** @@ -332,11 +328,11 @@ internal class SiteControllerInputIT @Autowired constructor( @Test fun `get sites, pagination limit exceeded`() { - val paginationValue = PaginationStartAfterRequest("",999999) + val paginationValue = PaginationStartAfterRequest("", 999999) - try{ + try { gateClient.sites().getSites(paginationValue) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } @@ -485,9 +481,9 @@ internal class SiteControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.sites().upsertSites(sites) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { assertEquals(HttpStatus.OK, e.statusCode) } @@ -496,7 +492,8 @@ internal class SiteControllerInputIT @Autowired constructor( assertThat(upsertSitesRequest.businessPartners).containsExactlyInAnyOrderElementsOf(expectedSites) // check that "delete relations" was called in SaaS as expected - val deleteRelationsRequestSaas = wireMockServer.deserializeMatchedRequests(stubMappingDeleteRelations, objectMapper).single() + val deleteRelationsRequestSaas = + wireMockServer.deserializeMatchedRequests(stubMappingDeleteRelations, objectMapper).single() assertThat(deleteRelationsRequestSaas.relations).containsExactlyInAnyOrderElementsOf(expectedDeletedRelations) // check that "upsert relations" was called in SaaS as expected @@ -539,9 +536,9 @@ internal class SiteControllerInputIT @Autowired constructor( ) ) - try{ + try { gateClient.sites().upsertSites(sites) - }catch (e: WebClientResponseException){ + } catch (e: WebClientResponseException) { assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } 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 02f3705df..733f30e80 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 @@ -28,10 +28,10 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.dto.request.PaginationStartAfterRequest +import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.dto.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.exception.BusinessPartnerOutputError +import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError import org.eclipse.tractusx.bpdm.gate.util.CommonValues import org.eclipse.tractusx.bpdm.gate.util.EndpointValues import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH @@ -178,7 +178,7 @@ internal class SiteControllerOutputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter,limit) + val paginationValue = PaginationStartAfterRequest(startAfter, limit) val pageResponseValue = gateClient.sites().getSitesOutput(paginationValue, emptyList()) assertThat(pageResponseValue).isEqualTo( @@ -291,7 +291,7 @@ internal class SiteControllerOutputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter,limit) + val paginationValue = PaginationStartAfterRequest(startAfter, limit) val pageResponseValue = gateClient.sites().getSitesOutput(paginationValue, listOf(CommonValues.externalIdSite1, CommonValues.externalIdSite2)) assertThat(pageResponseValue).isEqualTo( From 36b40995b499d493b28d1ae5fa8c244552a6a62c Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Wed, 22 Mar 2023 18:35:50 +0000 Subject: [PATCH 14/16] test(Gate): Add controller upsert for creating changelog test(Gate): Add unit test for new controller --- .../tractusx/bpdm/gate/api/GateAddressApi.kt | 6 +- .../bpdm/gate/api/GateBusinessPartnerApi.kt | 2 +- .../bpdm/gate/api/GateChangelogApi.kt | 6 +- .../bpdm/gate/api/GateLegalEntityApi.kt | 6 +- .../tractusx/bpdm/gate/api/GateSiteApi.kt | 6 +- .../gate/api/model/AddressGateInputRequest.kt | 2 +- .../api/model/AddressGateInputResponse.kt | 2 +- .../bpdm/gate/api/model/AddressGateOutput.kt | 2 +- .../api/model/BusinessPartnerCandidateDto.kt | 2 +- .../api/model/LegalEntityGateInputRequest.kt | 2 +- .../api/model/LegalEntityGateInputResponse.kt | 2 +- .../gate/api/model/LegalEntityGateOutput.kt | 2 +- .../gate/api/model/SiteGateInputRequest.kt | 2 +- .../gate/api/model/SiteGateInputResponse.kt | 2 +- .../bpdm/gate/api/model/SiteGateOutput.kt | 2 +- .../api/model/response/ChangelogResponse.kt | 2 +- .../bpdm/gate/api/model/response/ErrorInfo.kt | 2 +- .../model/response/PageChangeLogResponse.kt | 2 +- .../api/model/response/PageOutputResponse.kt | 1 - bpdm-gate/flyway.conf | 2 +- bpdm-gate/pom.xml | 13 + .../bpdm/gate/controller/AddressController.kt | 10 +- .../controller/BusinessPartnerController.kt | 2 +- .../gate/controller/LegalEntityController.kt | 10 +- .../bpdm/gate/controller/SiteController.kt | 10 +- .../bpdm/gate/dto/AddressGateInputRequest.kt | 48 --- .../bpdm/gate/dto/AddressGateInputResponse.kt | 53 --- .../bpdm/gate/dto/AddressGateOutput.kt | 44 -- .../gate/dto/BusinessPartnerCandidateDto.kt | 41 -- .../gate/dto/LegalEntityGateInputRequest.kt | 39 -- .../gate/dto/LegalEntityGateInputResponse.kt | 45 -- .../bpdm/gate/dto/LegalEntityGateOutput.kt | 41 -- .../bpdm/gate/dto/SiteGateInputRequest.kt | 44 -- .../bpdm/gate/dto/SiteGateInputResponse.kt | 49 --- .../tractusx/bpdm/gate/dto/SiteGateOutput.kt | 42 -- .../bpdm/gate/dto/response/ErrorInfo.kt | 34 -- .../bpdm/gate/exception/GateErrorCodes.kt | 41 -- .../model/SharingStatusEvaluationResult.kt | 2 +- .../bpdm/gate/service/AddressService.kt | 15 +- .../bpdm/gate/service/ChangelogService.kt | 14 +- .../gate/service/InputSaasMappingService.kt | 6 +- .../bpdm/gate/service/LegalEntityService.kt | 14 +- .../gate/service/OutputSaasMappingService.kt | 4 +- .../gate/service/SaasLookupMappingService.kt | 2 +- .../gate/service/SaasRequestMappingService.kt | 10 +- .../tractusx/bpdm/gate/service/SiteService.kt | 15 +- .../bpdm/gate/service/TypeMatchingService.kt | 6 +- .../bpdm/gate/service/ValidationService.kt | 6 +- .../src/main/resources/application.properties | 4 +- .../controller/AddressControllerInputIT.kt | 4 +- .../controller/AddressControllerOutputIT.kt | 13 +- .../controller/BusinessPartnerControllerIT.kt | 5 +- .../gate/controller/ChangeLogControllerIT.kt | 397 ++++++++++++++++++ .../LegalEntityControllerInputIT.kt | 9 +- .../LegalEntityControllerOutputIT.kt | 13 +- .../gate/controller/SiteControllerInputIT.kt | 4 +- .../gate/controller/SiteControllerOutputIT.kt | 13 +- .../tractusx/bpdm/gate/util/CommonValues.kt | 7 + .../gate/util/PostgreSQLContextInitializer.kt | 43 ++ .../tractusx/bpdm/gate/util/RequestValues.kt | 8 +- .../tractusx/bpdm/gate/util/ResponseValues.kt | 2 +- .../tractusx/bpdm/pool/api/PoolAddressApi.kt | 7 - .../bpdm/pool/controller/AddressController.kt | 2 - .../bpdm/pool/controller/BpnController.kt | 2 +- .../controller/BusinessPartnerController.kt | 3 - .../pool/controller/AddressControllerIT.kt | 1 + 66 files changed, 592 insertions(+), 660 deletions(-) delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateInputRequest.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateInputResponse.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateOutput.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/BusinessPartnerCandidateDto.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateInputRequest.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateInputResponse.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateOutput.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateInputRequest.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateInputResponse.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateOutput.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ErrorInfo.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt create mode 100644 bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt create mode 100644 bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/PostgreSQLContextInitializer.kt 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 14252f87e..5dc3d83f7 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 @@ -25,9 +25,9 @@ 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 jakarta.validation.Valid -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt index be1c13523..0f0ff016d 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt @@ -23,7 +23,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.gate.dto.BusinessPartnerCandidateDto +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt index a9a1011dc..7b553819f 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt @@ -51,7 +51,6 @@ interface GateChangelogApi { value = [ ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), - ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) ] ) @PostMapping("/search") @@ -70,15 +69,14 @@ interface GateChangelogApi { value = [ ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), - ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) ] ) @PostMapping("/filter") @PostExchange("/filter") fun getChangelogEntriesLsaType( @ParameterObject @Valid paginationRequest: PaginationRequest, - @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam fromTime: Instant?, - @Parameter(description = "LSA Type") @RequestParam lsaType: LsaType? + @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam(required = false) fromTime: Instant?, + @Parameter(description = "LSA Type") @RequestParam(required = false) lsaType: LsaType? ): PageResponse } \ No newline at end of file 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 206ffccf6..3811a9add 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 @@ -25,9 +25,9 @@ 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 jakarta.validation.Valid -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse 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 08cb9e8ee..c8ba106fd 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 @@ -25,9 +25,9 @@ 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 jakarta.validation.Valid -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt index 27e64a946..4e5a83a83 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt index db4c1c7b2..e18b6ba18 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt index aa6f92d4f..a77842850 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt index eebf74329..57c9fd0be 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import io.swagger.v3.oas.annotations.media.ArraySchema import io.swagger.v3.oas.annotations.media.Schema diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt index 372f88930..50ccc5749 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt index 689d0672e..8625580a7 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt index 76b5049d9..c27eb3f4a 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt index ae7f787c9..d75d7f191 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt index c977eeae4..8b7b55372 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt index 4027166d9..16762260e 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto +package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt index c51583e8a..ddc95f7d7 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt @@ -30,5 +30,5 @@ data class ChangelogResponse( @Schema(description = "The type of the change") val businessPartnerType: LsaType, @Schema(description = "The timestamp of the operation") - val createdAt: Instant + val modifiedAt: Instant ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ErrorInfo.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ErrorInfo.kt index 415c014b2..78d3db19b 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ErrorInfo.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ErrorInfo.kt @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.dto.response +package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.gate.api.exception.ErrorCode diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt index 4f73895ba..bd6b02705 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageChangeLogResponse.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError -import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo + @Schema(description = "Paginated collection of results") data class PageChangeLogResponse( diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageOutputResponse.kt index 011645b72..7ff720ba7 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PageOutputResponse.kt @@ -21,7 +21,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError -import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo @Schema(description = "Paginated collection of results") data class PageOutputResponse( diff --git a/bpdm-gate/flyway.conf b/bpdm-gate/flyway.conf index 45496bc9c..25832935e 100644 --- a/bpdm-gate/flyway.conf +++ b/bpdm-gate/flyway.conf @@ -1,4 +1,4 @@ flyway.url=jdbc:postgresql://localhost:5432/bpdm flyway.user=bpdm flyway.password=${BPDM_DB_PASS} -flyway.schemas=bpdm-gate \ No newline at end of file +flyway.schemas=bpdmgate \ No newline at end of file diff --git a/bpdm-gate/pom.xml b/bpdm-gate/pom.xml index 8d76add59..83f9194bd 100644 --- a/bpdm-gate/pom.xml +++ b/bpdm-gate/pom.xml @@ -37,6 +37,7 @@ 42.5.1 8.5.12 + 1.17.2 @@ -149,6 +150,18 @@ assertj-core test + + org.testcontainers + junit-jupiter + ${testcontainers.version} + test + + + org.testcontainers + postgresql + ${testcontainers.version} + test + 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 910b1a11e..4f8516547 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,15 +20,15 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.gate.api.GateAddressApi -import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties -import org.eclipse.tractusx.bpdm.gate.containsDuplicates -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties +import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.AddressService import org.eclipse.tractusx.bpdm.gate.service.ValidationService import org.springframework.http.HttpStatus diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt index 95eace32d..f382dba8c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.gate.api.GateBusinessPartnerApi -import org.eclipse.tractusx.bpdm.gate.dto.BusinessPartnerCandidateDto +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse import org.eclipse.tractusx.bpdm.gate.exception.BpdmInvalidPartnerException import org.eclipse.tractusx.bpdm.gate.service.TypeMatchingService 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 83a7a58b2..3b95bd599 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,15 +20,15 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.gate.api.GateLegalEntityApi -import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties -import org.eclipse.tractusx.bpdm.gate.containsDuplicates -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties +import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.LegalEntityService import org.eclipse.tractusx.bpdm.gate.service.ValidationService import org.springframework.http.HttpStatus 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 9d8311958..a30d6cda7 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,15 +20,15 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.gate.api.GateSiteApi -import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties -import org.eclipse.tractusx.bpdm.gate.containsDuplicates -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse +import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties +import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.SiteService import org.eclipse.tractusx.bpdm.gate.service.ValidationService import org.springframework.http.HttpStatus diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateInputRequest.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateInputRequest.kt deleted file mode 100644 index 27e64a946..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateInputRequest.kt +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.AddressDto -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema( - name = "AddressGateInputRequest", description = "Address with legal entity or site references. " + - "Only one of either legal entity or site external id can be set for an address." -) -data class AddressGateInputRequest( - @field:JsonUnwrapped - val address: AddressDto, - - @Schema(description = "ID the record has in the external system where the record originates from") - val externalId: String, - - @Schema(description = "External id of the related legal entity") - val legalEntityExternalId: String? = null, - - @Schema(description = "External id of the related site") - val siteExternalId: String? = null, - - @Schema(description = "Business Partner Number") - val bpn: String? = null -) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateInputResponse.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateInputResponse.kt deleted file mode 100644 index 3e07bb094..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateInputResponse.kt +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.AddressDto -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer -import java.time.LocalDateTime - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema( - name = "AddressGateInputResponse", description = "Address with legal entity or site references. " + - "Only one of either legal entity or site external id can be set for an address." -) -data class AddressGateInputResponse( - @field:JsonUnwrapped - val address: AddressDto, - - @Schema(description = "ID the record has in the external system where the record originates from") - val externalId: String, - - @Schema(description = "External id of the related legal entity") - val legalEntityExternalId: String? = null, - - @Schema(description = "External id of the related site") - val siteExternalId: String? = null, - - @Schema(description = "Business Partner Number") - val bpn: String? = null, - - @Schema(description = "Time the sharing process was started according to SaaS") - val processStartedAt: LocalDateTime? = null, -) - diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateOutput.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateOutput.kt deleted file mode 100644 index aa6f92d4f..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/AddressGateOutput.kt +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.AddressResponse -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema( - name = "AddressGateOutput", description = "Address with legal entity or site references. " + - "Only one of either legal entity or site external id can be set for an address." -) -data class AddressGateOutput( - @Schema(description = "Business Partner Number") - val bpn: String? = null, - @field:JsonUnwrapped - val address: AddressResponse, - @Schema(description = "ID the record has in the external system where the record originates from") - val externalId: String, - @Schema(description = "External id of the related legal entity") - val legalEntityBpn: String? = null, - @Schema(description = "External id of the related site") - val siteBpn: String? = null -) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/BusinessPartnerCandidateDto.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/BusinessPartnerCandidateDto.kt deleted file mode 100644 index eebf74329..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/BusinessPartnerCandidateDto.kt +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import io.swagger.v3.oas.annotations.media.ArraySchema -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.* - -data class BusinessPartnerCandidateDto( - @ArraySchema(arraySchema = Schema(description = "Identifiers of this partner candidate", required = false)) - val identifiers: Collection = emptyList(), - @ArraySchema(arraySchema = Schema(description = "Names the partner goes by"), minItems = 1) - val names: Collection, - @Schema(description = "Technical key of the legal form") - val legalForm: String? = null, - @Schema(description = "Current business status") - val status: BusinessStatusDto? = null, - @ArraySchema(arraySchema = Schema(description = "Profile classifications", required = false)) - val profileClassifications: Collection = emptyList(), - @ArraySchema(arraySchema = Schema(description = "Bank accounts of this partner", required = false)) - val bankAccounts: Collection = emptyList(), - @Schema(description = "Address of this partner") - val address: AddressDto -) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateInputRequest.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateInputRequest.kt deleted file mode 100644 index 372f88930..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateInputRequest.kt +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "LegalEntityGateInputRequest", description = "Legal entity with external id") -data class LegalEntityGateInputRequest( - @field:JsonUnwrapped - val legalEntity: LegalEntityDto, - - @Schema(description = "ID the record has in the external system where the record originates from", required = true) - val externalId: String, - - @Schema(description = "Business Partner Number") - val bpn: String?, -) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateInputResponse.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateInputResponse.kt deleted file mode 100644 index 689d0672e..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateInputResponse.kt +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer -import java.time.LocalDateTime - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "LegalEntityGateInputResponse", description = "Legal entity with external id") -data class LegalEntityGateInputResponse( - @field:JsonUnwrapped - val legalEntity: LegalEntityDto, - - @Schema(description = "ID the record has in the external system where the record originates from", required = true) - val externalId: String, - - @Schema(description = "Business Partner Number") - val bpn: String?, - - @Schema(description = "Time the sharing process was started according to SaaS") - val processStartedAt: LocalDateTime? = null, -) - - diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateOutput.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateOutput.kt deleted file mode 100644 index 76b5049d9..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/LegalEntityGateOutput.kt +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.AddressResponse -import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "LegalEntityGateOutput", description = "Legal entity with references") -data class LegalEntityGateOutput( - @field:JsonUnwrapped - val legalEntity: LegalEntityResponse, - @Schema(description = "Address of the official seat of this legal entity") - val legalAddress: AddressResponse, - @Schema(description = "Business Partner Number, main identifier value for business partners") - val bpn: String?, - @Schema(description = "ID the record has in the external system where the record originates from") - val externalId: String -) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateInputRequest.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateInputRequest.kt deleted file mode 100644 index ae7f787c9..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateInputRequest.kt +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.SiteDto -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema( - name = "SiteGateInputRequest", description = "Site with legal entity reference" -) -data class SiteGateInputRequest( - @field:JsonUnwrapped - val site: SiteDto, - - @Schema(description = "ID the record has in the external system where the record originates from") - val externalId: String, - - @Schema(description = "External id of the related legal entity") - val legalEntityExternalId: String, - - @Schema(description = "Business Partner Number") - val bpn: String?, -) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateInputResponse.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateInputResponse.kt deleted file mode 100644 index c977eeae4..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateInputResponse.kt +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.SiteDto -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer -import java.time.LocalDateTime - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema( - name = "SiteGateInputResponse", description = "Site with legal entity reference" -) -data class SiteGateInputResponse( - @field:JsonUnwrapped - val site: SiteDto, - - @Schema(description = "ID the record has in the external system where the record originates from") - val externalId: String, - - @Schema(description = "External id of the related legal entity") - val legalEntityExternalId: String, - - @Schema(description = "Business Partner Number") - val bpn: String?, - - @Schema(description = "Time the sharing process was started according to SaaS") - val processStartedAt: LocalDateTime? = null, -) - diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateOutput.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateOutput.kt deleted file mode 100644 index 4027166d9..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/SiteGateOutput.kt +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.AddressResponse -import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "SiteGateOutput", description = "Site with legal entity reference.") -data class SiteGateOutput( - @field:JsonUnwrapped - val site: SiteResponse, - @Schema(description = "Main address where this site resides") - val mainAddress: AddressResponse, - @Schema(description = "ID the record has in the external system where the record originates from") - val externalId: String, - @Schema(description = "Business Partner Number, main identifier value for sites") - val bpn: String?, - @Schema(description = "Bpn of the related legal entity") - val legalEntityBpn: String, -) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ErrorInfo.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ErrorInfo.kt deleted file mode 100644 index 415c014b2..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/dto/response/ErrorInfo.kt +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.dto.response - -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.gate.api.exception.ErrorCode - -@Schema(title = "ErrorInfo", description = "Holds information about failures") -data class ErrorInfo( - - @Schema(description = "Error code identifying the error") - val errorCode: ERROR, - @Schema(description = "Error message that explains the error") - val message: String, - @Schema(description = "Key (externalId) of the entity that failed") - val entityKey: String? -) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt deleted file mode 100644 index 75bcf768c..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/exception/GateErrorCodes.kt +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.exception - -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.gate.api.exception.ErrorCode - -/** - * For every combination of possible errors a separate enum class is defined extending this marker interface. - * We need separate enum classes in order to get the correct error codes for each endpoint in the Swagger schema. - */ -interface ErrorCode - -@Schema(description = "BusinessPartnerOutputError") -enum class BusinessPartnerOutputError : ErrorCode { - SharingProcessError, - SharingTimeout, - BpnNotInPool -} - -@Schema(description = "ChangeLogOutputError") -enum class ChangeLogOutputError : ErrorCode { - ExternalIdNotFound, -} diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/model/SharingStatusEvaluationResult.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/model/SharingStatusEvaluationResult.kt index 8988fa728..e4441caab 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/model/SharingStatusEvaluationResult.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/model/SharingStatusEvaluationResult.kt @@ -19,8 +19,8 @@ package org.eclipse.tractusx.bpdm.gate.model -import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError +import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo data class SharingStatusEvaluationResult( val validExternalIds: Collection, 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 3c191e31f..b49df8809 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 @@ -24,14 +24,14 @@ import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerSearchRespons import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.dto.saas.FetchResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException -import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.exception.SaasInvalidRecordException import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException @@ -153,13 +153,14 @@ class AddressService( */ fun upsertAddresses(addresses: Collection) { + val addressesSaas = toSaasModels(addresses) + saasClient.upsertAddresses(addressesSaas) + + // create changelog entry if all goes well from saasClient addresses.forEach { address -> changelogRepository.save(ChangelogEntity(address.externalId, LsaType.Address)) } - val addressesSaas = toSaasModels(addresses) - saasClient.upsertAddresses(addressesSaas) - deleteParentRelationsOfAddresses(addresses) upsertParentRelations(addresses) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index c81a2dce3..7eac1845d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -20,11 +20,11 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse -import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo +import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse -import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byCreatedAtGreaterThan import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byExternalIdsIn @@ -48,23 +48,23 @@ class ChangelogService(private val changelogRepository: ChangelogRepository) { it.toGateDto() } - val errorInfoList = externalIds.filterNot { id -> + val errorInfoSet = externalIds.filterNot { id -> pageDto.content.any { it.externalId == id } }.map { ErrorInfo( ChangeLogOutputError.ExternalIdNotFound, "$it not found", - "externalId not found" + it ) - } + }.toSet() return PageChangeLogResponse( page = page, totalElements = pageDto.totalElements, totalPages = pageDto.totalPages, contentSize = pageDto.content.size, content = pageDto.content, - invalidEntries = errorInfoList.size, - errors = errorInfoList + invalidEntries = errorInfoSet.size, + errors = errorInfoSet ) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt index fc0a2239b..56269b199 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt @@ -24,11 +24,11 @@ import org.eclipse.tractusx.bpdm.common.service.SaasMappings import org.eclipse.tractusx.bpdm.common.service.SaasMappings.toDto import org.eclipse.tractusx.bpdm.common.service.SaasMappings.toLegalEntityDto import org.eclipse.tractusx.bpdm.common.service.SaasMappings.toSiteDto +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputResponse import org.springframework.stereotype.Service @Service 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 059805785..5ebb24c86 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 @@ -26,9 +26,9 @@ import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.dto.saas.FetchResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmMappingException import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse @@ -50,12 +50,14 @@ class LegalEntityService( fun upsertLegalEntities(legalEntities: Collection) { - legalEntities.forEach { legalEntity -> - changelogRepository.save(ChangelogEntity(legalEntity.externalId, LsaType.LegalEntity)) - } val legalEntitiesSaas = legalEntities.map { saasRequestMappingService.toSaasModel(it) } saasClient.upsertLegalEntities(legalEntitiesSaas) + + // create changelog entry if all goes well from saasClient + legalEntities.forEach { legalEntity -> + changelogRepository.save(ChangelogEntity(legalEntity.externalId, LsaType.LegalEntity)) + } } fun getLegalEntityByExternalId(externalId: String): LegalEntityGateInputResponse { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OutputSaasMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OutputSaasMappingService.kt index 1c7eb02e2..885dc5e62 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OutputSaasMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OutputSaasMappingService.kt @@ -25,9 +25,9 @@ import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.dto.saas.SharingStatusSaas import org.eclipse.tractusx.bpdm.common.dto.saas.isError import org.eclipse.tractusx.bpdm.common.service.SaasMappings -import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties -import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError +import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo +import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.eclipse.tractusx.bpdm.gate.filterNotNullKeys import org.eclipse.tractusx.bpdm.gate.model.BusinessPartnerSaasWithBpn import org.eclipse.tractusx.bpdm.gate.model.BusinessPartnerSaasWithExternalId diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt index 2a67b9011..1ebcbc687 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.AddressDto import org.eclipse.tractusx.bpdm.common.dto.IdentifierDto import org.eclipse.tractusx.bpdm.common.dto.saas.* -import org.eclipse.tractusx.bpdm.gate.dto.BusinessPartnerCandidateDto +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto import org.springframework.stereotype.Service @Service diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt index 61032fb04..208b4d429 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt @@ -24,11 +24,11 @@ import com.neovisionaries.i18n.LanguageCode import org.eclipse.tractusx.bpdm.common.dto.* import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.common.model.CharacterSet +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest import org.springframework.stereotype.Service @Service @@ -46,7 +46,7 @@ class SaasRequestMappingService( dataSource = saasConfigProperties.datasource, names = listOf(NameSaas(value = site.site.name)), addresses = listOf(toSaasModel(site.site.mainAddress)), - identifiers = if (site.bpn != null) listOf(createBpnIdentifierSaas(site.bpn)) else emptyList(), + identifiers = if (site.bpn != null) listOf(createBpnIdentifierSaas(site.bpn!!)) else emptyList(), types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.ORGANIZATIONAL_UNIT.name)) ) } @@ -56,7 +56,7 @@ class SaasRequestMappingService( externalId = address.externalId, dataSource = saasConfigProperties.datasource, addresses = listOf(toSaasModel(address.address)), - identifiers = if (address.bpn != null) listOf(createBpnIdentifierSaas(address.bpn)) else emptyList(), + identifiers = if (address.bpn != null) listOf(createBpnIdentifierSaas(address.bpn!!)) else emptyList(), types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.BP_ADDRESS.name)) ) } 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 5c87f2b9e..2515c8573 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 @@ -26,13 +26,13 @@ import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.dto.saas.FetchResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException -import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputResponse -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse +import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.exception.SaasInvalidRecordException import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException @@ -141,13 +141,14 @@ class SiteService( */ fun upsertSites(sites: Collection) { + val sitesSaas = toSaasModels(sites) + saasClient.upsertSites(sitesSaas) + + // create changelog entry if all goes well from saasClient sites.forEach { site -> changelogRepository.save(ChangelogEntity(site.externalId, LsaType.Site)) } - val sitesSaas = toSaasModels(sites) - saasClient.upsertSites(sitesSaas) - deleteParentRelationsOfSites(sites) upsertParentRelations(sites) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt index 5d59b4171..439bfbbf8 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt @@ -22,11 +22,11 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.dto.saas.ReferenceDataLookupRequestSaas -import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties -import org.eclipse.tractusx.bpdm.gate.config.TypeMatchConfigProperties -import org.eclipse.tractusx.bpdm.gate.dto.BusinessPartnerCandidateDto +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse +import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties +import org.eclipse.tractusx.bpdm.gate.config.TypeMatchConfigProperties import org.springframework.stereotype.Service @Service diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt index c1dcfb3d1..49233787b 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt @@ -24,9 +24,9 @@ import org.eclipse.tractusx.bpdm.common.dto.saas.ValidationRequestSaas import org.eclipse.tractusx.bpdm.common.dto.saas.ValidationResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.ViolationLevel import org.eclipse.tractusx.bpdm.common.service.ValidationMapper -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus import org.springframework.stereotype.Service diff --git a/bpdm-gate/src/main/resources/application.properties b/bpdm-gate/src/main/resources/application.properties index bb995e44e..384ad1cfa 100644 --- a/bpdm-gate/src/main/resources/application.properties +++ b/bpdm-gate/src/main/resources/application.properties @@ -65,14 +65,14 @@ spring.datasource.driverClassName=org.postgresql.Driver spring.datasource.username=bpdm spring.datasource.password= spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect -spring.jpa.properties.hibernate.default_schema=bpdm-gate +spring.jpa.properties.hibernate.default_schema=bpdmgate #Send updates and inserts out in batches to decrease network connections to the database spring.jpa.properties.hibernate.jdbc.batch_size=16 spring.jpa.properties.hibernate.order_updates=true spring.jpa.properties.hibernate.order_inserts=true #Flyway configuration spring.flyway.enabled=true -spring.flyway.schemas=bpdm-gate +spring.flyway.schemas=bpdmgate 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 231af23f8..005a46e76 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 @@ -45,11 +45,11 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus +import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_RELATIONS_PATH @@ -63,12 +63,14 @@ import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.HttpStatus import org.springframework.http.HttpStatusCode import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource import org.springframework.web.reactive.function.client.WebClientResponseException @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") +@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class AddressControllerInputIT @Autowired constructor( private val objectMapper: ObjectMapper, private val saasConfigProperties: SaasConfigProperties, 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 a0a425fa3..86203b9ff 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 @@ -47,26 +47,25 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.gate.api.client.GateClient +import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo +import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError -import org.eclipse.tractusx.bpdm.gate.util.CommonValues -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues +import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_ADDRESSES_SEARCH_PATH -import org.eclipse.tractusx.bpdm.gate.util.ResponseValues -import org.eclipse.tractusx.bpdm.gate.util.SaasValues +import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") +@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class AddressControllerOutputIT @Autowired constructor( private val objectMapper: ObjectMapper, val gateClient: GateClient diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt index ad7dd4155..f97f9a9f8 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt @@ -45,10 +45,11 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.config.TypeMatchConfigProperties import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse +import org.eclipse.tractusx.bpdm.gate.config.TypeMatchConfigProperties import org.eclipse.tractusx.bpdm.gate.util.EndpointValues +import org.eclipse.tractusx.bpdm.gate.util.PostgreSQLContextInitializer import org.eclipse.tractusx.bpdm.gate.util.RequestValues import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue @@ -59,6 +60,7 @@ import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.HttpStatus import org.springframework.http.HttpStatusCode import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource import org.springframework.web.reactive.function.client.WebClientResponseException @@ -66,6 +68,7 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") +@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) class BusinessPartnerControllerIT @Autowired constructor( private val objectMapper: ObjectMapper, private val typeMatchConfigProperties: TypeMatchConfigProperties, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt new file mode 100644 index 000000000..bcbd4a915 --- /dev/null +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt @@ -0,0 +1,397 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.controller + +import com.fasterxml.jackson.databind.ObjectMapper +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.core.WireMockConfiguration +import com.github.tomakehurst.wiremock.junit5.WireMockExtension +import jakarta.persistence.EntityManager +import jakarta.persistence.EntityManagerFactory +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.RecursiveComparisonAssert +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.saas.* +import org.eclipse.tractusx.bpdm.gate.api.client.GateClient +import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError +import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse +import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo +import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity + +import org.eclipse.tractusx.bpdm.gate.util.* + +import org.eclipse.tractusx.bpdm.gate.util.CommonValues.lsaTypeParam +import org.eclipse.tractusx.bpdm.gate.util.CommonValues.lsaTypeParamNotFound +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.RegisterExtension +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.DynamicPropertyRegistry +import org.springframework.test.context.DynamicPropertySource + +import java.time.Instant + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) +internal class ChangeLogControllerIT @Autowired constructor( + val gateClient: GateClient, + private val objectMapper: ObjectMapper, + val saasConfigProperties: SaasConfigProperties, + entityManagerFactory: EntityManagerFactory, +) { + companion object { + @RegisterExtension + private val wireMockServer: WireMockExtension = WireMockExtension.newInstance() + .options(WireMockConfiguration.wireMockConfig().dynamicPort()) + .build() + + @JvmStatic + @DynamicPropertySource + fun properties(registry: DynamicPropertyRegistry) { + registry.add("bpdm.saas.host") { wireMockServer.baseUrl() } + } + } + + + val instant = Instant.now() + + val BPDM_DB_SCHEMA_NAME: String = "bpdmgate" + + val em: EntityManager = entityManagerFactory.createEntityManager() + + @BeforeEach + fun beforeEach() { + truncateDbTables() + wireMockServer.resetAll() + mockSaas() + createChangeLogs() + } + + /** + * Given externalId exists in database + * When getting changeLog by external id + * Then changeLog mapped to the catena data model should be returned + */ + @Test + fun `get changeLog by external id`() { + + val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), null, listOf(CommonValues.externalIdAddress1)) + + assertRecursively(searchResult.content) + .ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") + .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) + } + + + + /** + * Given externalId does not exist in database + * When getting changeLog by external id + * Then changeLog mapped to the catena data model should not be returned + */ + @Test + fun `get changeLog by external id not found`() { + + val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), null, listOf("NONEXIST")) + + assertThat(searchResult.content) + .usingRecursiveComparison() + .ignoringAllOverriddenEquals() + .ignoringCollectionOrder() + .isEqualTo(emptyList()) + + assertRecursively(searchResult.content) + .isEqualTo(emptyList()) + + assertRecursively(searchResult.errors) + .isEqualTo(listOf( + ErrorInfo( + ChangeLogOutputError.ExternalIdNotFound, + "NONEXIST not found", + "NONEXIST") + )) + + + + } + + /** + * Given externalId and timestamp a changeLog exist in database + * When getting changeLog by external id and timestamp + * Then changeLog mapped to the catena data model should be returned + */ + @Test + fun `get changeLog by external id and timeStamp`() { + + val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), instant, listOf(CommonValues.externalIdAddress1)) + + + assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") + .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) + } + + /** + * Given a lsaType a changeLog exists in database + * When getting changeLog by lsaType + * Then changeLog mapped to the catena data model should be returned + */ + @Test + fun `get changeLog by lsaType`() { + + val searchResult = gateClient.changelog().getChangelogEntriesLsaType(PaginationRequest(), null, lsaTypeParam) + + assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") + .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) + } + + /** + * Given lsaType does not exist in database + * When getting changeLog by lsaType + * Then changeLog mapped to the catena data model should not be returned + */ + + @Test + fun `get changeLog by lsaType not found`() { + val searchResult = gateClient.changelog().getChangelogEntriesLsaType(PaginationRequest(), null, lsaTypeParamNotFound) + + assertRecursively(searchResult.content) + .isEqualTo(emptyList()) + } + + /** + * Given lsaType and timestamp a changeLog exist in database + * When getting changeLog by lsaType and timestamp + * Then changeLog mapped to the catena data model should be returned + */ + @Test + fun `get changeLog by lsaType and timeStamp`() { + + val searchResult = gateClient.changelog().getChangelogEntriesLsaType(PaginationRequest(), instant, lsaTypeParam) + + assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") + .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) + } + + /** + * Given a timeStamp a changeLog exists in database + * When getting changeLog by timeStamp + * Then changeLog from that instant until now is mapped to the catena data model should be returned + */ + @Test + fun `get changeLog from timeStamp`() { + + val searchResult = gateClient.changelog().getChangelogEntriesLsaType(paginationRequest = PaginationRequest(), fromTime = instant, lsaType = null) + + assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") + .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) + } + + fun mockSaas() { + val addresses = listOf( + RequestValues.addressGateInputRequest1 + ) + + val parentLegalEntitiesSaas = listOf( + SaasValues.legalEntityResponse1 + ) + + val parentSitesSaas = listOf( + SaasValues.siteBusinessPartner1 + ) + + + + // mock "get parent legal entities" + wireMockServer.stubFor( + get(urlPathMatching(EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH)) + .withQueryParam("externalId", equalTo(addresses.mapNotNull { it.legalEntityExternalId }.joinToString(","))) + .withQueryParam("dataSource", equalTo(saasConfigProperties.datasource)) + .willReturn( + aResponse() + .withHeader("Content-Type", "application/json") + .withBody( + objectMapper.writeValueAsString( + PagedResponseSaas( + limit = 50, + total = 1, + values = parentLegalEntitiesSaas + ) + ) + ) + ) + ) + // mock "get parent sites" + wireMockServer.stubFor( + get(urlPathMatching(EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH)) + .withQueryParam("externalId", equalTo(addresses.mapNotNull { it.siteExternalId }.joinToString(","))) + .withQueryParam("dataSource", equalTo(saasConfigProperties.datasource)) + .willReturn( + aResponse() + .withHeader("Content-Type", "application/json") + .withBody( + objectMapper.writeValueAsString( + PagedResponseSaas( + limit = 50, + total = 1, + values = parentSitesSaas + ) + ) + ) + ) + ) + val stubMappingUpsertAddresses = wireMockServer.stubFor( + put(urlPathMatching(EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH)) + .willReturn( + aResponse() + .withHeader("Content-Type", "application/json") + .withBody( + objectMapper.writeValueAsString( + UpsertResponse( + emptyList(), + emptyList(), + 2, + 0 + ) + ) + ) + ) + ) + // mock "get addresses with relations" + // this simulates the case that the address already had some relations + wireMockServer.stubFor( + get(urlPathMatching(EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH)) + .withQueryParam("externalId", equalTo(addresses.map { it.externalId }.joinToString(","))) + .withQueryParam("dataSource", equalTo(saasConfigProperties.datasource)) + .withQueryParam("featuresOn", containing("FETCH_RELATIONS")) + .willReturn( + aResponse() + .withHeader("Content-Type", "application/json") + .withBody( + objectMapper.writeValueAsString( + PagedResponseSaas( + limit = 50, + total = 2, + values = listOf( + SaasValues.addressBusinessPartnerWithRelations1, + SaasValues.addressBusinessPartnerWithRelations2 + ) + ) + ) + ) + ) + ) + val stubMappingDeleteRelations = wireMockServer.stubFor( + post(urlPathMatching(EndpointValues.SAAS_MOCK_DELETE_RELATIONS_PATH)) + .willReturn( + aResponse() + .withHeader("Content-Type", "application/json") + .withBody( + objectMapper.writeValueAsString( + DeleteRelationsResponseSaas(2) + ) + ) + ) + ) + val stubMappingUpsertRelations = wireMockServer.stubFor( + put(urlPathMatching(EndpointValues.SAAS_MOCK_RELATIONS_PATH)) + .willReturn( + aResponse() + .withHeader("Content-Type", "application/json") + .withBody( + objectMapper.writeValueAsString( + UpsertRelationsResponseSaas( + failures = emptyList(), + numberOfFailed = 0, + numberOfInserts = 2, + numberOfProvidedRelations = 2, + numberOfUpdates = 0 + ) + ) + ) + ) + ) + } + + fun truncateDbTables() { + em.transaction.begin() + + em.createNativeQuery( + """ + DO $$ DECLARE table_names RECORD; + BEGIN + FOR table_names IN SELECT table_name + FROM information_schema.tables + WHERE table_schema='${BPDM_DB_SCHEMA_NAME}' + AND table_name NOT IN ('flyway_schema_history') + LOOP + EXECUTE format('TRUNCATE TABLE ${BPDM_DB_SCHEMA_NAME}.%I CONTINUE IDENTITY CASCADE;', table_names.table_name); + END LOOP; + END $$; + """.trimIndent() + ).executeUpdate() + + em.transaction.commit() + } + + fun assertRecursively(actual: T): RecursiveComparisonAssert<*> { + return assertThat(actual) + .usingRecursiveComparison() + .ignoringCollectionOrder() + .ignoringAllOverriddenEquals() + + } + + /** + * Creates changelog entities + * Retains the order: All response objects will be in the same order as their request counterparts + * Assumption: Changelog entities have unique indexes among them each + */ + fun createChangeLogs(){ + val addresses = listOf( + RequestValues.addressGateInputRequest1 + ) + gateClient.addresses().upsertAddresses(addresses) + } + +} \ No newline at end of file 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 374f83be0..aa265473d 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 @@ -29,18 +29,15 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues +import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.GATE_API_INPUT_LEGAL_ENTITIES_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_FETCH_BUSINESS_PARTNER_PATH -import org.eclipse.tractusx.bpdm.gate.util.RequestValues -import org.eclipse.tractusx.bpdm.gate.util.ResponseValues -import org.eclipse.tractusx.bpdm.gate.util.SaasValues import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test @@ -51,6 +48,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.HttpStatusCode import org.springframework.http.MediaType import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource import org.springframework.test.web.reactive.server.WebTestClient @@ -58,6 +56,7 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = ["bpdm.api.upsert-limit=2"]) @ActiveProfiles("test") +@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class LegalEntityControllerInputIT @Autowired constructor( private val webTestClient: WebTestClient, private val objectMapper: ObjectMapper, 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 4891d7dee..662c0237c 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 @@ -27,27 +27,26 @@ import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.gate.api.client.GateClient +import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo +import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError -import org.eclipse.tractusx.bpdm.gate.util.CommonValues -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH +import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_LEGAL_ADDRESSES_SEARCH_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_LEGAL_ENTITIES_SEARCH_PATH -import org.eclipse.tractusx.bpdm.gate.util.ResponseValues -import org.eclipse.tractusx.bpdm.gate.util.SaasValues +import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") +@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class LegalEntityControllerOutputIT @Autowired constructor( private val objectMapper: ObjectMapper, val gateClient: GateClient 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 128c4dbb7..d4d5a7104 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 @@ -26,11 +26,11 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus +import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_DELETE_RELATIONS_PATH @@ -44,12 +44,14 @@ import org.springframework.boot.test.context.SpringBootTest import org.springframework.http.HttpStatus import org.springframework.http.HttpStatusCode import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource import org.springframework.web.reactive.function.client.WebClientResponseException @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") +@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class SiteControllerInputIT @Autowired constructor( private val objectMapper: ObjectMapper, private val saasConfigProperties: SaasConfigProperties, 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 733f30e80..7a4f0414a 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 @@ -28,27 +28,26 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.gate.api.client.GateClient +import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.dto.response.ErrorInfo +import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerOutputError -import org.eclipse.tractusx.bpdm.gate.util.CommonValues -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH +import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_SITES_MAIN_ADDRESSES_SEARCH_PATH import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_SITES_SEARCH_PATH -import org.eclipse.tractusx.bpdm.gate.util.ResponseValues -import org.eclipse.tractusx.bpdm.gate.util.SaasValues +import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") +@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class SiteControllerOutputIT @Autowired constructor( private val objectMapper: ObjectMapper, val gateClient: GateClient diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt index efefd37ab..011a5c41b 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt @@ -22,6 +22,8 @@ package org.eclipse.tractusx.bpdm.gate.util import com.neovisionaries.i18n.CountryCode import com.neovisionaries.i18n.LanguageCode import org.eclipse.tractusx.bpdm.common.model.* +import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType import java.time.LocalDateTime /** @@ -34,6 +36,10 @@ object CommonValues { val externalId4 = "external-4" val externalId5 = "external-5" + val lsaTypeParam = LsaType.Address + val lsaTypeParamNotFound = LsaType.Site + val lsaNone = OptionalLsaType.None + val externalIdSite1 = "site-external-1" val externalIdSite2 = "site-external-2" @@ -224,4 +230,5 @@ object CommonValues { val geoCoordinates1 = Triple(0f, 0f, 0f) val geoCoordinates2 = Triple(1f, 1f, 0f) + } \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/PostgreSQLContextInitializer.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/PostgreSQLContextInitializer.kt new file mode 100644 index 000000000..744d8cf46 --- /dev/null +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/PostgreSQLContextInitializer.kt @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.gate.util + +import org.springframework.boot.test.util.TestPropertyValues +import org.springframework.context.ApplicationContextInitializer +import org.springframework.context.ConfigurableApplicationContext +import org.testcontainers.containers.PostgreSQLContainer + +/** + * When used on a spring boot test, starts a singleton postgres db container that is shared between all integration tests. + */ +class PostgreSQLContextInitializer : ApplicationContextInitializer { + companion object { + val postgreSQLContainer = PostgreSQLContainer("postgres:13.2") + } + + override fun initialize(applicationContext: ConfigurableApplicationContext) { + postgreSQLContainer.start() + TestPropertyValues.of( + "spring.datasource.url=${postgreSQLContainer.jdbcUrl}", + "spring.datasource.username=${postgreSQLContainer.username}", + "spring.datasource.password=${postgreSQLContainer.password}" + ).applyTo(applicationContext.environment) + } +} \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index 62721d2ab..c2f0bf953 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -22,10 +22,10 @@ package org.eclipse.tractusx.bpdm.gate.util import com.neovisionaries.i18n.CurrencyCode import org.eclipse.tractusx.bpdm.common.dto.* import org.eclipse.tractusx.bpdm.common.model.AddressType -import org.eclipse.tractusx.bpdm.gate.dto.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.BusinessPartnerCandidateDto -import org.eclipse.tractusx.bpdm.gate.dto.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.dto.SiteGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest object RequestValues { val identifier1 = diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 73dd23aee..3a4975d42 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -27,7 +27,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameUrlDto import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeNameUrlDto import org.eclipse.tractusx.bpdm.common.model.AddressType import org.eclipse.tractusx.bpdm.common.model.BusinessPartnerType -import org.eclipse.tractusx.bpdm.gate.dto.* +import org.eclipse.tractusx.bpdm.gate.api.model.* import java.time.Instant object ResponseValues { 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 f06cf9e4e..cae9cefb4 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 @@ -31,14 +31,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse 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.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.* -import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponseWrapper -import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerUpdateResponseWrapper import org.springdoc.core.annotations.ParameterObject import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.GetExchange 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 2f0f95371..110619bd2 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 @@ -21,8 +21,6 @@ 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.AddressPartnerResponse -import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.AddressPartnerSearchResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.PoolAddressApi 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 e51ffad6c..582bf8b6c 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 @@ -19,10 +19,10 @@ package org.eclipse.tractusx.bpdm.pool.controller -import org.eclipse.tractusx.bpdm.pool.config.ControllerConfigProperties 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.config.ControllerConfigProperties import org.eclipse.tractusx.bpdm.pool.service.BusinessPartnerFetchService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt index 30a646585..ae84fc502 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt @@ -27,9 +27,6 @@ import org.eclipse.tractusx.bpdm.pool.config.ControllerConfigProperties import org.eclipse.tractusx.bpdm.pool.exception.BpdmRequestSizeException import org.eclipse.tractusx.bpdm.pool.service.PartnerChangelogService import org.springdoc.core.annotations.ParameterObject -import org.springframework.http.HttpStatus -import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController import java.time.Instant 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 99c6be32c..90dd46d9c 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 @@ -289,6 +289,7 @@ class AddressControllerIT @Autowired constructor( response.entities.forEach { assertThat(it.bpn).matches(testHelpers.bpnAPattern) } testHelpers.assertRecursively(response.entities).ignoringFields(AddressPartnerCreateResponse::bpn.name).isEqualTo(expected) + assertThat(response.errorCount).isEqualTo(0) } From bae9c8c2077bfeb88dd9aac4d490a2af1042b91b Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Wed, 29 Mar 2023 13:01:16 +0100 Subject: [PATCH 15/16] fix(Gate): Resolve bug on page requesting and content on other pages --- .../tractusx/bpdm/gate/api/GateChangelogApi.kt | 2 +- .../gate/controller/ChangelogController.kt | 2 +- .../gate/repository/ChangelogRepository.kt | 5 +++++ .../bpdm/gate/service/ChangelogService.kt | 18 +++++++++++------- .../gate/controller/ChangeLogControllerIT.kt | 6 +++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt index 7b553819f..5b3bcddbe 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt @@ -58,7 +58,7 @@ interface GateChangelogApi { fun getChangelogEntriesExternalId( @ParameterObject @Valid paginationRequest: PaginationRequest, @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam(required = false) fromTime: Instant?, - @RequestBody(required = true) @NotEmpty(message = "Input externalIds list cannot be empty.") externalIds: Collection + @RequestBody(required = true) @NotEmpty(message = "Input externalIds list cannot be empty.") externalIds: Set ): PageChangeLogResponse @Operation( diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index deb2391d8..5658836f8 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -37,7 +37,7 @@ class ChangelogController( ) : GateChangelogApi { override fun getChangelogEntriesExternalId( - paginationRequest: PaginationRequest, fromTime: Instant?, externalIds: Collection + paginationRequest: PaginationRequest, fromTime: Instant?, externalIds: Set ): PageChangeLogResponse { return changelogService.getChangeLogByExternalId(externalIds, fromTime, paginationRequest.page, paginationRequest.size) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index aade6279e..9f2a39964 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -19,11 +19,13 @@ package org.eclipse.tractusx.bpdm.gate.repository +import io.swagger.v3.oas.annotations.Parameter import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.springframework.data.jpa.domain.Specification import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.JpaSpecificationExecutor +import org.springframework.data.jpa.repository.Query import java.time.Instant @@ -64,5 +66,8 @@ interface ChangelogRepository : JpaRepository, JpaSpecifi } } + @Query("select distinct u.externalId from ChangelogEntity u where u.externalId in :externalIdList") + fun findExternalIdsInListDistinct(externalIdList: Collection): Set + } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 7eac1845d..fbf954423 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -29,42 +29,45 @@ import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byCreatedAtGreaterThan import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byExternalIdsIn import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byLsaType +import org.springframework.data.domain.PageImpl import org.springframework.data.domain.PageRequest import org.springframework.data.jpa.domain.Specification import org.springframework.stereotype.Service + import java.time.Instant +import kotlin.math.ceil @Service class ChangelogService(private val changelogRepository: ChangelogRepository) { - fun getChangeLogByExternalId(externalIds: Collection, createdAt: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { + fun getChangeLogByExternalId(externalIds: Set, createdAt: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { val spec = Specification.allOf(byExternalIdsIn(externalIds = externalIds), byCreatedAtGreaterThan(createdAt = createdAt)) val pageable = PageRequest.of(page, pageSize) val pageResponse = changelogRepository.findAll(spec, pageable) + val setDistinctList = changelogRepository.findExternalIdsInListDistinct(externalIds) val pageDto = pageResponse.map { it.toGateDto() } - val errorInfoSet = externalIds.filterNot { id -> - pageDto.content.any { it.externalId == id } - }.map { + val errorList = (externalIds - setDistinctList).map { ErrorInfo( ChangeLogOutputError.ExternalIdNotFound, "$it not found", it ) - }.toSet() + } + return PageChangeLogResponse( page = page, totalElements = pageDto.totalElements, totalPages = pageDto.totalPages, contentSize = pageDto.content.size, content = pageDto.content, - invalidEntries = errorInfoSet.size, - errors = errorInfoSet + invalidEntries = errorList.size, + errors = errorList ) } @@ -86,4 +89,5 @@ class ChangelogService(private val changelogRepository: ChangelogRepository) { content = pageDto.content, ) } + } \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt index bcbd4a915..c394214c2 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt @@ -116,7 +116,7 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by external id`() { - val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), null, listOf(CommonValues.externalIdAddress1)) + val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), null, setOf(CommonValues.externalIdAddress1)) assertRecursively(searchResult.content) .ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") @@ -133,7 +133,7 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by external id not found`() { - val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), null, listOf("NONEXIST")) + val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), null, setOf("NONEXIST")) assertThat(searchResult.content) .usingRecursiveComparison() @@ -164,7 +164,7 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by external id and timeStamp`() { - val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), instant, listOf(CommonValues.externalIdAddress1)) + val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), instant, setOf(CommonValues.externalIdAddress1)) assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") From 5d7e066df419a9ad9e9978ecdb6ef2bd6f5d05b1 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 31 Mar 2023 11:41:59 +0100 Subject: [PATCH 16/16] fix(Gate): ChangelogEntity to ChangelogEntry --- .../{ChangelogEntity.kt => ChangelogEntry.kt} | 2 +- .../gate/repository/ChangelogRepository.kt | 19 +++++++++---------- .../bpdm/gate/service/AddressService.kt | 4 ++-- .../bpdm/gate/service/LegalEntityService.kt | 4 ++-- .../bpdm/gate/service/ResponseMappings.kt | 4 ++-- .../tractusx/bpdm/gate/service/SiteService.kt | 4 ++-- .../gate/controller/ChangeLogControllerIT.kt | 8 ++++---- 7 files changed, 22 insertions(+), 23 deletions(-) rename bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/{ChangelogEntity.kt => ChangelogEntry.kt} (98%) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt similarity index 98% rename from bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt rename to bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt index 9eaa43fe3..5c352f3bb 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt @@ -26,7 +26,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType @Entity @Table(name = "changelog_entries") -class ChangelogEntity( +class ChangelogEntry( @Column(name = "external_id", nullable = false, updatable = false) val externalId: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index 9f2a39964..6c6afb5fe 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -19,9 +19,8 @@ package org.eclipse.tractusx.bpdm.gate.repository -import io.swagger.v3.oas.annotations.Parameter import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.springframework.data.jpa.domain.Specification import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.JpaSpecificationExecutor @@ -29,7 +28,7 @@ import org.springframework.data.jpa.repository.Query import java.time.Instant -interface ChangelogRepository : JpaRepository, JpaSpecificationExecutor { +interface ChangelogRepository : JpaRepository, JpaSpecificationExecutor { object Specs { @@ -37,10 +36,10 @@ interface ChangelogRepository : JpaRepository, JpaSpecifi * Restrict to entries with any one of the given ExternalIds; ignore if null */ fun byExternalIdsIn(externalIds: Collection) = - Specification { root, _, _ -> + Specification { root, _, _ -> externalIds.let { - root.get(ChangelogEntity::externalId.name).`in`(externalIds.map { externalId -> externalId }) + root.get(ChangelogEntry::externalId.name).`in`(externalIds.map { externalId -> externalId }) } } @@ -49,9 +48,9 @@ interface ChangelogRepository : JpaRepository, JpaSpecifi * Restrict to entries created at or after the given instant; ignore if null */ fun byCreatedAtGreaterThan(createdAt: Instant?) = - Specification { root, _, builder -> + Specification { root, _, builder -> createdAt?.let { - builder.greaterThanOrEqualTo(root.get(ChangelogEntity::createdAt.name), createdAt) + builder.greaterThanOrEqualTo(root.get(ChangelogEntry::createdAt.name), createdAt) } } @@ -59,14 +58,14 @@ interface ChangelogRepository : JpaRepository, JpaSpecifi * Restrict to entries for the LsaType; ignore if null */ fun byLsaType(lsaType: LsaType?) = - Specification { root, _, builder -> + Specification { root, _, builder -> lsaType?.let { - builder.equal(root.get(ChangelogEntity::businessPartnerType.name), lsaType) + builder.equal(root.get(ChangelogEntry::businessPartnerType.name), lsaType) } } } - @Query("select distinct u.externalId from ChangelogEntity u where u.externalId in :externalIdList") + @Query("select distinct u.externalId from ChangelogEntry u where u.externalId in :externalIdList") fun findExternalIdsInListDistinct(externalIdList: Collection): Set 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 b49df8809..f269c4df6 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 @@ -32,7 +32,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.exception.SaasInvalidRecordException import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository @@ -158,7 +158,7 @@ class AddressService( // create changelog entry if all goes well from saasClient addresses.forEach { address -> - changelogRepository.save(ChangelogEntity(address.externalId, LsaType.Address)) + changelogRepository.save(ChangelogEntry(address.externalId, LsaType.Address)) } deleteParentRelationsOfAddresses(addresses) 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 5ebb24c86..c8f5b0c9c 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 @@ -32,7 +32,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.springframework.stereotype.Service @@ -56,7 +56,7 @@ class LegalEntityService( // create changelog entry if all goes well from saasClient legalEntities.forEach { legalEntity -> - changelogRepository.save(ChangelogEntity(legalEntity.externalId, LsaType.LegalEntity)) + changelogRepository.save(ChangelogEntry(legalEntity.externalId, LsaType.LegalEntity)) } } 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 89b446420..59e722ebd 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,8 +20,8 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.springframework.data.domain.Page @@ -29,7 +29,7 @@ fun Page.toDto(dtoContent: Collection): PageResponse { return PageResponse(this.totalElements, this.totalPages, this.number, this.numberOfElements, dtoContent) } -fun ChangelogEntity.toGateDto(): ChangelogResponse { +fun ChangelogEntry.toGateDto(): ChangelogResponse { return ChangelogResponse( externalId, businessPartnerType, 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 2515c8573..083992322 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 @@ -33,7 +33,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageStartAfterResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.exception.SaasInvalidRecordException import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository @@ -146,7 +146,7 @@ class SiteService( // create changelog entry if all goes well from saasClient sites.forEach { site -> - changelogRepository.save(ChangelogEntity(site.externalId, LsaType.Site)) + changelogRepository.save(ChangelogEntry(site.externalId, LsaType.Site)) } deleteParentRelationsOfSites(sites) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt index c394214c2..b9d073725 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt @@ -53,7 +53,7 @@ import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntity +import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.util.* @@ -139,10 +139,10 @@ internal class ChangeLogControllerIT @Autowired constructor( .usingRecursiveComparison() .ignoringAllOverriddenEquals() .ignoringCollectionOrder() - .isEqualTo(emptyList()) + .isEqualTo(emptyList()) assertRecursively(searchResult.content) - .isEqualTo(emptyList()) + .isEqualTo(emptyList()) assertRecursively(searchResult.errors) .isEqualTo(listOf( @@ -196,7 +196,7 @@ internal class ChangeLogControllerIT @Autowired constructor( val searchResult = gateClient.changelog().getChangelogEntriesLsaType(PaginationRequest(), null, lsaTypeParamNotFound) assertRecursively(searchResult.content) - .isEqualTo(emptyList()) + .isEqualTo(emptyList()) } /**