Skip to content

Commit

Permalink
feat(trg_edit_node): show error message when new epa_type doesn't cor…
Browse files Browse the repository at this point in the history
…respond with feature type for valve and pump
  • Loading branch information
albertbofill committed Aug 21, 2024
1 parent 8277fab commit 77b66a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions updates/36/36012/ws/dml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,8 @@ join config_form_fields on formname = child_layer
where formtype = 'form_feature' and tabname = 'tab_data' and layoutname = 'lyt_data_1' and layoutorder < 900
group by child_layer, formname, formtype, tabname
ON CONFLICT (formname, formtype, columnname, tabname) DO NOTHING;


INSERT INTO sys_message (id, error_message, hint_message, log_level, show_user, project_type, "source")
VALUES(3266, 'Selected epa_type cannot be used in this feature',
'For valve and pump, feature type and epa type must correspond ', 2, true, 'utils', 'core') on conflict (id) do nothing;
17 changes: 15 additions & 2 deletions ws/ftrg/ws_gw_trg_edit_node.sql
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ BEGIN

IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
-- man2inp_values
v_man_view = (SELECT child_layer FROM cat_feature f JOIN cat_node c ON c.nodetype_id = f.id WHERE c.id = NEW.nodecat_id);
SELECT child_layer, system_id INTO v_man_view, v_system_id FROM cat_feature f JOIN cat_node c ON c.nodetype_id = f.id WHERE c.id = NEW.nodecat_id;
v_input = concat('{"feature":{"type":"node", "childLayer":"',v_man_view,'", "id":"',NEW.node_id,'"}}');

-- check if streetname exists
Expand Down Expand Up @@ -149,7 +149,12 @@ BEGIN


-- Epa type
IF (NEW.epa_type IS NULL) THEN
IF NEW.epa_type IN ('VALVE', 'PUMP') THEN
IF NEW.epa_type <> v_system_id THEN
EXECUTE 'SELECT gw_fct_getmessage($${"client":{"device":4, "infoType":1, "lang":"ES"},"feature":{},
"data":{"message":"3266", "function":"1320","debug_msg":null, "is_process":true}}$$)';
END IF;
ELSIF NEW.epa_type IS NULL THEN
NEW.epa_type:= (SELECT epa_default FROM cat_node JOIN cat_feature_node ON cat_feature_node.id=cat_node.nodetype_id WHERE cat_node.id=NEW.nodecat_id LIMIT 1)::text;
END IF;

Expand Down Expand Up @@ -782,8 +787,16 @@ BEGIN
ELSIF (NEW.epa_type = 'SHORTPIPE') THEN
v_inp_table:= 'inp_shortpipe';
ELSIF (NEW.epa_type = 'VALVE') THEN
IF (SELECT lower(type) FROM cat_feature_node cf JOIN cat_node c ON cf.id=c.nodetype_id WHERE c.id=NEW.nodecat_id)<>'valve' THEN
EXECUTE 'SELECT gw_fct_getmessage($${"client":{"device":4, "infoType":1, "lang":"ES"},"feature":{},
"data":{"message":"3266", "function":"1320","debug_msg":null, "is_process":true}}$$)';
END IF;
v_inp_table:= 'inp_valve';
ELSIF (NEW.epa_type = 'PUMP') THEN
IF (SELECT lower(type) FROM cat_feature_node cf JOIN cat_node c ON cf.id=c.nodetype_id WHERE c.id=NEW.nodecat_id)<>'pump' THEN
EXECUTE 'SELECT gw_fct_getmessage($${"client":{"device":4, "infoType":1, "lang":"ES"},"feature":{},
"data":{"message":"3266", "function":"1320","debug_msg":null, "is_process":true}}$$)';
END IF;
v_inp_table:= 'inp_pump';
ELSIF (NEW.epa_type = 'INLET') THEN
v_inp_table:= 'inp_inlet';
Expand Down

0 comments on commit 77b66a2

Please sign in to comment.