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()) } /**