{ from => [ 'config.ou_marc_subfields', 1, $marc_record_type, $context_ou ] }
);
foreach my $sf (@$subfields) {
- push @{ $sf_by_tag{$sf->{tag}} }, {
+ my $sf_data = {
code => $sf->{code},
description => $sf->{description},
mandatory => $sf->{mandatory},
repeatable => $sf->{repeatable},
+ };
+ if ($sf->{value_ctype}) {
+ $sf_data->{value_list} = $e->json_query({
+ select => { ccvm => [
+ 'code',
+ { column => 'value', alias => 'description' }
+ ]
+ },
+ from => 'ccvm',
+ where => { ctype => $sf->{value_ctype} },
+ order_by => { ccvm => { code => {} } },
+ });
}
+ push @{ $sf_by_tag{$sf->{tag}} }, $sf_data;
}
}
repeatable BOOLEAN,
mandatory BOOLEAN,
hidden BOOLEAN,
+ value_ctype TEXT
+ REFERENCES config.record_attr_definition (name)
+ DEFERRABLE INITIALLY DEFERRED,
owner INTEGER REFERENCES actor.org_unit (id)
-- if the owner is null, the data about the subfield is
-- assumed to come from the controlling MARC standard
CREATE OR REPLACE VIEW config.marc_field_for_ou AS
WITH RECURSIVE ou_marc_fields(id, marc_format, marc_record_type, tag,
name, description, fixed_field, repeatable,
- mandatory, hidden, owner, depth) AS (
+ mandatory, hidden, value_ctype, owner, depth) AS (
-- start with all MARC fields defined by the controlling national standard
SELECT id, marc_format, marc_record_type, tag, name, description, fixed_field, repeatable, mandatory, hidden, owner, 0
FROM config.marc_field
description, repeatable,
mandatory, hidden, owner, depth) AS (
-- start with all MARC subfields defined by the controlling national standard
- SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner, 0
+ SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory,
+ hidden, value_ctype, owner, 0
FROM config.marc_subfield
WHERE owner IS NULL
UNION
-- as well as any purely local ones that have been added
- SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner, 0
+ SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory,
+ hidden, value_ctype, owner, 0
FROM config.marc_subfield
WHERE ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag, code] NOT IN (
SELECT ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag, code]
COALESCE(c.repeatable, p.repeatable),
COALESCE(c.mandatory, p.mandatory),
COALESCE(c.hidden, p.hidden),
+ COALESCE(c.value_ctype, p.value_ctype),
c.owner,
depth + 1
FROM config.marc_subfield c
)
SELECT id, marc_format, marc_record_type, tag, code,
description, repeatable,
- mandatory, hidden, owner, depth
+ mandatory, hidden, value_ctype, owner, depth
FROM ou_marc_subfields;
CREATE OR REPLACE FUNCTION config.ou_marc_fields(marc_format INTEGER, marc_record_type config.marc_record_type, ou INTEGER) RETURNS SETOF config.marc_field AS $func$
$func$ LANGUAGE SQL;
CREATE OR REPLACE FUNCTION config.ou_marc_subfields(marc_format INTEGER, marc_record_type config.marc_record_type, ou INTEGER) RETURNS SETOF config.marc_subfield AS $func$
- SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner
+ SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory,
+ hidden, value_ctype, owner
FROM (
SELECT id, marc_format, marc_record_type, tag, code, description,
- repeatable, mandatory, hidden, owner, depth,
+ repeatable, mandatory, hidden, value_ctype, owner, depth,
MAX(depth) OVER (PARTITION BY marc_format, marc_record_type, tag, code) AS winner
FROM config.marc_subfield_for_ou
WHERE (owner IS NULL
repeatable BOOLEAN,
mandatory BOOLEAN,
hidden BOOLEAN,
+ value_ctype TEXT
+ REFERENCES config.record_attr_definition (name)
+ DEFERRABLE INITIALLY DEFERRED,
owner INTEGER REFERENCES actor.org_unit (id)
-- if the owner is null, the data about the subfield is
-- assumed to come from the controlling MARC standard
CREATE OR REPLACE VIEW config.marc_subfield_for_ou AS
WITH RECURSIVE ou_marc_subfields(id, marc_format, marc_record_type, tag, code,
description, repeatable,
- mandatory, hidden, owner, depth) AS (
+ mandatory, hidden, value_ctype, owner, depth) AS (
-- start with all MARC subfields defined by the controlling national standard
- SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner, 0
+ SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory,
+ hidden, value_ctype, owner, 0
FROM config.marc_subfield
WHERE owner IS NULL
UNION
-- as well as any purely local ones that have been added
- SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner, 0
+ SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory,
+ hidden, value_ctype, owner, 0
FROM config.marc_subfield
WHERE ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag, code] NOT IN (
SELECT ARRAY[marc_format::TEXT, marc_record_type::TEXT, tag, code]
COALESCE(c.repeatable, p.repeatable),
COALESCE(c.mandatory, p.mandatory),
COALESCE(c.hidden, p.hidden),
+ COALESCE(c.value_ctype, p.value_ctype),
c.owner,
depth + 1
FROM config.marc_subfield c
)
SELECT id, marc_format, marc_record_type, tag, code,
description, repeatable,
- mandatory, hidden, owner, depth
+ mandatory, hidden, value_ctype, owner, depth
FROM ou_marc_subfields;
CREATE OR REPLACE FUNCTION config.ou_marc_fields(marc_format INTEGER, marc_record_type config.marc_record_type, ou INTEGER) RETURNS SETOF config.marc_field AS $func$
$func$ LANGUAGE SQL;
CREATE OR REPLACE FUNCTION config.ou_marc_subfields(marc_format INTEGER, marc_record_type config.marc_record_type, ou INTEGER) RETURNS SETOF config.marc_subfield AS $func$
- SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory, hidden, owner
+ SELECT id, marc_format, marc_record_type, tag, code, description, repeatable, mandatory,
+ hidden, value_ctype, owner
FROM (
SELECT id, marc_format, marc_record_type, tag, code, description,
- repeatable, mandatory, hidden, owner, depth,
+ repeatable, mandatory, hidden, value_ctype, owner, depth,
MAX(depth) OVER (PARTITION BY marc_format, marc_record_type, tag, code) AS winner
FROM config.marc_subfield_for_ou
WHERE (owner IS NULL