Skip to content

Commit

Permalink
Sketch initial migrator for v1 to aardvark
Browse files Browse the repository at this point in the history
Note that the fixture called aardvark hasn't actually been converted
yet, is just a straight up copy of the full_geoblacklight fixutre

refs #121
  • Loading branch information
hackartisan committed Feb 25, 2022
1 parent c62a0d3 commit aadfc78
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/geo_combine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def to_html
# Require harvesting/indexing files
require 'geo_combine/geo_blacklight_harvester'

# Migrators
require 'geo_combine/migrators/v1_aardvark_migrator'

# Require gem files
require 'geo_combine/version'
require 'geo_combine/railtie' if defined?(Rails)
19 changes: 19 additions & 0 deletions lib/geo_combine/migrators/v1_aardvark_migrator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module GeoCombine
module Migrators
# migrates the v1 schema to the aardvark schema
class V1AardvarkMigrator
attr_reader :v1_hash

# @param v1_hash [Hash] parsed json in the v1 schema
def initialize(v1_hash:)
@v1_hash = v1_hash
end

def run
v1_hash
end
end
end
end
33 changes: 33 additions & 0 deletions spec/fixtures/docs/full_geoblacklight_aardvark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"geoblacklight_version":"1.0",
"dc_identifier_s":"http://purl.stanford.edu/cz128vq0535",
"dc_title_s":"2005 Rural Poverty GIS Database: Uganda",
"dc_description_s":"This polygon shapefile contains 2005 poverty data for 855 rural subcounties in Uganda. These data are intended for researchers, students, policy makers and the general public for reference and mapping purposes, and may be used for basic applications such as viewing, querying, and map output production.",
"dc_rights_s":"Public",
"dct_provenance_s":"Stanford",
"dct_references_s":"{\"http://schema.org/url\":\"http://purl.stanford.edu/cz128vq0535\",\"http://schema.org/downloadUrl\":\"http://stacks.stanford.edu/file/druid:cz128vq0535/data.zip\",\"http://www.loc.gov/mods/v3\":\"http://purl.stanford.edu/cz128vq0535.mods\",\"http://www.isotc211.org/schemas/2005/gmd/\":\"http://opengeometadata.stanford.edu/metadata/edu.stanford.purl/druid:cz128vq0535/iso19139.xml\",\"http://www.w3.org/1999/xhtml\":\"http://opengeometadata.stanford.edu/metadata/edu.stanford.purl/druid:cz128vq0535/default.html\",\"http://www.opengis.net/def/serviceType/ogc/wfs\":\"https://geowebservices.stanford.edu/geoserver/wfs\",\"http://www.opengis.net/def/serviceType/ogc/wms\":\"https://geowebservices.stanford.edu/geoserver/wms\"}",
"layer_id_s":"druid:cz128vq0535",
"layer_slug_s":"stanford-cz128vq0535",
"layer_geom_type_s":"Polygon",
"layer_modified_dt":"2015-01-13T18:46:38Z",
"dc_format_s":"Shapefile",
"dc_language_s":"English",
"dc_type_s":"Dataset",
"dc_publisher_s":"Uganda Bureau of Statistics",
"dc_creator_sm":[
"Uganda Bureau of Statistics"
],
"dc_subject_sm":[
"Poverty",
"Statistics"
],
"dct_issued_s":"2005",
"dct_temporal_sm":[
"2005"
],
"dct_spatial_sm":[
"Uganda"
],
"solr_geom":"ENVELOPE(29.572742, 35.000308, 4.234077, -1.478794)",
"solr_year_i":2005
}
6 changes: 6 additions & 0 deletions spec/fixtures/json_docs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ def full_geoblacklight
File.read(File.join(File.dirname(__FILE__), './docs/full_geoblacklight.json'))
end

##
# full_geoblacklight fixture converted to the aardvark schema
def full_geoblacklight_aardvark
File.read(File.join(File.dirname(__FILE__), './docs/full_geoblacklight_aardvark.json'))
end

##
# A sample Esri OpenData metadata record
def esri_opendata_metadata
Expand Down
15 changes: 15 additions & 0 deletions spec/lib/geo_combine/migrators/v1_aardvark_migrator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe GeoCombine::Migrators::V1AardvarkMigrator do
include JsonDocs

describe '#run' do
it 'migrates keys' do
input_hash = JSON.parse(full_geoblacklight)
expected_output = JSON.parse(full_geoblacklight_aardvark)
expect(described_class.new(v1_hash: input_hash).run).to eq(expected_output)
end
end
end

0 comments on commit aadfc78

Please sign in to comment.