Skip to content

Commit

Permalink
feat(generic bpm): eclipse-tractusx#384 Gate API: Create input endpoi…
Browse files Browse the repository at this point in the history
…nts for generic business partners

- Comments from the review incorporate
  • Loading branch information
rainer-exxcellent committed Sep 7, 2023
1 parent 655785d commit 158a83f
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ object CommonDescription {
const val score = "Relative quality score of the match. The higher the better."

const val externalId = "The identifier which uniquely identifies (in the internal system landscape of the sharing member) the business partner."

const val roles = "Roles this business partner takes in relation to the sharing member."

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ object LegalEntityDescription {
const val states = "The list of (temporary) states of the legal entity."
const val classifications = "The list of classifications of the legal entity, such as a specific industry."
const val relations = "Relations to other business partners."
const val roles = "Roles this business partner takes in relation to the sharing member."

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import jakarta.validation.Valid
import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.PageDto
import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerInputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerInputResponseDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerInputDto
import org.springdoc.core.annotations.ParameterObject
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.PostMapping
Expand All @@ -45,8 +45,8 @@ interface GateBusinessPartnerApi {
@Operation(
summary = "Create or update business partner with given external ID",
description = "Create or update generic business partner. " +
"Updates instead of creating a new business partner if an already existing external id is used. " +
"The same external id may not occur more than once in a single request. " +
"Updates instead of creating a new business partner if an already existing external ID is used. " +
"The same external ID may not occur more than once in a single request. " +
"For a single request, the maximum number of business partners in the request is limited to \${bpdm.api.upsert-limit} entries."
)
@ApiResponses(
Expand All @@ -57,15 +57,15 @@ interface GateBusinessPartnerApi {
)
@PutMapping("/input/business-partners")
@PutExchange("/input/business-partners")
fun upsertBusinessPartnersInput(@RequestBody businessPartners: Collection<BusinessPartnerInputRequest>): Collection<BusinessPartnerInputResponseDto>
fun upsertBusinessPartnersInput(@RequestBody businessPartners: Collection<BusinessPartnerInputRequest>): Collection<BusinessPartnerInputDto>

@Operation(
summary = "Search business partner by external ID. An empty external ID list returns a paginated list of all business partners.",
description = "Get page of business partners filtered by a collection of externalIds."
description = "Get page of business partners filtered by a collection of external IDs."
)
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "The requested page of busines partners"),
ApiResponse(responseCode = "200", description = "The requested page of business partners"),
ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]),
]
)
Expand All @@ -74,6 +74,6 @@ interface GateBusinessPartnerApi {
fun getBusinessPartnersInputByExternalIds(
@ParameterObject @Valid paginationRequest: PaginationRequest,
@RequestBody externalIds: Collection<String>
): PageDto<BusinessPartnerInputResponseDto>
): PageDto<BusinessPartnerInputDto>

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import io.swagger.v3.oas.annotations.media.Schema
data class BusinessPartnerIdentifierDto(

@get:Schema(description = "Value of the identifier")
val value: String,
val value: String?,

@get:Schema(description = "Technical key of the type to which this identifier belongs to")
val type: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import java.time.LocalDateTime
@Schema(description = LegalEntityStateDescription.header, requiredProperties = ["type"])
data class BusinessPartnerStateDto(

@get:Schema(description = "Exact, official denotation of the status")
@get:Schema(description = "Denotation of the status.")
val description: String?,

@get:Schema(description = "Date since when the status is/was valid")
@get:Schema(description = "Date since when the status is/was valid.")
val validFrom: LocalDateTime?,

@get:Schema(description = "Date until the status was valid, if applicable")
@get:Schema(description = "Date until the status was valid, if applicable.")
val validTo: LocalDateTime?,

@get:Schema(description = "The type of this specified status")
@get:Schema(description = "The type of this specified status.")
val type: BusinessStateType
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ package org.eclipse.tractusx.bpdm.gate.api.model
import io.swagger.v3.oas.annotations.media.ArraySchema
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityDescription

import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription

interface IBaseBusinessPartnerInputDto {

@get:Schema(description = "ID the record has in the external system where the record originates from")
@get:Schema(description = CommonDescription.externalId)
val externalId: String

@get:Schema(description = "")
Expand All @@ -36,25 +35,25 @@ interface IBaseBusinessPartnerInputDto {
@get:Schema(description = "Abbreviated name or shorthand")
val shortName: String?

@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.identifiers))
@get:ArraySchema(arraySchema = Schema(description = "The list of identifiers of the business partner."))
val identifiers: Collection<BusinessPartnerIdentifierDto>

@get:Schema(description = "Technical key of the legal form")
@get:Schema(description = "Technical key of the legal form.")
val legalForm: String?

@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.states))
@get:ArraySchema(arraySchema = Schema(description = "The list of (temporary) states of the business partner."))
val states: Collection<BusinessPartnerStateDto>

