Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 44 additions & 20 deletions sql_metadb/derived_tables/agreements_custom_property.sql
Original file line number Diff line number Diff line change
@@ -1,34 +1,55 @@
--metadb:table agreements_custom_property
--metadb:require folio_agreements.custom_property_container.id bigint
--metadb:require folio_agreements.custom_property.id bigint
--metadb:require folio_agreements.custom_property.parent_id bigint
--metadb:require folio_agreements.custom_property.note text
--metadb:require folio_agreements.custom_property.public_note text
--metadb:require folio_agreements.custom_property.definition_id uuid
--metadb:require folio_agreements.custom_property_definition.pd_id uuid
--metadb:require folio_agreements.custom_property_definition.pd_name text
--metadb:require folio_agreements.custom_property_definition.pd_type text
--metadb:require folio_agreements.custom_property_definition.pd_description text
--metadb:require folio_agreements.custom_property_definition.pd_label text
--metadb:require folio_agreements.custom_property_integer.id bigint
--metadb:require folio_agreements.custom_property_integer.value integer
--metadb:require folio_agreements.custom_property_text.id bigint
--metadb:require folio_agreements.custom_property_text.value text
--metadb:require folio_agreements.custom_property_refdata.id bigint
--metadb:require folio_agreements.custom_property_refdata.value_id uuid
--metadb:require folio_agreements.refdata_value.rdv_id uuid
--metadb:require folio_agreements.refdata_value.rdv_value text
--metadb:require folio_agreements.refdata_value.rdv_label text

--Creates a derived table on agreements custom properties.

DROP TABLE IF EXISTS agreements_custom_property;

CREATE TABLE agreements_custom_property AS
SELECT
agreements_custom_property_container.id AS custom_property_container_id, -- ID that can be linked to the "custom_properties_id" attribute in the "folio_agreements.subscription_agreement" table
agreements_custom_property.id AS custom_property_id,
agreements_custom_property.note AS custom_property_note,
agreements_custom_property.public_note AS custom_property_public_note,
agreements_custom_property_definition.pd_id AS custom_property_definition_uuid,
agreements_custom_property_definition.pd_name AS custom_property_definition_pd_name,
agreements_custom_property_definition.pd_type AS custom_property_definition_pd_type,
agreements_custom_property_definition.pd_description AS custom_property_definition_pd_description,
agreements_custom_property_definition.pd_label AS custom_property_definition_pd_label,
agreements_custom_property_integer.id AS custom_property_integer_id,
agreements_custom_property_integer.value AS custom_property_integer_value,
agreements_custom_property_text.id AS custom_property_text_id,
agreements_custom_property_text.value AS custom_property_text_value
FROM
folio_agreements.custom_property_container AS agreements_custom_property_container
LEFT JOIN folio_agreements.custom_property AS agreements_custom_property ON agreements_custom_property_container.id = agreements_custom_property.parent_id
LEFT JOIN folio_agreements.custom_property_definition AS agreements_custom_property_definition ON agreements_custom_property.definition_id = agreements_custom_property_definition.pd_id
LEFT JOIN folio_agreements.custom_property_integer AS agreements_custom_property_integer ON agreements_custom_property_integer.id = agreements_custom_property.id
LEFT JOIN folio_agreements.custom_property_text AS agreements_custom_property_text ON agreements_custom_property_text.id = agreements_custom_property.id;
SELECT
agreements_custom_property_container.id AS custom_property_container_id, -- ID that can be linked to the "custom_properties_id" attribute in the "folio_agreements.subscription_agreement" table
agreements_custom_property.id AS custom_property_id,
agreements_custom_property.note AS custom_property_note,
agreements_custom_property.public_note AS custom_property_public_note,
agreements_custom_property_definition.pd_id AS custom_property_definition_uuid,
agreements_custom_property_definition.pd_name AS custom_property_definition_pd_name,
agreements_custom_property_definition.pd_type AS custom_property_definition_pd_type,
agreements_custom_property_definition.pd_description AS custom_property_definition_pd_description,
agreements_custom_property_definition.pd_label AS custom_property_definition_pd_label,
agreements_custom_property_integer.id AS custom_property_integer_id,
agreements_custom_property_integer.value AS custom_property_integer_value,
agreements_custom_property_text.id AS custom_property_text_id,
agreements_custom_property_text.value AS custom_property_text_value,
agreements_refdata_value.rdv_value AS custom_property_refdata_value,
agreements_refdata_value.rdv_label AS custom_property_refdata_label
FROM
folio_agreements.custom_property_container AS agreements_custom_property_container
LEFT JOIN folio_agreements.custom_property AS agreements_custom_property ON agreements_custom_property.parent_id = agreements_custom_property_container.id
LEFT JOIN folio_agreements.custom_property_definition AS agreements_custom_property_definition ON agreements_custom_property_definition.pd_id = agreements_custom_property.definition_id
LEFT JOIN folio_agreements.custom_property_integer AS agreements_custom_property_integer ON agreements_custom_property_integer.id = agreements_custom_property.id
LEFT JOIN folio_agreements.custom_property_text AS agreements_custom_property_text ON agreements_custom_property_text.id = agreements_custom_property.id
LEFT JOIN folio_agreements.custom_property_refdata ON custom_property_refdata.id = agreements_custom_property.id
LEFT JOIN folio_agreements.refdata_value AS agreements_refdata_value ON agreements_refdata_value.rdv_id = custom_property_refdata.value_id
;

COMMENT ON COLUMN agreements_custom_property.custom_property_container_id IS 'Container ID of the custom property. The ID can be linked to the custom_properties_id attribute in the folio_agreements.subscription_agreement table';

Expand Down Expand Up @@ -56,3 +77,6 @@ COMMENT ON COLUMN agreements_custom_property.custom_property_text_id IS 'ID of t

COMMENT ON COLUMN agreements_custom_property.custom_property_text_value IS 'Value of the text value, that was entered';

COMMENT ON COLUMN agreements_custom_property.custom_property_refdata_value IS 'Refdata value for supplemental Property';

COMMENT ON COLUMN agreements_custom_property.custom_property_refdata_label IS 'Refdata label for supplemental Property';