Skip to content

Commit

Permalink
feat(Gate): replace name with name parts collection in site DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoprow committed Jun 9, 2023
1 parent 1e5a5c3 commit 9e0847b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
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

0 comments on commit 9e0847b

Please sign in to comment.