This example project outlines various ways of programmatic data manipulation in CUBA applications.
Programmatic creation, updating and deletion of entities on the middleware and on the client tier. See the following methods of the CustomerBrowse screen controller:
onCreateInService()- sends customer data to a middleware service method.
onCreateInController()- replicates the logic of the midlleware service right in the screen controller.
Execution of queries on the middleware and on the client tier. See the following methods of the
Providing uniqueness by using database-level unique constraints. The
SAMPLE_CUSTOMERtable has the
webmodule contains a message with the
IDX_SAMPLE_CUSTOMER_UNQ_EMAILkey which will be automatically picked up by the platform to display a user-friendly message. See cuba.uniqueConstraintViolationPattern application property for how to adjust this mechanism for your database.
Enforcing complex rules using entity listeners. OrderEntityListener throws an exception on attempt to create an order if there are already two or more orders for the same customer on the same day.
Using the REST API to control the application from an external tool. See the project in the
clients/rest-clientdirectory. To create IntelliJ IDEA project files, open the command line in this directory and run
RestClient.createCustomer()method creates an entity by sending JSON to the standard REST API CRUD method.
RestClient.createCustomerViaService()method creates an entity by sending its attributes to the middleware service.
Based on CUBA Platform 6.10.1
Please use https://www.cuba-platform.com/discuss for discussion, support, and reporting problems coressponding to this sample.