Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Consistently name endpoints, DTOs, properties in Orchestrator-API #512

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,81 +32,80 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.service.annotation.HttpExchange
import org.springframework.web.service.annotation.PostExchange

const val TagRequester = "Requester"
const val TagCleaningService = "Cleaning Service"
const val TagClient = "Task Client"
const val TagWorker = "Task Worker"

@RequestMapping("/api/cleaning-tasks", produces = [MediaType.APPLICATION_JSON_VALUE])
@HttpExchange("/api/cleaning-tasks")
interface CleaningTaskApi {
@RequestMapping("/api/golden-record-tasks", produces = [MediaType.APPLICATION_JSON_VALUE])
@HttpExchange("/api/golden-record-tasks")
interface GoldenRecordTaskApi {

@Operation(
summary = "Create new cleaning tasks for given business partner data",
description = "Create cleaning tasks for given business partner data in given cleaning mode. " +
"The mode decides through which cleaning steps the given business partner data will go through. " +
"The response contains the states of the created cleaning tasks in the order of given business partner data." +
"If there is an error in the request no cleaning tasks are created (all or nothing). " +
summary = "Create new golden record tasks for given business partner data",
description = "Create golden record tasks for given business partner data in given mode. " +
"The mode decides through which processing steps the given business partner data will go through. " +
"The response contains the states of the created tasks in the order of given business partner data." +
"If there is an error in the request no tasks are created (all or nothing). " +
"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 = "The states of successfully created cleaning tasks including the task identifier for tracking purposes."
description = "The states of successfully created tasks including the task identifier for tracking purposes."
),
ApiResponse(responseCode = "400", description = "On malformed task create requests or reaching upsert limit", content = [Content()]),
]
)
@Tag(name = TagRequester)
@Tag(name = TagClient)
@PostMapping
@PostExchange
fun createCleaningTasks(@RequestBody createRequest: TaskCreateRequest): TaskCreateResponse

fun createTasks(@RequestBody createRequest: TaskCreateRequest): TaskCreateResponse

@Operation(
summary = "Search for the state of cleaning tasks by task identifiers",
description = "Returns the state of finished cleaning tasks based on the provided task identifiers."
summary = "Search for the state of golden record tasks by task identifiers",
description = "Returns the state of golden record tasks based on the provided task identifiers."
)
@ApiResponses(
value = [
ApiResponse(
responseCode = "200",
description = "The state of the finished cleaning tasks for the provided task identifiers."
description = "The state of the tasks for the provided task identifiers."
),
ApiResponse(responseCode = "400", description = "On malformed task search requests", content = [Content()]),
]
)
@Tag(name = TagRequester)
@Tag(name = TagClient)
@PostMapping("/state/search")
@PostExchange("/state/search")
fun searchCleaningTaskState(@RequestBody searchTaskIdRequest: TaskStateRequest): TaskStateResponse
fun searchTaskStates(@RequestBody stateRequest: TaskStateRequest): TaskStateResponse

@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." +
summary = "Reserve the next golden record tasks waiting in the given step queue",
description = "Reserve up to a given number of golden record tasks in the given step queue. " +
"The response entries contain the business partner data to process which consists of the generic and L/S/A data. " +
"The reservation has a time limit which is returned. " +
"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."
description = "The reserved tasks with their business partner data to process."
),
ApiResponse(responseCode = "400", description = "On malformed task create requests or reaching upsert limit", content = [Content()]),
]
)
@Tag(name = TagCleaningService)
@PostMapping("/reservations")
@PostExchange("/reservations")
fun reserveCleaningTasks(@RequestBody reservationRequest: CleaningReservationRequest): CleaningReservationResponse
@Tag(name = TagWorker)
@PostMapping("/step-reservations")
@PostExchange("/step-reservations")
fun reserveTasksForStep(@RequestBody reservationRequest: TaskStepReservationRequest): TaskStepReservationResponse

