forked from eclipse-tractusx/bpdm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(generic bpm): eclipse-tractusx#384 Gate API: Create input endpoi…
…nts for generic business partner
- Loading branch information
1 parent
6f8f9de
commit 94cb5c7
Showing
8 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/******************************************************************************* | ||
* 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.gate.api | ||
|
||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.media.Content | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses | ||
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.springdoc.core.annotations.ParameterObject | ||
import org.springframework.http.MediaType | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.PutMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.service.annotation.HttpExchange | ||
import org.springframework.web.service.annotation.PostExchange | ||
import org.springframework.web.service.annotation.PutExchange | ||
|
||
@RequestMapping("/api/catena", produces = [MediaType.APPLICATION_JSON_VALUE]) | ||
@HttpExchange("/api/catena") | ||
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. " + | ||
"For a single request, the maximum number of business partners in the request is limited to \${bpdm.api.upsert-limit} entries." | ||
) | ||
@ApiResponses( | ||
value = [ | ||
ApiResponse(responseCode = "200", description = "Business partner were successfully updated or created"), | ||
ApiResponse(responseCode = "400", description = "On malformed legal entity request", content = [Content()]), | ||
] | ||
) | ||
@PutMapping("/input/business-partners") | ||
@PutExchange("/input/business-partners") | ||
fun upsertBusinessPartnersInput(@RequestBody businessPartners: Collection<BusinessPartnerInputRequest>): Collection<BusinessPartnerInputResponseDto> | ||
|
||
@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." | ||
) | ||
@ApiResponses( | ||
value = [ | ||
ApiResponse(responseCode = "200", description = "The requested page of busines partners"), | ||
ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), | ||
] | ||
) | ||
@PostMapping("/input/business-partners/search") | ||
@PostExchange("/input/business-partners/search") | ||
fun getBusinessPartnersInputByExternalIds( | ||
@ParameterObject @Valid paginationRequest: PaginationRequest, | ||
@RequestBody externalIds: Collection<String> | ||
): PageDto<BusinessPartnerInputResponseDto> | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
.../src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerIdentifierDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/******************************************************************************* | ||
* 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.gate.api.model | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
@Schema(description = "Identifier record for a business partner", requiredProperties = ["type"]) | ||
data class BusinessPartnerIdentifierDto( | ||
|
||
@get:Schema(description = "Value of the identifier") | ||
val value: String, | ||
|
||
@get:Schema(description = "Technical key of the type to which this identifier belongs to") | ||
val type: String, | ||
|
||
@get:Schema(description = "Body which issued the identifier") | ||
val issuingBody: String? | ||
) |
42 changes: 42 additions & 0 deletions
42
...c/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerPostalAddressDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* 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.gate.api.model | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
import org.eclipse.tractusx.bpdm.common.dto.AlternativePostalAddressDto | ||
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LogisticAddressDescription | ||
|
||
@Schema(description = "Postal address of a business partner", requiredProperties = ["physicalPostalAddress"]) | ||
data class BusinessPartnerPostalAddressDto( | ||
|
||
@get:Schema(name = "isLegalAddress", description = LogisticAddressDescription.isLegalAddress) | ||
val isLegalAddress: Boolean = false, | ||
|
||
@get:Schema(name = "isSiteMainAddress", description = LogisticAddressDescription.isMainAddress) | ||
val isSiteMainAddress: Boolean = false, | ||
|
||
// TODO OpenAPI description for complex field does not work!! | ||
@get:Schema(description = LogisticAddressDescription.physicalPostalAddress) | ||
val physicalPostalAddress: PhysicalPostalAddressGateDto, | ||
|
||
// TODO OpenAPI description for complex field does not work!! | ||
@get:Schema(description = LogisticAddressDescription.alternativePostalAddress) | ||
val alternativePostalAddress: AlternativePostalAddressDto? = null | ||
) |
41 changes: 41 additions & 0 deletions
41
...e-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerStateDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/******************************************************************************* | ||
* 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.gate.api.model | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityStateDescription | ||
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType | ||
import java.time.LocalDateTime | ||
|
||
@Schema(description = LegalEntityStateDescription.header, requiredProperties = ["type"]) | ||
data class BusinessPartnerStateDto( | ||
|
||
@get:Schema(description = "Exact, official denotation of the status") | ||
val description: String?, | ||
|
||
@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") | ||
val validTo: LocalDateTime?, | ||
|
||
@get:Schema(description = "The type of this specified status") | ||
val type: BusinessStateType | ||
) |
63 changes: 63 additions & 0 deletions
63
.../src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerInputDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/******************************************************************************* | ||
* 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.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 | ||
|
||
|
||
interface IBaseBusinessPartnerInputDto { | ||
|
||
@get:Schema(description = "ID the record has in the external system where the record originates from") | ||
val externalId: String | ||
|
||
@get:Schema(description = "") | ||
val nameParts: List<String> | ||
|
||
@get:Schema(description = "Abbreviated name or shorthand") | ||
val shortName: String? | ||
|
||
@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.identifiers)) | ||
val identifiers: Collection<BusinessPartnerIdentifierDto> | ||
|
||
@get:Schema(description = "Technical key of the legal form") | ||
val legalForm: String? | ||
|
||
@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.states)) | ||
val states: Collection<BusinessPartnerStateDto> | ||
|
||
@get:ArraySchema(arraySchema = Schema(description = LegalEntityDescription.classifications)) | ||
val classifications: Collection<ClassificationDto> | ||
|
||
@get:Schema(description = "Which roles this business partner takes in relation to the sharing member") | ||
val roles: Collection<BusinessPartnerRole> | ||
|
||
@get:Schema(description = "") | ||
val isOwner: Boolean | ||
|
||
@get:Schema(description = "Address of the official seat of this legal entity") | ||
val postalAddress: BusinessPartnerPostalAddressDto | ||
|
||
|
||
} | ||
|
||
|
39 changes: 39 additions & 0 deletions
39
...in/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/******************************************************************************* | ||
* 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.gate.api.model.request | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
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"]) | ||
data class BusinessPartnerInputRequest( | ||
override val externalId: String, | ||
override val nameParts: List<String> = emptyList(), | ||
override val shortName: String?, | ||
override val identifiers: Collection<BusinessPartnerIdentifierDto> = emptyList(), | ||
override val legalForm: String? = null, | ||
override val states: Collection<BusinessPartnerStateDto> = emptyList(), | ||
override val classifications: Collection<ClassificationDto> = emptyList(), | ||
override val roles: Collection<BusinessPartnerRole> = emptyList(), | ||
override val postalAddress: BusinessPartnerPostalAddressDto, | ||
override val isOwner: Boolean | ||
) : IBaseBusinessPartnerInputDto |
47 changes: 47 additions & 0 deletions
47
...tlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerInputResponseDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* 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.gate.api.model.response | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
import org.eclipse.tractusx.bpdm.common.dto.ClassificationDto | ||
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription | ||
import org.eclipse.tractusx.bpdm.gate.api.model.* | ||
import java.time.Instant | ||
|
||
|
||
@Schema(description = "Generic business partner with external id", requiredProperties = ["externalId", "postalAddress"]) | ||
data class BusinessPartnerInputResponseDto( | ||
override val externalId: String, | ||
override val nameParts: List<String> = emptyList(), | ||
override val shortName: String?, | ||
override val identifiers: Collection<BusinessPartnerIdentifierDto> = emptyList(), | ||
override val legalForm: String? = null, | ||
override val states: Collection<BusinessPartnerStateDto> = emptyList(), | ||
override val classifications: Collection<ClassificationDto> = emptyList(), | ||
override val roles: Collection<BusinessPartnerRole> = emptyList(), | ||
override val postalAddress: BusinessPartnerPostalAddressDto, | ||
override val isOwner: Boolean, | ||
|
||
@get:Schema(description = CommonDescription.createdAt) | ||
val createdAt: Instant, | ||
|
||
@get:Schema(description = CommonDescription.updatedAt) | ||
val updatedAt: Instant, | ||
) : IBaseBusinessPartnerInputDto |
42 changes: 42 additions & 0 deletions
42
...te/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* 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.gate.controller | ||
|
||
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.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
class BusinessPartnerController() : GateBusinessPartnerApi { | ||
|
||
override fun upsertBusinessPartnersInput(businessPartners: Collection<BusinessPartnerInputRequest>): Collection<BusinessPartnerInputResponseDto> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getBusinessPartnersInputByExternalIds( | ||
paginationRequest: PaginationRequest, | ||
externalIds: Collection<String> | ||
): PageDto<BusinessPartnerInputResponseDto> { | ||
TODO("Not yet implemented") | ||
} | ||
} |