Skip to content

Commit

Permalink
MODFQMMGR-471: Instance-contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
kjain110 committed Sep 27, 2024
1 parent 5280cfa commit df52892
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -438,20 +440,6 @@ public Map<UUID, Function<String, EntityTypeWarning>> getEntityTypeWarnings() {
@Override
public Map<UUID, Map<String, BiFunction<String, String, FieldWarning>>> 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(
Expand Down
157 changes: 86 additions & 71 deletions src/main/resources/entity-types/inventory/simple_instance.json5
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
17 changes: 6 additions & 11 deletions translations/mod-fqm-manager/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 7 additions & 12 deletions translations/mod-fqm-manager/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}

0 comments on commit df52892

Please sign in to comment.