Skip to content

Commit

Permalink
feat(pool): eclipse-tractusx#556 Upsert Business Partners from Cleani…
Browse files Browse the repository at this point in the history
…ng Result

- refactor validation and persistence
  • Loading branch information
rainer-exxcellent committed Oct 27, 2023
1 parent e5ce1da commit af5bbb3
Show file tree
Hide file tree
Showing 26 changed files with 401 additions and 380 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@ data class AlternativePostalAddressDto(

override val deliveryServiceNumber: String

) : IBaseAlternativePostalAddressDto
) : IBaseAlternativePostalAddressDto {
override fun adminLevel1Key(): String? {
return administrativeAreaLevel1
}

override fun countryCode(): CountryCode {
return country
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.eclipse.tractusx.bpdm.common.dto

import com.neovisionaries.i18n.CountryCode
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.PostalAddressDescription
import org.eclipse.tractusx.bpdm.common.model.DeliveryServiceType
Expand Down Expand Up @@ -51,4 +52,8 @@ interface IBaseAlternativePostalAddressDto {

@get:Schema(description = PostalAddressDescription.deliveryServiceNumber)
val deliveryServiceNumber: String?

fun adminLevel1Key(): String?

fun countryCode(): CountryCode?
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.eclipse.tractusx.bpdm.common.dto

import com.neovisionaries.i18n.CountryCode
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.PostalAddressDescription

Expand Down Expand Up @@ -68,4 +69,8 @@ interface IBasePhysicalPostalAddressDto {

@get:Schema(description = PostalAddressDescription.door)
val door: String?

fun adminLevel1Key(): String?

fun countryCode(): CountryCode?
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import org.eclipse.tractusx.bpdm.common.dto.openapidescription.SiteDescription
@Schema(description = SiteDescription.header)
interface IBaseSiteDto {

@get:Schema(description = SiteDescription.name)
val name: String?

@get:ArraySchema(arraySchema = Schema(description = SiteDescription.states))
val states: Collection<IBaseSiteStateDto>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ data class PhysicalPostalAddressDto(

override val door: String?

) : IBasePhysicalPostalAddressDto
) : IBasePhysicalPostalAddressDto {
override fun adminLevel1Key(): String? {
return administrativeAreaLevel1
}

override fun countryCode(): CountryCode {
return country
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2021,2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

package org.eclipse.tractusx.bpdm.common.dto

interface RequestWithKey {

fun getRequestKey(): String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ import org.eclipse.tractusx.bpdm.common.dto.openapidescription.SiteDescription
@Schema(description = SiteDescription.header)
data class SiteDto(

@get:Schema(description = SiteDescription.name)
val name: String,
override val name: String,

@ArraySchema(arraySchema = Schema(description = SiteDescription.states))
val states: Collection<SiteStateDto> = emptyList(),
override val states: Collection<SiteStateDto> = emptyList(),

// TODO OpenAPI description for complex field does not work!!
@get:Schema(description = SiteDescription.mainAddress)
val mainAddress: LogisticAddressDto
)
override val mainAddress: LogisticAddressDto
) : IBaseSiteDto
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ data class AlternativePostalAddressVerboseDto(

override val deliveryServiceNumber: String

) : IBaseAlternativePostalAddressDto
) : IBaseAlternativePostalAddressDto {
override fun adminLevel1Key(): String? {
return administrativeAreaLevel1?.regionCode
}
override fun countryCode(): CountryCode {
return country.technicalKey
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,12 @@ data class PhysicalPostalAddressVerboseDto(

override val door: String?

) : IBasePhysicalPostalAddressDto
) : IBasePhysicalPostalAddressDto {
override fun adminLevel1Key(): String? {
return administrativeAreaLevel1?.regionCode
}

override fun countryCode(): CountryCode {
return country.technicalKey
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@ data class AlternativePostalAddressGateDto(

override val deliveryServiceNumber: String? = null

) : IBaseAlternativePostalAddressDto
) : IBaseAlternativePostalAddressDto {
override fun adminLevel1Key(): String? {
return administrativeAreaLevel1
}

override fun countryCode(): CountryCode? {
return country
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,12 @@ data class PhysicalPostalAddressGateDto(

override val door: String? = null

) : IBasePhysicalPostalAddressDto
) : IBasePhysicalPostalAddressDto {
override fun adminLevel1Key(): String? {
return administrativeAreaLevel1
}

override fun countryCode(): CountryCode? {
return country
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ data class AlternativePostalAddressDto(
override val deliveryServiceQualifier: String? = null,
override val deliveryServiceNumber: String? = null

) : IBaseAlternativePostalAddressDto
) : IBaseAlternativePostalAddressDto {
override fun adminLevel1Key(): String? {
return administrativeAreaLevel1
}
override fun countryCode(): CountryCode? {
return country
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ data class PhysicalPostalAddressDto(
override val floor: String? = null,
override val door: String? = null

) : IBasePhysicalPostalAddressDto
) : IBasePhysicalPostalAddressDto {
override fun adminLevel1Key(): String? {
return administrativeAreaLevel1
}

override fun countryCode(): CountryCode? {
return country
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ data class SiteDto(
@get:Schema(description = "Whether this site data is different from its golden record counterpart in the Pool")
val hasChanged: Boolean? = null,

@get:Schema(description = SiteDescription.name)
val name: String? = null,
override val name: String? = null,

override val states: Collection<SiteStateDto> = emptyList(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.eclipse.tractusx.orchestrator.api.model

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.RequestWithKey

@Schema(description = "Task reservation entry")
data class TaskStepReservationEntryDto(
Expand All @@ -29,4 +30,8 @@ data class TaskStepReservationEntryDto(

@get:Schema(description = "The business partner data to process")
val businessPartner: BusinessPartnerFullDto
)
) : RequestWithKey {
override fun getRequestKey(): String? {
return taskId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.dto.RequestWithKey
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LogisticAddressDescription
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer
Expand All @@ -39,4 +40,9 @@ data class AddressPartnerCreateRequest(

@Schema(description = CommonDescription.index)
val index: String?
)
): RequestWithKey {
override fun getRequestKey(): String? {
return index
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.dto.RequestWithKey
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LogisticAddressDescription
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

Expand All @@ -35,4 +36,8 @@ data class AddressPartnerUpdateRequest(

@field:JsonUnwrapped
val address: LogisticAddressDto
)
): RequestWithKey {
override fun getRequestKey(): String? {
return bpna
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto
import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.dto.RequestWithKey
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityDescription
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer
Expand All @@ -44,4 +45,8 @@ data class LegalEntityPartnerCreateRequest(

@get:Schema(description = CommonDescription.index)
val index: String?
)
): RequestWithKey {
override fun getRequestKey(): String? {
return index
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto
import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto
import org.eclipse.tractusx.bpdm.common.dto.RequestWithKey
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityDescription
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

Expand All @@ -43,4 +44,8 @@ data class LegalEntityPartnerUpdateRequest(
// TODO OpenAPI description for complex field does not work!!
@get:Schema(description = LegalEntityDescription.legalAddress)
val legalAddress: LogisticAddressDto,
)
): RequestWithKey {
override fun getRequestKey(): String? {
return bpnl
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.api.model.request
import com.fasterxml.jackson.annotation.JsonUnwrapped
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.RequestWithKey
import org.eclipse.tractusx.bpdm.common.dto.SiteDto
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.SiteDescription
Expand All @@ -39,4 +40,8 @@ data class SitePartnerCreateRequest(

@Schema(description = CommonDescription.index)
val index: String?
)
) : RequestWithKey {
override fun getRequestKey(): String? {
return index
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.api.model.request
import com.fasterxml.jackson.annotation.JsonUnwrapped
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.RequestWithKey
import org.eclipse.tractusx.bpdm.common.dto.SiteDto
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.SiteDescription
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer
Expand All @@ -35,4 +36,8 @@ data class SitePartnerUpdateRequest(

@field:JsonUnwrapped
val site: SiteDto
)
): RequestWithKey {
override fun getRequestKey(): String? {
return bpns
}
}

0 comments on commit af5bbb3

Please sign in to comment.