Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gate API: Replace Name with Name Parts in Site #255

Merged
merged 1 commit into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class PoolUpdateService(
?.let { leParentBpn ->
SitePartnerCreateRequest(
site = SiteDto(
name = entry.site.name,
name = entry.site.nameParts.firstOrNull()?: "",
states = entry.site.states,
mainAddress = gateToPoolLogisticAddress(entry.site.mainAddress),
),
Expand All @@ -131,7 +131,7 @@ class PoolUpdateService(
val updateRequests = entriesToUpdate.map {
SitePartnerUpdateRequest(
site = SiteDto(
name = it.site.name,
name = it.site.nameParts.firstOrNull()?: "",
states = it.site.states,
mainAddress = gateToPoolLogisticAddress(it.site.mainAddress),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import org.eclipse.tractusx.bpdm.common.dto.SiteStateDto

@Schema(name = "Site", description = "Site record")
data class SiteGateDto(
@get:Schema(description = "Site name")
val name: String,
@get:Schema(description = "Parts that make up the name of that site")
val nameParts: Collection<String> = emptyList(),

@ArraySchema(arraySchema = Schema(description = "Business status"))
val states: Collection<SiteStateDto> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputIn
)

val site = Site(
name = site.name,
name = site.nameParts.firstOrNull()?: "",
externalId = externalId,
legalEntity = legalEntity,
dataType = datatype
Expand All @@ -160,7 +160,7 @@ fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputI

val site = Site(
bpn = bpn,
name = site.name,
name = site.nameParts.firstOrNull()?: "",
externalId = externalId,
legalEntity = legalEntity,
dataType = datatype
Expand Down Expand Up @@ -399,7 +399,7 @@ fun LegalEntity.LegalEntityGateInputResponse(legalEntity: LegalEntity): LegalEnt
fun Site.toSiteDto(): SiteGateDto {

return SiteGateDto(
name = name,
nameParts = if(name.isEmpty()) emptyList() else listOf(name),
states = mapToDtoSitesStates(states),
mainAddress = mainAddress.toLogisticAddressDto()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SaasRequestMappingService(
dataSource = saasConfigProperties.datasource,
types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.ORGANIZATIONAL_UNIT.name)),
identifiers = toIdentifiersSaas(""),
names = toNamesSaas(site.name),
names = toNamesSaas(site.nameParts.firstOrNull()),
status = site.states.map { it.toSaasModel() }.firstOrNull(),
// TODO Known issue: Name, state, BPN-A and identifiers of the main address are not transferred to SaaS yet!!
addresses = toAddressesSaasModel(site.mainAddress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class SitePersistenceService(

private fun updateSite(site: Site, updatedSite: SiteGateInputRequest, legalEntityRecord: LegalEntity) {

site.name = updatedSite.site.name
site.name = updatedSite.site.nameParts.firstOrNull() ?: ""
site.externalId = updatedSite.externalId
site.legalEntity = legalEntityRecord
site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) })
Expand Down Expand Up @@ -138,7 +138,7 @@ class SitePersistenceService(
private fun updateSiteOutput(site: Site, updatedSite: SiteGateOutputRequest, legalEntityRecord: LegalEntity) {

site.bpn = updatedSite.bpn
site.name = updatedSite.site.name
site.name = updatedSite.site.nameParts.firstOrNull() ?: ""
site.externalId = updatedSite.externalId
site.legalEntity = legalEntityRecord
site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@ object RequestValues {
)

val site1 = SiteGateDto(
name = CommonValues.nameSite1,
nameParts = listOf(CommonValues.nameSite1),
states = listOf(siteBusinessStatus1),
mainAddress = address1
)

val site2 = SiteGateDto(
name = CommonValues.nameSite2,
nameParts = listOf(CommonValues.nameSite2),
states = listOf(siteBusinessStatus2),
mainAddress = address2
)
Expand Down