From ae9f6866b7f7fdf3bfddd4be0ff7be5647f96409 Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 11:35:12 +0100 Subject: [PATCH 01/20] Create .pre-commit-config.yaml --- .pre-commit-config.yaml | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..1dff8c288 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,70 @@ +# files: '^.*\.py|.*\.tpl|.*\.sql|.*\.yaml|.*\.txt|.*\.md$' +exclude: '^.*\.xtf|.*\.xml|.*\.ili|qgepqwat2ili/bin.*$' + +repos: + # Fix end of files + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: mixed-line-ending + args: + - "--fix=lf" + + # Remove unused imports/variables + - repo: https://github.com/PyCQA/autoflake + rev: v2.3.1 + hooks: + - id: autoflake + args: + - "--in-place" + - "--remove-all-unused-imports" + - "--remove-unused-variable" + + # Sort imports + - repo: https://github.com/pycqa/isort + rev: "5.13.2" + hooks: + - id: isort + args: + - --profile + - black + + # Black formatting + - repo: https://github.com/psf/black + rev: "24.10.0" + hooks: + - id: black + args: ["--line-length=99"] + + # tool to automatically upgrade syntax for newer versions of the language + - repo: https://github.com/asottile/pyupgrade + rev: v3.17.0 + hooks: + - id: pyupgrade + args: [--py37-plus] + + # Lint files + - repo: https://github.com/pycqa/flake8 + rev: "7.1.1" + hooks: + - id: flake8 + args: [ + "--max-line-length=115", + # ignore long comments (E501), as long lines are formatted by black + "--ignore=E501,E203,W503", + ] + +# # Static type-checking with mypy +# - repo: https://github.com/pre-commit/mirrors-mypy +# rev: 'v1.5.1' +# hooks: +# - id: mypy +# additional_dependencies: [types-pytz, types-Deprecated, types-PyYAML, types-requests, types-tabulate, types-jsonschema, django-stubs] +# pass_filenames: false +# entry: bash -c 'mypy -p docker-qgis -p docker-app "$@"' -- + +ci: + autofix_prs: true + autoupdate_schedule: quarterly From f7ff8c7fd0678a3e1c17e32e97716bb3d769b6a0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:35:44 +0000 Subject: [PATCH 02/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .deploy/create-dumps.py | 215 +++--- .docker/README.md | 2 +- .docker/init_qgep.sh | 2 +- .github/workflows/docker-test-and-push.yaml | 2 +- .gitignore | 1 - 01_audit.sql | 42 +- 03_qgep_db_dss.sql | 298 ++++---- 04_vsa_kek_extension.sql | 38 +- 05_data_model_extensions.sql | 4 +- 06_symbology_functions.sql | 48 +- 07_network_tracking.sql | 1 - 12_1_roles.sql | 1 - 14_geometry_functions.sql | 6 +- 50_maintenance_zones.sql | 1 - VSA_DSS_2008_1.imd | 2 +- delta/delta_1.0.1_prefix_reach_view.sql | 2 +- delta/delta_1.1.0_fix_dictionary_od_table.sql | 1 - ...delta_1.1.1_add_reach_direction_change.sql | 8 +- ...1.1.1_fix_depth_after_node_update.post.sql | 2 +- ...delta_1.1.1_reach_point_update_trigger.sql | 2 +- delta/delta_1.1.1_symbology_drop_triggers.sql | 1 - delta/delta_1.1.1_symbology_update.sql | 1 - delta/delta_1.2.0_geometry_altitude.post.sql | 4 +- delta/delta_1.2.0_reach_on_delete_rule.sql | 4 +- ...1.2.1_fix_vw_qgep_wastewater_structure.sql | 2 +- delta/delta_1.3.0_import_trigger.sql | 2 +- delta/delta_1.3.0_remove_old_views.post.sql | 2 - delta/delta_1.3.2_update_audit.sql | 32 +- delta/delta_1.4.0_import_views.sql | 2 +- ...ase_maintenance_event_base_data_length.sql | 1 - ...ater_structure_label_with_bottom_level.sql | 5 +- delta/delta_1.4.1_swmm_catchment_areas.sql | 2 +- ...delta_1.5.0_fix_network_tracking_views.sql | 2 +- delta/delta_1.5.3_fix_ws_output_labels.sql | 2 +- ...5.5_add_spatial_index_on_network_views.sql | 2 +- ...ermissions_on_network_refresh_function.sql | 2 +- delta/delta_1.5.5_symbology_for_nodes.sql | 4 +- ...delta_1.5.6_kek_model_update_2008_2019.sql | 112 +-- ...pdate_attribute_pump_construction_type.sql | 8 +- delta/delta_1.5.7_fix_symbology_for_nodes.sql | 2 +- .../delta_1.5.8_add_reach_hydraulic_load.sql | 2 +- ...lta_1.5.8_dss_upddate_attributes_class.sql | 20 +- ...ta_1.5.8_tbl_swmm_coefficient_friction.sql | 12 +- delta/delta_1.5.9_adjust_ws_labeling.sql | 12 +- ...delta_1.6.1_alter_order_fct_hierarchic.sql | 6 +- ...xx_fk_chute_to_fk_surface_water_bodies.sql | 1 - ...low_characteristic_to_fk_overflow_char.sql | 16 +- delta/delta_1.6.2_dss_rename_system_user.sql | 4 +- ...1.6.2_update_usage_current_by_overflow.sql | 30 +- delta/post-all.py | 34 +- delta/pre-all.py | 82 ++- fixes/fix_depth.sql | 1 - fixes/fix_on_delete_actions.sql | 2 +- functions/reach_direction_change.sql | 8 +- scripts/dispatch_table_migration/README.md | 8 +- swmm_views/01_vw_swmm_create_schema.sql | 2 +- swmm_views/02_vw_swmm_junctions.sql | 16 +- swmm_views/04_vw_swmm_conduits.sql | 28 +- swmm_views/05_vw_swmm_dividers.sql | 8 +- swmm_views/07_vw_swmm_losses.sql | 4 +- swmm_views/08_vw_swmm_outfalls.sql | 10 +- swmm_views/09_vw_swmm_subcatchments.sql | 20 +- swmm_views/10_vw_swmm_subareas.sql | 10 +- swmm_views/11_vw_swmm_dwf.sql | 20 +- swmm_views/12_vw_swmm_raingages.sql | 4 +- swmm_views/13_vw_swmm_infiltrations.sql | 6 +- swmm_views/16_vw_swmm_pumps.sql | 4 +- swmm_views/18_vw_swmm_storages.sql | 26 +- swmm_views/19_vw_swmm_outlets.sql | 6 +- swmm_views/20_vw_swmm_orifices.sql | 2 +- swmm_views/21_vw_swmm_weirs.sql | 10 +- swmm_views/22_vw_swmm_curves.sql | 22 +- swmm_views/23_vw_swmm_xsections.sql | 9 +- swmm_views/24_vw_swmm_coordinates.sql | 2 +- test/test_geometry.py | 630 ++++++++++------- test/test_import.py | 444 ++++++------ test/test_label.py | 154 ++-- test/test_network.py | 225 +++--- test/test_on_delete.py | 227 +++--- test/test_removed_fields.py | 14 +- test/test_swmm.py | 11 +- test/test_triggers.py | 401 ++++++----- test/test_typos.py | 24 +- test/test_views.py | 108 +-- test/utils.py | 111 +-- test_data/data_fixes.sql | 2 +- view/additional_views/vw_blocking_debris.sql | 1 - view/additional_views/vw_building.sql | 1 - view/additional_views/vw_chute.sql | 1 - view/additional_views/vw_cooperative.sql | 1 - view/additional_views/vw_dam.sql | 1 - view/additional_views/vw_drainage_system.sql | 1 - .../vw_electric_equipment.sql | 1 - .../vw_electromechanical_equipment.sql | 1 - view/additional_views/vw_ford.sql | 1 - view/additional_views/vw_fountain.sql | 1 - .../vw_ground_water_protection_perimeter.sql | 1 - .../vw_groundwater_protection_zone.sql | 1 - .../vw_infiltration_installation.sql | 1 - .../additional_views/vw_infiltration_zone.sql | 1 - view/additional_views/vw_lake.sql | 1 - view/additional_views/vw_lock.sql | 1 - view/additional_views/vw_param_ca_general.sql | 1 - view/additional_views/vw_param_ca_mouse1.sql | 1 - view/additional_views/vw_passage.sql | 1 - view/additional_views/vw_planning_zone.sql | 1 - .../vw_qgep_catchment_area.sql | 1 - .../vw_qgep_maintenance_on_reach.sql | 2 +- .../vw_qgep_maintenance_on_wws.sql | 4 +- view/additional_views/vw_reach_relining.sql | 3 +- view/additional_views/vw_reservoir.sql | 1 - view/additional_views/vw_river.sql | 1 - view/additional_views/vw_rock_ramp.sql | 1 - view/additional_views/vw_solids_retention.sql | 1 - view/additional_views/vw_tank_cleaning.sql | 1 - view/additional_views/vw_tank_emptying.sql | 1 - .../vw_wizard_reach_channel.sql | 7 +- view/additional_views/vw_wwtp_structure.sql | 1 - view/create_views.py | 356 +++++++--- view/export/vw_export_reach.yaml | 1 - .../vw_export_wastewater_structure.yaml | 1 - view/network/vw_network_node.sql | 2 +- view/network/vw_network_segment.sql | 4 +- view/vw_catchment_area_additional.sql | 2 +- view/vw_catchment_area_rwc_connenctions.sql | 2 +- view/vw_catchment_area_rwp_connections.sql | 2 +- view/vw_damage.yaml | 1 - view/vw_file.sql | 2 +- view/vw_maintenance_examination.yaml | 2 - view/vw_oo_organisation.yaml | 1 - view/vw_oo_overflow.yaml | 4 - view/vw_qgep_import.sql | 1 - view/vw_qgep_reach.py | 478 +++++++------ view/vw_qgep_wastewater_structure.py | 657 ++++++++++-------- 134 files changed, 2919 insertions(+), 2309 deletions(-) diff --git a/.deploy/create-dumps.py b/.deploy/create-dumps.py index 078801fbb..2d424e182 100755 --- a/.deploy/create-dumps.py +++ b/.deploy/create-dumps.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ *************************************************************************** @@ -18,16 +17,14 @@ *************************************************************************** """ -__author__ = 'Denis Rouzaud' -__date__ = 'April 2018' -__copyright__ = '(C) 2018,Denis Rouzaud' +__author__ = "Denis Rouzaud" +__date__ = "April 2018" +__copyright__ = "(C) 2018,Denis Rouzaud" # This will get replaced with a git SHA1 when you do a git archive -__revision__ = '$Format:%H$' +__revision__ = "$Format:%H$" -import http.client import os -import json import subprocess @@ -56,7 +53,9 @@ def files_description(version): * If you plan to **use QGEP for production**, it is more likely you will be using the plain SQL `qgep_{version}_structure_with_value_lists.sql`. * If you want to **give a try at QGEP**, you will likely restore the `qgep_{version}_structure_and_demo_data.backup` backup file. -""".format(version=version) +""".format( + version=version + ) def create_dumps(): @@ -76,43 +75,54 @@ def create_plain_structure_only(): Create a plain SQL dump of data structure of all schemas and the content of pum_sys.inf :return: the file name of the dump """ - print('::group::plain SQL structure only') + print("::group::plain SQL structure only") # structure - dump_s = 'qgep_{version}_structure.sql'.format( - version=os.environ['CI_TAG']) - - print('Creating dump {}'.format(dump_s)) - dump_file_s = 'artifacts/{dump}'.format(dump=dump_s) - _cmd(['pg_dump', - '--format', 'plain', - '--schema-only', - '--file', dump_file_s, - '--exclude-schema', 'public', - '--no-owner', - 'qgep_prod'] - ) + dump_s = "qgep_{version}_structure.sql".format(version=os.environ["CI_TAG"]) + + print(f"Creating dump {dump_s}") + dump_file_s = f"artifacts/{dump_s}" + _cmd( + [ + "pg_dump", + "--format", + "plain", + "--schema-only", + "--file", + dump_file_s, + "--exclude-schema", + "public", + "--no-owner", + "qgep_prod", + ] + ) # dump all from qgep_sys except logged_actions - dump_i = 'qgep_{version}_pum_info.sql'.format( - version=os.environ['CI_TAG']) - print('Creating dump {}'.format(dump_i)) - dump_file_i = 'artifacts/{dump}'.format(dump=dump_i) - _cmd(['pg_dump', - '--format', 'plain', - '--data-only', - '--file', dump_file_i, - '--schema', 'qgep_sys', - '--exclude-table', 'qgep_sys.logged_actions', - 'qgep_prod'] - ) - print('Concatenating the 2 dumps') + dump_i = "qgep_{version}_pum_info.sql".format(version=os.environ["CI_TAG"]) + print(f"Creating dump {dump_i}") + dump_file_i = f"artifacts/{dump_i}" + _cmd( + [ + "pg_dump", + "--format", + "plain", + "--data-only", + "--file", + dump_file_i, + "--schema", + "qgep_sys", + "--exclude-table", + "qgep_sys.logged_actions", + "qgep_prod", + ] + ) + print("Concatenating the 2 dumps") with open(dump_file_i) as f: dump_data = f.read() with open(dump_file_s, "a") as f: f.write(dump_data) - print('::endgroup::') + print("::endgroup::") return dump_file_s @@ -123,35 +133,40 @@ def create_plain_value_list(structure_dump_file): with value list content :return: the file name of the dump """ - print('::group::value lists dump') - - dump = 'qgep_{version}_structure_with_value_lists.sql'.format( - version=os.environ['CI_TAG']) - - print('Creating dump {}'.format(dump)) - dump_file = 'artifacts/{dump}'.format(dump=dump) - - _cmd(['pg_dump', - '--format', 'plain', - '--blobs', - '--data-only', - '--file', dump_file, - '--schema', 'qgep_vl', - 'qgep_prod'] - ) - - print('Concatenating the 2 dumps') + print("::group::value lists dump") + + dump = "qgep_{version}_structure_with_value_lists.sql".format(version=os.environ["CI_TAG"]) + + print(f"Creating dump {dump}") + dump_file = f"artifacts/{dump}" + + _cmd( + [ + "pg_dump", + "--format", + "plain", + "--blobs", + "--data-only", + "--file", + dump_file, + "--schema", + "qgep_vl", + "qgep_prod", + ] + ) + + print("Concatenating the 2 dumps") with open(dump_file) as f: dump_data = f.read() with open(structure_dump_file) as f: structure_dump_data = f.read() - with open(dump_file, 'w') as f: + with open(dump_file, "w") as f: f.write(structure_dump_data) - f.write('\n\n\n-- Value lists dump --\n\n') + f.write("\n\n\n-- Value lists dump --\n\n") f.write(dump_data) - print('::endgroup::') - + print("::endgroup::") + return dump_file @@ -161,22 +176,29 @@ def create_backup_data(): :return: the file name """ # Create data-only dumps (with sample data) - dump = 'qgep_{version}_demo_data.backup'.format( - version = os.environ['CI_TAG']) - print('::group::{}'.format(dump)) - print('Creating dump {}'.format(dump)) - dump_file = 'artifacts/{dump}'.format(dump=dump) - _cmd(['pg_dump', - '--format', 'custom', - '--blobs', - '--data-only', - '--compress', '5', - '--file', dump_file, - '--table', 'qgep_od.*', - '--table', 'qgep_sys.logged_actions', - 'qgep_prod'] - ) - print('::endgroup::') + dump = "qgep_{version}_demo_data.backup".format(version=os.environ["CI_TAG"]) + print(f"::group::{dump}") + print(f"Creating dump {dump}") + dump_file = f"artifacts/{dump}" + _cmd( + [ + "pg_dump", + "--format", + "custom", + "--blobs", + "--data-only", + "--compress", + "5", + "--file", + dump_file, + "--table", + "qgep_od.*", + "--table", + "qgep_sys.logged_actions", + "qgep_prod", + ] + ) + print("::endgroup::") return dump_file @@ -186,20 +208,26 @@ def create_backup_complete(): :return: the file name """ # Create data + structure dumps (with sample data) - dump = 'qgep_{version}_structure_and_demo_data.backup'.format( - version = os.environ['CI_TAG']) - print('::group::{}'.format(dump)) - print('Creating dump {}'.format(dump)) - dump_file = 'artifacts/{dump}'.format(dump=dump) - _cmd(['pg_dump', - '--format', 'custom', - '--blobs', - '--compress', '5', - '--file', dump_file, - '-N', 'public', - 'qgep_prod'] - ) - print('::endgroup::') + dump = "qgep_{version}_structure_and_demo_data.backup".format(version=os.environ["CI_TAG"]) + print(f"::group::{dump}") + print(f"Creating dump {dump}") + dump_file = f"artifacts/{dump}" + _cmd( + [ + "pg_dump", + "--format", + "custom", + "--blobs", + "--compress", + "5", + "--file", + dump_file, + "-N", + "public", + "qgep_prod", + ] + ) + print("::endgroup::") return dump_file @@ -208,15 +236,16 @@ def main(): """ Creates dumps to be attached to releases. """ - if 'CI_TAG' not in os.environ or not os.environ['CI_TAG']: - print('No git tag: not deploying anything') + if "CI_TAG" not in os.environ or not os.environ["CI_TAG"]: + print("No git tag: not deploying anything") return else: - print('Creating release from tag {}'.format(os.environ['CI_TAG'])) + print("Creating release from tag {}".format(os.environ["CI_TAG"])) - os.mkdir('artifacts') + os.mkdir("artifacts") files = create_dumps() - print('Dumps created: {}'.format(', '.join(files))) + print("Dumps created: {}".format(", ".join(files))) + if __name__ == "__main__": main() diff --git a/.docker/README.md b/.docker/README.md index e0d6b0dae..e1eca97bb 100644 --- a/.docker/README.md +++ b/.docker/README.md @@ -24,7 +24,7 @@ Reinitialization ```bash # later on, to reinitialize all databases docker exec qgep init_qgep.sh -# optionally, you can specify which database to reinitialize like this +# optionally, you can specify which database to reinitialize like this # docker exec qgep init_qgep.sh structure ``` diff --git a/.docker/init_qgep.sh b/.docker/init_qgep.sh index c327b211b..793ae0e16 100644 --- a/.docker/init_qgep.sh +++ b/.docker/init_qgep.sh @@ -40,7 +40,7 @@ if [ "$1" == "release" ]; then echo 'you must provide the release version as second argument' exit 1 fi - + echo '----------------------------------------' echo "Installing demo data from release" diff --git a/.github/workflows/docker-test-and-push.yaml b/.github/workflows/docker-test-and-push.yaml index b95f75c80..b37cd064d 100644 --- a/.github/workflows/docker-test-and-push.yaml +++ b/.github/workflows/docker-test-and-push.yaml @@ -22,7 +22,7 @@ jobs: matrix: # postgres-postgis version, see available tags https://hub.docker.com/r/postgis/postgis/tags pgis: - # WARNING: if changing this, make sure tu update `pgis_stable` below + # WARNING: if changing this, make sure tu update `pgis_stable` below - 13-3.2 - 14-3.2 #- 15-3.3 # Postgis 3.3 requires QGEP datamodel adaptations diff --git a/.gitignore b/.gitignore index 945948426..1d61282e2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,3 @@ nosetests.xml .DS_Store .idea temp/ - diff --git a/01_audit.sql b/01_audit.sql index 64cae73b8..35fa0e082 100644 --- a/01_audit.sql +++ b/01_audit.sql @@ -38,9 +38,9 @@ CREATE TABLE qgep_sys.logged_actions ( changed_fields hstore, statement_only BOOLEAN NOT NULL ); - + REVOKE ALL ON qgep_sys.logged_actions FROM public; - + COMMENT ON TABLE qgep_sys.logged_actions IS 'History of auditable actions on audited tables, from qgep_sys.if_modified_func()'; COMMENT ON COLUMN qgep_sys.logged_actions.event_id IS 'Unique identifier for each auditable event'; COMMENT ON COLUMN qgep_sys.logged_actions.schema_name IS 'Database schema audited table for this event is in'; @@ -59,7 +59,7 @@ COMMENT ON COLUMN qgep_sys.logged_actions.action IS 'Action type; I = insert, D COMMENT ON COLUMN qgep_sys.logged_actions.row_data IS 'Record value. Null for statement-level trigger. For INSERT this is the new tuple. For DELETE and UPDATE it is the old tuple.'; COMMENT ON COLUMN qgep_sys.logged_actions.changed_fields IS 'New values of fields changed by UPDATE. Null except for row-level UPDATE events.'; COMMENT ON COLUMN qgep_sys.logged_actions.statement_only IS '''t'' if audit event is from an FOR EACH STATEMENT trigger, ''f'' for FOR EACH ROW'; - + CREATE INDEX logged_actions_relid_idx ON qgep_sys.logged_actions(relid); CREATE INDEX logged_actions_action_tstamp_tx_stm_idx ON qgep_sys.logged_actions(action_tstamp_stm); CREATE INDEX logged_actions_action_idx ON qgep_sys.logged_actions(action); @@ -129,12 +129,12 @@ BEGIN END IF; INSERT INTO qgep_sys.logged_actions VALUES (audit_row.*); RETURN NEW; - + ELSIF (TG_OP = 'DELETE' AND TG_LEVEL = 'ROW') THEN audit_row.row_data = hstore(OLD.*) - excluded_cols; INSERT INTO qgep_sys.logged_actions VALUES (audit_row.*); RETURN OLD; - + ELSIF (TG_OP = 'INSERT' AND TG_LEVEL = 'ROW') THEN audit_row.row_data = hstore(NEW.*) - excluded_cols; INSERT INTO qgep_sys.logged_actions VALUES (audit_row.*); @@ -199,13 +199,13 @@ DECLARE BEGIN EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_row ON ' || target_table::text; EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_stm ON ' || target_table::text; - + IF audit_rows THEN IF array_length(ignored_cols,1) > 0 THEN _ignored_cols_snip = ', ' || quote_literal(ignored_cols); END IF; - _q_txt = 'CREATE TRIGGER audit_trigger_row AFTER INSERT OR UPDATE OR DELETE ON ' || - target_table::text || + _q_txt = 'CREATE TRIGGER audit_trigger_row AFTER INSERT OR UPDATE OR DELETE ON ' || + target_table::text || ' FOR EACH ROW EXECUTE PROCEDURE qgep_sys.if_modified_func(' || quote_literal(audit_query_text) || _ignored_cols_snip || ');'; RAISE NOTICE '%',_q_txt; @@ -213,7 +213,7 @@ BEGIN stm_targets = 'TRUNCATE'; ELSE END IF; - + _q_txt = 'CREATE TRIGGER audit_trigger_stm AFTER ' || stm_targets || ' ON ' || target_table || ' FOR EACH STATEMENT EXECUTE PROCEDURE qgep_sys.if_modified_func('|| @@ -236,19 +236,19 @@ LANGUAGE plpgsql; COMMENT ON FUNCTION qgep_sys.audit_table(regclass, BOOLEAN, BOOLEAN, text[]) IS $body$ ADD auditing support TO a TABLE. - + Arguments: target_table: TABLE name, schema qualified IF NOT ON search_path audit_rows: Record each row CHANGE, OR only audit at a statement level audit_query_text: Record the text of the client query that triggered the audit event? ignored_cols: COLUMNS TO exclude FROM UPDATE diffs, IGNORE updates that CHANGE only ignored cols. $body$; - + -- Pg doesn't allow variadic calls with 0 params, so provide a wrapper CREATE OR REPLACE FUNCTION qgep_sys.audit_table(target_table regclass, audit_rows BOOLEAN, audit_query_text BOOLEAN) RETURNS void AS $body$ SELECT qgep_sys.audit_table($1, $2, $3, ARRAY[]::text[]); $body$ LANGUAGE SQL; - + -- And provide a convenience call wrapper for the simplest case -- of row-level logging with no excluded cols and query logging enabled. -- @@ -300,7 +300,7 @@ BEGIN from event, where_pks ; - + execute query; END; $body$ @@ -308,7 +308,7 @@ LANGUAGE plpgsql; COMMENT ON FUNCTION qgep_sys.replay_event(int) IS $body$ Replay a logged event. - + Arguments: pevent_id: The event_id of the event in qgep_sys.logged_actions to replay $body$; @@ -322,12 +322,12 @@ DECLARE BEGIN EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_row ON ' || target_view::text; EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_stm ON ' || target_view::text; - + IF array_length(ignored_cols,1) > 0 THEN _ignored_cols_snip = ', ' || quote_literal(ignored_cols); END IF; - _q_txt = 'CREATE TRIGGER audit_trigger_row INSTEAD OF INSERT OR UPDATE OR DELETE ON ' || - target_view::TEXT || + _q_txt = 'CREATE TRIGGER audit_trigger_row INSTEAD OF INSERT OR UPDATE OR DELETE ON ' || + target_view::TEXT || ' FOR EACH ROW EXECUTE PROCEDURE qgep_sys.if_modified_func(' || quote_literal(audit_query_text) || _ignored_cols_snip || ');'; RAISE NOTICE '%',_q_txt; @@ -337,7 +337,7 @@ BEGIN IF (select count(*) from qgep_sys.logged_relations where relation_name = (select target_view)::text AND uid_column= (select unnest(uid_cols))::text) = 0 THEN insert into qgep_sys.logged_relations (relation_name, uid_column) select target_view, unnest(uid_cols); - END IF; + END IF; END; $body$ @@ -345,7 +345,7 @@ LANGUAGE plpgsql; COMMENT ON FUNCTION qgep_sys.audit_view(regclass, BOOLEAN, text[], text[]) IS $body$ ADD auditing support TO a VIEW. - + Arguments: target_view: TABLE name, schema qualified IF NOT ON search_path audit_query_text: Record the text of the client query that triggered the audit event? @@ -353,9 +353,9 @@ Arguments: uid_cols: MANDATORY COLUMNS to use to uniquely identify a row from the view (in order to replay UPDATE and DELETE) Example: - SELECT qgep_sys.audit_view('qgep_od.vw_element_installation', 'true'::BOOLEAN, '{field_to_ignore}'::text[], '{key_field1, keyfield2}'::text[]) + SELECT qgep_sys.audit_view('qgep_od.vw_element_installation', 'true'::BOOLEAN, '{field_to_ignore}'::text[], '{key_field1, keyfield2}'::text[]) $body$; - + CREATE OR REPLACE FUNCTION qgep_sys.unaudit_view(target_view regclass) RETURNS void AS $body$ BEGIN EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_row ON ' || target_view::text; diff --git a/03_qgep_db_dss.sql b/03_qgep_db_dss.sql index be60ef218..ddeb6ffa6 100644 --- a/03_qgep_db_dss.sql +++ b/03_qgep_db_dss.sql @@ -3340,7 +3340,7 @@ ALTER TABLE qgep_vl.symbol_plantype ADD CONSTRAINT pkey_qgep_vl_symbol_plantype_ INSERT INTO qgep_vl.symbol_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7878,7878,'overviewmap.om5','Uebersichtsplan.UeP5','plan_d_ensemble.pe5', 'piano_di_insieme.pi5', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.symbol_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7875,7875,'network_plan','Werkplan','plan_de_reseau', 'zzz_Werkplan', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.txt_symbol ADD CONSTRAINT fkey_vl_symbol_plantype FOREIGN KEY (plantype) - REFERENCES qgep_vl.symbol_plantype (code) MATCH SIMPLE + REFERENCES qgep_vl.symbol_plantype (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.txt_symbol ADD COLUMN fk_wastewater_structure varchar (16); ALTER TABLE qgep_od.txt_symbol ADD CONSTRAINT rel_symbol_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -3352,7 +3352,7 @@ ALTER TABLE qgep_vl.text_plantype ADD CONSTRAINT pkey_qgep_vl_text_plantype_code INSERT INTO qgep_vl.text_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7848,7848,'overviewmap.om5','Uebersichtsplan.UeP5','plan_d_ensemble.pe5', 'piano_di_insieme.pi5', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.text_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7845,7845,'network_plan','Werkplan','plan_de_reseau', '', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.txt_text ADD CONSTRAINT fkey_vl_text_plantype FOREIGN KEY (plantype) - REFERENCES qgep_vl.text_plantype (code) MATCH SIMPLE + REFERENCES qgep_vl.text_plantype (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.text_texthali () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.text_texthali ADD CONSTRAINT pkey_qgep_vl_text_texthali_code PRIMARY KEY (code); @@ -3360,7 +3360,7 @@ ALTER TABLE qgep_vl.text_texthali ADD CONSTRAINT pkey_qgep_vl_text_texthali_code INSERT INTO qgep_vl.text_texthali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7851,7851,'1','1','1', '1', '1', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.text_texthali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7852,7852,'2','2','2', '2', '2', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.txt_text ADD CONSTRAINT fkey_vl_text_texthali FOREIGN KEY (texthali) - REFERENCES qgep_vl.text_texthali (code) MATCH SIMPLE + REFERENCES qgep_vl.text_texthali (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.text_textvali () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.text_textvali ADD CONSTRAINT pkey_qgep_vl_text_textvali_code PRIMARY KEY (code); @@ -3370,7 +3370,7 @@ ALTER TABLE qgep_vl.text_textvali ADD CONSTRAINT pkey_qgep_vl_text_textvali_code INSERT INTO qgep_vl.text_textvali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7856,7856,'3','3','3', '3', '3', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.text_textvali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7857,7857,'4','4','4', '4', '4', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.txt_text ADD CONSTRAINT fkey_vl_text_textvali FOREIGN KEY (textvali) - REFERENCES qgep_vl.text_textvali (code) MATCH SIMPLE + REFERENCES qgep_vl.text_textvali (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.txt_text ADD COLUMN fk_wastewater_structure varchar (16); ALTER TABLE qgep_od.txt_text ADD CONSTRAINT rel_text_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -3384,7 +3384,7 @@ ALTER TABLE qgep_vl.mutation_kind ADD CONSTRAINT pkey_qgep_vl_mutation_kind_code INSERT INTO qgep_vl.mutation_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5582,5582,'changed','geaendert','changee', 'zzz_geaendert', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.mutation_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5583,5583,'deleted','geloescht','effacee', 'zzz_geloescht', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.mutation ADD CONSTRAINT fkey_vl_mutation_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.mutation_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.mutation_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.river ADD CONSTRAINT oorel_od_river_surface_water_bodies FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_water_bodies(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.river_kind () INHERITS (qgep_sys.value_list_base); @@ -3395,7 +3395,7 @@ ALTER TABLE qgep_vl.river_kind ADD CONSTRAINT pkey_qgep_vl_river_kind_code PRIMA INSERT INTO qgep_vl.river_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3396,3396,'travertine_river','Travertinbach','ruisseau_sur_fond_tufcalcaire', 'zzz_Travertinbach', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3400,3400,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river ADD CONSTRAINT fkey_vl_river_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.river_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.river_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.lake ADD CONSTRAINT oorel_od_lake_surface_water_bodies FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_water_bodies(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.water_course_segment_algae_growth () INHERITS (qgep_sys.value_list_base); @@ -3405,7 +3405,7 @@ ALTER TABLE qgep_vl.water_course_segment_algae_growth ADD CONSTRAINT pkey_qgep_v INSERT INTO qgep_vl.water_course_segment_algae_growth (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2625,2625,'excessive_rampant','uebermaessig_wuchernd','tres_fort_proliferation', 'zzz_uebermaessig_wuchernd', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_algae_growth (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3050,3050,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_algae_growth FOREIGN KEY (algae_growth) - REFERENCES qgep_vl.water_course_segment_algae_growth (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_algae_growth (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_altitudinal_zone () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_altitudinal_zone ADD CONSTRAINT pkey_qgep_vl_water_course_segment_altitudinal_zone_code PRIMARY KEY (code); @@ -3415,7 +3415,7 @@ ALTER TABLE qgep_vl.water_course_segment_altitudinal_zone ADD CONSTRAINT pkey_qg INSERT INTO qgep_vl.water_course_segment_altitudinal_zone (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (319,319,'subalpine','subalpin','subalpin', 'zzz_subalpin', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_altitudinal_zone (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3020,3020,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_altitudinal_zone FOREIGN KEY (altitudinal_zone) - REFERENCES qgep_vl.water_course_segment_altitudinal_zone (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_altitudinal_zone (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_dead_wood () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_dead_wood ADD CONSTRAINT pkey_qgep_vl_water_course_segment_dead_wood_code PRIMARY KEY (code); @@ -3424,7 +3424,7 @@ ALTER TABLE qgep_vl.water_course_segment_dead_wood ADD CONSTRAINT pkey_qgep_vl_w INSERT INTO qgep_vl.water_course_segment_dead_wood (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3052,3052,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_dead_wood (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2630,2630,'scattered','zerstreut','dissemine', 'zzz_zerstreut', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_dead_wood FOREIGN KEY (dead_wood) - REFERENCES qgep_vl.water_course_segment_dead_wood (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_dead_wood (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_depth_variability () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_depth_variability ADD CONSTRAINT pkey_qgep_vl_water_course_segment_depth_variability_code PRIMARY KEY (code); @@ -3433,7 +3433,7 @@ ALTER TABLE qgep_vl.water_course_segment_depth_variability ADD CONSTRAINT pkey_q INSERT INTO qgep_vl.water_course_segment_depth_variability (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2618,2618,'moderate','maessig','moyenne', 'zzz_maessig', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_depth_variability (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3049,3049,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_depth_variability FOREIGN KEY (depth_variability) - REFERENCES qgep_vl.water_course_segment_depth_variability (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_depth_variability (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_discharge_regime () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_discharge_regime ADD CONSTRAINT pkey_qgep_vl_water_course_segment_discharge_regime_code PRIMARY KEY (code); @@ -3443,7 +3443,7 @@ ALTER TABLE qgep_vl.water_course_segment_discharge_regime ADD CONSTRAINT pkey_qg INSERT INTO qgep_vl.water_course_segment_discharge_regime (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (296,296,'close_to_natural','naturnah','presque_naturel', 'zzz_naturnah', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_discharge_regime (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3091,3091,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_discharge_regime FOREIGN KEY (discharge_regime) - REFERENCES qgep_vl.water_course_segment_discharge_regime (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_discharge_regime (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_ecom_classification () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_ecom_classification ADD CONSTRAINT pkey_qgep_vl_water_course_segment_ecom_classification_code PRIMARY KEY (code); @@ -3454,7 +3454,7 @@ ALTER TABLE qgep_vl.water_course_segment_ecom_classification ADD CONSTRAINT pkey INSERT INTO qgep_vl.water_course_segment_ecom_classification (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3494,3494,'heavily_compromised','stark_beeintraechtigt','fortement_modifie', 'zzz_stark_beeintraechtigt', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_ecom_classification (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3493,3493,'partially_compromised','wenig_beeintraechtigt','peu_modifie', 'zzz_wenig_beeintraechtigt', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_ecom_classification FOREIGN KEY (ecom_classification) - REFERENCES qgep_vl.water_course_segment_ecom_classification (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_ecom_classification (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_kind ADD CONSTRAINT pkey_qgep_vl_water_course_segment_kind_code PRIMARY KEY (code); @@ -3462,7 +3462,7 @@ ALTER TABLE qgep_vl.water_course_segment_kind ADD CONSTRAINT pkey_qgep_vl_water_ INSERT INTO qgep_vl.water_course_segment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2709,2709,'open','offen','ouvert', 'zzz_offen', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3058,3058,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.water_course_segment_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_length_profile () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_length_profile ADD CONSTRAINT pkey_qgep_vl_water_course_segment_length_profile_code PRIMARY KEY (code); @@ -3471,7 +3471,7 @@ ALTER TABLE qgep_vl.water_course_segment_length_profile ADD CONSTRAINT pkey_qgep INSERT INTO qgep_vl.water_course_segment_length_profile (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (99,99,'continuous','stetig','continu', 'zzz_stetig', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_length_profile (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3035,3035,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_length_profile FOREIGN KEY (length_profile) - REFERENCES qgep_vl.water_course_segment_length_profile (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_length_profile (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_macrophyte_coverage () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_macrophyte_coverage ADD CONSTRAINT pkey_qgep_vl_water_course_segment_macrophyte_coverage_code PRIMARY KEY (code); @@ -3480,7 +3480,7 @@ ALTER TABLE qgep_vl.water_course_segment_macrophyte_coverage ADD CONSTRAINT pkey INSERT INTO qgep_vl.water_course_segment_macrophyte_coverage (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2628,2628,'excessive_rampant','uebermaessig_wuchernd','tres_fort_proliferation', 'zzz_uebermaessig_wuchernd', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_macrophyte_coverage (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3051,3051,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_macrophyte_coverage FOREIGN KEY (macrophyte_coverage) - REFERENCES qgep_vl.water_course_segment_macrophyte_coverage (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_macrophyte_coverage (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_section_morphology () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_section_morphology ADD CONSTRAINT pkey_qgep_vl_water_course_segment_section_morphology_code PRIMARY KEY (code); @@ -3490,7 +3490,7 @@ ALTER TABLE qgep_vl.water_course_segment_section_morphology ADD CONSTRAINT pkey_ INSERT INTO qgep_vl.water_course_segment_section_morphology (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4578,4578,'heavily_bent','starkbogig','fortement_incurve', 'zzz_starkbogig', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_section_morphology (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4576,4576,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_section_morphology FOREIGN KEY (section_morphology) - REFERENCES qgep_vl.water_course_segment_section_morphology (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_section_morphology (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_slope () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_slope ADD CONSTRAINT pkey_qgep_vl_water_course_segment_slope_code PRIMARY KEY (code); @@ -3499,7 +3499,7 @@ ALTER TABLE qgep_vl.water_course_segment_slope ADD CONSTRAINT pkey_qgep_vl_water INSERT INTO qgep_vl.water_course_segment_slope (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (293,293,'steep','steil','raide', 'ripido', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_slope (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3019,3019,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_slope FOREIGN KEY (slope) - REFERENCES qgep_vl.water_course_segment_slope (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_slope (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_utilisation () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_utilisation ADD CONSTRAINT pkey_qgep_vl_water_course_segment_utilisation_code PRIMARY KEY (code); @@ -3508,7 +3508,7 @@ ALTER TABLE qgep_vl.water_course_segment_utilisation ADD CONSTRAINT pkey_qgep_vl INSERT INTO qgep_vl.water_course_segment_utilisation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (385,385,'dam','Stauanlage','installation_de_retenue', 'zzz_Stauanlage', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_utilisation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3039,3039,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_utilisation FOREIGN KEY (utilisation) - REFERENCES qgep_vl.water_course_segment_utilisation (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_utilisation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_water_hardness () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_water_hardness ADD CONSTRAINT pkey_qgep_vl_water_course_segment_water_hardness_code PRIMARY KEY (code); @@ -3516,7 +3516,7 @@ ALTER TABLE qgep_vl.water_course_segment_water_hardness ADD CONSTRAINT pkey_qgep INSERT INTO qgep_vl.water_course_segment_water_hardness (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (322,322,'silicate','Silikat','silicieuse', 'zzz_Silikat', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_water_hardness (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3024,3024,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_water_hardness FOREIGN KEY (water_hardness) - REFERENCES qgep_vl.water_course_segment_water_hardness (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_water_hardness (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.water_course_segment_width_variability () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_width_variability ADD CONSTRAINT pkey_qgep_vl_water_course_segment_width_variability_code PRIMARY KEY (code); @@ -3525,7 +3525,7 @@ ALTER TABLE qgep_vl.water_course_segment_width_variability ADD CONSTRAINT pkey_q INSERT INTO qgep_vl.water_course_segment_width_variability (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (178,178,'none','keine','nulle', 'nessuno', 'inexistent', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_course_segment_width_variability (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3078,3078,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT fkey_vl_water_course_segment_width_variability FOREIGN KEY (width_variability) - REFERENCES qgep_vl.water_course_segment_width_variability (code) MATCH SIMPLE + REFERENCES qgep_vl.water_course_segment_width_variability (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.water_course_segment ADD COLUMN fk_watercourse varchar (16); ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT rel_water_course_segment_watercourse FOREIGN KEY (fk_watercourse) REFERENCES qgep_od.river(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -3535,7 +3535,7 @@ ALTER TABLE qgep_vl.water_catchment_kind ADD CONSTRAINT pkey_qgep_vl_water_catch INSERT INTO qgep_vl.water_catchment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (25,25,'drinking_water','Trinkwasser','eau_potable', 'zzz_Trinkwasser', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_catchment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3075,3075,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_catchment ADD CONSTRAINT fkey_vl_water_catchment_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.water_catchment_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.water_catchment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.water_catchment ADD COLUMN fk_aquifier varchar (16); ALTER TABLE qgep_od.water_catchment ADD CONSTRAINT rel_water_catchment_aquifier FOREIGN KEY (fk_aquifier) REFERENCES qgep_od.aquifier(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -3551,7 +3551,7 @@ ALTER TABLE qgep_vl.river_bank_control_grade_of_river ADD CONSTRAINT pkey_qgep_v INSERT INTO qgep_vl.river_bank_control_grade_of_river (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2611,2611,'sporadic','vereinzelt','localise', 'zzz_vereinzelt', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_bank_control_grade_of_river (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2615,2615,'complete','vollstaendig','total', 'zzz_vollstaendig', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river_bank ADD CONSTRAINT fkey_vl_river_bank_control_grade_of_river FOREIGN KEY (control_grade_of_river) - REFERENCES qgep_vl.river_bank_control_grade_of_river (code) MATCH SIMPLE + REFERENCES qgep_vl.river_bank_control_grade_of_river (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.river_bank_river_control_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_bank_river_control_type ADD CONSTRAINT pkey_qgep_vl_river_bank_river_control_type_code PRIMARY KEY (code); @@ -3565,7 +3565,7 @@ ALTER TABLE qgep_vl.river_bank_river_control_type ADD CONSTRAINT pkey_qgep_vl_ri INSERT INTO qgep_vl.river_bank_river_control_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3484,3484,'loose_natural_stone_permeable','Naturstein_locker_durchlaessig','pierre_naturelle_lache', 'zzz_Naturstein_locker_durchlaessig', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_bank_river_control_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3080,3080,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river_bank ADD CONSTRAINT fkey_vl_river_bank_river_control_type FOREIGN KEY (river_control_type) - REFERENCES qgep_vl.river_bank_river_control_type (code) MATCH SIMPLE + REFERENCES qgep_vl.river_bank_river_control_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.river_bank_shores () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_bank_shores ADD CONSTRAINT pkey_qgep_vl_river_bank_shores_code PRIMARY KEY (code); @@ -3574,7 +3574,7 @@ ALTER TABLE qgep_vl.river_bank_shores ADD CONSTRAINT pkey_qgep_vl_river_bank_sho INSERT INTO qgep_vl.river_bank_shores (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (405,405,'artificial','kuenstlich','artificielle', 'zzz_kuenstlich', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_bank_shores (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3081,3081,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river_bank ADD CONSTRAINT fkey_vl_river_bank_shores FOREIGN KEY (shores) - REFERENCES qgep_vl.river_bank_shores (code) MATCH SIMPLE + REFERENCES qgep_vl.river_bank_shores (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.river_bank_side () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_bank_side ADD CONSTRAINT pkey_qgep_vl_river_bank_side_code PRIMARY KEY (code); @@ -3582,7 +3582,7 @@ ALTER TABLE qgep_vl.river_bank_side ADD CONSTRAINT pkey_qgep_vl_river_bank_side_ INSERT INTO qgep_vl.river_bank_side (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (421,421,'right','rechts','droite', 'zzz_rechts', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_bank_side (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3065,3065,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river_bank ADD CONSTRAINT fkey_vl_river_bank_side FOREIGN KEY (side) - REFERENCES qgep_vl.river_bank_side (code) MATCH SIMPLE + REFERENCES qgep_vl.river_bank_side (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.river_bank_utilisation_of_shore_surroundings () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_bank_utilisation_of_shore_surroundings ADD CONSTRAINT pkey_qgep_vl_river_bank_utilisation_of_shore_surroundings_code PRIMARY KEY (code); @@ -3591,7 +3591,7 @@ ALTER TABLE qgep_vl.river_bank_utilisation_of_shore_surroundings ADD CONSTRAINT INSERT INTO qgep_vl.river_bank_utilisation_of_shore_surroundings (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3068,3068,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_bank_utilisation_of_shore_surroundings (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (426,426,'forest','Wald','foret', 'zzz_Wald', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river_bank ADD CONSTRAINT fkey_vl_river_bank_utilisation_of_shore_surroundings FOREIGN KEY (utilisation_of_shore_surroundings) - REFERENCES qgep_vl.river_bank_utilisation_of_shore_surroundings (code) MATCH SIMPLE + REFERENCES qgep_vl.river_bank_utilisation_of_shore_surroundings (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.river_bank_vegetation () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_bank_vegetation ADD CONSTRAINT pkey_qgep_vl_river_bank_vegetation_code PRIMARY KEY (code); @@ -3600,7 +3600,7 @@ ALTER TABLE qgep_vl.river_bank_vegetation ADD CONSTRAINT pkey_qgep_vl_river_bank INSERT INTO qgep_vl.river_bank_vegetation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (324,324,'atypical_for_habitat','standortuntypisch','non_typique_du_lieu', 'zzz_standortuntypisch', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_bank_vegetation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3025,3025,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river_bank ADD CONSTRAINT fkey_vl_river_bank_vegetation FOREIGN KEY (vegetation) - REFERENCES qgep_vl.river_bank_vegetation (code) MATCH SIMPLE + REFERENCES qgep_vl.river_bank_vegetation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.river_bank ADD COLUMN fk_water_course_segment varchar (16); ALTER TABLE qgep_od.river_bank ADD CONSTRAINT rel_river_bank_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -3614,7 +3614,7 @@ ALTER TABLE qgep_vl.river_bed_control_grade_of_river ADD CONSTRAINT pkey_qgep_vl INSERT INTO qgep_vl.river_bed_control_grade_of_river (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2606,2606,'sporadic','vereinzelt','localise', 'zzz_vereinzelt', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_bed_control_grade_of_river (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2610,2610,'complete','vollstaendig','total', 'zzz_vollstaendig', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river_bed ADD CONSTRAINT fkey_vl_river_bed_control_grade_of_river FOREIGN KEY (control_grade_of_river) - REFERENCES qgep_vl.river_bed_control_grade_of_river (code) MATCH SIMPLE + REFERENCES qgep_vl.river_bed_control_grade_of_river (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.river_bed_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_bed_kind ADD CONSTRAINT pkey_qgep_vl_river_bed_kind_code PRIMARY KEY (code); @@ -3622,7 +3622,7 @@ ALTER TABLE qgep_vl.river_bed_kind ADD CONSTRAINT pkey_qgep_vl_river_bed_kind_co INSERT INTO qgep_vl.river_bed_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3089,3089,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_bed_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (289,289,'soft','weich','tendre', 'zzz_weich', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river_bed ADD CONSTRAINT fkey_vl_river_bed_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.river_bed_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.river_bed_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.river_bed_river_control_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_bed_river_control_type ADD CONSTRAINT pkey_qgep_vl_river_bed_river_control_type_code PRIMARY KEY (code); @@ -3633,7 +3633,7 @@ ALTER TABLE qgep_vl.river_bed_river_control_type ADD CONSTRAINT pkey_qgep_vl_riv INSERT INTO qgep_vl.river_bed_river_control_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3478,3478,'rock_fill_or_loose_boulders','Steinschuettung_Blockwurf','pierres_naturelles', 'zzz_Steinschuettung_Blockwurf', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.river_bed_river_control_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3079,3079,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.river_bed ADD CONSTRAINT fkey_vl_river_bed_river_control_type FOREIGN KEY (river_control_type) - REFERENCES qgep_vl.river_bed_river_control_type (code) MATCH SIMPLE + REFERENCES qgep_vl.river_bed_river_control_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.river_bed ADD COLUMN fk_water_course_segment varchar (16); ALTER TABLE qgep_od.river_bed ADD CONSTRAINT rel_river_bed_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -3645,7 +3645,7 @@ ALTER TABLE qgep_vl.sector_water_body_kind ADD CONSTRAINT pkey_qgep_vl_sector_wa INSERT INTO qgep_vl.sector_water_body_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2656,2656,'shore','Ufer','rives', 'zzz_Ufer', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.sector_water_body_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3054,3054,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.sector_water_body ADD CONSTRAINT fkey_vl_sector_water_body_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.sector_water_body_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.sector_water_body_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.sector_water_body ADD COLUMN fk_surface_water_bodies varchar (16); ALTER TABLE qgep_od.sector_water_body ADD CONSTRAINT rel_sector_water_body_surface_water_bodies FOREIGN KEY (fk_surface_water_bodies) REFERENCES qgep_od.surface_water_bodies(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -3663,7 +3663,7 @@ ALTER TABLE qgep_vl.wastewater_structure_accessibility ADD CONSTRAINT pkey_qgep_ INSERT INTO qgep_vl.wastewater_structure_accessibility (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3446,3446,'inaccessible','unzugaenglich','inaccessible', 'non_accessibile', 'inaccesibil', '', 'UZG', 'NA', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_accessibility (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3445,3445,'accessible','zugaenglich','accessible', 'accessibile', 'accessibil', '', 'ZG', 'A', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT fkey_vl_wastewater_structure_accessibility FOREIGN KEY (accessibility) - REFERENCES qgep_vl.wastewater_structure_accessibility (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_accessibility (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.wastewater_structure_financing () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wastewater_structure_financing ADD CONSTRAINT pkey_qgep_vl_wastewater_structure_financing_code PRIMARY KEY (code); @@ -3671,7 +3671,7 @@ ALTER TABLE qgep_vl.wastewater_structure_financing ADD CONSTRAINT pkey_qgep_vl_w INSERT INTO qgep_vl.wastewater_structure_financing (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5511,5511,'private','privat','prive', 'privato', 'privata', 'PR', 'PR', 'PR', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_financing (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5512,5512,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscuta', 'U', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT fkey_vl_wastewater_structure_financing FOREIGN KEY (financing) - REFERENCES qgep_vl.wastewater_structure_financing (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_financing (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.wastewater_structure_renovation_necessity () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wastewater_structure_renovation_necessity ADD CONSTRAINT pkey_qgep_vl_wastewater_structure_renovation_necessity_code PRIMARY KEY (code); @@ -3682,7 +3682,7 @@ ALTER TABLE qgep_vl.wastewater_structure_renovation_necessity ADD CONSTRAINT pke INSERT INTO qgep_vl.wastewater_structure_renovation_necessity (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3,3,'medium_term','mittelfristig','a_moyen_terme', 'medio_termine', 'termen_mediu', '', 'MF', 'MT', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_renovation_necessity (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5369,5369,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT fkey_vl_wastewater_structure_renovation_necessity FOREIGN KEY (renovation_necessity) - REFERENCES qgep_vl.wastewater_structure_renovation_necessity (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_renovation_necessity (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.wastewater_structure_rv_construction_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wastewater_structure_rv_construction_type ADD CONSTRAINT pkey_qgep_vl_wastewater_structure_rv_construction_type_code PRIMARY KEY (code); @@ -3693,7 +3693,7 @@ ALTER TABLE qgep_vl.wastewater_structure_rv_construction_type ADD CONSTRAINT pke INSERT INTO qgep_vl.wastewater_structure_rv_construction_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4604,4604,'road','Strasse','sous_route', 'strada', 'sub_strada', 'ST', 'ST', 'ST', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_rv_construction_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4601,4601,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT fkey_vl_wastewater_structure_rv_construction_type FOREIGN KEY (rv_construction_type) - REFERENCES qgep_vl.wastewater_structure_rv_construction_type (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_rv_construction_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.wastewater_structure_status () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wastewater_structure_status ADD CONSTRAINT pkey_qgep_vl_wastewater_structure_status_code PRIMARY KEY (code); @@ -3709,7 +3709,7 @@ ALTER TABLE qgep_vl.wastewater_structure_status ADD CONSTRAINT pkey_qgep_vl_wast INSERT INTO qgep_vl.wastewater_structure_status (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7959,7959,'other.planned','weitere.geplant','autre.planifie', 'altri.previsto', 'rrr_weitere.geplant', '', 'G', 'PL', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_status (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6529,6529,'other.project','weitere.Projekt','autre.projet', 'altri.progetto', 'alta.proiect', '', 'N', 'PR', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT fkey_vl_wastewater_structure_status FOREIGN KEY (status) - REFERENCES qgep_vl.wastewater_structure_status (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_status (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.wastewater_structure_structure_condition () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wastewater_structure_structure_condition ADD CONSTRAINT pkey_qgep_vl_wastewater_structure_structure_condition_code PRIMARY KEY (code); @@ -3720,7 +3720,7 @@ ALTER TABLE qgep_vl.wastewater_structure_structure_condition ADD CONSTRAINT pkey INSERT INTO qgep_vl.wastewater_structure_structure_condition (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3361,3361,'Z3','Z3','Z3', 'Z3', 'Z3', '', 'Z3', 'Z3', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_structure_condition (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3362,3362,'Z4','Z4','Z4', 'Z4', '', '', 'Z4', 'Z4', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT fkey_vl_wastewater_structure_structure_condition FOREIGN KEY (structure_condition) - REFERENCES qgep_vl.wastewater_structure_structure_condition (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_structure_condition (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.wastewater_structure ADD COLUMN fk_owner varchar (16); ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT rel_wastewater_structure_owner FOREIGN KEY (fk_owner) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -3744,7 +3744,7 @@ ALTER TABLE qgep_vl.channel_bedding_encasement ADD CONSTRAINT pkey_qgep_vl_chann INSERT INTO qgep_vl.channel_bedding_encasement (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5327,5327,'bed_plank','Sohlbrett','radier_en_planches', 'zzz_Sohlbrett', 'pat_de_pamant', '', 'SB', 'RP', '', '', 'true'); INSERT INTO qgep_vl.channel_bedding_encasement (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5329,5329,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.channel ADD CONSTRAINT fkey_vl_channel_bedding_encasement FOREIGN KEY (bedding_encasement) - REFERENCES qgep_vl.channel_bedding_encasement (code) MATCH SIMPLE + REFERENCES qgep_vl.channel_bedding_encasement (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.channel_connection_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.channel_connection_type ADD CONSTRAINT pkey_qgep_vl_channel_connection_type_code PRIMARY KEY (code); @@ -3762,7 +3762,7 @@ ALTER TABLE qgep_vl.channel_connection_type ADD CONSTRAINT pkey_qgep_vl_channel_ INSERT INTO qgep_vl.channel_connection_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3036,3036,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.channel_connection_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3666,3666,'jacking_pipe_coupling','Vortriebsrohrkupplung','raccord_pour_tube_de_pousse_tube', 'zzz_Vortriebsrohrkupplung', 'racord_prin_presstube', '', 'VK', 'RTD', '', '', 'true'); ALTER TABLE qgep_od.channel ADD CONSTRAINT fkey_vl_channel_connection_type FOREIGN KEY (connection_type) - REFERENCES qgep_vl.channel_connection_type (code) MATCH SIMPLE + REFERENCES qgep_vl.channel_connection_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.channel_function_hierarchic () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.channel_function_hierarchic ADD CONSTRAINT pkey_qgep_vl_channel_function_hierarchic_code PRIMARY KEY (code); @@ -3781,7 +3781,7 @@ ALTER TABLE qgep_vl.channel_function_hierarchic ADD CONSTRAINT pkey_qgep_vl_chan INSERT INTO qgep_vl.channel_function_hierarchic (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5073,5073,'swwf.road_drainage','SAA.Strassenentwaesserung','OAS.evacuation_des_eaux_de_routes', 'ISS.smaltimento_acque_strade', 'swwf.evacuare_ape_rigole', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.channel_function_hierarchic (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5075,5075,'swwf.unknown','SAA.unbekannt','OAS.inconnue', 'ISS.sconosciuto', 'swwf.necunoscuta', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.channel ADD CONSTRAINT fkey_vl_channel_function_hierarchic FOREIGN KEY (function_hierarchic) - REFERENCES qgep_vl.channel_function_hierarchic (code) MATCH SIMPLE + REFERENCES qgep_vl.channel_function_hierarchic (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.channel_function_hydraulic () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.channel_function_hydraulic ADD CONSTRAINT pkey_qgep_vl_channel_function_hydraulic_code PRIMARY KEY (code); @@ -3797,7 +3797,7 @@ ALTER TABLE qgep_vl.channel_function_hydraulic ADD CONSTRAINT pkey_qgep_vl_chann INSERT INTO qgep_vl.channel_function_hydraulic (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5321,5321,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.channel_function_hydraulic (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3655,3655,'vacuum_pipe','Vakuumleitung','conduite_sous_vide', 'canalizzazione_sotto_vuoto', 'conducta_vidata', '', 'VL', 'CV', '', '', 'true'); ALTER TABLE qgep_od.channel ADD CONSTRAINT fkey_vl_channel_function_hydraulic FOREIGN KEY (function_hydraulic) - REFERENCES qgep_vl.channel_function_hydraulic (code) MATCH SIMPLE + REFERENCES qgep_vl.channel_function_hydraulic (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.channel_usage_current () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.channel_usage_current ADD CONSTRAINT pkey_qgep_vl_channel_usage_current_code PRIMARY KEY (code); @@ -3811,7 +3811,7 @@ ALTER TABLE qgep_vl.channel_usage_current ADD CONSTRAINT pkey_qgep_vl_channel_us INSERT INTO qgep_vl.channel_usage_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4526,4526,'wastewater','Schmutzabwasser','eaux_usees', 'acque_luride', 'ape_uzate', '', 'SW', 'EU', '', '', 'true'); INSERT INTO qgep_vl.channel_usage_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4571,4571,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.channel ADD CONSTRAINT fkey_vl_channel_usage_current FOREIGN KEY (usage_current) - REFERENCES qgep_vl.channel_usage_current (code) MATCH SIMPLE + REFERENCES qgep_vl.channel_usage_current (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.channel_usage_planned () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.channel_usage_planned ADD CONSTRAINT pkey_qgep_vl_channel_usage_planned_code PRIMARY KEY (code); @@ -3825,7 +3825,7 @@ ALTER TABLE qgep_vl.channel_usage_planned ADD CONSTRAINT pkey_qgep_vl_channel_us INSERT INTO qgep_vl.channel_usage_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4527,4527,'wastewater','Schmutzabwasser','eaux_usees', 'acque_luride', 'ape_uzate', '', 'SW', 'EU', '', '', 'true'); INSERT INTO qgep_vl.channel_usage_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4569,4569,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.channel ADD CONSTRAINT fkey_vl_channel_usage_planned FOREIGN KEY (usage_planned) - REFERENCES qgep_vl.channel_usage_planned (code) MATCH SIMPLE + REFERENCES qgep_vl.channel_usage_planned (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.manhole ADD CONSTRAINT oorel_od_manhole_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.manhole_function () INHERITS (qgep_sys.value_list_base); @@ -3847,7 +3847,7 @@ ALTER TABLE qgep_vl.manhole_function ADD CONSTRAINT pkey_qgep_vl_manhole_functio INSERT INTO qgep_vl.manhole_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4798,4798,'separating_structure','Trennbauwerk','ouvrage_de_repartition', 'camera_ripartizione', 'separator', '', 'TB', 'OR', '', '', 'true'); INSERT INTO qgep_vl.manhole_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5345,5345,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.manhole ADD CONSTRAINT fkey_vl_manhole_function FOREIGN KEY (function) - REFERENCES qgep_vl.manhole_function (code) MATCH SIMPLE + REFERENCES qgep_vl.manhole_function (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.manhole_material () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.manhole_material ADD CONSTRAINT pkey_qgep_vl_manhole_material_code PRIMARY KEY (code); @@ -3856,7 +3856,7 @@ ALTER TABLE qgep_vl.manhole_material ADD CONSTRAINT pkey_qgep_vl_manhole_materia INSERT INTO qgep_vl.manhole_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4542,4542,'plastic','Kunststoff','matiere_plastique', 'zzz_Kunststoff', 'materie_plastica', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.manhole_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4543,4543,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.manhole ADD CONSTRAINT fkey_vl_manhole_material FOREIGN KEY (material) - REFERENCES qgep_vl.manhole_material (code) MATCH SIMPLE + REFERENCES qgep_vl.manhole_material (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.manhole_surface_inflow () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.manhole_surface_inflow ADD CONSTRAINT pkey_qgep_vl_manhole_surface_inflow_code PRIMARY KEY (code); @@ -3866,7 +3866,7 @@ ALTER TABLE qgep_vl.manhole_surface_inflow ADD CONSTRAINT pkey_qgep_vl_manhole_s INSERT INTO qgep_vl.manhole_surface_inflow (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5343,5343,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.manhole_surface_inflow (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2740,2740,'intake_from_side','Zulauf_seitlich','arrivee_laterale', 'zzz_Zulauf_seitlich', 'admisie_laterala', '', 'ZS', 'AL', '', '', 'true'); ALTER TABLE qgep_od.manhole ADD CONSTRAINT fkey_vl_manhole_surface_inflow FOREIGN KEY (surface_inflow) - REFERENCES qgep_vl.manhole_surface_inflow (code) MATCH SIMPLE + REFERENCES qgep_vl.manhole_surface_inflow (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.discharge_point ADD CONSTRAINT oorel_od_discharge_point_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.discharge_point_relevance () INHERITS (qgep_sys.value_list_base); @@ -3874,7 +3874,7 @@ ALTER TABLE qgep_vl.discharge_point_relevance ADD CONSTRAINT pkey_qgep_vl_discha INSERT INTO qgep_vl.discharge_point_relevance (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5580,5580,'relevant_for_water_course','gewaesserrelevant','pertinent_pour_milieu_recepteur', 'zzz_gewaesserrelevant', 'relevanta_pentru_mediul_receptor', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.discharge_point_relevance (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5581,5581,'non_relevant_for_water_course','nicht_gewaesserrelevant','insignifiant_pour_milieu_recepteur', 'zzz_nicht_gewaesserrelevant', 'nerelevanta_pentru_mediul_receptor', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.discharge_point ADD CONSTRAINT fkey_vl_discharge_point_relevance FOREIGN KEY (relevance) - REFERENCES qgep_vl.discharge_point_relevance (code) MATCH SIMPLE + REFERENCES qgep_vl.discharge_point_relevance (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.discharge_point ADD COLUMN fk_sector_water_body varchar (16); ALTER TABLE qgep_od.discharge_point ADD CONSTRAINT rel_discharge_point_sector_water_body FOREIGN KEY (fk_sector_water_body) REFERENCES qgep_od.sector_water_body(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -3885,7 +3885,7 @@ ALTER TABLE qgep_vl.special_structure_bypass ADD CONSTRAINT pkey_qgep_vl_special INSERT INTO qgep_vl.special_structure_bypass (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3055,3055,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.special_structure_bypass (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2681,2681,'existent','vorhanden','existant', 'zzz_vorhanden', 'existent', '', 'V', 'E', '', '', 'true'); ALTER TABLE qgep_od.special_structure ADD CONSTRAINT fkey_vl_special_structure_bypass FOREIGN KEY (bypass) - REFERENCES qgep_vl.special_structure_bypass (code) MATCH SIMPLE + REFERENCES qgep_vl.special_structure_bypass (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.special_structure_emergency_spillway () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.special_structure_emergency_spillway ADD CONSTRAINT pkey_qgep_vl_special_structure_emergency_spillway_code PRIMARY KEY (code); @@ -3896,7 +3896,7 @@ ALTER TABLE qgep_vl.special_structure_emergency_spillway ADD CONSTRAINT pkey_qge INSERT INTO qgep_vl.special_structure_emergency_spillway (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5878,5878,'none','keiner','aucun', 'nessuno', 'niciunul', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.special_structure_emergency_spillway (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5867,5867,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.special_structure ADD CONSTRAINT fkey_vl_special_structure_emergency_spillway FOREIGN KEY (emergency_spillway) - REFERENCES qgep_vl.special_structure_emergency_spillway (code) MATCH SIMPLE + REFERENCES qgep_vl.special_structure_emergency_spillway (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.special_structure_function () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.special_structure_function ADD CONSTRAINT pkey_qgep_vl_special_structure_function_code PRIMARY KEY (code); @@ -3931,7 +3931,7 @@ ALTER TABLE qgep_vl.special_structure_function ADD CONSTRAINT pkey_qgep_vl_speci INSERT INTO qgep_vl.special_structure_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3008,3008,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.special_structure_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2745,2745,'vortex_manhole','Wirbelfallschacht','chambre_de_chute_a_vortex', 'zzz_Wirbelfallschacht', 'instalatie_picurare_cu_vortex', '', 'WF', 'CT', '', '', 'true'); ALTER TABLE qgep_od.special_structure ADD CONSTRAINT fkey_vl_special_structure_function FOREIGN KEY (function) - REFERENCES qgep_vl.special_structure_function (code) MATCH SIMPLE + REFERENCES qgep_vl.special_structure_function (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.special_structure_stormwater_tank_arrangement () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.special_structure_stormwater_tank_arrangement ADD CONSTRAINT pkey_qgep_vl_special_structure_stormwater_tank_arrangement_code PRIMARY KEY (code); @@ -3939,7 +3939,7 @@ ALTER TABLE qgep_vl.special_structure_stormwater_tank_arrangement ADD CONSTRAINT INSERT INTO qgep_vl.special_structure_stormwater_tank_arrangement (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4609,4609,'side_connection','Nebenschluss','connexion_laterale', 'in_parallelo', 'conectare_laterala', '', 'NS', 'CL', '', '', 'true'); INSERT INTO qgep_vl.special_structure_stormwater_tank_arrangement (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4610,4610,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.special_structure ADD CONSTRAINT fkey_vl_special_structure_stormwater_tank_arrangement FOREIGN KEY (stormwater_tank_arrangement) - REFERENCES qgep_vl.special_structure_stormwater_tank_arrangement (code) MATCH SIMPLE + REFERENCES qgep_vl.special_structure_stormwater_tank_arrangement (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT oorel_od_infiltration_installation_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.infiltration_installation_defects () INHERITS (qgep_sys.value_list_base); @@ -3948,7 +3948,7 @@ ALTER TABLE qgep_vl.infiltration_installation_defects ADD CONSTRAINT pkey_qgep_v INSERT INTO qgep_vl.infiltration_installation_defects (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3276,3276,'marginal','unwesentliche','modestes', 'zzz_unwesentliche', 'modeste', '', 'UW', 'MI', '', '', 'true'); INSERT INTO qgep_vl.infiltration_installation_defects (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3275,3275,'substantial','wesentliche','importantes', 'zzz_wesentliche', 'importante', '', 'W', 'MA', '', '', 'true'); ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT fkey_vl_infiltration_installation_defects FOREIGN KEY (defects) - REFERENCES qgep_vl.infiltration_installation_defects (code) MATCH SIMPLE + REFERENCES qgep_vl.infiltration_installation_defects (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.infiltration_installation_emergency_spillway () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.infiltration_installation_emergency_spillway ADD CONSTRAINT pkey_qgep_vl_infiltration_installation_emergency_spillway_code PRIMARY KEY (code); @@ -3959,7 +3959,7 @@ ALTER TABLE qgep_vl.infiltration_installation_emergency_spillway ADD CONSTRAINT INSERT INTO qgep_vl.infiltration_installation_emergency_spillway (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3305,3305,'surface_discharge','oberflaechlichausmuendend','deversement_en_surface', 'zzz_oberflaechlichausmuendend', 'deversare_la_suprafata', '', 'OA', 'DS', '', '', 'true'); INSERT INTO qgep_vl.infiltration_installation_emergency_spillway (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3308,3308,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT fkey_vl_infiltration_installation_emergency_spillway FOREIGN KEY (emergency_spillway) - REFERENCES qgep_vl.infiltration_installation_emergency_spillway (code) MATCH SIMPLE + REFERENCES qgep_vl.infiltration_installation_emergency_spillway (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.infiltration_installation_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.infiltration_installation_kind ADD CONSTRAINT pkey_qgep_vl_infiltration_installation_kind_code PRIMARY KEY (code); @@ -3975,7 +3975,7 @@ ALTER TABLE qgep_vl.infiltration_installation_kind ADD CONSTRAINT pkey_qgep_vl_i INSERT INTO qgep_vl.infiltration_installation_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (278,278,'adsorbing_well','Versickerungsschacht','puits_d_infiltration', 'zzz_Versickerungsschacht', 'put_de_inflitrare', '', 'VS', 'PI', '', '', 'true'); INSERT INTO qgep_vl.infiltration_installation_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3283,3283,'infiltration_pipe_sections_gallery','Versickerungsstrang_Galerie','bande_infiltration_galerie', 'zzz_Versickerungsstrang_Galerie', 'conducta_infiltrare_galerie', '', 'VG', 'TIG', '', '', 'true'); ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT fkey_vl_infiltration_installation_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.infiltration_installation_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.infiltration_installation_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.infiltration_installation_labeling () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.infiltration_installation_labeling ADD CONSTRAINT pkey_qgep_vl_infiltration_installation_labeling_code PRIMARY KEY (code); @@ -3983,7 +3983,7 @@ ALTER TABLE qgep_vl.infiltration_installation_labeling ADD CONSTRAINT pkey_qgep_ INSERT INTO qgep_vl.infiltration_installation_labeling (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5363,5363,'not_labeled','nichtbeschriftet','non_signalee', 'zzz_nichtbeschriftet', 'nemarcat', '', 'NBS', 'NSI', '', '', 'true'); INSERT INTO qgep_vl.infiltration_installation_labeling (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5364,5364,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT fkey_vl_infiltration_installation_labeling FOREIGN KEY (labeling) - REFERENCES qgep_vl.infiltration_installation_labeling (code) MATCH SIMPLE + REFERENCES qgep_vl.infiltration_installation_labeling (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.infiltration_installation_seepage_utilization () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.infiltration_installation_seepage_utilization ADD CONSTRAINT pkey_qgep_vl_infiltration_installation_seepage_utilization_code PRIMARY KEY (code); @@ -3991,7 +3991,7 @@ ALTER TABLE qgep_vl.infiltration_installation_seepage_utilization ADD CONSTRAINT INSERT INTO qgep_vl.infiltration_installation_seepage_utilization (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (273,273,'clean_water','Reinabwasser','eaux_claires', 'acque_chiare', 'ape_conventional_curate', '', 'KW', 'EC', '', '', 'true'); INSERT INTO qgep_vl.infiltration_installation_seepage_utilization (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5359,5359,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT fkey_vl_infiltration_installation_seepage_utilization FOREIGN KEY (seepage_utilization) - REFERENCES qgep_vl.infiltration_installation_seepage_utilization (code) MATCH SIMPLE + REFERENCES qgep_vl.infiltration_installation_seepage_utilization (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.infiltration_installation_vehicle_access () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.infiltration_installation_vehicle_access ADD CONSTRAINT pkey_qgep_vl_infiltration_installation_vehicle_access_code PRIMARY KEY (code); @@ -3999,7 +3999,7 @@ ALTER TABLE qgep_vl.infiltration_installation_vehicle_access ADD CONSTRAINT pkey INSERT INTO qgep_vl.infiltration_installation_vehicle_access (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3288,3288,'inaccessible','unzugaenglich','inaccessible', 'non_accessibile', 'neaccesibil', '', 'ZU', 'IAC', '', '', 'true'); INSERT INTO qgep_vl.infiltration_installation_vehicle_access (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3287,3287,'accessible','zugaenglich','accessible', 'accessibile', 'accessibil', '', 'Z', 'AC', '', '', 'true'); ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT fkey_vl_infiltration_installation_vehicle_access FOREIGN KEY (vehicle_access) - REFERENCES qgep_vl.infiltration_installation_vehicle_access (code) MATCH SIMPLE + REFERENCES qgep_vl.infiltration_installation_vehicle_access (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.infiltration_installation_watertightness () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.infiltration_installation_watertightness ADD CONSTRAINT pkey_qgep_vl_infiltration_installation_watertightness_code PRIMARY KEY (code); @@ -4007,7 +4007,7 @@ ALTER TABLE qgep_vl.infiltration_installation_watertightness ADD CONSTRAINT pkey INSERT INTO qgep_vl.infiltration_installation_watertightness (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5360,5360,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.infiltration_installation_watertightness (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3294,3294,'watertight','wasserdicht','etanche', 'zzz_wasserdicht', 'etans', '', 'WD', 'E', '', '', 'true'); ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT fkey_vl_infiltration_installation_watertightness FOREIGN KEY (watertightness) - REFERENCES qgep_vl.infiltration_installation_watertightness (code) MATCH SIMPLE + REFERENCES qgep_vl.infiltration_installation_watertightness (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.infiltration_installation ADD COLUMN fk_aquifier varchar (16); ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT rel_infiltration_installation_aquifier FOREIGN KEY (fk_aquifier) REFERENCES qgep_od.aquifier(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4023,7 +4023,7 @@ ALTER TABLE qgep_vl.wwtp_structure_kind ADD CONSTRAINT pkey_qgep_vl_wwtp_structu INSERT INTO qgep_vl.wwtp_structure_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3032,3032,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.wwtp_structure_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (326,326,'primary_clarifier','Vorklaerbecken','decanteurs_primaires', 'zzz_Vorklaerbecken', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.wwtp_structure ADD CONSTRAINT fkey_vl_wwtp_structure_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.wwtp_structure_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.wwtp_structure_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.maintenance_event_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.maintenance_event_kind ADD CONSTRAINT pkey_qgep_vl_maintenance_event_kind_code PRIMARY KEY (code); @@ -4036,7 +4036,7 @@ ALTER TABLE qgep_vl.maintenance_event_kind ADD CONSTRAINT pkey_qgep_vl_maintenan INSERT INTO qgep_vl.maintenance_event_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3045,3045,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.maintenance_event_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4564,4564,'examination','Untersuchung','examen', 'zzz_Untersuchung', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.maintenance_event ADD CONSTRAINT fkey_vl_maintenance_event_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.maintenance_event_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.maintenance_event_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.maintenance_event_status () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.maintenance_event_status ADD CONSTRAINT pkey_qgep_vl_maintenance_event_status_code PRIMARY KEY (code); @@ -4045,7 +4045,7 @@ ALTER TABLE qgep_vl.maintenance_event_status ADD CONSTRAINT pkey_qgep_vl_mainten INSERT INTO qgep_vl.maintenance_event_status (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3678,3678,'not_possible','nicht_moeglich','impossible', 'zzz_nicht_moeglich', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.maintenance_event_status (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3047,3047,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.maintenance_event ADD CONSTRAINT fkey_vl_maintenance_event_status FOREIGN KEY (status) - REFERENCES qgep_vl.maintenance_event_status (code) MATCH SIMPLE + REFERENCES qgep_vl.maintenance_event_status (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.maintenance_event ADD COLUMN fk_operating_company varchar (16); ALTER TABLE qgep_od.maintenance_event ADD CONSTRAINT rel_maintenance_event_operating_company FOREIGN KEY (fk_operating_company) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4059,7 +4059,7 @@ ALTER TABLE qgep_vl.planning_zone_kind ADD CONSTRAINT pkey_qgep_vl_planning_zone INSERT INTO qgep_vl.planning_zone_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3077,3077,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.planning_zone_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (29,29,'residential_zone','Wohnzone','zone_d_habitations', 'zzz_Wohnzone', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.planning_zone ADD CONSTRAINT fkey_vl_planning_zone_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.planning_zone_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.planning_zone_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.infiltration_zone ADD CONSTRAINT oorel_od_infiltration_zone_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.infiltration_zone_infiltration_capacity () INHERITS (qgep_sys.value_list_base); @@ -4071,7 +4071,7 @@ ALTER TABLE qgep_vl.infiltration_zone_infiltration_capacity ADD CONSTRAINT pkey_ INSERT INTO qgep_vl.infiltration_zone_infiltration_capacity (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3073,3073,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.infiltration_zone_infiltration_capacity (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2996,2996,'not_allowed','unzulaessig','non_admis', 'zzz_unzulaessig', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.infiltration_zone ADD CONSTRAINT fkey_vl_infiltration_zone_infiltration_capacity FOREIGN KEY (infiltration_capacity) - REFERENCES qgep_vl.infiltration_zone_infiltration_capacity (code) MATCH SIMPLE + REFERENCES qgep_vl.infiltration_zone_infiltration_capacity (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.drainage_system ADD CONSTRAINT oorel_od_drainage_system_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.drainage_system_kind () INHERITS (qgep_sys.value_list_base); @@ -4083,7 +4083,7 @@ ALTER TABLE qgep_vl.drainage_system_kind ADD CONSTRAINT pkey_qgep_vl_drainage_sy INSERT INTO qgep_vl.drainage_system_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2723,2723,'separated_system','Trennsystem','systeme_separatif', 'sistema_separato', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.drainage_system_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3060,3060,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.drainage_system ADD CONSTRAINT fkey_vl_drainage_system_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.drainage_system_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.drainage_system_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.water_body_protection_sector ADD CONSTRAINT oorel_od_water_body_protection_sector_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.water_body_protection_sector_kind () INHERITS (qgep_sys.value_list_base); @@ -4097,7 +4097,7 @@ ALTER TABLE qgep_vl.water_body_protection_sector_kind ADD CONSTRAINT pkey_qgep_v INSERT INTO qgep_vl.water_body_protection_sector_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3651,3651,'Zo','Zo','Zo', 'zzz_Zo', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.water_body_protection_sector_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3650,3650,'Zu','Zu','Zu', 'zzz_Zu', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.water_body_protection_sector ADD CONSTRAINT fkey_vl_water_body_protection_sector_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.water_body_protection_sector_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.water_body_protection_sector_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.ground_water_protection_perimeter ADD CONSTRAINT oorel_od_ground_water_protection_perimeter_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.groundwater_protection_zone ADD CONSTRAINT oorel_od_groundwater_protection_zone_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; @@ -4108,7 +4108,7 @@ ALTER TABLE qgep_vl.groundwater_protection_zone_kind ADD CONSTRAINT pkey_qgep_vl INSERT INTO qgep_vl.groundwater_protection_zone_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (442,442,'S3','S3','S3', 'S3', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.groundwater_protection_zone_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3040,3040,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.groundwater_protection_zone ADD CONSTRAINT fkey_vl_groundwater_protection_zone_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.groundwater_protection_zone_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.groundwater_protection_zone_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.pipe_profile_profile_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.pipe_profile_profile_type ADD CONSTRAINT pkey_qgep_vl_pipe_profile_profile_type_code PRIMARY KEY (code); @@ -4120,7 +4120,7 @@ ALTER TABLE qgep_vl.pipe_profile_profile_type ADD CONSTRAINT pkey_qgep_vl_pipe_p INSERT INTO qgep_vl.pipe_profile_profile_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3355,3355,'special','Spezialprofil','profil_special', 'sezione_speciale', 'sectiune_speciala', 'S', 'S', 'PS', 'S', 'S', 'true'); INSERT INTO qgep_vl.pipe_profile_profile_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3357,3357,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', 'U', 'U', 'I', 'S', 'N', 'true'); ALTER TABLE qgep_od.pipe_profile ADD CONSTRAINT fkey_vl_pipe_profile_profile_type FOREIGN KEY (profile_type) - REFERENCES qgep_vl.pipe_profile_profile_type (code) MATCH SIMPLE + REFERENCES qgep_vl.pipe_profile_profile_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.wwtp_energy_use ADD COLUMN fk_waste_water_treatment_plant varchar (16); ALTER TABLE qgep_od.wwtp_energy_use ADD CONSTRAINT rel_wwtp_energy_use_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4133,7 +4133,7 @@ ALTER TABLE qgep_vl.waste_water_treatment_kind ADD CONSTRAINT pkey_qgep_vl_waste INSERT INTO qgep_vl.waste_water_treatment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (366,366,'mechanical','mechanisch','mecanique', 'zzz_mechanisch', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.waste_water_treatment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3076,3076,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.waste_water_treatment ADD CONSTRAINT fkey_vl_waste_water_treatment_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.waste_water_treatment_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.waste_water_treatment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.waste_water_treatment ADD COLUMN fk_waste_water_treatment_plant varchar (16); ALTER TABLE qgep_od.waste_water_treatment ADD CONSTRAINT rel_waste_water_treatment_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4147,7 +4147,7 @@ ALTER TABLE qgep_vl.sludge_treatment_stabilisation ADD CONSTRAINT pkey_qgep_vl_s INSERT INTO qgep_vl.sludge_treatment_stabilisation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2994,2994,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.sludge_treatment_stabilisation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3004,3004,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.sludge_treatment ADD CONSTRAINT fkey_vl_sludge_treatment_stabilisation FOREIGN KEY (stabilisation) - REFERENCES qgep_vl.sludge_treatment_stabilisation (code) MATCH SIMPLE + REFERENCES qgep_vl.sludge_treatment_stabilisation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.sludge_treatment ADD COLUMN fk_waste_water_treatment_plant varchar (16); ALTER TABLE qgep_od.sludge_treatment ADD CONSTRAINT rel_sludge_treatment_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4161,7 +4161,7 @@ ALTER TABLE qgep_vl.chute_kind ADD CONSTRAINT pkey_qgep_vl_chute_kind_code PRIMA INSERT INTO qgep_vl.chute_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3592,3592,'natural','natuerlich','naturel', 'zzz_natuerlich', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.chute_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3593,3593,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.chute ADD CONSTRAINT fkey_vl_chute_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.chute_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.chute_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.chute_material () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.chute_material ADD CONSTRAINT pkey_qgep_vl_chute_material_code PRIMARY KEY (code); @@ -4172,7 +4172,7 @@ ALTER TABLE qgep_vl.chute_material ADD CONSTRAINT pkey_qgep_vl_chute_material_co INSERT INTO qgep_vl.chute_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (410,410,'natural_none','natuerlich_kein','naturel_aucun', 'zzz_natuerlich_kein', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.chute_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3061,3061,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.chute ADD CONSTRAINT fkey_vl_chute_material FOREIGN KEY (material) - REFERENCES qgep_vl.chute_material (code) MATCH SIMPLE + REFERENCES qgep_vl.chute_material (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.lock ADD CONSTRAINT oorel_od_lock_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE qgep_od.passage ADD CONSTRAINT oorel_od_passage_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; @@ -4186,7 +4186,7 @@ ALTER TABLE qgep_vl.dam_kind ADD CONSTRAINT pkey_qgep_vl_dam_kind_code PRIMARY K INSERT INTO qgep_vl.dam_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (418,418,'tyrolean_weir','Tirolerwehr','prise_tyrolienne', 'zzz_Tirolerwehr', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.dam_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3064,3064,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.dam ADD CONSTRAINT fkey_vl_dam_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.dam_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.dam_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.rock_ramp ADD CONSTRAINT oorel_od_rock_ramp_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.rock_ramp_stabilisation () INHERITS (qgep_sys.value_list_base); @@ -4199,7 +4199,7 @@ ALTER TABLE qgep_vl.rock_ramp_stabilisation ADD CONSTRAINT pkey_qgep_vl_rock_ram INSERT INTO qgep_vl.rock_ramp_stabilisation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (414,414,'wooden_beam','Holzbalken','poutres_en_bois', 'zzz_Holzbalken', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.rock_ramp_stabilisation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3063,3063,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.rock_ramp ADD CONSTRAINT fkey_vl_rock_ramp_stabilisation FOREIGN KEY (stabilisation) - REFERENCES qgep_vl.rock_ramp_stabilisation (code) MATCH SIMPLE + REFERENCES qgep_vl.rock_ramp_stabilisation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.fish_pass ADD COLUMN fk_water_control_structure varchar (16); ALTER TABLE qgep_od.fish_pass ADD CONSTRAINT rel_fish_pass_water_control_structure FOREIGN KEY (fk_water_control_structure) REFERENCES qgep_od.water_control_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4215,7 +4215,7 @@ ALTER TABLE qgep_vl.reach_point_elevation_accuracy ADD CONSTRAINT pkey_qgep_vl_r INSERT INTO qgep_vl.reach_point_elevation_accuracy (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3247,3247,'plusminus_6cm','plusminus_6cm','plus_moins_6cm', 'piu_meno_6cm', 'plus_minus_6cm', '', 'P06', 'P06', '', '', 'true'); INSERT INTO qgep_vl.reach_point_elevation_accuracy (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5376,5376,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.reach_point ADD CONSTRAINT fkey_vl_reach_point_elevation_accuracy FOREIGN KEY (elevation_accuracy) - REFERENCES qgep_vl.reach_point_elevation_accuracy (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_point_elevation_accuracy (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_point_outlet_shape () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_point_outlet_shape ADD CONSTRAINT pkey_qgep_vl_reach_point_outlet_shape_code PRIMARY KEY (code); @@ -4225,7 +4225,7 @@ ALTER TABLE qgep_vl.reach_point_outlet_shape ADD CONSTRAINT pkey_qgep_vl_reach_p INSERT INTO qgep_vl.reach_point_outlet_shape (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (286,286,'sharp_edged','scharfkantig','aretes_vives', 'zzz_scharfkantig', 'margini_ascutite', '', 'SK', 'AV', '', '', 'true'); INSERT INTO qgep_vl.reach_point_outlet_shape (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5375,5375,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.reach_point ADD CONSTRAINT fkey_vl_reach_point_outlet_shape FOREIGN KEY (outlet_shape) - REFERENCES qgep_vl.reach_point_outlet_shape (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_point_outlet_shape (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.reach_point ADD COLUMN fk_wastewater_networkelement varchar (16); ALTER TABLE qgep_od.reach_point ADD CONSTRAINT rel_reach_point_wastewater_networkelement FOREIGN KEY (fk_wastewater_networkelement) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4239,7 +4239,7 @@ ALTER TABLE qgep_vl.reach_elevation_determination ADD CONSTRAINT pkey_qgep_vl_re INSERT INTO qgep_vl.reach_elevation_determination (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4778,4778,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.reach_elevation_determination (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4779,4779,'inaccurate','ungenau','imprecise', 'impreciso', 'imprecisa', '', 'LU', 'IP', '', '', 'true'); ALTER TABLE qgep_od.reach ADD CONSTRAINT fkey_vl_reach_elevation_determination FOREIGN KEY (elevation_determination) - REFERENCES qgep_vl.reach_elevation_determination (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_elevation_determination (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_horizontal_positioning () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_horizontal_positioning ADD CONSTRAINT pkey_qgep_vl_reach_horizontal_positioning_code PRIMARY KEY (code); @@ -4247,7 +4247,7 @@ ALTER TABLE qgep_vl.reach_horizontal_positioning ADD CONSTRAINT pkey_qgep_vl_rea INSERT INTO qgep_vl.reach_horizontal_positioning (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5379,5379,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.reach_horizontal_positioning (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5380,5380,'inaccurate','ungenau','imprecise', 'impreciso', 'imprecisa', '', 'LU', 'IP', '', '', 'true'); ALTER TABLE qgep_od.reach ADD CONSTRAINT fkey_vl_reach_horizontal_positioning FOREIGN KEY (horizontal_positioning) - REFERENCES qgep_vl.reach_horizontal_positioning (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_horizontal_positioning (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_inside_coating () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_inside_coating ADD CONSTRAINT pkey_qgep_vl_reach_inside_coating_code PRIMARY KEY (code); @@ -4258,7 +4258,7 @@ ALTER TABLE qgep_vl.reach_inside_coating ADD CONSTRAINT pkey_qgep_vl_reach_insid INSERT INTO qgep_vl.reach_inside_coating (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5384,5384,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.reach_inside_coating (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (249,249,'cement_mortar_lining','Zementmoertelauskleidung','revetement_en_mortier_de_ciment', 'zzz_Zementmoertelauskleidung', 'strat_mortar_ciment', '', 'ZM', 'RM', '', '', 'true'); ALTER TABLE qgep_od.reach ADD CONSTRAINT fkey_vl_reach_inside_coating FOREIGN KEY (inside_coating) - REFERENCES qgep_vl.reach_inside_coating (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_inside_coating (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_material () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_material ADD CONSTRAINT pkey_qgep_vl_reach_material_code PRIMARY KEY (code); @@ -4287,7 +4287,7 @@ ALTER TABLE qgep_vl.reach_material ADD CONSTRAINT pkey_qgep_vl_reach_material_co INSERT INTO qgep_vl.reach_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3016,3016,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', 'U', 'U', 'I', 'SC', '', 'true'); INSERT INTO qgep_vl.reach_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2762,2762,'cement','Zement','ciment', 'cemento', 'ciment', 'C', 'Z', 'C', 'C', '', 'true'); ALTER TABLE qgep_od.reach ADD CONSTRAINT fkey_vl_reach_material FOREIGN KEY (material) - REFERENCES qgep_vl.reach_material (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_material (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_reliner_material () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_reliner_material ADD CONSTRAINT pkey_qgep_vl_reach_reliner_material_code PRIMARY KEY (code); @@ -4308,7 +4308,7 @@ ALTER TABLE qgep_vl.reach_reliner_material ADD CONSTRAINT pkey_qgep_vl_reach_rel INSERT INTO qgep_vl.reach_reliner_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6468,6468,'vinyl_ester_resin_glass_fibre_laminate','Vinylesterharz_Glasfaserlaminat','resine_d_ester_vinylique_lamine_en_fibre_de_verre', 'zzz_Vinylesterharz_Glasfaserlaminat', 'rasina_de_ester_vinil_laminata_in_fibra_de_sticla', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.reach_reliner_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6469,6469,'vinyl_ester_resin_plastic_felt','Vinylesterharz_Kunststofffilz','resine_d_ester_vinylique_feutre_synthetique', 'zzz_Vinylesterharz_Kunststofffilz', 'rasina_de_ester_vinil', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.reach ADD CONSTRAINT fkey_vl_reach_reliner_material FOREIGN KEY (reliner_material) - REFERENCES qgep_vl.reach_reliner_material (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_reliner_material (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_relining_construction () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_relining_construction ADD CONSTRAINT pkey_qgep_vl_reach_relining_construction_code PRIMARY KEY (code); @@ -4322,7 +4322,7 @@ ALTER TABLE qgep_vl.reach_relining_construction ADD CONSTRAINT pkey_qgep_vl_reac INSERT INTO qgep_vl.reach_relining_construction (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6453,6453,'unknown','unbekannt','inconnu', 'zzz_unbekannt', 'necunoscuta', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.reach_relining_construction (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6480,6480,'spiral_lining','Wickelrohrrelining','chemisage_par_tube_spirale', 'zzz_Wickelrohrrelining', 'captusire_prin_tub_spirala', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.reach ADD CONSTRAINT fkey_vl_reach_relining_construction FOREIGN KEY (relining_construction) - REFERENCES qgep_vl.reach_relining_construction (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_relining_construction (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_relining_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_relining_kind ADD CONSTRAINT pkey_qgep_vl_reach_relining_kind_code PRIMARY KEY (code); @@ -4330,7 +4330,7 @@ ALTER TABLE qgep_vl.reach_relining_kind ADD CONSTRAINT pkey_qgep_vl_reach_relini INSERT INTO qgep_vl.reach_relining_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6456,6456,'partial','partiell','partiellement', 'zzz_partiell', 'partial', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.reach_relining_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6457,6457,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.reach ADD CONSTRAINT fkey_vl_reach_relining_kind FOREIGN KEY (relining_kind) - REFERENCES qgep_vl.reach_relining_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_relining_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.reach ADD COLUMN fk_reach_point_from varchar (16); ALTER TABLE qgep_od.reach ADD CONSTRAINT rel_reach_reach_point_from FOREIGN KEY (fk_reach_point_from) REFERENCES qgep_od.reach_point(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4351,7 +4351,7 @@ ALTER TABLE qgep_vl.mechanical_pretreatment_kind ADD CONSTRAINT pkey_qgep_vl_mec INSERT INTO qgep_vl.mechanical_pretreatment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3321,3321,'floating_matter_separator','Schwimmstoffabscheider','separateur_materiaux_flottants', 'separatore_materiali_galleggianti', 'separator_materie_flotanta', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.mechanical_pretreatment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3322,3322,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.mechanical_pretreatment ADD CONSTRAINT fkey_vl_mechanical_pretreatment_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.mechanical_pretreatment_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.mechanical_pretreatment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.mechanical_pretreatment ADD COLUMN fk_infiltration_installation varchar (16); ALTER TABLE qgep_od.mechanical_pretreatment ADD CONSTRAINT rel_mechanical_pretreatment_infiltration_installation FOREIGN KEY (fk_infiltration_installation) REFERENCES qgep_od.infiltration_installation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4366,7 +4366,7 @@ ALTER TABLE qgep_vl.retention_body_kind ADD CONSTRAINT pkey_qgep_vl_retention_bo INSERT INTO qgep_vl.retention_body_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (347,347,'accumulation_channel','Staukanal','retention_dans_canalisations_stockage', 'zzz_Staukanal', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.retention_body_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3031,3031,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.retention_body ADD CONSTRAINT fkey_vl_retention_body_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.retention_body_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.retention_body_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.retention_body ADD COLUMN fk_infiltration_installation varchar (16); ALTER TABLE qgep_od.retention_body ADD CONSTRAINT rel_retention_body_infiltration_installation FOREIGN KEY (fk_infiltration_installation) REFERENCES qgep_od.infiltration_installation(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4376,7 +4376,7 @@ ALTER TABLE qgep_vl.overflow_char_kind_overflow_char ADD CONSTRAINT pkey_qgep_vl INSERT INTO qgep_vl.overflow_char_kind_overflow_char (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6221,6221,'qq','QQ','QQ', 'QQ', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.overflow_char_kind_overflow_char (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6228,6228,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.overflow_char ADD CONSTRAINT fkey_vl_overflow_char_kind_overflow_char FOREIGN KEY (kind_overflow_char) - REFERENCES qgep_vl.overflow_char_kind_overflow_char (code) MATCH SIMPLE + REFERENCES qgep_vl.overflow_char_kind_overflow_char (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.overflow_char_overflow_char_digital () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.overflow_char_overflow_char_digital ADD CONSTRAINT pkey_qgep_vl_overflow_char_overflow_char_digital_code PRIMARY KEY (code); @@ -4384,7 +4384,7 @@ ALTER TABLE qgep_vl.overflow_char_overflow_char_digital ADD CONSTRAINT pkey_qgep INSERT INTO qgep_vl.overflow_char_overflow_char_digital (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6224,6224,'no','nein','non', 'no', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.overflow_char_overflow_char_digital (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6225,6225,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.overflow_char ADD CONSTRAINT fkey_vl_overflow_char_overflow_char_digital FOREIGN KEY (overflow_char_digital) - REFERENCES qgep_vl.overflow_char_overflow_char_digital (code) MATCH SIMPLE + REFERENCES qgep_vl.overflow_char_overflow_char_digital (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.hq_relation ADD COLUMN fk_overflow_char varchar (16); ALTER TABLE qgep_od.hq_relation ADD CONSTRAINT rel_hq_relation_overflow_char FOREIGN KEY (fk_overflow_char) REFERENCES qgep_od.overflow_char(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4394,7 +4394,7 @@ ALTER TABLE qgep_vl.structure_part_renovation_demand ADD CONSTRAINT pkey_qgep_vl INSERT INTO qgep_vl.structure_part_renovation_demand (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (137,137,'necessary','notwendig','necessaire', 'zzz_notwendig', 'necesare', 'N', 'N', 'N', '', '', 'true'); INSERT INTO qgep_vl.structure_part_renovation_demand (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5358,5358,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.structure_part ADD CONSTRAINT fkey_vl_structure_part_renovation_demand FOREIGN KEY (renovation_demand) - REFERENCES qgep_vl.structure_part_renovation_demand (code) MATCH SIMPLE + REFERENCES qgep_vl.structure_part_renovation_demand (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.structure_part ADD COLUMN fk_wastewater_structure varchar (16); ALTER TABLE qgep_od.structure_part ADD CONSTRAINT rel_structure_part_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4412,7 +4412,7 @@ ALTER TABLE qgep_vl.access_aid_kind ADD CONSTRAINT pkey_qgep_vl_access_aid_kind_ INSERT INTO qgep_vl.access_aid_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3230,3230,'door','Tuere','porte', 'porta', 'usa', '', 'T', 'P', '', '', 'true'); INSERT INTO qgep_vl.access_aid_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3048,3048,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.access_aid ADD CONSTRAINT fkey_vl_access_aid_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.access_aid_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.access_aid_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.dryweather_flume ADD CONSTRAINT oorel_od_dryweather_flume_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.dryweather_flume_material () INHERITS (qgep_sys.value_list_base); @@ -4424,7 +4424,7 @@ ALTER TABLE qgep_vl.dryweather_flume_material ADD CONSTRAINT pkey_qgep_vl_drywea INSERT INTO qgep_vl.dryweather_flume_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3017,3017,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.dryweather_flume_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (237,237,'cement_mortar','Zementmoertel','mortier_de_ciment', 'zzz_Zementmoertel', 'mortar_ciment', '', 'ZM', 'MC', '', '', 'true'); ALTER TABLE qgep_od.dryweather_flume ADD CONSTRAINT fkey_vl_dryweather_flume_material FOREIGN KEY (material) - REFERENCES qgep_vl.dryweather_flume_material (code) MATCH SIMPLE + REFERENCES qgep_vl.dryweather_flume_material (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.cover ADD CONSTRAINT oorel_od_cover_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.cover_cover_shape () INHERITS (qgep_sys.value_list_base); @@ -4434,7 +4434,7 @@ ALTER TABLE qgep_vl.cover_cover_shape ADD CONSTRAINT pkey_qgep_vl_cover_cover_sh INSERT INTO qgep_vl.cover_cover_shape (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3498,3498,'round','rund','rond', 'zzz_rund', 'rotund', '', 'R', 'R', '', '', 'true'); INSERT INTO qgep_vl.cover_cover_shape (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5354,5354,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.cover ADD CONSTRAINT fkey_vl_cover_cover_shape FOREIGN KEY (cover_shape) - REFERENCES qgep_vl.cover_cover_shape (code) MATCH SIMPLE + REFERENCES qgep_vl.cover_cover_shape (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.cover_fastening () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.cover_fastening ADD CONSTRAINT pkey_qgep_vl_cover_fastening_code PRIMARY KEY (code); @@ -4442,7 +4442,7 @@ ALTER TABLE qgep_vl.cover_fastening ADD CONSTRAINT pkey_qgep_vl_cover_fastening_ INSERT INTO qgep_vl.cover_fastening (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5351,5351,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.cover_fastening (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5352,5352,'bolted','verschraubt','vissee', 'zzz_verschraubt', 'insurubata', '', 'VS', 'VS', '', '', 'true'); ALTER TABLE qgep_od.cover ADD CONSTRAINT fkey_vl_cover_fastening FOREIGN KEY (fastening) - REFERENCES qgep_vl.cover_fastening (code) MATCH SIMPLE + REFERENCES qgep_vl.cover_fastening (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.cover_material () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.cover_material ADD CONSTRAINT pkey_qgep_vl_cover_material_code PRIMARY KEY (code); @@ -4453,7 +4453,7 @@ ALTER TABLE qgep_vl.cover_material ADD CONSTRAINT pkey_qgep_vl_cover_material_co INSERT INTO qgep_vl.cover_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (235,235,'cast_iron_with_concrete_filling','Guss_mit_Betonfuellung','fonte_avec_remplissage_en_beton', 'zzz_Guss_mit_Betonfuellung', 'fonta_cu_umplutura_beton', '', 'GBT', 'FRB', '', '', 'true'); INSERT INTO qgep_vl.cover_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3015,3015,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.cover ADD CONSTRAINT fkey_vl_cover_material FOREIGN KEY (material) - REFERENCES qgep_vl.cover_material (code) MATCH SIMPLE + REFERENCES qgep_vl.cover_material (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.cover_positional_accuracy () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.cover_positional_accuracy ADD CONSTRAINT pkey_qgep_vl_cover_positional_accuracy_code PRIMARY KEY (code); @@ -4463,7 +4463,7 @@ ALTER TABLE qgep_vl.cover_positional_accuracy ADD CONSTRAINT pkey_qgep_vl_cover_ INSERT INTO qgep_vl.cover_positional_accuracy (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3242,3242,'plusminus_50cm','plusminus_50cm','plus_moins_50cm', 'piu_meno_50cm', 'plus_minus_50cm', '', 'P50', 'P50', '', '', 'true'); INSERT INTO qgep_vl.cover_positional_accuracy (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5349,5349,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.cover ADD CONSTRAINT fkey_vl_cover_positional_accuracy FOREIGN KEY (positional_accuracy) - REFERENCES qgep_vl.cover_positional_accuracy (code) MATCH SIMPLE + REFERENCES qgep_vl.cover_positional_accuracy (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.cover_sludge_bucket () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.cover_sludge_bucket ADD CONSTRAINT pkey_qgep_vl_cover_sludge_bucket_code PRIMARY KEY (code); @@ -4471,7 +4471,7 @@ ALTER TABLE qgep_vl.cover_sludge_bucket ADD CONSTRAINT pkey_qgep_vl_cover_sludge INSERT INTO qgep_vl.cover_sludge_bucket (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3066,3066,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); INSERT INTO qgep_vl.cover_sludge_bucket (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (422,422,'existent','vorhanden','existant', 'zzz_vorhanden', 'existent', '', 'V', 'E', '', '', 'true'); ALTER TABLE qgep_od.cover ADD CONSTRAINT fkey_vl_cover_sludge_bucket FOREIGN KEY (sludge_bucket) - REFERENCES qgep_vl.cover_sludge_bucket (code) MATCH SIMPLE + REFERENCES qgep_vl.cover_sludge_bucket (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.cover_venting () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.cover_venting ADD CONSTRAINT pkey_qgep_vl_cover_venting_code PRIMARY KEY (code); @@ -4479,7 +4479,7 @@ ALTER TABLE qgep_vl.cover_venting ADD CONSTRAINT pkey_qgep_vl_cover_venting_code INSERT INTO qgep_vl.cover_venting (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (230,230,'not_vented','nicht_entlueftet','non_aere', 'zzz_nicht_entlueftet', 'fara_aerisire', '', 'NEL', 'NAE', '', '', 'true'); INSERT INTO qgep_vl.cover_venting (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5348,5348,'unknown','unbekannt','inconnue', 'sconosciuto', 'necunoscut', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.cover ADD CONSTRAINT fkey_vl_cover_venting FOREIGN KEY (venting) - REFERENCES qgep_vl.cover_venting (code) MATCH SIMPLE + REFERENCES qgep_vl.cover_venting (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.electric_equipment ADD CONSTRAINT oorel_od_electric_equipment_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.electric_equipment_kind () INHERITS (qgep_sys.value_list_base); @@ -4491,7 +4491,7 @@ ALTER TABLE qgep_vl.electric_equipment_kind ADD CONSTRAINT pkey_qgep_vl_electric INSERT INTO qgep_vl.electric_equipment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (377,377,'phone','Telephon','telephone', 'telefono', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.electric_equipment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3038,3038,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.electric_equipment ADD CONSTRAINT fkey_vl_electric_equipment_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.electric_equipment_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.electric_equipment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.electromechanical_equipment ADD CONSTRAINT oorel_od_electromechanical_equipment_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.electromechanical_equipment_kind () INHERITS (qgep_sys.value_list_base); @@ -4502,7 +4502,7 @@ ALTER TABLE qgep_vl.electromechanical_equipment_kind ADD CONSTRAINT pkey_qgep_vl INSERT INTO qgep_vl.electromechanical_equipment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (381,381,'scraper_installation','Raeumeinrichtung','dispositif_de_curage', 'zzz_Raeumeinrichtung', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.electromechanical_equipment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3072,3072,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.electromechanical_equipment ADD CONSTRAINT fkey_vl_electromechanical_equipment_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.electromechanical_equipment_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.electromechanical_equipment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.benching ADD CONSTRAINT oorel_od_benching_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.benching_kind () INHERITS (qgep_sys.value_list_base); @@ -4513,7 +4513,7 @@ ALTER TABLE qgep_vl.benching_kind ADD CONSTRAINT pkey_qgep_vl_benching_kind_code INSERT INTO qgep_vl.benching_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3231,3231,'none','kein','aucun', 'nessuno', 'niciun', '', 'KB', 'AN', '', '', 'true'); INSERT INTO qgep_vl.benching_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3033,3033,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscuta', '', 'U', 'I', '', '', 'true'); ALTER TABLE qgep_od.benching ADD CONSTRAINT fkey_vl_benching_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.benching_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.benching_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.connection_object ADD COLUMN fk_wastewater_networkelement varchar (16); ALTER TABLE qgep_od.connection_object ADD CONSTRAINT rel_connection_object_wastewater_networkelement FOREIGN KEY (fk_wastewater_networkelement) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4537,7 +4537,7 @@ ALTER TABLE qgep_vl.individual_surface_function ADD CONSTRAINT pkey_qgep_vl_indi INSERT INTO qgep_vl.individual_surface_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3465,3465,'connecting_or_principal_or_major_road','Verbindungs_Hauptverkehrs_Hochleistungsstrassen','routes_de_raccordement_principales_grand_trafic', '', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.individual_surface_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3463,3463,'forecourt_and_access_road','VorplaetzeZufahrten','places_devant_entree_acces', 'zzz_VorplaetzeZufahrten', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.individual_surface ADD CONSTRAINT fkey_vl_individual_surface_function FOREIGN KEY (function) - REFERENCES qgep_vl.individual_surface_function (code) MATCH SIMPLE + REFERENCES qgep_vl.individual_surface_function (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.individual_surface_pavement () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.individual_surface_pavement ADD CONSTRAINT pkey_qgep_vl_individual_surface_pavement_code PRIMARY KEY (code); @@ -4548,7 +4548,7 @@ ALTER TABLE qgep_vl.individual_surface_pavement ADD CONSTRAINT pkey_qgep_vl_indi INSERT INTO qgep_vl.individual_surface_pavement (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3030,3030,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.individual_surface_pavement (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2034,2034,'barren','vegetationslos','sans_vegetation', 'zzz_vegetationslos', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.individual_surface ADD CONSTRAINT fkey_vl_individual_surface_pavement FOREIGN KEY (pavement) - REFERENCES qgep_vl.individual_surface_pavement (code) MATCH SIMPLE + REFERENCES qgep_vl.individual_surface_pavement (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.fountain ADD CONSTRAINT oorel_od_fountain_connection_object FOREIGN KEY (obj_id) REFERENCES qgep_od.connection_object(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.hazard_source ADD COLUMN fk_connection_object varchar (16); @@ -4565,7 +4565,7 @@ ALTER TABLE qgep_vl.catchment_area_direct_discharge_current ADD CONSTRAINT pkey_ INSERT INTO qgep_vl.catchment_area_direct_discharge_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5458,5458,'no','nein','non', 'no', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_direct_discharge_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5463,5463,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT fkey_vl_catchment_area_direct_discharge_current FOREIGN KEY (direct_discharge_current) - REFERENCES qgep_vl.catchment_area_direct_discharge_current (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_direct_discharge_current (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_direct_discharge_planned () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_direct_discharge_planned ADD CONSTRAINT pkey_qgep_vl_catchment_area_direct_discharge_planned_code PRIMARY KEY (code); @@ -4573,7 +4573,7 @@ ALTER TABLE qgep_vl.catchment_area_direct_discharge_planned ADD CONSTRAINT pkey_ INSERT INTO qgep_vl.catchment_area_direct_discharge_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5460,5460,'no','nein','non', 'no', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_direct_discharge_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5464,5464,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT fkey_vl_catchment_area_direct_discharge_planned FOREIGN KEY (direct_discharge_planned) - REFERENCES qgep_vl.catchment_area_direct_discharge_planned (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_direct_discharge_planned (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_drainage_system_current () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_drainage_system_current ADD CONSTRAINT pkey_qgep_vl_catchment_area_drainage_system_current_code PRIMARY KEY (code); @@ -4584,7 +4584,7 @@ ALTER TABLE qgep_vl.catchment_area_drainage_system_current ADD CONSTRAINT pkey_q INSERT INTO qgep_vl.catchment_area_drainage_system_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5187,5187,'separated_system','Trennsystem','systeme_separatif', 'sistema_separato', 'rrr_Trennsystem', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_drainage_system_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5189,5189,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT fkey_vl_catchment_area_drainage_system_current FOREIGN KEY (drainage_system_current) - REFERENCES qgep_vl.catchment_area_drainage_system_current (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_drainage_system_current (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_drainage_system_planned () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_drainage_system_planned ADD CONSTRAINT pkey_qgep_vl_catchment_area_drainage_system_planned_code PRIMARY KEY (code); @@ -4595,7 +4595,7 @@ ALTER TABLE qgep_vl.catchment_area_drainage_system_planned ADD CONSTRAINT pkey_q INSERT INTO qgep_vl.catchment_area_drainage_system_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5192,5192,'separated_system','Trennsystem','systeme_separatif', 'sistema_separato', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_drainage_system_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5195,5195,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT fkey_vl_catchment_area_drainage_system_planned FOREIGN KEY (drainage_system_planned) - REFERENCES qgep_vl.catchment_area_drainage_system_planned (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_drainage_system_planned (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_infiltration_current () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_infiltration_current ADD CONSTRAINT pkey_qgep_vl_catchment_area_infiltration_current_code PRIMARY KEY (code); @@ -4603,7 +4603,7 @@ ALTER TABLE qgep_vl.catchment_area_infiltration_current ADD CONSTRAINT pkey_qgep INSERT INTO qgep_vl.catchment_area_infiltration_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5453,5453,'no','nein','non', 'no', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_infiltration_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5165,5165,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT fkey_vl_catchment_area_infiltration_current FOREIGN KEY (infiltration_current) - REFERENCES qgep_vl.catchment_area_infiltration_current (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_infiltration_current (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_infiltration_planned () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_infiltration_planned ADD CONSTRAINT pkey_qgep_vl_catchment_area_infiltration_planned_code PRIMARY KEY (code); @@ -4611,7 +4611,7 @@ ALTER TABLE qgep_vl.catchment_area_infiltration_planned ADD CONSTRAINT pkey_qgep INSERT INTO qgep_vl.catchment_area_infiltration_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5462,5462,'no','nein','non', 'no', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_infiltration_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5170,5170,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT fkey_vl_catchment_area_infiltration_planned FOREIGN KEY (infiltration_planned) - REFERENCES qgep_vl.catchment_area_infiltration_planned (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_infiltration_planned (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_retention_current () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_retention_current ADD CONSTRAINT pkey_qgep_vl_catchment_area_retention_current_code PRIMARY KEY (code); @@ -4619,7 +4619,7 @@ ALTER TABLE qgep_vl.catchment_area_retention_current ADD CONSTRAINT pkey_qgep_vl INSERT INTO qgep_vl.catchment_area_retention_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5468,5468,'no','nein','non', 'no', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_retention_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5469,5469,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT fkey_vl_catchment_area_retention_current FOREIGN KEY (retention_current) - REFERENCES qgep_vl.catchment_area_retention_current (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_retention_current (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_retention_planned () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_retention_planned ADD CONSTRAINT pkey_qgep_vl_catchment_area_retention_planned_code PRIMARY KEY (code); @@ -4627,7 +4627,7 @@ ALTER TABLE qgep_vl.catchment_area_retention_planned ADD CONSTRAINT pkey_qgep_vl INSERT INTO qgep_vl.catchment_area_retention_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5471,5471,'no','nein','non', 'no', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_retention_planned (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5472,5472,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT fkey_vl_catchment_area_retention_planned FOREIGN KEY (retention_planned) - REFERENCES qgep_vl.catchment_area_retention_planned (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_retention_planned (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.catchment_area ADD COLUMN fk_wastewater_networkelement_rw_current varchar (16); ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT rel_catchment_area_wastewater_networkelement_rw_current FOREIGN KEY (fk_wastewater_networkelement_rw_current) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4647,7 +4647,7 @@ ALTER TABLE qgep_vl.measuring_point_damming_device ADD CONSTRAINT pkey_qgep_vl_m INSERT INTO qgep_vl.measuring_point_damming_device (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5724,5724,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.measuring_point_damming_device (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5723,5723,'venturi_necking','Venturieinschnuerung','etranglement_venturi', 'zzz_Venturieinschnuerung', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT fkey_vl_measuring_point_damming_device FOREIGN KEY (damming_device) - REFERENCES qgep_vl.measuring_point_damming_device (code) MATCH SIMPLE + REFERENCES qgep_vl.measuring_point_damming_device (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.measuring_point_purpose () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.measuring_point_purpose ADD CONSTRAINT pkey_qgep_vl_measuring_point_purpose_code PRIMARY KEY (code); @@ -4656,7 +4656,7 @@ ALTER TABLE qgep_vl.measuring_point_purpose ADD CONSTRAINT pkey_qgep_vl_measurin INSERT INTO qgep_vl.measuring_point_purpose (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4594,4594,'technical_purpose','technischer_Zweck','but_technique', 'scopo_tecnico', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.measuring_point_purpose (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4592,4592,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT fkey_vl_measuring_point_purpose FOREIGN KEY (purpose) - REFERENCES qgep_vl.measuring_point_purpose (code) MATCH SIMPLE + REFERENCES qgep_vl.measuring_point_purpose (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.measuring_point ADD COLUMN fk_operator varchar (16); ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT rel_measuring_point_operator FOREIGN KEY (fk_operator) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4678,7 +4678,7 @@ ALTER TABLE qgep_vl.measuring_device_kind ADD CONSTRAINT pkey_qgep_vl_measuring_ INSERT INTO qgep_vl.measuring_device_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6322,6322,'ultrasound','Ultraschall','ultrason', 'zzz_Ultraschall', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.measuring_device_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5709,5709,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.measuring_device ADD CONSTRAINT fkey_vl_measuring_device_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.measuring_device_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.measuring_device_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.measuring_device ADD COLUMN fk_measuring_point varchar (16); ALTER TABLE qgep_od.measuring_device ADD CONSTRAINT rel_measuring_device_measuring_point FOREIGN KEY (fk_measuring_point) REFERENCES qgep_od.measuring_point(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4689,7 +4689,7 @@ ALTER TABLE qgep_vl.measurement_series_kind ADD CONSTRAINT pkey_qgep_vl_measurem INSERT INTO qgep_vl.measurement_series_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2647,2647,'rain_weather','Regenwetter','temps_de_pluie', 'tempo_pioggia', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.measurement_series_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3053,3053,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.measurement_series ADD CONSTRAINT fkey_vl_measurement_series_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.measurement_series_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.measurement_series_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.measurement_series ADD COLUMN fk_measuring_point varchar (16); ALTER TABLE qgep_od.measurement_series ADD CONSTRAINT rel_measurement_series_measuring_point FOREIGN KEY (fk_measuring_point) REFERENCES qgep_od.measuring_point(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4700,7 +4700,7 @@ ALTER TABLE qgep_vl.measurement_result_measurement_type ADD CONSTRAINT pkey_qgep INSERT INTO qgep_vl.measurement_result_measurement_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5734,5734,'level','Niveau','niveau', 'livello', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.measurement_result_measurement_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5735,5735,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.measurement_result ADD CONSTRAINT fkey_vl_measurement_result_measurement_type FOREIGN KEY (measurement_type) - REFERENCES qgep_vl.measurement_result_measurement_type (code) MATCH SIMPLE + REFERENCES qgep_vl.measurement_result_measurement_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.measurement_result ADD COLUMN fk_measuring_device varchar (16); ALTER TABLE qgep_od.measurement_result ADD CONSTRAINT rel_measurement_result_measuring_device FOREIGN KEY (fk_measuring_device) REFERENCES qgep_od.measuring_device(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4718,7 +4718,7 @@ ALTER TABLE qgep_vl.overflow_actuation ADD CONSTRAINT pkey_qgep_vl_overflow_actu INSERT INTO qgep_vl.overflow_actuation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (304,304,'pneumatic','pneumatisch','pneumatique', 'zzz_pneumatisch', 'pneumatic', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.overflow_actuation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3005,3005,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.overflow ADD CONSTRAINT fkey_vl_overflow_actuation FOREIGN KEY (actuation) - REFERENCES qgep_vl.overflow_actuation (code) MATCH SIMPLE + REFERENCES qgep_vl.overflow_actuation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.overflow_adjustability () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.overflow_adjustability ADD CONSTRAINT pkey_qgep_vl_overflow_adjustability_code PRIMARY KEY (code); @@ -4726,7 +4726,7 @@ ALTER TABLE qgep_vl.overflow_adjustability ADD CONSTRAINT pkey_qgep_vl_overflow_ INSERT INTO qgep_vl.overflow_adjustability (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3021,3021,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.overflow_adjustability (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (356,356,'adjustable','verstellbar','reglable', 'zzz_verstellbar', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.overflow ADD CONSTRAINT fkey_vl_overflow_adjustability FOREIGN KEY (adjustability) - REFERENCES qgep_vl.overflow_adjustability (code) MATCH SIMPLE + REFERENCES qgep_vl.overflow_adjustability (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.overflow_control () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.overflow_control ADD CONSTRAINT pkey_qgep_vl_overflow_control_code PRIMARY KEY (code); @@ -4735,7 +4735,7 @@ ALTER TABLE qgep_vl.overflow_control ADD CONSTRAINT pkey_qgep_vl_overflow_contro INSERT INTO qgep_vl.overflow_control (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (306,306,'none','keine','aucun', 'nessuno', 'inexistent', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.overflow_control (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3028,3028,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.overflow ADD CONSTRAINT fkey_vl_overflow_control FOREIGN KEY (control) - REFERENCES qgep_vl.overflow_control (code) MATCH SIMPLE + REFERENCES qgep_vl.overflow_control (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.overflow_function () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.overflow_function ADD CONSTRAINT pkey_qgep_vl_overflow_function_code PRIMARY KEY (code); @@ -4746,7 +4746,7 @@ ALTER TABLE qgep_vl.overflow_function ADD CONSTRAINT pkey_qgep_vl_overflow_funct INSERT INTO qgep_vl.overflow_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5546,5546,'internal_overflow','Trennueberlauf','deversoir_interne', 'zzz_Trennueberlauf', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.overflow_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3010,3010,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.overflow ADD CONSTRAINT fkey_vl_overflow_function FOREIGN KEY (function) - REFERENCES qgep_vl.overflow_function (code) MATCH SIMPLE + REFERENCES qgep_vl.overflow_function (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.overflow_signal_transmission () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.overflow_signal_transmission ADD CONSTRAINT pkey_qgep_vl_overflow_signal_transmission_code PRIMARY KEY (code); @@ -4755,7 +4755,7 @@ ALTER TABLE qgep_vl.overflow_signal_transmission ADD CONSTRAINT pkey_qgep_vl_ove INSERT INTO qgep_vl.overflow_signal_transmission (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2695,2695,'sending_receiving','senden_empfangen','emettre_recevoir', 'zzz_senden_empfangen', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.overflow_signal_transmission (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3056,3056,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.overflow ADD CONSTRAINT fkey_vl_overflow_signal_transmission FOREIGN KEY (signal_transmission) - REFERENCES qgep_vl.overflow_signal_transmission (code) MATCH SIMPLE + REFERENCES qgep_vl.overflow_signal_transmission (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.overflow ADD COLUMN fk_wastewater_node varchar (16); ALTER TABLE qgep_od.overflow ADD CONSTRAINT rel_overflow_wastewater_node FOREIGN KEY (fk_wastewater_node) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4777,7 +4777,7 @@ ALTER TABLE qgep_vl.throttle_shut_off_unit_actuation ADD CONSTRAINT pkey_qgep_vl INSERT INTO qgep_vl.throttle_shut_off_unit_actuation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3158,3158,'pneumatic','pneumatisch','pneumatique', 'zzz_pneumatisch', 'pneumatic', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.throttle_shut_off_unit_actuation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3151,3151,'unknown','unbekannt','inconnu', 'sconosciuto', 'necunoscut', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT fkey_vl_throttle_shut_off_unit_actuation FOREIGN KEY (actuation) - REFERENCES qgep_vl.throttle_shut_off_unit_actuation (code) MATCH SIMPLE + REFERENCES qgep_vl.throttle_shut_off_unit_actuation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.throttle_shut_off_unit_adjustability () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.throttle_shut_off_unit_adjustability ADD CONSTRAINT pkey_qgep_vl_throttle_shut_off_unit_adjustability_code PRIMARY KEY (code); @@ -4785,7 +4785,7 @@ ALTER TABLE qgep_vl.throttle_shut_off_unit_adjustability ADD CONSTRAINT pkey_qge INSERT INTO qgep_vl.throttle_shut_off_unit_adjustability (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3161,3161,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.throttle_shut_off_unit_adjustability (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3160,3160,'adjustable','verstellbar','reglable', 'zzz_verstellbar', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT fkey_vl_throttle_shut_off_unit_adjustability FOREIGN KEY (adjustability) - REFERENCES qgep_vl.throttle_shut_off_unit_adjustability (code) MATCH SIMPLE + REFERENCES qgep_vl.throttle_shut_off_unit_adjustability (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.throttle_shut_off_unit_control () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.throttle_shut_off_unit_control ADD CONSTRAINT pkey_qgep_vl_throttle_shut_off_unit_control_code PRIMARY KEY (code); @@ -4794,7 +4794,7 @@ ALTER TABLE qgep_vl.throttle_shut_off_unit_control ADD CONSTRAINT pkey_qgep_vl_t INSERT INTO qgep_vl.throttle_shut_off_unit_control (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3165,3165,'none','keine','aucun', 'nessuno', 'inexistent', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.throttle_shut_off_unit_control (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3164,3164,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT fkey_vl_throttle_shut_off_unit_control FOREIGN KEY (control) - REFERENCES qgep_vl.throttle_shut_off_unit_control (code) MATCH SIMPLE + REFERENCES qgep_vl.throttle_shut_off_unit_control (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.throttle_shut_off_unit_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.throttle_shut_off_unit_kind ADD CONSTRAINT pkey_qgep_vl_throttle_shut_off_unit_kind_code PRIMARY KEY (code); @@ -4814,7 +4814,7 @@ ALTER TABLE qgep_vl.throttle_shut_off_unit_kind ADD CONSTRAINT pkey_qgep_vl_thro INSERT INTO qgep_vl.throttle_shut_off_unit_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3046,3046,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.throttle_shut_off_unit_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (133,133,'whirl_throttle','Wirbeldrossel','limiteur_a_vortex', 'zzz_Wirbeldrossel', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT fkey_vl_throttle_shut_off_unit_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.throttle_shut_off_unit_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.throttle_shut_off_unit_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.throttle_shut_off_unit_signal_transmission () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.throttle_shut_off_unit_signal_transmission ADD CONSTRAINT pkey_qgep_vl_throttle_shut_off_unit_signal_transmission_code PRIMARY KEY (code); @@ -4823,7 +4823,7 @@ ALTER TABLE qgep_vl.throttle_shut_off_unit_signal_transmission ADD CONSTRAINT pk INSERT INTO qgep_vl.throttle_shut_off_unit_signal_transmission (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3169,3169,'sending_receiving','senden_empfangen','emettre_recevoir', 'zzz_senden_empfangen', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.throttle_shut_off_unit_signal_transmission (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3170,3170,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT fkey_vl_throttle_shut_off_unit_signal_transmission FOREIGN KEY (signal_transmission) - REFERENCES qgep_vl.throttle_shut_off_unit_signal_transmission (code) MATCH SIMPLE + REFERENCES qgep_vl.throttle_shut_off_unit_signal_transmission (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.throttle_shut_off_unit ADD COLUMN fk_wastewater_node varchar (16); ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT rel_throttle_shut_off_unit_wastewater_node FOREIGN KEY (fk_wastewater_node) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; @@ -4840,14 +4840,14 @@ ALTER TABLE qgep_vl.prank_weir_weir_edge ADD CONSTRAINT pkey_qgep_vl_prank_weir_ INSERT INTO qgep_vl.prank_weir_weir_edge (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (349,349,'sharp_edged','scharfkantig','arete_vive', 'zzz_scharfkantig', 'margini_ascutite', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.prank_weir_weir_edge (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3014,3014,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.prank_weir ADD CONSTRAINT fkey_vl_prank_weir_weir_edge FOREIGN KEY (weir_edge) - REFERENCES qgep_vl.prank_weir_weir_edge (code) MATCH SIMPLE + REFERENCES qgep_vl.prank_weir_weir_edge (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.prank_weir_weir_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.prank_weir_weir_kind ADD CONSTRAINT pkey_qgep_vl_prank_weir_weir_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.prank_weir_weir_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5772,5772,'raised','hochgezogen','a_seuil_sureleve', 'laterale_alto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.prank_weir_weir_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5771,5771,'low','niedrig','a_seuil_abaisse', 'laterale_basso', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.prank_weir ADD CONSTRAINT fkey_vl_prank_weir_weir_kind FOREIGN KEY (weir_kind) - REFERENCES qgep_vl.prank_weir_weir_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.prank_weir_weir_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.pump ADD CONSTRAINT oorel_od_pump_overflow FOREIGN KEY (obj_id) REFERENCES qgep_od.overflow(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.pump_construction_type () INHERITS (qgep_sys.value_list_base); @@ -4860,7 +4860,7 @@ ALTER TABLE qgep_vl.pump_construction_type ADD CONSTRAINT pkey_qgep_vl_pump_cont INSERT INTO qgep_vl.pump_construction_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3082,3082,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.pump_construction_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2661,2661,'vacuum_system','Vakuumanlage','systeme_a_vide_d_air', 'impinato_a_vuoto_aria', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.pump ADD CONSTRAINT fkey_vl_pump_construction_type FOREIGN KEY (construction_type) - REFERENCES qgep_vl.pump_construction_type (code) MATCH SIMPLE + REFERENCES qgep_vl.pump_construction_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.pump_placement_of_actuation () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.pump_placement_of_actuation ADD CONSTRAINT pkey_qgep_vl_pump_placement_of_actuation_code PRIMARY KEY (code); @@ -4868,7 +4868,7 @@ ALTER TABLE qgep_vl.pump_placement_of_actuation ADD CONSTRAINT pkey_qgep_vl_pump INSERT INTO qgep_vl.pump_placement_of_actuation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (311,311,'dry','trocken','non_submersible', 'zzz_trocken', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.pump_placement_of_actuation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3070,3070,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.pump ADD CONSTRAINT fkey_vl_pump_placement_of_actuation FOREIGN KEY (placement_of_actuation) - REFERENCES qgep_vl.pump_placement_of_actuation (code) MATCH SIMPLE + REFERENCES qgep_vl.pump_placement_of_actuation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.pump_placement_of_pump () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.pump_placement_of_pump ADD CONSTRAINT pkey_qgep_vl_pump_placement_of_pump_code PRIMARY KEY (code); @@ -4876,7 +4876,7 @@ ALTER TABLE qgep_vl.pump_placement_of_pump ADD CONSTRAINT pkey_qgep_vl_pump_plac INSERT INTO qgep_vl.pump_placement_of_pump (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3071,3071,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.pump_placement_of_pump (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (363,363,'vertical','vertikal','vertical', 'zzz_vertikal', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.pump ADD CONSTRAINT fkey_vl_pump_placement_of_pump FOREIGN KEY (placement_of_pump) - REFERENCES qgep_vl.pump_placement_of_pump (code) MATCH SIMPLE + REFERENCES qgep_vl.pump_placement_of_pump (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.pump_usage_current () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.pump_usage_current ADD CONSTRAINT pkey_qgep_vl_pump_usage_current_code PRIMARY KEY (code); @@ -4890,7 +4890,7 @@ ALTER TABLE qgep_vl.pump_usage_current ADD CONSTRAINT pkey_qgep_vl_pump_usage_cu INSERT INTO qgep_vl.pump_usage_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6206,6206,'wastewater','Schmutzabwasser','eaux_usees', 'acque_luride', '', '', 'SW', 'EU', '', '', 'true'); INSERT INTO qgep_vl.pump_usage_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6326,6326,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.pump ADD CONSTRAINT fkey_vl_pump_usage_current FOREIGN KEY (usage_current) - REFERENCES qgep_vl.pump_usage_current (code) MATCH SIMPLE + REFERENCES qgep_vl.pump_usage_current (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.leapingweir ADD CONSTRAINT oorel_od_leapingweir_overflow FOREIGN KEY (obj_id) REFERENCES qgep_od.overflow(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.leapingweir_opening_shape () INHERITS (qgep_sys.value_list_base); @@ -4901,7 +4901,7 @@ ALTER TABLE qgep_vl.leapingweir_opening_shape ADD CONSTRAINT pkey_qgep_vl_leapin INSERT INTO qgep_vl.leapingweir_opening_shape (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3583,3583,'rectangular','Rechteck','rectangulaire', 'zzz_Rechteck', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.leapingweir_opening_shape (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3584,3584,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.leapingweir ADD CONSTRAINT fkey_vl_leapingweir_opening_shape FOREIGN KEY (opening_shape) - REFERENCES qgep_vl.leapingweir_opening_shape (code) MATCH SIMPLE + REFERENCES qgep_vl.leapingweir_opening_shape (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.hydraulic_char_data_is_overflowing () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.hydraulic_char_data_is_overflowing ADD CONSTRAINT pkey_qgep_vl_hydraulic_char_data_is_overflowing_code PRIMARY KEY (code); @@ -4909,7 +4909,7 @@ ALTER TABLE qgep_vl.hydraulic_char_data_is_overflowing ADD CONSTRAINT pkey_qgep_ INSERT INTO qgep_vl.hydraulic_char_data_is_overflowing (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5775,5775,'no','nein','non', 'no', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.hydraulic_char_data_is_overflowing (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5778,5778,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT fkey_vl_hydraulic_char_data_is_overflowing FOREIGN KEY (is_overflowing) - REFERENCES qgep_vl.hydraulic_char_data_is_overflowing (code) MATCH SIMPLE + REFERENCES qgep_vl.hydraulic_char_data_is_overflowing (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.hydraulic_char_data_main_weir_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.hydraulic_char_data_main_weir_kind ADD CONSTRAINT pkey_qgep_vl_hydraulic_char_data_main_weir_kind_code PRIMARY KEY (code); @@ -4917,7 +4917,7 @@ ALTER TABLE qgep_vl.hydraulic_char_data_main_weir_kind ADD CONSTRAINT pkey_qgep_ INSERT INTO qgep_vl.hydraulic_char_data_main_weir_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6420,6420,'spillway_raised','Streichwehr_hochgezogen','deversoir_lateral_a_seuil_sureleve', 'stramazzo_laterale_alto', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.hydraulic_char_data_main_weir_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6421,6421,'spillway_low','Streichwehr_niedrig','deversoir_lateral_a_seuil_abaisse', 'stamazzo_laterale_basso', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT fkey_vl_hydraulic_char_data_main_weir_kind FOREIGN KEY (main_weir_kind) - REFERENCES qgep_vl.hydraulic_char_data_main_weir_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.hydraulic_char_data_main_weir_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.hydraulic_char_data_pump_characteristics () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.hydraulic_char_data_pump_characteristics ADD CONSTRAINT pkey_qgep_vl_hydraulic_char_data_pump_characteristics_code PRIMARY KEY (code); @@ -4927,7 +4927,7 @@ ALTER TABLE qgep_vl.hydraulic_char_data_pump_characteristics ADD CONSTRAINT pkey INSERT INTO qgep_vl.hydraulic_char_data_pump_characteristics (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6377,6377,'parallel','parallel','parallele', 'parallelo', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.hydraulic_char_data_pump_characteristics (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6378,6378,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT fkey_vl_hydraulic_char_data_pump_characteristics FOREIGN KEY (pump_characteristics) - REFERENCES qgep_vl.hydraulic_char_data_pump_characteristics (code) MATCH SIMPLE + REFERENCES qgep_vl.hydraulic_char_data_pump_characteristics (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.hydraulic_char_data_pump_usage_current () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.hydraulic_char_data_pump_usage_current ADD CONSTRAINT pkey_qgep_vl_hydraulic_char_data_pump_usage_current_code PRIMARY KEY (code); @@ -4941,7 +4941,7 @@ ALTER TABLE qgep_vl.hydraulic_char_data_pump_usage_current ADD CONSTRAINT pkey_q INSERT INTO qgep_vl.hydraulic_char_data_pump_usage_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6368,6368,'wastewater','Schmutzabwasser','eaux_usees', 'acque_luride', '', '', 'SW', 'EU', '', '', 'true'); INSERT INTO qgep_vl.hydraulic_char_data_pump_usage_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6369,6369,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT fkey_vl_hydraulic_char_data_pump_usage_current FOREIGN KEY (pump_usage_current) - REFERENCES qgep_vl.hydraulic_char_data_pump_usage_current (code) MATCH SIMPLE + REFERENCES qgep_vl.hydraulic_char_data_pump_usage_current (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.hydraulic_char_data_status () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.hydraulic_char_data_status ADD CONSTRAINT pkey_qgep_vl_hydraulic_char_data_status_code PRIMARY KEY (code); @@ -4949,7 +4949,7 @@ ALTER TABLE qgep_vl.hydraulic_char_data_status ADD CONSTRAINT pkey_qgep_vl_hydra INSERT INTO qgep_vl.hydraulic_char_data_status (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6372,6372,'current','Ist','actuel', 'attuale', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.hydraulic_char_data_status (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6373,6373,'current_optimized','Ist_optimiert','actuel_opt', 'attuale_ottimizzato', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT fkey_vl_hydraulic_char_data_status FOREIGN KEY (status) - REFERENCES qgep_vl.hydraulic_char_data_status (code) MATCH SIMPLE + REFERENCES qgep_vl.hydraulic_char_data_status (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.hydraulic_char_data ADD COLUMN fk_wastewater_node varchar (16); ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT rel_hydraulic_char_data_wastewater_node FOREIGN KEY (fk_wastewater_node) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4963,7 +4963,7 @@ ALTER TABLE qgep_vl.backflow_prevention_kind ADD CONSTRAINT pkey_qgep_vl_backflo INSERT INTO qgep_vl.backflow_prevention_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5757,5757,'backflow_flap','Rueckstauklappe','clapet_de_non_retour_a_battant', 'zzz_Rueckstauklappe', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.backflow_prevention_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5758,5758,'gate_shield','Stauschild','plaque_de_retenue', 'paratoia_cilindrica', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.backflow_prevention ADD CONSTRAINT fkey_vl_backflow_prevention_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.backflow_prevention_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.backflow_prevention_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.backflow_prevention ADD COLUMN fk_throttle_shut_off_unit varchar (16); ALTER TABLE qgep_od.backflow_prevention ADD CONSTRAINT rel_backflow_prevention_throttle_shut_off_unit FOREIGN KEY (fk_throttle_shut_off_unit) REFERENCES qgep_od.throttle_shut_off_unit(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -4979,7 +4979,7 @@ ALTER TABLE qgep_vl.solids_retention_type ADD CONSTRAINT pkey_qgep_vl_solids_ret INSERT INTO qgep_vl.solids_retention_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5668,5668,'scumboard','Tauchwand','paroi_plongeante', 'parete_sommersa', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.solids_retention_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5669,5669,'unknown','unbekannt','inconnu', 'sconosciuto', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.solids_retention ADD CONSTRAINT fkey_vl_solids_retention_type FOREIGN KEY (type) - REFERENCES qgep_vl.solids_retention_type (code) MATCH SIMPLE + REFERENCES qgep_vl.solids_retention_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.tank_cleaning ADD CONSTRAINT oorel_od_tank_cleaning_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.tank_cleaning_type () INHERITS (qgep_sys.value_list_base); @@ -4990,7 +4990,7 @@ ALTER TABLE qgep_vl.tank_cleaning_type ADD CONSTRAINT pkey_qgep_vl_tank_cleaning INSERT INTO qgep_vl.tank_cleaning_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5623,5623,'surge_flushing','Schwallspuelung','rincage_en_cascade', 'zzz_Schwallspülung', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.tank_cleaning_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5624,5624,'tipping_bucket','Spuelkippe','bac_de_rincage', 'zzz_Spuelkippe', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.tank_cleaning ADD CONSTRAINT fkey_vl_tank_cleaning_type FOREIGN KEY (type) - REFERENCES qgep_vl.tank_cleaning_type (code) MATCH SIMPLE + REFERENCES qgep_vl.tank_cleaning_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.tank_emptying ADD CONSTRAINT oorel_od_tank_emptying_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.tank_emptying_type () INHERITS (qgep_sys.value_list_base); @@ -5000,7 +5000,7 @@ ALTER TABLE qgep_vl.tank_emptying_type ADD CONSTRAINT pkey_qgep_vl_tank_emptying INSERT INTO qgep_vl.tank_emptying_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5628,5628,'pump','Pumpe','pompe', 'pompa', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.tank_emptying_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5629,5629,'valve','Schieber','vanne', 'zzz_Schieber', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.tank_emptying ADD CONSTRAINT fkey_vl_tank_emptying_type FOREIGN KEY (type) - REFERENCES qgep_vl.tank_emptying_type (code) MATCH SIMPLE + REFERENCES qgep_vl.tank_emptying_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.tank_emptying ADD COLUMN fk_throttle_shut_off_unit varchar (16); ALTER TABLE qgep_od.tank_emptying ADD CONSTRAINT rel_tank_emptying_throttle_shut_off_unit FOREIGN KEY (fk_throttle_shut_off_unit) REFERENCES qgep_od.throttle_shut_off_unit(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; @@ -5181,7 +5181,7 @@ ALTER TABLE qgep_vl.wastewater_structure_text_plantype ADD CONSTRAINT pkey_qgep_ INSERT INTO qgep_vl.wastewater_structure_text_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7848,7848,'overviewmap.om5','Uebersichtsplan.UeP5','plan_d_ensemble.pe5', 'piano_di_insieme.pi5', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_text_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7845,7845,'network_plan','Werkplan','plan_de_reseau', '', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure_text ADD CONSTRAINT fkey_vl_wastewater_structure_text_plantype FOREIGN KEY (plantype) - REFERENCES qgep_vl.wastewater_structure_text_plantype (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_text_plantype (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.wastewater_structure_text_texthali () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wastewater_structure_text_texthali ADD CONSTRAINT pkey_qgep_vl_wastewater_structure_text_texthali_code PRIMARY KEY (code); @@ -5189,7 +5189,7 @@ ALTER TABLE qgep_vl.wastewater_structure_text_texthali ADD CONSTRAINT pkey_qgep_ INSERT INTO qgep_vl.wastewater_structure_text_texthali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7851,7851,'1','1','1', '1', '1', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_text_texthali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7852,7852,'2','2','2', '2', '2', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure_text ADD CONSTRAINT fkey_vl_wastewater_structure_text_texthali FOREIGN KEY (texthali) - REFERENCES qgep_vl.wastewater_structure_text_texthali (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_text_texthali (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.wastewater_structure_text_textvali () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wastewater_structure_text_textvali ADD CONSTRAINT pkey_qgep_vl_wastewater_structure_text_textvali_code PRIMARY KEY (code); @@ -5199,7 +5199,7 @@ ALTER TABLE qgep_vl.wastewater_structure_text_textvali ADD CONSTRAINT pkey_qgep_ INSERT INTO qgep_vl.wastewater_structure_text_textvali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7856,7856,'3','3','3', '3', '3', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_text_textvali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7857,7857,'4','4','4', '4', '4', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure_text ADD CONSTRAINT fkey_vl_wastewater_structure_text_textvali FOREIGN KEY (textvali) - REFERENCES qgep_vl.wastewater_structure_text_textvali (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_text_textvali (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_text_plantype () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_text_plantype ADD CONSTRAINT pkey_qgep_vl_reach_text_plantype_code PRIMARY KEY (code); @@ -5209,7 +5209,7 @@ ALTER TABLE qgep_vl.reach_text_plantype ADD CONSTRAINT pkey_qgep_vl_reach_text_p INSERT INTO qgep_vl.reach_text_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7848,7848,'overviewmap.om5','Uebersichtsplan.UeP5','plan_d_ensemble.pe5', 'piano_di_insieme.pi5', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.reach_text_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7845,7845,'network_plan','Werkplan','plan_de_reseau', '', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.reach_text ADD CONSTRAINT fkey_vl_reach_text_plantype FOREIGN KEY (plantype) - REFERENCES qgep_vl.reach_text_plantype (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_text_plantype (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_text_texthali () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_text_texthali ADD CONSTRAINT pkey_qgep_vl_reach_text_texthali_code PRIMARY KEY (code); @@ -5217,7 +5217,7 @@ ALTER TABLE qgep_vl.reach_text_texthali ADD CONSTRAINT pkey_qgep_vl_reach_text_t INSERT INTO qgep_vl.reach_text_texthali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7851,7851,'1','1','1', '1', '1', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.reach_text_texthali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7852,7852,'2','2','2', '2', '2', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.reach_text ADD CONSTRAINT fkey_vl_reach_text_texthali FOREIGN KEY (texthali) - REFERENCES qgep_vl.reach_text_texthali (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_text_texthali (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.reach_text_textvali () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_text_textvali ADD CONSTRAINT pkey_qgep_vl_reach_text_textvali_code PRIMARY KEY (code); @@ -5227,7 +5227,7 @@ ALTER TABLE qgep_vl.reach_text_textvali ADD CONSTRAINT pkey_qgep_vl_reach_text_t INSERT INTO qgep_vl.reach_text_textvali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7856,7856,'3','3','3', '3', '3', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.reach_text_textvali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7857,7857,'4','4','4', '4', '4', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.reach_text ADD CONSTRAINT fkey_vl_reach_text_textvali FOREIGN KEY (textvali) - REFERENCES qgep_vl.reach_text_textvali (code) MATCH SIMPLE + REFERENCES qgep_vl.reach_text_textvali (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_text_plantype () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_text_plantype ADD CONSTRAINT pkey_qgep_vl_catchment_area_text_plantype_code PRIMARY KEY (code); @@ -5237,7 +5237,7 @@ ALTER TABLE qgep_vl.catchment_area_text_plantype ADD CONSTRAINT pkey_qgep_vl_cat INSERT INTO qgep_vl.catchment_area_text_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7848,7848,'overviewmap.om5','Uebersichtsplan.UeP5','plan_d_ensemble.pe5', 'piano_di_insieme.pi5', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_text_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7845,7845,'network_plan','Werkplan','plan_de_reseau', '', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area_text ADD CONSTRAINT fkey_vl_catchment_area_text_plantype FOREIGN KEY (plantype) - REFERENCES qgep_vl.catchment_area_text_plantype (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_text_plantype (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_text_texthali () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_text_texthali ADD CONSTRAINT pkey_qgep_vl_catchment_area_text_texthali_code PRIMARY KEY (code); @@ -5245,7 +5245,7 @@ ALTER TABLE qgep_vl.catchment_area_text_texthali ADD CONSTRAINT pkey_qgep_vl_cat INSERT INTO qgep_vl.catchment_area_text_texthali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7851,7851,'1','1','1', '1', '1', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_text_texthali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7852,7852,'2','2','2', '2', '2', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area_text ADD CONSTRAINT fkey_vl_catchment_area_text_texthali FOREIGN KEY (texthali) - REFERENCES qgep_vl.catchment_area_text_texthali (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_text_texthali (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.catchment_area_text_textvali () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_text_textvali ADD CONSTRAINT pkey_qgep_vl_catchment_area_text_textvali_code PRIMARY KEY (code); @@ -5255,7 +5255,7 @@ ALTER TABLE qgep_vl.catchment_area_text_textvali ADD CONSTRAINT pkey_qgep_vl_cat INSERT INTO qgep_vl.catchment_area_text_textvali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7856,7856,'3','3','3', '3', '3', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.catchment_area_text_textvali (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7857,7857,'4','4','4', '4', '4', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.catchment_area_text ADD CONSTRAINT fkey_vl_catchment_area_text_textvali FOREIGN KEY (textvali) - REFERENCES qgep_vl.catchment_area_text_textvali (code) MATCH SIMPLE + REFERENCES qgep_vl.catchment_area_text_textvali (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.wastewater_structure_symbol_plantype () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wastewater_structure_symbol_plantype ADD CONSTRAINT pkey_qgep_vl_wastewater_structure_symbol_plantype_code PRIMARY KEY (code); @@ -5265,7 +5265,7 @@ ALTER TABLE qgep_vl.wastewater_structure_symbol_plantype ADD CONSTRAINT pkey_qge INSERT INTO qgep_vl.wastewater_structure_symbol_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7878,7878,'overviewmap.om5','Uebersichtsplan.UeP5','plan_d_ensemble.pe5', 'piano_di_insieme.pi5', '', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.wastewater_structure_symbol_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7875,7875,'network_plan','Werkplan','plan_de_reseau', 'zzz_Werkplan', '', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.wastewater_structure_symbol ADD CONSTRAINT fkey_vl_wastewater_structure_symbol_plantype FOREIGN KEY (plantype) - REFERENCES qgep_vl.wastewater_structure_symbol_plantype (code) MATCH SIMPLE + REFERENCES qgep_vl.wastewater_structure_symbol_plantype (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; --------- Relations to class organisation for dataowner and provider (new 3.11.2014); diff --git a/04_vsa_kek_extension.sql b/04_vsa_kek_extension.sql index 867f4840b..a61aa552f 100644 --- a/04_vsa_kek_extension.sql +++ b/04_vsa_kek_extension.sql @@ -226,7 +226,7 @@ ALTER TABLE qgep_vl.examination_recording_type ADD CONSTRAINT pkey_qgep_vl_exami INSERT INTO qgep_vl.examination_recording_type (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3686,3686,'channel_TV','Kanalfernsehen','camera_canalisations', '', '', '', 'true'); INSERT INTO qgep_vl.examination_recording_type (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3687,3687,'unknown','unbekannt','inconnu', '', '', '', 'true'); ALTER TABLE qgep_od.examination ADD CONSTRAINT fkey_vl_examination_recording_type FOREIGN KEY (recording_type) - REFERENCES qgep_vl.examination_recording_type (code) MATCH SIMPLE + REFERENCES qgep_vl.examination_recording_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.examination_weather () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.examination_weather ADD CONSTRAINT pkey_qgep_vl_examination_weather_code PRIMARY KEY (code); @@ -237,7 +237,7 @@ ALTER TABLE qgep_vl.examination_weather ADD CONSTRAINT pkey_qgep_vl_examination_ INSERT INTO qgep_vl.examination_weather (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3703,3703,'nice_dry','schoen_trocken','beau_sec', '', '', '', 'true'); INSERT INTO qgep_vl.examination_weather (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3704,3704,'unknown','unbekannt','inconnu', '', '', '', 'true'); ALTER TABLE qgep_od.examination ADD CONSTRAINT fkey_vl_examination_weather FOREIGN KEY (weather) - REFERENCES qgep_vl.examination_weather (code) MATCH SIMPLE + REFERENCES qgep_vl.examination_weather (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.examination ADD COLUMN fk_reach_point varchar (16); ALTER TABLE qgep_od.examination ADD CONSTRAINT rel_examination_reach_point FOREIGN KEY (fk_reach_point) REFERENCES qgep_od.reach_point(obj_id) ON UPDATE CASCADE ON DELETE set null; @@ -246,7 +246,7 @@ ALTER TABLE qgep_vl.damage_connection ADD CONSTRAINT pkey_qgep_vl_damage_connect INSERT INTO qgep_vl.damage_connection (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (8498,8498,'yes','ja','oui', '', '', '', 'true'); INSERT INTO qgep_vl.damage_connection (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (8499,8499,'no','nein','non', '', '', '', 'true'); ALTER TABLE qgep_od.damage ADD CONSTRAINT fkey_vl_damage_connection FOREIGN KEY (connection) - REFERENCES qgep_vl.damage_connection (code) MATCH SIMPLE + REFERENCES qgep_vl.damage_connection (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.damage_single_damage_class () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.damage_single_damage_class ADD CONSTRAINT pkey_qgep_vl_damage_single_damage_class_code PRIMARY KEY (code); @@ -257,7 +257,7 @@ ALTER TABLE qgep_vl.damage_single_damage_class ADD CONSTRAINT pkey_qgep_vl_damag INSERT INTO qgep_vl.damage_single_damage_class (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3711,3711,'EZ4','EZ4','EZ4', '', '', '', 'true'); INSERT INTO qgep_vl.damage_single_damage_class (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (4561,4561,'unknown','unbekannt','inconnu', '', '', '', 'true'); ALTER TABLE qgep_od.damage ADD CONSTRAINT fkey_vl_damage_single_damage_class FOREIGN KEY (single_damage_class) - REFERENCES qgep_vl.damage_single_damage_class (code) MATCH SIMPLE + REFERENCES qgep_vl.damage_single_damage_class (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.damage_channel ADD CONSTRAINT oorel_od_damage_channel_damage FOREIGN KEY (obj_id) REFERENCES qgep_od.damage(obj_id) ON DELETE cascade; CREATE TABLE qgep_vl.damage_channel_channel_damage_code () INHERITS (qgep_sys.value_list_base); @@ -575,20 +575,20 @@ ALTER TABLE qgep_vl.damage_channel_channel_damage_code ADD CONSTRAINT pkey_qgep_ INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8894,8894,'BDCZD','BDCZD','BDCZD', 'BDCZD', 'BDCZD', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8895,8895,'BDCZE','BDCZE','BDCZE', 'BDCZE', 'BDCZE', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8896,8896,'BDCZZ','BDCZZ','BDCZZ', 'BDCZZ', 'BDCZZ', '', '', '', '', '', 'true'); - INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8897,8897,'BDDC','BDDC','BDDC', 'BDDC', 'BDDC', '', '', '', '', '', 'true'); - INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8898,8898,'BDDD','BDDD','BDDD', 'BDDD', 'BDDD', '', '', '', '', '', 'true'); - INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8899,8899,'BDDE','BDDE','BDDE', 'BDDE', 'BDDE', '', '', '', '', '', 'true'); + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8897,8897,'BDDC','BDDC','BDDC', 'BDDC', 'BDDC', '', '', '', '', '', 'true'); + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8898,8898,'BDDD','BDDD','BDDD', 'BDDD', 'BDDD', '', '', '', '', '', 'true'); + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8899,8899,'BDDE','BDDE','BDDE', 'BDDE', 'BDDE', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8900,8900,'BDECA','BDECA','BDECA', 'BDECA', 'BDECA', '', '', '', '', '', 'true'); - INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8901,8901,'BDECB','BDECB','BDECB', 'BDECB', 'BDECB', '', '', '', '', '', 'true'); + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8901,8901,'BDECB','BDECB','BDECB', 'BDECB', 'BDECB', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8902,8902,'BDECC','BDECC','BDECC', 'BDECC', 'BDECC', '', '', '', '', '', 'true'); - INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8903,8903,'BDEDA','BDEDA','BDEDA', 'BDEDA', 'BDEDA', '', '', '', '', '', 'true'); + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8903,8903,'BDEDA','BDEDA','BDEDA', 'BDEDA', 'BDEDA', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8904,8904,'BDEDB','BDEDB','BDEDB', 'BDEDB', 'BDEDB', '', '', '', '', '', 'true'); - INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8905,8905,'BDEDC','BDEDC','BDEDC', 'BDEDC', 'BDEDC', '', '', '', '', '', 'true'); - INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8906,8906,'BDEEA','BDEEA','BDEEA', 'BDEEA', 'BDEEA', '', '', '', '', '', 'true'); - INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8907,8907,'BDEEB','BDEEB','BDEEB', 'BDEEB', 'BDEEB', '', '', '', '', '', 'true'); + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8905,8905,'BDEDC','BDEDC','BDEDC', 'BDEDC', 'BDEDC', '', '', '', '', '', 'true'); + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8906,8906,'BDEEA','BDEEA','BDEEA', 'BDEEA', 'BDEEA', '', '', '', '', '', 'true'); + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8907,8907,'BDEEB','BDEEB','BDEEB', 'BDEEB', 'BDEEB', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8908,8908,'BDEEC','BDEEC','BDEEC', 'BDEEC', 'BDEEC', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.damage_channel ADD CONSTRAINT fkey_vl_damage_channel_channel_damage_code FOREIGN KEY (channel_damage_code) - REFERENCES qgep_vl.damage_channel_channel_damage_code (code) MATCH SIMPLE + REFERENCES qgep_vl.damage_channel_channel_damage_code (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.damage_manhole ADD CONSTRAINT oorel_od_damage_manhole_damage FOREIGN KEY (obj_id) REFERENCES qgep_od.damage(obj_id) ON DELETE cascade; CREATE TABLE qgep_vl.damage_manhole_manhole_damage_code () INHERITS (qgep_sys.value_list_base); @@ -930,9 +930,9 @@ ALTER TABLE qgep_vl.damage_manhole_manhole_damage_code ADD CONSTRAINT pkey_qgep_ INSERT INTO qgep_vl.damage_manhole_manhole_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8970,8970,'DDEDC','DDEDC','DDEDC', 'DDEDC', 'DDEDC', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_manhole_manhole_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8971,8971,'DDEEA','DDEEA','DDEEA', 'DDEEA', 'DDEEA', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_manhole_manhole_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8972,8972,'DDEEB','DDEEB','DDEEB', 'DDEEB', 'DDEEB', '', '', '', '', '', 'true'); - INSERT INTO qgep_vl.damage_manhole_manhole_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8973,8973,'DDEEC','DDEEC','DDEEC', 'DDEEC', 'DDEEC', '', '', '', '', '', 'true'); + INSERT INTO qgep_vl.damage_manhole_manhole_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8973,8973,'DDEEC','DDEEC','DDEEC', 'DDEEC', 'DDEEC', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.damage_manhole ADD CONSTRAINT fkey_vl_damage_manhole_manhole_damage_code FOREIGN KEY (manhole_damage_code) - REFERENCES qgep_vl.damage_manhole_manhole_damage_code (code) MATCH SIMPLE + REFERENCES qgep_vl.damage_manhole_manhole_damage_code (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.damage_manhole_manhole_shaft_area () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.damage_manhole_manhole_shaft_area ADD CONSTRAINT pkey_qgep_vl_damage_manhole_manhole_shaft_area_code PRIMARY KEY (code); @@ -944,7 +944,7 @@ ALTER TABLE qgep_vl.damage_manhole_manhole_shaft_area ADD CONSTRAINT pkey_qgep_v INSERT INTO qgep_vl.damage_manhole_manhole_shaft_area (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3748,3748,'I','I','I', '', '', '', 'true'); INSERT INTO qgep_vl.damage_manhole_manhole_shaft_area (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3749,3749,'J','J','J', '', '', '', 'true'); ALTER TABLE qgep_od.damage_manhole ADD CONSTRAINT fkey_vl_damage_manhole_manhole_shaft_area FOREIGN KEY (manhole_shaft_area) - REFERENCES qgep_vl.damage_manhole_manhole_shaft_area (code) MATCH SIMPLE + REFERENCES qgep_vl.damage_manhole_manhole_shaft_area (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.data_media_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.data_media_kind ADD CONSTRAINT pkey_qgep_vl_data_media_kind_code PRIMARY KEY (code); @@ -956,7 +956,7 @@ ALTER TABLE qgep_vl.data_media_kind ADD CONSTRAINT pkey_qgep_vl_data_media_kind_ INSERT INTO qgep_vl.data_media_kind (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3789,3789,'server','Server','serveur', '', '', '', 'true'); INSERT INTO qgep_vl.data_media_kind (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3790,3790,'videotape','Videoband','bande_video', '', '', '', 'true'); ALTER TABLE qgep_od.data_media ADD CONSTRAINT fkey_vl_data_media_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.data_media_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.data_media_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.file ADD COLUMN fk_data_media varchar(16); ALTER TABLE qgep_od.file ADD CONSTRAINT rel_file_data_media FOREIGN KEY (fk_data_media) REFERENCES qgep_od.data_media(obj_id) ON UPDATE CASCADE ON DELETE set null; @@ -1054,7 +1054,7 @@ ALTER TABLE qgep_vl.file_class ADD CONSTRAINT pkey_qgep_vl_file_class_code PRIMA INSERT INTO qgep_vl.file_class (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3890,3890,'water_catchment','Wasserfassung','CAPTAGE', '', '', '', 'true'); INSERT INTO qgep_vl.file_class (code, vsacode, value_en, value_de, value_fr, abbr_en, abbr_de, abbr_fr, active) VALUES (3891,3891,'zone','Zone','ZONE', '', '', '', 'true'); ALTER TABLE qgep_od.file ADD CONSTRAINT fkey_vl_file_class FOREIGN KEY (class) - REFERENCES qgep_vl.file_class (code) MATCH SIMPLE + REFERENCES qgep_vl.file_class (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; CREATE TABLE qgep_vl.file_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.file_kind ADD CONSTRAINT pkey_qgep_vl_file_kind_code PRIMARY KEY (code); @@ -1067,7 +1067,7 @@ ALTER TABLE qgep_vl.file_kind ADD CONSTRAINT pkey_qgep_vl_file_kind_code PRIMARY INSERT INTO qgep_vl.file_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8812,8812,'sketch','Skizze','croquis', 'schizzo', 'rrr_Skizze', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.file_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (9146,9146,'digital_video','digitales_Video','video_numerique', 'video_digitale', 'rrr_digitales_Video', '', '', '', '', '', 'true'); ALTER TABLE qgep_od.file ADD CONSTRAINT fkey_vl_file_kind FOREIGN KEY (kind) - REFERENCES qgep_vl.file_kind (code) MATCH SIMPLE + REFERENCES qgep_vl.file_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; --------- Relations to class organisation for dataowner and provider (new 3.11.2014); diff --git a/05_data_model_extensions.sql b/05_data_model_extensions.sql index d3659049e..8f26c065e 100644 --- a/05_data_model_extensions.sql +++ b/05_data_model_extensions.sql @@ -36,7 +36,7 @@ added solely for QGEP'; -- this column is an extension to the VSA data model and puts the _function_hierarchic in order ALTER TABLE qgep_vl.channel_function_hierarchic ADD COLUMN order_fct_hierarchic smallint; -UPDATE qgep_vl.channel_function_hierarchic +UPDATE qgep_vl.channel_function_hierarchic SET order_fct_hierarchic= array_position( ARRAY[ @@ -45,7 +45,7 @@ SET order_fct_hierarchic= ,5069 --pwwf.main_drain ,5071 --pwwf.collector_sewer ,5062 --pwwf.renovation_conduction - ,5064 --pwwf.residential_drainage + ,5064 --pwwf.residential_drainage ,5072 --pwwf.road_drainage ,5066 --pwwf.other ,5074 --pwwf.unknown diff --git a/06_symbology_functions.sql b/06_symbology_functions.sql index 32fc2f140..d3df58df5 100644 --- a/06_symbology_functions.sql +++ b/06_symbology_functions.sql @@ -40,7 +40,7 @@ FROM( LEFT JOIN qgep_od.wastewater_structure ws_from ON ws_from.obj_id = ne_from.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_from ON CH_from.function_hierarchic = vl_fct_hier_from.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_from ON CH_from.usage_current = vl_usg_curr_from.code - + LEFT JOIN qgep_od.reach re_to ON re_to.fk_reach_point_to = rp.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_to ON ne_to.obj_id = re_to.obj_id @@ -52,7 +52,7 @@ FROM( -- Update by Overflow LEFT JOIN qgep_od.overflow ov ON ov.fk_overflow_to=ne.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov ON ne_ov.obj_id = ov.fk_wastewater_node - + LEFT JOIN qgep_od.reach_point rp_ov_from ON ne_ov.obj_id = rp_ov_from.fk_wastewater_networkelement LEFT JOIN qgep_od.reach re_ov_from ON re_ov_from.fk_reach_point_from = rp_ov_from.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov_from ON ne_ov_from.obj_id = re_ov_from.obj_id @@ -60,7 +60,7 @@ FROM( LEFT JOIN qgep_od.wastewater_structure ws_ov_from ON ws_ov_from.obj_id = ne_ov_from.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_ov_from ON CH_ov_from.function_hierarchic = vl_fct_hier_ov_from.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_ov_from ON CH_ov_from.usage_current = vl_usg_curr_ov_from.code - + LEFT JOIN qgep_od.reach_point rp_ov_to ON ne_ov.obj_id = rp_ov_to.fk_wastewater_networkelement LEFT JOIN qgep_od.reach re_ov_to ON re_ov_to.fk_reach_point_to = rp_ov_to.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov_to ON ne_ov_to.obj_id = re_ov_to.obj_id @@ -68,14 +68,14 @@ FROM( LEFT JOIN qgep_od.wastewater_structure ws_ov_to ON ws_ov_to.obj_id = ne_ov_to.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_ov_to ON CH_ov_to.function_hierarchic = vl_fct_hier_ov_to.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_ov_to ON CH_ov_to.usage_current = vl_usg_curr_ov_to.code - + WHERE _all OR ne.obj_id = _obj_id - WINDOW w AS ( PARTITION BY ne.obj_id + WINDOW w AS ( PARTITION BY ne.obj_id ORDER BY vl_fct_hier_from.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_to.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_ov_from.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_ov_to.order_fct_hierarchic ASC NULLS LAST - + , vl_usg_curr_from.order_usage_current ASC NULLS LAST , vl_usg_curr_to.order_usage_current ASC NULLS LAST , vl_usg_curr_ov_from.order_usage_current ASC NULLS LAST @@ -123,18 +123,18 @@ SELECT DISTINCT ON (ws.obj_id) ws.obj_id AS ws_obj_id, LEFT JOIN qgep_od.channel CH_from ON CH_from.obj_id = ne_from.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_from ON CH_from.function_hierarchic = vl_fct_hier_from.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_from ON CH_from.usage_current = vl_usg_curr_from.code - + LEFT JOIN qgep_od.reach re_to ON re_to.fk_reach_point_to = rp.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_to ON ne_to.obj_id = re_to.obj_id LEFT JOIN qgep_od.channel CH_to ON CH_to.obj_id = ne_to.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_to ON CH_to.function_hierarchic = vl_fct_hier_to.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_to ON CH_to.usage_current = vl_usg_curr_to.code - + -- Update by Overflow LEFT JOIN qgep_od.wastewater_networkelement ne_ws ON ne_ws.fk_wastewater_structure=ws.obj_id LEFT JOIN qgep_od.overflow ov ON ov.fk_overflow_to=ne_ws.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov ON ne_ov.obj_id = ov.fk_wastewater_node - + LEFT JOIN qgep_od.reach_point rp_ov_from ON ne_ov.obj_id = rp_ov_from.fk_wastewater_networkelement LEFT JOIN qgep_od.reach re_ov_from ON re_ov_from.fk_reach_point_from = rp_ov_from.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov_from ON ne_ov_from.obj_id = re_ov_from.obj_id @@ -142,7 +142,7 @@ SELECT DISTINCT ON (ws.obj_id) ws.obj_id AS ws_obj_id, LEFT JOIN qgep_od.wastewater_structure ws_ov_from ON ws_ov_from.obj_id = ne_ov_from.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_ov_from ON CH_ov_from.function_hierarchic = vl_fct_hier_ov_from.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_ov_from ON CH_ov_from.usage_current = vl_usg_curr_ov_from.code - + LEFT JOIN qgep_od.reach_point rp_ov_to ON ne_ov.obj_id = rp_ov_to.fk_wastewater_networkelement LEFT JOIN qgep_od.reach re_ov_to ON re_ov_to.fk_reach_point_to = rp_ov_to.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov_to ON ne_ov_to.obj_id = re_ov_to.obj_id @@ -150,18 +150,18 @@ SELECT DISTINCT ON (ws.obj_id) ws.obj_id AS ws_obj_id, LEFT JOIN qgep_od.wastewater_structure ws_ov_to ON ws_ov_to.obj_id = ne_ov_to.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_ov_to ON CH_ov_to.function_hierarchic = vl_fct_hier_ov_to.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_ov_to ON CH_ov_to.usage_current = vl_usg_curr_ov_to.code - + WHERE _all OR ws.obj_id = _obj_id - WINDOW w AS ( PARTITION BY ws.obj_id + WINDOW w AS ( PARTITION BY ws.obj_id ORDER BY vl_fct_hier_from.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_to.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_ov_from.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_ov_to.order_fct_hierarchic ASC NULLS LAST - + , vl_usg_curr_from.order_usage_current ASC NULLS LAST , vl_usg_curr_to.order_usage_current ASC NULLS LAST - , vl_usg_curr_ov_from.order_usage_current ASC NULLS LAST - , vl_usg_curr_ov_to.order_usage_current ASC NULLS LAST + , vl_usg_curr_ov_from.order_usage_current ASC NULLS LAST + , vl_usg_curr_ov_to.order_usage_current ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) ) symbology_ws WHERE symbology_ws.ws_obj_id = ws.obj_id; @@ -190,7 +190,7 @@ BEGIN WHEN TG_OP = 'DELETE' THEN ch_obj_id = OLD.obj_id; END CASE; - + BEGIN SELECT ws.obj_id, ne.obj_id INTO _ws_from_id, _ne_from_id FROM qgep_od.wastewater_networkelement ch_ne @@ -207,7 +207,7 @@ BEGIN WHEN TOO_MANY_ROWS THEN RAISE EXCEPTION 'TRIGGER ERROR ws_symbology_update_by_channel. Subquery shoud return exactly one row. This is not supposed to happen and indicates an isue with the trigger. The issue must be fixed in QGEP.'; END; - + BEGIN SELECT ws.obj_id, ne.obj_id INTO _ws_to_id, _ne_to_id FROM qgep_od.wastewater_networkelement ch_ne @@ -438,7 +438,7 @@ VOLATILE; ------ 14.9.2022 use idx only when more than one entry /cymed ------ 15.8.2018 uk adapted label display only for primary wastwater system ------ WHERE (_all OR NE.fk_wastewater_structure = _obj_id) and CH_to.function_hierarchic in (5062,5064,5066,5068,5069,5070,5071,5072,5074) ----label only reaches with function_hierarchic=pwwf.* - + CREATE OR REPLACE FUNCTION qgep_od.update_wastewater_structure_label(_obj_id text, _all boolean default false) @@ -468,7 +468,7 @@ SELECT ws_obj_id, SELECT ws.obj_id AS ws_obj_id, ws.identifier AS ws_identifier, parts.co_level AS co_level, parts.rpi_level AS rpi_level, parts.rpo_level AS rpo_level, parts.obj_id, idx, bottom_level AS bottom_level FROM qgep_od.wastewater_structure WS - LEFT JOIN ( + LEFT JOIN ( SELECT coalesce(round(CO.level, 2)::text, '?') AS co_level, NULL::text AS rpi_level, NULL::text AS rpo_level, SP.fk_wastewater_structure ws, SP.obj_id, row_number() OVER(PARTITION BY SP.fk_wastewater_structure) AS idx, NULL::text AS bottom_level FROM qgep_od.structure_part SP RIGHT JOIN qgep_od.cover CO ON CO.obj_id = SP.obj_id @@ -484,12 +484,12 @@ SELECT ws_obj_id, WHERE (_all OR NE.fk_wastewater_structure = _obj_id) and CH_to.function_hierarchic in (5062,5064,5066,5068,5069,5070,5071,5072,5074) ----label only reaches with function_hierarchic=pwwf.* -- Outputs UNION - SELECT NULL AS co_level, NULL::text AS rpi_level, - coalesce(round(RP.level, 2)::text, '?') AS rpo_level, - NE.fk_wastewater_structure ws, RP.obj_id, - row_number() OVER(PARTITION BY NE.fk_wastewater_structure + SELECT NULL AS co_level, NULL::text AS rpi_level, + coalesce(round(RP.level, 2)::text, '?') AS rpo_level, + NE.fk_wastewater_structure ws, RP.obj_id, + row_number() OVER(PARTITION BY NE.fk_wastewater_structure ORDER BY array_position(ARRAY[4522,4526,4524,4516,4514,4518,520,4571,5322], ch.usage_current), - ST_Azimuth(RP.situation_geometry,ST_PointN(RE_from.progression_geometry,2))/pi()*180 ASC), + ST_Azimuth(RP.situation_geometry,ST_PointN(RE_from.progression_geometry,2))/pi()*180 ASC), NULL::text AS bottom_level FROM qgep_od.reach_point RP LEFT JOIN qgep_od.wastewater_networkelement NE ON RP.fk_wastewater_networkelement = NE.obj_id diff --git a/07_network_tracking.sql b/07_network_tracking.sql index 95b277ac9..6b69911e3 100644 --- a/07_network_tracking.sql +++ b/07_network_tracking.sql @@ -133,4 +133,3 @@ BEGIN END; $body$ LANGUAGE plpgsql; - diff --git a/12_1_roles.sql b/12_1_roles.sql index 4be9e75a7..722c826a1 100644 --- a/12_1_roles.sql +++ b/12_1_roles.sql @@ -64,4 +64,3 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA qgep_od REVOKE ALL ON TABLES FROM qgep_view ALTER DEFAULT PRIVILEGES IN SCHEMA qgep_sys REVOKE ALL ON TABLES FROM qgep_viewer; ALTER DEFAULT PRIVILEGES IN SCHEMA qgep_vl REVOKE ALL ON TABLES FROM qgep_viewer; */ - diff --git a/14_geometry_functions.sql b/14_geometry_functions.sql index e5b4fc527..2480cfe9a 100644 --- a/14_geometry_functions.sql +++ b/14_geometry_functions.sql @@ -17,7 +17,7 @@ BEGIN WHEN TG_OP = 'UPDATE' THEN IF NEW.bottom_level <> OLD.bottom_level OR (NEW.bottom_level IS NULL AND OLD.bottom_level IS NOT NULL) OR (NEW.bottom_level IS NOT NULL AND OLD.bottom_level IS NULL) THEN NEW.situation_geometry = ST_SetSRID( ST_MakePoint( ST_X(NEW.situation_geometry), ST_Y(NEW.situation_geometry), COALESCE(NEW.bottom_level,'NaN') ), %1$s); - ELSE + ELSE IF ST_Z(NEW.situation_geometry) <> ST_Z(OLD.situation_geometry) THEN NEW.bottom_level = NULLIF(ST_Z(NEW.situation_geometry),'NaN'); END IF; @@ -59,7 +59,7 @@ BEGIN WHEN TG_OP = 'UPDATE' THEN IF NEW.level <> OLD.level OR (NEW.level IS NULL AND OLD.level IS NOT NULL) OR (NEW.level IS NOT NULL AND OLD.level IS NULL) THEN NEW.situation_geometry = ST_SetSRID( ST_MakePoint( ST_X(NEW.situation_geometry), ST_Y(NEW.situation_geometry), COALESCE(NEW.level,'NaN') ), %1$s); - ELSE + ELSE IF ST_Z(NEW.situation_geometry) <> ST_Z(OLD.situation_geometry) THEN NEW.level = NULLIF(ST_Z(NEW.situation_geometry),'NaN'); END IF; @@ -86,4 +86,4 @@ CREATE TRIGGER synchronize_level_with_altitude ----------------------------------------------- -- Synchronize reach and reach_point GEOMETRY with level qgep_od.vw_qgep_reach is implemented in vw_qgep_reach.sql ----------------------------------------------- ------------------------------------------------ \ No newline at end of file +----------------------------------------------- diff --git a/50_maintenance_zones.sql b/50_maintenance_zones.sql index 895bd1da8..dfb042e0d 100644 --- a/50_maintenance_zones.sql +++ b/50_maintenance_zones.sql @@ -1,3 +1,2 @@ ALTER TABLE qgep_od.maintenance_event ADD COLUMN active_zone VARCHAR(1); COMMENT ON COLUMN qgep_od.maintenance_event.active_zone IS 'ID of the active zone, for visualization purpose (use A, B, C, D, E, F, G and H)'; - diff --git a/VSA_DSS_2008_1.imd b/VSA_DSS_2008_1.imd index 8920303da..fdb2eb800 100644 --- a/VSA_DSS_2008_1.imd +++ b/VSA_DSS_2008_1.imd @@ -4120,4 +4120,4 @@ Erhaltungsereignis_AbwasserbauwerkAbwasserbauwerkfalsefalseAssociationtrue - \ No newline at end of file + diff --git a/delta/delta_1.0.1_prefix_reach_view.sql b/delta/delta_1.0.1_prefix_reach_view.sql index 027b7d63f..e0ac49d1e 100644 --- a/delta/delta_1.0.1_prefix_reach_view.sql +++ b/delta/delta_1.0.1_prefix_reach_view.sql @@ -1 +1 @@ -SELECT 1; \ No newline at end of file +SELECT 1; diff --git a/delta/delta_1.1.0_fix_dictionary_od_table.sql b/delta/delta_1.1.0_fix_dictionary_od_table.sql index 498852b45..1692caab6 100644 --- a/delta/delta_1.1.0_fix_dictionary_od_table.sql +++ b/delta/delta_1.1.0_fix_dictionary_od_table.sql @@ -6,4 +6,3 @@ UPDATE qgep_sys.dictionary_od_table SET tablename = 'damage_channel' WHERE table UPDATE qgep_sys.dictionary_od_table SET tablename = 'damage_manhole' WHERE tablename = 'od_damage_manhole'; UPDATE qgep_sys.dictionary_od_table SET tablename = 'file' WHERE tablename = 'od_file'; UPDATE qgep_sys.dictionary_od_table SET tablename = 'data_media' WHERE tablename = 'od_data_media'; - diff --git a/delta/delta_1.1.1_add_reach_direction_change.sql b/delta/delta_1.1.1_add_reach_direction_change.sql index fa8881da3..20862ebae 100644 --- a/delta/delta_1.1.1_add_reach_direction_change.sql +++ b/delta/delta_1.1.1_add_reach_direction_change.sql @@ -17,15 +17,15 @@ * This function changes the direction of a set of reaches. * It will change the direction of the line itself as well as switch the two reach points * to make sure the topology and reach point attributes stay the way they were. - * + * * With the parameter `reach_obj_ids` it is possible to specify on which reaches this operation * should be performed by passing in an array of obj_ids */ CREATE OR REPLACE FUNCTION qgep_od.reach_direction_change(reach_obj_ids text[])RETURNS void AS $BODY$ -BEGIN - -UPDATE qgep_od.reach +BEGIN + +UPDATE qgep_od.reach SET progression_geometry = (ST_ForceCurve(ST_Reverse(ST_CurveToLine(progression_geometry)))), fk_reach_point_from = fk_reach_point_to, diff --git a/delta/delta_1.1.1_fix_depth_after_node_update.post.sql b/delta/delta_1.1.1_fix_depth_after_node_update.post.sql index b425dea54..e4199acc8 100644 --- a/delta/delta_1.1.1_fix_depth_after_node_update.post.sql +++ b/delta/delta_1.1.1_fix_depth_after_node_update.post.sql @@ -32,4 +32,4 @@ CREATE TRIGGER on_wasterwaternode_change AFTER INSERT OR UPDATE ON qgep_od.wastewater_node FOR EACH ROW - EXECUTE PROCEDURE qgep_od.on_wasterwaternode_change(); \ No newline at end of file + EXECUTE PROCEDURE qgep_od.on_wasterwaternode_change(); diff --git a/delta/delta_1.1.1_reach_point_update_trigger.sql b/delta/delta_1.1.1_reach_point_update_trigger.sql index 471728fbd..829765a38 100644 --- a/delta/delta_1.1.1_reach_point_update_trigger.sql +++ b/delta/delta_1.1.1_reach_point_update_trigger.sql @@ -40,4 +40,4 @@ BEGIN RETURN NEW; END; $BODY$ -LANGUAGE plpgsql VOLATILE; \ No newline at end of file +LANGUAGE plpgsql VOLATILE; diff --git a/delta/delta_1.1.1_symbology_drop_triggers.sql b/delta/delta_1.1.1_symbology_drop_triggers.sql index 1fb5d9981..63a5a93ee 100644 --- a/delta/delta_1.1.1_symbology_drop_triggers.sql +++ b/delta/delta_1.1.1_symbology_drop_triggers.sql @@ -15,4 +15,3 @@ BEGIN RETURN; END; $$ LANGUAGE plpgsql; - diff --git a/delta/delta_1.1.1_symbology_update.sql b/delta/delta_1.1.1_symbology_update.sql index ed85e3bce..826be056f 100644 --- a/delta/delta_1.1.1_symbology_update.sql +++ b/delta/delta_1.1.1_symbology_update.sql @@ -63,4 +63,3 @@ VOLATILE; --- the following code is updating all existinng labels SELECT qgep_od.update_wastewater_structure_label(NULL, true); - diff --git a/delta/delta_1.2.0_geometry_altitude.post.sql b/delta/delta_1.2.0_geometry_altitude.post.sql index d0e44a53a..02c722fa6 100644 --- a/delta/delta_1.2.0_geometry_altitude.post.sql +++ b/delta/delta_1.2.0_geometry_altitude.post.sql @@ -282,7 +282,7 @@ BEGIN WHEN TG_OP = 'UPDATE' THEN IF NEW.bottom_level <> OLD.bottom_level OR (NEW.bottom_level IS NULL AND OLD.bottom_level IS NOT NULL) OR (NEW.bottom_level IS NOT NULL AND OLD.bottom_level IS NULL) THEN NEW.situation_geometry = ST_SetSRID( ST_MakePoint( ST_X(NEW.situation_geometry), ST_Y(NEW.situation_geometry), COALESCE(NEW.bottom_level,'NaN') ), %(SRID)s); - ELSE + ELSE IF ST_Z(NEW.situation_geometry) <> ST_Z(OLD.situation_geometry) THEN NEW.bottom_level = NULLIF(ST_Z(NEW.situation_geometry),'NaN'); END IF; @@ -318,7 +318,7 @@ BEGIN WHEN TG_OP = 'UPDATE' THEN IF NEW.level <> OLD.level OR (NEW.level IS NULL AND OLD.level IS NOT NULL) OR (NEW.level IS NOT NULL AND OLD.level IS NULL) THEN NEW.situation_geometry = ST_SetSRID( ST_MakePoint( ST_X(NEW.situation_geometry), ST_Y(NEW.situation_geometry), COALESCE(NEW.level,'NaN') ), %(SRID)s); - ELSE + ELSE IF ST_Z(NEW.situation_geometry) <> ST_Z(OLD.situation_geometry) THEN NEW.level = NULLIF(ST_Z(NEW.situation_geometry),'NaN'); END IF; diff --git a/delta/delta_1.2.0_reach_on_delete_rule.sql b/delta/delta_1.2.0_reach_on_delete_rule.sql index 76f496c1e..65a9246b4 100644 --- a/delta/delta_1.2.0_reach_on_delete_rule.sql +++ b/delta/delta_1.2.0_reach_on_delete_rule.sql @@ -1,11 +1,11 @@ CREATE OR REPLACE RULE reach_on_delete AS - ON DELETE TO qgep_od.reach DO ALSO ( + ON DELETE TO qgep_od.reach DO ALSO ( DELETE FROM qgep_od.wastewater_networkelement WHERE wastewater_networkelement.obj_id::text = old.obj_id::text; DELETE FROM qgep_od.reach_point WHERE reach_point.obj_id::text = old.fk_reach_point_from::text; DELETE FROM qgep_od.reach_point WHERE reach_point.obj_id::text = old.fk_reach_point_to::text; -); \ No newline at end of file +); diff --git a/delta/delta_1.2.1_fix_vw_qgep_wastewater_structure.sql b/delta/delta_1.2.1_fix_vw_qgep_wastewater_structure.sql index 72d46754d..2744230f7 100644 --- a/delta/delta_1.2.1_fix_vw_qgep_wastewater_structure.sql +++ b/delta/delta_1.2.1_fix_vw_qgep_wastewater_structure.sql @@ -1,2 +1,2 @@ -SELECT 1; \ No newline at end of file +SELECT 1; diff --git a/delta/delta_1.3.0_import_trigger.sql b/delta/delta_1.3.0_import_trigger.sql index 027b7d63f..e0ac49d1e 100644 --- a/delta/delta_1.3.0_import_trigger.sql +++ b/delta/delta_1.3.0_import_trigger.sql @@ -1 +1 @@ -SELECT 1; \ No newline at end of file +SELECT 1; diff --git a/delta/delta_1.3.0_remove_old_views.post.sql b/delta/delta_1.3.0_remove_old_views.post.sql index 0fd4b50ec..7625ae9d5 100644 --- a/delta/delta_1.3.0_remove_old_views.post.sql +++ b/delta/delta_1.3.0_remove_old_views.post.sql @@ -95,5 +95,3 @@ DROP VIEW IF EXISTS qgep_od.vw_waste_water_treatment_plant; DROP VIEW IF EXISTS qgep_od.vw_file; DROP VIEW IF EXISTS qgep_od.vw_change_points; DROP VIEW IF EXISTS qgep_od.vw_catchment_area_connections; - - diff --git a/delta/delta_1.3.2_update_audit.sql b/delta/delta_1.3.2_update_audit.sql index b510b352c..cc15dc4a0 100644 --- a/delta/delta_1.3.2_update_audit.sql +++ b/delta/delta_1.3.2_update_audit.sql @@ -63,12 +63,12 @@ BEGIN END IF; INSERT INTO qgep_sys.logged_actions VALUES (audit_row.*); RETURN NEW; - + ELSIF (TG_OP = 'DELETE' AND TG_LEVEL = 'ROW') THEN audit_row.row_data = hstore(OLD.*) - excluded_cols; INSERT INTO qgep_sys.logged_actions VALUES (audit_row.*); RETURN OLD; - + ELSIF (TG_OP = 'INSERT' AND TG_LEVEL = 'ROW') THEN audit_row.row_data = hstore(NEW.*) - excluded_cols; INSERT INTO qgep_sys.logged_actions VALUES (audit_row.*); @@ -99,13 +99,13 @@ DECLARE BEGIN EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_row ON ' || target_table::text; EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_stm ON ' || target_table::text; - + IF audit_rows THEN IF array_length(ignored_cols,1) > 0 THEN _ignored_cols_snip = ', ' || quote_literal(ignored_cols); END IF; - _q_txt = 'CREATE TRIGGER audit_trigger_row AFTER INSERT OR UPDATE OR DELETE ON ' || - target_table::text || + _q_txt = 'CREATE TRIGGER audit_trigger_row AFTER INSERT OR UPDATE OR DELETE ON ' || + target_table::text || ' FOR EACH ROW EXECUTE PROCEDURE qgep_sys.if_modified_func(' || quote_literal(audit_query_text) || _ignored_cols_snip || ');'; RAISE NOTICE '%%',_q_txt; @@ -113,7 +113,7 @@ BEGIN stm_targets = 'TRUNCATE'; ELSE END IF; - + _q_txt = 'CREATE TRIGGER audit_trigger_stm AFTER ' || stm_targets || ' ON ' || target_table || ' FOR EACH STATEMENT EXECUTE PROCEDURE qgep_sys.if_modified_func('|| @@ -182,7 +182,7 @@ BEGIN from event, where_pks ; - + execute query; END; $body$ @@ -190,7 +190,7 @@ LANGUAGE plpgsql; COMMENT ON FUNCTION qgep_sys.replay_event(int) IS $body$ Replay a logged event. - + Arguments: pevent_id: The event_id of the event in qgep_sys.logged_actions to replay $body$; @@ -204,12 +204,12 @@ DECLARE BEGIN EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_row ON ' || target_view::text; EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_stm ON ' || target_view::text; - + IF array_length(ignored_cols,1) > 0 THEN _ignored_cols_snip = ', ' || quote_literal(ignored_cols); END IF; - _q_txt = 'CREATE TRIGGER audit_trigger_row INSTEAD OF INSERT OR UPDATE OR DELETE ON ' || - target_view::TEXT || + _q_txt = 'CREATE TRIGGER audit_trigger_row INSTEAD OF INSERT OR UPDATE OR DELETE ON ' || + target_view::TEXT || ' FOR EACH ROW EXECUTE PROCEDURE qgep_sys.if_modified_func(' || quote_literal(audit_query_text) || _ignored_cols_snip || ');'; RAISE NOTICE '%%',_q_txt; @@ -219,7 +219,7 @@ BEGIN IF (select count(*) from qgep_sys.logged_relations where relation_name = (select target_view)::text AND uid_column= (select unnest(uid_cols))::text) = 0 THEN insert into qgep_sys.logged_relations (relation_name, uid_column) select target_view, unnest(uid_cols); - END IF; + END IF; END; $body$ @@ -227,7 +227,7 @@ LANGUAGE plpgsql; COMMENT ON FUNCTION qgep_sys.audit_view(regclass, BOOLEAN, text[], text[]) IS $body$ ADD auditing support TO a VIEW. - + Arguments: target_view: TABLE name, schema qualified IF NOT ON search_path audit_query_text: Record the text of the client query that triggered the audit event? @@ -235,13 +235,13 @@ Arguments: uid_cols: MANDATORY COLUMNS to use to uniquely identify a row from the view (in order to replay UPDATE and DELETE) Example: - SELECT qgep_sys.audit_view('qgep_od.vw_element_installation', 'true'::BOOLEAN, '{field_to_ignore}'::text[], '{key_field1, keyfield2}'::text[]) + SELECT qgep_sys.audit_view('qgep_od.vw_element_installation', 'true'::BOOLEAN, '{field_to_ignore}'::text[], '{key_field1, keyfield2}'::text[]) $body$; - + CREATE OR REPLACE FUNCTION qgep_sys.unaudit_view(target_view regclass) RETURNS void AS $body$ BEGIN EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_row ON ' || target_view::text; EXECUTE 'DROP TRIGGER IF EXISTS audit_trigger_stm ON ' || target_view::text; END; $body$ -LANGUAGE plpgsql; \ No newline at end of file +LANGUAGE plpgsql; diff --git a/delta/delta_1.4.0_import_views.sql b/delta/delta_1.4.0_import_views.sql index 027b7d63f..e0ac49d1e 100644 --- a/delta/delta_1.4.0_import_views.sql +++ b/delta/delta_1.4.0_import_views.sql @@ -1 +1 @@ -SELECT 1; \ No newline at end of file +SELECT 1; diff --git a/delta/delta_1.4.0_increase_maintenance_event_base_data_length.sql b/delta/delta_1.4.0_increase_maintenance_event_base_data_length.sql index cccfa6a4d..17461fcf2 100644 --- a/delta/delta_1.4.0_increase_maintenance_event_base_data_length.sql +++ b/delta/delta_1.4.0_increase_maintenance_event_base_data_length.sql @@ -1,4 +1,3 @@ ALTER TABLE qgep_od.maintenance_event ALTER COLUMN base_data TYPE text; - diff --git a/delta/delta_1.4.0_update_wastewater_structure_label_with_bottom_level.sql b/delta/delta_1.4.0_update_wastewater_structure_label_with_bottom_level.sql index b1216ed3a..35a2e3e0a 100644 --- a/delta/delta_1.4.0_update_wastewater_structure_label_with_bottom_level.sql +++ b/delta/delta_1.4.0_update_wastewater_structure_label_with_bottom_level.sql @@ -12,7 +12,7 @@ UPDATE qgep_od.wastewater_structure ws SET _label = label FROM ( SELECT ws_obj_id, - COALESCE(ws_identifier, '') || E'\n' || + COALESCE(ws_identifier, '') || E'\n' || array_to_string( array_append(array_agg('C' || '=' || co_level::text ORDER BY co_level DESC), ''), E'\n' @@ -93,6 +93,5 @@ BEGIN RETURN NEW; END; $BODY$ -LANGUAGE plpgsql +LANGUAGE plpgsql VOLATILE; - diff --git a/delta/delta_1.4.1_swmm_catchment_areas.sql b/delta/delta_1.4.1_swmm_catchment_areas.sql index 027b7d63f..e0ac49d1e 100644 --- a/delta/delta_1.4.1_swmm_catchment_areas.sql +++ b/delta/delta_1.4.1_swmm_catchment_areas.sql @@ -1 +1 @@ -SELECT 1; \ No newline at end of file +SELECT 1; diff --git a/delta/delta_1.5.0_fix_network_tracking_views.sql b/delta/delta_1.5.0_fix_network_tracking_views.sql index 2d30aff48..53fd14cad 100644 --- a/delta/delta_1.5.0_fix_network_tracking_views.sql +++ b/delta/delta_1.5.0_fix_network_tracking_views.sql @@ -191,7 +191,7 @@ LEFT JOIN qgep_od.manhole mh ON mh.obj_id = ws.obj_id; CREATE MATERIALIZED VIEW qgep_od.vw_network_segment AS SELECT s.id as gid, COALESCE( - s.ne_id, + s.ne_id, CASE WHEN n1.type = 'wastewater_node' THEN n1.obj_id WHEN n2.type = 'wastewater_node' THEN n2.obj_id diff --git a/delta/delta_1.5.3_fix_ws_output_labels.sql b/delta/delta_1.5.3_fix_ws_output_labels.sql index 7e9bd8d5f..298f52738 100644 --- a/delta/delta_1.5.3_fix_ws_output_labels.sql +++ b/delta/delta_1.5.3_fix_ws_output_labels.sql @@ -61,4 +61,4 @@ END $BODY$ LANGUAGE plpgsql -VOLATILE; \ No newline at end of file +VOLATILE; diff --git a/delta/delta_1.5.5_add_spatial_index_on_network_views.sql b/delta/delta_1.5.5_add_spatial_index_on_network_views.sql index 72d46754d..2744230f7 100644 --- a/delta/delta_1.5.5_add_spatial_index_on_network_views.sql +++ b/delta/delta_1.5.5_add_spatial_index_on_network_views.sql @@ -1,2 +1,2 @@ -SELECT 1; \ No newline at end of file +SELECT 1; diff --git a/delta/delta_1.5.5_fix_permissions_on_network_refresh_function.sql b/delta/delta_1.5.5_fix_permissions_on_network_refresh_function.sql index 6f1061bd0..10db393fc 100644 --- a/delta/delta_1.5.5_fix_permissions_on_network_refresh_function.sql +++ b/delta/delta_1.5.5_fix_permissions_on_network_refresh_function.sql @@ -1 +1 @@ -ALTER FUNCTION qgep_network.refresh_network_simple() SECURITY DEFINER; \ No newline at end of file +ALTER FUNCTION qgep_network.refresh_network_simple() SECURITY DEFINER; diff --git a/delta/delta_1.5.5_symbology_for_nodes.sql b/delta/delta_1.5.5_symbology_for_nodes.sql index 23b875546..fb485831f 100644 --- a/delta/delta_1.5.5_symbology_for_nodes.sql +++ b/delta/delta_1.5.5_symbology_for_nodes.sql @@ -93,7 +93,7 @@ BEGIN WHEN TG_OP = 'DELETE' THEN ch_obj_id = OLD.obj_id; END CASE; - + BEGIN SELECT ws.obj_id, ne.obj_id INTO _ws_from_id, _ne_from_id FROM qgep_od.wastewater_networkelement ch_ne @@ -110,7 +110,7 @@ BEGIN WHEN TOO_MANY_ROWS THEN RAISE EXCEPTION 'TRIGGER ERROR ws_symbology_update_by_channel. Subquery shoud return exactly one row. This is not supposed to happen and indicates an isue with the trigger. The issue must be fixed in QGEP.'; END; - + BEGIN SELECT ws.obj_id, ne.obj_id INTO _ws_to_id, _ne_to_id FROM qgep_od.wastewater_networkelement ch_ne diff --git a/delta/delta_1.5.6_kek_model_update_2008_2019.sql b/delta/delta_1.5.6_kek_model_update_2008_2019.sql index 60981dce0..2c1d91347 100644 --- a/delta/delta_1.5.6_kek_model_update_2008_2019.sql +++ b/delta/delta_1.5.6_kek_model_update_2008_2019.sql @@ -99,7 +99,7 @@ WHERE code = 3771; INSERT INTO qgep_vl.damage_manhole_manhole_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8972,8972,'DDEEB','DDEEB','DDEEB', 'DDEEB', 'DDEEB', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_manhole_manhole_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8973,8973,'DDEEC','DDEEC','DDEEC', 'DDEEC', 'DDEEC', '', '', '', '', '', 'true'); - + -- 1.5.6.8_kek_add_vl_damage_channel_channel_damage_code_add_new_values @@ -108,115 +108,115 @@ WHERE code = 3771; INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8834,8834,'BABAE','BABAE','BABAE', 'BABAE', 'BABAE', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8835,8835,'BABBE','BABBE','BABBE', 'BABBE', 'BABBE', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8836,8836,'BABCE','BABCE','BABCE', 'BABCE', 'BABCE', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8837,8837,'BAFAZ','BAFAZ','BAFAZ', 'BAFAZ', 'BAFAZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8838,8838,'BAFBZ','BAFBZ','BAFBZ', 'BAFBZ', 'BAFBZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8839,8839,'BAFCZ','BAFCZ','BAFCZ', 'BAFCZ', 'BAFCZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8840,8840,'BAFDZ','BAFDZ','BAFDZ', 'BAFDZ', 'BAFDZ', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8841,8841,'BAFEZ','BAFEZ','BAFEZ', 'BAFEZ', 'BAFEZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8842,8842,'BAFFZ','BAFFZ','BAFFZ', 'BAFFZ', 'BAFFZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8843,8843,'BAFGZ','BAFGZ','BAFGZ', 'BAFGZ', 'BAFGZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8844,8844,'BAFIZ','BAFIZ','BAFIZ', 'BAFIZ', 'BAFIZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8845,8845,'BAFJZ','BAFJZ','BAFJZ', 'BAFJZ', 'BAFJZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8846,8846,'BAFKA','BAFKA','BAFKA', 'BAFKA', 'BAFKA', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8847,8847,'BAFKE','BAFKE','BAFKE', 'BAFKE', 'BAFKE', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8848,8848,'BAFKZ','BAFKZ','BAFKZ', 'BAFKZ', 'BAFKZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8849,8849,'BAFZZ','BAFZZ','BAFZZ', 'BAFZZ', 'BAFZZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8850,8850,'BAKDD','BAKDD','BAKDD', 'BAKDD', 'BAKDD', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8851,8851,'BAKF','BAKF','BAKF', 'BAKF', 'BAKF', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8852,8852,'BAKG','BAKG','BAKG', 'BAKG', 'BAKG', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8853,8853,'BAKH','BAKH','BAKH', 'BAKH', 'BAKH', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8854,8854,'BAKI','BAKI','BAKI', 'BAKI', 'BAKI', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8855,8855,'BAKJ','BAKJ','BAKJ', 'BAKJ', 'BAKJ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8856,8856,'BAKK','BAKK','BAKK', 'BAKK', 'BAKK', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8857,8857,'BAKL','BAKL','BAKL', 'BAKL', 'BAKL', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8858,8858,'BAKM','BAKM','BAKM', 'BAKM', 'BAKM', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8859,8859,'BAKN','BAKN','BAKN', 'BAKN', 'BAKN', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8860,8860,'BALC','BALC','BALC', 'BALC', 'BALC', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8861,8861,'BALD','BALD','BALD', 'BALD', 'BALD', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8862,8862,'BALE','BALE','BALE', 'BALE', 'BALE', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8863,8863,'BALF','BALF','BALF', 'BALF', 'BALF', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8864,8864,'BALGA','BALGA','BALGA', 'BALGA', 'BALGA', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8865,8865,'BALGB','BALGB','BALGB', 'BALGB', 'BALGB', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8866,8866,'BALGC','BALGC','BALGC', 'BALGC', 'BALGC', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8867,8867,'BALGD','BALGD','BALGD', 'BALGD', 'BALGD', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8868,8868,'BCBF','BCBF','BCBF', 'BCBF', 'BCBF', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8869,8869,'BCBG','BCBG','BCBG', 'BCBG', 'BCBG', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8870,8870,'BCDXP','BCDXP','BCDXP', 'BCDXP', 'BCDXP', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8871,8871,'BCEXP','BCEXP','BCEXP', 'BCEXP', 'BCEXP', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8872,8872,'BDBM','BDBM','BDBM', 'BDBM', 'BDBM', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8873,8873,'BDCAA','BDCAA','BDCAA', 'BDCAA', 'BDCAA', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8874,8874,'BDCAB','BDCAB','BDCAB', 'BDCAB', 'BDCAB', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8875,8875,'BDCAC','BDCAC','BDCAC', 'BDCAC', 'BDCAC', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8876,8876,'BDCAD','BDCAD','BDCAD', 'BDCAD', 'BDCAD', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8877,8877,'BDCAE','BDCAE','BDCAE', 'BDCAE', 'BDCAE', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8878,8878,'BDCAZ','BDCAZ','BDCAZ', 'BDCAZ', 'BDCAZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8879,8879,'BDCBA','BDCBA','BDCBA', 'BDCBA', 'BDCBA', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8880,8880,'BDCBB','BDCBB','BDCBB', 'BDCBB', 'BDCBB', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8881,8881,'BDCBC','BDCBC','BDCBC', 'BDCBC', 'BDCBC', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8882,8882,'BDCBD','BDCBD','BDCBD', 'BDCBD', 'BDCBD', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8883,8883,'BDCBE','BDCBE','BDCBE', 'BDCBE', 'BDCBE', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8884,8884,'BDCBZ','BDCBZ','BDCBZ', 'BDCBZ', 'BDCBZ', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8885,8885,'BDCCA','BDCCA','BDCCA', 'BDCCA', 'BDCCA', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8886,8886,'BDCCB','BDCCB','BDCCB', 'BDCCB', 'BDCCB', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8887,8887,'BDCCC','BDCCC','BDCCC', 'BDCCC', 'BDCCC', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8888,8888,'BDCCD','BDCCD','BDCCD', 'BDCCD', 'BDCCD', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8889,8889,'BDCCE','BDCCE','BDCCE', 'BDCCE', 'BDCCE', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8890,8890,'BDCCZ','BDCCZ','BDCCZ', 'BDCCZ', 'BDCCZ', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8891,8891,'BDCZA','BDCZA','BDCZA', 'BDCZA', 'BDCZA', '', '', '', '', '', 'true'); @@ -232,27 +232,27 @@ WHERE code = 3771; INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8896,8896,'BDCZZ','BDCZZ','BDCZZ', 'BDCZZ', 'BDCZZ', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8897,8897,'BDDC','BDDC','BDDC', 'BDDC', 'BDDC', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8898,8898,'BDDD','BDDD','BDDD', 'BDDD', 'BDDD', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8899,8899,'BDDE','BDDE','BDDE', 'BDDE', 'BDDE', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8900,8900,'BDECA','BDECA','BDECA', 'BDECA', 'BDECA', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8901,8901,'BDECB','BDECB','BDECB', 'BDECB', 'BDECB', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8902,8902,'BDECC','BDECC','BDECC', 'BDECC', 'BDECC', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8903,8903,'BDEDA','BDEDA','BDEDA', 'BDEDA', 'BDEDA', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8904,8904,'BDEDB','BDEDB','BDEDB', 'BDEDB', 'BDEDB', '', '', '', '', '', 'true'); INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8905,8905,'BDEDC','BDEDC','BDEDC', 'BDEDC', 'BDEDC', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8906,8906,'BDEEA','BDEEA','BDEEA', 'BDEEA', 'BDEEA', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8907,8907,'BDEEB','BDEEB','BDEEB', 'BDEEB', 'BDEEB', '', '', '', '', '', 'true'); - + INSERT INTO qgep_vl.damage_channel_channel_damage_code (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (8908,8908,'BDEEC','BDEEC','BDEEC', 'BDEEC', 'BDEEC', '', '', '', '', '', 'true'); diff --git a/delta/delta_1.5.7_dss_vl_file_update_attribute_pump_construction_type.sql b/delta/delta_1.5.7_dss_vl_file_update_attribute_pump_construction_type.sql index 86e0b4547..ed542319d 100644 --- a/delta/delta_1.5.7_dss_vl_file_update_attribute_pump_construction_type.sql +++ b/delta/delta_1.5.7_dss_vl_file_update_attribute_pump_construction_type.sql @@ -1,7 +1,7 @@ -- 1. rename attribute in table qgep_od.pump -- https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-rename-column/ -ALTER TABLE qgep_od.pump +ALTER TABLE qgep_od.pump RENAME COLUMN contruction_type TO construction_type; @@ -28,17 +28,17 @@ ALTER TABLE IF EXISTS qgep_od.pump -- adjust value list in dictionary_od_field -- INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (50,33,'pump','contruction_type','contruction_type','Bauart','GENRE_CONSTRUCTION','zzz_Bauart','tipul_constructiei','Types of pumps','Pumpenarten','Types de pompe','NULL','Observatii',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','integer',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); - + UPDATE qgep_sys.dictionary_od_field SET field_name = 'construction_type', field_name_en = 'construction_type' WHERE (table_name = 'pump' AND field_name = 'contruction_type' AND field_name_en = 'contruction_type') RETURNING *; - + -- 5. rename wrong value in qgep_sys.dictionary_od_field -- INSERT INTO qgep_sys.dictionary_od_values (class_id, attribute_id, value_id, table_name, field_name, value_name, value_name_en, shortcut_en, value_name_de, shortcut_de, value_name_fr, shortcut_fr, value_name_it, shortcut_it, value_name_ro, shortcut_ro, value_description_en, value_description_de, value_description_fr, value_description_it, value_description_ro) VALUES (50,33,2983,'pump','contruction_type','other','other',NULL,'andere',NULL,'autres',NULL,'altro',NULL,'rrr_altul',NULL,NULL,NULL,NULL,NULL,NULL); - + UPDATE qgep_sys.dictionary_od_values SET field_name = 'construction_type' WHERE (table_name = 'pump' AND field_name = 'contruction_type') diff --git a/delta/delta_1.5.7_fix_symbology_for_nodes.sql b/delta/delta_1.5.7_fix_symbology_for_nodes.sql index bdc5d3218..b42ae9026 100644 --- a/delta/delta_1.5.7_fix_symbology_for_nodes.sql +++ b/delta/delta_1.5.7_fix_symbology_for_nodes.sql @@ -61,4 +61,4 @@ $BODY$ LANGUAGE plpgsql VOLATILE; -SELECT qgep_od.update_wastewater_node_symbology(NULL, true); \ No newline at end of file +SELECT qgep_od.update_wastewater_node_symbology(NULL, true); diff --git a/delta/delta_1.5.8_add_reach_hydraulic_load.sql b/delta/delta_1.5.8_add_reach_hydraulic_load.sql index ec2061b41..147fea6fb 100644 --- a/delta/delta_1.5.8_add_reach_hydraulic_load.sql +++ b/delta/delta_1.5.8_add_reach_hydraulic_load.sql @@ -1,2 +1,2 @@ ALTER TABLE qgep_od.reach ADD COLUMN dss2020_hydraulic_load_current smallint; -COMMENT ON COLUMN qgep_od.reach.dss2020_hydraulic_load_current IS 'Dimensioning of the discharge divided by the normal discharge capacity of the reach [%%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%%].'; \ No newline at end of file +COMMENT ON COLUMN qgep_od.reach.dss2020_hydraulic_load_current IS 'Dimensioning of the discharge divided by the normal discharge capacity of the reach [%%]. / Débit de dimensionnement divisé par la capacité d''écoulement normale de la conduite [%%].'; diff --git a/delta/delta_1.5.8_dss_upddate_attributes_class.sql b/delta/delta_1.5.8_dss_upddate_attributes_class.sql index 81135ed17..34395fb33 100644 --- a/delta/delta_1.5.8_dss_upddate_attributes_class.sql +++ b/delta/delta_1.5.8_dss_upddate_attributes_class.sql @@ -1,24 +1,24 @@ -- 1. rename attribute in table qgep_od.mutation -- https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-rename-column/ -ALTER TABLE qgep_od.mutation +ALTER TABLE qgep_od.mutation RENAME COLUMN class TO classname; -- 2. rename wrong value in qgep_sys.dictionary_od_field -- adjust value list in dictionary_od_field -- INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (50,33,'pump','contruction_type','contruction_type','Bauart','GENRE_CONSTRUCTION','zzz_Bauart','tipul_constructiei','Types of pumps','Pumpenarten','Types de pompe','NULL','Observatii',ARRAY['kein_Plantyp_definiert']::qgep_od.plantype[],'true','integer',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); - + UPDATE qgep_sys.dictionary_od_field SET field_name = 'classname', field_name_en = 'classname' WHERE (table_name = 'mutation' AND field_name = 'class' AND field_name_en = 'class') RETURNING *; - + -- 3. rename wrong value in qgep_sys.dictionary_od_values -- INSERT INTO qgep_sys.dictionary_od_values (class_id, attribute_id, value_id, table_name, field_name, value_name, value_name_en, shortcut_en, value_name_de, shortcut_de, value_name_fr, shortcut_fr, value_name_it, shortcut_it, value_name_ro, shortcut_ro, value_description_en, value_description_de, value_description_fr, value_description_it, value_description_ro) VALUES (50,33,2983,'pump','contruction_type','other','other',NULL,'andere',NULL,'autres',NULL,'altro',NULL,'rrr_altul',NULL,NULL,NULL,NULL,NULL,NULL); - + UPDATE qgep_sys.dictionary_od_values SET field_name = 'classname' WHERE (table_name = 'mutation' AND field_name = 'class') @@ -26,7 +26,7 @@ RETURNING *; -- 4. rename attribute in table qgep_od.txt_text -ALTER TABLE qgep_od.txt_text +ALTER TABLE qgep_od.txt_text RENAME COLUMN class TO classname; -- 5. rename wrong value in qgep_sys.dictionary_od_field @@ -36,9 +36,9 @@ SET field_name = 'classname', field_name_en = 'classname' WHERE (table_name = 'txt_text' AND field_name = 'class' AND field_name_en = 'class') RETURNING *; - + -- 6. rename wrong value in qgep_sys.dictionary_od_values - + UPDATE qgep_sys.dictionary_od_values SET field_name = 'classname' WHERE (table_name = 'txt_text' AND field_name = 'class') @@ -46,7 +46,7 @@ RETURNING *; -- 7. rename attribute in table qgep_od.txt_symbol -ALTER TABLE qgep_od.txt_symbol +ALTER TABLE qgep_od.txt_symbol RENAME COLUMN class TO classname; -- 8. rename wrong value in qgep_sys.dictionary_od_field @@ -56,9 +56,9 @@ SET field_name = 'classname', field_name_en = 'classname' WHERE (table_name = 'txt_symbol' AND field_name = 'class' AND field_name_en = 'class') RETURNING *; - + -- 9. rename wrong value in qgep_sys.dictionary_od_values - + UPDATE qgep_sys.dictionary_od_values SET field_name = 'classname' WHERE (table_name = 'txt_symbol' AND field_name = 'class') diff --git a/delta/delta_1.5.8_tbl_swmm_coefficient_friction.sql b/delta/delta_1.5.8_tbl_swmm_coefficient_friction.sql index a9b97cfb2..4ad1796b0 100644 --- a/delta/delta_1.5.8_tbl_swmm_coefficient_friction.sql +++ b/delta/delta_1.5.8_tbl_swmm_coefficient_friction.sql @@ -1,19 +1,19 @@ CREATE TABLE qgep_swmm.reach_coefficient_of_friction (fk_material integer, coefficient_of_friction smallint); -ALTER TABLE qgep_swmm.reach_coefficient_of_friction +ALTER TABLE qgep_swmm.reach_coefficient_of_friction ADD CONSTRAINT pkey_qgep_vl_reach_coefficient_of_friction_id PRIMARY KEY (fk_material); -INSERT INTO qgep_swmm.reach_coefficient_of_friction(fk_material) - SELECT DISTINCT vsacode +INSERT INTO qgep_swmm.reach_coefficient_of_friction(fk_material) + SELECT DISTINCT vsacode FROM qgep_vl.reach_material; -UPDATE qgep_swmm.reach_coefficient_of_friction +UPDATE qgep_swmm.reach_coefficient_of_friction SET coefficient_of_friction = ( - CASE + CASE WHEN fk_material IN (5381,5081,3016) THEN 100 WHEN fk_material IN (2754,3638,3639,3640,3641,3256,147,148,3648,5079,5080,153,2762) THEN 83 WHEN fk_material IN (2755) THEN 67 WHEN fk_material IN (5076,5077,5078,5382) THEN 111 WHEN fk_material IN (3654) THEN 91 WHEN fk_material IN (154,2761) THEN 71 - ELSE 100 END); \ No newline at end of file + ELSE 100 END); diff --git a/delta/delta_1.5.9_adjust_ws_labeling.sql b/delta/delta_1.5.9_adjust_ws_labeling.sql index 899cd7780..0fca492c2 100644 --- a/delta/delta_1.5.9_adjust_ws_labeling.sql +++ b/delta/delta_1.5.9_adjust_ws_labeling.sql @@ -25,7 +25,7 @@ SELECT ws_obj_id, SELECT ws.obj_id AS ws_obj_id, ws.identifier AS ws_identifier, parts.co_level AS co_level, parts.rpi_level AS rpi_level, parts.rpo_level AS rpo_level, parts.obj_id, idx, bottom_level AS bottom_level FROM qgep_od.wastewater_structure WS - LEFT JOIN ( + LEFT JOIN ( SELECT coalesce(round(CO.level, 2)::text, '?') AS co_level, NULL::text AS rpi_level, NULL::text AS rpo_level, SP.fk_wastewater_structure ws, SP.obj_id, row_number() OVER(PARTITION BY SP.fk_wastewater_structure) AS idx, NULL::text AS bottom_level FROM qgep_od.structure_part SP RIGHT JOIN qgep_od.cover CO ON CO.obj_id = SP.obj_id @@ -41,12 +41,12 @@ SELECT ws_obj_id, WHERE (_all OR NE.fk_wastewater_structure = _obj_id) and CH_to.function_hierarchic in (5062,5064,5066,5068,5069,5070,5071,5072,5074) ----label only reaches with function_hierarchic=pwwf.* -- Outputs UNION - SELECT NULL AS co_level, NULL::text AS rpi_level, - coalesce(round(RP.level, 2)::text, '?') AS rpo_level, - NE.fk_wastewater_structure ws, RP.obj_id, - row_number() OVER(PARTITION BY NE.fk_wastewater_structure + SELECT NULL AS co_level, NULL::text AS rpi_level, + coalesce(round(RP.level, 2)::text, '?') AS rpo_level, + NE.fk_wastewater_structure ws, RP.obj_id, + row_number() OVER(PARTITION BY NE.fk_wastewater_structure ORDER BY array_position(ARRAY[4522,4526,4524,4516,4514,4518,520,4571,5322], ch.usage_current), - ST_Azimuth(RP.situation_geometry,ST_PointN(RE_from.progression_geometry,2))/pi()*180 ASC), + ST_Azimuth(RP.situation_geometry,ST_PointN(RE_from.progression_geometry,2))/pi()*180 ASC), NULL::text AS bottom_level FROM qgep_od.reach_point RP LEFT JOIN qgep_od.wastewater_networkelement NE ON RP.fk_wastewater_networkelement = NE.obj_id diff --git a/delta/delta_1.6.1_alter_order_fct_hierarchic.sql b/delta/delta_1.6.1_alter_order_fct_hierarchic.sql index 0760b89ff..576339c71 100644 --- a/delta/delta_1.6.1_alter_order_fct_hierarchic.sql +++ b/delta/delta_1.6.1_alter_order_fct_hierarchic.sql @@ -1,4 +1,4 @@ -UPDATE qgep_vl.channel_function_hierarchic +UPDATE qgep_vl.channel_function_hierarchic SET order_fct_hierarchic= array_position( ARRAY[ @@ -7,7 +7,7 @@ SET order_fct_hierarchic= ,5069 --pwwf.main_drain ,5071 --pwwf.collector_sewer ,5062 --pwwf.renovation_conduction - ,5064 --pwwf.residential_drainage + ,5064 --pwwf.residential_drainage ,5072 --pwwf.road_drainage ,5066 --pwwf.other ,5074 --pwwf.unknown @@ -17,4 +17,4 @@ SET order_fct_hierarchic= ,5067 --swwf.other ,5075 --swwf.unknown ] - ,code) + ,code) diff --git a/delta/delta_1.6.1_dss_rename_xxx_fk_chute_to_fk_surface_water_bodies.sql b/delta/delta_1.6.1_dss_rename_xxx_fk_chute_to_fk_surface_water_bodies.sql index 50fa8d06a..b512cbfc5 100644 --- a/delta/delta_1.6.1_dss_rename_xxx_fk_chute_to_fk_surface_water_bodies.sql +++ b/delta/delta_1.6.1_dss_rename_xxx_fk_chute_to_fk_surface_water_bodies.sql @@ -66,4 +66,3 @@ ALTER TABLE IF EXISTS qgep_od.sector_water_body DROP COLUMN fk_chute; -- 6. rename wrong value in qgep_sys.dictionary_od_field -- not needed as fk_attributes are not in qgep_sys tables - diff --git a/delta/delta_1.6.1_dss_rename_xxx_fk_overflow_characteristic_to_fk_overflow_char.sql b/delta/delta_1.6.1_dss_rename_xxx_fk_overflow_characteristic_to_fk_overflow_char.sql index 74f413bd9..2195beb11 100644 --- a/delta/delta_1.6.1_dss_rename_xxx_fk_overflow_characteristic_to_fk_overflow_char.sql +++ b/delta/delta_1.6.1_dss_rename_xxx_fk_overflow_characteristic_to_fk_overflow_char.sql @@ -78,10 +78,10 @@ ALTER TABLE IF EXISTS qgep_od.hydraulic_char_data DROP COLUMN fk_overflow_charac -- 1. rename attribute kind_overflow_characteristic and overflow_characteristic_digital in table qgep_od.overflow_char -- https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-rename-column/ -ALTER TABLE qgep_od.overflow_char +ALTER TABLE qgep_od.overflow_char RENAME COLUMN kind_overflow_characteristic TO kind_overflow_char; -ALTER TABLE qgep_od.overflow_char +ALTER TABLE qgep_od.overflow_char RENAME COLUMN overflow_characteristic_digital TO overflow_char_digital; @@ -93,7 +93,7 @@ ALTER TABLE qgep_vl.overflow_char_kind_overflow_characteristic RENAME TO overflo ALTER TABLE qgep_vl.overflow_char_overflow_characteristic_digital RENAME TO overflow_char_overflow_char_digital; --- 3. delete primary constraint of vl_list tables neu 5.10.2023 - geht nicht wegen dependencies +-- 3. delete primary constraint of vl_list tables neu 5.10.2023 - geht nicht wegen dependencies -- use rename instead ALTER TABLE name RENAME CONSTRAINT constraint_name TO new_constraint_name; --ALTER TABLE IF EXISTS qgep_vl.overflow_char_kind_overflow_characteristic DROP CONSTRAINT pkey_qgep_vl_overflow_char_kind_overflow_characteristic_code; @@ -114,7 +114,7 @@ ALTER TABLE qgep_vl.overflow_char_overflow_char_digital RENAME CONSTRAINT pkey_q -- adjust value list in dictionary_od_field -- INSERT INTO qgep_sys.dictionary_od_field (class_id, attribute_id, table_name, field_name, field_name_en, field_name_de, field_name_fr, field_name_it, field_name_ro, field_description_en, field_description_de, field_description_fr, field_description_it, field_description_ro, field_mandatory, field_visible, field_datatype, field_unit_en, field_unit_description_en, field_unit_de, field_unit_description_de, field_unit_fr, field_unit_description_fr, field_unit_it, field_unit_description_it, field_unit_ro, field_unit_description_ro, field_max, field_min) VALUES (64,6219,'overflow_char','kind_overflow_characteristic','kind_overflow_characteristic','Kennlinie_Typ','GENRE_COURBE_DE_FONCTIONNEMENT','curva_caratteristica_tipo','tipul_curbei_de_func?ionare','yyy_Die Kennlinie ist als Q /Q- (bei Bodenöffnungen) oder als H/Q-Tabelle (bei Streichwehren) zu dokumentieren. Bei einer freien Aufteilung muss die Kennlinie nicht dokumentiert werden. Bei Abflussverhältnissen in Einstaubereichen ist die Funktion separat in einer Beilage zu beschreiben.','Die Kennlinie ist als Q /Q- (bei Bodenöffnungen) oder als H/Q-Tabelle (bei Streichwehren) zu dokumentieren. Bei einer freien Aufteilung muss die Kennlinie nicht dokumentiert werden. Bei Abflussverhältnissen in Einstaubereichen ist die Funktion separat in einer Beilage zu beschreiben.','La courbe est à documenter sous forme de rapport Q/Q (Leaping weir) ou H/Q (déversoir latéral). Les conditions d’écoulement dans la chambre d’accumulation sont à fournir en annexe.','NULL','[CHF]',ARRAY['GEP_Verband','PAA']::qgep_od.plantype[],'true','integer','','','','','','','','','','',NULL,NULL); - + UPDATE qgep_sys.dictionary_od_field SET field_name = 'kind_overflow_char', @@ -130,10 +130,10 @@ SET field_name = 'overflow_char_digital', WHERE (table_name = 'overflow_char' AND field_name = 'overflow_characteristic_digital' AND field_name_en = 'overflow_characteristic_digital') RETURNING *; - + -- 4. rename wrong value in qgep_sys.dictionary_od_values -- INSERT INTO qgep_sys.dictionary_od_values (class_id, attribute_id, value_id, table_name, field_name, value_name, value_name_en, shortcut_en, value_name_de, shortcut_de, value_name_fr, shortcut_fr, value_name_it, shortcut_it, value_name_ro, shortcut_ro, value_description_en, value_description_de, value_description_fr, value_description_it, value_description_ro) VALUES (64,6219,6220,'overflow_char','kind_overflow_characteristic','hq','hq','','HQ','','HQ','','HQ','','','','yyy_H-Q Beziehung: Hoehe (H) und Durchfluss (Q) Richtung ARA abfüllen','H-Q Beziehung: Hoehe (H) und Durchfluss (Q) Richtung ARA abfüllen','ligne H / Q: H = hauteur d’eau lors du déversement [m.s.m.], Q = débit conservé vers STEP [l/s]','Assegnare altezza (H) e portata (Q)',''); - + UPDATE qgep_sys.dictionary_od_values SET field_name = 'kind_overflow_char' WHERE (table_name = 'overflow_char' AND field_name = 'kind_overflow_characteristic') @@ -148,9 +148,9 @@ RETURNING *; --INSERT INTO qgep_sys.dictionary_od_values (class_id, attribute_id, value_id, table_name, field_name, value_name, value_name_en, shortcut_en, value_name_de, shortcut_de, value_name_fr, shortcut_fr, value_name_it, shortcut_it, value_name_ro, shortcut_ro, value_description_en, value_description_de, value_description_fr, value_description_it, value_description_ro) VALUES (3754,3764,3883,'file','class','overflow_char','overflow_char','','Ueberlaufcharakteristik','','CARACTERISTIQUES_DEVERSOIR','','zzz_Ueberlaufcharakteristik','','','',' ','','','',''); - + UPDATE qgep_sys.dictionary_od_values SET value_name = 'overflow_char', value_name_en = 'overflow_char' WHERE (table_name = 'file' AND field_name = 'class') -RETURNING *; \ No newline at end of file +RETURNING *; diff --git a/delta/delta_1.6.2_dss_rename_system_user.sql b/delta/delta_1.6.2_dss_rename_system_user.sql index 7b289f9f2..5a83796b2 100644 --- a/delta/delta_1.6.2_dss_rename_system_user.sql +++ b/delta/delta_1.6.2_dss_rename_system_user.sql @@ -1,5 +1,5 @@ -- noop delta, used only to unambigously define the datamodel version -ALTER TABLE qgep_od.mutation +ALTER TABLE qgep_od.mutation RENAME COLUMN system_user to user_system; UPDATE qgep_sys.dictionary_od_field @@ -8,4 +8,4 @@ WHERE attribute_id = 5532; UPDATE qgep_sys.dictionary_od_field SET field_name_en = 'user_system' -WHERE attribute_id = 5532; \ No newline at end of file +WHERE attribute_id = 5532; diff --git a/delta/delta_1.6.2_update_usage_current_by_overflow.sql b/delta/delta_1.6.2_update_usage_current_by_overflow.sql index 1e2113be1..e9b148f3d 100644 --- a/delta/delta_1.6.2_update_usage_current_by_overflow.sql +++ b/delta/delta_1.6.2_update_usage_current_by_overflow.sql @@ -40,7 +40,7 @@ FROM( LEFT JOIN qgep_od.wastewater_structure ws_from ON ws_from.obj_id = ne_from.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_from ON CH_from.function_hierarchic = vl_fct_hier_from.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_from ON CH_from.usage_current = vl_usg_curr_from.code - + LEFT JOIN qgep_od.reach re_to ON re_to.fk_reach_point_to = rp.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_to ON ne_to.obj_id = re_to.obj_id @@ -52,7 +52,7 @@ FROM( -- Update by Overflow LEFT JOIN qgep_od.overflow ov ON ov.fk_overflow_to=ne.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov ON ne_ov.obj_id = ov.fk_wastewater_node - + LEFT JOIN qgep_od.reach_point rp_ov_from ON ne_ov.obj_id = rp_ov_from.fk_wastewater_networkelement LEFT JOIN qgep_od.reach re_ov_from ON re_ov_from.fk_reach_point_from = rp_ov_from.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov_from ON ne_ov_from.obj_id = re_ov_from.obj_id @@ -60,7 +60,7 @@ FROM( LEFT JOIN qgep_od.wastewater_structure ws_ov_from ON ws_ov_from.obj_id = ne_ov_from.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_ov_from ON CH_ov_from.function_hierarchic = vl_fct_hier_ov_from.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_ov_from ON CH_ov_from.usage_current = vl_usg_curr_ov_from.code - + LEFT JOIN qgep_od.reach_point rp_ov_to ON ne_ov.obj_id = rp_ov_to.fk_wastewater_networkelement LEFT JOIN qgep_od.reach re_ov_to ON re_ov_to.fk_reach_point_to = rp_ov_to.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov_to ON ne_ov_to.obj_id = re_ov_to.obj_id @@ -68,14 +68,14 @@ FROM( LEFT JOIN qgep_od.wastewater_structure ws_ov_to ON ws_ov_to.obj_id = ne_ov_to.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_ov_to ON CH_ov_to.function_hierarchic = vl_fct_hier_ov_to.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_ov_to ON CH_ov_to.usage_current = vl_usg_curr_ov_to.code - + WHERE _all OR ne.obj_id = _obj_id - WINDOW w AS ( PARTITION BY ne.obj_id + WINDOW w AS ( PARTITION BY ne.obj_id ORDER BY vl_fct_hier_from.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_to.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_ov_from.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_ov_to.order_fct_hierarchic ASC NULLS LAST - + , vl_usg_curr_from.order_usage_current ASC NULLS LAST , vl_usg_curr_to.order_usage_current ASC NULLS LAST , vl_usg_curr_ov_from.order_usage_current ASC NULLS LAST @@ -123,18 +123,18 @@ SELECT DISTINCT ON (ws.obj_id) ws.obj_id AS ws_obj_id, LEFT JOIN qgep_od.channel CH_from ON CH_from.obj_id = ne_from.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_from ON CH_from.function_hierarchic = vl_fct_hier_from.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_from ON CH_from.usage_current = vl_usg_curr_from.code - + LEFT JOIN qgep_od.reach re_to ON re_to.fk_reach_point_to = rp.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_to ON ne_to.obj_id = re_to.obj_id LEFT JOIN qgep_od.channel CH_to ON CH_to.obj_id = ne_to.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_to ON CH_to.function_hierarchic = vl_fct_hier_to.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_to ON CH_to.usage_current = vl_usg_curr_to.code - + -- Update by Overflow LEFT JOIN qgep_od.wastewater_networkelement ne_ws ON ne_ws.fk_wastewater_structure=ws.obj_id LEFT JOIN qgep_od.overflow ov ON ov.fk_overflow_to=ne_ws.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov ON ne_ov.obj_id = ov.fk_wastewater_node - + LEFT JOIN qgep_od.reach_point rp_ov_from ON ne_ov.obj_id = rp_ov_from.fk_wastewater_networkelement LEFT JOIN qgep_od.reach re_ov_from ON re_ov_from.fk_reach_point_from = rp_ov_from.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov_from ON ne_ov_from.obj_id = re_ov_from.obj_id @@ -142,7 +142,7 @@ SELECT DISTINCT ON (ws.obj_id) ws.obj_id AS ws_obj_id, LEFT JOIN qgep_od.wastewater_structure ws_ov_from ON ws_ov_from.obj_id = ne_ov_from.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_ov_from ON CH_ov_from.function_hierarchic = vl_fct_hier_ov_from.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_ov_from ON CH_ov_from.usage_current = vl_usg_curr_ov_from.code - + LEFT JOIN qgep_od.reach_point rp_ov_to ON ne_ov.obj_id = rp_ov_to.fk_wastewater_networkelement LEFT JOIN qgep_od.reach re_ov_to ON re_ov_to.fk_reach_point_to = rp_ov_to.obj_id LEFT JOIN qgep_od.wastewater_networkelement ne_ov_to ON ne_ov_to.obj_id = re_ov_to.obj_id @@ -150,18 +150,18 @@ SELECT DISTINCT ON (ws.obj_id) ws.obj_id AS ws_obj_id, LEFT JOIN qgep_od.wastewater_structure ws_ov_to ON ws_ov_to.obj_id = ne_ov_to.fk_wastewater_structure LEFT JOIN qgep_vl.channel_function_hierarchic vl_fct_hier_ov_to ON CH_ov_to.function_hierarchic = vl_fct_hier_ov_to.code LEFT JOIN qgep_vl.channel_usage_current vl_usg_curr_ov_to ON CH_ov_to.usage_current = vl_usg_curr_ov_to.code - + WHERE _all OR ws.obj_id = _obj_id - WINDOW w AS ( PARTITION BY ws.obj_id + WINDOW w AS ( PARTITION BY ws.obj_id ORDER BY vl_fct_hier_from.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_to.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_ov_from.order_fct_hierarchic ASC NULLS LAST , vl_fct_hier_ov_to.order_fct_hierarchic ASC NULLS LAST - + , vl_usg_curr_from.order_usage_current ASC NULLS LAST , vl_usg_curr_to.order_usage_current ASC NULLS LAST - , vl_usg_curr_ov_from.order_usage_current ASC NULLS LAST - , vl_usg_curr_ov_to.order_usage_current ASC NULLS LAST + , vl_usg_curr_ov_from.order_usage_current ASC NULLS LAST + , vl_usg_curr_ov_to.order_usage_current ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) ) symbology_ws WHERE symbology_ws.ws_obj_id = ws.obj_id; diff --git a/delta/post-all.py b/delta/post-all.py index 498bbc76a..f014980b1 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -1,29 +1,39 @@ #!/usr/bin/env python3 -import sys, os +import os +import sys + import psycopg2 -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) + +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) from pum.core.deltapy import DeltaPy + from view.create_views import create_views class CreateViews(DeltaPy): def run(self): - qgep_wastewater_structure_extra = self.variables.get('qgep_wastewater_structure_extra', None) - qgep_reach_extra = self.variables.get('qgep_reach_extra', None) + qgep_wastewater_structure_extra = self.variables.get( + "qgep_wastewater_structure_extra", None + ) + qgep_reach_extra = self.variables.get("qgep_reach_extra", None) - if not self.variables.get('SRID'): - raise RuntimeError('SRID not specified. Add `-v int SRID 2056` (or the corresponding EPSG code) to the upgrade command.') - create_views(srid=self.variables.get('SRID'), - pg_service=self.pg_service, - qgep_wastewater_structure_extra=qgep_wastewater_structure_extra, - qgep_reach_extra=qgep_reach_extra) + if not self.variables.get("SRID"): + raise RuntimeError( + "SRID not specified. Add `-v int SRID 2056` (or the corresponding EPSG code) to the upgrade command." + ) + create_views( + srid=self.variables.get("SRID"), + pg_service=self.pg_service, + qgep_wastewater_structure_extra=qgep_wastewater_structure_extra, + qgep_reach_extra=qgep_reach_extra, + ) # refresh network views - conn = psycopg2.connect("service={0}".format(self.pg_service)) + conn = psycopg2.connect(f"service={self.pg_service}") cursor = conn.cursor() - cursor.execute('SELECT qgep_network.refresh_network_simple();') + cursor.execute("SELECT qgep_network.refresh_network_simple();") conn.commit() conn.close() diff --git a/delta/pre-all.py b/delta/pre-all.py index 6fe64774c..1e970498e 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -1,38 +1,44 @@ -#!/usr/bin/env python3 - -import sys, os -import psycopg2 -sys.path.append(os.path.join(os.path.dirname(__file__), '..')) - -from pum.core.deltapy import DeltaPy -from view.create_views import drop_views -from pkg_resources import get_distribution, parse_version, DistributionNotFound - -# Older verisons of pum and pirogue can create issues such as reapplying deltas whose checksum have changed, -# or create columuns in views in a non-deterministic order. To avoid causing trouble in user's database, -# we check these versions here before doing anything -MIN_PUM = "0.10.0" -MIN_PIROGUE = "1.4.1" - - -class CheckLibraryVersions(DeltaPy): - def run(self): - # check pum - try: - if get_distribution("pum").parsed_version < parse_version(MIN_PUM): - raise RuntimeError - except (RuntimeError, DistributionNotFound): - raise RuntimeError(f"You need pum {MIN_PUM} or newer to proceed. Run `pip install pum --upgrade` before continuing") - - # check pirogue - try: - if get_distribution("pirogue").parsed_version < parse_version(MIN_PIROGUE): - raise RuntimeError - except (RuntimeError, DistributionNotFound): - raise RuntimeError(f"You need pirogue {MIN_PIROGUE} or newer to proceed. Run `pip install pirogue --upgrade` before continuing") - - -class DropViews(DeltaPy): - - def run(self): - drop_views(pg_service=self.pg_service) +#!/usr/bin/env python3 + +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) + +from pkg_resources import DistributionNotFound, get_distribution, parse_version +from pum.core.deltapy import DeltaPy + +from view.create_views import drop_views + +# Older verisons of pum and pirogue can create issues such as reapplying deltas whose checksum have changed, +# or create columuns in views in a non-deterministic order. To avoid causing trouble in user's database, +# we check these versions here before doing anything +MIN_PUM = "0.10.0" +MIN_PIROGUE = "1.4.1" + + +class CheckLibraryVersions(DeltaPy): + def run(self): + # check pum + try: + if get_distribution("pum").parsed_version < parse_version(MIN_PUM): + raise RuntimeError + except (RuntimeError, DistributionNotFound): + raise RuntimeError( + f"You need pum {MIN_PUM} or newer to proceed. Run `pip install pum --upgrade` before continuing" + ) + + # check pirogue + try: + if get_distribution("pirogue").parsed_version < parse_version(MIN_PIROGUE): + raise RuntimeError + except (RuntimeError, DistributionNotFound): + raise RuntimeError( + f"You need pirogue {MIN_PIROGUE} or newer to proceed. Run `pip install pirogue --upgrade` before continuing" + ) + + +class DropViews(DeltaPy): + + def run(self): + drop_views(pg_service=self.pg_service) diff --git a/fixes/fix_depth.sql b/fixes/fix_depth.sql index a0e8e993d..4827133cc 100644 --- a/fixes/fix_depth.sql +++ b/fixes/fix_depth.sql @@ -15,4 +15,3 @@ DROP COLUMN depth; ALTER TABLE qgep_od.wastewater_structure ADD COLUMN _depth numeric(6,3); COMMENT ON COLUMN qgep_od.wastewater_structure._depth IS 'yyy_Funktion (berechneter Wert) = repräsentative Abwasserknoten.Sohlenkote minus zugehörige Deckenkote des Bauwerks falls Detailgeometrie vorhanden, sonst Funktion (berechneter Wert) = Abwasserknoten.Sohlenkote minus zugehörige Deckel.Kote des Bauwerks / Funktion (berechneter Wert) = repräsentative Abwasserknoten.Sohlenkote minus zugehörige Deckenkote des Bauwerks falls Detailgeometrie vorhanden, sonst Funktion (berechneter Wert) = Abwasserknoten.Sohlenkote minus zugehörige Deckel.Kote des Bauwerks / Fonction (valeur calculée) = NOEUD_RESEAU.COTE_RADIER représentatif moins COTE_PLAFOND de l’ouvrage correspondant si la géométrie détaillée est disponible, sinon fonction (valeur calculée) = NŒUD_RESEAU.COT_RADIER moins COUVERCLE.COTE de l’ouvrage correspondant'; - diff --git a/fixes/fix_on_delete_actions.sql b/fixes/fix_on_delete_actions.sql index d24757de1..4b6a8b828 100644 --- a/fixes/fix_on_delete_actions.sql +++ b/fixes/fix_on_delete_actions.sql @@ -17,7 +17,7 @@ ALTER TABLE qgep_od.manhole DROP CONSTRAINT oorel_od_manhole_wastewater_structur ALTER TABLE qgep_od.manhole ADD CONSTRAINT oorel_od_manhole_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE; - + ALTER TABLE qgep_od.wastewater_node DROP CONSTRAINT oorel_od_wastewater_node_wastewater_networkelement; ALTER TABLE qgep_od.wastewater_node ADD CONSTRAINT oorel_od_wastewater_node_wastewater_networkelement FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_networkelement(obj_id) MATCH SIMPLE diff --git a/functions/reach_direction_change.sql b/functions/reach_direction_change.sql index fa8881da3..20862ebae 100644 --- a/functions/reach_direction_change.sql +++ b/functions/reach_direction_change.sql @@ -17,15 +17,15 @@ * This function changes the direction of a set of reaches. * It will change the direction of the line itself as well as switch the two reach points * to make sure the topology and reach point attributes stay the way they were. - * + * * With the parameter `reach_obj_ids` it is possible to specify on which reaches this operation * should be performed by passing in an array of obj_ids */ CREATE OR REPLACE FUNCTION qgep_od.reach_direction_change(reach_obj_ids text[])RETURNS void AS $BODY$ -BEGIN - -UPDATE qgep_od.reach +BEGIN + +UPDATE qgep_od.reach SET progression_geometry = (ST_ForceCurve(ST_Reverse(ST_CurveToLine(progression_geometry)))), fk_reach_point_from = fk_reach_point_to, diff --git a/scripts/dispatch_table_migration/README.md b/scripts/dispatch_table_migration/README.md index f2ac0893e..3c09ba509 100644 --- a/scripts/dispatch_table_migration/README.md +++ b/scripts/dispatch_table_migration/README.md @@ -8,12 +8,12 @@ The logic behind the migration is: 1. Make a copy of the original DB containing QGEP schema (`CREATE DATABASE new WITH TEMPLATE old`) 2. Init QGEP with its new schema within the new DB (hence former `qgep` schema will be along with new `qgep_sys`, `qgep_vl`, `qgep_od` schemas) 3. Copy data from `qgep`schema to the new ones. - + To perform the migration: 1. Adapt the script `migrate_dispatch.sh` and define source and destination PG services and databases. 2. Run the script. - + ## Things which are handled * Every table in qgep schema has its content copied to new schemas, except: @@ -27,12 +27,12 @@ To perform the migration: * these changes are performed wisely: they are only applied after checking if the latest version cannot be found * If a table present in former schema doesn't have its correspondance in new schemas, a WARNING is thrown for value list and an ERROR for any other type of tables. * Sequences are updated from former schema. - + ## Things which are **NOT** handled or should be considered * If some fields are too long (varchar columns were extended in former schema). * Former `qgep` schema is kept in the new DB, it would need to be removed afterwards. * This migration will break history in logged_actions, this would require patching data in the logged actions. - + ## Technical details * table renames * hydraulic_characteristic_data to hydraulic_char_data diff --git a/swmm_views/01_vw_swmm_create_schema.sql b/swmm_views/01_vw_swmm_create_schema.sql index 84c36866b..748345603 100644 --- a/swmm_views/01_vw_swmm_create_schema.sql +++ b/swmm_views/01_vw_swmm_create_schema.sql @@ -1 +1 @@ -CREATE SCHEMA IF NOT EXISTS qgep_swmm; \ No newline at end of file +CREATE SCHEMA IF NOT EXISTS qgep_swmm; diff --git a/swmm_views/02_vw_swmm_junctions.sql b/swmm_views/02_vw_swmm_junctions.sql index 1b079fac9..bd3ce9cf4 100644 --- a/swmm_views/02_vw_swmm_junctions.sql +++ b/swmm_views/02_vw_swmm_junctions.sql @@ -14,11 +14,11 @@ SELECT ws.identifier::text as description, CONCAT_WS(',', 'manhole', mf.value_en) as tag, wn.situation_geometry as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN ch_fh.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -47,11 +47,11 @@ SELECT ws.identifier::text as description, CONCAT_WS(',','special_structure', ss_fu.value_en) as tag, wn.situation_geometry as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN ch_fh.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -112,11 +112,11 @@ SELECT coalesce(from_wn.obj_id, concat('from_node@',re.obj_id)) as description, 'junction without structure' as tag, coalesce(from_wn.situation_geometry, ST_StartPoint(re.progression_geometry)) as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN ch_fh.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -148,11 +148,11 @@ SELECT coalesce(to_wn.obj_id, concat('to_node@',re.obj_id)) as description, 'junction without structure' as tag, coalesce(to_wn.situation_geometry, ST_EndPoint(re.progression_geometry)) as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN ch_fh.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, diff --git a/swmm_views/04_vw_swmm_conduits.sql b/swmm_views/04_vw_swmm_conduits.sql index c82a89e95..170bdd0d6 100644 --- a/swmm_views/04_vw_swmm_conduits.sql +++ b/swmm_views/04_vw_swmm_conduits.sql @@ -17,7 +17,7 @@ SELECT -- Roughness export prioriy: 1. coefficient_of_friction, 2. wall_roughness, 3. swmm_default_coefficient_of_friction, 4. 0.01 CASE WHEN re.coefficient_of_friction IS NOT NULL THEN (1 / re.coefficient_of_friction::double precision) - WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN + WHEN re.coefficient_of_friction IS NULL AND re.wall_roughness IS NOT NULL THEN CASE WHEN re.clear_height IS NOT NULL THEN 1./((4. * SQRT(9.81) * POWER((32. / (re.clear_height::double precision / 1000.)),(1. / 6.::double precision)))*LOG(((3.71 * (re.clear_height::double precision / 1000.)) / (re.wall_roughness / 1000.))))::numeric(7,4) WHEN re.clear_height IS NULL AND re.swmm_default_coefficient_of_friction IS NOT NULL THEN (1 / re.swmm_default_coefficient_of_friction::double precision) @@ -52,50 +52,50 @@ SELECT ELSE 'Default value 0.01 is used as roughness' END, CASE - WHEN vl_pp.vsacode = 3350 THEN + WHEN vl_pp.vsacode = 3350 THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': circular profile with default value of 0.1m as clear_height') ELSE NULL END - WHEN vl_pp.vsacode = 3351 THEN + WHEN vl_pp.vsacode = 3351 THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': egg profile with default value of 0.1m as clear_height') ELSE NULL END - WHEN vl_pp.vsacode = 3352 THEN + WHEN vl_pp.vsacode = 3352 THEN CASE - WHEN pp.height_width_ratio IS NOT NULL THEN + WHEN pp.height_width_ratio IS NOT NULL THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': arch profile with known height_width_ratio value and with default value of 0.1m as clear_height') ELSE NULL END - WHEN pp.height_width_ratio IS NULL THEN + WHEN pp.height_width_ratio IS NULL THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': arch profile with default value of 1 as height_width_ratio and with default value of 0.1m as clear_height') ELSE concat('Reach', re.obj_id,': arch profile with default value of 1 as height_width_ratio and with known clear_height value') END END - WHEN vl_pp.vsacode = 3353 THEN + WHEN vl_pp.vsacode = 3353 THEN CASE - WHEN pp.height_width_ratio IS NOT NULL THEN + WHEN pp.height_width_ratio IS NOT NULL THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': rectangular profile with known height_width_ratio value and with default value of 0.1m as clear_height') ELSE NULL END - WHEN pp.height_width_ratio IS NULL THEN + WHEN pp.height_width_ratio IS NULL THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': rectangular profile with default value of 1 as height_width_ratio and with default value of 0.1m as clear_height') ELSE concat('Reach', re.obj_id,': rectangular profile with default value of 1 as height_width_ratio and with known clear_height value') END END - WHEN vl_pp.vsacode = 3354 THEN + WHEN vl_pp.vsacode = 3354 THEN CASE - WHEN pp.height_width_ratio IS NOT NULL THEN + WHEN pp.height_width_ratio IS NOT NULL THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': parabolic profile with known height_width_ratio value, default value of 0.1m as clear_height and no code value') ELSE NULL END - WHEN pp.height_width_ratio IS NULL THEN + WHEN pp.height_width_ratio IS NULL THEN CASE WHEN re.clear_height = 0 OR re.clear_height IS NULL THEN concat('Reach', re.obj_id,': parabolic profile with default value of 1 as height_width_ratio, with default value of 0.1m as clear_height and no code value') ELSE concat('Reach', re.obj_id,': parabolic profile with default value of 1 as height_width_ratio, with known clear_height value and no code value') @@ -111,11 +111,11 @@ SELECT ) as description, cfhy.value_en as tag, ST_CurveToLine(st_force3d(progression_geometry))::geometry(LineStringZ, %(SRID)s) as geom, - CASE + CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, diff --git a/swmm_views/05_vw_swmm_dividers.sql b/swmm_views/05_vw_swmm_dividers.sql index 310bb1785..51fb8ea77 100644 --- a/swmm_views/05_vw_swmm_dividers.sql +++ b/swmm_views/05_vw_swmm_dividers.sql @@ -14,11 +14,11 @@ SELECT 0 as SurchargeDepth, 0 as PondedArea, wn.situation_geometry as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -47,11 +47,11 @@ SELECT 0 as SurchargeDepth, 0 as PondedArea, wn.situation_geometry as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, diff --git a/swmm_views/07_vw_swmm_losses.sql b/swmm_views/07_vw_swmm_losses.sql index e10079a0b..5c1c952ea 100644 --- a/swmm_views/07_vw_swmm_losses.sql +++ b/swmm_views/07_vw_swmm_losses.sql @@ -14,11 +14,11 @@ SELECT DISTINCT ELSE 'NO' END as flap_gate, 0::float as Seepage, - CASE + CASE WHEN status IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, diff --git a/swmm_views/08_vw_swmm_outfalls.sql b/swmm_views/08_vw_swmm_outfalls.sql index b0dc5feb0..0017eac6d 100644 --- a/swmm_views/08_vw_swmm_outfalls.sql +++ b/swmm_views/08_vw_swmm_outfalls.sql @@ -13,11 +13,11 @@ SELECT ws.identifier as description, dp.obj_id::varchar as tag, wn.situation_geometry as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -43,11 +43,11 @@ SELECT ws.identifier as description, ii.obj_id::varchar as tag, wn.situation_geometry as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -59,5 +59,5 @@ LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hie LEFT JOIN qgep_od.wastewater_networkelement we ON we.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node wn on wn.obj_id = we.obj_id WHERE wn.obj_id IS NOT NULL -AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) +AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) ; diff --git a/swmm_views/09_vw_swmm_subcatchments.sql b/swmm_views/09_vw_swmm_subcatchments.sql index 56d367c3f..9257254ac 100644 --- a/swmm_views/09_vw_swmm_subcatchments.sql +++ b/swmm_views/09_vw_swmm_subcatchments.sql @@ -28,7 +28,7 @@ SELECT END as percImperv, -- take from catchment_area instead of default value CASE WHEN wn_geom IS NOT NULL - THEN + THEN ( st_maxdistance(wn_geom, ST_ExteriorRing(perimeter_geometry)) + st_distance(wn_geom, ST_ExteriorRing(perimeter_geometry)) @@ -44,21 +44,21 @@ SELECT NULL::varchar as SnowPack, -- default value CASE WHEN fk_wastewater_networkelement_ww_current is not null - THEN - CASE + THEN + CASE WHEN waste_water_production_current IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_current') ELSE - CASE + CASE WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_current and a default production of 160 Litre / inhabitant /day') ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_current and a default production of 160 Litre / inhabitant /day') END END WHEN fk_wastewater_networkelement_ww_planned is not null - THEN - CASE + THEN + CASE WHEN waste_water_production_planned IS NOT NULL THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from waste_water_production_planned') ELSE - CASE + CASE WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from surface_area, population_density_planned and a default production of 160 Litre / inhabitant /day') ELSE concat('catchment_area: ', ca.obj_id,': DWF baseline is computed from the geometric area, population_density_planned and a default production of 160 Litre / inhabitant /day') END @@ -75,7 +75,7 @@ SELECT WHEN state = 'rw_planned' OR state = 'ww_planned' THEN 'planned' ELSE 'planned' END as state, - CASE + CASE WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -131,7 +131,7 @@ FROM ( wn.obj_id AS wn_obj_id, fhy.vsacode as _function_hierarchic FROM qgep_od.catchment_area ca_1 - JOIN qgep_od.wastewater_networkelement ne + JOIN qgep_od.wastewater_networkelement ne ON ne.obj_id::text IN (ca_1.fk_wastewater_networkelement_rw_current::text, ca_1.fk_wastewater_networkelement_ww_current::text, ca_1.fk_wastewater_networkelement_rw_planned::text, @@ -144,6 +144,6 @@ FROM ( LEFT JOIN qgep_vl.catchment_area_infiltration_current ic ON ic.code=ca_1.infiltration_current LEFT JOIN qgep_vl.catchment_area_infiltration_planned ip ON ip.code=ca_1.infiltration_planned LEFT JOIN qgep_vl.catchment_area_retention_current rc ON rc.code=ca_1.retention_current - LEFT JOIN qgep_vl.catchment_area_retention_planned rp ON rp.code=ca_1.retention_planned + LEFT JOIN qgep_vl.catchment_area_retention_planned rp ON rp.code=ca_1.retention_planned LEFT JOIN qgep_vl.channel_function_hierarchic fhy ON fhy.code=wn._function_hierarchic ) as ca; diff --git a/swmm_views/10_vw_swmm_subareas.sql b/swmm_views/10_vw_swmm_subareas.sql index c7b09376d..01257ac86 100644 --- a/swmm_views/10_vw_swmm_subareas.sql +++ b/swmm_views/10_vw_swmm_subareas.sql @@ -2,14 +2,14 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_subareas AS SELECT concat(replace(ca.obj_id, ' ', '_'), '_', state) as Subcatchment, - 0.01 as NImperv, -- default value, Manning's n for overland flow over the impervious portion of the subcatchment + 0.01 as NImperv, -- default value, Manning's n for overland flow over the impervious portion of the subcatchment 0.1 as NPerv,-- default value, Manning's n for overland flow over the pervious portion of the subcatchment CASE - WHEN surface_storage IS NOT NULL THEN surface_storage + WHEN surface_storage IS NOT NULL THEN surface_storage ELSE 0.05 -- default value END as SImperv,-- Depth of depression storage on the impervious portion of the subcatchment (inches or millimeters) CASE - WHEN surface_storage IS NOT NULL THEN surface_storage + WHEN surface_storage IS NOT NULL THEN surface_storage ELSE 0.05 -- default value END as SPerv,-- Depth of depression storage on the pervious portion of the subcatchment (inches or millimeters) 25 as PctZero,-- default value, Percent of the impervious area with no depression storage. @@ -18,12 +18,12 @@ SELECT ca.identifier as description, ca.obj_id::varchar as tag, state as state, - CASE + CASE WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn_obj_id as obj_id -FROM +FROM ( SELECT ca.*, sr.surface_storage, 'rw_current' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca diff --git a/swmm_views/11_vw_swmm_dwf.sql b/swmm_views/11_vw_swmm_dwf.sql index bd0931792..e97fb0ead 100644 --- a/swmm_views/11_vw_swmm_dwf.sql +++ b/swmm_views/11_vw_swmm_dwf.sql @@ -1,7 +1,7 @@ -- Creates Dry Weather Flow related to the catchment area CREATE OR REPLACE VIEW qgep_swmm.vw_dwf AS SELECT - CASE + CASE WHEN type_ca = 'rw_current' THEN fk_wastewater_networkelement_rw_current WHEN type_ca = 'rw_planned' THEN fk_wastewater_networkelement_rw_planned WHEN type_ca = 'ww_current' THEN fk_wastewater_networkelement_ww_current @@ -10,21 +10,21 @@ SELECT 'FLOW'::varchar as Constituent, CASE WHEN fk_wastewater_networkelement_ww_current is not null - THEN - CASE - WHEN waste_water_production_current IS NOT NULL THEN waste_water_production_current + THEN + CASE + WHEN waste_water_production_current IS NOT NULL THEN waste_water_production_current ELSE - CASE + CASE WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_current,0) * surface_area * 160 / (24 * 60 * 60) ELSE coalesce(population_density_current,0) * ST_Area(perimeter_geometry) / 10000 * 160 / (24 * 60 * 60) END END WHEN fk_wastewater_networkelement_ww_planned is not null - THEN - CASE + THEN + CASE WHEN waste_water_production_planned IS NOT NULL THEN waste_water_production_planned ELSE - CASE + CASE WHEN (surface_area IS NOT NULL AND surface_area != 0) THEN coalesce(population_density_planned,0) * surface_area * 160 / (24 * 60 * 60) ELSE coalesce(population_density_planned,0) * ST_Area(perimeter_geometry) / 10000 * 160 / (24 * 60 * 60) END @@ -36,12 +36,12 @@ SELECT END as Baseline, -- 160 Litre / inhabitant /day 'dailyPatternDWF'::varchar as Patterns, state as state, - CASE + CASE WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn_obj_id as obj_id -FROM +FROM ( SELECT ca.*,'current' as state, 'rw_current' as type_ca, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca diff --git a/swmm_views/12_vw_swmm_raingages.sql b/swmm_views/12_vw_swmm_raingages.sql index 8437a9472..cfdac4cc6 100644 --- a/swmm_views/12_vw_swmm_raingages.sql +++ b/swmm_views/12_vw_swmm_raingages.sql @@ -8,12 +8,12 @@ SELECT 'TIMESERIES default_qgep_raingage_timeserie'::varchar as Source, st_centroid(perimeter_geometry)::geometry(Point, %(SRID)s) as geom, state, - CASE + CASE WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn_obj_id as obj_id -FROM +FROM ( SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca diff --git a/swmm_views/13_vw_swmm_infiltrations.sql b/swmm_views/13_vw_swmm_infiltrations.sql index cdd8f1254..355ec0733 100644 --- a/swmm_views/13_vw_swmm_infiltrations.sql +++ b/swmm_views/13_vw_swmm_infiltrations.sql @@ -1,7 +1,7 @@ -- Creates default infiltration for each subcatchment CREATE OR REPLACE VIEW qgep_swmm.vw_infiltration AS SELECT - CASE + CASE WHEN state = 'current' THEN concat(replace(ca.obj_id, ' ', '_'), '_', 'rw_current') WHEN state = 'planned' THEN concat(replace(ca.obj_id, ' ', '_'), '_', 'rw_planned') END as Subcatchment, @@ -11,12 +11,12 @@ SELECT 7 as DryTime, 0 as MaxInfil, state, - CASE + CASE WHEN _function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, wn_obj_id as obj_id -FROM +FROM ( SELECT ca.*,'current' as state, wn.obj_id as wn_obj_id, cfhi.vsacode AS _function_hierarchic FROM qgep_od.catchment_area as ca diff --git a/swmm_views/16_vw_swmm_pumps.sql b/swmm_views/16_vw_swmm_pumps.sql index 53f0dfd7d..11638d50c 100644 --- a/swmm_views/16_vw_swmm_pumps.sql +++ b/swmm_views/16_vw_swmm_pumps.sql @@ -28,11 +28,11 @@ SELECT END ) as description, pu.obj_id::varchar as tag, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, diff --git a/swmm_views/18_vw_swmm_storages.sql b/swmm_views/18_vw_swmm_storages.sql index ae0213f74..1001e6662 100644 --- a/swmm_views/18_vw_swmm_storages.sql +++ b/swmm_views/18_vw_swmm_storages.sql @@ -8,11 +8,11 @@ SELECT coalesce(wn.bottom_level,0) as InvertElev, coalesce((co.level-wn.bottom_level),0) as MaxDepth, 0 as InitDepth, - CASE + CASE WHEN hr.fk_hydr_geometry IS NOT NULL THEN 'TABULAR' ELSE 'FUNCTIONAL' END as Shape, - CASE + CASE WHEN hr.fk_hydr_geometry IS NOT NULL THEN concat('storageCurve@', wn.obj_id) ELSE '0' END as CurveCoefficientOrCurveName, -- curve coefficient if FONCTIONAL curve name if TABULAR @@ -22,15 +22,15 @@ SELECT 0 as Fevap, NULL as Psi, NULL as Ksat, -- conductivity - NULL as IMD, + NULL as IMD, ws.identifier::text as description, CONCAT_WS(',','special_structure', ssf.value_en) as tag, wn.situation_geometry as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -89,11 +89,11 @@ SELECT coalesce(wn.bottom_level,0) as InvertElev, coalesce((ii.upper_elevation-wn.bottom_level),0) as MaxDepth, 0 as InitDepth, - CASE + CASE WHEN hr.fk_hydr_geometry IS NOT NULL THEN 'TABULAR' ELSE 'FUNCTIONAL' END as Shape, - CASE + CASE WHEN hr.fk_hydr_geometry IS NOT NULL THEN concat('storageCurve@',wn.obj_id) ELSE '0' END as CurveCoefficientOrCurveName, -- curve coefficient if FONCTIONAL curve name if TABULAR @@ -107,11 +107,11 @@ SELECT ws.identifier::text as description, CONCAT_WS(',','infiltration_installation', iik.value_en) as tag, wn.situation_geometry as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -158,7 +158,7 @@ SELECT 0 as SurchargeDepth, 0 as Fevap, NULL as Psi, - NULL as Ksat, + NULL as Ksat, NULL as IMD, concat_ws(';', ws.identifier::text, @@ -166,11 +166,11 @@ SELECT ) as description, 'Prank weir' as tag, wn.situation_geometry as geom, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN ws._function_hierarchic in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -186,4 +186,4 @@ FROM qgep_od.prank_weir pw LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) AND vl_oc_dig.vsacode = 6223 --'yes; - AND vL_oc_ki.vsacode = 6220; -- h/q relations (Q/Q relations are not supported by SWMM) + AND vL_oc_ki.vsacode = 6220; -- h/q relations (Q/Q relations are not supported by SWMM) diff --git a/swmm_views/19_vw_swmm_outlets.sql b/swmm_views/19_vw_swmm_outlets.sql index c9b95b64e..0eeec0d2c 100644 --- a/swmm_views/19_vw_swmm_outlets.sql +++ b/swmm_views/19_vw_swmm_outlets.sql @@ -9,11 +9,11 @@ SELECT concat('prank_weir_curve@',pw.obj_id) as QTable_Qcoeff, NULL as Qexpon, 'NO' as Gated, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -29,4 +29,4 @@ FROM qgep_od.prank_weir pw LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) AND vL_oc_dig.vsacode = 6223 --'yes; - AND vl_oc_ki.vsacode = 6220; -- h/q relations (Q/Q relations are not supported by SWMM) + AND vl_oc_ki.vsacode = 6220; -- h/q relations (Q/Q relations are not supported by SWMM) diff --git a/swmm_views/20_vw_swmm_orifices.sql b/swmm_views/20_vw_swmm_orifices.sql index 0fa173280..a4cff52ef 100644 --- a/swmm_views/20_vw_swmm_orifices.sql +++ b/swmm_views/20_vw_swmm_orifices.sql @@ -12,4 +12,4 @@ NULL::text as ToNode, NULL::text as state, NULL::text as hierarchy, NULL::text as obj_id -LIMIT 0; \ No newline at end of file +LIMIT 0; diff --git a/swmm_views/21_vw_swmm_weirs.sql b/swmm_views/21_vw_swmm_weirs.sql index 48f81cbe0..977a7c2a5 100644 --- a/swmm_views/21_vw_swmm_weirs.sql +++ b/swmm_views/21_vw_swmm_weirs.sql @@ -15,11 +15,11 @@ SELECT NULL as RoadWidth, NULL as RoadSurf, NULL as CoeffCurve, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -36,7 +36,7 @@ FROM qgep_od.prank_weir pw LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) AND (vl_oc_dig.vsacode != 6223 OR vl_oc_dig.vsacode IS NULL) --'yes; - OR (vl_oc_ki.vsacode != 6220 OR vl_oc_ki.vsacode IS NULL)-- h/q relations (Q/Q relations are not supported by SWMM) + OR (vl_oc_ki.vsacode != 6220 OR vl_oc_ki.vsacode IS NULL)-- h/q relations (Q/Q relations are not supported by SWMM) UNION ALL @@ -55,11 +55,11 @@ SELECT NULL as RoadWidth, NULL as RoadSurf, NULL as CoeffCurve, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, diff --git a/swmm_views/22_vw_swmm_curves.sql b/swmm_views/22_vw_swmm_curves.sql index afaf31e10..0e52fb86a 100644 --- a/swmm_views/22_vw_swmm_curves.sql +++ b/swmm_views/22_vw_swmm_curves.sql @@ -6,18 +6,18 @@ CREATE OR REPLACE VIEW qgep_swmm.vw_curves AS -- Pump curves (SELECT concat('pump_curve@',pu.obj_id)::varchar as Name, - CASE + CASE WHEN ROW_NUMBER () OVER (PARTITION BY pu.obj_id ORDER BY pu.obj_id, hq.altitude) = 1 THEN 'Pump4' ELSE NULL END as type, hq.altitude as XValue, hq.flow as YValue, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -34,7 +34,7 @@ FROM qgep_od.hq_relation hq LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) AND vl_oc_dig.vsacode = 6223 --'yes; - AND vl_oc_ki.vsacode = 6220 -- h/q relations (Q/Q relations are not supported by SWMM) + AND vl_oc_ki.vsacode = 6220 -- h/q relations (Q/Q relations are not supported by SWMM) AND pu.obj_id IS NOT NULL ORDER BY pu.obj_id, hq.altitude) @@ -43,18 +43,18 @@ UNION ALL -- Prank weir curves (SELECT concat('prank_weir_curve@',pw.obj_id)::varchar as Name, - CASE + CASE WHEN ROW_NUMBER () OVER (PARTITION BY pw.obj_id ORDER BY pw.obj_id, hq.altitude) = 1 THEN 'Rating' ELSE NULL END as type, hq.altitude as XValue, hq.flow as YValue, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -71,7 +71,7 @@ FROM qgep_od.hq_relation hq LEFT JOIN qgep_vl.channel_function_hierarchic cfhi ON cfhi.code=ws._function_hierarchic WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) AND vl_oc_dig.vsacode = 6223 --'yes; - AND vl_oc_ki.vsacode = 6220 -- h/q relations (Q/Q relations are not supported by SWMM) + AND vl_oc_ki.vsacode = 6220 -- h/q relations (Q/Q relations are not supported by SWMM) AND pw.obj_id IS NOT NULL ORDER BY pw.obj_id, hq.altitude) @@ -80,18 +80,18 @@ UNION ALL -- storage curves (SELECT concat('storageCurve@',wn.obj_id)::varchar as Name, - CASE + CASE WHEN ROW_NUMBER () OVER (PARTITION BY wn.obj_id ORDER BY wn.obj_id, hr.water_depth) = 1 THEN 'Storage' ELSE NULL END as type, hr.water_depth as XValue, hr.water_surface as YValue, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, diff --git a/swmm_views/23_vw_swmm_xsections.sql b/swmm_views/23_vw_swmm_xsections.sql index 84da065c1..337746075 100644 --- a/swmm_views/23_vw_swmm_xsections.sql +++ b/swmm_views/23_vw_swmm_xsections.sql @@ -38,11 +38,11 @@ SELECT DISTINCT 0 as Geom4, 1 as Barrels, NULL as Culvert, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -70,11 +70,11 @@ SELECT NULL as Geom4, NULL as Barrels, NULL as Culvert, - CASE + CASE WHEN ws_st.vsacode IN (7959, 6529, 6526) THEN 'planned' ELSE 'current' END as state, - CASE + CASE WHEN cfhi.vsacode in (5062, 5064, 5066, 5068, 5069, 5070, 5071, 5072, 5074) THEN 'primary' ELSE 'secondary' END as hierarchy, @@ -90,4 +90,3 @@ WHERE ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959) AND oc.overflow_char_digital != 6223 --'NO or unknown; OR oc.kind_overflow_char != 6220 -- Q/Q relation or unknown AND ws_st.vsacode IN (6530, 6533, 8493, 6529, 6526, 7959); - diff --git a/swmm_views/24_vw_swmm_coordinates.sql b/swmm_views/24_vw_swmm_coordinates.sql index 9170717b3..9aedfedca 100644 --- a/swmm_views/24_vw_swmm_coordinates.sql +++ b/swmm_views/24_vw_swmm_coordinates.sql @@ -39,7 +39,7 @@ SELECT ROUND(ST_Y(geom)::numeric,2) as Y_Coord, state, hierarchy, - obj_id + obj_id FROM qgep_swmm.vw_dividers WHERE geom IS NOT NULL diff --git a/test/test_geometry.py b/test/test_geometry.py index f58091ff3..9d43cabe3 100644 --- a/test/test_geometry.py +++ b/test/test_geometry.py @@ -1,9 +1,9 @@ -import unittest +import copy import os +import unittest import psycopg2 import psycopg2.extras -import copy from .utils import DbTestBase @@ -16,472 +16,562 @@ def tearDownClass(cls): @classmethod def setUpClass(cls): - pgservice = os.environ.get('PGSERVICE') or 'pg_qgep' - cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) + pgservice = os.environ.get("PGSERVICE") or "pg_qgep" + cls.conn = psycopg2.connect(f"service={pgservice}") def test_vw_qgep_reach_geometry_insert(self): # 1. insert geometry with Z and no rp_from_level and no rp_to_level # INSERT INTO qgep_od.vw_qgep_reach (progression_geometry, rp_from_obj_id, rp_to_obj_id) VALUES (ST_SetSRID(ST_GeomFromText('COMPOUNDCURVE Z ((1 2 3,4 5 6,7 8 9))'), 2056), 'BBB 1337_0001', 'CCC 1337_0001' ); row = { - 'progression_geometry': '01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240', - 'rp_from_obj_id': 'BBB 1337_0001', - 'rp_to_obj_id': 'CCC 1337_0001' + "progression_geometry": "01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240", + "rp_from_obj_id": "BBB 1337_0001", + "rp_to_obj_id": "CCC 1337_0001", } expected_row = copy.deepcopy(row) # vw_qgep_reach has the geometry but NaN as Z on start_point and NaN as Z on end_point: SELECT ST_SetSRID( ST_ForceCurve(ST_MakeLine(ARRAY[ST_MakePoint(1,2,'NaN'), ST_MakePoint(4,5,6), ST_MakePoint(7,8,'NaN')])), 2056) - expected_row['progression_geometry'] = '01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F' + expected_row["progression_geometry"] = ( + "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F" + ) # rp_from_level is NULL - expected_row['rp_from_level'] = None + expected_row["rp_from_level"] = None # rp_to_level is NULL - expected_row['rp_to_level'] = None - obj_id = self.insert_check('vw_qgep_reach', row, expected_row) + expected_row["rp_to_level"] = None + self.insert_check("vw_qgep_reach", row, expected_row) # reach_point has on rp_to as Z NaN: SELECT ST_SetSRID( ST_MakePoint(1,2,'NaN'), 2056) - row = self.select('reach_point', 'BBB 1337_0001') - assert row['situation_geometry'] == '01010000A008080000000000000000F03F0000000000000040000000000000F87F' + row = self.select("reach_point", "BBB 1337_0001") + assert ( + row["situation_geometry"] + == "01010000A008080000000000000000F03F0000000000000040000000000000F87F" + ) # reach_point has on rp_from as Z NaN: SELECT ST_SetSRID( ST_MakePoint(7,8,'NaN'), 2056) - row = self.select('reach_point', 'CCC 1337_0001') - assert row['situation_geometry'] == '01010000A0080800000000000000001C400000000000002040000000000000F87F' + row = self.select("reach_point", "CCC 1337_0001") + assert ( + row["situation_geometry"] + == "01010000A0080800000000000000001C400000000000002040000000000000F87F" + ) # 2. insert geometry with Z and no rp_from_level and 66 as rp_to_level # INSERT INTO qgep_od.vw_qgep_reach (obj_id, progression_geometry, rp_to_level, rp_from_obj_id, rp_to_obj_id) VALUES ('AAA 1337_0002', ST_SetSRID(ST_GeomFromText('COMPOUNDCURVE Z ((1 2 3,4 5 6,7 8 9))'), 2056), 66, 'BBB 1337_0002', 'CCC 1337_0002' ); row = { - 'progression_geometry': '01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240', - 'rp_to_level': '66', - 'rp_from_obj_id': 'BBB 1337_0002', - 'rp_to_obj_id': 'CCC 1337_0002' + "progression_geometry": "01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240", + "rp_to_level": "66", + "rp_from_obj_id": "BBB 1337_0002", + "rp_to_obj_id": "CCC 1337_0002", } expected_row = copy.deepcopy(row) # vw_qgep_reach has the geometry but NaN as Z on start_point and 66 (rp_to_level) as Z on end_point: SELECT ST_SetSRID( ST_ForceCurve(ST_MakeLine(ARRAY[ST_MakePoint(1,2,'NaN'), ST_MakePoint(4,5,6), ST_MakePoint(7,8,66)])), 2056) - expected_row['progression_geometry'] = '01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000805040' + expected_row["progression_geometry"] = ( + "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000805040" + ) # rp_from_level is NULL - expected_row['rp_from_level'] = None + expected_row["rp_from_level"] = None # rp_to_level is 66.000 - expected_row['rp_to_level'] = '66.000' - obj_id = self.insert_check('vw_qgep_reach', row, expected_row) + expected_row["rp_to_level"] = "66.000" + self.insert_check("vw_qgep_reach", row, expected_row) # reach_point has on rp_from as Z NaN: SELECT ST_SetSRID( ST_MakePoint(1,2,'NaN'), 2056) - row = self.select('reach_point', 'BBB 1337_0002') - assert row['situation_geometry'] == '01010000A008080000000000000000F03F0000000000000040000000000000F87F' + row = self.select("reach_point", "BBB 1337_0002") + assert ( + row["situation_geometry"] + == "01010000A008080000000000000000F03F0000000000000040000000000000F87F" + ) # reach_point has on rp_to as Z 66.000: SELECT ST_SetSRID( ST_MakePoint(7,8,66.000), 2056) - row = self.select('reach_point', 'CCC 1337_0002') - assert row['situation_geometry'] == '01010000A0080800000000000000001C4000000000000020400000000000805040' + row = self.select("reach_point", "CCC 1337_0002") + assert ( + row["situation_geometry"] + == "01010000A0080800000000000000001C4000000000000020400000000000805040" + ) # 3. insert geometry with Z and 77 as rp_from_level and NULL as rp_to_level # INSERT INTO qgep_od.vw_qgep_reach (obj_id, progression_geometry, rp_from_level, rp_to_level, rp_from_obj_id, rp_to_obj_id) VALUES ('AAA 1337_0003', ST_SetSRID(ST_GeomFromText('COMPOUNDCURVE Z ((1 2 3,4 5 6,7 8 9))'), 2056), NULL, 77, 'BBB 1337_0003', 'CCC 1337_0003' ); row = { - 'progression_geometry': '01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240', - 'rp_from_level': '77.000', - 'rp_to_level': None, - 'rp_from_obj_id': 'BBB 1337_0003', - 'rp_to_obj_id': 'CCC 1337_0003' + "progression_geometry": "01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240", + "rp_from_level": "77.000", + "rp_to_level": None, + "rp_from_obj_id": "BBB 1337_0003", + "rp_to_obj_id": "CCC 1337_0003", } expected_row = copy.deepcopy(row) # vw_qgep_reach has the geometry but 77 (rp_from_level) as Z on start_point and NaN as Z on end_point: SELECT ST_SetSRID( ST_ForceCurve(ST_MakeLine(ARRAY[ST_MakePoint(1,2,77), ST_MakePoint(4,5,6), ST_MakePoint(7,8,'NaN')])), 2056) - expected_row['progression_geometry'] = '01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000004053400000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F' + expected_row["progression_geometry"] = ( + "01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000004053400000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F" + ) # rp_from_level is 77.000 - expected_row['rp_from_level'] = '77.000' + expected_row["rp_from_level"] = "77.000" # rp_to_level is NULL - expected_row['rp_to_level'] = None - obj_id = self.insert_check('vw_qgep_reach', row, expected_row) + expected_row["rp_to_level"] = None + self.insert_check("vw_qgep_reach", row, expected_row) # reach_point has on rp_from as Z 77.000: SELECT ST_SetSRID( ST_MakePoint(1,2,77.000), 2056) - row = self.select('reach_point', 'BBB 1337_0003') - assert row['situation_geometry'] == '01010000A008080000000000000000F03F00000000000000400000000000405340' + row = self.select("reach_point", "BBB 1337_0003") + assert ( + row["situation_geometry"] + == "01010000A008080000000000000000F03F00000000000000400000000000405340" + ) # reach_point has on rp_to as Z 66.000: SELECT ST_SetSRID( ST_MakePoint(7,8,'NaN'), 2056) - row = self.select('reach_point', 'CCC 1337_0003') - assert row['situation_geometry'] == '01010000A0080800000000000000001C400000000000002040000000000000F87F' - + row = self.select("reach_point", "CCC 1337_0003") + assert ( + row["situation_geometry"] + == "01010000A0080800000000000000001C400000000000002040000000000000F87F" + ) def test_vw_qgep_reach_geometry_update(self): # first insert # no Z and no rp_from_level and no rp_to_level # INSERT INTO qgep_od.vw_qgep_reach (progression_geometry, rp_from_obj_id, rp_to_obj_id) VALUES (ST_SetSRID( ST_ForceCurve(ST_MakeLine(ARRAY[ST_MakePoint(1,2,'NaN'), ST_MakePoint(4,5,'NaN'), ST_MakePoint(7,8,'NaN')])), 2056), 'BBB 1337_1010', 'CCC 1337_1010' ); row = { - 'progression_geometry': '01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F00000000000010400000000000001440000000000000F87F0000000000001C400000000000002040000000000000F87F', - 'rp_from_obj_id': 'BBB 1337_1010', - 'rp_to_obj_id': 'CCC 1337_1010' + "progression_geometry": "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F00000000000010400000000000001440000000000000F87F0000000000001C400000000000002040000000000000F87F", + "rp_from_obj_id": "BBB 1337_1010", + "rp_to_obj_id": "CCC 1337_1010", } - obj_id = self.insert('vw_qgep_reach', row) + obj_id = self.insert("vw_qgep_reach", row) # 1. change geometry including Z with startpoint Z 3 and endpoint Z 9, no change on rp_from_level, no change on rp_to_level # UPDATE qgep_od.vw_qgep_reach SET progression_geometry=ST_SetSRID(ST_GeomFromText('COMPOUNDCURVE Z ((1 2 3,4 5 6,7 8 9))'), 2056) WHERE obj_id=obj_id' row = { - 'progression_geometry': '01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240' + "progression_geometry": "01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240" } - self.update('vw_qgep_reach', row, obj_id) - new_row = self.select('vw_qgep_reach', obj_id) - # vw_qgep_reach has the geometry - assert new_row['progression_geometry'] == '01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240' + self.update("vw_qgep_reach", row, obj_id) + new_row = self.select("vw_qgep_reach", obj_id) + # vw_qgep_reach has the geometry + assert ( + new_row["progression_geometry"] + == "01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000002240" + ) # rp_from_level is 3 (startpoint of geometry) - assert new_row['rp_from_level'] == 3 + assert new_row["rp_from_level"] == 3 # rp_to_level is 9 (endpoint of geometry) - assert new_row['rp_to_level'] == 9 + assert new_row["rp_to_level"] == 9 # reach_point has on rp_from as Z 3 - new_row = self.select('reach_point', 'BBB 1337_1010') - assert new_row['level'] == 3 + new_row = self.select("reach_point", "BBB 1337_1010") + assert new_row["level"] == 3 # reach_point has on rp_to as Z 9 - new_row = self.select('reach_point', 'CCC 1337_1010') - assert new_row['level'] == 9 + new_row = self.select("reach_point", "CCC 1337_1010") + assert new_row["level"] == 9 # 2. change geometry including Z with startpoint Z 33 and endpoint Z 99, no change on rp_from_level, but change on rp_to_level to NULL # UPDATE qgep_od.vw_qgep_reach SET progression_geometry=ST_SetSRID(ST_GeomFromText('COMPOUNDCURVE Z ((1 2 33,4 5 6,7 8 99))'), 2056), rp_to_level=NULL WHERE obj_id=obj_id' row = { - 'progression_geometry': '01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000008040400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000C05840', - 'rp_to_level': None + "progression_geometry": "01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000008040400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000C05840", + "rp_to_level": None, } - self.update('vw_qgep_reach', row, obj_id) - new_row = self.select('vw_qgep_reach', obj_id) - # vw_qgep_reach has the geometry but as endpoint Z there is NaN: SELECT ST_SetSRID( ST_ForceCurve(ST_MakeLine(ARRAY[ST_MakePoint(1,2,33), ST_MakePoint(4,5,6), ST_MakePoint(7,8,'NaN')])), 2056) - assert new_row['progression_geometry'] == '01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000008040400000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F' + self.update("vw_qgep_reach", row, obj_id) + new_row = self.select("vw_qgep_reach", obj_id) + # vw_qgep_reach has the geometry but as endpoint Z there is NaN: SELECT ST_SetSRID( ST_ForceCurve(ST_MakeLine(ARRAY[ST_MakePoint(1,2,33), ST_MakePoint(4,5,6), ST_MakePoint(7,8,'NaN')])), 2056) + assert ( + new_row["progression_geometry"] + == "01090000A00808000001000000010200008003000000000000000000F03F000000000000004000000000008040400000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F" + ) # rp_from_level is 33 (startpoint of geometry) - assert new_row['rp_from_level'] == 33 + assert new_row["rp_from_level"] == 33 # rp_to_level is None (endpoint of geometry) and rp_to_level - assert new_row['rp_to_level'] == None + assert new_row["rp_to_level"] == None # reach_point has on rp_from as Z 3 - new_row = self.select('reach_point', 'BBB 1337_1010') - assert new_row['level'] == 33 + new_row = self.select("reach_point", "BBB 1337_1010") + assert new_row["level"] == 33 # reach_point has on rp_to as Z None - new_row = self.select('reach_point', 'CCC 1337_1010') - assert new_row['level'] == None + new_row = self.select("reach_point", "CCC 1337_1010") + assert new_row["level"] == None # 3. change geometry including Z with startpoint Z 300 and endpoint Z 900, but change on rp_from_level to 333, and change on rp_to_level to 999 # UPDATE qgep_od.vw_qgep_reach SET progression_geometry=ST_SetSRID(ST_GeomFromText('COMPOUNDCURVE Z ((1 2 300,4 5 6,7 8 900))'), 2056), rp_to_level=NULL WHERE obj_id=obj_id' row = { - 'progression_geometry': '01090000A00808000001000000010200008003000000000000000000F03F00000000000000400000000000C072400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000208C40', - 'rp_from_level': '333.000', - 'rp_to_level': '999.000' + "progression_geometry": "01090000A00808000001000000010200008003000000000000000000F03F00000000000000400000000000C072400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000208C40", + "rp_from_level": "333.000", + "rp_to_level": "999.000", } - self.update('vw_qgep_reach', row, obj_id) - new_row = self.select('vw_qgep_reach', obj_id) + self.update("vw_qgep_reach", row, obj_id) + new_row = self.select("vw_qgep_reach", obj_id) # vw_qgep_reach has the geometry but as startpoint Z is 333 and on endpoint Z is 999: SELECT ST_SetSRID( ST_ForceCurve(ST_MakeLine(ARRAY[ST_MakePoint(1,2,333), ST_MakePoint(4,5,6), ST_MakePoint(7,8,'999)])), 2056) - assert new_row['progression_geometry'] == '01090000A00808000001000000010200008003000000000000000000F03F00000000000000400000000000D074400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000388F40' + assert ( + new_row["progression_geometry"] + == "01090000A00808000001000000010200008003000000000000000000F03F00000000000000400000000000D074400000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000388F40" + ) # rp_from_level is 333 (startpoint of geometry) and rp_from_level - assert new_row['rp_from_level'] == 333 + assert new_row["rp_from_level"] == 333 # rp_to_level is 999 (endpoint of geometry) and rp_to_level - assert new_row['rp_to_level'] == 999 + assert new_row["rp_to_level"] == 999 # reach_point has on rp_from as Z 333 - new_row = self.select('reach_point', 'BBB 1337_1010') - assert new_row['level'] == 333 + new_row = self.select("reach_point", "BBB 1337_1010") + assert new_row["level"] == 333 # reach_point has on rp_to as Z 999 - new_row = self.select('reach_point', 'CCC 1337_1010') - assert new_row['level'] == 999 + new_row = self.select("reach_point", "CCC 1337_1010") + assert new_row["level"] == 999 # 4. change geometry including Z with startpoint Z NaN and endpoint Z NaN, no change on rp_from_level, no change on rp_to_level # UPDATE qgep_od.vw_qgep_reach SET progression_geometry=ST_SetSRID( ST_ForceCurve(ST_MakeLine(ARRAY[ST_MakePoint(1,2,'NaN'), ST_MakePoint(4,5,6), ST_MakePoint(7,8,'NaN')])), 2056) WHERE obj_id=obj_id' row = { - 'progression_geometry': '01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F' + "progression_geometry": "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F" } - self.update('vw_qgep_reach', row, obj_id) - new_row = self.select('vw_qgep_reach', obj_id) - # vw_qgep_reach has the geometry - assert new_row['progression_geometry'] == '01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F' + self.update("vw_qgep_reach", row, obj_id) + new_row = self.select("vw_qgep_reach", obj_id) + # vw_qgep_reach has the geometry + assert ( + new_row["progression_geometry"] + == "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F" + ) # rp_from_level is NULL (startpoint of geometry) - assert new_row['rp_from_level'] == None + assert new_row["rp_from_level"] == None # rp_to_level is NULL (endpoint of geometry) - assert new_row['rp_to_level'] == None + assert new_row["rp_to_level"] == None # reach_point has on rp_from as Z NULL - new_row = self.select('reach_point', 'BBB 1337_1010') - assert new_row['level'] == None + new_row = self.select("reach_point", "BBB 1337_1010") + assert new_row["level"] == None # reach_point has on rp_to as Z NULL - new_row = self.select('reach_point', 'CCC 1337_1010') - assert new_row['level'] == None - + new_row = self.select("reach_point", "CCC 1337_1010") + assert new_row["level"] == None def test_vw_qgep_wastewater_structure_geometry_insert(self): # 1. insert geometry and no co_level and no wn_bottom_level # INSERT INTO qgep_od.vw_qgep_wastewater_structure (situation_geometry, wn_obj_id, co_obj_id) VALUES (ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056), '1337_1001', '1337_1001'); row = { - 'situation_geometry': '0101000020080800000000000020D6434100000000804F3241', - 'wn_obj_id': '1337_1001', - 'co_obj_id': '1337_1001' + "situation_geometry": "0101000020080800000000000020D6434100000000804F3241", + "wn_obj_id": "1337_1001", + "co_obj_id": "1337_1001", } expected_row = copy.deepcopy(row) # ws_qgep_wastewaterstructure has the geometry but NaN as Z because of no co_level (geometry of cover): ST_SetSRID(ST_Collect(ST_MakePoint(2600000, 1200000, 'NaN')), 2056) - expected_row['situation_geometry'] = '0101000020080800000000000020D6434100000000804F3241' + expected_row["situation_geometry"] = "0101000020080800000000000020D6434100000000804F3241" # co_level is NULL - expected_row['co_level'] = None + expected_row["co_level"] = None # wn_bottom_level NULL - expected_row['wn_bottom_level'] = None - obj_id = self.insert_check('vw_qgep_wastewater_structure', row, expected_row) + expected_row["wn_bottom_level"] = None + self.insert_check("vw_qgep_wastewater_structure", row, expected_row) # cover geometry has the geometry but NaN as Z: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - row = self.select('cover', '1337_1001') - assert row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' + row = self.select("cover", "1337_1001") + assert ( + row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) # wastewater_node has the geometry but NaN as Z: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - row = self.select('wastewater_node', '1337_1001') - assert row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' + row = self.select("wastewater_node", "1337_1001") + assert ( + row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) # 2. insert geometry with no co_level and WITH wn_bottom_level # INSERT INTO qgep_od.vw_qgep_wastewater_structure (situation_geometry, wn_obj_id, co_obj_id, wn_bottom_level) VALUES (ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056), '1337_1002', '1337_1002', 200.000); row = { - 'situation_geometry': '0101000020080800000000000020D6434100000000804F3241', - 'wn_obj_id': '1337_1002', - 'co_obj_id': '1337_1002', - 'wn_bottom_level': '200.000' + "situation_geometry": "0101000020080800000000000020D6434100000000804F3241", + "wn_obj_id": "1337_1002", + "co_obj_id": "1337_1002", + "wn_bottom_level": "200.000", } expected_row = copy.deepcopy(row) # ws_qgep_wastewaterstructure has the 2D geometry: ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056) - expected_row['situation_geometry'] = '0101000020080800000000000020D6434100000000804F3241' + expected_row["situation_geometry"] = "0101000020080800000000000020D6434100000000804F3241" # co_level is NULL - expected_row['co_level'] = None + expected_row["co_level"] = None # wn_bottom_level is new wn_bottom_level - expected_row['wn_bottom_level'] = '200.000' - obj_id = self.insert_check('vw_qgep_wastewater_structure', row, expected_row) + expected_row["wn_bottom_level"] = "200.000" + self.insert_check("vw_qgep_wastewater_structure", row, expected_row) # cover geometry has the geometry but NaN as Z: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - row = self.select('cover', '1337_1002') - assert row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' + row = self.select("cover", "1337_1002") + assert ( + row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) # wastewater_node has the geometry and wn_buttom_level as Z: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - row = self.select('wastewater_node', '1337_1002') - assert row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000006940' + row = self.select("wastewater_node", "1337_1002") + assert ( + row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) # 3. insert geometry with Z and WITH co_level and WITH wn_bottom_level # INSERT INTO qgep_od.vw_qgep_wastewater_structure (situation_geometry, wn_obj_id, co_obj_id, wn_bottom_level, co_level) VALUES (ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056), '1337_1003', '1337_1003', 200.000, 500.000); row = { - 'situation_geometry': '0101000020080800000000000020D6434100000000804F3241', - 'wn_obj_id': '1337_1003', - 'co_obj_id': '1337_1003', - 'wn_bottom_level': '200.000', - 'co_level': '500.000' + "situation_geometry": "0101000020080800000000000020D6434100000000804F3241", + "wn_obj_id": "1337_1003", + "co_obj_id": "1337_1003", + "wn_bottom_level": "200.000", + "co_level": "500.000", } expected_row = copy.deepcopy(row) # ws_qgep_wastewaterstructure has 2D geometry: ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056) - expected_row['situation_geometry'] = '0101000020080800000000000020D6434100000000804F3241' + expected_row["situation_geometry"] = "0101000020080800000000000020D6434100000000804F3241" # co_level is new co_level - expected_row['co_level'] = '500.000' + expected_row["co_level"] = "500.000" # wn_bottom_level is new wn_bottom_level - expected_row['wn_bottom_level'] = '200.000' - obj_id = self.insert_check('vw_qgep_wastewater_structure', row, expected_row) + expected_row["wn_bottom_level"] = "200.000" + self.insert_check("vw_qgep_wastewater_structure", row, expected_row) # cover geometry has the geometry and co_level as Z: ST_SetSRID(ST_MakePoint(2600000, 1200000, 500), 2056) - row = self.select('cover', '1337_1003') - assert row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000407F40' + row = self.select("cover", "1337_1003") + assert ( + row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000407F40" + ) # wastewater_node has the geometry and wn_buttom_level as Z: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - row = self.select('wastewater_node', '1337_1003') - assert row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000006940' - + row = self.select("wastewater_node", "1337_1003") + assert ( + row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) def test_vw_qgep_wastewater_structure_geometry_update(self): # first insert # insert geometry with no co_level and no wn_bottom_level # INSERT INTO qgep_od.vw_qgep_wastewater_structure (situation_geometry, wn_obj_id, co_obj_id) VALUES (ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056), '1337_1010', '1337_1010'); row = { - 'situation_geometry': '0101000020080800000000000020D6434100000000804F3241', - 'ws_type': 'manhole', - 'wn_obj_id': '1337_1010', - 'co_obj_id': '1337_1010' + "situation_geometry": "0101000020080800000000000020D6434100000000804F3241", + "ws_type": "manhole", + "wn_obj_id": "1337_1010", + "co_obj_id": "1337_1010", } - obj_id = self.insert('vw_qgep_wastewater_structure', row) + obj_id = self.insert("vw_qgep_wastewater_structure", row) # 1. update no change on geometry with Z but WITH wn_bottom_level # UPDATE qgep_od.vw_wastewater_node SET wn_bottom_level=200.000 WHERE obj_id = obj_id - row = { - 'wn_bottom_level': '200.000' - } - self.update('vw_qgep_wastewater_structure', row, obj_id) - new_row = self.select('vw_qgep_wastewater_structure', obj_id) + row = {"wn_bottom_level": "200.000"} + self.update("vw_qgep_wastewater_structure", row, obj_id) + new_row = self.select("vw_qgep_wastewater_structure", obj_id) # no change on geometry of ws_qgep_wastewaterstructure (because it's geometry of cover that does not change) - self.assertEqual(new_row['situation_geometry'], '0101000020080800000000000020D6434100000000804F3241') + self.assertEqual( + new_row["situation_geometry"], "0101000020080800000000000020D6434100000000804F3241" + ) # no change on co_level - self.assertIsNone(new_row['co_level']) + self.assertIsNone(new_row["co_level"]) # wn_bottom_level is new wn_bottom_level - self.assertEqual(new_row['wn_bottom_level'], 200.000) + self.assertEqual(new_row["wn_bottom_level"], 200.000) # no change on cover geometry: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - new_row = self.select('cover', '1337_1010') - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' + new_row = self.select("cover", "1337_1010") + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) # wastewater_node geometry has Z from new wn_bottom_level: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - new_row = self.select('wastewater_node', '1337_1010') - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000006940' + new_row = self.select("wastewater_node", "1337_1010") + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) # 2. update change co_level # UPDATE qgep_od.vw_wastewater_node SET level=500.000 WHERE obj_id = obj_id - row = { - 'co_level': '500.000' - } - self.update('vw_qgep_wastewater_structure', row, obj_id) - new_row = self.select('vw_qgep_wastewater_structure', obj_id) + row = {"co_level": "500.000"} + self.update("vw_qgep_wastewater_structure", row, obj_id) + new_row = self.select("vw_qgep_wastewater_structure", obj_id) # geometry of ws_qgep_wastewaterstructure has 2D geometry: ST_SetSRID(ST_MakePoint(2600000, 1200000, 500), 2056) - assert new_row['situation_geometry'] == '0101000020080800000000000020D6434100000000804F3241' + assert ( + new_row["situation_geometry"] == "0101000020080800000000000020D6434100000000804F3241" + ) # co_level is new co_level - assert new_row['co_level'] == 500.000 + assert new_row["co_level"] == 500.000 # no change on wn_bottom_level - assert new_row['wn_bottom_level'] == 200.000 + assert new_row["wn_bottom_level"] == 200.000 # cover geometry has Z from new co_level: ST_SetSRID(ST_MakePoint(2600000, 1200000, 500), 2056) - new_row = self.select('cover', '1337_1010') - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000407F40' + new_row = self.select("cover", "1337_1010") + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000407F40" + ) # no change on wastewater_node geometry: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - new_row = self.select('wastewater_node', '1337_1010') - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000006940' + new_row = self.select("wastewater_node", "1337_1010") + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) # 3. update change WITH co_level and WITH wn_bottom_level # UPDATE qgep_od.vw_wastewater_node SET co_level=600.000, wn_bottom_level=300.000 WHERE obj_id = obj_id - row = { - 'co_level': '600.000', - 'wn_bottom_level': '300.000' - } - self.update('vw_qgep_wastewater_structure', row, obj_id) - new_row = self.select('vw_qgep_wastewater_structure', obj_id) + row = {"co_level": "600.000", "wn_bottom_level": "300.000"} + self.update("vw_qgep_wastewater_structure", row, obj_id) + new_row = self.select("vw_qgep_wastewater_structure", obj_id) # geometry of ws_qgep_wastewaterstructure unchanged: ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056) - assert new_row['situation_geometry'] == '0101000020080800000000000020D6434100000000804F3241' + assert ( + new_row["situation_geometry"] == "0101000020080800000000000020D6434100000000804F3241" + ) # co_level is new co_level - assert new_row['co_level'] == 600.000 + assert new_row["co_level"] == 600.000 # wn_bottom_level is new wn_bottom_level - assert new_row['wn_bottom_level'] == 300.000 + assert new_row["wn_bottom_level"] == 300.000 # cover geometry has Z from new co_level: ST_SetSRID(ST_MakePoint(2600000, 1200000, 600), 2056) - new_row = self.select('cover', '1337_1010') - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000C08240' + new_row = self.select("cover", "1337_1010") + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000C08240" + ) # no change on wastewater_node geometry: ST_SetSRID(ST_MakePoint(2600000, 1200000, 300), 2056) - new_row = self.select('wastewater_node', '1337_1010') - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000C07240' - + new_row = self.select("wastewater_node", "1337_1010") + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000C07240" + ) def test_wastewater_node_geometry_sync_on_insert(self): # 1. bottom level 200 and no Z # INSERT INTO qgep_od.vw_wastewater_node (bottom_level, situation_geometry) VALUES (200, ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) ); row = { - 'bottom_level': '200.000', - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F3241000000000000F87F', + "bottom_level": "200.000", + "situation_geometry": "01010000A0080800000000000020D6434100000000804F3241000000000000F87F", } expected_row = copy.deepcopy(row) # bottom_level 200 overwrites Z (NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - expected_row['bottom_level'] = '200.000' - expected_row['situation_geometry'] = '01010000A0080800000000000020D6434100000000804F32410000000000006940' - obj_id = self.insert_check('vw_wastewater_node', row, expected_row) + expected_row["bottom_level"] = "200.000" + expected_row["situation_geometry"] = ( + "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) + self.insert_check("vw_wastewater_node", row, expected_row) # 2. bottom level 200 and 555 Z # INSERT INTO qgep_od.vw_wastewater_node (bottom_level, situation_geometry) VALUES (200, ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) ); row = { - 'bottom_level': '200.000', - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000588140', + "bottom_level": "200.000", + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000588140", } expected_row = copy.deepcopy(row) # bottom_level 200 overwrites Z (555) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - expected_row['bottom_level'] = '200.000' - expected_row['situation_geometry'] = '01010000A0080800000000000020D6434100000000804F32410000000000006940' - obj_id = self.insert_check('vw_wastewater_node', row, expected_row) + expected_row["bottom_level"] = "200.000" + expected_row["situation_geometry"] = ( + "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) + self.insert_check("vw_wastewater_node", row, expected_row) # 3. bottom level NULL and 555 Z # INSERT INTO qgep_od.vw_wastewater_node (bottom_level, situation_geometry) VALUES (NULL, ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) ); row = { - 'bottom_level': None, - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000588140', + "bottom_level": None, + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000588140", } expected_row = copy.deepcopy(row) # bottom_level NULL overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row['bottom_level'] = None - expected_row['situation_geometry'] = '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' - obj_id = self.insert_check('vw_wastewater_node', row, expected_row) + expected_row["bottom_level"] = None + expected_row["situation_geometry"] = ( + "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) + self.insert_check("vw_wastewater_node", row, expected_row) # 4. no bottom level and 555 Z # INSERT INTO qgep_od.vw_wastewater_node (situation_geometry) VALUES (ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) ); row = { - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000588140', + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000588140", } expected_row = copy.deepcopy(row) # no bottom_level overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row['bottom_level'] = None - expected_row['situation_geometry'] = '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' - obj_id = self.insert_check('vw_wastewater_node', row, expected_row) - + expected_row["bottom_level"] = None + expected_row["situation_geometry"] = ( + "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) + self.insert_check("vw_wastewater_node", row, expected_row) def test_wastewater_node_geometry_sync_on_update(self): # first insert # no bottom level and no Z # INSERT INTO qgep_od.vw_wastewater_node (bottom_level, situation_geometry) VALUES (200, ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) ); row = { - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F3241000000000000F87F', + "situation_geometry": "01010000A0080800000000000020D6434100000000804F3241000000000000F87F", } - obj_id = self.insert('vw_wastewater_node', row) + obj_id = self.insert("vw_wastewater_node", row) # 1. change Z to 555 (don't change bottom_level) # UPDATE qgep_od.vw_wastewater_node SET situation_geometry=ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) WHERE obj_id = obj_id; row = { - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000588140', + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000588140", } - self.update('vw_wastewater_node', row, obj_id) + self.update("vw_wastewater_node", row, obj_id) # Z (555) overwrites bottom_level results in: 555.000 - new_row = self.select('vw_wastewater_node', obj_id) - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000588140' - assert new_row['bottom_level'] == 555.000 + new_row = self.select("vw_wastewater_node", obj_id) + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000588140" + ) + assert new_row["bottom_level"] == 555.000 # 2. change bottom_level to 200 (don't change Z) # UPDATE qgep_od.vw_wastewater_node SET bottom_level=200 WHERE obj_id = obj_id; - row = { - 'bottom_level': '200.000' - } - self.update('vw_wastewater_node', row, obj_id) + row = {"bottom_level": "200.000"} + self.update("vw_wastewater_node", row, obj_id) # bottom_level 200 overwrites Z results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - new_row = self.select('vw_wastewater_node', obj_id) - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000006940' - assert new_row['bottom_level'] == 200.000 + new_row = self.select("vw_wastewater_node", obj_id) + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) + assert new_row["bottom_level"] == 200.000 # 3. change bottom_level to 555 and Z to 666 # UPDATE qgep_od.vw_wastewater_node SET bottom_level=200 WHERE obj_id = obj_id; row = { - 'bottom_level': '555.000', - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000D08440', + "bottom_level": "555.000", + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000D08440", } - self.update('vw_wastewater_node', row, obj_id) + self.update("vw_wastewater_node", row, obj_id) # bottom_level 555 overwrites Z (666) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) - new_row = self.select('vw_wastewater_node', obj_id) - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000588140' - assert new_row['bottom_level'] == 555.000 + new_row = self.select("vw_wastewater_node", obj_id) + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000588140" + ) + assert new_row["bottom_level"] == 555.000 # 4. change Z to NaN (don't change bottom_level) # UPDATE qgep_od.vw_wastewater_node SET situation_geometry=ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) WHERE obj_id = obj_id; row = { - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F3241000000000000F87F', + "situation_geometry": "01010000A0080800000000000020D6434100000000804F3241000000000000F87F", } - self.update('vw_wastewater_node', row, obj_id) + self.update("vw_wastewater_node", row, obj_id) # Z (NaN) overwrites bottom_level results in: NULL - new_row = self.select('vw_wastewater_node', obj_id) - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' - assert new_row['bottom_level'] == None - + new_row = self.select("vw_wastewater_node", obj_id) + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) + assert new_row["bottom_level"] == None def test_cover_geometry_sync_on_insert(self): # 1. level 200 and no Z # INSERT INTO qgep_od.vw_cover (level, situation_geometry) VALUES (200, ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) ); row = { - 'level': '200.000', - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F3241000000000000F87F', + "level": "200.000", + "situation_geometry": "01010000A0080800000000000020D6434100000000804F3241000000000000F87F", } expected_row = copy.deepcopy(row) # level 200 overwrites Z (NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - expected_row['level'] = '200.000' - expected_row['situation_geometry'] = '01010000A0080800000000000020D6434100000000804F32410000000000006940' - obj_id = self.insert_check('vw_cover', row, expected_row) + expected_row["level"] = "200.000" + expected_row["situation_geometry"] = ( + "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) + self.insert_check("vw_cover", row, expected_row) # 2. level 200 and 555 Z # INSERT INTO qgep_od.vw_cover (level, situation_geometry) VALUES (200, ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) ); row = { - 'level': '200.000', - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000588140', + "level": "200.000", + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000588140", } expected_row = copy.deepcopy(row) # level 200 overwrites Z (555) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - expected_row['level'] = '200.000' - expected_row['situation_geometry'] = '01010000A0080800000000000020D6434100000000804F32410000000000006940' - obj_id = self.insert_check('vw_cover', row, expected_row) + expected_row["level"] = "200.000" + expected_row["situation_geometry"] = ( + "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) + self.insert_check("vw_cover", row, expected_row) # 3. level NULL and 555 Z # INSERT INTO qgep_od.vw_cover (level, situation_geometry) VALUES (NULL, ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) ); row = { - 'level': None, - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000588140', + "level": None, + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000588140", } expected_row = copy.deepcopy(row) # level NULL overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row['level'] = None - expected_row['situation_geometry'] = '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' - obj_id = self.insert_check('vw_cover', row, expected_row) + expected_row["level"] = None + expected_row["situation_geometry"] = ( + "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) + self.insert_check("vw_cover", row, expected_row) # 4. no level and 555 Z # INSERT INTO qgep_od.vw_cover (situation_geometry) VALUES (ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) ); row = { - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000588140', + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000588140", } expected_row = copy.deepcopy(row) # no level overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row['level'] = None - expected_row['situation_geometry'] = '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' - obj_id = self.insert_check('vw_cover', row, expected_row) - + expected_row["level"] = None + expected_row["situation_geometry"] = ( + "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) + self.insert_check("vw_cover", row, expected_row) def test_cover_geometry_sync_on_update(self): @@ -489,57 +579,65 @@ def test_cover_geometry_sync_on_update(self): # no level and no Z # INSERT INTO qgep_od.vw_cover (level, situation_geometry) VALUES (200, ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) ); row = { - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F3241000000000000F87F', + "situation_geometry": "01010000A0080800000000000020D6434100000000804F3241000000000000F87F", } - obj_id = self.insert('vw_cover', row) + obj_id = self.insert("vw_cover", row) # 1. change Z to 555 (don't change level) # UPDATE qgep_od.vw_cover SET situation_geometry=ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) WHERE obj_id = obj_id; row = { - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000588140', + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000588140", } - self.update('vw_cover', row, obj_id) + self.update("vw_cover", row, obj_id) # Z (555) overwrites level results in: 555.000 - new_row = self.select('vw_cover', obj_id) - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000588140' - assert new_row['level'] == 555.000 + new_row = self.select("vw_cover", obj_id) + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000588140" + ) + assert new_row["level"] == 555.000 # 2. change level to 200 (don't change Z) # UPDATE qgep_od.vw_cover SET level=200 WHERE obj_id = obj_id; - row = { - 'level': '200.000' - } - self.update('vw_cover', row, obj_id) + row = {"level": "200.000"} + self.update("vw_cover", row, obj_id) # level 200 overwrites Z results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 200), 2056) - new_row = self.select('vw_cover', obj_id) - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000006940' - assert new_row['level'] == 200.000 + new_row = self.select("vw_cover", obj_id) + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000006940" + ) + assert new_row["level"] == 200.000 # 3. change level to 555 and Z to 666 # UPDATE qgep_od.cover_node SET level=200 WHERE obj_id = obj_id; row = { - 'level': '555.000', - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F32410000000000D08440', + "level": "555.000", + "situation_geometry": "01010000A0080800000000000020D6434100000000804F32410000000000D08440", } - self.update('vw_cover', row, obj_id) + self.update("vw_cover", row, obj_id) # level 555 overwrites Z (666) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 555), 2056) - new_row = self.select('vw_cover', obj_id) - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F32410000000000588140' - assert new_row['level'] == 555.000 + new_row = self.select("vw_cover", obj_id) + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F32410000000000588140" + ) + assert new_row["level"] == 555.000 # 4. change Z to NaN (don't change level) # UPDATE qgep_od.vw_cover SET situation_geometry=ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) WHERE obj_id = obj_id; row = { - 'situation_geometry': '01010000A0080800000000000020D6434100000000804F3241000000000000F87F', + "situation_geometry": "01010000A0080800000000000020D6434100000000804F3241000000000000F87F", } - self.update('vw_cover', row, obj_id) + self.update("vw_cover", row, obj_id) # Z (555) overwrites level results in: 555.000 - new_row = self.select('vw_cover', obj_id) - assert new_row['situation_geometry'] == '01010000A0080800000000000020D6434100000000804F3241000000000000F87F' - assert new_row['level'] == None + new_row = self.select("vw_cover", obj_id) + assert ( + new_row["situation_geometry"] + == "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" + ) + assert new_row["level"] == None - -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() - diff --git a/test/test_import.py b/test/test_import.py index feac4379f..98a84708e 100644 --- a/test/test_import.py +++ b/test/test_import.py @@ -1,10 +1,10 @@ -import unittest +import decimal import os +import unittest import psycopg2 import psycopg2.extras import psycopg2.sql -import decimal from .utils import DbTestBase @@ -17,162 +17,151 @@ def tearDownClass(cls): @classmethod def setUpClass(cls): - pgservice = os.environ.get('PGSERVICE') or 'pg_qgep' - cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) + pgservice = os.environ.get("PGSERVICE") or "pg_qgep" + cls.conn = psycopg2.connect(f"service={pgservice}") # - level calculation failing because only no reference level # -> not updated structure with calculated values # -> still in quarantine def test_calculation_level_fail(self): # obj_id from the test data - obj_id = 'ch13p7mzMA000011' + obj_id = "ch13p7mzMA000011" row = { - '_depth': 12.220, - 'co_level': None, - 'wn_bottom_level': None, - 'outlet_1_material': 5081, - 'verified': True + "_depth": 12.220, + "co_level": None, + "wn_bottom_level": None, + "outlet_1_material": 5081, + "verified": True, } # update - self.update('vw_manhole', row, obj_id, 'qgep_import') + self.update("vw_manhole", row, obj_id, "qgep_import") # it should be calculated correctly in the live table qgep_od.wastewater_structure - row = self.select( 'wastewater_structure', obj_id, 'qgep_od') - self.assertNotEqual( row['_depth'], decimal.Decimal('12.220')) + row = self.select("wastewater_structure", obj_id, "qgep_od") + self.assertNotEqual(row["_depth"], decimal.Decimal("12.220")) # it should be visible in the qgep_import.vw_manhole view - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertNotEqual( row['_depth'], decimal.Decimal('12.220')) + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertNotEqual(row["_depth"], decimal.Decimal("12.220")) # it shouldn't be in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNotNone( row ) + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNotNone(row) # delete it manually - self.delete( 'manhole_quarantine', obj_id, 'qgep_import') - + self.delete("manhole_quarantine", obj_id, "qgep_import") # - ws bottom level calculation # -> updated structure with calculated values def test_calculation_wn_bottom_level(self): # obj_id from the test data - obj_id = 'ch13p7mzMA000071' + obj_id = "ch13p7mzMA000071" row = { - '_depth': 2.220, - 'wn_bottom_level': None, - 'co_level': 22.220, - 'inlet_3_material': 5081, - 'outlet_1_material': 5081, - 'verified': True + "_depth": 2.220, + "wn_bottom_level": None, + "co_level": 22.220, + "inlet_3_material": 5081, + "outlet_1_material": 5081, + "verified": True, } # update - self.update('vw_manhole', row, obj_id, 'qgep_import') + self.update("vw_manhole", row, obj_id, "qgep_import") # it should be calculated correctly in the live view qgep_od.vw_qgep_wastewater_structure - row = self.select( 'vw_qgep_wastewater_structure', obj_id, 'qgep_od') - self.assertEqual( row['_depth'], decimal.Decimal('2.220')) - self.assertEqual( row['co_level'], decimal.Decimal('22.220')) - self.assertEqual( row['wn_bottom_level'], decimal.Decimal('20')) + row = self.select("vw_qgep_wastewater_structure", obj_id, "qgep_od") + self.assertEqual(row["_depth"], decimal.Decimal("2.220")) + self.assertEqual(row["co_level"], decimal.Decimal("22.220")) + self.assertEqual(row["wn_bottom_level"], decimal.Decimal("20")) # it should be visible in the qgep_import.vw_manhole view - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertEqual( row['_depth'], decimal.Decimal('2.220')) - self.assertEqual( row['co_level'], decimal.Decimal('22.220')) - self.assertEqual( row['wn_bottom_level'], decimal.Decimal('20')) + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertEqual(row["_depth"], decimal.Decimal("2.220")) + self.assertEqual(row["co_level"], decimal.Decimal("22.220")) + self.assertEqual(row["wn_bottom_level"], decimal.Decimal("20")) # it shouldn't be in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNone( row ) - + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNone(row) # - cover level calculation # -> updated structure with calculated values # -> deleted in quarantine def test_calculation_co_level(self): # obj_id from the test data - obj_id = 'ch13p7mzMA000071' + obj_id = "ch13p7mzMA000071" row = { - '_depth': 7.780, - 'wn_bottom_level': 22.220, - 'co_level': None, - 'inlet_3_material': 5081, - 'outlet_1_material': 5081, - 'verified': True + "_depth": 7.780, + "wn_bottom_level": 22.220, + "co_level": None, + "inlet_3_material": 5081, + "outlet_1_material": 5081, + "verified": True, } # update - self.update('vw_manhole', row, obj_id, 'qgep_import') - + self.update("vw_manhole", row, obj_id, "qgep_import") + # it should be calculated correctly in the live view qgep_od.vw_qgep_wastewater_structure - row = self.select( 'vw_qgep_wastewater_structure', obj_id, 'qgep_od') - self.assertEqual( row['_depth'], decimal.Decimal('7.780')) - self.assertEqual( row['co_level'], decimal.Decimal('30')) - self.assertEqual( row['wn_bottom_level'], decimal.Decimal('22.220')) + row = self.select("vw_qgep_wastewater_structure", obj_id, "qgep_od") + self.assertEqual(row["_depth"], decimal.Decimal("7.780")) + self.assertEqual(row["co_level"], decimal.Decimal("30")) + self.assertEqual(row["wn_bottom_level"], decimal.Decimal("22.220")) # it should be visible in the qgep_import.vw_manhole view - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertEqual( row['_depth'], decimal.Decimal('7.780')) - self.assertEqual( row['co_level'], decimal.Decimal('30')) - self.assertEqual( row['wn_bottom_level'], decimal.Decimal('22.220')) + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertEqual(row["_depth"], decimal.Decimal("7.780")) + self.assertEqual(row["co_level"], decimal.Decimal("30")) + self.assertEqual(row["wn_bottom_level"], decimal.Decimal("22.220")) # it shouldn't be in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNone( row ) - + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNone(row) - # - delete of structure + # - delete of structure # -> delete in live def test_delete_structure(self): # obj_id from the test data - obj_id = 'ch13p7mzMA000037' + obj_id = "ch13p7mzMA000037" # change deleted from false to true - row = { - 'deleted': True, - 'verified': True - } + row = {"deleted": True, "verified": True} # update - self.update('vw_manhole', row, obj_id, 'qgep_import') + self.update("vw_manhole", row, obj_id, "qgep_import") # it should be deleted in the live table qgep_od.wastewater_structure - row = self.select( 'wastewater_structure', obj_id, 'qgep_od') - self.assertIsNone( row ) + row = self.select("wastewater_structure", obj_id, "qgep_od") + self.assertIsNone(row) # it should not be visible anymore in the qgep_import.vw_manhole view - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertIsNone( row ) - + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertIsNone(row) # - delete of structure but have verified at false # -> do not delete in live def test_delete_structure_failing(self): # obj_id from the test data - obj_id = 'ch13p7mzMA000044' + obj_id = "ch13p7mzMA000044" # change deleted from false to true # but do not set verified to true - row = { - 'deleted': True, - 'verified': False - } + row = {"deleted": True, "verified": False} # update - self.update('vw_manhole', row, obj_id, 'qgep_import') + self.update("vw_manhole", row, obj_id, "qgep_import") # it should not be deleted in the live table qgep_od.wastewater_structure - row = self.select( 'wastewater_structure', obj_id, 'qgep_od') - self.assertIsNotNone( row ) + row = self.select("wastewater_structure", obj_id, "qgep_od") + self.assertIsNotNone(row) # it should still be visible anymore in the qgep_import.vw_manhole view - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertIsNotNone( row ) - + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertIsNotNone(row) # - correct update with 1 old outlet and 1 new outlet and 0 old inlet and 0 new inlet # -> updated structure @@ -181,61 +170,70 @@ def test_delete_structure_failing(self): # -> deleted in quarantene def test_update_with_outlet(self): # obj_id from the test data - obj_id = 'ch13p7mzMA000012' + obj_id = "ch13p7mzMA000012" # change remark from 'Strasseneinlauf' to 'Strassenauslauf' # change co_material from 233 to 3015 row = { - 'remark': 'Strassenauslauf', - 'co_material': 3015, - 'outlet_1_material': 5081, - 'outlet_1_clear_height': 160, - 'outlet_1_depth_m': 100, - 'photo1' : 'funky_selfie.png', - 'verified': True + "remark": "Strassenauslauf", + "co_material": 3015, + "outlet_1_material": 5081, + "outlet_1_clear_height": 160, + "outlet_1_depth_m": 100, + "photo1": "funky_selfie.png", + "verified": True, } # update - self.update('vw_manhole', row, obj_id, 'qgep_import') + self.update("vw_manhole", row, obj_id, "qgep_import") # it should be in the live table qgep_od.wastewater_structure - row = self.select( 'wastewater_structure', obj_id, 'qgep_od') - self.assertIsNotNone( row ) - self.assertEqual( row['remark'], 'Strassenauslauf') + row = self.select("wastewater_structure", obj_id, "qgep_od") + self.assertIsNotNone(row) + self.assertEqual(row["remark"], "Strassenauslauf") # it should be in the view qgep_import.vw_manhole - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertIsNotNone( row ) - self.assertEqual( row['co_material'], 3015) - self.assertEqual( row['remark'], 'Strassenauslauf') + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertIsNotNone(row) + self.assertEqual(row["co_material"], 3015) + self.assertEqual(row["remark"], "Strassenauslauf") # it should be in the live table qgep_od.reach and qgep_od.reach_point cur = self.cursor() - cur.execute(psycopg2.sql.SQL("SELECT re.material, re.clear_height, rp.level, ws.co_level\ + cur.execute( + psycopg2.sql.SQL( + "SELECT re.material, re.clear_height, rp.level, ws.co_level\ FROM {schema}.reach re\ LEFT JOIN {schema}.reach_point rp ON rp.obj_id = re.fk_reach_point_from\ LEFT JOIN {schema}.wastewater_networkelement wn ON wn.obj_id = rp.fk_wastewater_networkelement\ LEFT JOIN {schema}.vw_qgep_wastewater_structure ws ON ws.obj_id = wn.fk_wastewater_structure\ - WHERE ws.obj_id = %(obj_id)s").format(schema=psycopg2.sql.Identifier('qgep_od')), {'obj_id':obj_id}) + WHERE ws.obj_id = %(obj_id)s" + ).format(schema=psycopg2.sql.Identifier("qgep_od")), + {"obj_id": obj_id}, + ) row = cur.fetchone() - self.assertIsNotNone( row ) - self.assertEqual( row['material'], 5081) - self.assertEqual( row['clear_height'], 160) - self.assertEqual( row['level'], decimal.Decimal('301.700')) + self.assertIsNotNone(row) + self.assertEqual(row["material"], 5081) + self.assertEqual(row["clear_height"], 160) + self.assertEqual(row["level"], decimal.Decimal("301.700")) # the photo should be in the live table qgep_od.file - row = self.select( 'file', obj_id, 'qgep_od') + row = self.select("file", obj_id, "qgep_od") cur = self.cursor() - cur.execute(psycopg2.sql.SQL("SELECT *\ + cur.execute( + psycopg2.sql.SQL( + "SELECT *\ FROM {schema}.file\ - WHERE object = %(obj_id)s").format(schema=psycopg2.sql.Identifier('qgep_od')), {'obj_id':obj_id}) + WHERE object = %(obj_id)s" + ).format(schema=psycopg2.sql.Identifier("qgep_od")), + {"obj_id": obj_id}, + ) row = cur.fetchone() - self.assertEqual( row['identifier'], 'funky_selfie.png') + self.assertEqual(row["identifier"], "funky_selfie.png") # it shouldn't be in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNone( row ) - + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNone(row) # - incorrect update with a wrong cover material # -> updated reach @@ -246,57 +244,55 @@ def test_update_with_outlet(self): # -> deleted in quarantene def test_update_with_wrong_material(self): # obj_id from the test data - obj_id = 'ch13p7mzMA000012' + obj_id = "ch13p7mzMA000012" # change co_material from 233 to 666, what not exists in the table qgep_vl.cover_material - row = { - 'co_material': 666, - 'outlet_1_material': 5081, - 'verified': True - } + row = {"co_material": 666, "outlet_1_material": 5081, "verified": True} # update - self.update('vw_manhole', row, obj_id, 'qgep_import') + self.update("vw_manhole", row, obj_id, "qgep_import") # it should be in the live table qgep_od.reach and qgep_od.reach_point cur = self.cursor() - cur.execute(psycopg2.sql.SQL("SELECT re.material, re.clear_height, rp.level, ws.co_level\ + cur.execute( + psycopg2.sql.SQL( + "SELECT re.material, re.clear_height, rp.level, ws.co_level\ FROM {schema}.reach re\ LEFT JOIN {schema}.reach_point rp ON rp.obj_id = re.fk_reach_point_from\ LEFT JOIN {schema}.wastewater_networkelement wn ON wn.obj_id = rp.fk_wastewater_networkelement\ LEFT JOIN {schema}.vw_qgep_wastewater_structure ws ON ws.obj_id = wn.fk_wastewater_structure\ - WHERE ws.obj_id = %(obj_id)s").format(schema=psycopg2.sql.Identifier('qgep_od')), {'obj_id':obj_id}) + WHERE ws.obj_id = %(obj_id)s" + ).format(schema=psycopg2.sql.Identifier("qgep_od")), + {"obj_id": obj_id}, + ) row = cur.fetchone() - self.assertIsNotNone( row ) - self.assertEqual( row['material'], 5081) + self.assertIsNotNone(row) + self.assertEqual(row["material"], 5081) # it shouldn't be updated in the view qgep_import.vw_manhole - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertNotEqual( row['co_material'], 666) + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertNotEqual(row["co_material"], 666) # it should be in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNotNone( row ) - self.assertEqual( row['co_material'], 666 ) - self.assertTrue( row['outlet_okay'] ) - self.assertTrue( row['inlet_okay'] ) - self.assertFalse( row['structure_okay'] ) + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNotNone(row) + self.assertEqual(row["co_material"], 666) + self.assertTrue(row["outlet_okay"]) + self.assertTrue(row["inlet_okay"]) + self.assertFalse(row["structure_okay"]) - row = { - 'co_material': 5547 - } + row = {"co_material": 5547} # update - self.update('manhole_quarantine', row, obj_id, 'qgep_import') - + self.update("manhole_quarantine", row, obj_id, "qgep_import") + # it should be updated in the view qgep_import.vw_manhole - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertEqual( row['co_material'], 5547) + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertEqual(row["co_material"], 5547) # it shouldn't be anymore in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNone( row ) - + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNone(row) # - problematic update with 1 old outlet and 1 new outlet and 0 old inlet and 1 new inlet # -> updated structure @@ -306,60 +302,62 @@ def test_update_with_wrong_material(self): # -> deleted in quarantene def test_update_with_unexpected_inlet(self): # obj_id from the test data - obj_id = 'ch13p7mzMA000012' + obj_id = "ch13p7mzMA000012" # change remark from 'Strasseneinlauf' to 'Strassenauslauf' # change co_material from 233 to 3015 row = { - 'remark': 'Strassenauslauf', - 'co_material': 3015, - 'outlet_1_material': 5081, - 'outlet_1_clear_height': 160, - 'outlet_1_depth_m': 100, - 'inlet_3_material': 5081, - 'inlet_3_clear_height': 160, - 'inlet_3_depth_m': 100, - 'verified': True + "remark": "Strassenauslauf", + "co_material": 3015, + "outlet_1_material": 5081, + "outlet_1_clear_height": 160, + "outlet_1_depth_m": 100, + "inlet_3_material": 5081, + "inlet_3_clear_height": 160, + "inlet_3_depth_m": 100, + "verified": True, } # update - self.update('vw_manhole', row, obj_id, 'qgep_import') + self.update("vw_manhole", row, obj_id, "qgep_import") # it should be in the view qgep_import.vw_manhole - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertIsNotNone( row ) - self.assertEqual( row['co_material'], 3015) - self.assertEqual( row['remark'], 'Strassenauslauf') + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertIsNotNone(row) + self.assertEqual(row["co_material"], 3015) + self.assertEqual(row["remark"], "Strassenauslauf") # it should be in the live table qgep_od.reach and qgep_od.reach_point cur = self.cursor() - cur.execute(psycopg2.sql.SQL("SELECT re.material, re.clear_height, rp.level, ws.co_level\ + cur.execute( + psycopg2.sql.SQL( + "SELECT re.material, re.clear_height, rp.level, ws.co_level\ FROM {schema}.reach re\ LEFT JOIN {schema}.reach_point rp ON rp.obj_id = re.fk_reach_point_from\ LEFT JOIN {schema}.wastewater_networkelement wn ON wn.obj_id = rp.fk_wastewater_networkelement\ LEFT JOIN {schema}.vw_qgep_wastewater_structure ws ON ws.obj_id = wn.fk_wastewater_structure\ - WHERE ws.obj_id = %(obj_id)s").format(schema=psycopg2.sql.Identifier('qgep_od')), {'obj_id':obj_id}) + WHERE ws.obj_id = %(obj_id)s" + ).format(schema=psycopg2.sql.Identifier("qgep_od")), + {"obj_id": obj_id}, + ) row = cur.fetchone() - self.assertIsNotNone( row ) - self.assertEqual( row['material'], 5081) - self.assertEqual( row['clear_height'], 160) - self.assertEqual( row['level'], decimal.Decimal('301.700')) + self.assertIsNotNone(row) + self.assertEqual(row["material"], 5081) + self.assertEqual(row["clear_height"], 160) + self.assertEqual(row["level"], decimal.Decimal("301.700")) # it should be still in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNotNone( row ) + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNotNone(row) - row = { - 'inlet_okay': 'true' - } + row = {"inlet_okay": "true"} # update - self.update('manhole_quarantine', row, obj_id, 'qgep_import') + self.update("manhole_quarantine", row, obj_id, "qgep_import") # it shouldn't be anymore in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNone( row ) - + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNone(row) # - problematic update with 1 old outlet and 0 new outlet and 0 old inlet and 0 new inlet # -> updated structure @@ -368,40 +366,33 @@ def test_update_with_unexpected_inlet(self): # -> deleted in quarantene def test_update_with_unexpected_outlet(self): # obj_id from the test data - obj_id = 'ch13p7mzMA000012' + obj_id = "ch13p7mzMA000012" # change remark from 'Strasseneinlauf' to 'Strassenauslauf' # change co_material from 233 to 3015 - row = { - 'remark': 'Strassenauslauf', - 'co_material': 3015, - 'verified': True - } + row = {"remark": "Strassenauslauf", "co_material": 3015, "verified": True} # update - self.update('vw_manhole', row, obj_id, 'qgep_import') + self.update("vw_manhole", row, obj_id, "qgep_import") # it should be in the view qgep_import.vw_manhole - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertIsNotNone( row ) - self.assertEqual( row['co_material'], 3015) - self.assertEqual( row['remark'], 'Strassenauslauf') + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertIsNotNone(row) + self.assertEqual(row["co_material"], 3015) + self.assertEqual(row["remark"], "Strassenauslauf") # it should be still in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNotNone( row ) + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNotNone(row) - row = { - 'outlet_okay': 'true' - } + row = {"outlet_okay": "true"} # update - self.update('manhole_quarantine', row, obj_id, 'qgep_import') + self.update("manhole_quarantine", row, obj_id, "qgep_import") # it shouldn't be anymore in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNone( row ) - + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNone(row) # - problematic update with 1 old outlet and 1 new outlet and 4 old inlet and 4 new inlet # -> updated structure @@ -411,69 +402,76 @@ def test_update_with_unexpected_outlet(self): # -> deleted in quarantene def test_update_with_multiple_inlets(self): # obj_id from the test data - obj_id = 'ch13p7mzMA005266' + obj_id = "ch13p7mzMA005266" # change remark from 'E09' to 'E10' # change co_material from 3016 to 3015 row = { - 'remark': 'E10', - 'co_material': 3015, - 'co_level': 500, - 'outlet_1_material': 5081, - 'outlet_1_clear_height': 160, - 'outlet_1_depth_m': 100, - 'inlet_3_material': 5081, - 'inlet_3_clear_height': 160, - 'inlet_3_depth_m': 100, - 'verified': True + "remark": "E10", + "co_material": 3015, + "co_level": 500, + "outlet_1_material": 5081, + "outlet_1_clear_height": 160, + "outlet_1_depth_m": 100, + "inlet_3_material": 5081, + "inlet_3_clear_height": 160, + "inlet_3_depth_m": 100, + "verified": True, } # update - self.update('vw_manhole', row, obj_id, 'qgep_import') + self.update("vw_manhole", row, obj_id, "qgep_import") # it should be in the view qgep_import.vw_manhole - row = self.select( 'vw_manhole', obj_id, 'qgep_import') - self.assertIsNotNone( row ) - self.assertEqual( row['co_material'], 3015) - self.assertEqual( row['remark'], 'E10') + row = self.select("vw_manhole", obj_id, "qgep_import") + self.assertIsNotNone(row) + self.assertEqual(row["co_material"], 3015) + self.assertEqual(row["remark"], "E10") # it should be in the live table qgep_od.reach and qgep_od.reach_point cur = self.cursor() - cur.execute(psycopg2.sql.SQL("SELECT re.material, re.clear_height, rp.level, ws.co_level\ + cur.execute( + psycopg2.sql.SQL( + "SELECT re.material, re.clear_height, rp.level, ws.co_level\ FROM {schema}.reach re\ LEFT JOIN {schema}.reach_point rp ON rp.obj_id = re.fk_reach_point_from\ LEFT JOIN {schema}.wastewater_networkelement wn ON wn.obj_id = rp.fk_wastewater_networkelement\ LEFT JOIN {schema}.vw_qgep_wastewater_structure ws ON ws.obj_id = wn.fk_wastewater_structure\ - WHERE ws.obj_id = %(obj_id)s").format(schema=psycopg2.sql.Identifier('qgep_od')), {'obj_id':obj_id}) + WHERE ws.obj_id = %(obj_id)s" + ).format(schema=psycopg2.sql.Identifier("qgep_od")), + {"obj_id": obj_id}, + ) row = cur.fetchone() - self.assertIsNotNone( row ) - self.assertEqual( row['material'], 5081) - self.assertEqual( row['clear_height'], 160) - self.assertEqual( row['level'], decimal.Decimal('400')) + self.assertIsNotNone(row) + self.assertEqual(row["material"], 5081) + self.assertEqual(row["clear_height"], 160) + self.assertEqual(row["level"], decimal.Decimal("400")) # it should be still in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNotNone( row ) + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNotNone(row) - row = { - 'inlet_okay': 'true' - } + row = {"inlet_okay": "true"} # update - self.update('manhole_quarantine', row, obj_id, 'qgep_import') + self.update("manhole_quarantine", row, obj_id, "qgep_import") # it shouldn't be anymore in the quarantine qgep_import.manhole_quarantine - row = self.select( 'manhole_quarantine', obj_id, 'qgep_import') - self.assertIsNone( row ) + row = self.select("manhole_quarantine", obj_id, "qgep_import") + self.assertIsNone(row) # - general test def test_general(self): # it should be in the live table qgep_od.reach and qgep_od.reach_point cur = self.cursor() - cur.execute(psycopg2.sql.SQL("SELECT * FROM {schema}.wastewater_structure LIMIT 1").format(schema=psycopg2.sql.Identifier('qgep_od'))) + cur.execute( + psycopg2.sql.SQL("SELECT * FROM {schema}.wastewater_structure LIMIT 1").format( + schema=psycopg2.sql.Identifier("qgep_od") + ) + ) row = cur.fetchone() - self.assertIsNotNone( row ) + self.assertIsNotNone(row) -if __name__ == '__main__': - unittest.main() \ No newline at end of file +if __name__ == "__main__": + unittest.main() diff --git a/test/test_label.py b/test/test_label.py index eb386f500..50595b0e5 100644 --- a/test/test_label.py +++ b/test/test_label.py @@ -1,5 +1,5 @@ -import unittest import os +import unittest import psycopg2 import psycopg2.extras @@ -15,56 +15,66 @@ def tearDownClass(cls): @classmethod def setUpClass(cls): - pgservice = os.environ.get('PGSERVICE') or 'pg_qgep' - cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) + pgservice = os.environ.get("PGSERVICE") or "pg_qgep" + cls.conn = psycopg2.connect(f"service={pgservice}") def insert_manholes(self, manholes): for manhole in manholes: - coords = manholes[manhole]['coords'] + coords = manholes[manhole]["coords"] row = { - 'identifier': manhole, - 'ws_type': 'manhole', - 'situation_geometry': self.execute( - "ST_SetSRID(ST_GeomFromText('POINT({x} {y})'), 2056)".format(x=coords[0], y=coords[1])), + "identifier": manhole, + "ws_type": "manhole", + "situation_geometry": self.execute( + "ST_SetSRID(ST_GeomFromText('POINT({x} {y})'), 2056)".format( + x=coords[0], y=coords[1] + ) + ), } - manholes[manhole]['obj_id'] = self.insert('vw_qgep_wastewater_structure', row) - manholes[manhole]['wn_obj_id'] = self.select('vw_qgep_wastewater_structure', manholes[manhole]['obj_id'])['wn_obj_id'] + manholes[manhole]["obj_id"] = self.insert("vw_qgep_wastewater_structure", row) + manholes[manhole]["wn_obj_id"] = self.select( + "vw_qgep_wastewater_structure", manholes[manhole]["obj_id"] + )["wn_obj_id"] def insert_reaches(self, reaches, manholes): for way, reaches in reaches.items(): for reach in reaches: - if way == 'input': - start_point = manholes[reach['mh_id']] - end_point = manholes['main'] + if way == "input": + start_point = manholes[reach["mh_id"]] + end_point = manholes["main"] else: - start_point = manholes['main'] - end_point = manholes[reach['mh_id']] + start_point = manholes["main"] + end_point = manholes[reach["mh_id"]] - points = [start_point['coords']] - if 'mid_point' in reach: - points.append(reach['mid_point']) - points.append(end_point['coords']) + points = [start_point["coords"]] + if "mid_point" in reach: + points.append(reach["mid_point"]) + points.append(end_point["coords"]) geom = self.execute( "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ARRAY[{points}]), 2056))".format( - points=', '.join( - ["ST_MakePoint({x}, {y}, 'NaN')".format(x=pt[0], y=pt[1]) for pt in points] + points=", ".join( + [ + f"ST_MakePoint({pt[0]}, {pt[1]}, 'NaN')" + for pt in points + ] ) ) ) row = { - 'clear_height': 100, - 'coefficient_of_friction': 10, - 'ws_identifier': reach['mh_id'], - 'ch_function_hierarchic': 5062, - 'rp_from_level': reach.get('rp_from_level', 1020.0), - 'rp_to_level': reach.get('rp_to_level', 1000.0), - 'ch_usage_current': 4514, - 'progression_geometry': geom, + "clear_height": 100, + "coefficient_of_friction": 10, + "ws_identifier": reach["mh_id"], + "ch_function_hierarchic": 5062, + "rp_from_level": reach.get("rp_from_level", 1020.0), + "rp_to_level": reach.get("rp_to_level", 1000.0), + "ch_usage_current": 4514, + "progression_geometry": geom, } - obj_id = self.insert('vw_qgep_reach', row) - self.connect_reach(obj_id, from_id=start_point['wn_obj_id'], to_id=end_point['wn_obj_id']) + obj_id = self.insert("vw_qgep_reach", row) + self.connect_reach( + obj_id, from_id=start_point["wn_obj_id"], to_id=end_point["wn_obj_id"] + ) def connect_reach(self, reach_id, from_id=None, to_id=None): """ @@ -72,59 +82,73 @@ def connect_reach(self, reach_id, from_id=None, to_id=None): """ data = {} if from_id is not None: - data['rp_from_fk_wastewater_networkelement'] = from_id + data["rp_from_fk_wastewater_networkelement"] = from_id if to_id is not None: - data['rp_to_fk_wastewater_networkelement'] = to_id - self.update('vw_qgep_reach', data, reach_id) + data["rp_to_fk_wastewater_networkelement"] = to_id + self.update("vw_qgep_reach", data, reach_id) def test_simpe_labels(self): manholes = { - 'main': {'obj_id': None, 'wn_obj_id': None, 'coords': [2600000, 1200000]}, - 'N': {'obj_id': None, 'wn_obj_id': None, 'coords': [2600000, 1200001]}, - 'NE': {'obj_id': None, 'wn_obj_id': None, 'coords': [2600001, 1200001]}, - 'E': {'obj_id': None, 'wn_obj_id': None, 'coords': [2600001, 1200000]}, - 'SE': {'obj_id': None, 'wn_obj_id': None, 'coords': [2600001, 1199999]}, - 'S': {'obj_id': None, 'wn_obj_id': None, 'coords': [2600000, 1199999]}, - 'SW': {'obj_id': None, 'wn_obj_id': None, 'coords': [2599999, 1199999]}, - 'W': {'obj_id': None, 'wn_obj_id': None, 'coords': [2599999, 1200000]}, - 'NW': {'obj_id': None, 'wn_obj_id': None, 'coords': [2599999, 1200001]}, + "main": {"obj_id": None, "wn_obj_id": None, "coords": [2600000, 1200000]}, + "N": {"obj_id": None, "wn_obj_id": None, "coords": [2600000, 1200001]}, + "NE": {"obj_id": None, "wn_obj_id": None, "coords": [2600001, 1200001]}, + "E": {"obj_id": None, "wn_obj_id": None, "coords": [2600001, 1200000]}, + "SE": {"obj_id": None, "wn_obj_id": None, "coords": [2600001, 1199999]}, + "S": {"obj_id": None, "wn_obj_id": None, "coords": [2600000, 1199999]}, + "SW": {"obj_id": None, "wn_obj_id": None, "coords": [2599999, 1199999]}, + "W": {"obj_id": None, "wn_obj_id": None, "coords": [2599999, 1200000]}, + "NW": {"obj_id": None, "wn_obj_id": None, "coords": [2599999, 1200001]}, } self.insert_manholes(manholes) reaches = { - 'input': [ - {'mh_id': 'NE', 'rp_to_level': 1011}, - {'mh_id': 'SE', 'rp_to_level': 1012}, - {'mh_id': 'SW', 'rp_to_level': 1013}, - {'mh_id': 'NW', 'rp_to_level': 1014} + "input": [ + {"mh_id": "NE", "rp_to_level": 1011}, + {"mh_id": "SE", "rp_to_level": 1012}, + {"mh_id": "SW", "rp_to_level": 1013}, + {"mh_id": "NW", "rp_to_level": 1014}, + ], + "output": [ + {"mh_id": "N", "rp_from_level": 1001}, + {"mh_id": "E", "rp_from_level": 1002}, + {"mh_id": "S", "rp_from_level": 1003}, + {"mh_id": "W", "rp_from_level": 1004}, ], - 'output': [ - {'mh_id': 'N', 'rp_from_level': 1001}, - {'mh_id': 'E', 'rp_from_level': 1002}, - {'mh_id': 'S', 'rp_from_level': 1003}, - {'mh_id': 'W', 'rp_from_level': 1004} - ] } self.insert_reaches(reaches, manholes) - self.assertEqual(self.select('vw_qgep_wastewater_structure', manholes['main']['obj_id'])['_input_label'], '\nI1=1011.00\nI2=1012.00\nI3=1013.00\nI4=1014.00') - self.assertEqual(self.select('vw_qgep_wastewater_structure', manholes['main']['obj_id'])['_output_label'], '\nO1=1001.00\nO2=1002.00\nO3=1003.00\nO4=1004.00') + self.assertEqual( + self.select("vw_qgep_wastewater_structure", manholes["main"]["obj_id"])[ + "_input_label" + ], + "\nI1=1011.00\nI2=1012.00\nI3=1013.00\nI4=1014.00", + ) + self.assertEqual( + self.select("vw_qgep_wastewater_structure", manholes["main"]["obj_id"])[ + "_output_label" + ], + "\nO1=1001.00\nO2=1002.00\nO3=1003.00\nO4=1004.00", + ) def test_crossing_circular_reaches(self): manholes = { - 'main': {'obj_id': None, 'wn_obj_id': None, 'coords': [2600000, 1200000]}, - 'N': {'obj_id': None, 'wn_obj_id': None, 'coords': [2600000, 1200001]}, - 'S': {'obj_id': None, 'wn_obj_id': None, 'coords': [2600000, 1199999]} + "main": {"obj_id": None, "wn_obj_id": None, "coords": [2600000, 1200000]}, + "N": {"obj_id": None, "wn_obj_id": None, "coords": [2600000, 1200001]}, + "S": {"obj_id": None, "wn_obj_id": None, "coords": [2600000, 1199999]}, } self.insert_manholes(manholes) reaches = { - 'input': [ - {'mh_id': 'N', 'rp_to_level': 1011, 'mid_point': [2600000.5, 1199999.5]}, - {'mh_id': 'S', 'rp_to_level': 1012, 'mid_point': [2600000.5, 1200000.5]} + "input": [ + {"mh_id": "N", "rp_to_level": 1011, "mid_point": [2600000.5, 1199999.5]}, + {"mh_id": "S", "rp_to_level": 1012, "mid_point": [2600000.5, 1200000.5]}, ] } self.insert_reaches(reaches, manholes) - self.assertEqual(self.select('vw_qgep_wastewater_structure', manholes['main']['obj_id'])['_input_label'], '\nI1=1012.00\nI2=1011.00') - + self.assertEqual( + self.select("vw_qgep_wastewater_structure", manholes["main"]["obj_id"])[ + "_input_label" + ], + "\nI1=1012.00\nI2=1011.00", + ) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_network.py b/test/test_network.py index d13f37084..555412acc 100644 --- a/test/test_network.py +++ b/test/test_network.py @@ -1,10 +1,8 @@ -import unittest import os +import unittest import psycopg2 import psycopg2.extras -import decimal -import copy from .utils import DbTestBase @@ -27,31 +25,28 @@ def tearDown(self): self.conn.rollback() def setUp(self): - pgservice=os.environ.get('PGSERVICE') or 'pg_qgep' - self.conn = psycopg2.connect("service={service}".format(service=pgservice)) + pgservice = os.environ.get("PGSERVICE") or "pg_qgep" + self.conn = psycopg2.connect(f"service={pgservice}") def make_reach(self, identifier, x1, y1, x2, y2): """ Helper function that makes a reach, returns obj_id, reachpoint_start_id, reachpoint_end_id """ reach = { - 'identifier': identifier, - 'progression_geometry': self.make_line(x1, y1, 100, x2, y2, 100), + "identifier": identifier, + "progression_geometry": self.make_line(x1, y1, 100, x2, y2, 100), } - reach_id = self.insert('vw_qgep_reach', reach) - reach = self.select('reach', reach_id) - return reach_id, reach['fk_reach_point_from'], reach['fk_reach_point_to'] + reach_id = self.insert("vw_qgep_reach", reach) + reach = self.select("reach", reach_id) + return reach_id, reach["fk_reach_point_from"], reach["fk_reach_point_to"] def make_manhole(self, identifier, x, y): """ Helper function that makes a manhole, returns (obj_id, wn_obj_id) """ - manhole = { - 'identifier': identifier, - 'situation_geometry': self.make_point_2d(x, y) - } - manhole_id = self.insert('vw_qgep_wastewater_structure', manhole) - manhole_wn_id = self.select('vw_qgep_wastewater_structure', manhole_id)['wn_obj_id'] + manhole = {"identifier": identifier, "situation_geometry": self.make_point_2d(x, y)} + manhole_id = self.insert("vw_qgep_wastewater_structure", manhole) + manhole_wn_id = self.select("vw_qgep_wastewater_structure", manhole_id)["wn_obj_id"] return manhole_id, manhole_wn_id def connect_reach(self, reach_id, from_id=None, to_id=None): @@ -60,10 +55,10 @@ def connect_reach(self, reach_id, from_id=None, to_id=None): """ data = {} if from_id is not None: - data['rp_from_fk_wastewater_networkelement'] = from_id + data["rp_from_fk_wastewater_networkelement"] = from_id if to_id is not None: - data['rp_to_fk_wastewater_networkelement'] = to_id - self.update('vw_qgep_reach', data, reach_id) + data["rp_to_fk_wastewater_networkelement"] = to_id + self.update("vw_qgep_reach", data, reach_id) def refresh_graph(self): cur = self.cursor() @@ -94,8 +89,8 @@ def downstream_nodes_depths(self, node_id): FROM downstream; """ cur = self.cursor() - cur.execute(query, (node_id, )) - return {row['obj_id'] : row['depth'] for row in cur.fetchall()} + cur.execute(query, (node_id,)) + return {row["obj_id"]: row["depth"] for row in cur.fetchall()} def upstream_nodes_depths(self, node_id): """returns a dict with all upstream nodes depths by id @@ -121,8 +116,8 @@ def upstream_nodes_depths(self, node_id): FROM upstream """ cur = self.cursor() - cur.execute(query, (node_id, )) - return {row['obj_id'] : row['depth'] for row in cur.fetchall()} + cur.execute(query, (node_id,)) + return {row["obj_id"]: row["depth"] for row in cur.fetchall()} def test_network_basic(self): """ @@ -139,9 +134,9 @@ def test_network_basic(self): first is connected FROM the manhole, second is connected TO manhole """ - manhole_id, manhole_wn_id = self.make_manhole('manhole', 0, 0) - reach_1_id, rp_1a_id, rp_1b_id = self.make_reach('first', 0, 0, 10, 0) - reach_2_id, rp_2a_id, rp_2b_id = self.make_reach('second', 0, 10, 0, 0) + manhole_id, manhole_wn_id = self.make_manhole("manhole", 0, 0) + reach_1_id, rp_1a_id, rp_1b_id = self.make_reach("first", 0, 0, 10, 0) + reach_2_id, rp_2a_id, rp_2b_id = self.make_reach("second", 0, 10, 0, 0) self.connect_reach(reach_1_id, from_id=manhole_wn_id) self.connect_reach(reach_2_id, to_id=manhole_wn_id) @@ -152,34 +147,34 @@ def test_network_basic(self): down_depths = self.downstream_nodes_depths(manhole_wn_id) up_depths = self.upstream_nodes_depths(manhole_wn_id) - self.assertEqual( len(up_depths), 3) - self.assertEqual( up_depths[rp_2a_id], -2 ) - self.assertEqual( up_depths[rp_2b_id], -1 ) - self.assertEqual( len(down_depths), 3) - self.assertEqual( down_depths[rp_1a_id], 1 ) - self.assertEqual( down_depths[rp_1b_id], 2 ) + self.assertEqual(len(up_depths), 3) + self.assertEqual(up_depths[rp_2a_id], -2) + self.assertEqual(up_depths[rp_2b_id], -1) + self.assertEqual(len(down_depths), 3) + self.assertEqual(down_depths[rp_1a_id], 1) + self.assertEqual(down_depths[rp_1b_id], 2) # test network from reach 2 start down_depths = self.downstream_nodes_depths(rp_2a_id) up_depths = self.upstream_nodes_depths(rp_2a_id) - self.assertEqual( len(up_depths), 1) - self.assertEqual( len(down_depths), 5) - self.assertEqual( down_depths[rp_2b_id], 1 ) - self.assertEqual( down_depths[manhole_wn_id], 2 ) - self.assertEqual( down_depths[rp_1a_id], 3 ) - self.assertEqual( down_depths[rp_1b_id], 4 ) + self.assertEqual(len(up_depths), 1) + self.assertEqual(len(down_depths), 5) + self.assertEqual(down_depths[rp_2b_id], 1) + self.assertEqual(down_depths[manhole_wn_id], 2) + self.assertEqual(down_depths[rp_1a_id], 3) + self.assertEqual(down_depths[rp_1b_id], 4) # test network from reach 1 end down_depths = self.downstream_nodes_depths(rp_1b_id) up_depths = self.upstream_nodes_depths(rp_1b_id) - self.assertEqual( len(up_depths), 5) - self.assertEqual( up_depths[rp_1a_id], -1 ) - self.assertEqual( up_depths[manhole_wn_id], -2 ) - self.assertEqual( up_depths[rp_2b_id], -3 ) - self.assertEqual( up_depths[rp_2a_id], -4 ) - self.assertEqual( len(down_depths), 1) + self.assertEqual(len(up_depths), 5) + self.assertEqual(up_depths[rp_1a_id], -1) + self.assertEqual(up_depths[manhole_wn_id], -2) + self.assertEqual(up_depths[rp_2b_id], -3) + self.assertEqual(up_depths[rp_2a_id], -4) + self.assertEqual(len(down_depths), 1) def test_network_blind_connection(self): """ @@ -195,9 +190,9 @@ def test_network_blind_connection(self): first is connected FROM manhole, second is connected TO first directly (blind connection) """ - manhole_id, manhole_wn_id = self.make_manhole('manhole', 0, 0) - reach_1_id, rp_1a_id, rp_1b_id = self.make_reach('first', 0, 0, 10, 0) - reach_2_id, rp_2a_id, rp_2b_id = self.make_reach('second', 5, 10, 5, 0) + manhole_id, manhole_wn_id = self.make_manhole("manhole", 0, 0) + reach_1_id, rp_1a_id, rp_1b_id = self.make_reach("first", 0, 0, 10, 0) + reach_2_id, rp_2a_id, rp_2b_id = self.make_reach("second", 5, 10, 5, 0) self.connect_reach(reach_1_id, from_id=manhole_wn_id) self.connect_reach(reach_2_id, to_id=reach_1_id) @@ -208,30 +203,30 @@ def test_network_blind_connection(self): down_depths = self.downstream_nodes_depths(manhole_wn_id) up_depths = self.upstream_nodes_depths(manhole_wn_id) - self.assertEqual( len(up_depths), 1) - self.assertEqual( len(down_depths), 4) - self.assertEqual( down_depths[rp_1a_id], 1 ) - self.assertEqual( down_depths[rp_1b_id], 3 ) + self.assertEqual(len(up_depths), 1) + self.assertEqual(len(down_depths), 4) + self.assertEqual(down_depths[rp_1a_id], 1) + self.assertEqual(down_depths[rp_1b_id], 3) # test network from reach 2 start down_depths = self.downstream_nodes_depths(rp_2a_id) up_depths = self.upstream_nodes_depths(rp_2a_id) - self.assertEqual( len(up_depths), 1) - self.assertEqual( len(down_depths), 4) - self.assertEqual( down_depths[rp_2b_id], 1 ) - self.assertEqual( down_depths[rp_1b_id], 3 ) + self.assertEqual(len(up_depths), 1) + self.assertEqual(len(down_depths), 4) + self.assertEqual(down_depths[rp_2b_id], 1) + self.assertEqual(down_depths[rp_1b_id], 3) # test network from reach 1 end down_depths = self.downstream_nodes_depths(rp_1b_id) up_depths = self.upstream_nodes_depths(rp_1b_id) - self.assertEqual( len(up_depths), 6) - self.assertEqual( up_depths[rp_1a_id], -2 ) - self.assertEqual( up_depths[manhole_wn_id], -3 ) - self.assertEqual( up_depths[rp_2b_id], -2 ) - self.assertEqual( up_depths[rp_2a_id], -3 ) - self.assertEqual( len(down_depths), 1) + self.assertEqual(len(up_depths), 6) + self.assertEqual(up_depths[rp_1a_id], -2) + self.assertEqual(up_depths[manhole_wn_id], -3) + self.assertEqual(up_depths[rp_2b_id], -2) + self.assertEqual(up_depths[rp_2a_id], -3) + self.assertEqual(len(down_depths), 1) def test_network_blind_connection_overlaid(self): """ @@ -247,9 +242,9 @@ def test_network_blind_connection_overlaid(self): but at the same position than the node """ - manhole_id, manhole_wn_id = self.make_manhole('manhole', 0, 0) - reach_1_id, rp_1a_id, rp_1b_id = self.make_reach('first', 0, 0, 10, 0) - reach_2_id, rp_2a_id, rp_2b_id = self.make_reach('second', 0, 10, 0, 0) + manhole_id, manhole_wn_id = self.make_manhole("manhole", 0, 0) + reach_1_id, rp_1a_id, rp_1b_id = self.make_reach("first", 0, 0, 10, 0) + reach_2_id, rp_2a_id, rp_2b_id = self.make_reach("second", 0, 10, 0, 0) self.connect_reach(reach_1_id, from_id=manhole_wn_id) self.connect_reach(reach_2_id, to_id=reach_1_id) @@ -260,30 +255,30 @@ def test_network_blind_connection_overlaid(self): down_depths = self.downstream_nodes_depths(manhole_wn_id) up_depths = self.upstream_nodes_depths(manhole_wn_id) - self.assertEqual( len(up_depths), 1) - self.assertEqual( len(down_depths), 3) - self.assertEqual( down_depths[rp_1a_id], 1 ) - self.assertEqual( down_depths[rp_1b_id], 2 ) + self.assertEqual(len(up_depths), 1) + self.assertEqual(len(down_depths), 3) + self.assertEqual(down_depths[rp_1a_id], 1) + self.assertEqual(down_depths[rp_1b_id], 2) # test network from reach 2 start down_depths = self.downstream_nodes_depths(rp_2a_id) up_depths = self.upstream_nodes_depths(rp_2a_id) - self.assertEqual( len(up_depths), 1) - self.assertEqual( len(down_depths), 4) - self.assertEqual( down_depths[rp_2b_id], 1 ) - self.assertEqual( down_depths[rp_1b_id], 3 ) + self.assertEqual(len(up_depths), 1) + self.assertEqual(len(down_depths), 4) + self.assertEqual(down_depths[rp_2b_id], 1) + self.assertEqual(down_depths[rp_1b_id], 3) # test network from reach 1 end down_depths = self.downstream_nodes_depths(rp_1b_id) up_depths = self.upstream_nodes_depths(rp_1b_id) - self.assertEqual( len(up_depths), 5) - self.assertEqual( up_depths[rp_1a_id], -1 ) - self.assertEqual( up_depths[manhole_wn_id], -2 ) - self.assertEqual( up_depths[rp_2b_id], -2 ) - self.assertEqual( up_depths[rp_2a_id], -3 ) - self.assertEqual( len(down_depths), 1) + self.assertEqual(len(up_depths), 5) + self.assertEqual(up_depths[rp_1a_id], -1) + self.assertEqual(up_depths[manhole_wn_id], -2) + self.assertEqual(up_depths[rp_2b_id], -2) + self.assertEqual(up_depths[rp_2a_id], -3) + self.assertEqual(len(down_depths), 1) def test_network_two_blind_connection(self): """ @@ -299,10 +294,10 @@ def test_network_two_blind_connection(self): first is connected FROM manhole, second and third are connected TO first directly (blind connection) """ - manhole_id, manhole_wn_id = self.make_manhole('manhole', 0, 0) - reach_1_id, rp_1a_id, rp_1b_id = self.make_reach('first', 0, 0, 10, 0) - reach_2_id, rp_2a_id, rp_2b_id = self.make_reach('second', 3, 10, 3, 0) - reach_3_id, rp_3a_id, rp_3b_id = self.make_reach('third', 6, 10, 6, 0) + manhole_id, manhole_wn_id = self.make_manhole("manhole", 0, 0) + reach_1_id, rp_1a_id, rp_1b_id = self.make_reach("first", 0, 0, 10, 0) + reach_2_id, rp_2a_id, rp_2b_id = self.make_reach("second", 3, 10, 3, 0) + reach_3_id, rp_3a_id, rp_3b_id = self.make_reach("third", 6, 10, 6, 0) self.connect_reach(reach_1_id, from_id=manhole_wn_id) self.connect_reach(reach_2_id, to_id=reach_1_id) @@ -314,30 +309,30 @@ def test_network_two_blind_connection(self): down_depths = self.downstream_nodes_depths(manhole_wn_id) up_depths = self.upstream_nodes_depths(manhole_wn_id) - self.assertEqual( len(up_depths), 1) - self.assertEqual( len(down_depths), 5) - self.assertEqual( down_depths[rp_1a_id], 1 ) - self.assertEqual( down_depths[rp_1b_id], 4 ) + self.assertEqual(len(up_depths), 1) + self.assertEqual(len(down_depths), 5) + self.assertEqual(down_depths[rp_1a_id], 1) + self.assertEqual(down_depths[rp_1b_id], 4) # test network from reach 2 start down_depths = self.downstream_nodes_depths(rp_2a_id) up_depths = self.upstream_nodes_depths(rp_2a_id) - self.assertEqual( len(up_depths), 1) - self.assertEqual( len(down_depths), 5) - self.assertEqual( down_depths[rp_2b_id], 1 ) - self.assertEqual( down_depths[rp_1b_id], 4 ) + self.assertEqual(len(up_depths), 1) + self.assertEqual(len(down_depths), 5) + self.assertEqual(down_depths[rp_2b_id], 1) + self.assertEqual(down_depths[rp_1b_id], 4) # test network from reach 1 end down_depths = self.downstream_nodes_depths(rp_1b_id) up_depths = self.upstream_nodes_depths(rp_1b_id) - self.assertEqual( len(up_depths), 9) - self.assertEqual( up_depths[rp_1a_id], -3 ) - self.assertEqual( up_depths[manhole_wn_id], -4 ) - self.assertEqual( up_depths[rp_2b_id], -3 ) - self.assertEqual( up_depths[rp_2a_id], -4 ) - self.assertEqual( len(down_depths), 1) + self.assertEqual(len(up_depths), 9) + self.assertEqual(up_depths[rp_1a_id], -3) + self.assertEqual(up_depths[manhole_wn_id], -4) + self.assertEqual(up_depths[rp_2b_id], -3) + self.assertEqual(up_depths[rp_2a_id], -4) + self.assertEqual(len(down_depths), 1) def test_network_two_opposing_blind_connection(self): """ @@ -359,10 +354,10 @@ def test_network_two_opposing_blind_connection(self): but arrive at the exact same point """ - manhole_id, manhole_wn_id = self.make_manhole('manhole', 0, 0) - reach_1_id, rp_1a_id, rp_1b_id = self.make_reach('first', 0, 0, 10, 0) - reach_2_id, rp_2a_id, rp_2b_id = self.make_reach('second', 5, 10, 5, 0) - reach_3_id, rp_3a_id, rp_3b_id = self.make_reach('third', 5, -10, 5, 0) + manhole_id, manhole_wn_id = self.make_manhole("manhole", 0, 0) + reach_1_id, rp_1a_id, rp_1b_id = self.make_reach("first", 0, 0, 10, 0) + reach_2_id, rp_2a_id, rp_2b_id = self.make_reach("second", 5, 10, 5, 0) + reach_3_id, rp_3a_id, rp_3b_id = self.make_reach("third", 5, -10, 5, 0) self.connect_reach(reach_1_id, from_id=manhole_wn_id) self.connect_reach(reach_2_id, to_id=reach_1_id) @@ -374,31 +369,31 @@ def test_network_two_opposing_blind_connection(self): down_depths = self.downstream_nodes_depths(manhole_wn_id) up_depths = self.upstream_nodes_depths(manhole_wn_id) - self.assertEqual( len(up_depths), 1) - self.assertEqual( len(down_depths), 4) - self.assertEqual( down_depths[rp_1a_id], 1 ) - self.assertEqual( down_depths[rp_1b_id], 3 ) + self.assertEqual(len(up_depths), 1) + self.assertEqual(len(down_depths), 4) + self.assertEqual(down_depths[rp_1a_id], 1) + self.assertEqual(down_depths[rp_1b_id], 3) # test network from reach 2 start down_depths = self.downstream_nodes_depths(rp_2a_id) up_depths = self.upstream_nodes_depths(rp_2a_id) - self.assertEqual( len(up_depths), 1) - self.assertEqual( len(down_depths), 4) - self.assertEqual( down_depths[rp_2b_id], 1 ) - self.assertEqual( down_depths[rp_1b_id], 3 ) + self.assertEqual(len(up_depths), 1) + self.assertEqual(len(down_depths), 4) + self.assertEqual(down_depths[rp_2b_id], 1) + self.assertEqual(down_depths[rp_1b_id], 3) # test network from reach 1 end down_depths = self.downstream_nodes_depths(rp_1b_id) up_depths = self.upstream_nodes_depths(rp_1b_id) - self.assertEqual( len(up_depths), 8) - self.assertEqual( up_depths[rp_1a_id], -2 ) - self.assertEqual( up_depths[manhole_wn_id], -3 ) - self.assertEqual( up_depths[rp_2b_id], -2 ) - self.assertEqual( up_depths[rp_2a_id], -3 ) - self.assertEqual( len(down_depths), 1) + self.assertEqual(len(up_depths), 8) + self.assertEqual(up_depths[rp_1a_id], -2) + self.assertEqual(up_depths[manhole_wn_id], -3) + self.assertEqual(up_depths[rp_2b_id], -2) + self.assertEqual(up_depths[rp_2a_id], -3) + self.assertEqual(len(down_depths), 1) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_on_delete.py b/test/test_on_delete.py index fde46afce..3134e7a5b 100644 --- a/test/test_on_delete.py +++ b/test/test_on_delete.py @@ -1,9 +1,9 @@ -import unittest +import decimal import os +import unittest import psycopg2 import psycopg2.extras -import decimal from .utils import DbTestBase @@ -16,144 +16,189 @@ def tearDownClass(cls): @classmethod def setUpClass(cls): - pgservice = os.environ.get('PGSERVICE') or 'pg_qgep' - cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) + pgservice = os.environ.get("PGSERVICE") or "pg_qgep" + cls.conn = psycopg2.connect(f"service={pgservice}") def test_delete_wastewater_structure(self): # Create a new cover(structure part) with manhole(wastewater structure) row = { - 'identifier': 'CO698', - 'co_level': decimal.Decimal('100.000'), - 'ws_type': 'manhole', - 'situation_geometry': '0101000020080800000000000060E346410000000060E33641' # ST_SetSRID(ST_MakePoint(3000000, 1500000), 2056) + "identifier": "CO698", + "co_level": decimal.Decimal("100.000"), + "ws_type": "manhole", + "situation_geometry": "0101000020080800000000000060E346410000000060E33641", # ST_SetSRID(ST_MakePoint(3000000, 1500000), 2056) } - obj_id = self.insert_check('vw_qgep_wastewater_structure', row) + obj_id = self.insert_check("vw_qgep_wastewater_structure", row) # Get the new cover - row = self.select('vw_qgep_wastewater_structure', obj_id) - row = self.select('vw_cover', row['co_obj_id']) + row = self.select("vw_qgep_wastewater_structure", obj_id) + row = self.select("vw_cover", row["co_obj_id"]) - self.delete('wastewater_structure', row['fk_wastewater_structure']) + self.delete("wastewater_structure", row["fk_wastewater_structure"]) # Just to be sure the structure really was deleted - self.assertIsNone(self.select('manhole', row['fk_wastewater_structure'])) - self.assertIsNone(self.select('wastewater_structure', row['fk_wastewater_structure'])) + self.assertIsNone(self.select("manhole", row["fk_wastewater_structure"])) + self.assertIsNone(self.select("wastewater_structure", row["fk_wastewater_structure"])) # The cover should be delted as well. If not, the foreign key constraint action does not work properly - self.assertIsNone(self.select('vw_cover', obj_id)) - + self.assertIsNone(self.select("vw_cover", obj_id)) def test_delete_reach(self): # Create a new reach and reachpoints - rp001_obj_id = self.insert_check('reach_point', {'identifier': 'RP001', 'situation_geometry': '01010000A0080800000000000060E346410000000060E336410000000000005940'}) # ST_MakePoint(3000000, 1500000, 100) - rp002_obj_id = self.insert_check('reach_point', {'identifier': 'RP002', 'situation_geometry': '01010000A0080800000000008060E346410000000061E336410000000000005940'}) # ST_MakePoint(3000001, 1500001, 100) - wn001_obj_id = self.insert_check('wastewater_networkelement', {'identifier': 'WN001'}) + rp001_obj_id = self.insert_check( + "reach_point", + { + "identifier": "RP001", + "situation_geometry": "01010000A0080800000000000060E346410000000060E336410000000000005940", + }, + ) # ST_MakePoint(3000000, 1500000, 100) + rp002_obj_id = self.insert_check( + "reach_point", + { + "identifier": "RP002", + "situation_geometry": "01010000A0080800000000008060E346410000000061E336410000000000005940", + }, + ) # ST_MakePoint(3000001, 1500001, 100) + wn001_obj_id = self.insert_check("wastewater_networkelement", {"identifier": "WN001"}) row = { - 'obj_id': wn001_obj_id, - 'fk_reach_point_from': rp001_obj_id, - 'fk_reach_point_to': rp002_obj_id, - 'progression_geometry': '01090000A008080000010000000102000080020000000000000060E346410000000060E3364100000000000059400000008060E346410000000061E336410000000000005940' # SELECT ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 100), ST_MakePoint(3000001, 1500001, 100)), 2056)); + "obj_id": wn001_obj_id, + "fk_reach_point_from": rp001_obj_id, + "fk_reach_point_to": rp002_obj_id, + "progression_geometry": "01090000A008080000010000000102000080020000000000000060E346410000000060E3364100000000000059400000008060E346410000000061E336410000000000005940", # SELECT ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 100), ST_MakePoint(3000001, 1500001, 100)), 2056)); } - re001_obj_id = self.insert_check('reach', row) + re001_obj_id = self.insert_check("reach", row) - self.assertIsNotNone(self.select('reach', re001_obj_id)) - self.assertIsNotNone(self.select('reach_point', rp001_obj_id)) - self.assertIsNotNone(self.select('reach_point', rp002_obj_id)) - self.assertIsNotNone(self.select('wastewater_networkelement', wn001_obj_id)) + self.assertIsNotNone(self.select("reach", re001_obj_id)) + self.assertIsNotNone(self.select("reach_point", rp001_obj_id)) + self.assertIsNotNone(self.select("reach_point", rp002_obj_id)) + self.assertIsNotNone(self.select("wastewater_networkelement", wn001_obj_id)) - self.delete('reach', re001_obj_id) + self.delete("reach", re001_obj_id) - self.assertIsNone(self.select('reach', re001_obj_id)) - self.assertIsNone(self.select('reach_point', rp001_obj_id)) - self.assertIsNone(self.select('reach_point', rp002_obj_id)) - self.assertIsNone(self.select('wastewater_networkelement', wn001_obj_id)) + self.assertIsNone(self.select("reach", re001_obj_id)) + self.assertIsNone(self.select("reach_point", rp001_obj_id)) + self.assertIsNone(self.select("reach_point", rp002_obj_id)) + self.assertIsNone(self.select("wastewater_networkelement", wn001_obj_id)) # The same but over the view vw_qgep_reach # Create a new reach and reach points - rp001_obj_id = self.insert_check('reach_point', {'identifier': 'RP001', 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000000, 1500000, 100), 2056)')}) - rp002_obj_id = self.insert_check('reach_point', {'identifier': 'RP002', 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000001, 1500001, 100), 2056)')}) - wn001_obj_id = self.insert_check('wastewater_networkelement', {'identifier': 'WN001'}) + rp001_obj_id = self.insert_check( + "reach_point", + { + "identifier": "RP001", + "situation_geometry": self.execute( + "ST_SetSrid(ST_MakePoint(3000000, 1500000, 100), 2056)" + ), + }, + ) + rp002_obj_id = self.insert_check( + "reach_point", + { + "identifier": "RP002", + "situation_geometry": self.execute( + "ST_SetSrid(ST_MakePoint(3000001, 1500001, 100), 2056)" + ), + }, + ) + wn001_obj_id = self.insert_check("wastewater_networkelement", {"identifier": "WN001"}) row = { - 'obj_id': wn001_obj_id, - 'fk_reach_point_from': rp001_obj_id, - 'fk_reach_point_to': rp002_obj_id, - 'progression_geometry': self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 100), ST_MakePoint(3000001, 1500001, 100)), 2056))') + "obj_id": wn001_obj_id, + "fk_reach_point_from": rp001_obj_id, + "fk_reach_point_to": rp002_obj_id, + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 100), ST_MakePoint(3000001, 1500001, 100)), 2056))" + ), } - re001_obj_id = self.insert_check('reach', row) + re001_obj_id = self.insert_check("reach", row) - self.assertIsNotNone(self.select('vw_qgep_reach', re001_obj_id)) - self.assertIsNotNone(self.select('reach_point', rp001_obj_id)) - self.assertIsNotNone(self.select('reach_point', rp002_obj_id)) - self.assertIsNotNone(self.select('wastewater_networkelement', wn001_obj_id)) + self.assertIsNotNone(self.select("vw_qgep_reach", re001_obj_id)) + self.assertIsNotNone(self.select("reach_point", rp001_obj_id)) + self.assertIsNotNone(self.select("reach_point", rp002_obj_id)) + self.assertIsNotNone(self.select("wastewater_networkelement", wn001_obj_id)) - self.delete('vw_qgep_reach', re001_obj_id) + self.delete("vw_qgep_reach", re001_obj_id) - self.assertIsNone(self.select('vw_qgep_reach', re001_obj_id)) - self.assertIsNone(self.select('reach_point', rp001_obj_id)) - self.assertIsNone(self.select('reach_point', rp002_obj_id)) - self.assertIsNone(self.select('wastewater_networkelement', wn001_obj_id)) + self.assertIsNone(self.select("vw_qgep_reach", re001_obj_id)) + self.assertIsNone(self.select("reach_point", rp001_obj_id)) + self.assertIsNone(self.select("reach_point", rp002_obj_id)) + self.assertIsNone(self.select("wastewater_networkelement", wn001_obj_id)) # control that channel is delete if no reach left - ws001_obj_id = self.insert_check('wastewater_structure', {'obj_id': 'CH001'}) - ch001_obj_id = self.insert_check('channel', {'obj_id': 'CH001'}) + ws001_obj_id = self.insert_check("wastewater_structure", {"obj_id": "CH001"}) + ch001_obj_id = self.insert_check("channel", {"obj_id": "CH001"}) rp001_obj_id = self.insert_check( - 'reach_point', { - 'identifier': 'RP001', - 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000000, 1500000, 100), 2056)') - } + "reach_point", + { + "identifier": "RP001", + "situation_geometry": self.execute( + "ST_SetSrid(ST_MakePoint(3000000, 1500000, 100), 2056)" + ), + }, ) rp002_obj_id = self.insert_check( - 'reach_point', { - 'identifier': 'RP002', + "reach_point", + { + "identifier": "RP002", # ST_SetSrid(ST_MakePoint(3000001, 1500001, 100), 2056) - 'situation_geometry': '01010000A0080800000000008060E346410000000061E336410000000000005940' - } + "situation_geometry": "01010000A0080800000000008060E346410000000061E336410000000000005940", + }, + ) + wn001_obj_id = self.insert_check( + "wastewater_networkelement", + {"identifier": "WN001", "fk_wastewater_structure": ch001_obj_id}, ) - wn001_obj_id = self.insert_check('wastewater_networkelement', {'identifier': 'WN001', - 'fk_wastewater_structure': ch001_obj_id}) re001_obj_id = self.insert_check( - 'reach', { - 'obj_id': wn001_obj_id, - 'fk_reach_point_from': rp001_obj_id, - 'fk_reach_point_to': rp002_obj_id, - 'progression_geometry': self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 100), ST_MakePoint(3000001, 1500001, 100)), 2056))') - } + "reach", + { + "obj_id": wn001_obj_id, + "fk_reach_point_from": rp001_obj_id, + "fk_reach_point_to": rp002_obj_id, + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 100), ST_MakePoint(3000001, 1500001, 100)), 2056))" + ), + }, ) rp011_obj_id = self.insert_check( - 'reach_point', { - 'identifier': 'RP011', - 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000002, 1500002, 100), 2056)') - } + "reach_point", + { + "identifier": "RP011", + "situation_geometry": self.execute( + "ST_SetSrid(ST_MakePoint(3000002, 1500002, 100), 2056)" + ), + }, ) rp012_obj_id = self.insert_check( - 'reach_point', { - 'identifier': 'RP012', - 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000003, 1500003, 100), 2056)') - } + "reach_point", + { + "identifier": "RP012", + "situation_geometry": self.execute( + "ST_SetSrid(ST_MakePoint(3000003, 1500003, 100), 2056)" + ), + }, ) wn011_obj_id = self.insert_check( - 'wastewater_networkelement', { - 'identifier': 'WN011', - 'fk_wastewater_structure': ch001_obj_id - } + "wastewater_networkelement", + {"identifier": "WN011", "fk_wastewater_structure": ch001_obj_id}, ) re011_obj_id = self.insert_check( - 'reach', { - 'obj_id': wn011_obj_id, - 'fk_reach_point_from': rp011_obj_id, - 'fk_reach_point_to': rp012_obj_id, - 'progression_geometry': self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000002, 1500002, 100), ST_MakePoint(3000003, 1500003, 100)), 2056))') - } + "reach", + { + "obj_id": wn011_obj_id, + "fk_reach_point_from": rp011_obj_id, + "fk_reach_point_to": rp012_obj_id, + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000002, 1500002, 100), ST_MakePoint(3000003, 1500003, 100)), 2056))" + ), + }, ) self.assertEqual(ch001_obj_id, ws001_obj_id) - self.delete('reach', re001_obj_id) - self.assertIsNotNone(self.select('channel', ch001_obj_id)) - self.delete('reach', re011_obj_id) - self.assertIsNone(self.select('channel', ch001_obj_id)) + self.delete("reach", re001_obj_id) + self.assertIsNotNone(self.select("channel", ch001_obj_id)) + self.delete("reach", re011_obj_id) + self.assertIsNone(self.select("channel", ch001_obj_id)) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_removed_fields.py b/test/test_removed_fields.py index 45d2cd55f..b98db514e 100644 --- a/test/test_removed_fields.py +++ b/test/test_removed_fields.py @@ -1,5 +1,5 @@ -import unittest import os +import unittest import psycopg2 import psycopg2.extras @@ -15,9 +15,8 @@ def tearDownClass(cls): @classmethod def setUpClass(cls): - pgservice = os.environ.get('PGSERVICE') or 'pg_qgep' - cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) - + pgservice = os.environ.get("PGSERVICE") or "pg_qgep" + cls.conn = psycopg2.connect(f"service={pgservice}") def test_dataowner(self): cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor) @@ -25,8 +24,9 @@ def test_dataowner(self): cur.execute("SELECT * FROM qgep_od.wastewater_structure LIMIT 1") colnames = [desc[0] for desc in cur.description] - self.assertNotIn('provider', colnames) - self.assertNotIn('dataowner', colnames) + self.assertNotIn("provider", colnames) + self.assertNotIn("dataowner", colnames) + -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_swmm.py b/test/test_swmm.py index 8fa2ad35b..cc4d98865 100644 --- a/test/test_swmm.py +++ b/test/test_swmm.py @@ -1,10 +1,8 @@ -import unittest import os +import unittest import psycopg2 import psycopg2.extras -import decimal -import copy from .utils import DbTestBase @@ -20,8 +18,8 @@ def tearDown(cls): @classmethod def setUp(cls): - pgservice=os.environ.get('PGSERVICE') or 'pg_qgep' - cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) + pgservice = os.environ.get("PGSERVICE") or "pg_qgep" + cls.conn = psycopg2.connect(f"service={pgservice}") def test_count_vw_aquifers(self): self.assert_count("vw_aquifers", "qgep_swmm", 0) @@ -83,5 +81,6 @@ def test_count_vw_vertices(self): def test_count_vw_xsections(self): self.assert_count("vw_xsections", "qgep_swmm", 5095) -if __name__ == '__main__': + +if __name__ == "__main__": unittest.main() diff --git a/test/test_triggers.py b/test/test_triggers.py index 416299f42..70943457e 100644 --- a/test/test_triggers.py +++ b/test/test_triggers.py @@ -1,9 +1,9 @@ -import unittest +import decimal import os +import unittest import psycopg2 import psycopg2.extras -import decimal from .utils import DbTestBase @@ -16,93 +16,101 @@ def tearDownClass(cls): @classmethod def setUpClass(cls): - pgservice = os.environ.get('PGSERVICE') or 'pg_qgep' - cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) + pgservice = os.environ.get("PGSERVICE") or "pg_qgep" + cls.conn = psycopg2.connect(f"service={pgservice}") def test_last_modified(self): row = { - 'identifier': 'CO123', - 'level': decimal.Decimal('100.000'), - 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000000, 1500000, 100), 2056)') + "identifier": "CO123", + "level": decimal.Decimal("100.000"), + "situation_geometry": self.execute( + "ST_SetSrid(ST_MakePoint(3000000, 1500000, 100), 2056)" + ), } - obj_id = self.insert_check('vw_cover', row) + obj_id = self.insert_check("vw_cover", row) - row = self.select('structure_part', obj_id) + row = self.select("structure_part", obj_id) - last_mod = row['last_modification'] + last_mod = row["last_modification"] assert last_mod is not None, "Last modification not set on insert" row = { - 'identifier': 'CO1234', + "identifier": "CO1234", } - self.update_check('structure_part', row, obj_id) + self.update_check("structure_part", row, obj_id) - row = self.select('structure_part', obj_id) - assert last_mod != row['last_modification'], "Last modification not set on update (still {})".format(row['last_modification']) + row = self.select("structure_part", obj_id) + assert ( + last_mod != row["last_modification"] + ), "Last modification not set on update (still {})".format(row["last_modification"]) - last_mod = row['last_modification'] + last_mod = row["last_modification"] - row = { - 'level': decimal.Decimal('300.000') - } + row = {"level": decimal.Decimal("300.000")} - self.update_check('cover', row, obj_id) + self.update_check("cover", row, obj_id) - row = self.select('structure_part', obj_id) - assert last_mod != row['last_modification'], "Last modification not set on update of child table (still {})".format(row['last_modification']) + row = self.select("structure_part", obj_id) + assert ( + last_mod != row["last_modification"] + ), "Last modification not set on update of child table (still {})".format( + row["last_modification"] + ) def test_identifier(self): row = { - 'co_level': decimal.Decimal('100.000'), - 'ws_type': 'manhole', - 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000000, 1500000), 2056)') + "co_level": decimal.Decimal("100.000"), + "ws_type": "manhole", + "situation_geometry": self.execute("ST_SetSrid(ST_MakePoint(3000000, 1500000), 2056)"), } - obj_id = self.insert_check('vw_qgep_wastewater_structure', row) + obj_id = self.insert_check("vw_qgep_wastewater_structure", row) - row = self.select('vw_qgep_wastewater_structure', obj_id) + row = self.select("vw_qgep_wastewater_structure", obj_id) for r in row: print(r) - row = self.select('structure_part', row['co_obj_id']) + row = self.select("structure_part", row["co_obj_id"]) for r in row: print(r) - identifier = row['identifier'] - assert identifier, "Identifier not set on insert: {}".format(repr(identifier)) + identifier = row["identifier"] + assert identifier, f"Identifier not set on insert: {repr(identifier)}" def test_labels(self): strct_id = None def check_values(expected_values_for_field): - row = self.select('vw_qgep_wastewater_structure', strct_id) + row = self.select("vw_qgep_wastewater_structure", strct_id) for field, expected_value in expected_values_for_field.items(): - assert row[field] == expected_value, "Field {} is incorrect: {} instead of {}".format( + assert ( + row[field] == expected_value + ), "Field {} is incorrect: {} instead of {}".format( field, repr(row[field]), repr(expected_value) ) - + # Test label generation on insert row_strct = { - 'identifier': 'A', - 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000000, 1500000), 2056)'), - 'ws_type': 'manhole', - 'co_level': decimal.Decimal('100.000'), + "identifier": "A", + "situation_geometry": self.execute("ST_SetSrid(ST_MakePoint(3000000, 1500000), 2056)"), + "ws_type": "manhole", + "co_level": decimal.Decimal("100.000"), } - strct_id = self.insert('vw_qgep_wastewater_structure', row_strct) - strct_row = self.select('vw_qgep_wastewater_structure', strct_id) + strct_id = self.insert("vw_qgep_wastewater_structure", row_strct) + strct_row = self.select("vw_qgep_wastewater_structure", strct_id) expected = { - '_label': 'A', - '_cover_label': '\nC=100.00', - '_bottom_label': '', - '_input_label': '', - '_output_label': '', + "_label": "A", + "_cover_label": "\nC=100.00", + "_bottom_label": "", + "_input_label": "", + "_output_label": "", } check_values(expected) @@ -110,99 +118,117 @@ def check_values(expected_values_for_field): # Test label generation on update row_strct = { - 'identifier': 'B', - 'co_level': decimal.Decimal('98.000'), - 'wn_bottom_level': decimal.Decimal('90.1234567'), + "identifier": "B", + "co_level": decimal.Decimal("98.000"), + "wn_bottom_level": decimal.Decimal("90.1234567"), } - self.update('vw_qgep_wastewater_structure', row_strct, strct_id) - - expected.update({ - '_label': 'B', - '_cover_label': '\nC=98.00', - '_bottom_label': '\nB=90.12', - }) + self.update("vw_qgep_wastewater_structure", row_strct, strct_id) + + expected.update( + { + "_label": "B", + "_cover_label": "\nC=98.00", + "_bottom_label": "\nB=90.12", + } + ) check_values(expected) # Test label generation on reach insert row_reach_a = { - 'identifier': 'R1', - 'progression_geometry': self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000001, 1500001, 100), ST_MakePoint(3000000, 1500000, 100)), 2056))'), - 'ch_function_hierarchic': 5062, - 'rp_to_fk_wastewater_networkelement': strct_row['wn_obj_id'], - 'rp_to_level': 95 + "identifier": "R1", + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000001, 1500001, 100), ST_MakePoint(3000000, 1500000, 100)), 2056))" + ), + "ch_function_hierarchic": 5062, + "rp_to_fk_wastewater_networkelement": strct_row["wn_obj_id"], + "rp_to_level": 95, } - reach_a_id = self.insert('vw_qgep_reach', row_reach_a) - - expected.update({ - '_input_label': '\nI=95.00', - }) + reach_a_id = self.insert("vw_qgep_reach", row_reach_a) + + expected.update( + { + "_input_label": "\nI=95.00", + } + ) check_values(expected) row_reach_b = { - 'identifier': 'R2', - 'progression_geometry': self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 92), ST_MakePoint(3000000, 1500001, 90)), 2056))'), - 'ch_function_hierarchic': 5062, - 'rp_from_fk_wastewater_networkelement': strct_row['wn_obj_id'], - 'rp_from_level': 92 + "identifier": "R2", + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 92), ST_MakePoint(3000000, 1500001, 90)), 2056))" + ), + "ch_function_hierarchic": 5062, + "rp_from_fk_wastewater_networkelement": strct_row["wn_obj_id"], + "rp_from_level": 92, } - reach_b_id = self.insert('vw_qgep_reach', row_reach_b) - - expected.update({ - '_output_label': '\nO=92.00', - }) + reach_b_id = self.insert("vw_qgep_reach", row_reach_b) + + expected.update( + { + "_output_label": "\nO=92.00", + } + ) check_values(expected) row_reach_c = { - 'identifier': 'R3', - 'progression_geometry': self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 93), ST_MakePoint(3000001, 1500000, 90)), 2056))'), - 'ch_function_hierarchic': 5062, - 'rp_from_fk_wastewater_networkelement': strct_row['wn_obj_id'], - 'rp_from_level': 93 + "identifier": "R3", + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 93), ST_MakePoint(3000001, 1500000, 90)), 2056))" + ), + "ch_function_hierarchic": 5062, + "rp_from_fk_wastewater_networkelement": strct_row["wn_obj_id"], + "rp_from_level": 93, } - reach_c_id = self.insert('vw_qgep_reach', row_reach_c) + reach_c_id = self.insert("vw_qgep_reach", row_reach_c) - expected.update({ - '_output_label': '\nO1=92.00\nO2=93.00', - }) + expected.update( + { + "_output_label": "\nO1=92.00\nO2=93.00", + } + ) check_values(expected) # Test label generation on reach update (change level) - row_reach_a = { - 'rp_to_level': 94 - } - self.update('vw_qgep_reach', row_reach_a, reach_a_id) - - expected.update({ - '_input_label': '\nI=94.00', - }) + row_reach_a = {"rp_to_level": 94} + self.update("vw_qgep_reach", row_reach_a, reach_a_id) + + expected.update( + { + "_input_label": "\nI=94.00", + } + ) check_values(expected) # Test label generation on reach update (change azimuth) row_reach_b = { - 'progression_geometry': self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 92), ST_MakePoint(3000000, 1499999, 90)), 2056))'), + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 92), ST_MakePoint(3000000, 1499999, 90)), 2056))" + ), } - self.update('vw_qgep_reach', row_reach_b, reach_b_id) - - expected.update({ - '_output_label': '\nO1=93.00\nO2=92.00', - }) + self.update("vw_qgep_reach", row_reach_b, reach_b_id) + + expected.update( + { + "_output_label": "\nO1=93.00\nO2=92.00", + } + ) check_values(expected) # Test label generation on reach update (level to null) - row_reach_c = { - 'rp_from_level': None - } - self.update('vw_qgep_reach', row_reach_c, reach_c_id) + row_reach_c = {"rp_from_level": None} + self.update("vw_qgep_reach", row_reach_c, reach_c_id) - expected.update({ - '_output_label': '\nO1=?\nO2=92.00', - }) + expected.update( + { + "_output_label": "\nO1=?\nO2=92.00", + } + ) check_values(expected) - + # TODO : reenable this (currently, deleting reaches doesn't trigger update on labels) # Test label generation on reach delete # @@ -221,68 +247,119 @@ def test_symbology(self): def check_values(table, obj_id, expected_values_for_field): row = self.select(table, obj_id) for field, expected_value in expected_values_for_field.items(): - assert field in row, "Field {} not present in results ! Available fields are {}".format( - field, ', '.join(row.keys()) + assert ( + field in row + ), "Field {} not present in results ! Available fields are {}".format( + field, ", ".join(row.keys()) ) - assert row[field] == expected_value, "Field {} is incorrect: {} instead of {}".format( + assert ( + row[field] == expected_value + ), "Field {} is incorrect: {} instead of {}".format( field, repr(row[field]), repr(expected_value) ) - strct_from_id = self.insert('vw_qgep_wastewater_structure', { - 'identifier': 'A', - 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000000, 1500000), 2056)'), - 'ws_type': 'manhole', - 'co_level': decimal.Decimal('100.000'), - }) - strct_from_row = self.select('vw_qgep_wastewater_structure', strct_from_id) - - strct_to_id = self.insert('vw_qgep_wastewater_structure', { - 'identifier': 'B', - 'situation_geometry': self.execute('ST_SetSrid(ST_MakePoint(3000001, 1500001), 2056)'), - 'ws_type': 'manhole', - 'co_level': decimal.Decimal('100.000'), - }) - strct_to_row = self.select('vw_qgep_wastewater_structure', strct_to_id) - - reach_id = self.insert('vw_qgep_reach', { - 'identifier': 'R1', - 'progression_geometry': self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000001, 1500001, 100), ST_MakePoint(3000000, 1500000, 100)), 2056))'), - 'ch_function_hierarchic': 5062, - 'rp_from_fk_wastewater_networkelement': strct_from_row['wn_obj_id'], - 'rp_to_fk_wastewater_networkelement': strct_to_row['wn_obj_id'], - }) - - check_values('vw_qgep_wastewater_structure', strct_from_id, { - '_channel_function_hierarchic': 5062, - }) - check_values('vw_qgep_wastewater_structure', strct_to_id, { - '_channel_function_hierarchic': 5062, - }) - - check_values('vw_wastewater_node', strct_from_row['wn_obj_id'], { - '_function_hierarchic': 5062, - }) - check_values('vw_wastewater_node', strct_to_row['wn_obj_id'], { - '_function_hierarchic': 5062, - }) + strct_from_id = self.insert( + "vw_qgep_wastewater_structure", + { + "identifier": "A", + "situation_geometry": self.execute( + "ST_SetSrid(ST_MakePoint(3000000, 1500000), 2056)" + ), + "ws_type": "manhole", + "co_level": decimal.Decimal("100.000"), + }, + ) + strct_from_row = self.select("vw_qgep_wastewater_structure", strct_from_id) + + strct_to_id = self.insert( + "vw_qgep_wastewater_structure", + { + "identifier": "B", + "situation_geometry": self.execute( + "ST_SetSrid(ST_MakePoint(3000001, 1500001), 2056)" + ), + "ws_type": "manhole", + "co_level": decimal.Decimal("100.000"), + }, + ) + strct_to_row = self.select("vw_qgep_wastewater_structure", strct_to_id) + + reach_id = self.insert( + "vw_qgep_reach", + { + "identifier": "R1", + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000001, 1500001, 100), ST_MakePoint(3000000, 1500000, 100)), 2056))" + ), + "ch_function_hierarchic": 5062, + "rp_from_fk_wastewater_networkelement": strct_from_row["wn_obj_id"], + "rp_to_fk_wastewater_networkelement": strct_to_row["wn_obj_id"], + }, + ) + + check_values( + "vw_qgep_wastewater_structure", + strct_from_id, + { + "_channel_function_hierarchic": 5062, + }, + ) + check_values( + "vw_qgep_wastewater_structure", + strct_to_id, + { + "_channel_function_hierarchic": 5062, + }, + ) + + check_values( + "vw_wastewater_node", + strct_from_row["wn_obj_id"], + { + "_function_hierarchic": 5062, + }, + ) + check_values( + "vw_wastewater_node", + strct_to_row["wn_obj_id"], + { + "_function_hierarchic": 5062, + }, + ) # We change _function hierarchic on the reach - self.update('vw_qgep_reach', {'ch_function_hierarchic': 5063}, reach_id) - - check_values('vw_qgep_wastewater_structure', strct_from_id, { - '_channel_function_hierarchic': 5063, - }) - check_values('vw_qgep_wastewater_structure', strct_to_id, { - '_channel_function_hierarchic': 5063, - }) - - check_values('vw_wastewater_node', strct_from_row['wn_obj_id'], { - '_function_hierarchic': 5063, - }) - check_values('vw_wastewater_node', strct_to_row['wn_obj_id'], { - '_function_hierarchic': 5063, - }) - - -if __name__ == '__main__': + self.update("vw_qgep_reach", {"ch_function_hierarchic": 5063}, reach_id) + + check_values( + "vw_qgep_wastewater_structure", + strct_from_id, + { + "_channel_function_hierarchic": 5063, + }, + ) + check_values( + "vw_qgep_wastewater_structure", + strct_to_id, + { + "_channel_function_hierarchic": 5063, + }, + ) + + check_values( + "vw_wastewater_node", + strct_from_row["wn_obj_id"], + { + "_function_hierarchic": 5063, + }, + ) + check_values( + "vw_wastewater_node", + strct_to_row["wn_obj_id"], + { + "_function_hierarchic": 5063, + }, + ) + + +if __name__ == "__main__": unittest.main() diff --git a/test/test_typos.py b/test/test_typos.py index 261fa85a8..47b4bb257 100644 --- a/test/test_typos.py +++ b/test/test_typos.py @@ -1,22 +1,24 @@ -import unittest - -import os import glob +import os +import unittest class TestTypos(unittest.TestCase): def test_typos(self): thisdir = os.path.dirname(os.path.realpath(__file__)) - for filename in glob.glob(os.path.join(thisdir, '..', '*.sql')): - with open(os.path.join(os.getcwd(), '..', filename), 'r') as f: + for filename in glob.glob(os.path.join(thisdir, "..", "*.sql")): + with open(os.path.join(os.getcwd(), "..", filename)) as f: for line in f: - self.assertNotIn('dammage', line) - self.assertNotIn('relativ_path', line) - self.assertNotIn('AddGeometryColumn', line, - msg="""AddGeometryColumn should no longer be used. Use - ALTER TABLE syntax instead""") + self.assertNotIn("dammage", line) + self.assertNotIn("relativ_path", line) + self.assertNotIn( + "AddGeometryColumn", + line, + msg="""AddGeometryColumn should no longer be used. Use + ALTER TABLE syntax instead""", + ) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/test_views.py b/test/test_views.py index aabafc6e0..dabb943de 100644 --- a/test/test_views.py +++ b/test/test_views.py @@ -1,10 +1,10 @@ -import unittest +import copy +import decimal import os +import unittest import psycopg2 import psycopg2.extras -import decimal -import copy from .utils import DbTestBase @@ -17,92 +17,94 @@ def tearDownClass(cls): @classmethod def setUpClass(cls): - pgservice=os.environ.get('PGSERVICE') or 'pg_qgep' - cls.conn = psycopg2.connect("service={service}".format(service=pgservice)) + pgservice = os.environ.get("PGSERVICE") or "pg_qgep" + cls.conn = psycopg2.connect(f"service={pgservice}") def test_vw_reach(self): row = { - 'clear_height': 100, - 'coefficient_of_friction': 10, - 'identifier': '20', - 'progression_geometry': self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 100), ST_MakePoint(3000001, 1500001, 100)), 2056))') - + "clear_height": 100, + "coefficient_of_friction": 10, + "identifier": "20", + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 100), ST_MakePoint(3000001, 1500001, 100)), 2056))" + ), } - obj_id = self.insert_check('vw_reach', row) + obj_id = self.insert_check("vw_reach", row) - row = { - 'clear_height': 200, - 'coefficient_of_friction': 20, - 'identifier': '10' - } + row = {"clear_height": 200, "coefficient_of_friction": 20, "identifier": "10"} - self.update_check('vw_reach', row, obj_id) + self.update_check("vw_reach", row, obj_id) def test_vw_prank_weir(self): - row = { - 'identifier': 'STAR20', - 'level_max': decimal.Decimal('300.123') - } + row = {"identifier": "STAR20", "level_max": decimal.Decimal("300.123")} - obj_id = self.insert_check('vw_prank_weir', row) + obj_id = self.insert_check("vw_prank_weir", row) - row = { - 'identifier': '30', - 'level_max': decimal.Decimal('400.321') - } + row = {"identifier": "30", "level_max": decimal.Decimal("400.321")} - self.update_check('vw_prank_weir', row, obj_id) + self.update_check("vw_prank_weir", row, obj_id) def test_vw_qgep_reach(self): row = { - 'clear_height': 100, - 'coefficient_of_friction': 10, - 'ws_identifier': 'pra', - 'ch_usage_current': 4514, - 'progression_geometry': self.execute("ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 'NaN'), ST_MakePoint(3000001, 1500001, 'NaN')), 2056))") + "clear_height": 100, + "coefficient_of_friction": 10, + "ws_identifier": "pra", + "ch_usage_current": 4514, + "progression_geometry": self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(3000000, 1500000, 'NaN'), ST_MakePoint(3000001, 1500001, 'NaN')), 2056))" + ), } - obj_id = self.insert_check('vw_qgep_reach', row) + obj_id = self.insert_check("vw_qgep_reach", row) row = { - 'clear_height': 200, - 'coefficient_of_friction': 20, - 'ws_identifier': '10', - 'ch_usage_current': 4516 + "clear_height": 200, + "coefficient_of_friction": 20, + "ws_identifier": "10", + "ch_usage_current": 4516, } - self.update_check('vw_qgep_reach', row, obj_id) + self.update_check("vw_qgep_reach", row, obj_id) def test_vw_qgep_wastewater_structure(self): row = { - 'identifier': '20', - 'ws_type': 'manhole', - 'situation_geometry': self.execute("ST_SetSRID(ST_GeomFromText('POINT(2600000 1200000)'), 2056)"), + "identifier": "20", + "ws_type": "manhole", + "situation_geometry": self.execute( + "ST_SetSRID(ST_GeomFromText('POINT(2600000 1200000)'), 2056)" + ), # 'co_material': 5355, - 'wn_backflow_level': decimal.Decimal('100.000') + "wn_backflow_level": decimal.Decimal("100.000"), } expected_row = copy.deepcopy(row) - expected_row['situation_geometry'] = self.execute("ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056)") - - obj_id = self.insert_check('vw_qgep_wastewater_structure', row, expected_row) + expected_row["situation_geometry"] = self.execute( + "ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056)" + ) + + obj_id = self.insert_check("vw_qgep_wastewater_structure", row, expected_row) row = { - 'identifier': '10', - 'ws_type': 'special_structure', - 'co_material': 233, - 'ss_upper_elevation': decimal.Decimal('405.000'), + "identifier": "10", + "ws_type": "special_structure", + "co_material": 233, + "ss_upper_elevation": decimal.Decimal("405.000"), } - self.update_check('vw_qgep_wastewater_structure', row, obj_id) + self.update_check("vw_qgep_wastewater_structure", row, obj_id) cur = self.cursor() - cur.execute("SELECT * FROM qgep_od.wastewater_networkelement NE LEFT JOIN qgep_od.wastewater_node NO ON NO.obj_id = NE.obj_id WHERE fk_wastewater_structure='{obj_id}' ".format(obj_id=obj_id)) + cur.execute( + "SELECT * FROM qgep_od.wastewater_networkelement NE LEFT JOIN qgep_od.wastewater_node NO ON NO.obj_id = NE.obj_id WHERE fk_wastewater_structure='{obj_id}' ".format( + obj_id=obj_id + ) + ) row = cur.fetchone() - assert row['backflow_level'] == decimal.Decimal('100.000') + assert row["backflow_level"] == decimal.Decimal("100.000") + -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() diff --git a/test/utils.py b/test/utils.py index 770c50c8c..a43c8ca18 100644 --- a/test/utils.py +++ b/test/utils.py @@ -1,5 +1,3 @@ -import unittest - import psycopg2 import psycopg2.extras @@ -8,48 +6,61 @@ class DbTestBase: def assert_count(self, table, schema, expected): cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor) - cur.execute("SELECT COUNT(*) FROM {schema}.{table}".format(table=table, schema=schema)) + cur.execute(f"SELECT COUNT(*) FROM {schema}.{table}") count = cur.fetchone()[0] - assert count == expected, "Relation {}.{} : expected {} rows, got {} rows".format(schema, table, expected, count) + assert count == expected, "Relation {}.{} : expected {} rows, got {} rows".format( + schema, table, expected, count + ) - def select(self, table, obj_id, schema='qgep_od'): + def select(self, table, obj_id, schema="qgep_od"): cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor) - cur.execute("SELECT * FROM {schema}.{table} WHERE obj_id=%(obj_id)s" - .format(table=table, schema=schema), - {'obj_id': obj_id}) + cur.execute( + "SELECT * FROM {schema}.{table} WHERE obj_id=%(obj_id)s".format( + table=table, schema=schema + ), + {"obj_id": obj_id}, + ) return cur.fetchone() def execute(self, sql: str, params=[]): cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor) - cur.execute("SELECT {}".format(sql), params) + cur.execute(f"SELECT {sql}", params) return cur.fetchone()[0] def cursor(self): return self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor) - def insert(self, table, row, schema='qgep_od'): + def insert(self, table, row, schema="qgep_od"): cur = self.conn.cursor() - cols = ', '.join(row.keys()) - values = ', '.join(["%({key})s".format(key=key) for key in row.keys()]) - cur.execute("INSERT INTO {schema}.{table} ({cols}) VALUES ({values}) RETURNING obj_id" - .format(table=table, schema=schema, cols=cols, values=values), - row) + cols = ", ".join(row.keys()) + values = ", ".join([f"%({key})s" for key in row.keys()]) + cur.execute( + "INSERT INTO {schema}.{table} ({cols}) VALUES ({values}) RETURNING obj_id".format( + table=table, schema=schema, cols=cols, values=values + ), + row, + ) return cur.fetchone()[0] - def update(self, table, row, obj_id, schema='qgep_od'): + def update(self, table, row, obj_id, schema="qgep_od"): cur = self.conn.cursor() - cols = ','.join(['{key}=%({key})s'.format(key=key) for key in row.keys()]) - row['obj_id'] = obj_id - cur.execute("UPDATE {schema}.{table} SET {cols} WHERE obj_id=%(obj_id)s" - .format(table=table, schema=schema, cols=cols), - row) - - def delete(self, table, obj_id, schema='qgep_od'): + cols = ",".join(["{key}=%({key})s".format(key=key) for key in row.keys()]) + row["obj_id"] = obj_id + cur.execute( + "UPDATE {schema}.{table} SET {cols} WHERE obj_id=%(obj_id)s".format( + table=table, schema=schema, cols=cols + ), + row, + ) + + def delete(self, table, obj_id, schema="qgep_od"): cur = self.conn.cursor() - cur.execute("DELETE FROM {schema}.{table} WHERE obj_id=%s" - .format(table=table, schema=schema), [obj_id]) + cur.execute( + f"DELETE FROM {schema}.{table} WHERE obj_id=%s", + [obj_id], + ) - def insert_check(self, table, row, expected_row=None, schema='qgep_od'): + def insert_check(self, table, row, expected_row=None, schema="qgep_od"): obj_id = self.insert(table, row, schema) result = self.select(table, obj_id, schema) @@ -58,22 +69,25 @@ def insert_check(self, table, row, expected_row=None, schema='qgep_od'): if expected_row: row = expected_row - self.check_result(row, result, table, 'insert', schema) + self.check_result(row, result, table, "insert", schema) return obj_id - def update_check(self, table, row, obj_id, schema='qgep_od'): + def update_check(self, table, row, obj_id, schema="qgep_od"): self.update(table, row, obj_id, schema) result = self.select(table, obj_id, schema) - self.check_result(row, result, table, 'update', schema) + self.check_result(row, result, table, "update", schema) - def check_result(self, expected, result, table, test_name, schema='qgep_od'): + def check_result(self, expected, result, table, test_name, schema="qgep_od"): # TODO: don't convert to unicode, type inference for smallint is # currently broken, that's the reason at the moment. self.assertTrue(result, "No result set received.") for key, value in expected.items(): - self.assertEqual(str(result[key]), str(value), """ + self.assertEqual( + str(result[key]), + str(value), + """ ======================================================== Data: {expected} @@ -89,37 +103,44 @@ def check_result(self, expected, result, table, test_name, schema='qgep_od'): ======================================================== """.format( - expected = repr(expected), - test_name = test_name, - table = table, - schema = schema, - key = key, - expected_value = value, - result_value = result[key], - expected_type = type(value), - result_type = type(result[key]) - )) + expected=repr(expected), + test_name=test_name, + table=table, + schema=schema, + key=key, + expected_value=value, + result_value=result[key], + expected_type=type(value), + result_type=type(result[key]), + ), + ) def make_line(self, x1, y1, z1, x2, y2, z2, srid=2056): """ Helper to make 3D line geometries """ - return self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(%s, %s, %s), ST_MakePoint(%s, %s, %s)), %s))', [x1, y1, z1, x2, y2, z2, srid]) + return self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(%s, %s, %s), ST_MakePoint(%s, %s, %s)), %s))", + [x1, y1, z1, x2, y2, z2, srid], + ) def make_line_2d(self, x1, y1, x2, y2, srid=2056): """ Helper to make 2D line geometries """ - return self.execute('ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(%s, %s), ST_MakePoint(%s, %s)), %s))', [x1, y1, x2, y2, srid]) + return self.execute( + "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ST_MakePoint(%s, %s), ST_MakePoint(%s, %s)), %s))", + [x1, y1, x2, y2, srid], + ) def make_point(self, x, y, z, srid=2056): """ Helper to make 3D point geometries """ - return self.execute('ST_SetSrid(ST_MakePoint(%s, %s, %s), %s)', [x, y, z, srid]) + return self.execute("ST_SetSrid(ST_MakePoint(%s, %s, %s), %s)", [x, y, z, srid]) def make_point_2d(self, x, y, z=None, srid=2056): """ Helper to make 2D point geometries """ - return self.execute('ST_SetSrid(ST_MakePoint(%s, %s), %s)', [x, y, srid]) + return self.execute("ST_SetSrid(ST_MakePoint(%s, %s), %s)", [x, y, srid]) diff --git a/test_data/data_fixes.sql b/test_data/data_fixes.sql index 8535f423d..2d3dc8682 100644 --- a/test_data/data_fixes.sql +++ b/test_data/data_fixes.sql @@ -2,4 +2,4 @@ delete from qgep_od.reach_point where situation_geometry is null; delete from qgep_od.wastewater_node where situation_geometry is null; -delete from qgep_od.cover where situation_geometry is null; \ No newline at end of file +delete from qgep_od.cover where situation_geometry is null; diff --git a/view/additional_views/vw_blocking_debris.sql b/view/additional_views/vw_blocking_debris.sql index 6565ae303..ba2508ffa 100644 --- a/view/additional_views/vw_blocking_debris.sql +++ b/view/additional_views/vw_blocking_debris.sql @@ -101,4 +101,3 @@ CREATE OR REPLACE RULE vw_blocking_debris_ON_DELETE AS ON DELETE TO qgep_od.vw_b DELETE FROM qgep_od.blocking_debris WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.water_control_structure WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_building.sql b/view/additional_views/vw_building.sql index 8d694b4f8..d6c4a596c 100644 --- a/view/additional_views/vw_building.sql +++ b/view/additional_views/vw_building.sql @@ -121,4 +121,3 @@ CREATE OR REPLACE RULE vw_building_ON_DELETE AS ON DELETE TO qgep_od.vw_building DELETE FROM qgep_od.building WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.connection_object WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_chute.sql b/view/additional_views/vw_chute.sql index 4eff05b93..f76cb8557 100644 --- a/view/additional_views/vw_chute.sql +++ b/view/additional_views/vw_chute.sql @@ -109,4 +109,3 @@ CREATE OR REPLACE RULE vw_chute_ON_DELETE AS ON DELETE TO qgep_od.vw_chute DO IN DELETE FROM qgep_od.chute WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.water_control_structure WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_cooperative.sql b/view/additional_views/vw_cooperative.sql index 9059f15f1..25b48dc01 100644 --- a/view/additional_views/vw_cooperative.sql +++ b/view/additional_views/vw_cooperative.sql @@ -95,4 +95,3 @@ CREATE OR REPLACE RULE vw_cooperative_ON_DELETE AS ON DELETE TO qgep_od.vw_coope DELETE FROM qgep_od.cooperative WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.organisation WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_dam.sql b/view/additional_views/vw_dam.sql index feb8c2f01..262a82850 100644 --- a/view/additional_views/vw_dam.sql +++ b/view/additional_views/vw_dam.sql @@ -105,4 +105,3 @@ CREATE OR REPLACE RULE vw_dam_ON_DELETE AS ON DELETE TO qgep_od.vw_dam DO INSTEA DELETE FROM qgep_od.dam WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.water_control_structure WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_drainage_system.sql b/view/additional_views/vw_drainage_system.sql index b1ba0843d..809514248 100644 --- a/view/additional_views/vw_drainage_system.sql +++ b/view/additional_views/vw_drainage_system.sql @@ -97,4 +97,3 @@ CREATE OR REPLACE RULE vw_drainage_system_ON_DELETE AS ON DELETE TO qgep_od.vw_d DELETE FROM qgep_od.drainage_system WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.zone WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_electric_equipment.sql b/view/additional_views/vw_electric_equipment.sql index 2a10cc4ae..19ebcf985 100644 --- a/view/additional_views/vw_electric_equipment.sql +++ b/view/additional_views/vw_electric_equipment.sql @@ -109,4 +109,3 @@ CREATE OR REPLACE RULE vw_electric_equipment_ON_DELETE AS ON DELETE TO qgep_od.v DELETE FROM qgep_od.electric_equipment WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.structure_part WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_electromechanical_equipment.sql b/view/additional_views/vw_electromechanical_equipment.sql index ab030ebd4..282ae68db 100644 --- a/view/additional_views/vw_electromechanical_equipment.sql +++ b/view/additional_views/vw_electromechanical_equipment.sql @@ -109,4 +109,3 @@ CREATE OR REPLACE RULE vw_electromechanical_equipment_ON_DELETE AS ON DELETE TO DELETE FROM qgep_od.electromechanical_equipment WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.structure_part WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_ford.sql b/view/additional_views/vw_ford.sql index 8e400ecfe..0aff74e5f 100644 --- a/view/additional_views/vw_ford.sql +++ b/view/additional_views/vw_ford.sql @@ -99,4 +99,3 @@ CREATE OR REPLACE RULE vw_ford_ON_DELETE AS ON DELETE TO qgep_od.vw_ford DO INST DELETE FROM qgep_od.ford WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.water_control_structure WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_fountain.sql b/view/additional_views/vw_fountain.sql index 63f93e1d1..226c7bb28 100644 --- a/view/additional_views/vw_fountain.sql +++ b/view/additional_views/vw_fountain.sql @@ -113,4 +113,3 @@ CREATE OR REPLACE RULE vw_fountain_ON_DELETE AS ON DELETE TO qgep_od.vw_fountain DELETE FROM qgep_od.fountain WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.connection_object WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_ground_water_protection_perimeter.sql b/view/additional_views/vw_ground_water_protection_perimeter.sql index e404fda55..1df01f00b 100644 --- a/view/additional_views/vw_ground_water_protection_perimeter.sql +++ b/view/additional_views/vw_ground_water_protection_perimeter.sql @@ -93,4 +93,3 @@ CREATE OR REPLACE RULE vw_ground_water_protection_perimeter_ON_DELETE AS ON DELE DELETE FROM qgep_od.ground_water_protection_perimeter WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.zone WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_groundwater_protection_zone.sql b/view/additional_views/vw_groundwater_protection_zone.sql index 07dc21eea..d84117edc 100644 --- a/view/additional_views/vw_groundwater_protection_zone.sql +++ b/view/additional_views/vw_groundwater_protection_zone.sql @@ -97,4 +97,3 @@ CREATE OR REPLACE RULE vw_groundwater_protection_zone_ON_DELETE AS ON DELETE TO DELETE FROM qgep_od.groundwater_protection_zone WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.zone WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_infiltration_installation.sql b/view/additional_views/vw_infiltration_installation.sql index 7dc74fa17..367c66e01 100644 --- a/view/additional_views/vw_infiltration_installation.sql +++ b/view/additional_views/vw_infiltration_installation.sql @@ -216,4 +216,3 @@ CREATE OR REPLACE RULE vw_infiltration_installation_ON_DELETE AS ON DELETE TO qg DELETE FROM qgep_od.infiltration_installation WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.wastewater_structure WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_infiltration_zone.sql b/view/additional_views/vw_infiltration_zone.sql index d5e494c65..0c76ba454 100644 --- a/view/additional_views/vw_infiltration_zone.sql +++ b/view/additional_views/vw_infiltration_zone.sql @@ -97,4 +97,3 @@ CREATE OR REPLACE RULE vw_infiltration_zone_ON_DELETE AS ON DELETE TO qgep_od.vw DELETE FROM qgep_od.infiltration_zone WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.zone WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_lake.sql b/view/additional_views/vw_lake.sql index 50899bd03..ffeba0ebe 100644 --- a/view/additional_views/vw_lake.sql +++ b/view/additional_views/vw_lake.sql @@ -93,4 +93,3 @@ CREATE OR REPLACE RULE vw_lake_ON_DELETE AS ON DELETE TO qgep_od.vw_lake DO INST DELETE FROM qgep_od.lake WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.surface_water_bodies WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_lock.sql b/view/additional_views/vw_lock.sql index 90525244d..747db40aa 100644 --- a/view/additional_views/vw_lock.sql +++ b/view/additional_views/vw_lock.sql @@ -101,4 +101,3 @@ CREATE OR REPLACE RULE vw_lock_ON_DELETE AS ON DELETE TO qgep_od.vw_lock DO INST DELETE FROM qgep_od.lock WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.water_control_structure WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_param_ca_general.sql b/view/additional_views/vw_param_ca_general.sql index adbcc6bf6..b3c30d26e 100644 --- a/view/additional_views/vw_param_ca_general.sql +++ b/view/additional_views/vw_param_ca_general.sql @@ -129,4 +129,3 @@ CREATE OR REPLACE RULE vw_param_ca_general_ON_DELETE AS ON DELETE TO qgep_od.vw_ DELETE FROM qgep_od.param_ca_general WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.surface_runoff_parameters WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_param_ca_mouse1.sql b/view/additional_views/vw_param_ca_mouse1.sql index c4a3a76b2..44b6ec982 100644 --- a/view/additional_views/vw_param_ca_mouse1.sql +++ b/view/additional_views/vw_param_ca_mouse1.sql @@ -133,4 +133,3 @@ CREATE OR REPLACE RULE vw_param_ca_mouse1_ON_DELETE AS ON DELETE TO qgep_od.vw_p DELETE FROM qgep_od.param_ca_mouse1 WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.surface_runoff_parameters WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_passage.sql b/view/additional_views/vw_passage.sql index 245e1f37e..69606e88d 100644 --- a/view/additional_views/vw_passage.sql +++ b/view/additional_views/vw_passage.sql @@ -99,4 +99,3 @@ CREATE OR REPLACE RULE vw_passage_ON_DELETE AS ON DELETE TO qgep_od.vw_passage D DELETE FROM qgep_od.passage WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.water_control_structure WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_planning_zone.sql b/view/additional_views/vw_planning_zone.sql index 895e57e53..6a3e8729b 100644 --- a/view/additional_views/vw_planning_zone.sql +++ b/view/additional_views/vw_planning_zone.sql @@ -97,4 +97,3 @@ CREATE OR REPLACE RULE vw_planning_zone_ON_DELETE AS ON DELETE TO qgep_od.vw_pla DELETE FROM qgep_od.planning_zone WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.zone WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_qgep_catchment_area.sql b/view/additional_views/vw_qgep_catchment_area.sql index 120221d13..835043f84 100644 --- a/view/additional_views/vw_qgep_catchment_area.sql +++ b/view/additional_views/vw_qgep_catchment_area.sql @@ -209,4 +209,3 @@ CREATE OR REPLACE RULE vw_qgep_catchment_area_ON_DELETE AS ON DELETE TO qgep_od. INSTEAD ( DELETE FROM qgep_od.catchment_area WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_qgep_maintenance_on_reach.sql b/view/additional_views/vw_qgep_maintenance_on_reach.sql index 98e8d36a2..4b15c3cbe 100644 --- a/view/additional_views/vw_qgep_maintenance_on_reach.sql +++ b/view/additional_views/vw_qgep_maintenance_on_reach.sql @@ -2,7 +2,7 @@ -- DROP VIEW qgep_od.vw_qgep_maintenance_on_reach; -CREATE OR REPLACE VIEW qgep_od.vw_qgep_maintenance_on_reach AS +CREATE OR REPLACE VIEW qgep_od.vw_qgep_maintenance_on_reach AS SELECT re_m_w.obj_id AS re_m_w_id, maintenance.obj_id, maintenance.identifier, diff --git a/view/additional_views/vw_qgep_maintenance_on_wws.sql b/view/additional_views/vw_qgep_maintenance_on_wws.sql index 3a11c1a71..3e27fb5db 100644 --- a/view/additional_views/vw_qgep_maintenance_on_wws.sql +++ b/view/additional_views/vw_qgep_maintenance_on_wws.sql @@ -2,7 +2,7 @@ -- DROP VIEW qgep_od.vw_qgep_maintenance_on_wws; -CREATE OR REPLACE VIEW qgep_od.vw_qgep_maintenance_on_wws AS +CREATE OR REPLACE VIEW qgep_od.vw_qgep_maintenance_on_wws AS SELECT re_m_w.obj_id AS re_m_w_id, maintenance.obj_id, maintenance.identifier, @@ -29,7 +29,7 @@ CREATE OR REPLACE VIEW qgep_od.vw_qgep_maintenance_on_wws AS LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.fk_wastewater_structure::text = ws.obj_id::text LEFT JOIN qgep_od.wastewater_node node ON node.obj_id::text = ne.obj_id::text WHERE node.obj_id is not null; - + ALTER TABLE qgep_od.vw_qgep_maintenance_on_wws OWNER TO postgres; diff --git a/view/additional_views/vw_reach_relining.sql b/view/additional_views/vw_reach_relining.sql index 4a010243f..452f11b80 100644 --- a/view/additional_views/vw_reach_relining.sql +++ b/view/additional_views/vw_reach_relining.sql @@ -2,7 +2,7 @@ -- DROP VIEW qgep_od.vw_reach_relining; -CREATE OR REPLACE VIEW qgep_od.vw_reach_relining AS +CREATE OR REPLACE VIEW qgep_od.vw_reach_relining AS SELECT re.obj_id, re.clear_height, re.inside_coating, @@ -27,4 +27,3 @@ ALTER TABLE qgep_od.vw_reach_relining OWNER TO postgres; GRANT ALL ON TABLE qgep_od.vw_reach_relining TO postgres; GRANT ALL ON TABLE qgep_od.vw_reach_relining TO qgep; - diff --git a/view/additional_views/vw_reservoir.sql b/view/additional_views/vw_reservoir.sql index 88c8198e9..48d610456 100644 --- a/view/additional_views/vw_reservoir.sql +++ b/view/additional_views/vw_reservoir.sql @@ -113,4 +113,3 @@ CREATE OR REPLACE RULE vw_reservoir_ON_DELETE AS ON DELETE TO qgep_od.vw_reservo DELETE FROM qgep_od.reservoir WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.connection_object WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_river.sql b/view/additional_views/vw_river.sql index 056d8f230..0646fd6d9 100644 --- a/view/additional_views/vw_river.sql +++ b/view/additional_views/vw_river.sql @@ -93,4 +93,3 @@ CREATE OR REPLACE RULE vw_river_ON_DELETE AS ON DELETE TO qgep_od.vw_river DO IN DELETE FROM qgep_od.river WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.surface_water_bodies WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_rock_ramp.sql b/view/additional_views/vw_rock_ramp.sql index 04639469e..435bb9838 100644 --- a/view/additional_views/vw_rock_ramp.sql +++ b/view/additional_views/vw_rock_ramp.sql @@ -105,4 +105,3 @@ CREATE OR REPLACE RULE vw_rock_ramp_ON_DELETE AS ON DELETE TO qgep_od.vw_rock_ra DELETE FROM qgep_od.rock_ramp WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.water_control_structure WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_solids_retention.sql b/view/additional_views/vw_solids_retention.sql index 665a138f2..8ca5bd781 100644 --- a/view/additional_views/vw_solids_retention.sql +++ b/view/additional_views/vw_solids_retention.sql @@ -117,4 +117,3 @@ CREATE OR REPLACE RULE vw_solids_retention_ON_DELETE AS ON DELETE TO qgep_od.vw_ DELETE FROM qgep_od.solids_retention WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.structure_part WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_tank_cleaning.sql b/view/additional_views/vw_tank_cleaning.sql index 66e242f06..4fa53fde1 100644 --- a/view/additional_views/vw_tank_cleaning.sql +++ b/view/additional_views/vw_tank_cleaning.sql @@ -109,4 +109,3 @@ CREATE OR REPLACE RULE vw_tank_cleaning_ON_DELETE AS ON DELETE TO qgep_od.vw_tan DELETE FROM qgep_od.tank_cleaning WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.structure_part WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_tank_emptying.sql b/view/additional_views/vw_tank_emptying.sql index b71854371..cbbb2a925 100644 --- a/view/additional_views/vw_tank_emptying.sql +++ b/view/additional_views/vw_tank_emptying.sql @@ -113,4 +113,3 @@ CREATE OR REPLACE RULE vw_tank_emptying_ON_DELETE AS ON DELETE TO qgep_od.vw_tan DELETE FROM qgep_od.tank_emptying WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.structure_part WHERE obj_id = OLD.obj_id; ); - diff --git a/view/additional_views/vw_wizard_reach_channel.sql b/view/additional_views/vw_wizard_reach_channel.sql index 0736f7410..164ffa883 100644 --- a/view/additional_views/vw_wizard_reach_channel.sql +++ b/view/additional_views/vw_wizard_reach_channel.sql @@ -2,8 +2,8 @@ -- DROP VIEW vw_wizard_reach_channel; -CREATE OR REPLACE VIEW qgep_od.vw_wizard_reach_channel AS - SELECT +CREATE OR REPLACE VIEW qgep_od.vw_wizard_reach_channel AS + SELECT re.obj_id , bedding_encasement , connection_type @@ -75,7 +75,7 @@ CREATE OR REPLACE VIEW qgep_od.vw_wizard_reach_channel AS , rp_to_dataowner , rp_to_provider , rp_to_fk_wastewater_networkelement - + FROM qgep_od.vw_channel ch LEFT JOIN qgep_od.vw_reach re ON ch.obj_id = re.fk_wastewater_structure WHERE false; @@ -243,4 +243,3 @@ DROP TRIGGER IF EXISTS vw_wizard_reach_channel_ON_INSERT ON qgep_od.vw_wizard_re CREATE TRIGGER vw_wizard_reach_channel_ON_INSERT INSTEAD OF INSERT ON qgep_od.vw_wizard_reach_channel FOR EACH ROW EXECUTE PROCEDURE qgep_od.vw_wizard_reach_channel_INSERT(); - diff --git a/view/additional_views/vw_wwtp_structure.sql b/view/additional_views/vw_wwtp_structure.sql index 519eb6e48..99271f700 100644 --- a/view/additional_views/vw_wwtp_structure.sql +++ b/view/additional_views/vw_wwtp_structure.sql @@ -168,4 +168,3 @@ CREATE OR REPLACE RULE vw_wwtp_structure_ON_DELETE AS ON DELETE TO qgep_od.vw_ww DELETE FROM qgep_od.wwtp_structure WHERE obj_id = OLD.obj_id; DELETE FROM qgep_od.wastewater_structure WHERE obj_id = OLD.obj_id; ); - diff --git a/view/create_views.py b/view/create_views.py index 0f7c45c5f..cd38fcb7c 100755 --- a/view/create_views.py +++ b/view/create_views.py @@ -1,20 +1,22 @@ #!/usr/bin/env python3 -from yaml import safe_load -import psycopg2 import argparse -from pirogue import SingleInheritance, MultipleInheritance, SimpleJoins +import os +import sys + +import psycopg2 +from pirogue import MultipleInheritance, SimpleJoins, SingleInheritance +from yaml import safe_load -import sys, os sys.path.append(os.path.join(os.path.dirname(__file__))) -from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure from vw_qgep_reach import vw_qgep_reach +from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure def run_sql(file_path: str, pg_service: str, variables: dict = {}): sql = open(file_path).read() - conn = psycopg2.connect("service={0}".format(pg_service)) + conn = psycopg2.connect(f"service={pg_service}") cursor = conn.cursor() cursor.execute(sql, variables) conn.commit() @@ -22,21 +24,24 @@ def run_sql(file_path: str, pg_service: str, variables: dict = {}): def drop_views(pg_service): - run_sql('view/drop_views.sql', pg_service) + run_sql("view/drop_views.sql", pg_service) -def create_views(srid: int, - pg_service: str, - qgep_reach_extra: str = None, - qgep_wastewater_structure_extra: str = None): +def create_views( + srid: int, + pg_service: str, + qgep_reach_extra: str = None, + qgep_wastewater_structure_extra: str = None, +): """ Creates the views for QGEP :param srid: the EPSG code for geometry columns :param pg_service: the PostgreSQL service, if not given it will be determined from environment variable in Pirogue :param qgep_reach_extra: YAML file path of the definition of additional columns for vw_qgep_reach view - :param qgep_wastewater_structure_extra: YAML file path of the definition of additional columns for vw_qgep_wastewater_structure_extra view""" + :param qgep_wastewater_structure_extra: YAML file path of the definition of additional columns for vw_qgep_wastewater_structure_extra view + """ - variables = {'SRID': srid} + variables = {"SRID": srid} # open YAML files if qgep_reach_extra: @@ -46,97 +51,264 @@ def create_views(srid: int, drop_views(pg_service) - run_sql('view/vw_dictionary_value_list.sql', pg_service, variables) - - SingleInheritance('qgep_od.structure_part', 'qgep_od.access_aid', view_name='vw_access_aid', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.benching', view_name='vw_benching', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.backflow_prevention', view_name='vw_backflow_prevention', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.cover', view_name='vw_cover', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.dryweather_downspout', view_name='vw_dryweather_downspout', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.dryweather_flume', view_name='vw_dryweather_flume', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.solids_retention', view_name='vw_solids_retention', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.tank_cleaning', view_name='vw_tank_cleaning', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.tank_emptying', view_name='vw_tank_emptying', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.electric_equipment', view_name='vw_electric_equipment', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - SingleInheritance('qgep_od.structure_part', 'qgep_od.electromechanical_equipment', view_name='vw_electromechanical_equipment', pg_service=pg_service, pkey_default_value=True, inner_defaults={'identifier': 'obj_id'}).create() - - SingleInheritance('qgep_od.wastewater_structure', 'qgep_od.channel', view_name='vw_channel', pg_service=pg_service).create() - SingleInheritance('qgep_od.wastewater_structure', 'qgep_od.manhole', view_name='vw_manhole', pg_service=pg_service).create() - SingleInheritance('qgep_od.wastewater_structure', 'qgep_od.discharge_point', view_name='vw_discharge_point', pg_service=pg_service).create() - SingleInheritance('qgep_od.wastewater_structure', 'qgep_od.special_structure', view_name='vw_special_structure', pg_service=pg_service).create() - SingleInheritance('qgep_od.wastewater_structure', 'qgep_od.infiltration_installation', view_name='vw_infiltration_installation', pg_service=pg_service).create() - SingleInheritance('qgep_od.wastewater_structure', 'qgep_od.wwtp_structure', view_name='vw_wwtp_structure', pg_service=pg_service).create() - - SingleInheritance('qgep_od.wastewater_networkelement', 'qgep_od.reach', view_name='vw_reach', pg_service=pg_service).create() - SingleInheritance('qgep_od.wastewater_networkelement', 'qgep_od.wastewater_node', view_name='vw_wastewater_node', pkey_default_value=True, pg_service=pg_service).create() - - SingleInheritance('qgep_od.connection_object', 'qgep_od.individual_surface', view_name='vw_individual_surface', pkey_default_value=True, pg_service=pg_service).create() - SingleInheritance('qgep_od.connection_object', 'qgep_od.building', view_name='vw_building', pkey_default_value=True, pg_service=pg_service).create() - SingleInheritance('qgep_od.connection_object', 'qgep_od.reservoir', view_name='vw_reservoir', pkey_default_value=True, pg_service=pg_service).create() - SingleInheritance('qgep_od.connection_object', 'qgep_od.fountain', view_name='vw_fountain', pkey_default_value=True, pg_service=pg_service).create() - - MultipleInheritance(safe_load(open("view/vw_maintenance_examination.yaml")), drop=True, pg_service=pg_service).create() - MultipleInheritance(safe_load(open("view/vw_damage.yaml")), drop=True, pg_service=pg_service).create() - - vw_qgep_wastewater_structure(srid, pg_service=pg_service, extra_definition=qgep_wastewater_structure_extra) + run_sql("view/vw_dictionary_value_list.sql", pg_service, variables) + + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.access_aid", + view_name="vw_access_aid", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.benching", + view_name="vw_benching", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.backflow_prevention", + view_name="vw_backflow_prevention", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.cover", + view_name="vw_cover", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.dryweather_downspout", + view_name="vw_dryweather_downspout", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.dryweather_flume", + view_name="vw_dryweather_flume", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.solids_retention", + view_name="vw_solids_retention", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.tank_cleaning", + view_name="vw_tank_cleaning", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.tank_emptying", + view_name="vw_tank_emptying", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.electric_equipment", + view_name="vw_electric_equipment", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + SingleInheritance( + "qgep_od.structure_part", + "qgep_od.electromechanical_equipment", + view_name="vw_electromechanical_equipment", + pg_service=pg_service, + pkey_default_value=True, + inner_defaults={"identifier": "obj_id"}, + ).create() + + SingleInheritance( + "qgep_od.wastewater_structure", + "qgep_od.channel", + view_name="vw_channel", + pg_service=pg_service, + ).create() + SingleInheritance( + "qgep_od.wastewater_structure", + "qgep_od.manhole", + view_name="vw_manhole", + pg_service=pg_service, + ).create() + SingleInheritance( + "qgep_od.wastewater_structure", + "qgep_od.discharge_point", + view_name="vw_discharge_point", + pg_service=pg_service, + ).create() + SingleInheritance( + "qgep_od.wastewater_structure", + "qgep_od.special_structure", + view_name="vw_special_structure", + pg_service=pg_service, + ).create() + SingleInheritance( + "qgep_od.wastewater_structure", + "qgep_od.infiltration_installation", + view_name="vw_infiltration_installation", + pg_service=pg_service, + ).create() + SingleInheritance( + "qgep_od.wastewater_structure", + "qgep_od.wwtp_structure", + view_name="vw_wwtp_structure", + pg_service=pg_service, + ).create() + + SingleInheritance( + "qgep_od.wastewater_networkelement", + "qgep_od.reach", + view_name="vw_reach", + pg_service=pg_service, + ).create() + SingleInheritance( + "qgep_od.wastewater_networkelement", + "qgep_od.wastewater_node", + view_name="vw_wastewater_node", + pkey_default_value=True, + pg_service=pg_service, + ).create() + + SingleInheritance( + "qgep_od.connection_object", + "qgep_od.individual_surface", + view_name="vw_individual_surface", + pkey_default_value=True, + pg_service=pg_service, + ).create() + SingleInheritance( + "qgep_od.connection_object", + "qgep_od.building", + view_name="vw_building", + pkey_default_value=True, + pg_service=pg_service, + ).create() + SingleInheritance( + "qgep_od.connection_object", + "qgep_od.reservoir", + view_name="vw_reservoir", + pkey_default_value=True, + pg_service=pg_service, + ).create() + SingleInheritance( + "qgep_od.connection_object", + "qgep_od.fountain", + view_name="vw_fountain", + pkey_default_value=True, + pg_service=pg_service, + ).create() + + MultipleInheritance( + safe_load(open("view/vw_maintenance_examination.yaml")), drop=True, pg_service=pg_service + ).create() + MultipleInheritance( + safe_load(open("view/vw_damage.yaml")), drop=True, pg_service=pg_service + ).create() + + vw_qgep_wastewater_structure( + srid, pg_service=pg_service, extra_definition=qgep_wastewater_structure_extra + ) vw_qgep_reach(pg_service=pg_service, extra_definition=qgep_reach_extra) - run_sql('view/vw_file.sql', pg_service, variables) + run_sql("view/vw_file.sql", pg_service, variables) - MultipleInheritance(safe_load(open("view/vw_oo_overflow.yaml")), create_joins=True, variables=variables, pg_service=pg_service, drop=True).create() - MultipleInheritance(safe_load(open("view/vw_oo_organisation.yaml")), drop=True, pg_service=pg_service).create() + MultipleInheritance( + safe_load(open("view/vw_oo_overflow.yaml")), + create_joins=True, + variables=variables, + pg_service=pg_service, + drop=True, + ).create() + MultipleInheritance( + safe_load(open("view/vw_oo_organisation.yaml")), drop=True, pg_service=pg_service + ).create() - run_sql('view/vw_catchment_area_connections.sql', pg_service, variables) - run_sql('view/vw_change_points.sql', pg_service, variables) - run_sql('view/vw_qgep_import.sql', pg_service, variables) + run_sql("view/vw_catchment_area_connections.sql", pg_service, variables) + run_sql("view/vw_change_points.sql", pg_service, variables) + run_sql("view/vw_qgep_import.sql", pg_service, variables) # Recreate network views - run_sql('view/network/vw_network_node.sql', pg_service, variables) - run_sql('view/network/vw_network_segment.sql', pg_service, variables) + run_sql("view/network/vw_network_node.sql", pg_service, variables) + run_sql("view/network/vw_network_segment.sql", pg_service, variables) # Recreate swmm views - run_sql('swmm_views/01_vw_swmm_create_schema.sql', pg_service, variables) - run_sql('swmm_views/02_vw_swmm_junctions.sql', pg_service, variables) - run_sql('swmm_views/03_vw_swmm_aquifers.sql', pg_service, variables) - run_sql('swmm_views/04_vw_swmm_conduits.sql', pg_service, variables) - run_sql('swmm_views/05_vw_swmm_dividers.sql', pg_service, variables) - run_sql('swmm_views/06_vw_swmm_landuses.sql', pg_service, variables) - run_sql('swmm_views/07_vw_swmm_losses.sql', pg_service, variables) - run_sql('swmm_views/08_vw_swmm_outfalls.sql', pg_service, variables) - run_sql('swmm_views/09_vw_swmm_subcatchments.sql', pg_service, variables) - run_sql('swmm_views/10_vw_swmm_subareas.sql', pg_service, variables) - run_sql('swmm_views/11_vw_swmm_dwf.sql', pg_service, variables) - run_sql('swmm_views/12_vw_swmm_raingages.sql', pg_service, variables) - run_sql('swmm_views/13_vw_swmm_infiltrations.sql', pg_service, variables) - run_sql('swmm_views/14_vw_swmm_coverages.sql', pg_service, variables) - run_sql('swmm_views/15_vw_swmm_vertices.sql', pg_service, variables) - run_sql('swmm_views/16_vw_swmm_pumps.sql', pg_service, variables) - run_sql('swmm_views/17_vw_swmm_polygons.sql', pg_service, variables) - run_sql('swmm_views/18_vw_swmm_storages.sql', pg_service, variables) - run_sql('swmm_views/19_vw_swmm_outlets.sql', pg_service, variables) - run_sql('swmm_views/20_vw_swmm_orifices.sql', pg_service, variables) - run_sql('swmm_views/21_vw_swmm_weirs.sql', pg_service, variables) - run_sql('swmm_views/22_vw_swmm_curves.sql', pg_service, variables) - run_sql('swmm_views/23_vw_swmm_xsections.sql', pg_service, variables) - run_sql('swmm_views/24_vw_swmm_coordinates.sql', pg_service, variables) - run_sql('swmm_views/25_vw_swmm_tags.sql', pg_service, variables) - run_sql('swmm_views/26_vw_swmm_symbols.sql', pg_service, variables) - run_sql('swmm_views/27_vw_swmm_results.sql', pg_service, variables) - - SimpleJoins(safe_load(open('view/export/vw_export_reach.yaml')), pg_service).create() - SimpleJoins(safe_load(open('view/export/vw_export_wastewater_structure.yaml')), pg_service).create() + run_sql("swmm_views/01_vw_swmm_create_schema.sql", pg_service, variables) + run_sql("swmm_views/02_vw_swmm_junctions.sql", pg_service, variables) + run_sql("swmm_views/03_vw_swmm_aquifers.sql", pg_service, variables) + run_sql("swmm_views/04_vw_swmm_conduits.sql", pg_service, variables) + run_sql("swmm_views/05_vw_swmm_dividers.sql", pg_service, variables) + run_sql("swmm_views/06_vw_swmm_landuses.sql", pg_service, variables) + run_sql("swmm_views/07_vw_swmm_losses.sql", pg_service, variables) + run_sql("swmm_views/08_vw_swmm_outfalls.sql", pg_service, variables) + run_sql("swmm_views/09_vw_swmm_subcatchments.sql", pg_service, variables) + run_sql("swmm_views/10_vw_swmm_subareas.sql", pg_service, variables) + run_sql("swmm_views/11_vw_swmm_dwf.sql", pg_service, variables) + run_sql("swmm_views/12_vw_swmm_raingages.sql", pg_service, variables) + run_sql("swmm_views/13_vw_swmm_infiltrations.sql", pg_service, variables) + run_sql("swmm_views/14_vw_swmm_coverages.sql", pg_service, variables) + run_sql("swmm_views/15_vw_swmm_vertices.sql", pg_service, variables) + run_sql("swmm_views/16_vw_swmm_pumps.sql", pg_service, variables) + run_sql("swmm_views/17_vw_swmm_polygons.sql", pg_service, variables) + run_sql("swmm_views/18_vw_swmm_storages.sql", pg_service, variables) + run_sql("swmm_views/19_vw_swmm_outlets.sql", pg_service, variables) + run_sql("swmm_views/20_vw_swmm_orifices.sql", pg_service, variables) + run_sql("swmm_views/21_vw_swmm_weirs.sql", pg_service, variables) + run_sql("swmm_views/22_vw_swmm_curves.sql", pg_service, variables) + run_sql("swmm_views/23_vw_swmm_xsections.sql", pg_service, variables) + run_sql("swmm_views/24_vw_swmm_coordinates.sql", pg_service, variables) + run_sql("swmm_views/25_vw_swmm_tags.sql", pg_service, variables) + run_sql("swmm_views/26_vw_swmm_symbols.sql", pg_service, variables) + run_sql("swmm_views/27_vw_swmm_results.sql", pg_service, variables) + + SimpleJoins(safe_load(open("view/export/vw_export_reach.yaml")), pg_service).create() + SimpleJoins( + safe_load(open("view/export/vw_export_wastewater_structure.yaml")), pg_service + ).create() if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument('-p', '--pg_service', help='postgres service') - parser.add_argument('-s', '--srid', help='SRID EPSG code, defaults to 2056', type=int, default=2056) - parser.add_argument('--qgep_wastewater_structure_extra', help='YAML definition file path for additions to vw_qgep_wastewater_structure view') - parser.add_argument('--qgep_reach_extra', help='YAML definition file path for additions to vw_qgep_reach view') + parser.add_argument("-p", "--pg_service", help="postgres service") + parser.add_argument( + "-s", "--srid", help="SRID EPSG code, defaults to 2056", type=int, default=2056 + ) + parser.add_argument( + "--qgep_wastewater_structure_extra", + help="YAML definition file path for additions to vw_qgep_wastewater_structure view", + ) + parser.add_argument( + "--qgep_reach_extra", help="YAML definition file path for additions to vw_qgep_reach view" + ) args = parser.parse_args() - create_views(args.srid, args.pg_service, - qgep_reach_extra=args.qgep_reach_extra, - qgep_wastewater_structure_extra=args.qgep_wastewater_structure_extra) - + create_views( + args.srid, + args.pg_service, + qgep_reach_extra=args.qgep_reach_extra, + qgep_wastewater_structure_extra=args.qgep_wastewater_structure_extra, + ) diff --git a/view/export/vw_export_reach.yaml b/view/export/vw_export_reach.yaml index 9f73516ad..ac9fb126e 100755 --- a/view/export/vw_export_reach.yaml +++ b/view/export/vw_export_reach.yaml @@ -92,4 +92,3 @@ joins: table: qgep_od.organisation fkey: ws_fk_operator prefix: operator_ - diff --git a/view/export/vw_export_wastewater_structure.yaml b/view/export/vw_export_wastewater_structure.yaml index 4d03673b3..98924a89e 100755 --- a/view/export/vw_export_wastewater_structure.yaml +++ b/view/export/vw_export_wastewater_structure.yaml @@ -90,4 +90,3 @@ joins: table: qgep_vl.discharge_point_relevance fkey: dp_relevance prefix: relevance_ - diff --git a/view/network/vw_network_node.sql b/view/network/vw_network_node.sql index d841351d3..d4e940777 100644 --- a/view/network/vw_network_node.sql +++ b/view/network/vw_network_node.sql @@ -47,4 +47,4 @@ LEFT JOIN cover_levels_per_network_element co ON n.ne_id = co.obj_id AND n.node_ LEFT JOIN qgep_od.wastewater_structure ws ON ws.obj_id = ne.fk_wastewater_structure LEFT JOIN qgep_od.manhole mh ON mh.obj_id = ws.obj_id; -CREATE INDEX in_qgep_od_vw_network_node_situation_geometry ON qgep_od.vw_network_node USING gist (situation_geometry); \ No newline at end of file +CREATE INDEX in_qgep_od_vw_network_node_situation_geometry ON qgep_od.vw_network_node USING gist (situation_geometry); diff --git a/view/network/vw_network_segment.sql b/view/network/vw_network_segment.sql index 7b3e6c707..f3e80f674 100644 --- a/view/network/vw_network_segment.sql +++ b/view/network/vw_network_segment.sql @@ -4,7 +4,7 @@ CREATE MATERIALIZED VIEW qgep_od.vw_network_segment AS SELECT s.id as gid, COALESCE( - s.ne_id, + s.ne_id, CASE WHEN n1.type = 'wastewater_node' THEN n1.obj_id WHEN n2.type = 'wastewater_node' THEN n2.obj_id @@ -38,4 +38,4 @@ LEFT JOIN qgep_vl.reach_material mat ON r.material = mat.code LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.obj_id = s.ne_id LEFT JOIN qgep_od.channel ch ON ch.obj_id = ne.fk_wastewater_structure; -CREATE INDEX in_qgep_od_vw_network_segment_progression_geometry ON qgep_od.vw_network_segment USING gist (progression_geometry); \ No newline at end of file +CREATE INDEX in_qgep_od_vw_network_segment_progression_geometry ON qgep_od.vw_network_segment USING gist (progression_geometry); diff --git a/view/vw_catchment_area_additional.sql b/view/vw_catchment_area_additional.sql index b26f12802..272aeebeb 100644 --- a/view/vw_catchment_area_additional.sql +++ b/view/vw_catchment_area_additional.sql @@ -8,5 +8,5 @@ CREATE OR REPLACE VIEW qgep_od.vw_catchment_area_additional AS ca.fk_wastewater_networkelement_rw_planned::text = ca.fk_wastewater_networkelement_ww_planned::text AS planned_ww_is_rw, ca.fk_wastewater_networkelement_ww_planned::text = ca.fk_wastewater_networkelement_ww_current::text AS ww_planned_is_current, ca.fk_wastewater_networkelement_rw_planned::text = ca.fk_wastewater_networkelement_rw_current::text AS rw_planned_is_current - + FROM qgep_od.catchment_area ca; diff --git a/view/vw_catchment_area_rwc_connenctions.sql b/view/vw_catchment_area_rwc_connenctions.sql index 5b4877cb6..9633e49a1 100644 --- a/view/vw_catchment_area_rwc_connenctions.sql +++ b/view/vw_catchment_area_rwc_connenctions.sql @@ -2,7 +2,7 @@ -- DROP VIEW qgep_od.vw_catchment_area_rwc_connections; -CREATE OR REPLACE VIEW qgep_od.vw_catchment_area_rwc_connections AS +CREATE OR REPLACE VIEW qgep_od.vw_catchment_area_rwc_connections AS SELECT ca.obj_id, ST_Force2D(st_makeline(st_centroid(st_curvetoline(ca.perimeter_geometry)), wn_rw_current.situation_geometry))::geometry(LineString,2056) AS connection_rw_current_geometry, ST_Length(ST_Force2D(st_makeline(st_centroid(st_curvetoline(ca.perimeter_geometry)), wn_rw_current.situation_geometry))::geometry(LineString,2056)) AS Length_rw_current, diff --git a/view/vw_catchment_area_rwp_connections.sql b/view/vw_catchment_area_rwp_connections.sql index 3f4ed529b..6f9728064 100644 --- a/view/vw_catchment_area_rwp_connections.sql +++ b/view/vw_catchment_area_rwp_connections.sql @@ -2,7 +2,7 @@ -- DROP VIEW qgep_od.vw_catchment_area_rwp_connections; -CREATE OR REPLACE VIEW qgep_od.vw_catchment_area_rwp_connections AS +CREATE OR REPLACE VIEW qgep_od.vw_catchment_area_rwp_connections AS SELECT ca.obj_id, ST_Force2D(st_makeline(st_centroid(st_curvetoline(ca.perimeter_geometry)), wn_rw_planned.situation_geometry))::geometry(LineString,2056) AS connection_rw_planned_geometry, ST_Length(ST_Force2D(st_makeline(st_centroid(st_curvetoline(ca.perimeter_geometry)), wn_rw_planned.situation_geometry))::geometry(LineString,2056)) AS Length_rw_planned, diff --git a/view/vw_damage.yaml b/view/vw_damage.yaml index 14f84111a..a10e1955d 100755 --- a/view/vw_damage.yaml +++ b/view/vw_damage.yaml @@ -12,4 +12,3 @@ joins: manhole: table: qgep_od.damage_manhole - diff --git a/view/vw_file.sql b/view/vw_file.sql index 3d05b11f7..24bd6cda8 100644 --- a/view/vw_file.sql +++ b/view/vw_file.sql @@ -28,7 +28,7 @@ CREATE OR REPLACE VIEW qgep_od.vw_file AS f.remark FROM qgep_od.file f LEFT JOIN qgep_od.data_media dm ON dm.obj_id::text = f.fk_data_media::text; - + ALTER VIEW qgep_od.vw_file ALTER obj_id SET DEFAULT qgep_sys.generate_oid('qgep_od','file'); -- ****************************************************************************** diff --git a/view/vw_maintenance_examination.yaml b/view/vw_maintenance_examination.yaml index 6bd583fd4..d09e732fa 100755 --- a/view/vw_maintenance_examination.yaml +++ b/view/vw_maintenance_examination.yaml @@ -9,5 +9,3 @@ pkey_default_value: True joins: examination: table: qgep_od.examination - - diff --git a/view/vw_oo_organisation.yaml b/view/vw_oo_organisation.yaml index cb7e40994..5b8db538a 100755 --- a/view/vw_oo_organisation.yaml +++ b/view/vw_oo_organisation.yaml @@ -32,4 +32,3 @@ joins: table: qgep_od.private remap_columns: kind: private_kind - diff --git a/view/vw_oo_overflow.yaml b/view/vw_oo_overflow.yaml index c0b8ffacf..c67a42f43 100755 --- a/view/vw_oo_overflow.yaml +++ b/view/vw_oo_overflow.yaml @@ -17,7 +17,3 @@ joins: pump: table: qgep_od.pump - - - - diff --git a/view/vw_qgep_import.sql b/view/vw_qgep_import.sql index e8d36e0e5..052429c55 100644 --- a/view/vw_qgep_import.sql +++ b/view/vw_qgep_import.sql @@ -509,4 +509,3 @@ CREATE TRIGGER after_mutation_delete_when_okay FOR EACH ROW WHEN ( NEW.structure_okay IS TRUE AND NEW.inlet_okay IS TRUE AND NEW.outlet_okay IS TRUE ) EXECUTE PROCEDURE qgep_import.manhole_quarantine_delete_entry(); - diff --git a/view/vw_qgep_reach.py b/view/vw_qgep_reach.py index 7496e22ea..2ec7be202 100755 --- a/view/vw_qgep_reach.py +++ b/view/vw_qgep_reach.py @@ -2,34 +2,34 @@ # # -- View: vw_qgep_wastewater_structure -import os import argparse +import os + import psycopg2 +from pirogue.utils import insert_command, select_columns, table_parts, update_command from yaml import safe_load -from pirogue.utils import select_columns, insert_command, update_command, table_parts -def vw_qgep_reach(pg_service: str = None, - extra_definition: dict = None): +def vw_qgep_reach(pg_service: str = None, extra_definition: dict = None): """ Creates qgep_reach view :param pg_service: the PostgreSQL service name :param extra_definition: a dictionary for additional read-only columns """ if not pg_service: - pg_service = os.getenv('PGSERVICE') + pg_service = os.getenv("PGSERVICE") assert pg_service extra_definition = extra_definition or {} - conn = psycopg2.connect("service={0}".format(pg_service)) + conn = psycopg2.connect(f"service={pg_service}") cursor = conn.cursor() view_sql = """ DROP VIEW IF EXISTS qgep_od.vw_qgep_reach; - + CREATE OR REPLACE VIEW qgep_od.vw_qgep_reach AS - - SELECT + + SELECT re.obj_id, re.clear_height, re.material, @@ -38,13 +38,13 @@ def vw_qgep_reach(pg_service: str = None, ws.status AS ws_status, ws.fk_owner AS ws_fk_owner, ch.function_hydraulic AS ch_function_hydraulic, - CASE - WHEN pp.height_width_ratio IS NOT NULL THEN round(re.clear_height::numeric / pp.height_width_ratio)::smallint - ELSE clear_height + CASE + WHEN pp.height_width_ratio IS NOT NULL THEN round(re.clear_height::numeric / pp.height_width_ratio)::smallint + ELSE clear_height END AS width, - CASE - WHEN rp_from.level > 0 AND rp_to.level > 0 THEN round((rp_from.level - rp_to.level)/ST_LENGTH(re.progression_geometry)::numeric*1000,1) - ELSE NULL + CASE + WHEN rp_from.level > 0 AND rp_to.level > 0 THEN round((rp_from.level - rp_to.level)/ST_LENGTH(re.progression_geometry)::numeric*1000,1) + ELSE NULL END AS _slope_per_mill , {extra_cols} {re_cols} @@ -61,77 +61,108 @@ def vw_qgep_reach(pg_service: str = None, LEFT JOIN qgep_od.channel ch ON ch.obj_id = ws.obj_id LEFT JOIN qgep_od.pipe_profile pp ON re.fk_pipe_profile = pp.obj_id {extra_joins}; - """.format(extra_cols='\n , '.join([select_columns(pg_cur=cursor, - table_schema=table_parts(table_def['table'])[0], - table_name=table_parts(table_def['table'])[1], - skip_columns=table_def.get('skip_columns', []), - remap_columns=table_def.get('remap_columns', {}), - prefix=table_def.get('prefix', None), - table_alias=table_def.get('alias', None) - ) - for table_def in extra_definition.get('joins', {}).values()]), - re_cols=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='reach', - table_alias='re', - remove_pkey=True, - indent=4, - skip_columns=['clear_height', 'material', - 'fk_reach_point_from', 'fk_reach_point_to']), - ne_cols=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_networkelement', - table_alias='ne', - remove_pkey=True, - indent=4, - skip_columns=['fk_wastewater_structure']), - ch_cols=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='channel', - table_alias='ch', - prefix='ch_', - remove_pkey=True, - indent=4, - skip_columns=['usage_current', 'function_hierarchic', 'function_hydraulic']), - ws_cols=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_structure', - table_alias='ws', - prefix='ws_', - remove_pkey=False, - indent=4, - skip_columns=['detail_geometry_geometry', 'status', 'fk_owner', - 'fk_dataowner', 'fk_provider', '_usage_current', - '_function_hierarchic', '_label', '_depth', 'fk_main_cover']), - rp_from_cols=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='reach_point', - table_alias='rp_from', - prefix='rp_from_', - remove_pkey=False, - indent=4, - skip_columns=['situation_geometry']), - rp_to_cols=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='reach_point', - table_alias='rp_to', - prefix='rp_to_', - remove_pkey=False, - indent=4, - skip_columns=['situation_geometry']), - extra_joins='\n '.join(['LEFT JOIN {tbl} {alias} ON {jon}'.format(tbl=table_def['table'], - alias=table_def.get('alias', ''), - jon=table_def['join_on']) - for table_def in extra_definition.get('joins', {}).values()]) - - ) + """.format( + extra_cols="\n , ".join( + [ + select_columns( + pg_cur=cursor, + table_schema=table_parts(table_def["table"])[0], + table_name=table_parts(table_def["table"])[1], + skip_columns=table_def.get("skip_columns", []), + remap_columns=table_def.get("remap_columns", {}), + prefix=table_def.get("prefix", None), + table_alias=table_def.get("alias", None), + ) + for table_def in extra_definition.get("joins", {}).values() + ] + ), + re_cols=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="reach", + table_alias="re", + remove_pkey=True, + indent=4, + skip_columns=["clear_height", "material", "fk_reach_point_from", "fk_reach_point_to"], + ), + ne_cols=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_networkelement", + table_alias="ne", + remove_pkey=True, + indent=4, + skip_columns=["fk_wastewater_structure"], + ), + ch_cols=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="channel", + table_alias="ch", + prefix="ch_", + remove_pkey=True, + indent=4, + skip_columns=["usage_current", "function_hierarchic", "function_hydraulic"], + ), + ws_cols=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_structure", + table_alias="ws", + prefix="ws_", + remove_pkey=False, + indent=4, + skip_columns=[ + "detail_geometry_geometry", + "status", + "fk_owner", + "fk_dataowner", + "fk_provider", + "_usage_current", + "_function_hierarchic", + "_label", + "_depth", + "fk_main_cover", + ], + ), + rp_from_cols=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="reach_point", + table_alias="rp_from", + prefix="rp_from_", + remove_pkey=False, + indent=4, + skip_columns=["situation_geometry"], + ), + rp_to_cols=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="reach_point", + table_alias="rp_to", + prefix="rp_to_", + remove_pkey=False, + indent=4, + skip_columns=["situation_geometry"], + ), + extra_joins="\n ".join( + [ + "LEFT JOIN {tbl} {alias} ON {jon}".format( + tbl=table_def["table"], + alias=table_def.get("alias", ""), + jon=table_def["join_on"], + ) + for table_def in extra_definition.get("joins", {}).values() + ] + ), + ) cursor.execute(view_sql) - trigger_insert_sql=""" + trigger_insert_sql = """ -- REACH INSERT -- Function: vw_qgep_reach_insert() - + CREATE OR REPLACE FUNCTION qgep_od.ft_vw_qgep_reach_insert() RETURNS trigger AS $BODY$ @@ -139,83 +170,105 @@ def vw_qgep_reach(pg_service: str = None, -- Synchronize geometry with level NEW.progression_geometry = ST_ForceCurve(ST_SetPoint(ST_CurveToLine(NEW.progression_geometry),0, ST_MakePoint(ST_X(ST_StartPoint(NEW.progression_geometry)),ST_Y(ST_StartPoint(NEW.progression_geometry)),COALESCE(NEW.rp_from_level,'NaN')))); - + NEW.progression_geometry = ST_ForceCurve(ST_SetPoint(ST_CurveToLine(NEW.progression_geometry),ST_NumPoints(NEW.progression_geometry)-1, ST_MakePoint(ST_X(ST_EndPoint(NEW.progression_geometry)),ST_Y(ST_EndPoint(NEW.progression_geometry)),COALESCE(NEW.rp_to_level,'NaN')))); - + {rp_from} {rp_to} {ws} {ch} {ne} {re} - + RETURN NEW; END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100; - + CREATE TRIGGER vw_qgep_reach_insert INSTEAD OF INSERT ON qgep_od.vw_qgep_reach FOR EACH ROW EXECUTE PROCEDURE qgep_od.ft_vw_qgep_reach_insert(); - """.format(rp_from=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='reach_point', - prefix='rp_from_', - remove_pkey=False, - indent=2, - skip_columns=[], - coalesce_pkey_default=True, - insert_values={'situation_geometry': 'ST_StartPoint(NEW.progression_geometry)'}, - returning='obj_id INTO NEW.rp_from_obj_id'), - rp_to=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='reach_point', - prefix='rp_to_', - remove_pkey=False, - indent=2, - skip_columns=[], - coalesce_pkey_default=True, - insert_values={'situation_geometry': 'ST_EndPoint(NEW.progression_geometry)'}, - returning='obj_id INTO NEW.rp_to_obj_id'), - ws=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_structure', - prefix='ws_', - remove_pkey=False, - indent=2, - skip_columns=['detail_geometry_geometry', 'fk_dataowner', 'fk_provider', - '_usage_current', '_function_hierarchic', '_label', '_depth', 'fk_main_cover']), - ch=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='channel', - prefix='ch_', - remove_pkey=False, - indent=2, - remap_columns={'obj_id': 'ws_obj_id'}, - skip_columns=[]), - ne=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_networkelement', - remove_pkey=False, - indent=2, - remap_columns={'fk_wastewater_structure': 'ws_obj_id'}), - re=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='reach', - remove_pkey=False, - indent=2, - insert_values={'fk_reach_point_from': 'NEW.rp_from_obj_id', - 'fk_reach_point_to': 'NEW.rp_to_obj_id'}), - - ) + """.format( + rp_from=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="reach_point", + prefix="rp_from_", + remove_pkey=False, + indent=2, + skip_columns=[], + coalesce_pkey_default=True, + insert_values={"situation_geometry": "ST_StartPoint(NEW.progression_geometry)"}, + returning="obj_id INTO NEW.rp_from_obj_id", + ), + rp_to=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="reach_point", + prefix="rp_to_", + remove_pkey=False, + indent=2, + skip_columns=[], + coalesce_pkey_default=True, + insert_values={"situation_geometry": "ST_EndPoint(NEW.progression_geometry)"}, + returning="obj_id INTO NEW.rp_to_obj_id", + ), + ws=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_structure", + prefix="ws_", + remove_pkey=False, + indent=2, + skip_columns=[ + "detail_geometry_geometry", + "fk_dataowner", + "fk_provider", + "_usage_current", + "_function_hierarchic", + "_label", + "_depth", + "fk_main_cover", + ], + ), + ch=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="channel", + prefix="ch_", + remove_pkey=False, + indent=2, + remap_columns={"obj_id": "ws_obj_id"}, + skip_columns=[], + ), + ne=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_networkelement", + remove_pkey=False, + indent=2, + remap_columns={"fk_wastewater_structure": "ws_obj_id"}, + ), + re=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="reach", + remove_pkey=False, + indent=2, + insert_values={ + "fk_reach_point_from": "NEW.rp_from_obj_id", + "fk_reach_point_to": "NEW.rp_to_obj_id", + }, + ), + ) cursor.execute(trigger_insert_sql) - trigger_update_sql=""" + trigger_update_sql = """ CREATE OR REPLACE FUNCTION qgep_od.ft_vw_qgep_reach_update() RETURNS trigger AS $BODY$ BEGIN - + -- Synchronize geometry with level IF NEW.rp_from_level <> OLD.rp_from_level OR (NEW.rp_from_level IS NULL AND OLD.rp_from_level IS NOT NULL) OR (NEW.rp_from_level IS NOT NULL AND OLD.rp_from_level IS NULL) THEN NEW.progression_geometry = ST_ForceCurve(ST_SetPoint(ST_CurveToLine(NEW.progression_geometry),0, @@ -225,7 +278,7 @@ def vw_qgep_reach(pg_service: str = None, NEW.rp_from_level = NULLIF(ST_Z(ST_StartPoint(NEW.progression_geometry)),'NaN'); END IF; END IF; - + -- Synchronize geometry with level IF NEW.rp_to_level <> OLD.rp_to_level OR (NEW.rp_to_level IS NULL AND OLD.rp_to_level IS NOT NULL) OR (NEW.rp_to_level IS NOT NULL AND OLD.rp_to_level IS NULL) THEN NEW.progression_geometry = ST_ForceCurve(ST_SetPoint(ST_CurveToLine(NEW.progression_geometry),ST_NumPoints(NEW.progression_geometry)-1, @@ -235,83 +288,102 @@ def vw_qgep_reach(pg_service: str = None, NEW.rp_to_level = NULLIF(ST_Z(ST_EndPoint(NEW.progression_geometry)),'NaN'); END IF; END IF; - + {rp_from} - + {rp_to} - + {ch} - + {ws} - + {ne} - + {re} - - + + RETURN NEW; END; $BODY$ LANGUAGE plpgsql VOLATILE; - """.format(rp_from=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='reach_point', - prefix='rp_from_', - remove_pkey=True, - indent=6, - update_values={'situation_geometry': 'ST_StartPoint(NEW.progression_geometry)'}), - rp_to=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='reach_point', - prefix='rp_to_', - remove_pkey=True, - indent=6, - update_values={'situation_geometry': 'ST_EndPoint(NEW.progression_geometry)'}), - ch=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='channel', - prefix='ch_', - remove_pkey=True, - indent=6, - remap_columns={'obj_id': 'ws_obj_id'}), - ws=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_structure', - prefix='ws_', - remove_pkey=True, - indent=6, - remap_columns={'fk_dataowner': 'fk_dataowner', - 'fk_provider': 'fk_provider', - 'last_modification': 'last_modification'}, - skip_columns=['detail_geometry_geometry', '_usage_current', '_function_hierarchic', - '_label', '_depth', 'fk_main_cover']), - ne=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_networkelement', - remove_pkey=True, - indent=6, - remap_columns={'fk_wastewater_structure': 'ws_obj_id'} - ), - re=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='reach', - remove_pkey=True, - indent=6, - skip_columns=['fk_reach_point_to', 'fk_reach_point_from']), - - ) + """.format( + rp_from=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="reach_point", + prefix="rp_from_", + remove_pkey=True, + indent=6, + update_values={"situation_geometry": "ST_StartPoint(NEW.progression_geometry)"}, + ), + rp_to=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="reach_point", + prefix="rp_to_", + remove_pkey=True, + indent=6, + update_values={"situation_geometry": "ST_EndPoint(NEW.progression_geometry)"}, + ), + ch=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="channel", + prefix="ch_", + remove_pkey=True, + indent=6, + remap_columns={"obj_id": "ws_obj_id"}, + ), + ws=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_structure", + prefix="ws_", + remove_pkey=True, + indent=6, + remap_columns={ + "fk_dataowner": "fk_dataowner", + "fk_provider": "fk_provider", + "last_modification": "last_modification", + }, + skip_columns=[ + "detail_geometry_geometry", + "_usage_current", + "_function_hierarchic", + "_label", + "_depth", + "fk_main_cover", + ], + ), + ne=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_networkelement", + remove_pkey=True, + indent=6, + remap_columns={"fk_wastewater_structure": "ws_obj_id"}, + ), + re=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="reach", + remove_pkey=True, + indent=6, + skip_columns=["fk_reach_point_to", "fk_reach_point_from"], + ), + ) cursor.execute(trigger_update_sql) - trigger_delete_sql=""" + trigger_delete_sql = """ CREATE TRIGGER vw_qgep_reach_update INSTEAD OF UPDATE ON qgep_od.vw_qgep_reach FOR EACH ROW EXECUTE PROCEDURE qgep_od.ft_vw_qgep_reach_update(); - - + + -- REACH DELETE -- Rule: vw_qgep_reach_delete() - + CREATE OR REPLACE RULE vw_qgep_reach_delete AS ON DELETE TO qgep_od.vw_qgep_reach DO INSTEAD ( DELETE FROM qgep_od.reach WHERE obj_id = OLD.obj_id; ); @@ -320,7 +392,7 @@ def vw_qgep_reach(pg_service: str = None, extras = """ ALTER VIEW qgep_od.vw_qgep_reach ALTER obj_id SET DEFAULT qgep_sys.generate_oid('qgep_od','reach'); - + ALTER VIEW qgep_od.vw_qgep_reach ALTER rp_from_obj_id SET DEFAULT qgep_sys.generate_oid('qgep_od','reach_point'); ALTER VIEW qgep_od.vw_qgep_reach ALTER rp_to_obj_id SET DEFAULT qgep_sys.generate_oid('qgep_od','reach_point'); ALTER VIEW qgep_od.vw_qgep_reach ALTER ws_obj_id SET DEFAULT qgep_sys.generate_oid('qgep_od','channel'); @@ -334,9 +406,11 @@ def vw_qgep_reach(pg_service: str = None, if __name__ == "__main__": # create the top-level parser parser = argparse.ArgumentParser() - parser.add_argument('-e', '--extra-definition', help='YAML file path for extra additions to the view') - parser.add_argument('-p', '--pg_service', help='the PostgreSQL service name') + parser.add_argument( + "-e", "--extra-definition", help="YAML file path for extra additions to the view" + ) + parser.add_argument("-p", "--pg_service", help="the PostgreSQL service name") args = parser.parse_args() - pg_service = args.pg_service or os.getenv('PGSERVICE') + pg_service = args.pg_service or os.getenv("PGSERVICE") extra_definition = safe_load(open(args.extra_definition)) if args.extra_definition else {} vw_qgep_reach(pg_service=pg_service, extra_definition=extra_definition) diff --git a/view/vw_qgep_wastewater_structure.py b/view/vw_qgep_wastewater_structure.py index 3a80ede2b..0d4c543aa 100755 --- a/view/vw_qgep_wastewater_structure.py +++ b/view/vw_qgep_wastewater_structure.py @@ -4,14 +4,13 @@ import argparse import os + import psycopg2 +from pirogue.utils import insert_command, select_columns, table_parts, update_command from yaml import safe_load -from pirogue.utils import select_columns, insert_command, update_command, table_parts -def vw_qgep_wastewater_structure(srid: int, - pg_service: str = None, - extra_definition: dict = None): +def vw_qgep_wastewater_structure(srid: int, pg_service: str = None, extra_definition: dict = None): """ Creates qgep_wastewater_structure view :param srid: EPSG code for geometries @@ -19,13 +18,13 @@ def vw_qgep_wastewater_structure(srid: int, :param extra_definition: a dictionary for additional read-only columns """ if not pg_service: - pg_service = os.getenv('PGSERVICE') + pg_service = os.getenv("PGSERVICE") assert pg_service extra_definition = extra_definition or {} - variables = {'SRID': int(srid)} + variables = {"SRID": int(srid)} - conn = psycopg2.connect("service={0}".format(pg_service)) + conn = psycopg2.connect(f"service={pg_service}") cursor = conn.cursor() view_sql = """ @@ -96,106 +95,150 @@ def vw_qgep_wastewater_structure(srid: int, ALTER VIEW qgep_od.vw_qgep_wastewater_structure ALTER obj_id SET DEFAULT qgep_sys.generate_oid('qgep_od','wastewater_structure'); ALTER VIEW qgep_od.vw_qgep_wastewater_structure ALTER co_obj_id SET DEFAULT qgep_sys.generate_oid('qgep_od','cover'); ALTER VIEW qgep_od.vw_qgep_wastewater_structure ALTER wn_obj_id SET DEFAULT qgep_sys.generate_oid('qgep_od','wastewater_node'); - """.format(extra_cols='\n '.join([select_columns(pg_cur=cursor, - table_schema=table_parts(table_def['table'])[0], - table_name=table_parts(table_def['table'])[1], - skip_columns=table_def.get('skip_columns', []), - remap_columns=table_def.get('remap_columns', {}), - prefix=table_def.get('prefix', None), - table_alias=table_def.get('alias', None) - ) + ',' - for table_def in extra_definition.get('joins', {}).values()]), - ws_cols=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_structure', - table_alias='ws', - remove_pkey=False, - indent=4, - skip_columns=['identifier', 'fk_owner', 'status', '_label', '_cover_label', '_bottom_label', '_input_label', '_output_label', '_usage_current', - '_function_hierarchic', 'fk_main_cover', 'fk_main_wastewater_node', 'detail_geometry_geometry']), - main_co_cols=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='cover', - table_alias='main_co', - remove_pkey=False, - indent=4, - skip_columns=['situation_geometry'], - prefix='co_', - remap_columns={'cover_shape': 'co_shape'}, - columns_at_end=['obj_id']), - ma_columns=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='manhole', - table_alias='ma', - remove_pkey=True, - indent=4, - skip_columns=['function'], - prefix='ma_', - remap_columns={'_orientation': 'ma_orientation'}), - ss_columns=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='special_structure', - table_alias='ss', - remove_pkey=True, - indent=4, - skip_columns=['function'], - prefix='ss_', - remap_columns={}), - ii_columns=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='infiltration_installation', - table_alias='ii', - remove_pkey=True, - indent=4, - skip_columns=[], - prefix='ii_', - remap_columns={}), - dp_columns=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='discharge_point', - table_alias='dp', - remove_pkey=True, - indent=4, - 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', - table_alias='wn', - remove_pkey=False, - indent=4, - skip_columns=['situation_geometry'], - prefix='wn_', - remap_columns={}, - columns_at_end=['obj_id']), - ne_cols=select_columns(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_networkelement', - table_alias='ne', - remove_pkey=True, - indent=4, - skip_columns=[], - prefix='wn_', - remap_columns={}), - extra_joins='\n '.join(['LEFT JOIN {tbl} {alias} ON {jon}'.format(tbl=table_def['table'], - alias=table_def.get('alias', ''), - jon=table_def['join_on']) - for table_def in extra_definition.get('joins', {}).values()]) - ) + """.format( + extra_cols="\n ".join( + [ + select_columns( + pg_cur=cursor, + table_schema=table_parts(table_def["table"])[0], + table_name=table_parts(table_def["table"])[1], + skip_columns=table_def.get("skip_columns", []), + remap_columns=table_def.get("remap_columns", {}), + prefix=table_def.get("prefix", None), + table_alias=table_def.get("alias", None), + ) + + "," + for table_def in extra_definition.get("joins", {}).values() + ] + ), + ws_cols=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_structure", + table_alias="ws", + remove_pkey=False, + indent=4, + skip_columns=[ + "identifier", + "fk_owner", + "status", + "_label", + "_cover_label", + "_bottom_label", + "_input_label", + "_output_label", + "_usage_current", + "_function_hierarchic", + "fk_main_cover", + "fk_main_wastewater_node", + "detail_geometry_geometry", + ], + ), + main_co_cols=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="cover", + table_alias="main_co", + remove_pkey=False, + indent=4, + skip_columns=["situation_geometry"], + prefix="co_", + remap_columns={"cover_shape": "co_shape"}, + columns_at_end=["obj_id"], + ), + ma_columns=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="manhole", + table_alias="ma", + remove_pkey=True, + indent=4, + skip_columns=["function"], + prefix="ma_", + remap_columns={"_orientation": "ma_orientation"}, + ), + ss_columns=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="special_structure", + table_alias="ss", + remove_pkey=True, + indent=4, + skip_columns=["function"], + prefix="ss_", + remap_columns={}, + ), + ii_columns=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="infiltration_installation", + table_alias="ii", + remove_pkey=True, + indent=4, + skip_columns=[], + prefix="ii_", + remap_columns={}, + ), + dp_columns=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="discharge_point", + table_alias="dp", + remove_pkey=True, + indent=4, + 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", + table_alias="wn", + remove_pkey=False, + indent=4, + skip_columns=["situation_geometry"], + prefix="wn_", + remap_columns={}, + columns_at_end=["obj_id"], + ), + ne_cols=select_columns( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_networkelement", + table_alias="ne", + remove_pkey=True, + indent=4, + skip_columns=[], + prefix="wn_", + remap_columns={}, + ), + extra_joins="\n ".join( + [ + "LEFT JOIN {tbl} {alias} ON {jon}".format( + tbl=table_def["table"], + alias=table_def.get("alias", ""), + jon=table_def["join_on"], + ) + for table_def in extra_definition.get("joins", {}).values() + ] + ), + ) cursor.execute(view_sql, variables) - trigger_insert_sql=""" + trigger_insert_sql = """ CREATE OR REPLACE FUNCTION qgep_od.ft_vw_qgep_wastewater_structure_INSERT() RETURNS trigger AS $BODY$ @@ -249,87 +292,122 @@ def vw_qgep_wastewater_structure(srid: int, CREATE TRIGGER vw_qgep_wastewater_structure_INSERT INSTEAD OF INSERT ON qgep_od.vw_qgep_wastewater_structure FOR EACH ROW EXECUTE PROCEDURE qgep_od.ft_vw_qgep_wastewater_structure_INSERT(); - """.format(insert_ws=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_structure', - table_alias='ws', - remove_pkey=False, - indent=2, - skip_columns=['_label', '_cover_label', '_bottom_label', '_input_label', '_output_label', '_usage_current', '_function_hierarchic', - 'fk_main_cover', 'fk_main_wastewater_node', 'detail_geometry_geometry']), - insert_ma=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='manhole', - table_alias='ma', - prefix='ma_', - remove_pkey=False, - indent=6, - skip_columns=['_orientation'], - remap_columns={'obj_id': 'obj_id'}), - insert_ss=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='special_structure', - table_alias='ss', - prefix='ss_', - remove_pkey=False, - indent=6, - remap_columns={'obj_id': 'obj_id'}), - insert_dp=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='discharge_point', - table_alias='dp', - prefix='dp_', - remove_pkey=False, - indent=6, - remap_columns={'obj_id': 'obj_id'}), - insert_ii=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='infiltration_installation', - table_alias='ii', - prefix='ii_', - 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', - table_type='view', - table_alias='wn', - prefix='wn_', - remove_pkey=False, - pkey='obj_id', - indent=6, - insert_values={'identifier': "COALESCE(NULLIF(NEW.wn_identifier,''), NEW.identifier)", - 'situation_geometry': 'ST_SetSRID(ST_MakePoint(ST_X(NEW.situation_geometry), ST_Y(NEW.situation_geometry), \'nan\'), {srid} )'.format(srid=srid), - 'last_modification': 'NOW()', - 'fk_provider': "COALESCE(NULLIF(NEW.wn_fk_provider,''), NEW.fk_provider)", - 'fk_dataowner': "COALESCE(NULLIF(NEW.wn_fk_dataowner,''), NEW.fk_dataowner)", - 'fk_wastewater_structure': 'NEW.obj_id'}), - insert_vw_cover=insert_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='vw_cover', - table_type='view', - table_alias='co', - prefix='co_', - remove_pkey=False, - pkey='obj_id', - indent=6, - remap_columns={'cover_shape': 'co_shape'}, - insert_values={'identifier': "COALESCE(NULLIF(NEW.co_identifier,''), NEW.identifier)", - 'situation_geometry': 'ST_SetSRID(ST_MakePoint(ST_X(NEW.situation_geometry), ST_Y(NEW.situation_geometry), \'nan\'), {srid} )'.format(srid=srid), - 'last_modification': 'NOW()', - 'fk_provider': 'NEW.fk_provider', - 'fk_dataowner': 'NEW.fk_dataowner', - 'fk_wastewater_structure': 'NEW.obj_id'}) - ) + """.format( + insert_ws=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_structure", + table_alias="ws", + remove_pkey=False, + indent=2, + skip_columns=[ + "_label", + "_cover_label", + "_bottom_label", + "_input_label", + "_output_label", + "_usage_current", + "_function_hierarchic", + "fk_main_cover", + "fk_main_wastewater_node", + "detail_geometry_geometry", + ], + ), + insert_ma=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="manhole", + table_alias="ma", + prefix="ma_", + remove_pkey=False, + indent=6, + skip_columns=["_orientation"], + remap_columns={"obj_id": "obj_id"}, + ), + insert_ss=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="special_structure", + table_alias="ss", + prefix="ss_", + remove_pkey=False, + indent=6, + remap_columns={"obj_id": "obj_id"}, + ), + insert_dp=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="discharge_point", + table_alias="dp", + prefix="dp_", + remove_pkey=False, + indent=6, + remap_columns={"obj_id": "obj_id"}, + ), + insert_ii=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="infiltration_installation", + table_alias="ii", + prefix="ii_", + 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", + table_type="view", + table_alias="wn", + prefix="wn_", + remove_pkey=False, + pkey="obj_id", + indent=6, + insert_values={ + "identifier": "COALESCE(NULLIF(NEW.wn_identifier,''), NEW.identifier)", + "situation_geometry": "ST_SetSRID(ST_MakePoint(ST_X(NEW.situation_geometry), ST_Y(NEW.situation_geometry), 'nan'), {srid} )".format( + srid=srid + ), + "last_modification": "NOW()", + "fk_provider": "COALESCE(NULLIF(NEW.wn_fk_provider,''), NEW.fk_provider)", + "fk_dataowner": "COALESCE(NULLIF(NEW.wn_fk_dataowner,''), NEW.fk_dataowner)", + "fk_wastewater_structure": "NEW.obj_id", + }, + ), + insert_vw_cover=insert_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="vw_cover", + table_type="view", + table_alias="co", + prefix="co_", + remove_pkey=False, + pkey="obj_id", + indent=6, + remap_columns={"cover_shape": "co_shape"}, + insert_values={ + "identifier": "COALESCE(NULLIF(NEW.co_identifier,''), NEW.identifier)", + "situation_geometry": "ST_SetSRID(ST_MakePoint(ST_X(NEW.situation_geometry), ST_Y(NEW.situation_geometry), 'nan'), {srid} )".format( + srid=srid + ), + "last_modification": "NOW()", + "fk_provider": "NEW.fk_provider", + "fk_dataowner": "NEW.fk_dataowner", + "fk_wastewater_structure": "NEW.obj_id", + }, + ), + ) cursor.execute(trigger_insert_sql) @@ -463,87 +541,118 @@ def vw_qgep_wastewater_structure(srid: int, CREATE TRIGGER vw_qgep_wastewater_structure_UPDATE INSTEAD OF UPDATE ON qgep_od.vw_qgep_wastewater_structure FOR EACH ROW EXECUTE PROCEDURE qgep_od.ft_vw_qgep_wastewater_structure_UPDATE(); """.format( - update_co=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='cover', - table_alias='co', - prefix='co_', - indent=6, - skip_columns=['situation_geometry'], - remap_columns={'cover_shape': 'co_shape'}), - update_sp=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='structure_part', - table_alias='sp', - prefix='co_', - indent=6, - skip_columns=['fk_wastewater_structure'], - update_values={'last_modification': 'NEW.last_modification', - 'fk_dataowner': 'NEW.fk_dataowner', - 'fk_provider': 'NEW.fk_provider'}), - update_ws=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='wastewater_structure', - table_alias='ws', - remove_pkey=False, - indent=6, - skip_columns=['detail_geometry_geometry', 'last_modification', - '_usage_current', '_function_hierarchic', '_label', '_cover_label', '_bottom_label', '_input_label', '_output_label', - 'fk_main_cover', 'fk_main_wastewater_node', '_depth'], - update_values={}), - update_ma=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='manhole', - table_alias='ws', - prefix='ma_', - remove_pkey=True, - indent=6, - skip_columns=['_orientation'], - remap_columns={'obj_id': 'obj_id'}), - update_ss=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='special_structure', - table_alias='ss', - prefix='ss_', - remove_pkey=True, - indent=6, - skip_columns=[], - remap_columns={'obj_id': 'obj_id'}), - update_dp=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='discharge_point', - table_alias='dp', - prefix='dp_', - remove_pkey=True, - indent=6, - skip_columns=[], - remap_columns={'obj_id': 'obj_id'}), - update_ii=update_command(pg_cur=cursor, - table_schema='qgep_od', - table_name='infiltration_installation', - table_alias='ii', - prefix='ii_', - remove_pkey=True, - 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', - table_alias='wn', - prefix='wn_', - indent=6, - skip_columns=['situation_geometry']) - ) + update_co=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="cover", + table_alias="co", + prefix="co_", + indent=6, + skip_columns=["situation_geometry"], + remap_columns={"cover_shape": "co_shape"}, + ), + update_sp=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="structure_part", + table_alias="sp", + prefix="co_", + indent=6, + skip_columns=["fk_wastewater_structure"], + update_values={ + "last_modification": "NEW.last_modification", + "fk_dataowner": "NEW.fk_dataowner", + "fk_provider": "NEW.fk_provider", + }, + ), + update_ws=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="wastewater_structure", + table_alias="ws", + remove_pkey=False, + indent=6, + skip_columns=[ + "detail_geometry_geometry", + "last_modification", + "_usage_current", + "_function_hierarchic", + "_label", + "_cover_label", + "_bottom_label", + "_input_label", + "_output_label", + "fk_main_cover", + "fk_main_wastewater_node", + "_depth", + ], + update_values={}, + ), + update_ma=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="manhole", + table_alias="ws", + prefix="ma_", + remove_pkey=True, + indent=6, + skip_columns=["_orientation"], + remap_columns={"obj_id": "obj_id"}, + ), + update_ss=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="special_structure", + table_alias="ss", + prefix="ss_", + remove_pkey=True, + indent=6, + skip_columns=[], + remap_columns={"obj_id": "obj_id"}, + ), + update_dp=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="discharge_point", + table_alias="dp", + prefix="dp_", + remove_pkey=True, + indent=6, + skip_columns=[], + remap_columns={"obj_id": "obj_id"}, + ), + update_ii=update_command( + pg_cur=cursor, + table_schema="qgep_od", + table_name="infiltration_installation", + table_alias="ii", + prefix="ii_", + remove_pkey=True, + 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", + table_alias="wn", + prefix="wn_", + indent=6, + skip_columns=["situation_geometry"], + ), + ) cursor.execute(update_trigger_sql, variables) @@ -578,11 +687,15 @@ def vw_qgep_wastewater_structure(srid: int, if __name__ == "__main__": # create the top-level parser parser = argparse.ArgumentParser() - parser.add_argument('-s', '--srid', help='EPSG code for SRID') - parser.add_argument('-e', '--extra-definition', help='YAML file path for extra additions to the view') - parser.add_argument('-p', '--pg_service', help='the PostgreSQL service name') + parser.add_argument("-s", "--srid", help="EPSG code for SRID") + parser.add_argument( + "-e", "--extra-definition", help="YAML file path for extra additions to the view" + ) + parser.add_argument("-p", "--pg_service", help="the PostgreSQL service name") args = parser.parse_args() - srid = args.srid or os.getenv('SRID') - pg_service = args.pg_service or os.getenv('PGSERVICE') + srid = args.srid or os.getenv("SRID") + pg_service = args.pg_service or os.getenv("PGSERVICE") extra_definition = safe_load(open(args.extra_definition)) if args.extra_definition else {} - vw_qgep_wastewater_structure(srid=srid, pg_service=pg_service, extra_definition=extra_definition) + vw_qgep_wastewater_structure( + srid=srid, pg_service=pg_service, extra_definition=extra_definition + ) From 18dea8a2d658c3df735c39ebb3f8f514b215f483 Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 13:33:09 +0100 Subject: [PATCH 03/20] Fix import syntax and syntax enhancements --- delta/post-all.py | 3 +-- delta/pre-all.py | 5 +++-- test/test_geometry.py | 38 +++++++++++++++++++------------------- view/create_views.py | 5 +++-- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/delta/post-all.py b/delta/post-all.py index f014980b1..e8a59e3dc 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -5,12 +5,11 @@ import psycopg2 -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) - from pum.core.deltapy import DeltaPy from view.create_views import create_views +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) class CreateViews(DeltaPy): diff --git a/delta/pre-all.py b/delta/pre-all.py index 1e970498e..b5c550d0a 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -3,13 +3,14 @@ import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) - from pkg_resources import DistributionNotFound, get_distribution, parse_version + from pum.core.deltapy import DeltaPy from view.create_views import drop_views +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) + # Older verisons of pum and pirogue can create issues such as reapplying deltas whose checksum have changed, # or create columuns in views in a non-deterministic order. To avoid causing trouble in user's database, # we check these versions here before doing anything diff --git a/test/test_geometry.py b/test/test_geometry.py index 9d43cabe3..63a1769ca 100644 --- a/test/test_geometry.py +++ b/test/test_geometry.py @@ -33,9 +33,9 @@ def test_vw_qgep_reach_geometry_insert(self): "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F" ) # rp_from_level is NULL - expected_row["rp_from_level"] = None + expected_row["rp_from_level"] is None # rp_to_level is NULL - expected_row["rp_to_level"] = None + expected_row["rp_to_level"] is None self.insert_check("vw_qgep_reach", row, expected_row) # reach_point has on rp_to as Z NaN: SELECT ST_SetSRID( ST_MakePoint(1,2,'NaN'), 2056) row = self.select("reach_point", "BBB 1337_0001") @@ -64,7 +64,7 @@ def test_vw_qgep_reach_geometry_insert(self): "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000805040" ) # rp_from_level is NULL - expected_row["rp_from_level"] = None + expected_row["rp_from_level"] is None # rp_to_level is 66.000 expected_row["rp_to_level"] = "66.000" self.insert_check("vw_qgep_reach", row, expected_row) @@ -98,7 +98,7 @@ def test_vw_qgep_reach_geometry_insert(self): # rp_from_level is 77.000 expected_row["rp_from_level"] = "77.000" # rp_to_level is NULL - expected_row["rp_to_level"] = None + expected_row["rp_to_level"] is None self.insert_check("vw_qgep_reach", row, expected_row) # reach_point has on rp_from as Z 77.000: SELECT ST_SetSRID( ST_MakePoint(1,2,77.000), 2056) row = self.select("reach_point", "BBB 1337_0003") @@ -163,13 +163,13 @@ def test_vw_qgep_reach_geometry_update(self): # rp_from_level is 33 (startpoint of geometry) assert new_row["rp_from_level"] == 33 # rp_to_level is None (endpoint of geometry) and rp_to_level - assert new_row["rp_to_level"] == None + assert new_row["rp_to_level"] is None # reach_point has on rp_from as Z 3 new_row = self.select("reach_point", "BBB 1337_1010") assert new_row["level"] == 33 # reach_point has on rp_to as Z None new_row = self.select("reach_point", "CCC 1337_1010") - assert new_row["level"] == None + assert new_row["level"] is None # 3. change geometry including Z with startpoint Z 300 and endpoint Z 900, but change on rp_from_level to 333, and change on rp_to_level to 999 # UPDATE qgep_od.vw_qgep_reach SET progression_geometry=ST_SetSRID(ST_GeomFromText('COMPOUNDCURVE Z ((1 2 300,4 5 6,7 8 900))'), 2056), rp_to_level=NULL WHERE obj_id=obj_id' @@ -209,15 +209,15 @@ def test_vw_qgep_reach_geometry_update(self): == "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F" ) # rp_from_level is NULL (startpoint of geometry) - assert new_row["rp_from_level"] == None + assert new_row["rp_from_level"] is None # rp_to_level is NULL (endpoint of geometry) - assert new_row["rp_to_level"] == None + assert new_row["rp_to_level"] is None # reach_point has on rp_from as Z NULL new_row = self.select("reach_point", "BBB 1337_1010") - assert new_row["level"] == None + assert new_row["level"] is None # reach_point has on rp_to as Z NULL new_row = self.select("reach_point", "CCC 1337_1010") - assert new_row["level"] == None + assert new_row["level"] is None def test_vw_qgep_wastewater_structure_geometry_insert(self): # 1. insert geometry and no co_level and no wn_bottom_level @@ -231,9 +231,9 @@ def test_vw_qgep_wastewater_structure_geometry_insert(self): # ws_qgep_wastewaterstructure has the geometry but NaN as Z because of no co_level (geometry of cover): ST_SetSRID(ST_Collect(ST_MakePoint(2600000, 1200000, 'NaN')), 2056) expected_row["situation_geometry"] = "0101000020080800000000000020D6434100000000804F3241" # co_level is NULL - expected_row["co_level"] = None + expected_row["co_level"] is None # wn_bottom_level NULL - expected_row["wn_bottom_level"] = None + expected_row["wn_bottom_level"] is None self.insert_check("vw_qgep_wastewater_structure", row, expected_row) # cover geometry has the geometry but NaN as Z: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) row = self.select("cover", "1337_1001") @@ -260,7 +260,7 @@ def test_vw_qgep_wastewater_structure_geometry_insert(self): # ws_qgep_wastewaterstructure has the 2D geometry: ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056) expected_row["situation_geometry"] = "0101000020080800000000000020D6434100000000804F3241" # co_level is NULL - expected_row["co_level"] = None + expected_row["co_level"] is None # wn_bottom_level is new wn_bottom_level expected_row["wn_bottom_level"] = "200.000" self.insert_check("vw_qgep_wastewater_structure", row, expected_row) @@ -434,7 +434,7 @@ def test_wastewater_node_geometry_sync_on_insert(self): } expected_row = copy.deepcopy(row) # bottom_level NULL overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row["bottom_level"] = None + expected_row["bottom_level"] is None expected_row["situation_geometry"] = ( "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) @@ -447,7 +447,7 @@ def test_wastewater_node_geometry_sync_on_insert(self): } expected_row = copy.deepcopy(row) # no bottom_level overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row["bottom_level"] = None + expected_row["bottom_level"] is None expected_row["situation_geometry"] = ( "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) @@ -515,7 +515,7 @@ def test_wastewater_node_geometry_sync_on_update(self): new_row["situation_geometry"] == "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) - assert new_row["bottom_level"] == None + assert new_row["bottom_level"] is None def test_cover_geometry_sync_on_insert(self): # 1. level 200 and no Z @@ -554,7 +554,7 @@ def test_cover_geometry_sync_on_insert(self): } expected_row = copy.deepcopy(row) # level NULL overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row["level"] = None + expected_row["level"] is None expected_row["situation_geometry"] = ( "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) @@ -567,7 +567,7 @@ def test_cover_geometry_sync_on_insert(self): } expected_row = copy.deepcopy(row) # no level overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row["level"] = None + expected_row["level"] is None expected_row["situation_geometry"] = ( "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) @@ -636,7 +636,7 @@ def test_cover_geometry_sync_on_update(self): new_row["situation_geometry"] == "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) - assert new_row["level"] == None + assert new_row["level"] is None if __name__ == "__main__": diff --git a/view/create_views.py b/view/create_views.py index cd38fcb7c..18f92b655 100755 --- a/view/create_views.py +++ b/view/create_views.py @@ -5,14 +5,15 @@ import sys import psycopg2 + from pirogue import MultipleInheritance, SimpleJoins, SingleInheritance -from yaml import safe_load -sys.path.append(os.path.join(os.path.dirname(__file__))) +from yaml import safe_load from vw_qgep_reach import vw_qgep_reach from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure +sys.path.append(os.path.join(os.path.dirname(__file__))) def run_sql(file_path: str, pg_service: str, variables: dict = {}): sql = open(file_path).read() From c431f016a2d0d396d884b291d451899096c9c52a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:33:22 +0000 Subject: [PATCH 04/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- delta/post-all.py | 2 +- delta/pre-all.py | 1 - test/test_label.py | 5 +---- view/create_views.py | 6 ++---- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/delta/post-all.py b/delta/post-all.py index e8a59e3dc..dffb58a4d 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -4,13 +4,13 @@ import sys import psycopg2 - from pum.core.deltapy import DeltaPy from view.create_views import create_views sys.path.append(os.path.join(os.path.dirname(__file__), "..")) + class CreateViews(DeltaPy): def run(self): diff --git a/delta/pre-all.py b/delta/pre-all.py index b5c550d0a..70a233c38 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -4,7 +4,6 @@ import sys from pkg_resources import DistributionNotFound, get_distribution, parse_version - from pum.core.deltapy import DeltaPy from view.create_views import drop_views diff --git a/test/test_label.py b/test/test_label.py index 50595b0e5..f87e4face 100644 --- a/test/test_label.py +++ b/test/test_label.py @@ -53,10 +53,7 @@ def insert_reaches(self, reaches, manholes): geom = self.execute( "ST_ForceCurve(ST_SetSrid(ST_MakeLine(ARRAY[{points}]), 2056))".format( points=", ".join( - [ - f"ST_MakePoint({pt[0]}, {pt[1]}, 'NaN')" - for pt in points - ] + [f"ST_MakePoint({pt[0]}, {pt[1]}, 'NaN')" for pt in points] ) ) ) diff --git a/view/create_views.py b/view/create_views.py index 18f92b655..46c8e9fdf 100755 --- a/view/create_views.py +++ b/view/create_views.py @@ -5,16 +5,14 @@ import sys import psycopg2 - from pirogue import MultipleInheritance, SimpleJoins, SingleInheritance - -from yaml import safe_load - from vw_qgep_reach import vw_qgep_reach from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure +from yaml import safe_load sys.path.append(os.path.join(os.path.dirname(__file__))) + def run_sql(file_path: str, pg_service: str, variables: dict = {}): sql = open(file_path).read() conn = psycopg2.connect(f"service={pg_service}") From e3529d78818cbe2ec347334ab7a2f6ecca46a2cb Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 13:40:39 +0100 Subject: [PATCH 05/20] Use wwtp (wt) columns in vw_qgep_wastewater_structure --- view/vw_qgep_wastewater_structure.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/view/vw_qgep_wastewater_structure.py b/view/vw_qgep_wastewater_structure.py index 0d4c543aa..711d3d0c2 100755 --- a/view/vw_qgep_wastewater_structure.py +++ b/view/vw_qgep_wastewater_structure.py @@ -66,6 +66,8 @@ def vw_qgep_wastewater_structure(srid: int, pg_service: str = None, extra_defini , {ii_columns} , {dp_columns} + + , {wt_columns} , {wn_cols} , {ne_cols} From 7a4e7fda7795a617dca7db7abd475c1a823a1290 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:41:11 +0000 Subject: [PATCH 06/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- view/vw_qgep_wastewater_structure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/vw_qgep_wastewater_structure.py b/view/vw_qgep_wastewater_structure.py index 711d3d0c2..03631ff77 100755 --- a/view/vw_qgep_wastewater_structure.py +++ b/view/vw_qgep_wastewater_structure.py @@ -66,7 +66,7 @@ def vw_qgep_wastewater_structure(srid: int, pg_service: str = None, extra_defini , {ii_columns} , {dp_columns} - + , {wt_columns} , {wn_cols} From c6d67a8cb2226011afa69b1c3ba6a342218dad06 Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 14:01:10 +0100 Subject: [PATCH 07/20] fix import in delta --- delta/post-all.py | 2 +- delta/pre-all.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/delta/post-all.py b/delta/post-all.py index dffb58a4d..855106583 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -6,7 +6,7 @@ import psycopg2 from pum.core.deltapy import DeltaPy -from view.create_views import create_views +from ..view.create_views import create_views sys.path.append(os.path.join(os.path.dirname(__file__), "..")) diff --git a/delta/pre-all.py b/delta/pre-all.py index 70a233c38..1cb24e15c 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -6,7 +6,7 @@ from pkg_resources import DistributionNotFound, get_distribution, parse_version from pum.core.deltapy import DeltaPy -from view.create_views import drop_views +from ..view.create_views import drop_views sys.path.append(os.path.join(os.path.dirname(__file__), "..")) From 1325c6e916e6f057c2f0648cab5a3a6ff4669431 Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 14:51:00 +0100 Subject: [PATCH 08/20] Try absolute --- delta/post-all.py | 2 +- delta/pre-all.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/delta/post-all.py b/delta/post-all.py index 855106583..f3c4f5dea 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -6,7 +6,7 @@ import psycopg2 from pum.core.deltapy import DeltaPy -from ..view.create_views import create_views +from datamodel.view.create_views import create_views sys.path.append(os.path.join(os.path.dirname(__file__), "..")) diff --git a/delta/pre-all.py b/delta/pre-all.py index 1cb24e15c..b6de3856f 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -6,7 +6,7 @@ from pkg_resources import DistributionNotFound, get_distribution, parse_version from pum.core.deltapy import DeltaPy -from ..view.create_views import drop_views +from datamodel.view.create_views import drop_views sys.path.append(os.path.join(os.path.dirname(__file__), "..")) From 595ea05cdfcb1b644bd2658a516dd4ca1a11fb3a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:52:10 +0000 Subject: [PATCH 09/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- delta/post-all.py | 3 +-- delta/pre-all.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/delta/post-all.py b/delta/post-all.py index f3c4f5dea..518721325 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -4,9 +4,8 @@ import sys import psycopg2 -from pum.core.deltapy import DeltaPy - from datamodel.view.create_views import create_views +from pum.core.deltapy import DeltaPy sys.path.append(os.path.join(os.path.dirname(__file__), "..")) diff --git a/delta/pre-all.py b/delta/pre-all.py index b6de3856f..40b56fa13 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -3,11 +3,10 @@ import os import sys +from datamodel.view.create_views import drop_views from pkg_resources import DistributionNotFound, get_distribution, parse_version from pum.core.deltapy import DeltaPy -from datamodel.view.create_views import drop_views - sys.path.append(os.path.join(os.path.dirname(__file__), "..")) # Older verisons of pum and pirogue can create issues such as reapplying deltas whose checksum have changed, From 9f6a617a86a0666cff055e5f8793814c5ca8fa7f Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 14:58:51 +0100 Subject: [PATCH 10/20] Extend module awareness --- delta/post-all.py | 4 ++-- delta/pre-all.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/delta/post-all.py b/delta/post-all.py index f3c4f5dea..a94a10814 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -6,10 +6,10 @@ import psycopg2 from pum.core.deltapy import DeltaPy -from datamodel.view.create_views import create_views - sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +from datamodel.view.create_views import create_views + class CreateViews(DeltaPy): diff --git a/delta/pre-all.py b/delta/pre-all.py index b6de3856f..b3601f84e 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -6,10 +6,10 @@ from pkg_resources import DistributionNotFound, get_distribution, parse_version from pum.core.deltapy import DeltaPy -from datamodel.view.create_views import drop_views - sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +from datamodel.view.create_views import drop_views + # Older verisons of pum and pirogue can create issues such as reapplying deltas whose checksum have changed, # or create columuns in views in a non-deterministic order. To avoid causing trouble in user's database, # we check these versions here before doing anything From 3bd2e9494eb1e11da460c26327e0ab1b881eddee Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 15:04:00 +0100 Subject: [PATCH 11/20] Get funky --- delta/post-all.py | 2 +- delta/pre-all.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/delta/post-all.py b/delta/post-all.py index a94a10814..c92b739ba 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -6,7 +6,7 @@ import psycopg2 from pum.core.deltapy import DeltaPy -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) from datamodel.view.create_views import create_views diff --git a/delta/pre-all.py b/delta/pre-all.py index 99634ef42..b66533fcd 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -3,11 +3,10 @@ import os import sys -from datamodel.view.create_views import drop_views from pkg_resources import DistributionNotFound, get_distribution, parse_version from pum.core.deltapy import DeltaPy -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) from datamodel.view.create_views import drop_views From f3931c656d93ad6536372cb130fd9e89f76ef5ce Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 15:06:44 +0100 Subject: [PATCH 12/20] Revert funky --- delta/post-all.py | 4 ++-- delta/pre-all.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/delta/post-all.py b/delta/post-all.py index c92b739ba..53a9bf72e 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -6,9 +6,9 @@ import psycopg2 from pum.core.deltapy import DeltaPy -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from datamodel.view.create_views import create_views +from view.create_views import create_views class CreateViews(DeltaPy): diff --git a/delta/pre-all.py b/delta/pre-all.py index b66533fcd..f9ce5d503 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -6,9 +6,9 @@ from pkg_resources import DistributionNotFound, get_distribution, parse_version from pum.core.deltapy import DeltaPy -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from datamodel.view.create_views import drop_views +from view.create_views import drop_views # Older verisons of pum and pirogue can create issues such as reapplying deltas whose checksum have changed, # or create columuns in views in a non-deterministic order. To avoid causing trouble in user's database, From 0bbdbc39225ce9bd0a08fc2de39d4ed63f06f370 Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 15:16:35 +0100 Subject: [PATCH 13/20] Revert funky --- view/create_views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/view/create_views.py b/view/create_views.py index 46c8e9fdf..f2123325a 100755 --- a/view/create_views.py +++ b/view/create_views.py @@ -6,12 +6,13 @@ import psycopg2 from pirogue import MultipleInheritance, SimpleJoins, SingleInheritance -from vw_qgep_reach import vw_qgep_reach -from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure + from yaml import safe_load sys.path.append(os.path.join(os.path.dirname(__file__))) +from vw_qgep_reach import vw_qgep_reach +from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure def run_sql(file_path: str, pg_service: str, variables: dict = {}): sql = open(file_path).read() From ae841a0be700e09987a075aa15a0c4672a384a04 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:16:51 +0000 Subject: [PATCH 14/20] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- view/create_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/create_views.py b/view/create_views.py index f2123325a..cd38fcb7c 100755 --- a/view/create_views.py +++ b/view/create_views.py @@ -6,7 +6,6 @@ import psycopg2 from pirogue import MultipleInheritance, SimpleJoins, SingleInheritance - from yaml import safe_load sys.path.append(os.path.join(os.path.dirname(__file__))) @@ -14,6 +13,7 @@ from vw_qgep_reach import vw_qgep_reach from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure + def run_sql(file_path: str, pg_service: str, variables: dict = {}): sql = open(file_path).read() conn = psycopg2.connect(f"service={pg_service}") From 4e808d6b2223182c1ed443c27c9076a13130998b Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 15:28:21 +0100 Subject: [PATCH 15/20] Expect = None, Assert is None --- test/test_geometry.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/test_geometry.py b/test/test_geometry.py index 63a1769ca..8cec39572 100644 --- a/test/test_geometry.py +++ b/test/test_geometry.py @@ -33,9 +33,9 @@ def test_vw_qgep_reach_geometry_insert(self): "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C400000000000002040000000000000F87F" ) # rp_from_level is NULL - expected_row["rp_from_level"] is None + expected_row["rp_from_level"] = None # rp_to_level is NULL - expected_row["rp_to_level"] is None + expected_row["rp_to_level"] = None self.insert_check("vw_qgep_reach", row, expected_row) # reach_point has on rp_to as Z NaN: SELECT ST_SetSRID( ST_MakePoint(1,2,'NaN'), 2056) row = self.select("reach_point", "BBB 1337_0001") @@ -64,7 +64,7 @@ def test_vw_qgep_reach_geometry_insert(self): "01090000A00808000001000000010200008003000000000000000000F03F0000000000000040000000000000F87F0000000000001040000000000000144000000000000018400000000000001C4000000000000020400000000000805040" ) # rp_from_level is NULL - expected_row["rp_from_level"] is None + expected_row["rp_from_level"] = None # rp_to_level is 66.000 expected_row["rp_to_level"] = "66.000" self.insert_check("vw_qgep_reach", row, expected_row) @@ -98,7 +98,7 @@ def test_vw_qgep_reach_geometry_insert(self): # rp_from_level is 77.000 expected_row["rp_from_level"] = "77.000" # rp_to_level is NULL - expected_row["rp_to_level"] is None + expected_row["rp_to_level"] = None self.insert_check("vw_qgep_reach", row, expected_row) # reach_point has on rp_from as Z 77.000: SELECT ST_SetSRID( ST_MakePoint(1,2,77.000), 2056) row = self.select("reach_point", "BBB 1337_0003") @@ -231,9 +231,9 @@ def test_vw_qgep_wastewater_structure_geometry_insert(self): # ws_qgep_wastewaterstructure has the geometry but NaN as Z because of no co_level (geometry of cover): ST_SetSRID(ST_Collect(ST_MakePoint(2600000, 1200000, 'NaN')), 2056) expected_row["situation_geometry"] = "0101000020080800000000000020D6434100000000804F3241" # co_level is NULL - expected_row["co_level"] is None + expected_row["co_level"] = None # wn_bottom_level NULL - expected_row["wn_bottom_level"] is None + expected_row["wn_bottom_level"] = None self.insert_check("vw_qgep_wastewater_structure", row, expected_row) # cover geometry has the geometry but NaN as Z: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) row = self.select("cover", "1337_1001") @@ -260,7 +260,7 @@ def test_vw_qgep_wastewater_structure_geometry_insert(self): # ws_qgep_wastewaterstructure has the 2D geometry: ST_SetSRID(ST_MakePoint(2600000, 1200000), 2056) expected_row["situation_geometry"] = "0101000020080800000000000020D6434100000000804F3241" # co_level is NULL - expected_row["co_level"] is None + expected_row["co_level"] = None # wn_bottom_level is new wn_bottom_level expected_row["wn_bottom_level"] = "200.000" self.insert_check("vw_qgep_wastewater_structure", row, expected_row) @@ -434,7 +434,7 @@ def test_wastewater_node_geometry_sync_on_insert(self): } expected_row = copy.deepcopy(row) # bottom_level NULL overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row["bottom_level"] is None + expected_row["bottom_level"] = None expected_row["situation_geometry"] = ( "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) @@ -447,7 +447,7 @@ def test_wastewater_node_geometry_sync_on_insert(self): } expected_row = copy.deepcopy(row) # no bottom_level overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row["bottom_level"] is None + expected_row["bottom_level"] = None expected_row["situation_geometry"] = ( "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) @@ -554,7 +554,7 @@ def test_cover_geometry_sync_on_insert(self): } expected_row = copy.deepcopy(row) # level NULL overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row["level"] is None + expected_row["level"] = None expected_row["situation_geometry"] = ( "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) @@ -567,7 +567,7 @@ def test_cover_geometry_sync_on_insert(self): } expected_row = copy.deepcopy(row) # no level overwrites Z (555) (to NaN) results in: ST_SetSRID(ST_MakePoint(2600000, 1200000, 'NaN'), 2056) - expected_row["level"] is None + expected_row["level"] = None expected_row["situation_geometry"] = ( "01010000A0080800000000000020D6434100000000804F3241000000000000F87F" ) From 5e0d763dc8dcf25896a549a7da0fbb421d4d2095 Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Fri, 15 Nov 2024 16:04:43 +0100 Subject: [PATCH 16/20] Update checkout version and postgis version --- .github/workflows/docker-test-and-push.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-test-and-push.yaml b/.github/workflows/docker-test-and-push.yaml index b37cd064d..965ca16b4 100644 --- a/.github/workflows/docker-test-and-push.yaml +++ b/.github/workflows/docker-test-and-push.yaml @@ -23,18 +23,18 @@ jobs: # postgres-postgis version, see available tags https://hub.docker.com/r/postgis/postgis/tags pgis: # WARNING: if changing this, make sure tu update `pgis_stable` below - - 13-3.2 - - 14-3.2 + - 13-3.4 + - 14-3.4 #- 15-3.3 # Postgis 3.3 requires QGEP datamodel adaptations # See https://github.com/QGEP/QGEP/issues/825 fail-fast: false env: # which pgis version to use for :tag images and to generate the dumps attached to the release (must be in the matrix above) - pgis_stable: "14-3.2" + pgis_stable: "14-3.4" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "assert version is up to date" run: | From e0006ab2dd13d5fcc4d5a849ab9cb1767537de93 Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Mon, 18 Nov 2024 08:24:03 +0100 Subject: [PATCH 17/20] Update delta/pre-all.py Co-authored-by: Damiano Lombardi --- delta/pre-all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/delta/pre-all.py b/delta/pre-all.py index f9ce5d503..cd7ee3343 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -6,7 +6,7 @@ from pkg_resources import DistributionNotFound, get_distribution, parse_version from pum.core.deltapy import DeltaPy -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) # noqa: E402 from view.create_views import drop_views From fe1f0a36d1dbd5d9720652ccc3d4648497cbecf1 Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Mon, 18 Nov 2024 08:24:09 +0100 Subject: [PATCH 18/20] Update delta/post-all.py Co-authored-by: Damiano Lombardi --- delta/post-all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/delta/post-all.py b/delta/post-all.py index 53a9bf72e..d7fd8ca8e 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -6,7 +6,7 @@ import psycopg2 from pum.core.deltapy import DeltaPy -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) # noqa: E402 from view.create_views import create_views From 537550e63198d95a414513f1f79002a7313dff5f Mon Sep 17 00:00:00 2001 From: Arnaud Poncet-Montanges Date: Mon, 18 Nov 2024 08:24:17 +0100 Subject: [PATCH 19/20] Update view/create_views.py Co-authored-by: Damiano Lombardi --- view/create_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/create_views.py b/view/create_views.py index cd38fcb7c..b2e644bf2 100755 --- a/view/create_views.py +++ b/view/create_views.py @@ -8,7 +8,7 @@ from pirogue import MultipleInheritance, SimpleJoins, SingleInheritance from yaml import safe_load -sys.path.append(os.path.join(os.path.dirname(__file__))) +sys.path.append(os.path.join(os.path.dirname(__file__))) # noqa: E402 from vw_qgep_reach import vw_qgep_reach from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure From 85313963ac4b7effc21b8587ad2b8d73221594bf Mon Sep 17 00:00:00 2001 From: Damiano Lombardi Date: Mon, 18 Nov 2024 12:14:12 +0100 Subject: [PATCH 20/20] Apply suggestions from code review --- delta/post-all.py | 4 ++-- delta/pre-all.py | 4 ++-- view/create_views.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/delta/post-all.py b/delta/post-all.py index d7fd8ca8e..7a6ed5f9d 100644 --- a/delta/post-all.py +++ b/delta/post-all.py @@ -6,9 +6,9 @@ import psycopg2 from pum.core.deltapy import DeltaPy -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) # noqa: E402 +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from view.create_views import create_views +from view.create_views import create_views # noqa: E402 class CreateViews(DeltaPy): diff --git a/delta/pre-all.py b/delta/pre-all.py index cd7ee3343..8967a3292 100644 --- a/delta/pre-all.py +++ b/delta/pre-all.py @@ -6,9 +6,9 @@ from pkg_resources import DistributionNotFound, get_distribution, parse_version from pum.core.deltapy import DeltaPy -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) # noqa: E402 +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from view.create_views import drop_views +from view.create_views import drop_views # noqa: E402 # Older verisons of pum and pirogue can create issues such as reapplying deltas whose checksum have changed, # or create columuns in views in a non-deterministic order. To avoid causing trouble in user's database, diff --git a/view/create_views.py b/view/create_views.py index b2e644bf2..bbfdea808 100755 --- a/view/create_views.py +++ b/view/create_views.py @@ -8,10 +8,10 @@ from pirogue import MultipleInheritance, SimpleJoins, SingleInheritance from yaml import safe_load -sys.path.append(os.path.join(os.path.dirname(__file__))) # noqa: E402 +sys.path.append(os.path.join(os.path.dirname(__file__))) -from vw_qgep_reach import vw_qgep_reach -from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure +from vw_qgep_reach import vw_qgep_reach # noqa: E402 +from vw_qgep_wastewater_structure import vw_qgep_wastewater_structure # noqa: E402 def run_sql(file_path: str, pg_service: str, variables: dict = {}):