From 34451a5d221cab001b918ffe039bf8a97f2702bd Mon Sep 17 00:00:00 2001 From: Nick Budak Date: Mon, 3 Jun 2024 12:24:03 -0700 Subject: [PATCH] Ensure that locn_geometry is populated when migrating v1 to Aardvark Previously we were setting dcat_bbox but not locn_geometry based on the v1 solr_geom. The latter is also crucial, because we can't do spatial search or render previews without it. This ensures that we always populate locn_geometry if we had solr_geom, and then also fill in dcat_bbox if the geometry happens to be in the ENVELOPE() format. --- lib/geo_combine/migrators/v1_aardvark_migrator.rb | 7 ++++++- spec/fixtures/docs/full_geoblacklight_aardvark.json | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/geo_combine/migrators/v1_aardvark_migrator.rb b/lib/geo_combine/migrators/v1_aardvark_migrator.rb index 62c3e3f..e77da67 100644 --- a/lib/geo_combine/migrators/v1_aardvark_migrator.rb +++ b/lib/geo_combine/migrators/v1_aardvark_migrator.rb @@ -50,6 +50,7 @@ def convert_single_to_multi_valued_fields end # Convert non-crosswalked fields via lookup tables + # rubocop:disable Metrics/PerceivedComplexity def convert_non_crosswalked_fields # Keys may or may not include whitespace, so we normalize them. # Resource class is required so we default to "Other"; resource type is not required. @@ -57,6 +58,9 @@ def convert_non_crosswalked_fields resource_type = RESOURCE_TYPE_MAP[@v1_hash['layer_geom_type_s']&.gsub(/\s+/, '')] @v2_hash['gbl_resourceType_sm'] = resource_type unless resource_type.nil? + # If locn_geometry is in the ENVELOPE format, also add it as dcat_bbox + @v2_hash['dcat_bbox'] = @v2_hash['locn_geometry'] if @v2_hash['locn_geometry']&.match?(/ENVELOPE/) + # If the user specified a collection id map, use it to convert the collection names to ids is_part_of = @v1_hash['dct_isPartOf_sm']&.map { |name| @collection_id_map[name] }&.compact if is_part_of.present? @@ -65,6 +69,7 @@ def convert_non_crosswalked_fields @v2_hash.delete('dct_isPartOf_sm') end end + # rubocop:enable Metrics/PerceivedComplexity # Remove fields that are no longer used def remove_deprecated_fields @@ -80,7 +85,7 @@ def remove_deprecated_fields 'dc_publisher_s' => 'dct_publisher_sm', # new namespace; single to multi-valued 'dct_provenance_s' => 'schema_provider_s', # new URI name 'dc_subject_sm' => 'dct_subject_sm', # new namespace - 'solr_geom' => 'dcat_bbox', # new URI name + 'solr_geom' => 'locn_geometry', # new URI name 'solr_year_i' => 'gbl_indexYear_im', # new URI name; single to multi-valued 'dc_source_sm' => 'dct_source_sm', # new namespace 'dc_rights_s' => 'dct_accessRights_s', # new URI name diff --git a/spec/fixtures/docs/full_geoblacklight_aardvark.json b/spec/fixtures/docs/full_geoblacklight_aardvark.json index bc3f837..7a0b557 100644 --- a/spec/fixtures/docs/full_geoblacklight_aardvark.json +++ b/spec/fixtures/docs/full_geoblacklight_aardvark.json @@ -44,6 +44,7 @@ "stanford-rb371kw9607" ], "dcat_bbox":"ENVELOPE(29.572742, 35.000308, 4.234077, -1.478794)", + "locn_geometry":"ENVELOPE(29.572742, 35.000308, 4.234077, -1.478794)", "gbl_indexYear_im":[ 2005 ],