Configure toolbox - Giswater/giswater_dbmodel GitHub Wiki

Definition of the function in toolbox_config determins the parameters that are being passed automatically to the function together with the form that is shown to the final user.

INSERT INTO config_toolbox (id, alias, isparametric, functionparams, inputparams, active)
VALUES (9280, 'Duplicated nodes', true, '{"featureType":["node"]}', '[{"widgetname":"exploitation", "label":"Exploitation ids:","widgettype":"combo","datatype":"text","layoutname":"grl_option_parameters","layoutorder":1, "dvQueryText":"select expl_id as id, name as idval from exploitation where active is not false order by name", "selectedId":"1"},{"widgetname":"nodeTolerance", "label":"Node tolerance:", "widgettype":"spinbox","datatype":"float","layoutname":"grl_option_parameters","layoutorder":2,"value":0.01}, {"widgetname":"saveOnDatabase", "label":"Save on database:","widgettype":"check","datatype":"boolean","layoutname":"grl_option_parameters","layoutorder":3, "value":"FALSE"}]', true);

widgetname – any name we want to give to the widget, the exported json key will have the same name
label – name showed to the user in a form
widgettype – type of widget, may be: spinbox, check, combo, text
datatype – type of data that will be inserted: boolean, float, json, string, integer
layoutname – name of form layout, in this case it’s always ‘grl_option_parameters’
layoutorder – order of widgets in the form
dvQueryText – query that fills in a combo widget:
select expl_id as id, name as idval from exploitation where active is not false order by name
It’s important to put an alias ‘id’ on field that is for example and identifier that we want to work with in a function, and ‘idval’ on a value showed to the user, for example the name.
selectedId – default value selected in a combo widget.
value - default value selected on widgets that are not combo

Column name Description
id Id assigned to the function
alias Function name showed in toolbox
isparametric Defines if function receives parameters
functionparams If defined as {"featureType":["node"]} shows field with list of layers related to the defined feature_type.
Appears in key “feature” of a function input json.
inputparams List of widgets not related to the layer, which need to be set by user.
Appears in key “parameters” of a function input json.
observ Observations
active If true, then function appears on toolbox

From the configuration defined above the following form is going to be created:

After clicking RUN, function call will be automatically generated:

SELECT user_fct_anl_node_duplicated($${"client":{"device":4, "infoType":1, "lang":"ES"},
"form":{},"feature":{"tableName":"v_edit_node", "featureType":"NODE", "id":[]},
"data":{"filterFields":{}, "pageInfo":{}, "selectionMode":"wholeSelection",
"parameters":{"exploitation":"1", "nodeTolerance":"3.0", "saveOnDatabase":"true"}}}$$)::text

In bold are marked the keys, which come by default in every function call.
In italic are those defined by user in config_toolbox.

REGISTER INTO CONFIG_FUNCTION TO CONTROL QGIS USING BACKEND

Config_function allows to define the symbology of a temporal layer, which is the result of the executed process. Apart from that, it also permits setting the visible layer or zoom it to the defined value.

INSERT INTO config_function(id, function_name, returnmanager, layermanager, actions)
VALUES ( 9280, 'user_fct_anl_node_duplicated',
'{"visible": ["v_edit_node", "v_edit_node"],"zoom": {"layer":"v_edit_node", "margin":20}}',
'{"style":{"point":{"style":"unique", "values":{"width":3, "color":[255,1,1], "transparency":0.5}},
"line":{"style":"unique", "values":{"width":3, "color":[255,1,1], "transparency":0.5}},
"polygon":{"style":"unique", "values":{"width":3, "color":[255,1,1], "transparency":0.5}}}}', NULL);

Column name Description
id Id assigned to the function
function_name Name of the function
returnmanager Defines style of the temporal result layer in qgis:
{"style":{"point":{"style":"unique", "values":{"width":3, "color":[255,1,1], "transparency":0.5}},
"line":{"style":"unique", "values":{"width":3, "color":[255,1,1], "transparency":0.5}},
"polygon":{"style":"unique", "values":{"width":3, "color":[255,1,1], "transparency":0.5}}}}
layermanager Sets visibility and zoom of layers present in the project:
{"visible": ["v_edit_node", "v_edit_node"],"zoom": {"layer":"v_edit_node", "margin":20}}
actions Python actions launched by function
⚠️ **GitHub.com Fallback** ⚠️