From ada53c2595a1884dd1b0080e8da23676d1004070 Mon Sep 17 00:00:00 2001 From: Matt Weaver Date: Fri, 4 Oct 2024 09:28:08 -0700 Subject: [PATCH] MODFQMMGR-497 Update instance date fields Inventory storage is removing the old publication period start/end date fields and replacing it with a more general 'dates' object. This commit removes the old publication_period_start/end fields from simple_instance and replaces them with a new simple entity type (simple_instance_date_type), which is joined with simple_instance in composite_instances. The old fields are being replaced in the DB, so we don't need to bother keeping the old field definitions around --- descriptors/ModuleDescriptor-template.json | 6 +- .../changes/v2.1.0/changelog-v2.1.0.xml | 11 ++++ .../inventory/composite_instances.json5 | 11 ++++ .../inventory/simple_instance.json5 | 21 +++++-- .../simple_instance_date_type.json5 | 63 +++++++++++++++++++ translations/mod-fqm-manager/en.json | 9 ++- 6 files changed, 114 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/entity-types/simple_instance_date_type.json5 diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 0be7693f2..28a629da7 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -234,7 +234,11 @@ }, { "id": "instance-storage", - "version": "10.0" + "version": "10.0 11.0" + }, + { + "id": "instance-date-types", + "version": "1.0" }, { "id": "instance-types", diff --git a/src/main/resources/db/changelog/changes/v2.1.0/changelog-v2.1.0.xml b/src/main/resources/db/changelog/changes/v2.1.0/changelog-v2.1.0.xml index de129b803..218bf0a03 100644 --- a/src/main/resources/db/changelog/changes/v2.1.0/changelog-v2.1.0.xml +++ b/src/main/resources/db/changelog/changes/v2.1.0/changelog-v2.1.0.xml @@ -189,4 +189,15 @@ + + + + + + SELECT * FROM ${tenant_id}_mod_inventory_storage.instance_date_type + + + diff --git a/src/main/resources/entity-types/inventory/composite_instances.json5 b/src/main/resources/entity-types/inventory/composite_instances.json5 index 9612faf79..6adbf9a6a 100644 --- a/src/main/resources/entity-types/inventory/composite_instances.json5 +++ b/src/main/resources/entity-types/inventory/composite_instances.json5 @@ -33,6 +33,17 @@ condition: ':this.id = :that.instanceTypeId', }, }, + { + alias: 'date_type', + type: 'entity-type', + id: '2d4bd468-720e-42b2-af41-8f4a9d7cb335', // simple_instance_date_type + essentialOnly: true, + join: { + type: 'left join', + joinTo: 'instance.inst', + condition: ":this.id = (:that.jsonb -> 'dates') ->> 'dateTypeId'", + }, + }, ], defaultSort: [ { diff --git a/src/main/resources/entity-types/inventory/simple_instance.json5 b/src/main/resources/entity-types/inventory/simple_instance.json5 index df5d5e2cc..630c39123 100644 --- a/src/main/resources/entity-types/inventory/simple_instance.json5 +++ b/src/main/resources/entity-types/inventory/simple_instance.json5 @@ -670,7 +670,19 @@ )", }, { - name: 'publication_period_start', + name: 'instance_date_1', + sourceAlias: 'inst', + essential: true, + dataType: { + dataType: 'dateType', + }, + isIdColumn: false, + queryable: true, + visibleByDefault: false, + valueGetter: ":sourceAlias.jsonb->'dates'->>'date1'", + }, + { + name: 'instance_date_2', sourceAlias: 'inst', essential: true, dataType: { @@ -679,10 +691,10 @@ isIdColumn: false, queryable: true, visibleByDefault: false, - valueGetter: ":sourceAlias.jsonb->'publicationPeriod'->>'start'", + valueGetter: ":sourceAlias.jsonb->'dates'->>'date1'", }, { - name: 'publication_period_end', + name: 'instance_date_type_id', sourceAlias: 'inst', essential: true, dataType: { @@ -690,8 +702,9 @@ }, isIdColumn: false, queryable: true, + hidden: true, visibleByDefault: false, - valueGetter: ":sourceAlias.jsonb->'publicationPeriod'->>'end'", + valueGetter: ":sourceAlias.jsonb->'date'->>'dateTypeId'", }, { name: 'electronic_access', diff --git a/src/main/resources/entity-types/simple_instance_date_type.json5 b/src/main/resources/entity-types/simple_instance_date_type.json5 new file mode 100644 index 000000000..e84a4373a --- /dev/null +++ b/src/main/resources/entity-types/simple_instance_date_type.json5 @@ -0,0 +1,63 @@ +{ + id: '2d4bd468-720e-42b2-af41-8f4a9d7cb335', + name: 'simple_instance_date_type', + sources: [ + { + alias: 'date_type', + type: 'db', + target: 'src_inventory_instance_date_type', + }, + ], + requiredPermissions: [ + 'inventory-storage.instance-date-types.collection.get', + ], + columns: [ + { + name: 'id', + dataType: { + dataType: 'rangedUUIDType', + }, + isIdColumn: true, + queryable: true, + hidden: true, + essential: true, + valueGetter: ':date_type.id', + }, + { + name: 'name', + dataType: { + dataType: 'stringType', + }, + idColumnName: 'id', + queryable: true, + essential: true, + valueGetter: ":date_type.jsonb ->> 'name'", + source: { + entityTypeId: '2d4bd468-720e-42b2-af41-8f4a9d7cb335', + columnName: 'name', + }, + valueSourceApi: { + path: 'instance-date-types', + valueJsonPath: '$.instanceDateTypes.*.id', + labelJsonPath: '$.instanceDateTypes.*.name', + }, + }, + { + name: 'code', + dataType: { + dataType: 'stringType', + }, + idColumnName: 'id', + queryable: true, + valueGetter: ":date_type.jsonb ->> 'code'", + source: { + entityTypeId: '2d4bd468-720e-42b2-af41-8f4a9d7cb335', + columnName: 'code', + }, + valueSourceApi: { + valueJsonPath: '$.instanceDateTypes.*.id', + labelJsonPath: '$.instanceDateTypes.*.code', + }, + }, + ], +} diff --git a/translations/mod-fqm-manager/en.json b/translations/mod-fqm-manager/en.json index f1e20c3dd..2a782f2b2 100644 --- a/translations/mod-fqm-manager/en.json +++ b/translations/mod-fqm-manager/en.json @@ -672,6 +672,9 @@ "entityType.simple_instance.identifiers.value._qualified": "Identifiers value", "entityType.simple_instance.index_title": "Index title", "entityType.simple_instance.instance_format_ids": "Instance format UUIDs", + "entityType.simple_instance.instance_date_1": "Date 1", + "entityType.simple_instance.instance_date_2": "Date 2", + "entityType.simple_instance.instance_date_type_id": "Date type ID", "entityType.simple_instance.instance_type_id": "Resource type UUID", "entityType.simple_instance.instance_type_name": "Resource type", "entityType.simple_instance.jsonb": "JSONB", @@ -699,8 +702,6 @@ "entityType.simple_instance.publication.role": "Role", "entityType.simple_instance.publication.role._qualified": "Publication role", "entityType.simple_instance.publication_frequency": "Publication frequency", - "entityType.simple_instance.publication_period_end": "Publication end year", - "entityType.simple_instance.publication_period_start": "Publication start year", "entityType.simple_instance.publication_range": "Publication range", "entityType.simple_instance.series": "Series", "entityType.simple_instance.shared": "Shared", @@ -718,6 +719,10 @@ "entityType.simple_instance.updated_at": "Updated date", "entityType.simple_instance.updated_by": "Updated by user UUID", "entityType.simple_instance.version": "Record version", + "entityType.simple_instance_date_type": "Instance date type", + "entityType.simple_instance_date_type.id": "ID", + "entityType.simple_instance_date_type.name": "Name", + "entityType.simple_instance_date_type.code": "Code", "entityType.simple_instance_status": "Instance status name", "entityType.simple_instance_status.code": "Code", "entityType.simple_instance_status.created_by_user_id": "Created by user UUID",