Introduction
Order only applies to services which return a collection resource, it is needed to enable clients to get an ordered collection instead of an unordered one (or a default ordered one). The ordering is applied during the search of the resources, after having applied the possibly requested filters and before applying pagination.
To request a specific order in one of OverIT APIs, the _order parameter can be used to specify the desired fields and direction that the server must use during the search.
Order parameters
Request QueryParameters
The _order parameter is a QueryParameter in which the client can specify a collection of strings representing the desired fields and direction. The format is the following: [+|-][field] where the symbols + and - represent the order direction, (ascendent order is + and descendent order is -) and the field placeholder represents the name of the field by which to order the results (the field must belong to the requested resource).
Response payload
The _order object will return exactly the requested order, or the default one if no order has been requested. The format is identical to the Request QueryParameter: [+|-][field].
Example
REST API
Request
curl "<https://api.overit.cloud/api/r1/work-order?_order=+code,-description>" \
-H "Authorization: Bearer <personal_access_token>"
Response
"content": [
{
"id": 0,
"code": "string",
"description": [
{
"lang": "string",
"value": "string"
}
],
"order": 0,
"active": true,
"urgency": true,
"color": "string"
}
],
"_order": ["+code","-description"]
SDK API
// Instantiate a WorkOrderHeaderSearchEvent
WorkOrderHeaderSearchEvent workOrderHeaderSearchEvent = new WorkOrderHeaderSearchEvent(Page.FULL, searchFilter);
...
// Set the required ordering criteria
Order order = new Order();
order.addAttributeOrderCriterion("endDate", OrderCriterion.ASC);
order.addAttributeOrderCriterion("urgency", OrderCriterion.DESC);
workOrderHeaderSearchEvent.setOrder(order);
// Launch the search event and obtains the paged list of BOWorkOrderHeader objects
PageResponse<BOWorkOrderHeader> searchResponse = workOrderHeaderSearchEvent.launch();