Tutorial: Web Interfaces - GET
Information
- The following workflow provides basic knowledge required to create an interface in PLANTA Project using the functions delivered.
- The objective of this workflow is to create a web interface which makes load data available.
Requirements
- Basic customizing knowledge
- Basic knowledge of REST
Notes
- To be able to use web interfaces you have to activate and configure the PLANTA link webservices in the web.conf:
- generic_service = true
- generic_service_interface and generic_service_port contain meaningful data
- If you have not activated the webservices, the buttons for carrying out different actions which require webservices will not be displayed.
- Web interfaces use the Fully Qualified Domain Name (FQDN) as an address by default. If the FQDN is not available, the host name of the machine will be used. If the host name is not available either, the IP of the machine will be used. An explicit host name can be defined using the global
planta_link_hostname
setting.
All fields in the web interface modules are case sensitive (observe upper/lower case spelling)!
Create Web Entity
Objective
- To create a web entity which describes our data
Procedure
- Open the Configuration panel.
- Insert a new entity in the Web Entities submodule
- via the Insert→ Web entity menu entry or
- by clicking on the Insert button.
- Specify a name and select table 472 in the Data table field.
- Insert four web attributes via the Insert → Web attribute context menu entry of the newly created web entity:
- DI001395 Project ID
- DI001516 Task ID
- DI001519 Load date
- DI001510 Actual load
- The Column types are automatically read out and displayed.
- The name of the attribute in the Name field is arbitrary but must comply with the Java name conventions for identifiers and must not occur more than once within an entity.
- For a date,
DateTransformer
is automatically selected in the Transformer field.- You can adjust the parameters of the transformer by clicking on the tool symbol.
- The
DateTransformer
enables you to configure the date format.
- The
- You can adjust the parameters of the transformer by clicking on the tool symbol.
- Save.
Create Web Interface
Objective
- To create a web entity which makes the data available
Procedure
- Open the Configuration panel
- Create a new web interface
- via the Insert→ Web interface menu entry or
- by clicking on the Insert button.
- Fill the fields as follows:
- The name is arbitrary.
- The Active field must be activated before the interface is used.
- Create a placeholder in the Url field, for example
/load/{resource}.
- Allocate an API key.
- Select the
DefaultServiceImplementation
GET implementation. - The entity which was newly created in the previous step is selected in the Web entity field.
- Save.
- After you have selected the entity, you can configure the URL filter by clicking on the tool button.
- Select data item 001517 Resource in the dialog module and save.
Test Web Interface
Objective
- To test the newly created web interface
Procedure
- Click on the arrow button (right next to "Complete URL") to open the Test Web Interface module.
- Select GET as HTTP-method.
- Enter R1 as a resource.
- Click on the Execute button.
- The placeholder in the URL is automatically replaced by the transferred value and the API key is passed on in the HTTP header
- In the Response field, the result of the query is displayed, cut at 3000 characters.
Example of a return value:
[{"date": "13.10.2016", "prId": "7000", "load": 8.0, "taskId": "1.01"}, {"date": "14.10.2016", "prId": "7000", "load": 10.0, "taskId": "1.01"}, {"date": "17.10.2016", "prId": "7000", "load": 3.0, "taskId": "1.01"}, {"date": "30.09.2016", "prId": "7000", "load": 7.0, "taskId": "1.01"}, {"date": "03.10.2016", "prId": "7000", "load": 7.0, "taskId": "1.01"}, {"date": "24.11.2016", "prId": "7000", "load": 8.0, "taskId": "3.10"}]