Skip to content

Commit

Permalink
feat(generic bpm): eclipse-tractusx#387 Gate API: Create output endpo…
Browse files Browse the repository at this point in the history
…ints for generic business partner
  • Loading branch information
rainer-exxcellent authored and martinfkaeser committed Sep 8, 2023
1 parent d717cdd commit ace0745
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ 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.BusinessPartnerInputDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerOutputDto
import org.springdoc.core.annotations.ParameterObject
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.PostMapping
Expand Down Expand Up @@ -65,7 +66,7 @@ interface GateBusinessPartnerApi {
)
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "The requested page of business partners"),
ApiResponse(responseCode = "200", description = "The requested page of busines partners"),
ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]),
]
)
Expand All @@ -76,4 +77,23 @@ interface GateBusinessPartnerApi {
@RequestBody externalIds: Collection<String>
): PageDto<BusinessPartnerInputDto>


@Operation(
summary = "Search business partners by an array of external IDs from the output stage",
description = "Get page of business partners output data filtered by a collection of external IDs. " +
"An empty external ID list will return a paginated list of all business partners."
)
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "The requested page of business partners"),
ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]),
]
)
@PostMapping("/output/business-partners/search")
@PostExchange("/output/business-partners/search")
fun getLegalEntitiesOutput(
@ParameterObject @Valid paginationRequest: PaginationRequest,
@RequestBody(required = false) externalIds: Collection<String>?
): PageDto<BusinessPartnerOutputDto>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*******************************************************************************
* 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 output with external id", requiredProperties = ["externalId", "postalAddress", "bpna", "bpnl"])
data class BusinessPartnerOutputDto(
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 = "BPNA")
val bpna: String,

@get:Schema(description = "BPNS")
val bpns: String?,

@get:Schema(description = "BPNL")
val bpnl: String,

@get:Schema(description = CommonDescription.createdAt)
val createdAt: Instant,

@get:Schema(description = CommonDescription.updatedAt)
val updatedAt: Instant,
) : IBaseBusinessPartnerInputDto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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.BusinessPartnerInputDto
import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerOutputDto
import org.springframework.web.bind.annotation.RestController

@RestController
Expand All @@ -39,4 +40,10 @@ class BusinessPartnerController() : GateBusinessPartnerApi {
): PageDto<BusinessPartnerInputDto> {
TODO("Not yet implemented")
}

override fun getLegalEntitiesOutput(paginationRequest: PaginationRequest, externalIds: Collection<String>?): PageDto<BusinessPartnerOutputDto> {
TODO("Not yet implemented")
}


}

0 comments on commit ace0745

Please sign in to comment.