geo_concerns 0.0.10 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.travis.yml +8 -4
- data/README.md +23 -8
- data/app/controllers/concerns/geo_concerns/messenger_behavior.rb +29 -0
- data/app/jobs/delivery_job.rb +15 -2
- data/app/jobs/geoblacklight_job.rb +10 -0
- data/app/models/concerns/geo_concerns/file_set/derivatives.rb +11 -9
- data/app/models/concerns/geo_concerns/solr_document_behavior.rb +5 -0
- data/app/presenters/geo_concerns/geo_concerns_show_presenter.rb +1 -1
- data/app/processors/geo_concerns/processors/base_geo_processor.rb +9 -24
- data/app/processors/geo_concerns/processors/image.rb +59 -0
- data/app/processors/geo_concerns/processors/ogr.rb +1 -1
- data/app/processors/geo_concerns/processors/raster.rb +18 -3
- data/app/processors/geo_concerns/processors/raster/base.rb +1 -0
- data/app/processors/geo_concerns/processors/rendering.rb +79 -0
- data/app/processors/geo_concerns/processors/vector.rb +16 -3
- data/app/processors/geo_concerns/processors/vector/base.rb +3 -2
- data/app/processors/geo_concerns/processors/vector/info.rb +21 -3
- data/app/services/geo_concerns/delivery/geoserver.rb +43 -6
- data/app/services/geo_concerns/discovery/abstract_document.rb +2 -1
- data/app/services/geo_concerns/discovery/document_builder.rb +2 -3
- data/app/services/geo_concerns/discovery/document_builder/basic_metadata_builder.rb +13 -2
- data/app/services/geo_concerns/discovery/document_builder/date_builder.rb +2 -0
- data/app/services/geo_concerns/discovery/document_builder/document_path.rb +12 -7
- data/app/services/geo_concerns/discovery/document_builder/references_builder.rb +20 -1
- data/app/services/geo_concerns/discovery/document_builder/spatial_builder.rb +2 -0
- data/app/services/geo_concerns/discovery/document_builder/wxs.rb +81 -0
- data/app/services/geo_concerns/discovery/geoblacklight_document.rb +9 -3
- data/app/services/geo_concerns/events_generator.rb +25 -0
- data/app/services/geo_concerns/events_generator/base_events_generator.rb +22 -0
- data/app/services/geo_concerns/events_generator/composite_generator.rb +18 -0
- data/app/services/geo_concerns/events_generator/geoblacklight_event_generator.rb +44 -0
- data/app/services/geo_concerns/events_generator/geoserver_event_generator.rb +30 -0
- data/app/services/geo_concerns/local_messaging_client.rb +18 -0
- data/app/services/geo_concerns/rabbit_messaging_client.rb +38 -0
- data/app/values/geo_concerns/time_period.rb +4 -5
- data/app/views/geo_concerns/_attribute_rows.html.erb +1 -0
- data/app/views/geo_concerns/_form_additional_information.html.erb +1 -0
- data/app/views/geo_concerns/file_sets/actions/_default_actions.html.erb +1 -1
- data/app/views/geo_concerns/file_sets/actions/_image_actions.html.erb +1 -1
- data/app/views/geo_concerns/file_sets/actions/_metadata_actions.html.erb +1 -1
- data/app/views/geo_concerns/file_sets/actions/_raster_actions.html.erb +2 -2
- data/app/views/geo_concerns/file_sets/actions/_vector_actions.html.erb +2 -2
- data/app/views/geo_concerns/file_sets/media_display/_geo.html.erb +2 -1
- data/docker-compose-full.yml +30 -0
- data/docker-compose.yml +4 -5
- data/geo_concerns.gemspec +5 -4
- data/lib/generators/geo_concerns/install_generator.rb +19 -25
- data/lib/generators/geo_concerns/templates/config/geoblacklight.yml +12 -0
- data/lib/generators/geo_concerns/templates/config/geoserver.yml +2 -0
- data/lib/generators/geo_concerns/templates/config/initializers/geoblacklight_config.rb +13 -0
- data/lib/generators/geo_concerns/templates/config/initializers/messaging_config.rb +34 -0
- data/lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb +65 -0
- data/lib/generators/geo_concerns/templates/config/messaging.yml +15 -0
- data/lib/generators/geo_concerns/templates/config/simpler_tiles.yml +24 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/file_sets_controller.rb +1 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/image_works_controller.rb +1 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/raster_works_controller.rb +1 -0
- data/lib/generators/geo_concerns/templates/controllers/curation_concerns/vector_works_controller.rb +1 -0
- data/lib/geo_concerns/version.rb +1 -1
- data/run-docker.sh +11 -1
- data/spec/controllers/file_sets_controller_spec.rb +50 -0
- data/spec/jobs/delivery_job_spec.rb +30 -7
- data/spec/models/concerns/geo_concerns/file_set/derivatives_spec.rb +9 -3
- data/spec/models/solr_document_spec.rb +6 -0
- data/spec/processors/geo_concerns/processors/base_geo_processor_spec.rb +15 -22
- data/spec/processors/geo_concerns/processors/image_spec.rb +71 -0
- data/spec/processors/geo_concerns/processors/rendering_spec.rb +64 -0
- data/spec/processors/geo_concerns/processors/vector/base_spec.rb +1 -1
- data/spec/processors/geo_concerns/processors/vector/info_spec.rb +10 -1
- data/spec/services/geo_concerns/delivery/geoserver_spec.rb +30 -6
- data/spec/services/{derivative_path_spec.rb → geo_concerns/derivative_path_spec.rb} +0 -0
- data/spec/services/geo_concerns/discovery/document_builder/wxs_spec.rb +69 -0
- data/spec/services/geo_concerns/discovery/document_builder_spec.rb +48 -32
- data/spec/services/geo_concerns/discovery/geoblacklight_document_spec.rb +1 -0
- data/spec/services/geo_concerns/events_generator/geoblacklight_event_generator_spec.rb +87 -0
- data/spec/services/geo_concerns/events_generator/geoserver_event_generator_spec.rb +40 -0
- data/spec/services/geo_concerns/local_messaging_client_spec.rb +35 -0
- data/spec/services/geo_concerns/rabbit_messaging_client_spec.rb +35 -0
- data/spec/services/{raster_format_service_spec.rb → geo_concerns/raster_format_service_spec.rb} +0 -0
- data/template.rb +1 -1
- metadata +85 -31
- data/app/processors/geo_concerns/processors/mapnik.rb +0 -35
- data/app/processors/geo_concerns/processors/raster/processor.rb +0 -26
- data/app/processors/geo_concerns/processors/vector/processor.rb +0 -24
- data/lib/generators/geo_concerns/templates/config/locales/geo_concerns.en.yml +0 -4
- data/lib/generators/geo_concerns/templates/config/mapnik.yml +0 -24
- data/spec/processors/geo_concerns/processors/mapnik_spec.rb +0 -70
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoConcerns::Processors::Image do
|
4
|
+
before do
|
5
|
+
class TestProcessor
|
6
|
+
include GeoConcerns::Processors::Image
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
after { Object.send(:remove_const, :TestProcessor) }
|
11
|
+
|
12
|
+
subject { TestProcessor.new }
|
13
|
+
|
14
|
+
let(:output_file_jpg) { 'output/geo.jpg' }
|
15
|
+
let(:output_file_png) { 'output/geo.png' }
|
16
|
+
let(:output_file) { output_file_png }
|
17
|
+
let(:file_name) { 'files/geo.tif' }
|
18
|
+
let(:options) { { output_size: '150 150' } }
|
19
|
+
|
20
|
+
describe '#convert' do
|
21
|
+
let(:image) { double }
|
22
|
+
|
23
|
+
before do
|
24
|
+
allow(MiniMagick::Image).to receive(:open).and_return(image)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'transforms the image and saves it as a PNG' do
|
28
|
+
expect(image).to receive(:format).with('png')
|
29
|
+
expect(image).to receive(:combine_options)
|
30
|
+
expect(image).to receive(:write).with(output_file_png)
|
31
|
+
subject.class.convert(file_name, output_file_png, options)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'transforms the image and saves it as a JPG' do
|
35
|
+
expect(image).to receive(:format).with('jpg')
|
36
|
+
expect(image).to receive(:combine_options)
|
37
|
+
expect(image).to receive(:write).with(output_file_jpg)
|
38
|
+
subject.class.convert(file_name, output_file_jpg, options)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#trim' do
|
43
|
+
let(:shell) { double }
|
44
|
+
let(:args) { [["convert", "files/geo.tif", "-trim", "output/geo.png"], { whiny: true }] }
|
45
|
+
|
46
|
+
before do
|
47
|
+
allow(MiniMagick::Shell).to receive(:new).and_return(shell)
|
48
|
+
end
|
49
|
+
it 'transforms the image and saves it as a PNG' do
|
50
|
+
expect(shell).to receive(:run).with(*args).and_return('output message')
|
51
|
+
subject.class.trim(file_name, output_file_png, options)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#center' do
|
56
|
+
let(:shell) { double }
|
57
|
+
let(:args) {
|
58
|
+
[['convert', '-size', '150x150', 'xc:white', 'files/geo.tif',
|
59
|
+
'-gravity', 'center', '-composite', 'output/geo.png'],
|
60
|
+
{ whiny: true }]
|
61
|
+
}
|
62
|
+
|
63
|
+
before do
|
64
|
+
allow(MiniMagick::Shell).to receive(:new).and_return(shell)
|
65
|
+
end
|
66
|
+
it 'transforms the image and saves it as a PNG' do
|
67
|
+
expect(shell).to receive(:run).with(*args).and_return('output message')
|
68
|
+
subject.class.center(file_name, output_file_png, options)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoConcerns::Processors::Rendering do
|
4
|
+
before do
|
5
|
+
class TestProcessor
|
6
|
+
include GeoConcerns::Processors::Rendering
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
after { Object.send(:remove_const, :TestProcessor) }
|
11
|
+
|
12
|
+
subject { TestProcessor.new }
|
13
|
+
|
14
|
+
let(:output_file) { 'output/geo.png' }
|
15
|
+
let(:file_name) { 'files' }
|
16
|
+
let(:options) { { output_size: '150 200' } }
|
17
|
+
let(:bounds) { { north: 40.0, east: -74.0, south: 40.0, west: -74.0 } }
|
18
|
+
let(:info) { instance_double(GeoConcerns::Processors::Vector::Info, name: 'test', bounds: bounds) }
|
19
|
+
let(:config) {
|
20
|
+
{
|
21
|
+
'stroke' => '#483d8b',
|
22
|
+
'line-cap' => 'square',
|
23
|
+
'line-join' => 'miter',
|
24
|
+
'weight' => '0.3',
|
25
|
+
'fill' => '#e4e3ea',
|
26
|
+
'radius' => '2'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
before do
|
31
|
+
allow(GeoConcerns::Processors::Vector::Info).to receive(:new).and_return(info)
|
32
|
+
allow(SimplerTiles.config).to receive(:to_h).and_return(config)
|
33
|
+
allow(SimplerTiles.config).to receive(:bg_color).and_return('#ffffff00')
|
34
|
+
allow(Dir).to receive(:glob).and_return(['test.shp'])
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#vector_thumbnail' do
|
38
|
+
it 'saves a vector thumbnail using simpler tiles' do
|
39
|
+
expect(File).to receive(:open).with(output_file, 'wb')
|
40
|
+
subject.class.vector_thumbnail(file_name, output_file, options)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#simple_tiles_map' do
|
45
|
+
subject { described_class.simple_tiles_map(file_name, options) }
|
46
|
+
|
47
|
+
it 'has a background color' do
|
48
|
+
expect(subject.bgcolor).to eq('#ffffff00')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'has a valid bounds property' do
|
52
|
+
expect(subject.bounds.to_wkt).to match(/-74.000000 40.000000/)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'has the correct width and height' do
|
56
|
+
expect(subject.width).to eq(150)
|
57
|
+
expect(subject.height).to eq(200)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'has a WGS 84 projection' do
|
61
|
+
expect(subject.srs).to eq('+proj=longlat +datum=WGS84 +no_defs ')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -28,7 +28,7 @@ describe GeoConcerns::Processors::Vector::Base do
|
|
28
28
|
|
29
29
|
describe '#encode_queue' do
|
30
30
|
it 'returns an array of command name symbols' do
|
31
|
-
expect(subject.class.encode_queue).to include :
|
31
|
+
expect(subject.class.encode_queue).to include :vector_thumbnail
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -9,7 +9,7 @@ describe GeoConcerns::Processors::Vector::Info do
|
|
9
9
|
|
10
10
|
context 'when initializing a new info class' do
|
11
11
|
it 'shells out to ogrinfo and sets the doc variable to the output string' do
|
12
|
-
expect(Open3).to receive(:capture3).with("ogrinfo #{path}")
|
12
|
+
expect(Open3).to receive(:capture3).with("ogrinfo -ro -so -al #{path}")
|
13
13
|
.and_return([info_doc, '', ''])
|
14
14
|
expect(subject.doc).to eq(info_doc)
|
15
15
|
end
|
@@ -37,5 +37,14 @@ describe GeoConcerns::Processors::Vector::Info do
|
|
37
37
|
expect(subject.geom).to eq('Polygon')
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
describe '#bounds' do
|
42
|
+
it 'returns bounds hash' do
|
43
|
+
expect(subject.bounds).to eq(north: 42.408249,
|
44
|
+
east: -71.052853,
|
45
|
+
south: 42.347654,
|
46
|
+
west: -71.163867)
|
47
|
+
end
|
48
|
+
end
|
40
49
|
end
|
41
50
|
end
|
@@ -34,6 +34,12 @@ describe GeoConcerns::Delivery::Geoserver do
|
|
34
34
|
expect(subject).to receive(:publish_vector)
|
35
35
|
subject.publish
|
36
36
|
end
|
37
|
+
|
38
|
+
it 'logs a message if there is an error' do
|
39
|
+
expect(subject).to receive(:publish_vector).and_raise(StandardError, 'error')
|
40
|
+
expect(Rails.logger).to receive(:error).with("GeoServer delivery job failed with: error")
|
41
|
+
subject.publish
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
45
|
context 'when type is raster' do
|
@@ -47,22 +53,30 @@ describe GeoConcerns::Delivery::Geoserver do
|
|
47
53
|
context 'when type is not a raster or vector' do
|
48
54
|
let(:path) { 'not-a-zip-or-tif' }
|
49
55
|
it 'raises an error' do
|
50
|
-
expect
|
56
|
+
expect(Rails.logger).to receive(:error).with(/Not a ZIPed Shapefile/)
|
57
|
+
subject.publish
|
51
58
|
end
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
55
62
|
describe '#publish_vector' do
|
56
63
|
context 'with a path to a zipped shapefile' do
|
64
|
+
let(:shapefile_path) { ['/spec/fixtures/files/shapefile/tufts-cambridgegrid100-04/tufts-cambridgegrid100-04.shp'] }
|
65
|
+
let(:url) { "file:////opt/geoserver/data_dir/derivatives#{shapefile_path.first}" }
|
57
66
|
let(:ws) { double }
|
58
67
|
let(:ds) { double }
|
59
68
|
|
69
|
+
before do
|
70
|
+
allow(Dir).to receive(:glob).and_return(shapefile_path)
|
71
|
+
allow(subject).to receive(:system).and_return(true)
|
72
|
+
end
|
73
|
+
|
60
74
|
it 'dispatches to RGeoServer' do
|
61
75
|
expect(RGeoServer::Workspace).to receive(:new).with(subject.catalog, hash_including(name: 'public')).and_return(ws)
|
62
76
|
expect(ws).to receive(:'new?').and_return(true)
|
63
77
|
expect(ws).to receive(:save)
|
64
78
|
expect(RGeoServer::DataStore).to receive(:new).with(subject.catalog, hash_including(workspace: ws, name: id)).and_return(ds)
|
65
|
-
expect(ds).to receive(:
|
79
|
+
expect(ds).to receive(:upload_external).with(url, hash_including(publish: true))
|
66
80
|
subject.send(:publish_vector)
|
67
81
|
end
|
68
82
|
end
|
@@ -70,15 +84,25 @@ describe GeoConcerns::Delivery::Geoserver do
|
|
70
84
|
|
71
85
|
describe '#publish_raster' do
|
72
86
|
let(:path) { 'spec/fixtures/files/S_566_1914_clip.tif' }
|
87
|
+
let(:url) { 'file:////opt/geoserver/data_dir/derivativesspec/fixtures/files/S_566_1914_clip.tif' }
|
73
88
|
let(:ws) { double }
|
74
89
|
let(:cs) { double }
|
90
|
+
let(:cov) { double }
|
75
91
|
|
76
92
|
it 'dispatches to RGeoServer' do
|
77
|
-
expect(RGeoServer::Workspace).to receive(:new).with(subject.catalog, hash_including(name: 'public')).and_return(ws)
|
78
|
-
expect(ws).to receive(:'new?').and_return(true)
|
79
|
-
expect(ws).to receive(:save)
|
93
|
+
expect(RGeoServer::Workspace).to receive(:new).with(subject.catalog, hash_including(name: 'public')).and_return(ws).twice
|
94
|
+
expect(ws).to receive(:'new?').and_return(true).twice
|
95
|
+
expect(ws).to receive(:save).twice
|
80
96
|
expect(RGeoServer::CoverageStore).to receive(:new).with(subject.catalog, hash_including(workspace: ws, name: id)).and_return(cs)
|
81
|
-
expect(cs).to receive(:
|
97
|
+
expect(cs).to receive(:name).and_return('abcdefg').at_least(:once)
|
98
|
+
expect(cs).to receive(:url=).with(url)
|
99
|
+
expect(cs).to receive(:enabled=).with('true')
|
100
|
+
expect(cs).to receive(:data_type=).with('GeoTIFF')
|
101
|
+
expect(cs).to receive(:save)
|
102
|
+
expect(RGeoServer::Coverage).to receive(:new).with(subject.catalog, hash_including(workspace: ws, coverage_store: cs, name: cs.name)).and_return(cov)
|
103
|
+
expect(cov).to receive(:title=).with(cs.name)
|
104
|
+
expect(cov).to receive(:metadata_links=).with([])
|
105
|
+
expect(cov).to receive(:save)
|
82
106
|
subject.send(:publish_raster)
|
83
107
|
end
|
84
108
|
end
|
File without changes
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoConcerns::Discovery::DocumentBuilder::Wxs do
|
4
|
+
subject { described_class.new(geo_concern_presenter) }
|
5
|
+
|
6
|
+
let(:geo_concern) { FactoryGirl.build(:public_vector_work, id: 'geo-work-1') }
|
7
|
+
let(:geo_concern_presenter) { GeoConcerns::VectorWorkShowPresenter.new(SolrDocument.new(geo_concern.to_solr), nil) }
|
8
|
+
let(:geo_file_mime_type) { 'application/zip; ogr-format="ESRI Shapefile"' }
|
9
|
+
let(:geo_file) { FileSet.new(id: 'geofile', geo_mime_type: geo_file_mime_type) }
|
10
|
+
let(:geo_file_presenter) { CurationConcerns::FileSetPresenter.new(SolrDocument.new(geo_file.to_solr), nil) }
|
11
|
+
let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC }
|
12
|
+
|
13
|
+
before do
|
14
|
+
allow(geo_file_presenter.solr_document).to receive(:visibility).and_return(visibility)
|
15
|
+
allow(geo_concern_presenter).to receive(:member_presenters).and_return([geo_file_presenter])
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#identifier' do
|
19
|
+
context 'public document' do
|
20
|
+
it 'returns a public identifier' do
|
21
|
+
expect(subject.identifier).to eq 'public:geofile'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'private document' do
|
26
|
+
let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
|
27
|
+
it 'returns a the fileset id' do
|
28
|
+
expect(subject.identifier).to eq 'geofile'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#wms_path' do
|
34
|
+
context 'public document' do
|
35
|
+
it 'returns a public wms path' do
|
36
|
+
expect(subject.wms_path).to eq 'http://localhost:8181/geoserver/public/wms'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'restricted document' do
|
41
|
+
let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED }
|
42
|
+
it 'returns a restricted value' do
|
43
|
+
expect(subject.wms_path).to eq 'http://localhost:8181/geoserver/restricted/wms'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'private document' do
|
48
|
+
let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
|
49
|
+
it 'returns a nil value' do
|
50
|
+
expect(subject.wms_path).to be_nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#wfs_path' do
|
56
|
+
context 'public document' do
|
57
|
+
it 'returns a valid wms path' do
|
58
|
+
expect(subject.wfs_path).to eq 'http://localhost:8181/geoserver/public/wfs'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'private document' do
|
63
|
+
let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
|
64
|
+
it 'returns a nil value' do
|
65
|
+
expect(subject.wfs_path).to be_nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -9,6 +9,7 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
9
9
|
let(:geo_concern_presenter) { GeoConcerns::VectorWorkShowPresenter.new(SolrDocument.new(geo_concern.to_solr), nil) }
|
10
10
|
let(:document_class) { GeoConcerns::Discovery::GeoblacklightDocument.new }
|
11
11
|
let(:document) { JSON.parse(subject.to_json(nil)) }
|
12
|
+
let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC }
|
12
13
|
let(:metadata__mime_type) { 'application/xml; schema=iso19139' }
|
13
14
|
let(:metadata_file) { FileSet.new(id: 'metadatafile', geo_mime_type: metadata__mime_type) }
|
14
15
|
let(:metadata_presenter) { CurationConcerns::FileSetPresenter.new(SolrDocument.new(metadata_file.to_solr), nil) }
|
@@ -28,22 +29,27 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
28
29
|
spatial: ['Micronesia'],
|
29
30
|
temporal: ['2011'],
|
30
31
|
subject: ['Human settlements'],
|
31
|
-
language: ['Esperanto']
|
32
|
+
language: ['Esperanto'],
|
33
|
+
identifier: ['ark:/99999/fk4'] }
|
32
34
|
}
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
before do
|
37
|
+
allow(geo_concern_presenter.solr_document).to receive(:visibility).and_return(visibility)
|
38
|
+
allow(geo_concern_presenter.solr_document).to receive(:representative_id).and_return(geo_file_presenter.id)
|
39
|
+
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
40
|
+
allow(geo_concern_presenter).to receive(:member_presenters).and_return([geo_file_presenter, metadata_presenter])
|
41
|
+
allow(geo_file_presenter.request).to receive_messages(host_with_port: 'localhost:3000', protocol: 'http://')
|
42
|
+
end
|
38
43
|
|
44
|
+
describe 'vector work' do
|
39
45
|
context 'required' do
|
40
46
|
it 'has all metadata' do
|
41
|
-
expect(document['dc_identifier_s']).to eq('
|
47
|
+
expect(document['dc_identifier_s']).to eq('ark:/99999/fk4')
|
42
48
|
expect(document['layer_slug_s']).to eq('your-institution-geo-work-1')
|
43
49
|
expect(document['dc_title_s']).to eq('Geo Work')
|
44
50
|
expect(document['solr_geom']).to eq('ENVELOPE(-71.032, -69.856, 43.039, 42.943)')
|
45
51
|
expect(document['dct_provenance_s']).to eq('Your Institution')
|
46
|
-
expect(document['dc_rights_s']).to eq('
|
52
|
+
expect(document['dc_rights_s']).to eq('Public')
|
47
53
|
expect(document['geoblacklight_version']).to eq('1.0')
|
48
54
|
end
|
49
55
|
end
|
@@ -98,10 +104,6 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
98
104
|
let(:geo_file_mime_type) { 'image/tiff; gdal-format=GTiff' }
|
99
105
|
let(:metadata__mime_type) { 'application/xml; schema=fgdc' }
|
100
106
|
|
101
|
-
before do
|
102
|
-
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
103
|
-
end
|
104
|
-
|
105
107
|
it 'has layer info fields' do
|
106
108
|
expect(document['layer_geom_type_s']).to eq('Raster')
|
107
109
|
expect(document['dc_format_s']).to eq('GeoTIFF')
|
@@ -117,10 +119,6 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
117
119
|
let(:geo_file_mime_type) { 'application/octet-stream; gdal-format=AIG' }
|
118
120
|
let(:metadata__mime_type) { 'application/mods+xml' }
|
119
121
|
|
120
|
-
before do
|
121
|
-
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
122
|
-
end
|
123
|
-
|
124
122
|
it 'has layer info fields' do
|
125
123
|
expect(document['dc_format_s']).to eq('ArcGRID')
|
126
124
|
end
|
@@ -139,8 +137,7 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
139
137
|
let(:geo_file_mime_type) { 'image/tiff' }
|
140
138
|
|
141
139
|
before do
|
142
|
-
|
143
|
-
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
140
|
+
allow(geo_concern_presenter).to receive(:description).and_return([])
|
144
141
|
end
|
145
142
|
|
146
143
|
it 'uses a default description' do
|
@@ -156,20 +153,18 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
156
153
|
|
157
154
|
context 'with a missing required metadata field' do
|
158
155
|
before do
|
159
|
-
|
160
|
-
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
156
|
+
allow(geo_concern_presenter).to receive(:coverage).and_return(nil)
|
161
157
|
end
|
162
158
|
|
163
159
|
it 'returns an error document' do
|
164
|
-
expect(document['error'][0]).to include('
|
160
|
+
expect(document['error'][0]).to include('solr_geom')
|
165
161
|
expect(document['error'].size).to eq(1)
|
166
162
|
end
|
167
163
|
end
|
168
164
|
|
169
165
|
context 'with a missing non-required metadata field' do
|
170
166
|
before do
|
171
|
-
|
172
|
-
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
167
|
+
allow(geo_concern_presenter).to receive(:language).and_return([])
|
173
168
|
end
|
174
169
|
|
175
170
|
it 'returns a document without the field but valid' do
|
@@ -177,25 +172,46 @@ describe GeoConcerns::Discovery::DocumentBuilder do
|
|
177
172
|
end
|
178
173
|
end
|
179
174
|
|
180
|
-
context 'with a
|
175
|
+
context 'with a missing temporal field' do
|
181
176
|
before do
|
182
|
-
|
183
|
-
allow(geo_concern_presenter).to receive(:file_set_presenters).and_return([geo_file_presenter, metadata_presenter])
|
184
|
-
allow(geo_concern_presenter.solr_document).to receive(:visibility).and_return(viz)
|
177
|
+
allow(geo_concern_presenter).to receive(:temporal).and_return([])
|
185
178
|
end
|
186
179
|
|
187
|
-
it '
|
188
|
-
expect(document['
|
180
|
+
it 'returns a document without the field but valid' do
|
181
|
+
expect(document['dct_temporal_sm']).to be_nil
|
189
182
|
end
|
190
183
|
end
|
191
184
|
|
192
|
-
context 'with
|
193
|
-
subject { described_class.new(geo_concern_presenter, document_class, ssl: true) }
|
194
|
-
|
185
|
+
context 'with a missing issued field' do
|
195
186
|
before do
|
196
|
-
allow(geo_concern_presenter).to receive(:
|
187
|
+
allow(geo_concern_presenter).to receive(:issued).and_return(nil)
|
197
188
|
end
|
198
189
|
|
190
|
+
it 'returns a document without the field but valid' do
|
191
|
+
expect(document['dct_issued_dt']).to be_nil
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context 'with an authenticated visibility' do
|
196
|
+
let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED }
|
197
|
+
|
198
|
+
it 'returns a restricted rights field value' do
|
199
|
+
expect(document['dc_rights_s']).to eq('Restricted')
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'with a private visibility' do
|
204
|
+
let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
|
205
|
+
|
206
|
+
it 'returns an empty document' do
|
207
|
+
expect(document).to eq({})
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context 'with ssl enabled' do
|
212
|
+
before do
|
213
|
+
allow(geo_file_presenter.request).to receive_messages(host_with_port: 'localhost:3000', protocol: 'https://')
|
214
|
+
end
|
199
215
|
it 'returns https reference urls' do
|
200
216
|
refs = JSON.parse(document['dct_references_s'])
|
201
217
|
expect(refs['http://schema.org/url']).to eq('https://localhost:3000/concern/vector_works/geo-work-1')
|