Rest DAO

In the JBStrap framework, the lowest level of Rest webservice handling is using the RestDao API. This API implements all supported tasks available for the application. The task handled by the API is compatible with the DataRecord and Criteria classes.


Use this functionality to programmatically retrieve data based on a DataDescriptor from a Rest server. In the data query, you can apply filter criteria to the query (if server side supports it). Filter criteria are JBStrap Criteria objects. Results are returned as DataRecord or List<DataRecord> objects. You can retrieve all the corresponding records or only a subset of the record for a faster response time.

If you specify the client object, the access rights in the DataDescriptor are checked. If a user does not have read rights for the data (as specified in the DataDescriptor), an error is returned, preventing unauthorized access to the data.

Note that by default, the the REST service does not handle filtering by using criteria, ordering, or fetching a new page. If these are not handled, or are only partially handled (only ordering is handled, etc.) the unhandled operations will not function.  All of these operations can be implemented in numerous ways. JBStrap allows you to develop your own, custom implementations by using the handler classes.

Here are a few examples of how to fetch data using the Rest DataDescriptor:

Fetching all data using a DataDescriptor
Fetching all data using a DataDescriptor while checking for access rights
Fetching all data that meet the specified Criteria using a DataDescriptor (fetching every Record object where the first name field is "Evelyn")
Fetching the first 50 records using a DataDescriptor that meets the specified filters. If there are more than 50 corresponding records, only the first 50 ones will be fetched).
Fetching the next 50 records (51-100) while checking the access rights
Fetching the first 50 records that meet the specified criteria and sorting the results in descending order by lastName
Fetching the record where the primary key is 1

Counting the records:

Counting the record rows in a DataDescriptor with filter

Save and update records:

Saving records using a DataDescriptor

Delete records:

Deleting records using a DataDescriptor