Class OrdersRest
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable,RowDetailMixin,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_HEADFields inherited from interface org.apache.juneau.console.views.RowDetailMixin
ROW_ID, SEGMENT -
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 dialog: pick a pet that is for sale and an optional ship date.page(RestRequest req) The Orders page.The Pet tab of the order row detail: the pet an order is for, as a one-row table.query(DataTablesRequest req, String day, String start, String end) Server-mode DataTables query over all orders.The bean-backed details this resource serves.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, logMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.juneau.console.views.RowDetailMixin
rowDetail, rowDetailCounts, rowDetailIndex, rowDetailTab, validRowId
-
Constructor Details
-
OrdersRest
public OrdersRest()
-
-
Method Details
-
page
The Orders page.- Parameters:
req- The request;?builderrenders the builder twin.- Returns:
- The page.
-
rowDetails
Description copied from interface:RowDetailMixinThe bean-backed details this resource serves.- Specified by:
rowDetailsin interfaceRowDetailMixin- Returns:
- The details. Each must have a distinct key.
-
petRows
The Pet tab of the order row detail: the pet an order is for, as a one-row table.- Parameters:
orderId- The order id.- Returns:
- The pet.
- Throws:
NotFound- IforderIdis missing or names no order, or its pet is gone.
-
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 dialog: pick a pet that is for sale and an optional ship date.The dialog submits to the ribbon item's endpoint.
- Returns:
- The modal, on the compact chrome.
-
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.
-