Skip to content

Commit

Permalink
Merge pull request #171 from OpenGeoMetadata/fix-geometry-crosswalk
Browse files Browse the repository at this point in the history
Ensure that locn_geometry is populated when migrating v1 to Aardvark
  • Loading branch information
eliotjordan authored Jun 3, 2024
2 parents b9fe396 + 34451a5 commit de84a31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/geo_combine/migrators/v1_aardvark_migrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ 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.
@v2_hash['gbl_resourceClass_sm'] = RESOURCE_CLASS_MAP[@v1_hash['dc_type_s']&.gsub(/\s+/, '')] || ['Other']
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?
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/docs/full_geoblacklight_aardvark.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down

0 comments on commit de84a31

Please sign in to comment.