Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that locn_geometry is populated when migrating v1 to Aardvark #171

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading