From 1b829160c891d824362892a76767ddfd0c4605ad Mon Sep 17 00:00:00 2001 From: SJiB Date: Fri, 3 May 2024 16:27:20 +0200 Subject: [PATCH] add wwtp_structure to view --- view/vw_qgep_wastewater_structure.py | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/view/vw_qgep_wastewater_structure.py b/view/vw_qgep_wastewater_structure.py index 7a178c72..3a80ede2 100755 --- a/view/vw_qgep_wastewater_structure.py +++ b/view/vw_qgep_wastewater_structure.py @@ -40,6 +40,7 @@ def vw_qgep_wastewater_structure(srid: int, WHEN ss.obj_id IS NOT NULL THEN 'special_structure' WHEN dp.obj_id IS NOT NULL THEN 'discharge_point' WHEN ii.obj_id IS NOT NULL THEN 'infiltration_installation' + WHEN wt.obj_id IS NOT NULL THEN 'wwtp_structure' ELSE 'unknown' END AS ws_type @@ -85,6 +86,7 @@ def vw_qgep_wastewater_structure(srid: int, LEFT JOIN qgep_od.special_structure ss ON ss.obj_id = ws.obj_id LEFT JOIN qgep_od.discharge_point dp ON dp.obj_id = ws.obj_id LEFT JOIN qgep_od.infiltration_installation ii ON ii.obj_id = ws.obj_id + LEFT JOIN qgep_od.wwtp_structure wt ON wt.obj_id = ws.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.obj_id = ws.fk_main_wastewater_node LEFT JOIN qgep_od.wastewater_node wn ON wn.obj_id = ws.fk_main_wastewater_node LEFT JOIN qgep_od.channel ch ON ch.obj_id = ws.obj_id @@ -157,6 +159,15 @@ def vw_qgep_wastewater_structure(srid: int, skip_columns=[], prefix='dp_', remap_columns={}), + wt_columns=select_columns(pg_cur=cursor, + table_schema='qgep_od', + table_name='wwtp_structure', + table_alias='wt', + remove_pkey=True, + indent=4, + skip_columns=[], + prefix='wt_', + remap_columns={}), wn_cols=select_columns(pg_cur=cursor, table_schema='qgep_od', table_name='wastewater_node', @@ -211,6 +222,10 @@ def vw_qgep_wastewater_structure(srid: int, WHEN NEW.ws_type = 'infiltration_installation' THEN {insert_ii} + -- Wastewater treatment plant structure (wwtp structure) + WHEN NEW.ws_type = 'wwtp_structure' THEN + {insert_wt} + ELSE RAISE NOTICE 'Wastewater structure type not known (%)', NEW.ws_type; -- ERROR END CASE; @@ -275,6 +290,14 @@ def vw_qgep_wastewater_structure(srid: int, remove_pkey=False, indent=6, remap_columns={'obj_id': 'obj_id'}), + insert_wt=insert_command(pg_cur=cursor, + table_schema='qgep_od', + table_name='wwtp_structure', + table_alias='wt', + prefix='wt_', + remove_pkey=False, + indent=6, + remap_columns={'obj_id': 'obj_id'}), insert_wn=insert_command(pg_cur=cursor, table_schema='qgep_od', table_name='vw_wastewater_node', @@ -329,6 +352,7 @@ def vw_qgep_wastewater_structure(srid: int, WHEN OLD.ws_type = 'special_structure' THEN DELETE FROM qgep_od.special_structure WHERE obj_id = OLD.obj_id; WHEN OLD.ws_type = 'discharge_point' THEN DELETE FROM qgep_od.discharge_point WHERE obj_id = OLD.obj_id; WHEN OLD.ws_type = 'infiltration_installation' THEN DELETE FROM qgep_od.infiltration_installation WHERE obj_id = OLD.obj_id; + WHEN OLD.ws_type = 'wwtp_structure' THEN DELETE FROM qgep_od.wwtp_structure WHERE obj_id = OLD.obj_id; ELSE -- do nothing END CASE; @@ -337,6 +361,7 @@ def vw_qgep_wastewater_structure(srid: int, WHEN NEW.ws_type = 'special_structure' THEN INSERT INTO qgep_od.special_structure (obj_id) VALUES(OLD.obj_id); WHEN NEW.ws_type = 'discharge_point' THEN INSERT INTO qgep_od.discharge_point (obj_id) VALUES(OLD.obj_id); WHEN NEW.ws_type = 'infiltration_installation' THEN INSERT INTO qgep_od.infiltration_installation (obj_id) VALUES(OLD.obj_id); + WHEN NEW.ws_type = 'wwtp_structure' THEN INSERT INTO qgep_od.wwtp_structure (obj_id) VALUES(OLD.obj_id); ELSE -- do nothing END CASE; END IF; @@ -354,6 +379,9 @@ def vw_qgep_wastewater_structure(srid: int, WHEN NEW.ws_type = 'infiltration_installation' THEN {update_ii} + WHEN NEW.ws_type = 'wwtp_structure' THEN + {update_wt} + ELSE -- do nothing END CASE; @@ -499,6 +527,15 @@ def vw_qgep_wastewater_structure(srid: int, indent=6, skip_columns=[], remap_columns={'obj_id': 'obj_id'}), + update_wt=update_command(pg_cur=cursor, + table_schema='qgep_od', + table_name='wwtp_structure', + table_alias='wt', + prefix='wt_', + remove_pkey=True, + indent=6, + skip_columns=[], + remap_columns={'obj_id': 'obj_id'}), update_wn=update_command(pg_cur=cursor, table_schema='qgep_od', table_name='wastewater_node',