Querying ADF BC REST service - RowFinders and REST Shape

JDev: 12.2.1.3.0
Source: GitHub

This article talks about querying ADF BC REST services using a RowFinder, and displaying different data sets based on our needs, using REST Shaping.

REST Shaping

This is a powerful tool provided by ADF BC to determine the kind of data you can expose to the end user.

Imagine this use-case where we need to display certain attributes of an employee on the front-end application depending on whether we have an anonymous or an authenticated user, while we retain all the features of the view object (View criteria, custom SQL etc). Creating multiple copies of the same VO is certainly not an option.

REST shaping allows you to create metadata on the view object, identified by a unique name, where you can specify which columns may displayed and which all may be hidden.

See examples below, which show two shapes created - AuthView and NoAuthView, each showing different data sets.




Important Note: Each REST instance supports a single REST shape. I did not find any way to switch shape at runtime. To use different REST Shapes, you would need to create multiple AM instances of the same VO, and then assign a shape to each instance.





Querying using RowFinder

To get started on this, you need a View-Criteria defined on your view object. Create a Row Finder object which makes use of this View Criteria.



You may create multiple Row Finders on a VO, associated with their corresponding View Criteria. Once this is deployed, we can query the service as below:



Running my resources - employeesauth and employeesnoauth - on POSTMAN, I get the desired results. Each resource displays a different data set, based on the rest shape associated with it.



Cheers!

Comments