Skip to content

Commit

Permalink
Fix(gate/pool):changed bpn to nullable and removed unique constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaralexandremorais committed May 4, 2023
1 parent 67ae1d8 commit 32f6aab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 32f6aab

Please sign in to comment.