From adacd65a6f457a3b77fe71a35625962fa6b975b4 Mon Sep 17 00:00:00 2001 From: Matt Weaver Date: Thu, 17 Oct 2024 10:10:26 -0700 Subject: [PATCH] MODFQMMGR-432 Switch back to a nested table for instance classifications This commit reverts the work that split instance classifications into separate columns, but keeps the changes the translations and value getters --- .../inventory/simple_instance.json5 | 101 +++++++++--------- translations/mod-fqm-manager/en.json | 10 +- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/src/main/resources/entity-types/inventory/simple_instance.json5 b/src/main/resources/entity-types/inventory/simple_instance.json5 index eb196f14..c461005b 100644 --- a/src/main/resources/entity-types/inventory/simple_instance.json5 +++ b/src/main/resources/entity-types/inventory/simple_instance.json5 @@ -520,66 +520,63 @@ valueFunction: 'lower(:value)', }, { - name: 'classification_type_ids', - sourceAlias: 'inst', - dataType: { - dataType: 'arrayType', - itemDataType: { - dataType: 'rangedUUIDType', - }, - }, - isIdColumn: false, - queryable: true, - visibleByDefault: false, - essential: true, - hidden: true, - valueGetter: - "(SELECT array_agg(elems.value->>'classificationTypeId' ORDER BY elems.value->>'classificationTypeId') \ - FROM jsonb_array_elements(:sourceAlias.jsonb->'classifications') AS elems \ - )", - filterValueGetter: - "(SELECT array_agg(lower(elems.value->>'classificationTypeId') ORDER BY elems.value->>'classificationTypeId') \ - FROM jsonb_array_elements(:sourceAlias.jsonb->'classifications') AS elems \ - )" - }, - { - name: 'classification_type_names', - sourceAlias: 'inst', - essential: true, - dataType: { - dataType: 'arrayType', - itemDataType: { - dataType: 'stringType', - }, - }, - idColumnName: 'classification_type_ids', - queryable: true, - visibleByDefault: false, - valueGetter: - "(SELECT array_agg(class_type.jsonb ->> 'name' ORDER BY record.value ->> 'classificationTypeId') \ - FILTER (WHERE (class_type.jsonb ->> 'name') IS NOT NULL) AS array_agg \ - FROM jsonb_array_elements((:sourceAlias.jsonb -> 'classifications')) record(value) \ - JOIN src_inventory_classification_type class_type \ - ON (record.value ->> 'classificationTypeId') = class_type.id::text \ - )" - }, - { - name: 'classification_numbers', + name: 'classifications', sourceAlias: 'inst', essential: true, dataType: { dataType: 'arrayType', itemDataType: { - dataType: 'stringType', + dataType: 'objectType', + properties: [ + { + name: 'type_name', + property: 'classificationType', + dataType: { + dataType: 'rangedUUIDType', + }, + queryable: false, + valueGetter: "(SELECT array_agg(class_type.jsonb ->> 'name' ORDER BY record.value ->> 'classificationTypeId') \ + FILTER (WHERE (class_type.jsonb ->> 'name') IS NOT NULL) AS array_agg \ + FROM jsonb_array_elements((:sourceAlias.jsonb -> 'classifications')) record(value) \ + JOIN src_inventory_classification_type class_type \ + ON (record.value ->> 'classificationTypeId') = class_type.id::text \ + )", + }, + { + name: 'number', + property: 'classificationNumber', + dataType: { + dataType: 'stringType', + }, + queryable: false, + valueGetter: "(SELECT array_agg(record.value ->> 'classificationNumber' ORDER BY record.value ->> 'classificationTypeId') \ + FILTER (WHERE (record.value ->> 'classificationNumber') IS NOT NULL) AS array_agg \ + FROM jsonb_array_elements((:sourceAlias.jsonb -> 'classifications')) record(value) \ + )" + }, +// { +// name: 'type_id', +// property: 'classificationTypeId', +// dataType: { +// dataType: 'rangedUUIDType', +// }, +// queryable: false, +// valueGetter: "(SELECT array_agg(elems.value->>'classificationTypeId' ORDER BY elems.value->>'classificationTypeId') \ +// FROM jsonb_array_elements(:sourceAlias.jsonb->'classifications') AS elems \ +// )", +// }, + ], }, }, - queryable: true, + isIdColumn: false, + queryable: false, visibleByDefault: false, - valueGetter: - "(SELECT array_agg(record.value ->> 'classificationNumber' ORDER BY record.value ->> 'classificationTypeId') \ - FILTER (WHERE (record.value ->> 'classificationNumber') IS NOT NULL) AS array_agg \ - FROM jsonb_array_elements((:sourceAlias.jsonb -> 'classifications')) record(value) \ - )", + valueGetter: "(SELECT jsonb_agg(record.value || \ + jsonb_build_object('classificationType', class_type.jsonb ->> 'name') \ + ORDER BY record.value ->> 'classificationTypeId') \ + FROM jsonb_array_elements((:sourceAlias.jsonb -> 'classifications')) record(value) \ + LEFT JOIN src_inventory_classification_type class_type \ + ON (record.value ->> 'classificationTypeId') = class_type.id::text)::text", }, { name: 'publication', diff --git a/translations/mod-fqm-manager/en.json b/translations/mod-fqm-manager/en.json index 399ddbe6..15f3b53d 100644 --- a/translations/mod-fqm-manager/en.json +++ b/translations/mod-fqm-manager/en.json @@ -638,9 +638,13 @@ "entityType.simple_instance.alternative_titles": "Alternative titles", "entityType.simple_instance.alternative_titles_ids": "Alternative titles - Type UUID", "entityType.simple_instance.cataloged_date": "Cataloged date", - "entityType.simple_instance.classification_type_ids": "Classification type UUIDs", - "entityType.simple_instance.classification_type_names": "Classification identifier type", - "entityType.simple_instance.classification_numbers": "Classification", + "entityType.simple_instance.classifications": "Classifications", + "entityType.simple_instance.classifications.number": "Classification", + "entityType.simple_instance.classifications.number._qualified": "Classification number", + "entityType.simple_instance.classifications.type_id": "Identifier type UUID", + "entityType.simple_instance.classifications.type_id._qualified": "Classification identifier type UUID", + "entityType.simple_instance.classifications.type_name": "Classification identifier type", + "entityType.simple_instance.classifications.type_name._qualified": "Classification identifier type", "entityType.simple_instance.complete_updated_date": "Complete updated date", "entityType.simple_instance.contributor_type_id": "Contributor type UUID", "entityType.simple_instance.contributors_name": "Contributor name",