From 32f6aabe8c9ba075af999f700f483e4802aae42b Mon Sep 17 00:00:00 2001 From: cezaralexandremorais Date: Thu, 4 May 2023 18:08:08 +0100 Subject: [PATCH] Fix(gate/pool):changed bpn to nullable and removed unique constraints --- .../org/eclipse/tractusx/bpdm/gate/entity/Site.kt | 4 ++-- .../tractusx/bpdm/gate/service/ResponseMappings.kt | 11 +++-------- .../db/migration/V0_1_4_0__create_site_tables.sql | 4 +--- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt index 28eb98d8f..4baf5df32 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt @@ -25,8 +25,8 @@ import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "sites") class Site( - @Column(name = "bpn", nullable = false, unique = true) - var bpn: String, + @Column(name = "bpn") + var bpn: String?, @Column(name = "name", nullable = false) var name: String, 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 d56051401..52fe6f3e9 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -20,7 +20,6 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.* -import org.eclipse.tractusx.bpdm.common.dto.SiteStateDto import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest @@ -30,9 +29,6 @@ import org.eclipse.tractusx.bpdm.gate.entity.* import org.springframework.data.domain.Page import java.time.Instant import java.time.temporal.ChronoUnit -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry -import org.eclipse.tractusx.bpdm.gate.entity.Site -import org.eclipse.tractusx.bpdm.gate.entity.SiteState fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site?): LogisticAddress { @@ -125,13 +121,12 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity): Site { val addressInputRequest = AddressGateInputRequest( address = site.mainAddress, - externalId = externalId + "_sites", - legalEntityExternalId = externalId, - bpn = bpn + externalId = externalId + "_mainAddress", + legalEntityExternalId = externalId ) val site = Site( - bpn = bpn.toString(), + bpn = bpn, name = site.name, externalId = externalId, legalEntity = legalEntity diff --git a/bpdm-gate/src/main/resources/db/migration/V0_1_4_0__create_site_tables.sql b/bpdm-gate/src/main/resources/db/migration/V0_1_4_0__create_site_tables.sql index ad1a9d57d..2c4fef062 100644 --- a/bpdm-gate/src/main/resources/db/migration/V0_1_4_0__create_site_tables.sql +++ b/bpdm-gate/src/main/resources/db/migration/V0_1_4_0__create_site_tables.sql @@ -16,7 +16,7 @@ create table sites ( created_at timestamp with time zone not null, updated_at timestamp with time zone not null, uuid uuid not null, - bpn varchar(255) not null, + bpn varchar(255) null, external_id varchar(255) not null, name varchar(255) not null, primary key (id) @@ -28,8 +28,6 @@ alter table if exists site_states add constraint UK_qr49l0kw056r00i88edmvjwqa un alter table if exists sites add constraint UK_b2t72lxjqja93ids61sgvo4hg unique (uuid); -alter table if exists sites add constraint UK_27n4pihn8c6rh8v202wevppyu unique (bpn); - alter table if exists sites add constraint UK_1vrdeiex4x7p93r5svtvb5b4x unique (external_id); alter table if exists site_states add constraint FK7t400j8drx0gxk0davixv7n54 foreign key (site_id) references sites;