ores.reporting.report_configuration

Table of Contents

This is how a report definition reaches its configuration: one row per configuration it binds, where the configuration type is the slot and the configuration fills it. Several reports may fill the same slot with the same configuration, so a configuration is never copied to be shared, and adding a slot is not a column on the report definition.

1. Flags

2. Columns

2.1. id

Surrogate key for the binding.

2.2. party_id

The party that owns the document this row belongs to. Set from the session that writes the document, and enforced by row level security, so a party sees only its own configuration.

ctx.generate_uuid()

2.3. report_definition_id

The report definition that binds the configuration.

2.4. configuration_type_code

The slot. It must match the kind of the configuration on the same row.

2.5. configuration_id

The configuration that fills the slot.

3. Artefact columns

A dataset stages definitions and their bindings together, and the ids of both are made when they publish, so the staging row names the definition and the configuration instead: by the definition's name, the configuration type's code and the configuration's name.

3.1. version

3.2. report_name

3.3. configuration_type_code

3.4. configuration_name

4. SQL

4.1. Flags

5. Foreign keys

5.1. report_definition_id

5.2. configuration_type_code

5.3. configuration_id

6. Insert trigger

-- An official report reads no sandbox: a definition cannot bind a risk
-- configuration whose scope names a sandbox portfolio or a virtual book.
if NEW.configuration_type_code = 'risk_report_config'
   and ores_reporting_definition_is_official_fn(NEW.tenant_id, NEW.report_definition_id)
   and exists (
       select 1 from ores_reporting_risk_report_configs_tbl c
       where c.tenant_id = NEW.tenant_id
         and c.configuration_id = NEW.configuration_id
         and c.valid_to = ores_utility_infinity_timestamp_fn()
         and ores_reporting_config_scope_has_sandbox_fn(NEW.tenant_id, c.id)) then
    raise exception 'Invalid configuration_id: %. The configuration scopes sandbox data and the definition is official.',
        NEW.configuration_id
        using errcode = '23514';
end if;

-- A typed report reads the books of its type only: a definition cannot bind a
-- risk configuration whose scope names a book of another type.
if NEW.configuration_type_code = 'risk_report_config'
   and exists (
       select 1
       from (select ores_reporting_definition_regulatory_type_fn(
                        NEW.tenant_id, NEW.report_definition_id) as book_type) d
       join ores_reporting_risk_report_configs_tbl c
         on c.tenant_id = NEW.tenant_id
        and c.configuration_id = NEW.configuration_id
        and c.valid_to = ores_utility_infinity_timestamp_fn()
       where d.book_type is not null
         and ores_reporting_config_scope_names_other_type_fn(
                 NEW.tenant_id, c.id, d.book_type)) then
    raise exception 'Invalid configuration_id: %. The configuration scopes books of another regulatory book type than the definition.',
        NEW.configuration_id
        using errcode = '23514';
end if;

-- A risk configuration is bound only when its analytics make an ORE run.
if NEW.configuration_type_code = 'risk_report_config'
   and ores_reporting_configuration_analytics_problem_fn(NEW.tenant_id, NEW.configuration_id)
       is not null then
    raise exception 'Invalid configuration_id: %. %', NEW.configuration_id,
        ores_reporting_configuration_analytics_problem_fn(NEW.tenant_id, NEW.configuration_id)
        using errcode = '23514';
end if;

6.1. Validations

column validation_function

7. C++

7.1. Flags

7.2. Repository

7.3. Domain includes

#include <string>

7.4. Entity includes

#include <string>

7.5. Conventions

7.6. Table display

column header
configuration_type_code Slot
configuration_id Configuration
modified_by Modified By
version Version

7.7. Presentation

7.7.1. Detail fields

field label type is_key is_required placeholder
configuration_type_code Slot line_edit true true Enter configuration type code
configuration_id Configuration line_edit   true Enter configuration id

7.7.2. Columns

enum_name field header type width
ConfigurationType configuration_type_code Slot string 180
ConfigurationId configuration_id Configuration string 260
Version version Version int 80
ModifiedBy modified_by Modified By string 120

7.8. Custom repository methods

8. See also

Emacs 29.3 (Org mode 9.6.15)