From b36a535ae5797ea5700055da42974a6147c7fa38 Mon Sep 17 00:00:00 2001 From: Stefano Maffei Date: Fri, 27 Oct 2023 12:40:34 +0200 Subject: [PATCH] [DSC-898] fix dc.date.accessioned during migration of CRIS entities --- .../dspace_cris_migration_post_import.kjb | 56 +- .../migration/update_dc_date_accessioned.ktr | 634 ++++++++++++++++++ 2 files changed, 686 insertions(+), 4 deletions(-) create mode 100644 dspace/etc/migration/update_dc_date_accessioned.ktr diff --git a/dspace/etc/migration/dspace_cris_migration_post_import.kjb b/dspace/etc/migration/dspace_cris_migration_post_import.kjb index b766c5d3723a..0c18927b5849 100644 --- a/dspace/etc/migration/dspace_cris_migration_post_import.kjb +++ b/dspace/etc/migration/dspace_cris_migration_post_import.kjb @@ -381,8 +381,8 @@ N Y 0 - 1448 - 112 + 1024 + 304 @@ -537,10 +537,49 @@ N Y 0 - 1290 + 1248 112 + + UPDATE dc_date_accessioned + + TRANS + + filename + + ${Internal.Entry.Current.Directory}/update_dc_date_accessioned.ktr + + N + N + N + N + N + N + + + N + N + Basic + N + + N + Y + N + N + N + Pentaho local + N + + Y + + N + Y + 1 + 1248 + 304 + + @@ -590,8 +629,17 @@ Migrate doi2item - Successo + UPDATE dc_date_accessioned 0 + 1 + Y + Y + N + + + UPDATE dc_date_accessioned + Successo + 1 0 Y Y diff --git a/dspace/etc/migration/update_dc_date_accessioned.ktr b/dspace/etc/migration/update_dc_date_accessioned.ktr new file mode 100644 index 000000000000..85be8c3c05b0 --- /dev/null +++ b/dspace/etc/migration/update_dc_date_accessioned.ktr @@ -0,0 +1,634 @@ + + + + udpate_dc_date_accessioned + + + + Normal + / + + + + + + + + + + + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + TRANSNAME + Y + TRANSNAME + + + STATUS + Y + STATUS + + + LINES_READ + Y + LINES_READ + + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + + LINES_UPDATED + Y + LINES_UPDATED + + + + LINES_INPUT + Y + LINES_INPUT + + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + + LINES_REJECTED + Y + LINES_REJECTED + + + + ERRORS + Y + ERRORS + + + STARTDATE + Y + STARTDATE + + + ENDDATE + Y + ENDDATE + + + LOGDATE + Y + LOGDATE + + + DEPDATE + Y + DEPDATE + + + REPLAYDATE + Y + REPLAYDATE + + + LOG_FIELD + Y + LOG_FIELD + + + EXECUTING_SERVER + N + EXECUTING_SERVER + + + EXECUTING_USER + N + EXECUTING_USER + + + CLIENT + N + CLIENT + + + + + +
+ + + + ID_BATCH + Y + ID_BATCH + + + SEQ_NR + Y + SEQ_NR + + + LOGDATE + Y + LOGDATE + + + TRANSNAME + Y + TRANSNAME + + + STEPNAME + Y + STEPNAME + + + STEP_COPY + Y + STEP_COPY + + + LINES_READ + Y + LINES_READ + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + LINES_UPDATED + Y + LINES_UPDATED + + + LINES_INPUT + Y + LINES_INPUT + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + LINES_REJECTED + Y + LINES_REJECTED + + + ERRORS + Y + ERRORS + + + INPUT_BUFFER_ROWS + Y + INPUT_BUFFER_ROWS + + + OUTPUT_BUFFER_ROWS + Y + OUTPUT_BUFFER_ROWS + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + LOGGING_OBJECT_TYPE + Y + LOGGING_OBJECT_TYPE + + + OBJECT_NAME + Y + OBJECT_NAME + + + OBJECT_COPY + Y + OBJECT_COPY + + + REPOSITORY_DIRECTORY + Y + REPOSITORY_DIRECTORY + + + FILENAME + Y + FILENAME + + + OBJECT_ID + Y + OBJECT_ID + + + OBJECT_REVISION + Y + OBJECT_REVISION + + + PARENT_CHANNEL_ID + Y + PARENT_CHANNEL_ID + + + ROOT_CHANNEL_ID + Y + ROOT_CHANNEL_ID + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + TRANSNAME + Y + TRANSNAME + + + STEPNAME + Y + STEPNAME + + + STEP_COPY + Y + STEP_COPY + + + LINES_READ + Y + LINES_READ + + + LINES_WRITTEN + Y + LINES_WRITTEN + + + LINES_UPDATED + Y + LINES_UPDATED + + + LINES_INPUT + Y + LINES_INPUT + + + LINES_OUTPUT + Y + LINES_OUTPUT + + + LINES_REJECTED + Y + LINES_REJECTED + + + ERRORS + Y + ERRORS + + + LOG_FIELD + N + LOG_FIELD + + + + + +
+ + + ID_BATCH + Y + ID_BATCH + + + CHANNEL_ID + Y + CHANNEL_ID + + + LOG_DATE + Y + LOG_DATE + + + METRICS_DATE + Y + METRICS_DATE + + + METRICS_CODE + Y + METRICS_CODE + + + METRICS_DESCRIPTION + Y + METRICS_DESCRIPTION + + + METRICS_SUBJECT + Y + METRICS_SUBJECT + + + METRICS_TYPE + Y + METRICS_TYPE + + + METRICS_VALUE + Y + METRICS_VALUE + + + + + +
+ + 0.0 + 0.0 + + 10000 + 50 + 50 + N + Y + 50000 + Y + + N + 1000 + 100 + + + + + + + + + - + 2021/07/23 16:30:09.987 + - + 2021/07/23 16:30:09.987 + H4sIAAAAAAAAAAMAAAAAAAAAAAA= + N + + + + + dspace + ${db_host_name} + POSTGRESQL + Native + ${db_name} + ${db_port_number} + ${db_username} + ${db_password} + + + + + + EXTRA_OPTION_POSTGRESQL.stringtype + unspecified + + + FORCE_IDENTIFIERS_TO_LOWERCASE + N + + + FORCE_IDENTIFIERS_TO_UPPERCASE + N + + + IS_CLUSTERED + N + + + PORT_NUMBER + ${db_port_number} + + + PRESERVE_RESERVED_WORD_CASE + Y + + + QUOTE_ALL_FIELDS + N + + + SUPPORTS_BOOLEAN_DATA_TYPE + Y + + + SUPPORTS_TIMESTAMP_DATA_TYPE + Y + + + USE_POOLING + N + + + + + + Generate rows + Execute SQL script + Y + + + + Execute SQL script + ExecSQL + + Y + + 1 + + none + + + dspace + N + Y + N + N +DO $$ +DECLARE + row_data record; + metadataFieldLegacyId INT; + metadataFieldDateId INT; + row_count integer := 0; +BEGIN + + SELECT m.metadata_field_id + INTO metadataFieldLegacyId + FROM metadatafieldregistry m JOIN metadataschemaregistry s + ON m.metadata_schema_id = s.metadata_schema_id + WHERE s.short_id = 'cris' AND m.element = 'legacyId'; + + SELECT m.metadata_field_id + INTO metadataFieldDateId + FROM metadatafieldregistry m JOIN metadataschemaregistry s + ON m.metadata_schema_id = s.metadata_schema_id + WHERE s.short_id = 'dc' AND m.element = 'date' AND m.qualifier = 'accessioned'; + + FOR row_data IN ( + SELECT m.dspace_object_id, d.timestampcreated + FROM old_cris_do d + JOIN metadatavalue m ON d.crisid = m.text_value + WHERE m.metadata_field_id = metadataFieldLegacyId + + UNION ALL + SELECT m.dspace_object_id, d.timestampcreated + FROM old_cris_rpage d + JOIN metadatavalue m ON d.crisid = m.text_value + WHERE m.metadata_field_id = metadataFieldLegacyId + + UNION ALL + SELECT m.dspace_object_id, d.timestampcreated + FROM old_cris_project d + JOIN metadatavalue m ON d.crisid = m.text_value + WHERE m.metadata_field_id = metadataFieldLegacyId + + UNION ALL + SELECT m.dspace_object_id, d.timestampcreated + FROM old_cris_orgunit d + JOIN metadatavalue m ON d.crisid = m.text_value + WHERE m.metadata_field_id = metadataFieldLegacyId + + ) + LOOP + UPDATE metadatavalue + SET text_value = TO_CHAR(row_data.timestampcreated, 'YYYY-MM-DD"T"HH24:MI:SS"Z"') + WHERE dspace_object_id = row_data.dspace_object_id + AND metadata_field_id = metadataFieldDateId; + + RAISE INFO 'Updating DSpace object with uuid %', row_data.dspace_object_id; + RAISE INFO 'New date is %', TO_CHAR(row_data.timestampcreated, 'YYYY-MM-DD"T"HH24:MI:SS"Z"'); + + row_count := row_count + 1; + END LOOP; + RAISE NOTICE 'Total items processed: %', row_count; +END $$; + + N + + + + + + + + + + + + + + + + 320 + 176 + Y + + + + Generate rows + RowGenerator + + Y + + 1 + + none + + + + + 1 + N + 5000 + now + FiveSecondsAgo + + + + + + + + + + 112 + 176 + Y + + + + + + + N + +