From 3c7f16a1bb5f85214bdc87cd7e585bfa1989f041 Mon Sep 17 00:00:00 2001 From: mguzman14 Date: Thu, 23 Jan 2025 17:51:06 +0100 Subject: [PATCH] enhance(check_data): enhance and adapt fct_temp_tables to om_check_data and disable user_check_data --- utils/fct/gw_fct_manage_temp_tables.sql | 30 +++++++++++++------------ utils/fct/gw_fct_om_check_data.sql | 8 +++++++ utils/fct/gw_fct_setcheckdatabase.sql | 17 +++++++++----- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/utils/fct/gw_fct_manage_temp_tables.sql b/utils/fct/gw_fct_manage_temp_tables.sql index 80166bb38..1a41a616b 100644 --- a/utils/fct/gw_fct_manage_temp_tables.sql +++ b/utils/fct/gw_fct_manage_temp_tables.sql @@ -150,24 +150,26 @@ BEGIN END IF; IF 'MAPZONES' = ANY(v_group_array) THEN - IF 'DMA' = ANY(v_subGroup_array) THEN + IF 'DMA' = ANY(v_subGroup_array) OR 'ALL' = ANY(v_subGroup_array) THEN CREATE TEMP TABLE t_dma AS SELECT * FROM v_edit_dma; + --raise exception 'aaaa'; END IF; - + + IF 'SECTOR' = ANY(v_subGroup_array) OR 'ALL' = ANY(v_subGroup_array) THEN + CREATE TEMP TABLE t_sector AS SELECT * FROM v_edit_sector; + END IF; + IF v_project_type = 'WS' THEN - IF 'DQA' = ANY(v_subGroup_array) THEN - CREATE TEMP TABLE t_dqa AS SELECT * FROM v_edit_dqa; - END IF; - - IF 'PRESSZONE' = ANY(v_subGroup_array) THEN - CREATE TEMP TABLE t_presszone AS SELECT * FROM v_edit_presszone; - END IF; - - IF 'SECTOR' = ANY(v_subGroup_array) THEN - CREATE TEMP TABLE t_sector AS SELECT * FROM v_edit_sector; - END IF; + IF 'PRESSZONE' = ANY(v_subGroup_array) OR 'ALL' = ANY(v_subGroup_array) THEN + CREATE TEMP TABLE t_presszone AS SELECT * FROM v_edit_presszone; + END IF; + + IF 'DQA' = ANY(v_subGroup_array) OR 'ALL' = ANY(v_subGroup_array)THEN + CREATE TEMP TABLE t_dqa AS SELECT * FROM v_edit_dqa; + END IF; + ELSIF v_project_type = 'UD' THEN - IF 'DRAINZONE' = ANY(v_subGroup_array) THEN + IF 'DRAINZONE' = ANY(v_subGroup_array) OR 'ALL' = ANY(v_subGroup_array) THEN CREATE TEMP TABLE t_drainzone AS SELECT * FROM v_edit_drainzone; END IF; END IF; diff --git a/utils/fct/gw_fct_om_check_data.sql b/utils/fct/gw_fct_om_check_data.sql index 75158d8aa..8bf873227 100644 --- a/utils/fct/gw_fct_om_check_data.sql +++ b/utils/fct/gw_fct_om_check_data.sql @@ -51,7 +51,11 @@ BEGIN -- create temp tables IF v_fid = 125 THEN + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"CREATE", "group":"LOG"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"CREATE", "group":"ANL"}}}$$)'; EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"CREATE", "group":"OMCHECK"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"CREATE", "group":"MAPZONES", "subGroup":"ALL"}}}$$)'; + END IF; -- getting sys_fprocess to be executed @@ -81,7 +85,11 @@ BEGIN EXECUTE 'SELECT gw_fct_create_logreturn($${"data":{"parameters":{"type":"line"}}}$$::json)' INTO v_result_line; EXECUTE 'SELECT gw_fct_create_logreturn($${"data":{"parameters":{"type":"polygon"}}}$$::json)' INTO v_result_polygon; + -- drop temp tables + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"DROP", "group":"LOG"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"DROP", "group":"ANL"}}}$$)'; EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"DROP", "group":"OMCHECK"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"DROP", "group":"MAPZONES", "subGroup":"ALL"}}}$$)'; -- Return RETURN gw_fct_json_create_return(('{"status":"Accepted", "message":{"level":1, "text":"Data quality analysis done succesfully"}, "version":"'||v_version||'"'|| diff --git a/utils/fct/gw_fct_setcheckdatabase.sql b/utils/fct/gw_fct_setcheckdatabase.sql index 9f159b2f9..ad7e4d770 100644 --- a/utils/fct/gw_fct_setcheckdatabase.sql +++ b/utils/fct/gw_fct_setcheckdatabase.sql @@ -65,10 +65,11 @@ BEGIN -- create log tables EXECUTE 'SELECT gw_fct_create_logtables($${"data":{"parameters":{"fid":604}}}$$::json)'; - -- create query tables - EXECUTE 'SELECT gw_fct_create_querytables($${"data":{"parameters":{"fid":604, - "omCheck":'||v_omcheck||', "graphCheck":'||v_graphcheck||', "epaCheck":'||v_epacheck||', "planCheck":'|| - v_plancheck||', "adminCheck":'||v_omcheck||', "verifiedExceptions":'||v_verified_exceptions||'}}}$$::json)'; + -- create temp tables + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"CREATE", "group":"LOG"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"CREATE", "group":"ANL"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"CREATE", "group":"OMCHECK"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"CREATE", "group":"MAPZONES", "subGroup":"ALL"}}}$$)'; -- starting check process IF 'role_om' IN (SELECT rolname FROM pg_roles WHERE pg_has_role( current_user, oid, 'member')) AND v_omcheck THEN @@ -84,7 +85,13 @@ BEGIN EXECUTE 'SELECT gw_fct_admin_check_data($${"data":{"parameters":{"fid":'||v_fid||', "isEmbebed":true}}}$$)'; END IF; - EXECUTE 'SELECT gw_fct_user_check_data($${"data":{"parameters":{"fid":'||v_fid||', "isEmbebed":true}}}$$)'; + --EXECUTE 'SELECT gw_fct_user_check_data($${"data":{"parameters":{"fid":'||v_fid||', "isEmbebed":true}}}$$)'; + + -- drop temp tables + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"DROP", "group":"LOG"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"DROP", "group":"ANL"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"DROP", "group":"OMCHECK"}}}$$)'; + EXECUTE 'SELECT gw_fct_manage_temp_tables($${"data":{"parameters":{"fid":'||v_fid||', "project_type":"'||v_project_type||'", "action":"DROP", "group":"MAPZONES", "subGroup":"ALL"}}}$$)'; -- create return EXECUTE 'SELECT gw_fct_create_return($${"data":{"parameters":{"functionId":3364, "isEmbebed":false}}}$$::json)' INTO v_return;