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

feat(impl):[TRI-1664] new batch api endpoints impl #561

Merged
merged 20 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
34e2c2c
feat(impl):[TRI-1664] new batch api endpoints impl
ds-ext-kmassalski Oct 2, 2023
c55ea1b
feat(impl):[TRI-1664] new api endpoint
ds-ext-kmassalski Oct 3, 2023
233c856
feat(impl):[TRI-1664] update api impl
ds-ext-kmassalski Oct 3, 2023
026d296
feat(impl):[TRI-1664] change default bpn allowed api
ds-ext-kmassalski Oct 3, 2023
e65cc7a
Update irs-api/src/main/java/org/eclipse/tractusx/irs/controllers/Bat…
ds-ext-kmassalski Oct 4, 2023
0072e4e
Update irs-api/src/main/java/org/eclipse/tractusx/irs/controllers/Bat…
ds-ext-kmassalski Oct 4, 2023
595b792
Update irs-models/src/main/java/org/eclipse/tractusx/irs/component/Re…
ds-ext-kmassalski Oct 4, 2023
b84cf42
feat(impl):[TRI-1664] fix tests
ds-ext-kmassalski Oct 4, 2023
c204308
Merge branch 'main' into feature/TRI-1664-new-batch-api-endpoint
ds-ext-kmassalski Oct 4, 2023
d346572
feat(impl):[TRI-1664] merge main
ds-ext-kmassalski Oct 4, 2023
8b15cd9
feat(impl):[TRI-1664] cleanup - move code from IrsService responsibility
ds-ext-kmassalski Oct 4, 2023
a19c6fc
Merge branch 'feature/TRI-1678-fix-jsonschema-validation' into featur…
ds-ext-kmassalski Oct 5, 2023
7a5f7c3
feat(impl):[TRI-1664] fix code smells
ds-ext-kmassalski Oct 5, 2023
e597629
Merge branch 'main' into feature/TRI-1664-new-batch-api-endpoint
ds-ext-kmassalski Oct 5, 2023
39b4704
feat(impl):[TRI-1664] fix test
ds-ext-kmassalski Oct 5, 2023
4cdb21f
feat(impl):[TRI-1664] cover with more unit tests
ds-ext-kmassalski Oct 5, 2023
d6193cf
Merge branch 'main' into feature/TRI-1664-new-batch-api-endpoint
ds-ext-kmassalski Oct 5, 2023
150f628
Merge branch 'main' into feature/TRI-1664-new-batch-api-endpoint
ds-ext-kmassalski Oct 9, 2023
da4b773
feat(impl):[TRI-1664] update changelog, merge main
ds-ext-kmassalski Oct 9, 2023
c6e3bbe
feat(impl):[TRI-1664] fix test
ds-ext-kmassalski Oct 9, 2023
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
137 changes: 127 additions & 10 deletions docs/src/api/irs-v1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,61 @@ paths:
summary: Accepts notifications sent via EDC.
tags:
- Environmental- and Social Standards
/irs/ess/orders:
post:
description: "Registers an order for an ESS investigation with an array of
{globalAssetIds}. Each globalAssetId will be processed in an separate job, grouped in batches."
operationId: registerESSInvestigationOrder
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RegisterBpnInvestigationBatchOrder'
required: true
responses:
"201":
content:
application/json:
examples:
complete:
$ref: '#/components/examples/job-handle'
schema:
$ref: '#/components/schemas/BatchOrderCreated'
description: Returns orderId of registered Batch order.
"400":
content:
application/json:
examples:
error:
$ref: '#/components/examples/error-response-400'
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Batch Order registration failed.
"401":
content:
application/json:
examples:
error:
$ref: '#/components/examples/error-response-401'
schema:
$ref: '#/components/schemas/ErrorResponse'
description: No valid authentication credentials.
"403":
content:
application/json:
examples:
error:
$ref: '#/components/examples/error-response-403'
schema:
$ref: '#/components/schemas/ErrorResponse'
description: Authorization refused by server.
security:
- oAuth2:
- profile email
summary: "Registers an order for an ESS investigation with an array of {globalAssetIds}.
Each globalAssetId will be processed in an separate job, grouped in batches."
tags:
- Environmental- and Social Standards
/irs/jobs:
get:
description: Returns paginated jobs with state and execution times.
Expand Down Expand Up @@ -759,7 +814,7 @@ paths:
responses:
"200":
content:
'application/json':
application/json:
schema:
type: array
items:
Expand Down Expand Up @@ -1155,8 +1210,8 @@ components:
- language: en
text: The shell for a vehicle
globalAssetId: urn:uuid:a45a2246-f6e1-42da-b47d-5c3b58ed62e9
idShort: future concept x
id: 882fc530-b69b-4707-95f6-5dbc5e9baaa8
idShort: future concept x
specificAssetIds:
- name: engineserialid
value: "12309481209312"
Expand Down Expand Up @@ -1186,13 +1241,13 @@ components:
href: https://catena-x.net/vehicle/partdetails/
endpointProtocol: HTTPS
endpointProtocolVersion: ["1.0"]
idShort: vehicle part details
id: dae4d249-6d66-4818-b576-bf52f3b9ae90
idShort: vehicle part details
semanticId:
type: ModelReference
keys:
- type: Submodel
value: urn:bamm:com.catenax.vehicle:0.1.1#PartDetails
type: ModelReference
submodels:
- aspectType: urn:bamm:io.catenax.single_level_bom_as_built:1.0.0
identification: urn:uuid:fc784d2a-5506-4e61-8e34-21600f8cdeff
Expand Down Expand Up @@ -1335,8 +1390,8 @@ components:
- language: en
text: The shell for a vehicle
globalAssetId: urn:uuid:a45a2246-f6e1-42da-b47d-5c3b58ed62e9
idShort: future concept x
id: 882fc530-b69b-4707-95f6-5dbc5e9baaa8
idShort: future concept x
specificAssetIds:
- name: engineserialid
value: "12309481209312"
Expand All @@ -1350,8 +1405,8 @@ components:
href: https://catena-x.net/vehicle/basedetails/
endpointProtocol: HTTPS
endpointProtocolVersion: ["1.0"]
idShort: vehicle base details
id: 4a738a24-b7d8-4989-9cd6-387772f40565
idShort: vehicle base details
semanticId:
type: ModelReference
keys:
Expand All @@ -1366,8 +1421,8 @@ components:
href: https://catena-x.net/vehicle/partdetails/
endpointProtocol: HTTPS
endpointProtocolVersion: ["1.0"]
idShort: vehicle part details
id: dae4d249-6d66-4818-b576-bf52f3b9ae90
idShort: vehicle part details
semanticId:
type: ModelReference
keys:
Expand Down Expand Up @@ -1468,10 +1523,10 @@ components:
type: string
description: Id of global asset.
example: urn:uuid:6c311d29-5753-46d4-b32c-19b918ea93b0
idShort:
type: string
id:
type: string
idShort:
type: string
specificAssetIds:
type: array
items:
Expand Down Expand Up @@ -1507,8 +1562,8 @@ components:
minimum: 0
BatchOrderCreated:
type: object
description: Id of the created Batch order.
additionalProperties: false
description: Id of the created Batch order.
properties:
id:
type: string
Expand Down Expand Up @@ -2258,6 +2313,68 @@ components:
minimum: 60
required:
- keys
RegisterBpnInvestigationBatchOrder:
type: object
additionalProperties: false
description: Request body for registering a new Batch Order for ESS Investigation
Job.
properties:
batchSize:
type: integer
format: int32
default: 20
description: Size of the batch.
maximum: 100
minimum: 10
batchStrategy:
type: string
description: The strategy how the batch is processed internally in IRS.
enum:
- PRESERVE_BATCH_JOB_ORDER
- PRESERVE_JOB_ORDER
- PRESERVE_BATCH_ORDER
bomLifecycle:
type: string
description: The lifecycle context in which the child part was assembled
into the parent part.
enum:
- asBuilt
- asPlanned
- asSpecified
callbackUrl:
type: string
description: "Callback url to notify requestor when job processing is finished.\
\ There are four uri variable placeholders that can be used: orderId,\
\ batchId, orderState and batchState."
example: "https://hostname.com/callback?orderId={orderId}&batchId={batchId}&orderState={orderState}&batchState={batchState}"
incidentBPNSs:
type: array
items:
type: string
maxItems: 2147483647
jobTimeout:
type: integer
format: int32
default: 3600
description: Timeout in seconds for each job processing inside the complete
order.
maximum: 7200
minimum: 60
keys:
type: array
items:
$ref: '#/components/schemas/PartChainIdentificationKey'
maxItems: 2147483647
timeout:
type: integer
format: int32
default: 43200
description: Timeout in seconds for the complete batch order processing.
maximum: 86400
minimum: 60
required:
- incidentBPNSs
- keys
RegisterBpnInvestigationJob:
type: object
additionalProperties: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,65 +44,41 @@
@Jacksonized
public class BatchOrder {

/**
* Batch Order Id
*/
private UUID batchOrderId;

/**
* Processing State of Batch Order
*/
@Setter
private ProcessingState batchOrderState;

/**
* Bom Lifecycle requested in order
*/
private BomLifecycle bomLifecycle;

/**
* List of Aspects requested in order
*/
private List<String> aspects;

/**
* Depth requested in order
*/
private Integer depth;

/**
* Direction requested in order
*/
private Direction direction;

/**
* Needs of collect aspects
*/
private Boolean collectAspects;

/**
* Flag to specify whether BPNs should be collected and resolved via the configured BPDM URL
*/
private Boolean lookupBPNs;

/**
* Timeout for Batch Order
*/
private Integer timeout;

/**
* Timeout for Job in Batch
*/
private Integer jobTimeout;

/**
* Callback Url to send results
*/
private String callbackUrl;

private String owner;

private List<String> incidentBPNSs;

private JobType jobType;

/**
* Owner
* JobType to create batch
*/
private String owner;
public enum JobType {
REGULAR,
ESS
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public JobParameter getJobParameter() {
return getJob().getParameter();
}

public boolean jobIsCompleted() {
return this.getJob().getState().equals(JobState.COMPLETED);
}

/**
* Builder for {@link MultiTransferJob}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.eclipse.tractusx.irs.component.BatchOrderResponse;
import org.eclipse.tractusx.irs.component.BatchResponse;
import org.eclipse.tractusx.irs.component.RegisterBatchOrder;
import org.eclipse.tractusx.irs.component.RegisterBpnInvestigationBatchOrder;
import org.eclipse.tractusx.irs.dtos.ErrorResponse;
import org.eclipse.tractusx.irs.common.auth.AuthorizationService;
import org.eclipse.tractusx.irs.services.CreationBatchService;
Expand Down Expand Up @@ -121,6 +122,45 @@ public BatchOrderCreated registerBatchOrder(final @Valid @RequestBody RegisterBa
return BatchOrderCreated.builder().id(batchOrderId).build();
}

@Operation(operationId = "registerESSInvestigationOrder",
summary = "Registers an order for an ESS investigation with an array of {globalAssetIds}. Each globalAssetId will be processed in an separate job, grouped in batches.",
security = @SecurityRequirement(name = "oAuth2", scopes = "profile email"),
tags = { "Environmental- and Social Standards" },
description = "Registers an order for an ESS investigation with an array of {globalAssetIds}. Each globalAssetId will be processed in an separate job, grouped in batches.")
@ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Returns orderId of registered Batch order.",
content = { @Content(mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = BatchOrderCreated.class),
examples = { @ExampleObject(name = "complete",
ref = "#/components/examples/job-handle")
})
}),
@ApiResponse(responseCode = "400", description = "Batch Order registration failed.",
content = { @Content(mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "error",
ref = "#/components/examples/error-response-400"))
}),
@ApiResponse(responseCode = "401", description = UNAUTHORIZED_DESC,
content = { @Content(mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "error",
ref = "#/components/examples/error-response-401"))
}),
@ApiResponse(responseCode = "403", description = FORBIDDEN_DESC,
content = { @Content(mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "error",
ref = "#/components/examples/error-response-403"))
}),
})
@PostMapping("/ess/orders")
@ResponseStatus(HttpStatus.CREATED)
@PreAuthorize("@authorizationService.verifyBpn() && hasAnyAuthority('" + IrsRoles.ADMIN_IRS + "', '" + IrsRoles.VIEW_IRS + "')")
public BatchOrderCreated registerESSInvestigationOrder(final @Valid @RequestBody RegisterBpnInvestigationBatchOrder request) {
final UUID batchOrderId = creationBatchService.create(request);
return BatchOrderCreated.builder().id(batchOrderId).build();
}

@Operation(description = "Get a batch order for a given orderId.",
operationId = "getBatchOrder",
summary = "Get a batch order for a given orderId.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,8 @@ public PageResult getJobsByState(
explode = Explode.FALSE, array = @ArraySchema(schema = @Schema(implementation = JobState.class), maxItems = Integer.MAX_VALUE))
@RequestParam(value = "states", required = false, defaultValue = "") final List<JobState> states,
@Parameter(hidden = true)
@RequestParam(value = "jobStates", required = false, defaultValue = "") final List<JobState> jobStates,
@Parameter(hidden = true)
@ParameterObject final Pageable pageable) {
return itemJobService.getJobsByState(states, jobStates, pageable);
ds-ext-kmassalski marked this conversation as resolved.
Show resolved Hide resolved
return itemJobService.getJobsByState(states, pageable);
}

@Operation(operationId = "getAllAspectModels",
Expand Down
Loading