Skip to content

Commit

Permalink
enhance(check_data): enhance and adapt fct_temp_tables to om_check_da…
Browse files Browse the repository at this point in the history
…ta and disable user_check_data
  • Loading branch information
mguzman14 committed Jan 23, 2025
1 parent 83f9ac6 commit 3c7f16a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
30 changes: 16 additions & 14 deletions utils/fct/gw_fct_manage_temp_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions utils/fct/gw_fct_om_check_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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||'"'||
Expand Down
17 changes: 12 additions & 5 deletions utils/fct/gw_fct_setcheckdatabase.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 3c7f16a

Please sign in to comment.