Platform provides three main avenues for reading models: the model read API, views, and reports. The model read API is used primarily in programmatic access while the latter two are used to display information to users. Views are covered in the next section. Reports are covered in the chapter titled Reporting in this user guide.
Model Read API
The primary entry point for the model read API is the
ModelDataService interface. You've seen the
ModelDataService in previous examples when reading models.
You can read a model or a collection of models using the
ModelDataService in several ways:
Surrogate IDs— Use the
readByIdsto retrieve models by their surrogate IDs
Views— Use the
readByViewmethod to retrieve models using an existing view
SQL Fragments— Use the
readmethod to retrieve models filtered by arbitrary filter fragments
Reading using the surrogate ID is the simplest method of retrieving a model from the database:
You can also reuse views defined for a model and filter the view as necessary:
If your existing views are not flexible enough, or you wish to dynamically determine filter criteria, you can use SQL fragments to retrieve the model:
A drawback to the
read method is that macros are not supported.