FOR acsaf IN SELECT * FROM authority.control_set_authority_field WHERE control_set = cset LOOP
res.atag := acsaf.id;
- IF acsaf.heading_field IS NULL THEN
+ -- KCLS JBAS-2285
+ -- IF acsaf.heading_field IS NULL THEN
tag_used := acsaf.tag;
nfi_used := acsaf.nfi;
joiner_text := COALESCE(acsaf.joiner, ' ');
END IF;
END LOOP;
+
+ -- KCLS JBAS-2285
+ /*
ELSE
FOR heading_row IN SELECT * FROM authority.extract_headings(marcxml, ARRAY[acsaf.heading_field]) LOOP
res.value := heading_row.heading;
RETURN NEXT res;
END LOOP;
END IF;
+ */
END LOOP;
RETURN;
RETURN;
END IF;
- --Is unauthorized?
SELECT INTO unauthorized_entry *
- FROM metabib.browse_entry_simple_heading_map mbeshm
- INNER JOIN authority.simple_heading ash ON ( mbeshm.simple_heading = ash.id )
- INNER JOIN authority.control_set_authority_field acsaf ON ( acsaf.id = ash.atag )
- JOIN authority.heading_field ahf ON (ahf.id = acsaf.heading_field)
- WHERE mbeshm.entry = rec.id
- AND ahf.heading_purpose = 'variant';
+ FROM metabib.browse_authority_is_unauthorized(rec.id, fields);
-- Gather aggregate data based on the MBE row we're looking at now, authority axis
IF (unauthorized_entry.record IS NOT NULL) THEN
-- returns
CREATE OR REPLACE FUNCTION
metabib.browse_authority_is_unauthorized (mbe_id BIGINT, field_class TEXT)
- RETURNS TABLE (auth_tag CHARACTER(3), atag INTEGER, auth_record BIGINT) AS
+ RETURNS TABLE (auth_tag CHARACTER(3), atag INTEGER, record BIGINT) AS
+$$
+ SELECT metabib.browse_authority_is_unauthorized(
+ mbe_id, (SELECT ARRAY_AGG(id)
+ FROM config.metabib_field WHERE field_class = $2)
+ );
+$$ LANGUAGE SQL;
+
+CREATE OR REPLACE FUNCTION
+ metabib.browse_authority_is_unauthorized (mbe_id BIGINT, fields INTEGER[])
+ RETURNS TABLE (auth_tag CHARACTER(3), atag INTEGER, record BIGINT) AS
$$
SELECT
acsaf.tag AS auth_tag,
ash.atag AS atag,
ash.record AS auth_record
- FROM metabib.browse_entry_simple_heading_map map
- JOIN authority.simple_heading ash ON (ash.id = map.simple_heading)
- JOIN authority.control_set_authority_field acsaf on (acsaf.id = ash.atag)
- JOIN authority.heading_field ahf ON (ahf.id = acsaf.heading_field)
- JOIN authority.control_set_auth_field_metabib_field_map_refs refs_map
- ON (ash.atag = refs_map.authority_field)
- JOIN config.metabib_field cmf ON (cmf.id = refs_map.metabib_field)
- WHERE map.entry = $1
- AND cmf.field_class = $2
- AND ahf.heading_purpose = 'variant'
+ FROM metabib.browse_entry_simple_heading_map mbeshm
+ JOIN authority.simple_heading ash ON (mbeshm.simple_heading = ash.id)
+ JOIN authority.control_set_authority_field acsaf
+ ON (acsaf.id = ash.atag AND acsaf.tag LIKE '4__')
+ JOIN authority.control_set_auth_field_metabib_field_map_refs refs_map
+ ON (acsaf.id = refs_map.authority_field)
+ JOIN config.metabib_field cmf ON
+ (cmf.id = refs_map.metabib_field AND cmf.id = ANY($2))
+ WHERE mbeshm.entry = $1
LIMIT 1
$$ LANGUAGE SQL;