@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'." +
summary = "Post step results for reserved golden record tasks in the given step queue",
description = "Post business partner step results for the given tasks. " +
"In order to post a result for a task it needs to be reserved first, has to currently be in the given step queue 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(
Expand All @@ -118,8 +117,8 @@ interface CleaningTaskApi {
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)
}
@Tag(name = TagWorker)
@PostMapping("/step-results")
@PostExchange("/step-results")
fun resolveStepResults(@RequestBody resultRequest: TaskStepResultRequest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@

package org.eclipse.tractusx.orchestrator.api.client

import org.eclipse.tractusx.orchestrator.api.CleaningTaskApi
import org.eclipse.tractusx.orchestrator.api.GoldenRecordTaskApi

interface OrchestrationApiClient {

val cleaningTasks: CleaningTaskApi

}
val goldenRecordTasks: GoldenRecordTaskApi
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.orchestrator.api.client

import org.eclipse.tractusx.bpdm.common.service.ParameterObjectArgumentResolver
import org.eclipse.tractusx.orchestrator.api.CleaningTaskApi
import org.eclipse.tractusx.orchestrator.api.GoldenRecordTaskApi
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.support.WebClientAdapter
import org.springframework.web.service.invoker.HttpServiceProxyFactory
Expand All @@ -44,7 +44,8 @@ class OrchestrationApiClientImpl(
.build()
}

override val cleaningTasks by lazy { createClient<CleaningTaskApi>() }
override val goldenRecordTasks by lazy { createClient<GoldenRecordTaskApi>() }

private inline fun <reified T> createClient() =
httpServiceProxyFactory.createClient(T::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package org.eclipse.tractusx.orchestrator.api.model

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.eclipse.tractusx.bpdm.common.dto.IBaseAddressStateDto
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

data class AddressState(
data class AddressStateDto(
override val description: String?,
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ 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(
data class BpnReferenceDto(

@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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ 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(
data class BusinessPartnerClassificationDto(
override val type: ClassificationType,
override val code: String?,
override val value: String?

) : IBaseClassificationDto
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ 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(
data class BusinessPartnerFullDto(

@get:Schema(description = "The business partner data in generic representation", required = true)
val generic: BusinessPartnerGeneric,
val generic: BusinessPartnerGenericDto,

@get:Schema(description = "The legal entity part of this business partner data")
val legalEntity: LegalEntity? = null,
val legalEntity: LegalEntityDto? = null,

@get:Schema(description = "The site part of this business partner data")
val site: Site? = null,
val site: SiteDto? = null,

@get:Schema(description = "The address part of this business partner data")
val address: LogisticAddress? = null
val address: LogisticAddressDto? = 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 BusinessPartnerGeneric(
data class BusinessPartnerGenericDto(
override val nameParts: List<String> = emptyList(),
override val shortName: String? = null,
override val identifiers: Collection<BusinessPartnerIdentifierDto> = emptyList(),
Expand All @@ -35,6 +35,8 @@ data class BusinessPartnerGeneric(
override val bpnL: String? = null,
override val bpnS: String? = null,
override val bpnA: String? = null,

@get:Schema(description = "The BPNL of the company sharing and claiming this business partner as its own")
val ownerBpnL: String? = null,
) : IBaseBusinessPartnerDto

) : IBaseBusinessPartnerDto

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.IBaseLegalEntityDto
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LegalEntityDescription

data class LegalEntity(
data class LegalEntityDto(

@get:Schema(description = "A reference to the BPNL of this legal entity. Either by the BPN value itself or a BPN request identifier.")
val bpnLReference: BpnReference? = null,
val bpnLReference: BpnReferenceDto? = null,

@get:Schema(description = "Whether this legal entity data is different from its golden record counterpart in the Pool")
val hasChanged: Boolean? = null,
Expand All @@ -35,13 +36,14 @@ data class LegalEntity(

override val legalShortName: String? = null,

override val identifiers: Collection<LegalEntityIdentifier> = emptyList(),
override val identifiers: Collection<LegalEntityIdentifierDto> = emptyList(),

override val legalForm: String? = null,

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

override val classifications: Collection<BusinessPartnerClassification> = emptyList(),
override val classifications: Collection<BusinessPartnerClassificationDto> = emptyList(),

override val legalAddress: LogisticAddressDto? = null

override val legalAddress: LogisticAddress? = null,
) : IBaseLegalEntityDto
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ package org.eclipse.tractusx.orchestrator.api.model

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

data class LegalEntityIdentifier(
data class LegalEntityIdentifierDto(
override val value: String,
override val type: String,
override val issuingBody: String?

) : IBaseLegalEntityIdentifierDto
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.IBaseLogisticAddressDto
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.LogisticAddressDescription

data class LogisticAddress(
data class LogisticAddressDto(

@get:Schema(description = "A reference to the BPNA of this address. Either by the BPN value itself or a BPN request identifier.")
val bpnAReference: BpnReference? = null,
val bpnAReference: BpnReferenceDto? = null,

@get:Schema(description = "Whether this address data is different from its golden record counterpart in the Pool")
val hasChanged: Boolean? = null,

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

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

override val identifiers: Collection<AddressIdentifier> = emptyList(),
override val identifiers: Collection<AddressIdentifierDto> = emptyList(),

override val physicalPostalAddress: PhysicalPostalAddressDto? = null,

override val alternativePostalAddress: AlternativePostalAddressDto? = null

) : IBaseLogisticAddressDto
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.IBaseSiteDto
import org.eclipse.tractusx.bpdm.common.dto.openapidescription.SiteDescription

data class Site(
data class SiteDto(

@get:Schema(description = "A reference to the BPNS of this site. Either by the BPN value itself or a BPN request identifier.")
val bpnSReference: BpnReference? = null,
val bpnSReference: BpnReferenceDto? = null,

@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 states: Collection<SiteState> = emptyList(),
override val states: Collection<SiteStateDto> = emptyList(),

override val mainAddress: LogisticAddressDto? = null

override val mainAddress: LogisticAddress? = null,
) : IBaseSiteDto
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.eclipse.tractusx.bpdm.common.dto.IBaseSiteStateDto
import org.eclipse.tractusx.bpdm.common.model.BusinessStateType
import java.time.LocalDateTime

data class SiteState(
data class SiteStateDto(
override val description: String?,
override val validFrom: LocalDateTime?,
override val validTo: LocalDateTime?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.eclipse.tractusx.orchestrator.api.model

enum class ReservationState {
enum class StepState {
Queued,
Reserved
}
Loading