DashBuilder DataSets Java API
This was removed from datasets API README. It shows how to use the Datasets Java API.
DataSet API usage
This is a quick reference guide on the setup and usage of the DataSet API.
Prerequisites
The DataSet library is available as a maven artifact. You need to import the library’s BOM within your dependencyManagement section as well as to add a dependency to the dashbuilder-dataset-core artifact. As you can see below, the SQL, CSV, Prometheus Kafka, dependencies are optional. Add them depending on what kind of datasets you want to support.
Data Set Definitions
First thing is to create a DataSetDef instance. Here is an example on how to define a CSV data set:
Java Bean generated data sets are supported as well:
Or even those based on SQL database queries:
Data Set Registration
The DataSetCore interface is the main entry point to the API. From this interface you can get access to any of the components and services provided by the DataSet subsystem.
To register a data set definition:
There exists an additional way to register definitions using an auto-deploy mechanism which scans a given file system
folder and registers any data set flagged as “deploy”
This is enough to get the deployment scanner up and running. Every 5 seconds, it will scan the target folder looking for “.dset” files like the following:
Along with the above file you also need to copy the expenseReports.csv file plus an empty file named
expenseReports.dset.deploy. This last file serves to trigger the auto-deploy of the data set definition.
Likewise, to remove any existing data set from the system you just need to copy a file named myDataSet.dset.undeploy
(where myDataSet is the uuid of the data set to remove).
Data Lookup Calls
Once registered, a data set definition is ready to accept data lookup calls:
Which returns a data set with the result of applying the filter, group and sort operations specified:
{“Engineering”, “16.00”, “6,547.56”}
{“Services”, “5.00”, “2,504.50”}
{“Sales”, “8.00”, “3,213.53”}
{“Support”, “6.00”, “2,343.70”}
{“Management”, “11.00”, “6,017.47”}
The lookup API works on top of any data set definition, regardless its type and data storage location.
Data sets providers
The only data set type supported by default is the Java Bean generated. If you want to support CSV, SQL, Prometheus or Kafka then, aside from adding the proper maven dependency (see the Prerequisites section above), you also need to register the target provider component: