diff --git a/src/main/java/org/folio/fqm/migration/strategies/V0POCMigration.java b/src/main/java/org/folio/fqm/migration/strategies/V0POCMigration.java index 5158a872..0e1bb33c 100644 --- a/src/main/java/org/folio/fqm/migration/strategies/V0POCMigration.java +++ b/src/main/java/org/folio/fqm/migration/strategies/V0POCMigration.java @@ -4,6 +4,7 @@ import java.util.UUID; import java.util.function.BiFunction; import java.util.function.Function; + import org.folio.fqm.migration.AbstractSimpleMigrationStrategy; import org.folio.fqm.migration.warnings.EntityTypeWarning; import org.folio.fqm.migration.warnings.FieldWarning; @@ -97,6 +98,7 @@ public class V0POCMigration extends AbstractSimpleMigrationStrategy { Map.entry("mode_of_issuance_id", "mode_of_issuance.id"), Map.entry("mode_of_issuance", "mode_of_issuance.name"), Map.entry("instance_source", "instance.source"), + Map.entry("instance_primary_contributor", "instance.instance_primary_contributor"), Map.entry("instance_contributor_type_ids", "instance.contributors[*]->contributor_type_id"), Map.entry("instance_contributor_type", "instance.contributors[*]->contributor_type_text"), Map.entry("instance_contributor_type_name_ids", "instance.contributors[*]->contributor_name_type_id"), @@ -438,20 +440,6 @@ public Map> getEntityTypeWarnings() { @Override public Map>> getFieldWarnings() { return Map.ofEntries( - Map.entry( - OLD_DRV_LOAN_DETAILS, - Map.of( - "instance_primary_contributor", - (String field, String fql) -> new QueryBreakingWarning(field, "instance.contributors", fql) - ) - ), - Map.entry( - OLD_DRV_ITEM_DETAILS, - Map.of( - "instance_primary_contributor", - (String field, String fql) -> new QueryBreakingWarning(field, "instance.contributors", fql) - ) - ), Map.entry( OLD_DRV_USER_DETAILS, Map.of( diff --git a/src/main/resources/entity-types/inventory/simple_instance.json5 b/src/main/resources/entity-types/inventory/simple_instance.json5 index c87ba43d..d45f2d59 100644 --- a/src/main/resources/entity-types/inventory/simple_instance.json5 +++ b/src/main/resources/entity-types/inventory/simple_instance.json5 @@ -369,86 +369,101 @@ valueGetter: ":sourceAlias.jsonb->>'identifiers'", }, { - name: 'contributors', + name: 'contributors_name', sourceAlias: 'inst', dataType: { dataType: 'arrayType', itemDataType: { - dataType: 'objectType', - properties: [ - { - name: 'name', - property: 'name', - dataType: { - dataType: 'stringType', - }, - queryable: false, - valueGetter: "( SELECT array_agg(elems.value->>'name') FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - filterValueGetter: "( SELECT array_agg(lower(elems.value->>'name')) FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - valueFunction: 'lower(:value)', - }, - { - name: 'contributor_type_id', - property: 'contributorTypeId', - dataType: { - dataType: 'stringType', - }, - queryable: false, - valueGetter: "( SELECT array_agg(elems.value->>'contributorTypeId') FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - filterValueGetter: "( SELECT array_agg(lower(elems.value->>'contributorTypeId')) FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - valueFunction: 'lower(:value)', - }, - { - name: 'contributor_type_text', - property: 'contributorTypeText', - dataType: { - dataType: 'stringType', - }, - queryable: false, - valueGetter: "( SELECT array_agg(elems.value->>'contributorTypeText') FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - filterValueGetter: "( SELECT array_agg(lower(elems.value->>'contributorTypeText')) FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - valueFunction: 'lower(:value)', - }, - { - name: 'contributor_name_type_id', - property: 'contributorNameTypeId', - dataType: { - dataType: 'stringType', - }, - queryable: false, - valueGetter: "( SELECT array_agg(elems.value->>'contributorNameTypeId') FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - filterValueGetter: "( SELECT array_agg(lower(elems.value->>'contributorNameTypeId')) FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - valueFunction: 'lower(:value)', - }, - { - name: 'primary', - property: 'primary', - dataType: { - dataType: 'booleanType', - }, - queryable: false, - valueGetter: "( SELECT array_agg(elems.value->>'primary') FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - filterValueGetter: "( SELECT array_agg(lower(elems.value->>'primary')) FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", - valueFunction: 'lower(:value)', - values: [ - { - value: 'true', - label: 'True', - }, - { - value: 'false', - label: 'False', - }, - ], - }, - ], + dataType: 'stringType', }, }, isIdColumn: false, + queryable: true, essential: true, - queryable: false, visibleByDefault: false, - valueGetter: ":sourceAlias.jsonb->>'contributors'", + valueGetter: "( SELECT array_agg(elems.value->>'name') FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", + filterValueGetter: "( SELECT array_agg(lower(elems.value->>'name')) FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", + valueFunction: 'lower(:value)' + }, + { + name: "contributor_type_id", + dataType: { + dataType: "arrayType", + itemDataType: { + dataType: "rangedUUIDType" + } + }, + sourceAlias: "inst", + queryable: true, + essential: true, + visibleByDefault: false, + hidden: true, + valueGetter: "( SELECT array_agg(elems.value->>'contributorTypeId') FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", + filterValueGetter: "( SELECT array_agg(lower(elems.value->>'contributorTypeId')) FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", + valueFunction: 'lower(:value)' + }, + { + name: 'contributor_type_text', + sourceAlias: 'inst', + dataType: { + dataType: 'arrayType', + itemDataType: { + dataType: 'stringType', + }, + }, + isIdColumn: false, + queryable: true, + essential: true, + visibleByDefault: false, + valueGetter: "( SELECT array_agg(elems.value->>'contributorTypeText') FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", + filterValueGetter: "( SELECT array_agg(lower(elems.value->>'contributorTypeText')) FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", + valueFunction: 'lower(:value)' + }, + { + name: "contributor_name_type_id", + dataType: { + dataType: "arrayType", + itemDataType: { + dataType: "rangedUUIDType" + } + }, + sourceAlias: "inst", + queryable: true, + essential: true, + visibleByDefault: false, + hidden: true, + valueGetter: "( SELECT array_agg(elems.value->>'contributorNameTypeId') FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", + filterValueGetter: "( SELECT array_agg(lower(elems.value->>'contributorNameTypeId')) FROM jsonb_array_elements(:sourceAlias.jsonb->'contributors') AS elems)", + valueFunction: 'lower(:value)' + }, + { + name: "contributor_name_type", + dataType: { + dataType: "arrayType", + itemDataType: { + dataType: "stringType" + } + }, + sourceAlias: "inst", + queryable: true, + essential: true, + visibleByDefault: false, + valueFunction: "lower(:value)", + valueGetter: "(SELECT array_agg(a.jsonb ->> 'name') FILTER (WHERE (a.jsonb ->> 'name') IS NOT NULL) AS array_agg FROM jsonb_array_elements((:sourceAlias.jsonb -> 'contributors') -> 'contributorNameTypeId') AS record(value) JOIN src_inventory_contributor_name_type aON (record.value::text) = a.id::text)", + filterValueGetter: "( SELECT array_agg(lower(a.jsonb ->> 'name'::text)) FILTER (WHERE (a.jsonb ->> 'name'::text) IS NOT NULL) AS array_agg FROM jsonb_array_elements_text((:sourceAlias.jsonb -> 'contributors'::text) ->> 'contributorNameTypeId'::text) record(value) JOIN src_inventory_contributor_name_type a ON (record.value::text) = a.id::text)", + }, + { + name: "instance_primary_contributor", + dataType: { + dataType: "stringType" + }, + valueGetter: "jsonb_path_query_first(:sourceAlias.jsonb, '$.\"contributors\"[*]?(@.\"primary\" == true).\"name\"'::jsonpath) #>> '{}'::text[]", + filterValueGetter: "jsonb_path_query_first(:sourceAlias.jsonb, '$.\"contributors\"[*]?(@.\"primary\" == true).\"name\"'::jsonpath) #>> '{}'::text[]", + valueFunction: "lower(:value)", + visibleByDefault: false, + queryable: false, + sourceAlias: "inst", + essential: true }, { name: 'subjects', diff --git a/translations/mod-fqm-manager/en.json b/translations/mod-fqm-manager/en.json index 0d149753..6997f5b1 100644 --- a/translations/mod-fqm-manager/en.json +++ b/translations/mod-fqm-manager/en.json @@ -643,17 +643,12 @@ "entityType.simple_instance.classifications.type_id": "Type UUID", "entityType.simple_instance.classifications.type_id._qualified": "Classification type UUID", "entityType.simple_instance.complete_updated_date": "Complete updated date", - "entityType.simple_instance.contributors": "Contributors", - "entityType.simple_instance.contributors.contributor_name_type_id": "Contributor name type UUID", - "entityType.simple_instance.contributors.contributor_name_type_id._qualified": "Contributors contributor name type UUID", - "entityType.simple_instance.contributors.contributor_type_id": "Contributor type UUID", - "entityType.simple_instance.contributors.contributor_type_id._qualified": "Contributors contributor type UUID", - "entityType.simple_instance.contributors.contributor_type_text": "Contributor type text", - "entityType.simple_instance.contributors.contributor_type_text._qualified": "Contributors contributor type text", - "entityType.simple_instance.contributors.name": "Name", - "entityType.simple_instance.contributors.name._qualified": "Contributors name", - "entityType.simple_instance.contributors.primary": "Primary", - "entityType.simple_instance.contributors.primary._qualified": "Contributors primary", + "entityType.simple_instance.contributor_type_id": "Contributor type UUID", + "entityType.simple_instance.contributors_name": "Contributor name", + "entityType.simple_instance.contributor_type_text": "Contributor type", + "entityType.simple_instance.contributor_name_type_id": "Contributor name type UUID", + "entityType.simple_instance.contributor_name_type": "Contributor name type", + "entityType.simple_instance.instance_primary_contributor": "Primary contributor", "entityType.simple_instance.created_at": "Created date", "entityType.simple_instance.created_by": "Created by user UUID", "entityType.simple_instance.discovery_suppress": "Discovery suppress", diff --git a/translations/mod-fqm-manager/en_US.json b/translations/mod-fqm-manager/en_US.json index 27d1312f..75e3e553 100644 --- a/translations/mod-fqm-manager/en_US.json +++ b/translations/mod-fqm-manager/en_US.json @@ -706,17 +706,12 @@ "entityType.simple_instance.classifications.type_id": "Type UUID", "entityType.simple_instance.classifications.type_id._qualified": "Classification type UUID", "entityType.simple_instance.complete_updated_date": "Complete updated date", - "entityType.simple_instance.contributors": "Contributors", - "entityType.simple_instance.contributors.contributor_name_type_id": "Contributor name type UUID", - "entityType.simple_instance.contributors.contributor_name_type_id._qualified": "Contributors contributor name type UUID", - "entityType.simple_instance.contributors.contributor_type_id": "Contributor type UUID", - "entityType.simple_instance.contributors.contributor_type_id._qualified": "Contributors contributor type UUID", - "entityType.simple_instance.contributors.contributor_type_text": "Contributor type text", - "entityType.simple_instance.contributors.contributor_type_text._qualified": "Contributors contributor type text", - "entityType.simple_instance.contributors.name": "Name", - "entityType.simple_instance.contributors.name._qualified": "Contributors name", - "entityType.simple_instance.contributors.primary": "Primary", - "entityType.simple_instance.contributors.primary._qualified": "Contributors primary", + "entityType.simple_instance.contributor_type_id": "Contributor type UUID", + "entityType.simple_instance.contributors_name": "Contributor name", + "entityType.simple_instance.contributor_type_text": "Contributor type", + "entityType.simple_instance.contributor_name_type_id": "Contributor name type UUID", + "entityType.simple_instance.contributor_name_type": "Contributor name type", + "entityType.simple_instance.instance_primary_contributor": "Primary contributor", "entityType.simple_instance.created_at": "Created date", "entityType.simple_instance.created_by": "Created by user UUID", "entityType.simple_instance.discovery_suppress": "Discovery suppress", @@ -1482,4 +1477,4 @@ "entityType.composite_purchase_order_lines._shortened": "POL", "entityType.simple_organization._shortened": "Orgs", "entityType.simple_instance.alternative_titles_ids": "Alternative titles - Type UUID" -} \ No newline at end of file +}