How To Use A JBStrap DataDescriptor

Upon start-up, all files with the extension .ds.xml are loaded from the file path specified in the DATADESCRIPTOR_DIR parameter and DataDescriptors are automatically created.

Note: The DATADESCRIPTOR_DIR parameter is the one that stores the file path for all DataDescriptor descriptor files.

You can access the DataDescriptors in any part of the source code or you can register a new DataDescriptor . Use a DataDescriptor for queries, data modification or you can just pass it to a data handling component which in turn automatically handles the DataDescriptor and contained data. Data handling components will be automatically built and set using DataDescriptor s .

Getting a DataDescriptor called „sampleDataDescriptor” from the framework:

Fetch

You can query data from the database using two different methods. A synchronous query means source code execution will wait until the queried data is loaded. An asynchronous query, on the other hand, means program execution will not be interrupted due to data loading and a callback method is used to handle data or exceptions.

Synchronous query using a DataDescriptor :

Getting all records in the DataDescriptor without user access control:
Getting all records from the DataDescriptor with user access control:
Getting records from the DataDescriptor corresponding a given Criteria without user access control (getting all records where the valid column has a Y value):
Getting all records from the DataDescriptor where the valid column has a Y, without user access control:
Getting the first 50 records where the valid column has a Y, without user access control:
Getting the first 50 records where the valid column has a Y, with user access control:
Getting the first 50 records where the valid column has a Y, without user access control and in ascending order by column1 values:
Getting the first 50 records where the valid column has a Y, with user access control and in ascending order by column1 values:
Getting a record from the DataDescriptor using the record’s unique ID, without user access control:
Getting a record from the DataDescriptor using the record’s unique ID, with user access control:

If you use an asynchronous query to get data from the DataDescriptor , you always have to implement the DataDescriptorCallback interface. The interface requires the implementation of two methods: onSuccess() gets the query result in a parameter. The method is called upon successful query execution. The method onError() gets the exception encountered during query execution. The method is called only if an exception has been thrown during the query.

Asynchronous query using a DataDescriptor :

Getting all records from a DataDescriptor using an asynchronous query:

Getting all records from a DataDescriptor using an asynchronous query where the valid column has a Y :

Getting all records from a DataDescriptor using an asynchronous query where the valid column has a Y in ascending order by column1 values:
Getting the first 50 records from a DataDescriptor using an asynchronous query where the valid column has a Y, in ascending order by column1 values:

Save

Not only can DataDescriptors query data, but records can be saved to a DataDescriptor . The save process can also be performed synchronously and asynchronously. Multiple records can be saved to a DataDescriptor at the same time and DataDescriptors support transaction management.

Saving a record to a DataDescriptor synchronously:
Saving multiple records synchronously to a DataDescriptor:
Saving a record to a DataDescriptor synchronously in a previously initiated transaction:
Saving multiple records synchronously to a DataDescriptor in a previously initiated transaction:

If the save is done asynchronously, saved records will be retrieved by the onSuccess() backend if the backup is successful. If an error occurs during save, the onError() method will be called to handle the error.

Saving a record to a DataDescriptor asynchronously:
Saving multiple records asynchronously to a DataDescriptor:
Saving a record to a DataDescriptor in a previously initiated asynchronous transaction:
Saving multiple records to a DataDescriptor in a previously initiated asynchronous transaction:

Remove

You can also delete records from a DataDescriptor , which can also be done synchronously and asynchronously. It is also possible to delete multiple records from a DataDescriptor at the same time, and DataDescriptors can handle transactions even if they are deleted.

Deleting a record from a DataDescriptor synchronously:
Synchronously deleting multiple records at a time from a DataDescriptor:
Deleting a record from a DataDescriptor synchronously in a previously initiated transaction:
Deleting multiple records synchronously from a DataDescriptor in a previously initiated transaction:

If deletion is performed asynchronously, the deleted records will be retrieved by the onSuccess() method in case of a successful deletion. If an error occurs during deletion, the onError() method will be called to handle the error.

Deleting a record from a DataDescriptor asynchronously:
Deleting multiple records at a time from a DataDescriptor asynchronously:
Deleting a record from a DataDescriptor in an asynchronously initiated transaction:
Deleting multiple records simultaneously from a DataDescriptor in an asynchronously initiated transaction: