Skip to content

Commit

Permalink
enhan(mapzones): Enhance mapzones strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
xtorret committed Jan 2, 2025
1 parent 10a82d8 commit 369b66e
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 307 deletions.
6 changes: 1 addition & 5 deletions example/user/ud/ud_99_sample_other.sql
Original file line number Diff line number Diff line change
Expand Up @@ -806,11 +806,7 @@ UPDATE cat_feature_gully SET double_geom = '{"activated":true,"value":1}' WHERE

INSERT INTO config_param_user (parameter, value, cur_user) VALUES ('om_visit_status_vdefault', '4', current_user) ON CONFLICT (parameter, cur_user) DO NOTHING;

SELECT setval('SCHEMA_NAME.urn_id_seq', gw_fct_setvalurn(),true);

UPDATE config_param_system SET value = gw_fct_json_object_set_key(value::json, 'sectorFromExpl', false) WHERE parameter = 'basic_selector_tab_exploitation';
UPDATE config_param_system SET value = gw_fct_json_object_set_key(value::json, 'explFromSector', false) WHERE parameter = 'basic_selector_tab_sector';
UPDATE config_param_system SET value = gw_fct_json_object_set_key(value::json,'explFromMacroexpl', false) WHERE parameter = 'basic_selector_tab_macroexploitation';
SELECT setval('SCHEMA_NAME.urn_id_seq', gw_fct_setvalurn(),true);;

INSERT INTO inp_lid VALUES ('BIO-RETENTION','BC');
INSERT INTO inp_lid VALUES ('VEGE-SWALE','VS');
Expand Down
2 changes: 0 additions & 2 deletions example/user/ud/ud_99_sample_zfinal.sql
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ UPDATE cat_arc SET visitability_vdef = 1 WHERE geom1 <= 1.2; -- NO VISITABLE
UPDATE cat_arc SET visitability_vdef = 2 WHERE geom1 > 1.2 AND geom1 < 1.6; -- SEMI VISITABLE
UPDATE cat_arc SET visitability_vdef = 3 WHERE geom1 >= 1.6; -- VISITABLE

UPDATE config_param_system SET isenabled = true WHERE parameter = 'basic_selector_tab_municipality';

UPDATE link SET muni_id = c.muni_id FROM connec c WHERE connec_id = feature_id;
UPDATE link SET muni_id = g.muni_id FROM gully g WHERE gully_id = feature_id;

Expand Down
5 changes: 0 additions & 5 deletions example/user/ws/ws_99_sample_other.sql
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,6 @@ UPDATE cat_mat_roughness SET roughness = 0.025 WHERE matcat_id IN ('FC');

SELECT setval('SCHEMA_NAME.urn_id_seq', gw_fct_setvalurn(),true);

UPDATE config_param_system SET value = gw_fct_json_object_set_key(value::json, 'sectorFromExpl', false) WHERE parameter = 'basic_selector_tab_exploitation';
UPDATE config_param_system SET value = gw_fct_json_object_set_key(value::json, 'explFromSector', false) WHERE parameter = 'basic_selector_tab_sector';
UPDATE config_param_system SET value = gw_fct_json_object_set_key(value::json,'explFromMacroexpl', false) WHERE parameter = 'basic_selector_tab_macroexploitation';


INSERT INTO config_param_user VALUES ('edit_pavement_vdefault','Asphalt',current_user);

INSERT INTO plan_arc_x_pavement (arc_id, pavcat_id, percent) VALUES ('2001', 'Slab', 0.5);
Expand Down
1 change: 0 additions & 1 deletion example/user/ws/ws_99_sample_zfinal.sql
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ UPDATE config_param_system SET value = gw_fct_json_object_set_key(value::json, '
UPDATE config_param_system SET value = gw_fct_json_object_set_key(value::json, 'sys_geom', 's.the_geom'::text)
WHERE parameter ='basic_search_v2_tab_address';

UPDATE config_param_system SET isenabled = true WHERE parameter = 'basic_selector_tab_municipality';

UPDATE link SET muni_id = c.muni_id FROM connec c WHERE connec_id = feature_id;

Expand Down
68 changes: 1 addition & 67 deletions updates/36/36017/ud/ddlview.sql
Original file line number Diff line number Diff line change
Expand Up @@ -988,70 +988,4 @@ drop view v_edit_link_connec;
create or replace view v_edit_link_connec as select * from v_edit_link where feature_type = 'CONNEC';

drop view v_edit_link_gully;
create or replace view v_edit_link_gully as select * from v_edit_link where feature_type = 'GULLY';

-- 31/12/2024
CREATE OR REPLACE VIEW vu_sector as
SELECT distinct on (sector_id) s.sector_id,
s.name,
s.macrosector_id,
m.name AS macrosector_name,
et.idval,
s.descript,
s.parent_id,
s.graphconfig::text AS graphconfig,
s.stylesheet::text AS stylesheet,
s.link,
s.active,
s.undelete,
s.tstamp,
s.insert_user,
s.lastupdate,
s.lastupdate_user,
s.the_geom
FROM sector s
JOIN (SELECT DISTINCT sector_id, expl_id FROM node WHERE state > 0) a USING (sector_id)
JOIN config_user_x_expl USING (expl_id)
LEFT JOIN macrosector m USING (macrosector_id)
LEFT JOIN edit_typevalue et ON et.id::text = s.sector_type::text AND et.typevalue::text = 'sector_type'::text
where username = current_user and (s.sector_id > 0 or s.sector_id <-9)
union
SELECT distinct on (sector_id) s.sector_id,
s.name,
s.macrosector_id,
m.name AS macrosector_name,
et.idval,
s.descript,
s.parent_id,
s.graphconfig::text AS graphconfig,
s.stylesheet::text AS stylesheet,
s.link,
s.active,
s.undelete,
s.tstamp,
s.insert_user,
s.lastupdate,
s.lastupdate_user,
s.the_geom
FROM sector s
LEFT JOIN ( SELECT DISTINCT node.sector_id, node.expl_id FROM node WHERE node.state > 0) a USING (sector_id)
LEFT JOIN macrosector m USING (macrosector_id)
LEFT JOIN edit_typevalue et ON et.id::text = s.sector_type::text AND et.typevalue::text = 'sector_type'::text
where (s.sector_id > 0 or s.sector <-9) and a.sector_id is null
ORDER BY 1;


CREATE OR REPLACE VIEW v_edit_sector
AS SELECT sector.sector_id,
sector.name,
sector.descript,
sector.macrosector_id,
sector.sector_type,
sector.the_geom,
sector.undelete,
sector.active,
sector.parent_id,
sector.graphconfig::text AS graphconfig,
sector.stylesheet
FROM selector_sector, sector
WHERE sector.sector_id = selector_sector.sector_id AND selector_sector.cur_user = "current_user"()::text and active is true;
create or replace view v_edit_link_gully as select * from v_edit_link where feature_type = 'GULLY';
57 changes: 1 addition & 56 deletions updates/36/36017/utils/ddlview.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,4 @@ This version of Giswater is provided by Giswater Association
SET search_path = SCHEMA_NAME, public, pg_catalog;


-- 31/12/2024

CREATE OR REPLACE VIEW vu_exploitation as
select e.* from exploitation e
JOIN config_user_x_expl USING (expl_id)
where username = current_user and (expl_id > 0 or expl_id < -9)
order by 1;

CREATE OR REPLACE VIEW vu_macroexploitation as
select distinct on (macroexpl_id) m.* from macroexploitation m
join exploitation using (macroexpl_id)
JOIN config_user_x_expl USING (expl_id)
where username = current_user and (macroexpl_id > 0 or macroexpl_id < -9)
UNION
select distinct on (macroexpl_id) m.* from macroexploitation m
LEFT join exploitation using (macroexpl_id)
where expl_id IS NULL and (macroexpl_id > 0 or macroexpl_id < -9)
order by 1;

CREATE OR REPLACE VIEW vu_macrosector as
select distinct on (macrosector_id) m.* from macrosector m
join sector using (macrosector_id)
JOIN (SELECT DISTINCT sector_id, expl_id FROM node WHERE state > 0) a USING (sector_id)
join exploitation using (expl_id)
JOIN config_user_x_expl USING (expl_id)
where username = current_user and (macrosector_id > 0 or macrosector_id < -9)
UNION
select distinct on (macrosector_id) m.* from macrosector m
LEFT join sector using (macrosector_id)
where sector_id IS NULL and (macrosector_id > 0 or macrosector_id < -9)
order by 1;

CREATE OR REPLACE VIEW vu_ext_municipality as
select m.* from ext_municipality m
join (SELECT DISTINCT muni_id, expl_id FROM node WHERE state > 0) a USING (muni_id)
JOIN config_user_x_expl USING (expl_id)
where username = current_user and (muni_id > 0 or muni_id < -9)
UNION
select m.* from ext_municipality m
LEFT join (SELECT DISTINCT muni_id, expl_id FROM node WHERE state > 0) a USING (muni_id)
where a.muni_id IS NULL and (muni_id > 0 or muni_id < -9)
order by 1;

CREATE OR REPLACE VIEW v_edit_exploitation
AS SELECT exploitation.expl_id,
exploitation.name,
exploitation.macroexpl_id,
exploitation.descript,
exploitation.undelete,
exploitation.the_geom,
exploitation.tstamp,
exploitation.active
FROM selector_expl,
exploitation
WHERE exploitation.expl_id = selector_expl.expl_id AND selector_expl.cur_user = "current_user"()::text
and active is true;
-- 31/12/2024
33 changes: 15 additions & 18 deletions updates/36/36017/utils/dml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ UPDATE config_form_tabs SET orderby = 2 where formname = 'selector_basic' and ta
UPDATE sys_table set sys_role='role_edit' where id = 'sector';
UPDATE sys_table set sys_role='role_basic' where id = 'config_user_x_expl';

update config_param_system set value =
'{"table":"vu_macrosector","selector":"selector_macrosector","table_id":"macrosector_id","selector_id":"macrosector_id","label":"macrosector_id, '' - '', name","orderBy":"macrosector_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(macrosector_id, '' - '', name))", "selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'::text
where parameter='basic_selector_tab_macrosector';

update config_param_system set value =
'{"table":"vu_macroexploitation","selector":"selector_macroexpl","table_id":"macroexpl_id","selector_id":"macroexpl_id","label":"macroexpl_id, '' - '', name","orderBy":"macroexpl_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(macroexpl_id, '' - '', name))", "selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'::text
where parameter='basic_selector_tab_macroexploitation';

INSERT INTO config_form_tabs VALUES ('selector_basic','tab_exploitation_add', 'Expl Add', 'Active exploitation', 'role_basic',null,null,1,'{4,5}');

INSERT into config_param_system (parameter, value, descript, label, isenabled, project_type, datatype, widgettype)
Expand All @@ -39,8 +31,9 @@ delete from config_param_system where parameter = 'basic_selector_mapzone_relati

delete from config_param_system where parameter = 'basic_selector_explfrommuni';

delete from config_param_system where parameter = 'basic_selector_options';
insert into config_param_system (parameter, value, descript, label, project_type)
values ('basic_selector_options', '{"sectorFromExpl":true, "explFromMacro":true, "sectorFromMacro":true, "muniClientFilter":false, "sectorClientFilter":false}', 'Options variables for selector', 'Selector variables', 'utils');
values ('basic_selector_options', '{"sectorFromExpl":false, "explFromMacro":false, "sectorFromMacro":false, "muniClientFilter":false, "sectorClientFilter":false}', 'Options variables for selector', 'Selector variables', 'utils');

UPDATE config_param_system set isenabled = false where parameter = 'basic_selector_tab_municipality';

Expand All @@ -54,29 +47,33 @@ INSERT INTO sys_table (id, descript, sys_role, source) VALUES ('vu_ext_municipal
INSERT INTO sys_table (id, descript, sys_role, source) VALUES ('vu_om_mincut','View of all mincuts related to user', 'role_basic', 'core');

update config_param_system
set value = '{"table":"vu_sector","selector":"selector_sector","table_id":"sector_id","selector_id":"sector_id","label":"sector_id, '' - '', name","orderBy":"sector_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(sector_id, '' - '', name))", "selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'
set value = '{"table":"temp_sector","selector":"selector_sector","table_id":"sector_id","selector_id":"sector_id","label":"sector_id, '' - '', name","orderBy":"sector_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(sector_id, '' - '', name))", "selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'
where parameter = 'basic_selector_tab_sector';

update config_param_system
set value = '{"table":"vu_exploitation","selector":"selector_expl","table_id":"expl_id","selector_id":"expl_id","label":"expl_id, '' - '', name","orderBy":"expl_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(expl_id, '' - '', name))","selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'
set value = '{"table":"temp_exploitation","selector":"selector_expl","table_id":"expl_id","selector_id":"expl_id","label":"expl_id, '' - '', name","orderBy":"expl_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(expl_id, '' - '', name))","selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'
where parameter = 'basic_selector_tab_exploitation';

update config_param_system set value =
'{"table":"temp_macrosector","selector":"selector_macrosector","table_id":"macrosector_id","selector_id":"macrosector_id","label":"macrosector_id, '' - '', name","orderBy":"macrosector_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(macrosector_id, '' - '', name))", "selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'::text
where parameter='basic_selector_tab_macrosector';

update config_param_system set value =
'{"table":"temp_macroexploitation","selector":"selector_macroexpl","table_id":"macroexpl_id","selector_id":"macroexpl_id","label":"macroexpl_id, '' - '', name","orderBy":"macroexpl_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(macroexpl_id, '' - '', name))", "selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'::text
where parameter='basic_selector_tab_macroexploitation';

update config_param_system
set value = '{"table":"vu_ext_municipality","selector":"selector_municipality","table_id":"muni_id","selector_id":"muni_id","label":"muni_id, ''- '', name","orderBy":"muni_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(muni_id, '' - '', name))","selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'
set isenabled = false, value = '{"table":"ext_municipality","selector":"selector_municipality","table_id":"muni_id","selector_id":"muni_id","label":"muni_id, ''- '', name","orderBy":"muni_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(muni_id, '' - '', name))","selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'
where parameter = 'basic_selector_tab_municipality';

update config_param_system
set value = '{"table":"vu_macroexploitation","selector":"selector_expl","table_id":"macroexpl_id","selector_id":"expl_id","label":"macroexpl_id, '' - '', name","orderBy":"macroexpl_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(macroexpl_id, '' - '', name))", "selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'
set value = '{"table":"macroexploitation","selector":"selector_expl","table_id":"macroexpl_id","selector_id":"expl_id","label":"macroexpl_id, '' - '', name","orderBy":"macroexpl_id","manageAll":true,"query_filter":"","typeaheadFilter":" AND lower(concat(macroexpl_id, '' - '', name))", "selectionMode":"keepPreviousUsingShift", "orderbyCheck":false}'
where parameter = 'basic_selector_tab_macroexploitation_add';

update config_param_system
set value = '{"table":"vu_om_mincut","table_id":"id","selector":"selector_mincut_result","selector_id":"result_id","label":"id, ''('', CASE WHEN work_order IS NULL THEN ''N/I'' ELSE work_order END, '') on '', forecast_start::date, '' at '', forecast_start::time, ''H-'', forecast_end::time,''H''","query_filter":"","manageAll":true}'
set value = '{"table":"temp_mincut","table_id":"id","selector":"selector_mincut_result","selector_id":"result_id","label":"id, ''('', CASE WHEN work_order IS NULL THEN ''N/I'' ELSE work_order END, '') on '', forecast_start::date, '' at '', forecast_start::time, ''H-'', forecast_end::time,''H''","query_filter":"","manageAll":true}'
where parameter = 'basic_selector_tab_mincut';

INSERT INTO sys_function (id, function_name, project_type, function_type, input_params, return_type, descript, sys_role, sample_query, "source")
VALUES(3368, 'gw_trg_exploitation', 'utils', 'trigger function', null, null, 'Manage insert into config_user_x_expl table.', 'role_basic', NULL, 'core');





Expand Down
15 changes: 0 additions & 15 deletions updates/36/36017/utils/trg.sql

This file was deleted.

106 changes: 39 additions & 67 deletions updates/36/36017/ws/ddlview.sql
Original file line number Diff line number Diff line change
Expand Up @@ -859,19 +859,14 @@ WITH
)
SELECT l.*
FROM link_selected l;


CREATE OR REPLACE VIEW vu_om_mincut as
select distinct on (m.id) m.* from om_mincut m
JOIN config_user_x_expl USING (expl_id)
where username = current_user and m.id > 0;

CREATE OR REPLACE VIEW vu_sector as
SELECT DISTINCT ON (s.sector_id) s.sector_id,
DROP VIEW IF EXISTS v_edit_sector;
DROP VIEW IF EXISTS vu_sector;
CREATE OR REPLACE VIEW vu_sector
AS SELECT s.sector_id,
s.name,
s.macrosector_id,
m.name AS macrosector_name,
et.idval,
et.idval as sector_type,
s.descript,
s.parent_id,
s.pattern_id,
Expand All @@ -887,61 +882,38 @@ SELECT DISTINCT ON (s.sector_id) s.sector_id,
s.lastupdate_user,
s.the_geom
FROM sector s
JOIN ( SELECT DISTINCT node.sector_id, node.expl_id FROM node WHERE node.state > 0) a USING (sector_id)
JOIN config_user_x_expl USING (expl_id)
LEFT JOIN macrosector m USING (macrosector_id)
LEFT JOIN edit_typevalue et ON et.id::text = s.sector_type::text AND et.typevalue::text = 'sector_type'::text
WHERE config_user_x_expl.username::text = CURRENT_USER AND (s.sector_id > 0 or s.sector_id < -9)
UNION
select s.sector_id,
s.name,
s.macrosector_id,
m.name AS macrosector_name,
et.idval,
s.descript,
s.parent_id,
s.pattern_id,
s.graphconfig::text AS graphconfig,
s.stylesheet::text AS stylesheet,
s.link,
s.avg_press,
s.active,
s.undelete,
s.tstamp,
s.insert_user,
s.lastupdate,
s.lastupdate_user,
s.the_geom
FROM sector s
LEFT JOIN ( SELECT DISTINCT node.sector_id, node.expl_id FROM node WHERE node.state > 0) a USING (sector_id)
LEFT JOIN macrosector m USING (macrosector_id)
LEFT JOIN edit_typevalue et ON et.id::text = s.sector_type::text AND et.typevalue::text = 'sector_type'::text
where (s.sector_id > 0 or s.sector_id < -9) and a.sector_id is null
ORDER BY 1;


CREATE OR REPLACE VIEW v_edit_sector
AS SELECT vu_sector.sector_id,
vu_sector.name,
vu_sector.macrosector_id,
vu_sector.macrosector_name,
vu_sector.idval,
vu_sector.descript,
vu_sector.parent_id,
vu_sector.pattern_id,
vu_sector.graphconfig,
vu_sector.stylesheet,
vu_sector.link,
vu_sector.avg_press,
vu_sector.active,
vu_sector.undelete,
vu_sector.tstamp,
vu_sector.insert_user,
vu_sector.lastupdate,
vu_sector.lastupdate_user,
vu_sector.the_geom
FROM vu_sector,
selector_sector
WHERE vu_sector.sector_id = selector_sector.sector_id AND selector_sector.cur_user = "current_user"()::text
and active is true;

ORDER BY s.sector_id;

DROP VIEW IF EXISTS v_edit_sector;
CREATE OR REPLACE VIEW v_edit_sector
AS SELECT s.*
FROM vu_sector s, selector_sector
WHERE s.sector_id = selector_sector.sector_id and active AND selector_sector.cur_user = "current_user"()::text;

create trigger gw_trg_edit_sector instead of insert or delete or update on v_edit_sector
for each row execute function gw_trg_edit_sector('sector');

create or replace view v_edit_presszone as
select vu.* from vu_presszone vu, selector_expl
WHERE vu.expl_id = selector_expl.expl_id and active AND selector_expl.cur_user = "current_user"()::text OR vu.expl_id IS NULL
ORDER BY vu.presszone_id;

create or replace view v_edit_dma as
select vu.* from vu_dma vu, selector_expl
WHERE vu.expl_id = selector_expl.expl_id and active AND selector_expl.cur_user = "current_user"()::text OR vu.expl_id IS NULL
ORDER BY vu.dma_id;

create or replace view v_edit_dma as
select vu.* from vu_dma vu, selector_expl
WHERE vu.expl_id = selector_expl.expl_id and active AND selector_expl.cur_user = "current_user"()::text OR vu.expl_id IS NULL
ORDER BY vu.dma_id;

create or replace view v_edit_dqa as
select vu.* from vu_dqa vu, selector_expl
WHERE vu.expl_id = selector_expl.expl_id and active AND selector_expl.cur_user = "current_user"()::text OR vu.expl_id IS NULL
ORDER BY vu.dqa_id;




Loading

0 comments on commit 369b66e

Please sign in to comment.