diff --git a/pg_metadata/install/sql/pgmetadata/20_TABLE_SEQUENCE_DEFAULT.sql b/pg_metadata/install/sql/pgmetadata/20_TABLE_SEQUENCE_DEFAULT.sql index 8687a863..6b7b2d9e 100755 --- a/pg_metadata/install/sql/pgmetadata/20_TABLE_SEQUENCE_DEFAULT.sql +++ b/pg_metadata/install/sql/pgmetadata/20_TABLE_SEQUENCE_DEFAULT.sql @@ -75,7 +75,8 @@ CREATE TABLE pgmetadata.dataset ( update_date timestamp without time zone DEFAULT now(), geom public.geometry(Polygon,4326), data_last_update timestamp without time zone, - themes text[] + themes text[], + license_attribution text ); diff --git a/pg_metadata/install/sql/pgmetadata/30_VIEW.sql b/pg_metadata/install/sql/pgmetadata/30_VIEW.sql index 1939004a..5ec0d049 100755 --- a/pg_metadata/install/sql/pgmetadata/30_VIEW.sql +++ b/pg_metadata/install/sql/pgmetadata/30_VIEW.sql @@ -88,6 +88,7 @@ CREATE VIEW pgmetadata.v_dataset AS d.publication_date, d.publication_frequency, d.license, + d.license_attribution, d.confidentiality, d.feature_count, d.geometry_type, @@ -121,6 +122,7 @@ CREATE VIEW pgmetadata.v_dataset AS s.publication_date, ((((glossary.dict -> 'dataset.publication_frequency'::text) -> s.publication_frequency) -> 'label'::text) ->> glossary.locale) AS publication_frequency, ((((glossary.dict -> 'dataset.license'::text) -> s.license) -> 'label'::text) ->> glossary.locale) AS license, + s.license_attribution, ((((glossary.dict -> 'dataset.confidentiality'::text) -> s.confidentiality) -> 'label'::text) ->> glossary.locale) AS confidentiality, s.feature_count, s.geometry_type, @@ -158,9 +160,10 @@ CREATE VIEW pgmetadata.v_dataset AS ss.spatial_extent, ss.creation_date, ss.update_date, - ss.data_last_update + ss.data_last_update, + ss.license_attribution FROM ss - GROUP BY ss.id, ss.uid, ss.table_name, ss.schema_name, ss.title, ss.abstract, ss.keywords, ss.spatial_level, ss.minimum_optimal_scale, ss.maximum_optimal_scale, ss.publication_date, ss.publication_frequency, ss.license, ss.confidentiality, ss.feature_count, ss.geometry_type, ss.projection_name, ss.projection_authid, ss.spatial_extent, ss.creation_date, ss.update_date, ss.data_last_update; + GROUP BY ss.id, ss.uid, ss.table_name, ss.schema_name, ss.title, ss.abstract, ss.keywords, ss.spatial_level, ss.minimum_optimal_scale, ss.maximum_optimal_scale, ss.publication_date, ss.publication_frequency, ss.license, ss.license_attribution, ss.confidentiality, ss.feature_count, ss.geometry_type, ss.projection_name, ss.projection_authid, ss.spatial_extent, ss.creation_date, ss.update_date, ss.data_last_update; -- VIEW v_dataset diff --git a/pg_metadata/install/sql/pgmetadata/70_COMMENT.sql b/pg_metadata/install/sql/pgmetadata/70_COMMENT.sql index 543099a5..aa1c3de4 100755 --- a/pg_metadata/install/sql/pgmetadata/70_COMMENT.sql +++ b/pg_metadata/install/sql/pgmetadata/70_COMMENT.sql @@ -207,6 +207,10 @@ COMMENT ON COLUMN pgmetadata.dataset.data_last_update IS 'Date of the last modif COMMENT ON COLUMN pgmetadata.dataset.themes IS 'List of themes'; +-- dataset.license_attribution +COMMENT ON COLUMN pgmetadata.dataset.license_attribution IS 'Attribution, e.g. giving credit for CC-by license, name of licensor, or license number'; + + -- dataset_contact COMMENT ON TABLE pgmetadata.dataset_contact IS 'Pivot table between dataset and contacts.'; diff --git a/pg_metadata/install/sql/upgrade/upgrade_to_1.3.0.sql b/pg_metadata/install/sql/upgrade/upgrade_to_1.3.0.sql index 9b340db9..e55da539 100644 --- a/pg_metadata/install/sql/upgrade/upgrade_to_1.3.0.sql +++ b/pg_metadata/install/sql/upgrade/upgrade_to_1.3.0.sql @@ -113,4 +113,111 @@ WHERE g.field = t.field AND g.code = t.code; DROP TABLE pgmetadata.t_glossary; + +-- DATASET + +-- new field: license_attribution + +ALTER TABLE pgmetadata.dataset ADD COLUMN IF NOT EXISTS license_attribution text; + +COMMENT ON COLUMN pgmetadata.dataset.license_attribution IS 'Attribution, e.g. giving credit for CC-by license, name of licensor, or license number'; + +CREATE OR REPLACE VIEW pgmetadata.v_dataset AS + WITH glossary AS ( + SELECT COALESCE(current_setting('pgmetadata.locale'::text, true), 'en'::text) AS locale, + v_glossary.dict + FROM pgmetadata.v_glossary + ), s AS ( + SELECT d.id, + d.uid, + d.table_name, + d.schema_name, + d.title, + d.abstract, + d.categories, + d.themes, + d.keywords, + d.spatial_level, + d.minimum_optimal_scale, + d.maximum_optimal_scale, + d.publication_date, + d.publication_frequency, + d.license, + d.license_attribution, + d.confidentiality, + d.feature_count, + d.geometry_type, + d.projection_name, + d.projection_authid, + d.spatial_extent, + d.creation_date, + d.update_date, + d.data_last_update, + d.geom, + cat.cat, + theme.theme + FROM ((pgmetadata.dataset d + LEFT JOIN LATERAL unnest(d.categories) cat(cat) ON (true)) + LEFT JOIN LATERAL unnest(d.themes) theme(theme) ON (true)) + WHERE true + ORDER BY d.id + ), ss AS ( + SELECT s.id, + s.uid, + s.table_name, + s.schema_name, + s.title, + s.abstract, + ((((glossary.dict -> 'dataset.categories'::text) -> s.cat) -> 'label'::text) ->> glossary.locale) AS cat, + gtheme.label AS theme, + s.keywords, + s.spatial_level, + ('1/'::text || s.minimum_optimal_scale) AS minimum_optimal_scale, + ('1/'::text || s.maximum_optimal_scale) AS maximum_optimal_scale, + s.publication_date, + ((((glossary.dict -> 'dataset.publication_frequency'::text) -> s.publication_frequency) -> 'label'::text) ->> glossary.locale) AS publication_frequency, + ((((glossary.dict -> 'dataset.license'::text) -> s.license) -> 'label'::text) ->> glossary.locale) AS license, + s.license_attribution, + ((((glossary.dict -> 'dataset.confidentiality'::text) -> s.confidentiality) -> 'label'::text) ->> glossary.locale) AS confidentiality, + s.feature_count, + s.geometry_type, + (regexp_split_to_array((rs.srtext)::text, '"'::text))[2] AS projection_name, + s.projection_authid, + s.spatial_extent, + s.creation_date, + s.update_date, + s.data_last_update + FROM glossary, + ((s + LEFT JOIN pgmetadata.theme gtheme ON ((gtheme.code = s.theme))) + LEFT JOIN public.spatial_ref_sys rs ON ((concat(rs.auth_name, ':', rs.auth_srid) = s.projection_authid))) + ) + SELECT ss.id, + ss.uid, + ss.table_name, + ss.schema_name, + ss.title, + ss.abstract, + string_agg(DISTINCT ss.cat, ', '::text ORDER BY ss.cat) AS categories, + string_agg(DISTINCT ss.theme, ', '::text ORDER BY ss.theme) AS themes, + ss.keywords, + ss.spatial_level, + ss.minimum_optimal_scale, + ss.maximum_optimal_scale, + ss.publication_date, + ss.publication_frequency, + ss.license, + ss.confidentiality, + ss.feature_count, + ss.geometry_type, + ss.projection_name, + ss.projection_authid, + ss.spatial_extent, + ss.creation_date, + ss.update_date, + ss.data_last_update, + ss.license_attribution + FROM ss + GROUP BY ss.id, ss.uid, ss.table_name, ss.schema_name, ss.title, ss.abstract, ss.keywords, ss.spatial_level, ss.minimum_optimal_scale, ss.maximum_optimal_scale, ss.publication_date, ss.publication_frequency, ss.license, ss.license_attribution, ss.confidentiality, ss.feature_count, ss.geometry_type, ss.projection_name, ss.projection_authid, ss.spatial_extent, ss.creation_date, ss.update_date, ss.data_last_update; + COMMIT; diff --git a/pg_metadata/resources/html/main.html b/pg_metadata/resources/html/main.html index 992a3f34..f7ff4a06 100644 --- a/pg_metadata/resources/html/main.html +++ b/pg_metadata/resources/html/main.html @@ -64,6 +64,9 @@

Publication

License[% license %] + + License attribution / number[% license_attribution %] + Confidentiality[% confidentiality %] diff --git a/pg_metadata/resources/projects/pg_metadata_administration.qgs b/pg_metadata/resources/projects/pg_metadata_administration.qgs index 690e5f64..4e046c3b 100644 --- a/pg_metadata/resources/projects/pg_metadata_administration.qgs +++ b/pg_metadata/resources/projects/pg_metadata_administration.qgs @@ -995,6 +995,16 @@ def my_form_open(dialog, layer, feature): + + + + + + + + n + @@ -1150,6 +1160,7 @@ def my_form_open(dialog, layer, feature): + @@ -1166,6 +1177,7 @@ def my_form_open(dialog, layer, feature): + @@ -1192,6 +1204,7 @@ def my_form_open(dialog, layer, feature): + @@ -1218,6 +1231,7 @@ def my_form_open(dialog, layer, feature): + @@ -1249,6 +1263,7 @@ def my_form_open(dialog, layer, feature):