ores.sql.asset_class.dq_system_populate

Table of Contents

Seeds the system tenant's own DQ tables for the taxonomy: one badge definition per class with its colour, severity and css class; the asset_class code domain; and one mapping per class from the domain to its badge. The generated script replaces the rows that used to sit inside dq_badge_system_populate.sql's single DO block, so the badge metadata has one author.

The browser mirrors are the sibling dq_artefact_populate archetype, which carries the same rows into the staging tables a tenant is published from.

See the Template variable reference for the complete list of available variables and their semantics.

1. Template

The full template source. Edit here and re-tangle with compass build --direct tangle_codegen_templates to regenerate library/templates/sql_asset_class_dq_system_populate.mustache.

{{! GENERATED FILE — tangled from projects/ores.codegen/library/templates/ores.sql.asset_class.org. Edit the org source. }}
{{{sql_license}}}

/**
 * AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
 * Template: sql_asset_class_dq_system_populate.mustache
 *
 * Asset Class DQ Rows Population Script
 *
 * Seeds the system tenant's badge definitions, the asset_class code domain and
 * the badge mappings for the refdata product taxonomy. Generated from
 * ores.refdata.asset_class_catalogue; the staging mirrors are the sibling
 * dq_asset_class_artefact_populate.sql.
 *
 * This script is idempotent (uses upsert functions).
 */

\echo '--- Asset Class DQ Rows ---'

do $$
begin
{{#asset_class_catalogue}}
{{#taxonomy}}
    perform ores_dq_badge_definitions_upsert_fn(ores_utility_system_tenant_id_fn(),
        '{{badge_code}}', '{{badge_name}}', '{{badge_description}}',
        '{{badge_background}}', '{{badge_text}}', '{{badge_severity}}', '{{badge_css}}', {{badge_order}});
{{/taxonomy}}
    perform ores_dq_code_domains_upsert_fn(ores_utility_system_tenant_id_fn(),
        '{{code_domain.code}}', '{{code_domain.name}}',
        '{{code_domain.description_sql}}', {{code_domain.display_order}});
{{#taxonomy}}
    perform ores_dq_badge_mappings_upsert_fn(ores_utility_system_tenant_id_fn(),
        '{{code_domain.code}}', '{{code}}', '{{badge_code}}');
{{/taxonomy}}
{{/asset_class_catalogue}}
end $$;

2. See also

Emacs 29.3 (Org mode 9.6.15)