diff --git a/updates/36/36012/ud/trg.sql b/updates/36/36012/ud/trg.sql index d7d77c87e6..216deccba5 100644 --- a/updates/36/36012/ud/trg.sql +++ b/updates/36/36012/ud/trg.sql @@ -8,20 +8,12 @@ This version of Giswater is provided by Giswater Association SET search_path = SCHEMA_NAME, public, pg_catalog; --26/07/2024 -CREATE TRIGGER gw_trg_ui_rpt_cat_result -INSTEAD OF INSERT OR DELETE OR UPDATE -ON v_ui_rpt_cat_result -FOR EACH ROW EXECUTE FUNCTION gw_trg_ui_rpt_cat_result(); +CREATE TRIGGER gw_trg_ui_rpt_cat_result INSTEAD OF INSERT OR DELETE OR UPDATE +ON v_ui_rpt_cat_result FOR EACH ROW EXECUTE FUNCTION gw_trg_ui_rpt_cat_result(); --05/08/2024 -CREATE trigger gw_trg_ui_doc_x_gully instead OF -INSERT - OR -DELETE - OR -UPDATE - ON - v_ui_doc_x_gully FOR each row EXECUTE function gw_trg_ui_doc('doc_x_gully'); +CREATE trigger gw_trg_ui_doc_x_gully instead OF INSERT OR DELETE OR UPDATE +ON v_ui_doc_x_gully FOR each row EXECUTE function gw_trg_ui_doc('doc_x_gully'); --07/08/2024 CREATE TRIGGER gw_trg_edit_element INSTEAD OF INSERT OR DELETE OR UPDATE ON v_edit_element @@ -143,3 +135,6 @@ FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_inp_arc('inp_conduit'); CREATE TRIGGER gw_trg_edit_pol_gully INSTEAD OF INSERT OR DELETE OR UPDATE ON ve_pol_gully FOR EACH ROW EXECUTE FUNCTION gw_trg_edit_man_gully_pol(); + +CREATE TRIGGER gw_trg_edit_link INSTEAD OF INSERT OR UPDATE OR DELETE ON v_edit_link +FOR EACH ROW EXECUTE PROCEDURE gw_trg_edit_link(); diff --git a/updates/36/36012/ws/trg.sql b/updates/36/36012/ws/trg.sql index 91aa4f9dd6..fd51bf0717 100644 --- a/updates/36/36012/ws/trg.sql +++ b/updates/36/36012/ws/trg.sql @@ -145,3 +145,6 @@ FOR EACH ROW EXECUTE PROCEDURE gw_trg_edit_ve_epa('valve'); CREATE TRIGGER gw_trg_edit_ve_epa_inlet INSTEAD OF INSERT OR UPDATE OR DELETE ON ve_epa_inlet FOR EACH ROW EXECUTE PROCEDURE gw_trg_edit_ve_epa('inlet'); + +CREATE TRIGGER gw_trg_edit_link INSTEAD OF INSERT OR UPDATE OR DELETE ON v_edit_link +FOR EACH ROW EXECUTE PROCEDURE gw_trg_edit_link(); diff --git a/utils/fct/gw_fct_linktonetwork.sql b/utils/fct/gw_fct_linktonetwork.sql index f296ec83e8..b38f682e1c 100644 --- a/utils/fct/gw_fct_linktonetwork.sql +++ b/utils/fct/gw_fct_linktonetwork.sql @@ -43,7 +43,6 @@ SELECT SCHEMA_NAME.gw_fct_setlinktonetwork($${"client":{"device":4, "infoType":1 SELECT SCHEMA_NAME.gw_fct_setlinktonetwork($${"client":{"device":4, "infoType":1,"lang":"ES"},"feature": {"id":"SELECT array_to_json(array_agg(connec_id::text)) FROM v_edit_connec WHERE connec_id IS NOT NULL AND state=1"},"data":{"feature_type":"CONNEC"}}$$); - --fid: 217 */ @@ -110,7 +109,6 @@ v_check_arcdnom integer; v_checkeddiam text; v_querytext text; - BEGIN @@ -448,14 +446,14 @@ BEGIN IF v_projecttype = 'WS' THEN INSERT INTO link (link_id, the_geom, feature_id, feature_type, exit_type, exit_id, state, expl_id, sector_id, dma_id, - presszone_id, dqa_id, minsector_id, fluid_type) + presszone_id, dqa_id, minsector_id, fluid_type, muni_id) VALUES (v_link.link_id, v_link.the_geom, v_connect_id, v_feature_type, v_link.exit_type, v_link.exit_id, - v_connect.state, v_arc.expl_id, v_arc.sector_id, v_dma_value, v_arc.presszone_id, v_arc.dqa_id, v_arc.minsector_id, v_fluidtype_value); + v_connect.state, v_arc.expl_id, v_arc.sector_id, v_dma_value, v_arc.presszone_id, v_arc.dqa_id, v_arc.minsector_id, v_fluidtype_value, v_connect.muni_id); ELSIF v_projecttype = 'UD' THEN - INSERT INTO link (link_id, the_geom, feature_id, feature_type, exit_type, exit_id, state, expl_id, sector_id, dma_id, fluid_type) + INSERT INTO link (link_id, the_geom, feature_id, feature_type, exit_type, exit_id, state, expl_id, sector_id, dma_id, fluid_type, muni_id) VALUES (v_link.link_id, v_link.the_geom, v_connect_id, v_feature_type, v_link.exit_type, v_link.exit_id, - v_connect.state, v_arc.expl_id, v_arc.sector_id, v_dma_value, v_fluidtype_value); + v_connect.state, v_arc.expl_id, v_arc.sector_id, v_dma_value, v_fluidtype_value, v_connect.muni_id); END IF; ELSE UPDATE link SET the_geom=v_link.the_geom, exit_type=v_link.exit_type, exit_id=v_link.exit_id, dma_id = v_dma_value, fluid_type = v_fluidtype_value WHERE link_id = v_link.link_id; diff --git a/utils/fct/gw_fct_setselectors.sql b/utils/fct/gw_fct_setselectors.sql index 9e9f9a4aa3..c7e25a0ded 100644 --- a/utils/fct/gw_fct_setselectors.sql +++ b/utils/fct/gw_fct_setselectors.sql @@ -391,12 +391,12 @@ BEGIN -- expl DELETE FROM selector_expl WHERE cur_user = current_user; INSERT INTO selector_expl - SELECT DISTINCT expl_id, current_user FROM node WHERE sector_id IN (SELECT sector_id FROM selector_sector WHERE cur_user = current_user); + SELECT DISTINCT expl_id, current_user FROM node WHERE sector_id IN (SELECT sector_id FROM selector_sector WHERE cur_user = current_user AND sector_id > 0); -- muni DELETE FROM selector_municipality WHERE cur_user = current_user; INSERT INTO selector_municipality - SELECT DISTINCT muni_id, current_user FROM node WHERE sector_id IN (SELECT sector_id FROM selector_sector WHERE cur_user = current_user); + SELECT DISTINCT muni_id, current_user FROM node WHERE sector_id IN (SELECT sector_id FROM selector_sector WHERE cur_user = current_user AND sector_id > 0); END IF; -- inserting muni_id from selected muni diff --git a/utils/ftrg/gw_trg_edit_link.sql b/utils/ftrg/gw_trg_edit_link.sql index 24fe0861d2..df6c0ce10f 100644 --- a/utils/ftrg/gw_trg_edit_link.sql +++ b/utils/ftrg/gw_trg_edit_link.sql @@ -552,17 +552,17 @@ BEGIN IF v_projectype = 'WS' THEN INSERT INTO link (link_id, feature_type, feature_id, expl_id, exit_id, exit_type, userdefined_geom, state, the_geom, sector_id, - fluid_type, dma_id, dqa_id, presszone_id, minsector_id, connecat_id, workcat_id, workcat_id_end, builtdate, enddate, exit_elev, exit_topelev, uncertain) + fluid_type, dma_id, dqa_id, presszone_id, minsector_id, connecat_id, workcat_id, workcat_id_end, builtdate, enddate, exit_elev, exit_topelev, uncertain, muni_id) VALUES (NEW.link_id, NEW.feature_type, NEW.feature_id, v_expl, NEW.exit_id, NEW.exit_type, TRUE, NEW.state, NEW.the_geom, v_sector, v_fluidtype, v_dma, v_dqa, v_presszone, v_minsector, NEW.connecat_id, NEW.workcat_id, NEW.workcat_id_end, NEW.builtdate, NEW.enddate, - NEW.exit_elev, NEW.exit_topelev, NEW.uncertain); + NEW.exit_elev, NEW.exit_topelev, NEW.uncertain, NEW.muni_id); ELSIF v_projectype = 'UD' THEN INSERT INTO link (link_id, feature_type, feature_id, expl_id, exit_id, exit_type, userdefined_geom, state, the_geom, sector_id, fluid_type, dma_id, - connecat_id, workcat_id, workcat_id_end, builtdate, enddate, exit_elev, exit_topelev, uncertain) + connecat_id, workcat_id, workcat_id_end, builtdate, enddate, exit_elev, exit_topelev, uncertain, muni_id) VALUES (NEW.link_id, NEW.feature_type, NEW.feature_id, v_expl, NEW.exit_id, NEW.exit_type, TRUE, NEW.state, NEW.the_geom, v_sector, v_fluidtype, v_dma, - NEW.connecat_id, NEW.workcat_id, NEW.workcat_id_end, NEW.builtdate, NEW.enddate, NEW.exit_elev, NEW.exit_topelev, NEW.uncertain); + NEW.connecat_id, NEW.workcat_id, NEW.workcat_id_end, NEW.builtdate, NEW.enddate, NEW.exit_elev, NEW.exit_topelev, NEW.uncertain, NEW.muni_id); END IF; -- update feature @@ -692,9 +692,9 @@ BEGIN END IF; - -- update link state + -- update link parameters UPDATE link SET state = NEW.state, the_geom = NEW.the_geom, workcat_id = NEW.workcat_id, workcat_id_end = NEW.workcat_id_end, builtdate = NEW.builtdate, - enddate = NEW.enddate, exit_elev = NEW.exit_elev, exit_topelev = NEW.exit_topelev, uncertain = NEW.uncertain + enddate = NEW.enddate, exit_elev = NEW.exit_elev, exit_topelev = NEW.exit_topelev, uncertain = NEW.uncertain, muni_id = NEW.muni_id WHERE link_id=NEW.link_id; -- Update state_type if edit_connect_update_statetype is TRUE diff --git a/utils/ftrg/gw_trg_link_data.sql b/utils/ftrg/gw_trg_link_data.sql index 19fa19bba5..7e1e4603b9 100644 --- a/utils/ftrg/gw_trg_link_data.sql +++ b/utils/ftrg/gw_trg_link_data.sql @@ -26,15 +26,15 @@ BEGIN IF v_feature_type = 'LINK' THEN IF v_projecttype = 'WS' THEN - UPDATE link l SET epa_type = c.epa_type, is_operative = v.is_operative, expl_id2 = c.expl_id2, connecat_id = c.connecat_id, fluid_type = c.fluid_type + UPDATE link l SET epa_type = c.epa_type, is_operative = v.is_operative, expl_id2 = c.expl_id2, connecat_id = c.connecat_id, fluid_type = c.fluid_type, muni_id = c.muni_id FROM connec c JOIN value_state_type v ON v.id = c.state_type WHERE l.feature_id = c.connec_id AND c.connec_id = NEW.feature_id AND l.state > 0 AND link_id = NEW.link_id; ELSE - UPDATE link l SET epa_type = c.epa_type, is_operative = v.is_operative, expl_id2 = c.expl_id2, connecat_id=c.connec_arccat_id, fluid_type = c.fluid_type + UPDATE link l SET epa_type = c.epa_type, is_operative = v.is_operative, expl_id2 = c.expl_id2, connecat_id=c.connec_arccat_id, fluid_type = c.fluid_type, muni_id = c.muni_id FROM gully c JOIN value_state_type v ON v.id = c.state_type WHERE l.feature_id = c.gully_id AND c.gully_id = NEW.feature_id AND l.state > 0 AND link_id = NEW.link_id; - UPDATE link l SET is_operative = v.is_operative, expl_id2 = c.expl_id2, connecat_id = c.connecat_id, fluid_type = c.fluid_type + UPDATE link l SET is_operative = v.is_operative, expl_id2 = c.expl_id2, connecat_id = c.connecat_id, fluid_type = c.fluid_type, muni_id = c.muni_id FROM connec c JOIN value_state_type v ON v.id = c.state_type WHERE l.feature_id = c.connec_id AND c.connec_id = NEW.feature_id AND l.state > 0 AND link_id = NEW.link_id; END IF; @@ -53,16 +53,16 @@ BEGIN IF v_feature_type = 'CONNEC' THEN IF v_projecttype = 'WS' THEN - UPDATE link SET epa_type = NEW.epa_type, is_operative = v.is_operative, expl_id2 = NEW.expl_id2, connecat_id = NEW.connecat_id, fluid_type = NEW.fluid_type + UPDATE link SET epa_type = NEW.epa_type, is_operative = v.is_operative, expl_id2 = NEW.expl_id2, connecat_id = NEW.connecat_id, fluid_type = NEW.fluid_type, muni_id = NEW.muni_id FROM value_state_type v WHERE id = NEW.state_type AND feature_id = NEW.connec_id; ELSE - UPDATE link SET is_operative = v.is_operative, expl_id2 = NEW.expl_id2, connecat_id = NEW.connecat_id, fluid_type = NEW.fluid_type + UPDATE link SET is_operative = v.is_operative, expl_id2 = NEW.expl_id2, connecat_id = NEW.connecat_id, fluid_type = NEW.fluid_type,muni_id = NEW.muni_id FROM value_state_type v WHERE id = NEW.state_type AND feature_id = NEW.connec_id; END IF; ELSIF v_feature_type = 'GULLY' THEN - UPDATE link SET epa_type = NEW.epa_type, is_operative = v.is_operative, expl_id2 = NEW.expl_id2, connecat_id = NEW.connec_arccat_id, fluid_type = NEW.fluid_type + UPDATE link SET epa_type = NEW.epa_type, is_operative = v.is_operative, expl_id2 = NEW.expl_id2, connecat_id = NEW.connec_arccat_id, fluid_type = NEW.fluid_type, muni_id = NEW.muni_id FROM value_state_type v WHERE id = NEW.state_type AND feature_id = NEW.gully_id; ELSIF v_feature_type = 'LINK' THEN