Class OrdersRest
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable,BasicUniversalConfig,DefaultConfig,DefaultHtmlConfig
approve and
deliver status transitions, and the cancel dialog form with its DELETE.
Example:
<@card type="datatables" id="orders"> { dataMode:'server', dataUrl:'/console/orders/query', rowActions:[{id:'approve', endpoint:'/console/orders/{id}/approve', method:'POST'}] } </@card>
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.juneau.rest.server.servlet.RestServlet
RestServlet.Builder<R extends RestServlet,SELF extends RestServlet.Builder<R, SELF>>, RestServlet.DefaultBuilder<R extends RestServlet> -
Field Summary
Fields inherited from class org.apache.juneau.petstore.console.PetstoreConsolePage
PAGE_HEADER, TEMPLATESFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapprove(RestRequest req, long id) Approves a placed order.cancel(RestRequest req, long id) Deletes (cancels) an order.cancelForm(long id) The cancel dialog form: a reason and whether to notify the customer.create(RestRequest req, JsonMap body) Places a new order.deliver(RestRequest req, long id) Delivers an approved order.newForm()The new-order wizard, step one: pick a pet that is for sale and an optional ship date.page(RestRequest req) The Orders page.query(DataTablesRequest req, String day, String start, String end) Server-mode DataTables query over all orders.reviewForm(String drafts) The new-order wizard, step two: the order about to be placed, read back from the first step's drafts.Methods inherited from class org.apache.juneau.petstore.console.PetstoreConsolePage
builder, freemarker, store, twinMethods inherited from class org.apache.juneau.rest.server.servlet.RestServlet
builder, createAuthenticator, destroy, doLog, getContext, getPath, getPaths, getRequest, getResponse, getRestBuilder, init, log, log, service, setContextMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
OrdersRest
public OrdersRest()
-
-
Method Details
-
page
The Orders page.- Parameters:
req- The request;?builderrenders the builder twin.- Returns:
- The page.
-
query
public DataTablesResults<Order> query(@Content DataTablesRequest req, @Query("day") @Schema(aev=true) String day, @Query("start") @Schema(aev=true) String start, @Query("end") @Schema(aev=true) String end) Server-mode DataTables query over all orders.The optional
dayquery parameter (yyyy-mm-dd) narrows the orders to those whose ship date falls in that day's window, before the request's own column filters apply, so the two combine. A missing, blank or malformed value is ignored.The optional
startandendquery parameters (thewindowURL-state directive's defaults; each ayyyy-mm-dddate or an ISO date-time, whose calendar date is used) keep the orders whose ship date falls between them, both days included, and either may be given alone. A bound that is blank or malformed is ignored. An order with no readable ship date is outside any window that has a usable bound. The window anddaycombine with each other and with the request's own column filters.- Parameters:
req- The DataTables request.day- The day to keep, ornull.start- The first ship day to keep, ornull.end- The last ship day to keep, ornull.- Returns:
- One page of orders, or a 200
errorenvelope for a malformed search expression.
-
newForm
The new-order wizard, step one: pick a pet that is for sale and an optional ship date.The
reviewbutton opens the stacked second step and carries these inputs to it as drafts. That step's Confirm posts to/console/orders, as declared on the child action.- Returns:
- The modal, on the compact chrome.
-
reviewForm
The new-order wizard, step two: the order about to be placed, read back from the first step's drafts.- Parameters:
drafts- The first step's inputs as JSON, carried by the dialog asjuneauDrafts.- Returns:
- The modal, on the compact chrome, whose form re-posts the validated values.
- Throws:
BadRequest- If the drafts are missing, not JSON, or carry a bad ship date.NotFound- If the pet does not exist.Conflict- If the pet is not available.
-
create
Places a new order.- Parameters:
req- The request (audit actor).body- The order, as the plain{petId, shipDate}or the dialog envelope{fields:{...}}.- Returns:
- The result toast, carrying the stored order.
- Throws:
BadRequest- On a missing body, non-objectfields, missing pet or a bad ship date.NotFound- If the pet does not exist.Conflict- If the pet is not available.
-
approve
Approves a placed order. -
deliver
Delivers an approved order. -
cancelForm
The cancel dialog form: a reason and whether to notify the customer.- Parameters:
id- The order id.- Returns:
- The modal.
- Throws:
NotFound- If the order does not exist.
-
cancel
Deletes (cancels) an order.- Parameters:
req- The request.id- The order id.- Returns:
- The result toast.
- Throws:
BadRequest- If the optional body is not a JSON object.NotFound- If the order does not exist.
-