@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.classifications))
@get:ArraySchema(arraySchema = Schema(description = "The list of classifications of the legal entity, such as a specific industry."))
val classifications: Collection<ClassificationDto>

@get:Schema(description = "Which roles this business partner takes in relation to the sharing member")
@get:ArraySchema(arraySchema = Schema(description = CommonDescription.roles))
val roles: Collection<BusinessPartnerRole>

@get:Schema(description = "")
@get:Schema(name = "isOwner", description = "True if the sharing member declares itself as the owner of the business partner.")
val isOwner: Boolean

@get:Schema(description = "Address of the official seat of this legal entity")
@get:Schema(description = "Address of the official seat of this business partner.")
val postalAddress: BusinessPartnerPostalAddressDto


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto
import org.eclipse.tractusx.bpdm.gate.api.model.*


@Schema(name = "BusinessPartnerInputDto", description = "Generic business partner with external id", requiredProperties = ["externalId", "postalAddress"])
@Schema(description = "Generic business partner with external id", requiredProperties = ["externalId", "postalAddress"])
data class BusinessPartnerInputRequest(
override val externalId: String,
override val nameParts: List<String> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ data class LegalEntityGateInputRequest(
@field:JsonUnwrapped
val legalEntity: LegalEntityDto,

@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.roles))
@get:ArraySchema(arraySchema = Schema(description = CommonDescription.roles))
val roles: Collection<BusinessPartnerRole> = emptyList(),

// TODO OpenAPI description for complex field does not work!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ data class LegalEntityGateOutputRequest(
@field:JsonUnwrapped
val legalEntity: LegalEntityDto,

@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.roles))
@get:ArraySchema(arraySchema = Schema(description = CommonDescription.roles))
val roles: Collection<BusinessPartnerRole> = emptyList(),

// TODO OpenAPI description for complex field does not work!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.time.Instant


@Schema(description = "Generic business partner with external id", requiredProperties = ["externalId", "postalAddress"])
data class BusinessPartnerInputResponseDto(
data class BusinessPartnerInputDto(
override val externalId: String,
override val nameParts: List<String> = emptyList(),
override val shortName: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ data class LegalEntityGateInputDto(
@field:JsonUnwrapped
val legalEntity: LegalEntityDto,

@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.roles))
@get:ArraySchema(arraySchema = Schema(description = CommonDescription.roles))
val roles: Collection<BusinessPartnerRole> = emptyList(),

// TODO OpenAPI description for complex field does not work!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data class LegalEntityGateOutputResponse(
@field:JsonUnwrapped
val legalEntity: LegalEntityDto,

@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.roles))
@get:ArraySchema(arraySchema = Schema(description = CommonDescription.roles))
val roles: Collection<BusinessPartnerRole> = emptyList(),

// TODO OpenAPI description for complex field does not work!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.PageDto
import org.eclipse.tractusx.bpdm.gate.api.GateBusinessPartnerApi
import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerInputRequest
import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerInputResponseDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerInputDto
import org.springframework.web.bind.annotation.RestController

@RestController
class BusinessPartnerController() : GateBusinessPartnerApi {

override fun upsertBusinessPartnersInput(businessPartners: Collection<BusinessPartnerInputRequest>): Collection<BusinessPartnerInputResponseDto> {
override fun upsertBusinessPartnersInput(businessPartners: Collection<BusinessPartnerInputRequest>): Collection<BusinessPartnerInputDto> {
TODO("Not yet implemented")
}

override fun getBusinessPartnersInputByExternalIds(
paginationRequest: PaginationRequest,
externalIds: Collection<String>
): PageDto<BusinessPartnerInputResponseDto> {
): PageDto<BusinessPartnerInputDto> {
TODO("Not yet implemented")
}
}

0 comments on commit 158a83f

Please sign in to comment.