Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
Fix Geoblacklight document generation (#891)
Browse files Browse the repository at this point in the history
* set different provenance for geoblacklight documents

* upgrade to geo_concerns v0.3.3
  • Loading branch information
eliotjordan authored and tampakis committed Dec 16, 2016
1 parent a4fe9c2 commit 224d30f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ gem 'rsolr', '~> 1.1.0'
gem 'devise', '~> 3.0'
gem 'devise-guests', '~> 0.3'
gem 'iiif-presentation', github: 'iiif/osullivan', branch: 'development'
gem 'geo_concerns', '~> 0.3.2'
gem 'geo_concerns', '~> 0.3.3'

# PDF generation
gem 'prawn'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ GEM
ffi (1.9.14)
font-awesome-rails (4.7.0.0)
railties (>= 3.2, < 5.1)
geo_concerns (0.3.2)
geo_concerns (0.3.3)
bunny
curation_concerns (>= 1.6)
geoblacklight_messaging
Expand Down Expand Up @@ -750,7 +750,7 @@ DEPENDENCIES
ezid-client
factory_girl_rails
fcrepo_wrapper (~> 0.6.0)
geo_concerns (~> 0.3.2)
geo_concerns (~> 0.3.3)
hydra-derivatives (= 3.1.3)
hydra-pcdm!
hydra-role-management (~> 0.2.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ def initialize(geo_concern)
end

def build(document)
document.provenance = provenance
document.slug = slug
end

# Overrides the geo_concerns provenance to match
# match existing geoblacklight metadata.
def provenance
Plum.config[:geoblacklight_provenance]
end

# Returns the document slug for use in discovery systems.
# @return [String] document slug
def slug
identifier = geo_concern.identifier || geo_concern.id
id = identifier.gsub(%r(ark:/\d{5}/), '')
return id unless geo_concern.provenance
"#{geo_concern.provenance.parameterize}-#{id}"
"#{provenance.parameterize}-#{id}"
end
end
end
Expand Down
1 change: 1 addition & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ defaults: &defaults
server: 'amqp://localhost:5672'
exchange: 'plum_events'
geo_derivatives_path: <%= File.join(Rails.root, 'tmp', 'geo-derivatives') %>
geoblacklight_provenance: 'Princeton'

development:
<<: *defaults
Expand Down
28 changes: 11 additions & 17 deletions spec/services/geo_concerns/slug_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,19 @@
describe GeoConcerns::Discovery::DocumentBuilder::SlugBuilder do
subject { described_class.new(geo_concern_presenter) }

let(:document) { instance_double('Document') }
let(:plum_config) { { geoblacklight_provenance: 'Princeton' } }
let(:geo_concern_presenter) { GeoConcerns::VectorWorkShowPresenter.new(SolrDocument.new(geo_concern.to_solr), nil) }
let(:geo_concern) { FactoryGirl.build(:vector_work, attributes) }
let(:attributes) { { id: 'geo-work-1',
title: ['Geo Work'],
description: ['This is a Geo Work'],
creator: ['Yosiwo George'],
publisher: ['National Geographic'],
spatial: ['Micronesia'],
temporal: ['2011'],
subject: ['Human settlements'],
language: ['Esperanto'],
identifier: 'ark:/99999/fk4'
}
}
let(:geo_concern) { FactoryGirl.build(:vector_work, identifier: 'ark:/99999/fk4') }

describe 'vector work slug' do
it 'uses ark noid fowlling the provenance' do
document = instance_double('Document')
expect(document).to receive(:slug=).with('princeton-university-library-fk4')
before do
allow(Plum).to receive(:config).and_return(plum_config)
end

describe 'vector work document' do
it 'creates a slug with an ark noid and uses a locally configured provenance' do
expect(document).to receive(:provenance=).with('Princeton')
expect(document).to receive(:slug=).with('princeton-fk4')
subject.build(document)
end
end
Expand Down

0 comments on commit 224d30f

Please sign in to comment.