Displaying data in Bonita BPM UI Designer forms relies on forms variables that you bind to forms widgets.
Forms variables value can be set using different options:
- JSON (i.e. constant)
- JavaScript expression (the returned value of script execution)
- External API call (REST API)...
The solution to get the data from the PostgreSQL database and put them into a form variable is actually to use a REST API call. That's the only solution to bind a form with a third party system without duplicating data in Bonita BPM.
Problem is (AFAIK) that PostgreSQL doesn't provide REST API to run SQL queries.
The solution here is to deploy in Bonita BPM a REST API extension that will act as a proxy: it will offers a REST API to initialize form variables and will execute Java code and use JDBC to run queries on the PostgreSQL database.
A REST API extension to do so is available as a Bonita BPM community project. Note that this extension does not actually handle directly the connection to the database but rather goes through a Java application server connection pool using data source.
Here is a sum up of the architecture:
Form -> Widgets -> Forms variables -> REST API extension -> Data source -> Database
Such architecture can seems quite complex. A good alternative would be to use Bonita BPM business data model (BDM). BDM basically let you define your database schema in Bonita BPM Studio and will create for you the database tables and Java classes to manipulate your data in processes.
Benefits of this solution is that you have out of the box REST API to get business data values and you can use "operations" on processes tasks to update them.