From b433f6ee7336eda6845c292ffd188b08f98cdb1c Mon Sep 17 00:00:00 2001 From: mguzman14 Date: Tue, 27 Aug 2024 20:04:18 +0200 Subject: [PATCH] fix(muni_id and sector_id): add columns sector_id and muni_id to trg_edit_tables --- ud/ftrg/ud_gw_trg_edit_raingage.sql | 7 ++++--- utils/ftrg/gw_trg_edit_dimensions.sql | 6 +++--- utils/ftrg/gw_trg_edit_element.sql | 6 +++--- ws/ftrg/ws_gw_trg_edit_unconnected.sql | 12 ++++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ud/ftrg/ud_gw_trg_edit_raingage.sql b/ud/ftrg/ud_gw_trg_edit_raingage.sql index e29c98f465..4e2739b482 100644 --- a/ud/ftrg/ud_gw_trg_edit_raingage.sql +++ b/ud/ftrg/ud_gw_trg_edit_raingage.sql @@ -31,8 +31,8 @@ BEGIN END IF; -- FEATURE INSERT - INSERT INTO raingage (rg_id, form_type, intvl, scf, rgage_type, timser_id, fname, sta, units, the_geom, expl_id) - VALUES (NEW.rg_id, NEW.form_type, NEW.intvl, NEW.scf, NEW.rgage_type, NEW.timser_id, NEW.fname, NEW.sta, NEW.units, NEW.the_geom, NEW.expl_id); + INSERT INTO raingage (rg_id, form_type, intvl, scf, rgage_type, timser_id, fname, sta, units, the_geom, expl_id, muni_id) + VALUES (NEW.rg_id, NEW.form_type, NEW.intvl, NEW.scf, NEW.rgage_type, NEW.timser_id, NEW.fname, NEW.sta, NEW.units, NEW.the_geom, NEW.expl_id, NEW.muni_id); RETURN NEW; @@ -41,7 +41,8 @@ BEGIN -- UPDATE values UPDATE raingage - SET rg_id=NEW.rg_id, form_type=NEW.form_type, intvl=NEW.intvl, scf=NEW.scf, rgage_type=NEW.rgage_type, timser_id=NEW.timser_id, fname=NEW.fname, sta=NEW.sta, units=NEW.units, the_geom=NEW.the_geom, expl_id=NEW.expl_id + SET rg_id=NEW.rg_id, form_type=NEW.form_type, intvl=NEW.intvl, scf=NEW.scf, rgage_type=NEW.rgage_type, timser_id=NEW.timser_id, fname=NEW.fname, sta=NEW.sta, + units=NEW.units, the_geom=NEW.the_geom, expl_id=NEW.expl_id, muni_id=NEW.muni_id WHERE rg_id = OLD.rg_id; RETURN NEW; diff --git a/utils/ftrg/gw_trg_edit_dimensions.sql b/utils/ftrg/gw_trg_edit_dimensions.sql index 8655b33e11..b71f76601e 100644 --- a/utils/ftrg/gw_trg_edit_dimensions.sql +++ b/utils/ftrg/gw_trg_edit_dimensions.sql @@ -51,9 +51,9 @@ BEGIN -- Insert INSERT INTO dimensions (id, distance, depth, the_geom, x_label, y_label, rotation_label, offset_label, direction_arrow, x_symbol, y_symbol, - feature_id, feature_type, state, expl_id, observ, comment) + feature_id, feature_type, state, expl_id, observ, comment, sector_id, muni_id) VALUES (NEW.id, NEW.distance, NEW.depth, NEW.the_geom, NEW.x_label, NEW.y_label, NEW.rotation_label, NEW.offset_label, NEW.direction_arrow, - NEW.x_symbol, NEW.y_symbol, NEW.feature_id, NEW.feature_type, NEW.state, NEW.expl_id, NEW.observ, NEW.comment); + NEW.x_symbol, NEW.y_symbol, NEW.feature_id, NEW.feature_type, NEW.state, NEW.expl_id, NEW.observ, NEW.comment, NEW.sector_id, NEW.muni_id); RETURN NEW; @@ -65,7 +65,7 @@ BEGIN SET id=NEW.id, distance=NEW.distance, depth=NEW.depth, the_geom=NEW.the_geom, x_label=NEW.x_label, y_label=NEW.y_label, rotation_label=NEW.rotation_label, offset_label=NEW.offset_label, direction_arrow=NEW.direction_arrow, x_symbol=NEW.x_symbol, y_symbol=NEW.y_symbol, feature_id=NEW.feature_id, feature_type=NEW.feature_type, - expl_id=NEW.expl_id, observ=NEW.observ, state=NEW.state, comment=NEW.comment, lastupdate=now(), lastupdate_user = current_user + expl_id=NEW.expl_id, observ=NEW.observ, state=NEW.state, comment=NEW.comment, lastupdate=now(), lastupdate_user = current_user, sector_id=NEW.sector_id, muni_id=NEW.muni_id WHERE id=NEW.id; RETURN NEW; diff --git a/utils/ftrg/gw_trg_edit_element.sql b/utils/ftrg/gw_trg_edit_element.sql index 483ea6ccce..5460040652 100644 --- a/utils/ftrg/gw_trg_edit_element.sql +++ b/utils/ftrg/gw_trg_edit_element.sql @@ -222,11 +222,11 @@ BEGIN -- FEATURE INSERT INSERT INTO element (element_id, code, elementcat_id, model_id, brand_id, serial_number, "state", state_type, observ, "comment", function_type, category_type, location_type, workcat_id, workcat_id_end, buildercat_id, builtdate, enddate, ownercat_id, rotation, link, verified, the_geom, label_x, label_y, label_rotation, publish, - inventory, undelete, expl_id, num_elements, pol_id, expl_id2) + inventory, undelete, expl_id, num_elements, pol_id, expl_id2, sector_id, muni_id) VALUES (NEW.element_id, NEW.code, NEW.elementcat_id, NEW.model_id, NEW.brand_id, NEW.serial_number, NEW."state", NEW.state_type, NEW.observ, NEW."comment", NEW.function_type, NEW.category_type, NEW.location_type, NEW.workcat_id, NEW.workcat_id_end, NEW.buildercat_id, NEW.builtdate, NEW.enddate, NEW.ownercat_id, NEW.rotation, NEW.link, NEW.verified, NEW.the_geom, NEW.label_x, NEW.label_y, NEW.label_rotation, NEW.publish, - NEW.inventory, NEW.undelete, NEW.expl_id, NEW.num_elements, v_pol_id, NEW.expl_id2); + NEW.inventory, NEW.undelete, NEW.expl_id, NEW.num_elements, v_pol_id, NEW.expl_id2, NEW.sector_id, NEW.muni_id); -- update element_x_feature table IF v_tablefeature IS NOT NULL AND v_feature IS NOT NULL THEN @@ -269,7 +269,7 @@ BEGIN function_type=NEW.function_type, category_type=NEW.category_type, location_type=NEW.location_type, workcat_id=NEW.workcat_id, workcat_id_end=NEW.workcat_id_end, buildercat_id=NEW.buildercat_id, builtdate=NEW.builtdate, enddate=NEW.enddate, ownercat_id=NEW.ownercat_id, rotation=NEW.rotation, link=NEW.link, verified=NEW.verified, the_geom=NEW.the_geom, label_x=NEW.label_x, label_y=NEW.label_y, label_rotation=NEW.label_rotation, publish=NEW.publish, inventory=NEW.inventory, undelete=NEW.undelete,expl_id=NEW.expl_id, num_elements=NEW.num_elements, - lastupdate=now(), lastupdate_user=current_user, trace_featuregeom=NEW.trace_featuregeom + lastupdate=now(), lastupdate_user=current_user, trace_featuregeom=NEW.trace_featuregeom, sector_id=NEW.sector_id, muni_id=NEW.muni_id WHERE element_id=OLD.element_id; IF v_project_type = 'WS' THEN diff --git a/ws/ftrg/ws_gw_trg_edit_unconnected.sql b/ws/ftrg/ws_gw_trg_edit_unconnected.sql index e5833650b8..96a50091f8 100644 --- a/ws/ftrg/ws_gw_trg_edit_unconnected.sql +++ b/ws/ftrg/ws_gw_trg_edit_unconnected.sql @@ -75,8 +75,8 @@ BEGIN NEW.pond_id:= (SELECT nextval('pond_id_seq')); END IF; - INSERT INTO pond (pond_id, connec_id, the_geom, expl_id, dma_id, state) - VALUES (NEW.pond_id, NEW.connec_id, NEW.the_geom, expl_id_int, NEW.dma_id, NEW."state"); + INSERT INTO pond (pond_id, connec_id, the_geom, expl_id, dma_id, state, muni_id) + VALUES (NEW.pond_id, NEW.connec_id, NEW.the_geom, expl_id_int, NEW.dma_id, NEW."state", NEW.muni_id); ELSIF man_table='pool' THEN -- Pool ID @@ -86,8 +86,8 @@ BEGIN NEW.pool_id:= (SELECT nextval('pool_id_seq')); END IF; - INSERT INTO pool(pool_id, connec_id, the_geom, expl_id,dma_id, state) - VALUES (NEW.pool_id, NEW.connec_id, NEW.the_geom, expl_id_int, NEW.dma_id, NEW."state"); + INSERT INTO pool(pool_id, connec_id, the_geom, expl_id,dma_id, state, muni_id) + VALUES (NEW.pool_id, NEW.connec_id, NEW.the_geom, expl_id_int, NEW.dma_id, NEW."state", NEW.muni_id); END IF; @@ -101,12 +101,12 @@ BEGIN IF man_table='pond' THEN UPDATE pond - SET pond_id=NEW.pond_id, connec_id=NEW.connec_id, the_geom=NEW.the_geom, expl_id=NEW.expl_id, dma_id=NEW.dma_id, "state"=NEW."state" + SET pond_id=NEW.pond_id, connec_id=NEW.connec_id, the_geom=NEW.the_geom, expl_id=NEW.expl_id, dma_id=NEW.dma_id, "state"=NEW."state", muni_id=NEW.muni_id WHERE pond_id=OLD.pond_id; ELSIF man_table='pool' THEN UPDATE pool - SET pool_id=NEW.pool_id, connec_id=NEW.connec_id, the_geom=NEW.the_geom, expl_id=NEW.expl_id, dma_id=NEW.dma_id, "state"=NEW."state" + SET pool_id=NEW.pool_id, connec_id=NEW.connec_id, the_geom=NEW.the_geom, expl_id=NEW.expl_id, dma_id=NEW.dma_id, "state"=NEW."state", muni_id=NEW.muni_id WHERE pool_id=NEW.pool_id; END IF;