14. Backend / Services
14.1 Intro
To exchange data with backend systems the x0-system offers various methods to choose from.
Service Connector
Source Data Objects
Global Data Storage
The next chapters describe all methods in detail and which method is best suited to a specific application.
14.2 ServiceConnector
A ServiceConnector object defines where to get the backend data from and when.
Backend Service URL
Occurring Events which trigger Data Load
Now after a ServiceConnector has been configured in object.json, it must be
activated by pointing the DestinationObjects RefID to the ServiceConnector
ObjectID in skeleton.json.
After it has been connected, any systems fired event will cause the connected service to re-trigger data load.
14.2.1. Object Properties
Property |
Value(s) |
Description |
|---|---|---|
OnEvent |
JS Object |
Event Properties |
14.2.2. Event Properties
Property |
Value(s) |
Description |
|---|---|---|
Events |
Array of EventIDs |
Listen to given Events |
ServiceCall |
Backend Script |
Call Backend Script on raised Event(s) |
14.2.3. object.json
Define ServiceConnector metadata in object.json.
"TestConnector1":
{
"Type": "ServiceConnector",
"Attributes":
{
"OnEvent":
{
"Events": [ "TestEvent" ],
"ServiceCall": "python/getData.py"
}
}
}
14.2.4. skeleton.json
Connect as ParentObject in skeleton.json.
"Screen1":
[
{
"TestConnector1":
{
"RefID": "Screen1"
}
},
{
"TestObject1":
{
"RefID": "TestConnector1"
}
}
]
14.3. Source Data Objects
x0-source-data-objects feature is a very smart way to control which data will be sent to the backend.
Just reference multiple x0-system-objects and its realtime data will be sent to the backend service.
The following sub-chapters describe how to use SrcDataObjects JSON format in detail.
Note
- x0-source-data-objects are not only usable in combination with
service connector, also buttons support the feature.
14.3.1. Global Objects Array
"SrcDataObjects":
[
"ObjectID1",
"ObjectID2",
"ObjectID3"
]
14.3.2. Hardcoded Values
"SrcDataObjects":
{
"Dummy":
{
"Type": "HardcodedValues",
"Values": {
"LimitRows": 20
}
}
}
14.3.3. Global Object
"SrcDataObjects":
{
"$ObjectID":
{
"Type": "GlobalObject"
}
}
14.3.4. Chaining Object Types
"SrcDataObjects":
{
"$ObjectID":
{
"Type": "GlobalObject"
},
"Dummy":
{
"Type": "HardcodedValues",
"Values": {
"LimitRows": 10
}
}
}
14.4. Global Data
It is possible to store global data (var / value pairs) in the following global data spaces:
Global Data
Screen Global Data
14.4.1. Load Global Data
x0-global-data will be loaded by x0-preload-script at x0-init.
INSERT INTO system.config (app_id, config_group, "value") VALUES ('appid', 'preload_script', '"InitSystem.py"');
INSERT INTO system.config (app_id, config_group, "value") VALUES ('appid', 'preload_var', '["GlobalVar1"] = "ret_var1"');
INSERT INTO system.config (app_id, config_group, "value") VALUES ('appid', 'preload_var', '["GlobalVar2"] = "ret_var2"');
INSERT INTO system.config (app_id, config_group, "value") VALUES ('appid', 'preload_var', '["GlobalVar3"] = "ret_var3"');
14.4.2. Pass Screen Global Data
To pass values from x0-screen-global-data to backend using x0-source-data-objects …
"SrcDataObjects":
{
"$ObjectID":
{
"Type": "ScreenGlobalVar",
"ScreenID": "Screen1"
}
}
14.5. Notify Indicator
To provide the user with status information (notify) a notification-indicator per backend service call is configurable.
Add a notify indicator by adding “Notify” attribute to x0-button-type like shown in the following example.
"ButtonSubmit": {
"Type": "Button",
"Attributes": {
"TextID": "TXT.BUTTON.SUBMIT",
"Style": "btn btn-primary w-100 mt-3",
"OnClick": "/python/example-service.py",
"SrcDataObjects": [
"FormfieldList1",
"FormfieldObject1",
"FormfieldObject2"
],
"Notify": {
"ID": "SubmitIdentifier",
"DisplayHeaderID": "TXT.NOTIFY.EXAMPLE"
}
}
}
14.6. AAA / Authentication
Currently x0-system only supports certificate based (Apache2 / ingress-nginx) authentication.
Especially when using decentralized / multiple application servers it is strongly advised to integrate an external SSO solution.
For authentication to work correctly x0-preload-script must be set up
with the correct x0-preload-vars UserID and UserSession.
INSERT INTO system.config (app_id, config_group, "value") VALUES ('appid', 'preload_script', '"InitSystem.py"');
INSERT INTO system.config (app_id, config_group, "value") VALUES ('appid', 'preload_var', '["UserID"] = "ret_user_id"');
INSERT INTO system.config (app_id, config_group, "value") VALUES ('appid', 'preload_var', '["UserSession"] = "ret_user_session"');
Internally x0-system authentication data will be stored in the following global variables.
sysFactory.sysUserID
sysFactory.sysSessionValue
Warning
Also x0-messaging component relies on setting UserSession the correct way.