Actions
grin-global-ui#27 (closed) is a use case that relies on RequestOrderItemAction
and we need new APIs to manage action records.
Superclass
We have a number of ...Action
entities (e.g. InventoryAction
, AccessionAction
, RequestOrderItemAction
, RequestOrderAction
) that can extend from a new @MappedEntity
superclass AbstractAction
.
The @ManyToOne
entity that owns the action should always be serialized as id.
Services and API
Actions are identified by the actionNameCode
. These are declared as CodeValue
. We should not use @PathVariable
because we cannot assure values are sensible.
We want to record in the system that an action was initiated (startedDate = now()
) and that an action was completed (completedDate = now()
).
Add API endpoints to add action records for request orders as a demo:
- POST /order/action/start
- POST /order/action/complete
- POST /order/action/reopen (resets
completedDate
to null andstartDate = now()
on the last action only)
The API should receive a set of IDs of RequestOrder
(or RequestOrderItem
) and the action data. This could probably be a small utility class:
{
public String actionNameCode; // action code
public Set<Long> id; // entities
// data
public Double actionCost;
public String actionInformation;
public String actionNameCode....
}
Listing actions
We want to retrieve action records by entity ID set (and optionally actionNameCode
and closed
):
- POST /order/action/list
This returns all RequestOrderAction
records where
RequestOrder.id.in(entityIds)
// if actionNameCode
.and(RequestOrderAction.actionNameCode.eq(actionNameCode)
// if closed
.and(....completedDate.notNull())
// if ! closed
...completedDate.isNull()
The filter object:
public class ActionFilter {
public Set<String> actionNameCode; // action code
public Set<Long> id; // entities
public Boolean closed;
}