Skip to content

Commit

Permalink
feat(orchestrator): add cleaning step endpoints to the api
Browse files Browse the repository at this point in the history
- add reservation and resolve endpoints to the orchestrator API
- add DTO model for L/S/A business partners
- connect endpoints with orchestrator controller
- return static dummy data on endpoint invocation
- add tests for validating endpoint invocation and dummy data return
  • Loading branch information
nicoprow committed Sep 27, 2023
1 parent 708fc6b commit 19f02d7
Show file tree
Hide file tree
Showing 28 changed files with 1,398 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ interface IBaseLegalEntityDto {

// TODO OpenAPI description for complex field does not work!!
@get:Schema(description = LegalEntityDescription.legalAddress)
val legalAddress: IBaseLogisticAddressDto
val legalAddress: IBaseLogisticAddressDto?
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface IBaseLogisticAddressDto {

// TODO OpenAPI description for complex field does not work!!
@get:Schema(description = LogisticAddressDescription.physicalPostalAddress)
val physicalPostalAddress: IBasePhysicalPostalAddressDto
val physicalPostalAddress: IBasePhysicalPostalAddressDto?

// TODO OpenAPI description for complex field does not work!!
@get:Schema(description = LogisticAddressDescription.alternativePostalAddress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ 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>

// TODO OpenAPI description for complex field does not work!!
@get:Schema(description = SiteDescription.mainAddress)
val mainAddress: IBaseLogisticAddressDto
val mainAddress: IBaseLogisticAddressDto?
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ 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 io.swagger.v3.oas.annotations.tags.Tag
import org.eclipse.tractusx.orchestrator.api.model.TaskCreateRequest
import org.eclipse.tractusx.orchestrator.api.model.TaskCreateResponse
import org.eclipse.tractusx.orchestrator.api.model.*
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
Expand Down Expand Up @@ -59,5 +58,46 @@ interface CleaningTaskApi {
@PostExchange
fun createCleaningTasks(@RequestBody createRequest: TaskCreateRequest): TaskCreateResponse

@Operation(
summary = "Reserve the next cleaning tasks waiting in the given cleaning step",
description = "Reserve up to a given number of cleaning tasks enqueued in the given cleaning step. " +
"The cleaning tasks contain the business partner to clean which consists of the generic and L/S/A data. " +
"For cleaning the business partners have a time limit which is returned with the reserved tasks." +
"For a single request, the maximum number of reservable tasks is limited to \${bpdm.api.upsert-limit}."
)
@ApiResponses(
value = [
ApiResponse(
responseCode = "200",
description = "The reserved cleaning tasks with their business partner data to clean."
),
ApiResponse(responseCode = "400", description = "On malformed task create requests or reaching upsert limit", content = [Content()]),
]
)
@Tag(name = "Cleaning Service")
@PostMapping("/reservations")
@PostExchange("/reservations")
fun reserveCleaningTasks(@RequestBody reservationRequest: CleaningReservationRequest): CleaningReservationResponse

@Operation(
summary = "Post cleaning results for reserved cleaning tasks in given cleaning step",
description = "Post business partner cleaning results for the given cleaning tasks. " +
"In order to post a result for a cleaning task it needs to be reserved first, has to currently be in the given cleaning step and the time limit is not exceeded." +
"The number of results you can post at a time does not need to match the original number of reserved tasks." +
"Results are accepted via strategy 'all or nothing'." +
"For a single request, the maximum number of postable results is limited to \${bpdm.api.upsert-limit}."
)
@ApiResponses(
value = [
ApiResponse(
responseCode = "200",
description = "If the results could be processed"
),
ApiResponse(responseCode = "400", description = "On malformed task create requests or reaching upsert limit", content = [Content()]),
]
)
@Tag(name = "Cleaning Service")
@PostMapping("/results")
@PostExchange("/results")
fun resolveCleaningTasks(@RequestBody resultRequest: CleaningResultRequest)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* 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.orchestrator.api.model

import org.eclipse.tractusx.bpdm.common.dto.IBaseAddressIdentifierDto

data class AddressIdentifier(
override val value: String,
override val type: String

) : IBaseAddressIdentifierDto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* 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.orchestrator.api.model

import org.eclipse.tractusx.bpdm.common.dto.IBaseAddressSateDto
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

data class AddressState(
override val description: String?,
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
override val type: BusinessStateType

) : IBaseAddressSateDto
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.orchestrator.api.model

import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "A reference to the BPN of a business partner. Either by the BPN value itself or a BPN request identifier")
data class BpnReference(
@get:Schema(description = "The value by which the BPN is referenced")
val referenceValue: String,
@get:Schema(description = "The type by which to reference the BPN with")
val referenceType: BpnReferenceType
)

enum class BpnReferenceType {
Bpn,
BpnRequestIdentifier
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*******************************************************************************
* 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.orchestrator.api.model

import org.eclipse.tractusx.bpdm.common.dto.IBaseClassificationDto
import org.eclipse.tractusx.bpdm.common.model.ClassificationType

data class BusinessPartnerClassification(
override val type: ClassificationType,
override val code: String?,
override val value: String?
) : IBaseClassificationDto
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* 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.orchestrator.api.model

import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "Business partner data in full representation, consisting of generic data as well as its L/S/A representation.")
data class BusinessPartnerFull(
@get:Schema(description = "The business partner data in generic representation", required = true)
val generic: BusinessPartnerGeneric,
@get:Schema(description = "The legal entity part of this business partner data")
val legalEntity: LegalEntity? = null,
@get:Schema(description = "The site part of this business partner data")
val site: Site? = null,
@get:Schema(description = "The address part of this business partner data")
val address: LogisticAddress? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.*


data class BusinessPartnerDto(
data class BusinessPartnerGeneric(
override val nameParts: List<String> = emptyList(),
override val shortName: String? = null,
override val identifiers: Collection<BusinessPartnerIdentifierDto> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*******************************************************************************
* 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.orchestrator.api.model

import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "Cleaning reservation entry")
data class CleaningReservation(
@get:Schema(description = "The identifier of the reserved cleaning task")
val taskId: String,
@get:Schema(description = "The business partner data to clean")
val businessPartner: BusinessPartnerFull
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*******************************************************************************
* 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.orchestrator.api.model

import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "Request object for reserving a number of cleaning tasks waiting in a cleaning step.")
data class CleaningReservationRequest(
@get:Schema(description = "The maximum number of cleaning tasks to reserve. Can be fewer if queue is not full enough.", required = true)
val amount: Int = 10,
@get:Schema(description = "The cleaning step queue to reserve from", required = true)
val step: CleaningStep
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* 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.orchestrator.api.model

import io.swagger.v3.oas.annotations.media.ArraySchema
import io.swagger.v3.oas.annotations.media.Schema
import java.time.Instant

@Schema(description = "Response object for giving a list of reserved cleaning tasks")
data class CleaningReservationResponse(
@get:ArraySchema(arraySchema = Schema(description = "The reserved cleaning tasks with their business partner data to clean"))
val reservedTasks: List<CleaningReservation>,
@get:Schema(description = "The timestamp until the reservation is valid and accepts cleaning results")
val timeout: Instant
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* 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.orchestrator.api.model

import io.swagger.v3.oas.annotations.media.ArraySchema
import io.swagger.v3.oas.annotations.media.Schema


@Schema(description = "A cleaning result for a cleaning task")
data class CleaningResultEntry(
@get:Schema(description = "The identifier of the cleaning task for which this is a result", required = true)
val taskId: String,
@get:Schema(description = "The actual result in form of business partner data. Maybe null if an error occurred during cleaning of this task.")
val result: BusinessPartnerFull? = null,
@get:ArraySchema(arraySchema = Schema(description = "Errors that occurred during cleaning of this task"))
val errors: List<TaskError> = emptyList()
)
Loading

0 comments on commit 19f02d7

Please sign in to comment.