Status Handling
The first and most important way to handle submission and product statuses is by returning SubmitStatus object from submitBatch method of a specific SubmitHandler.
If asynchronous status handling is required (i.e. triggered by event coming from external system), status of a product (but not the submission) can be updated with StatusService#sendItemStatus method accepting the same ItemStatus object as submitBatch method returns.
Submit Status
SubmitStatus returned by submitBatch method is used to set submission and individual products statuses.
Statuses for all batches are automatically merged into single status event. Adapter can control aggregated status event status and message by providing custom implementation of SubmitStatusAggregationStrategy interface. By default Status which is highest in the hierarchy is chosen (i.e. Error if any of batches resulted in Error) and distinct messages are joined into single message (i.e. “All good.\nError!” if some batches resulted in “All good.” and some in “Error!”).
| Property | Description |
|---|---|
| status | Submission status reported by adapter. Possible values are: Error, Pending, Success. Error (error() method in SubmitStatus) - denotes submission as “Failed” in submission log. In most cases submission should not recover from this state. Pending (pending() method in SubmitStatus) - denotes submission as “Pending” in submission log. This is not terminal state and should be later updated in Status-handling process. Success (success() method in SubmitStatus) - denotes submission as “Success” in submission log. Submission should not change this state. Subsequent changes of products' statuses should only be registered on single product level - see Status-handling process description for more details. |
| message | Additional message visible in the “Additional details” of submission. |
| files | Optional files to publish together with the submission (for example a generated export or receipt). Added via the withFile(...) methods on SubmitStatusBuilder. |
| items | Statuses for particular products. It is possible that some products are in error status while submission as a whole is successful - then submission will be marked as “Partial” in the submission log. Remember to return statuses for all products because otherwise submission will also be marked as “Partial”. |
Examples:
{
"status" : "Success",
"message" : "Products were submitted.",
"items" : [ ]
}SubmitStatus submitStatus = SubmitStatus.success()
.withMessage("Products were submitted.")
.build();Item Status
ItemStatus describes the status of a single product (not only in the context of a submission).
| Property | Description |
|---|---|
| productId | PDX id of the product. |
| externalProductId | Id of the product in the external system. If set will be visible in product details and available in Product for submission processing. If set it means that product was previously submitted. |
| accountId | Account id for which status is registered. The product's account id is stored in the account attribute; see Submissions Object Model for how to read it during submission. |
| status | Product status reported by adapter. Possible values are: None, Pending, Sent, Error, Review, Success, Rejected, Returned. None is a special status which when sent will not change the current product status - useful if product statuses in PDX are not known. |
| message | Additional message visible in the “Product details” of submission. If multiple messages are provided, they will all be listed. |
| externalStatus | External statuses for external status attributes. |
| files | Optional files associated with the product's status. Added via the ItemStatus builder. |
Examples:
{
"productId" : "1200983127222",
"externalProductId" : "1878902",
"accountId" : "default",
"status" : "Success",
"messages" : [ "this is an important message to supplier" ],
"channelProcessingStages" : [ "sent" ],
"externalStatus" : {
"WORKFLOW_STATE" : [ "STEP workflow state" ]
}
}ItemStatus itemStatus = ItemStatus.accepted("1200983127222", "this is an important message to supplier")
.withExternalProductId("1878902")
.withAccountId("default")
.withExternalStatus("WORKFLOW_STATE", "STEP workflow state")
.withChannelProcessingStage("sent")
.build();Updated 8 days ago
