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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.travis.yml +8 -4
  4. data/README.md +23 -8
  5. data/app/controllers/concerns/geo_concerns/messenger_behavior.rb +29 -0
  6. data/app/jobs/delivery_job.rb +15 -2
  7. data/app/jobs/geoblacklight_job.rb +10 -0
  8. data/app/models/concerns/geo_concerns/file_set/derivatives.rb +11 -9
  9. data/app/models/concerns/geo_concerns/solr_document_behavior.rb +5 -0
  10. data/app/presenters/geo_concerns/geo_concerns_show_presenter.rb +1 -1
  11. data/app/processors/geo_concerns/processors/base_geo_processor.rb +9 -24
  12. data/app/processors/geo_concerns/processors/image.rb +59 -0
  13. data/app/processors/geo_concerns/processors/ogr.rb +1 -1
  14. data/app/processors/geo_concerns/processors/raster.rb +18 -3
  15. data/app/processors/geo_concerns/processors/raster/base.rb +1 -0
  16. data/app/processors/geo_concerns/processors/rendering.rb +79 -0
  17. data/app/processors/geo_concerns/processors/vector.rb +16 -3
  18. data/app/processors/geo_concerns/processors/vector/base.rb +3 -2
  19. data/app/processors/geo_concerns/processors/vector/info.rb +21 -3
  20. data/app/services/geo_concerns/delivery/geoserver.rb +43 -6
  21. data/app/services/geo_concerns/discovery/abstract_document.rb +2 -1
  22. data/app/services/geo_concerns/discovery/document_builder.rb +2 -3
  23. data/app/services/geo_concerns/discovery/document_builder/basic_metadata_builder.rb +13 -2
  24. data/app/services/geo_concerns/discovery/document_builder/date_builder.rb +2 -0
  25. data/app/services/geo_concerns/discovery/document_builder/document_path.rb +12 -7
  26. data/app/services/geo_concerns/discovery/document_builder/references_builder.rb +20 -1
  27. data/app/services/geo_concerns/discovery/document_builder/spatial_builder.rb +2 -0
  28. data/app/services/geo_concerns/discovery/document_builder/wxs.rb +81 -0
  29. data/app/services/geo_concerns/discovery/geoblacklight_document.rb +9 -3
  30. data/app/services/geo_concerns/events_generator.rb +25 -0
  31. data/app/services/geo_concerns/events_generator/base_events_generator.rb +22 -0
  32. data/app/services/geo_concerns/events_generator/composite_generator.rb +18 -0
  33. data/app/services/geo_concerns/events_generator/geoblacklight_event_generator.rb +44 -0
  34. data/app/services/geo_concerns/events_generator/geoserver_event_generator.rb +30 -0
  35. data/app/services/geo_concerns/local_messaging_client.rb +18 -0
  36. data/app/services/geo_concerns/rabbit_messaging_client.rb +38 -0
  37. data/app/values/geo_concerns/time_period.rb +4 -5
  38. data/app/views/geo_concerns/_attribute_rows.html.erb +1 -0
  39. data/app/views/geo_concerns/_form_additional_information.html.erb +1 -0
  40. data/app/views/geo_concerns/file_sets/actions/_default_actions.html.erb +1 -1
  41. data/app/views/geo_concerns/file_sets/actions/_image_actions.html.erb +1 -1
  42. data/app/views/geo_concerns/file_sets/actions/_metadata_actions.html.erb +1 -1
  43. data/app/views/geo_concerns/file_sets/actions/_raster_actions.html.erb +2 -2
  44. data/app/views/geo_concerns/file_sets/actions/_vector_actions.html.erb +2 -2
  45. data/app/views/geo_concerns/file_sets/media_display/_geo.html.erb +2 -1
  46. data/docker-compose-full.yml +30 -0
  47. data/docker-compose.yml +4 -5
  48. data/geo_concerns.gemspec +5 -4
  49. data/lib/generators/geo_concerns/install_generator.rb +19 -25
  50. data/lib/generators/geo_concerns/templates/config/geoblacklight.yml +12 -0
  51. data/lib/generators/geo_concerns/templates/config/geoserver.yml +2 -0
  52. data/lib/generators/geo_concerns/templates/config/initializers/geoblacklight_config.rb +13 -0
  53. data/lib/generators/geo_concerns/templates/config/initializers/messaging_config.rb +34 -0
  54. data/lib/generators/geo_concerns/templates/config/initializers/simpler_tiles.rb +65 -0
  55. data/lib/generators/geo_concerns/templates/config/messaging.yml +15 -0
  56. data/lib/generators/geo_concerns/templates/config/simpler_tiles.yml +24 -0
  57. data/lib/generators/geo_concerns/templates/controllers/curation_concerns/file_sets_controller.rb +1 -0
  58. data/lib/generators/geo_concerns/templates/controllers/curation_concerns/image_works_controller.rb +1 -0
  59. data/lib/generators/geo_concerns/templates/controllers/curation_concerns/raster_works_controller.rb +1 -0
  60. data/lib/generators/geo_concerns/templates/controllers/curation_concerns/vector_works_controller.rb +1 -0
  61. data/lib/geo_concerns/version.rb +1 -1
  62. data/run-docker.sh +11 -1
  63. data/spec/controllers/file_sets_controller_spec.rb +50 -0
  64. data/spec/jobs/delivery_job_spec.rb +30 -7
  65. data/spec/models/concerns/geo_concerns/file_set/derivatives_spec.rb +9 -3
  66. data/spec/models/solr_document_spec.rb +6 -0
  67. data/spec/processors/geo_concerns/processors/base_geo_processor_spec.rb +15 -22
  68. data/spec/processors/geo_concerns/processors/image_spec.rb +71 -0
  69. data/spec/processors/geo_concerns/processors/rendering_spec.rb +64 -0
  70. data/spec/processors/geo_concerns/processors/vector/base_spec.rb +1 -1
  71. data/spec/processors/geo_concerns/processors/vector/info_spec.rb +10 -1
  72. data/spec/services/geo_concerns/delivery/geoserver_spec.rb +30 -6
  73. data/spec/services/{derivative_path_spec.rb → geo_concerns/derivative_path_spec.rb} +0 -0
  74. data/spec/services/geo_concerns/discovery/document_builder/wxs_spec.rb +69 -0
  75. data/spec/services/geo_concerns/discovery/document_builder_spec.rb +48 -32
  76. data/spec/services/geo_concerns/discovery/geoblacklight_document_spec.rb +1 -0
  77. data/spec/services/geo_concerns/events_generator/geoblacklight_event_generator_spec.rb +87 -0
  78. data/spec/services/geo_concerns/events_generator/geoserver_event_generator_spec.rb +40 -0
  79. data/spec/services/geo_concerns/local_messaging_client_spec.rb +35 -0
  80. data/spec/services/geo_concerns/rabbit_messaging_client_spec.rb +35 -0
  81. data/spec/services/{raster_format_service_spec.rb → geo_concerns/raster_format_service_spec.rb} +0 -0
  82. data/template.rb +1 -1
  83. metadata +85 -31
  84. data/app/processors/geo_concerns/processors/mapnik.rb +0 -35
  85. data/app/processors/geo_concerns/processors/raster/processor.rb +0 -26
  86. data/app/processors/geo_concerns/processors/vector/processor.rb +0 -24
  87. data/lib/generators/geo_concerns/templates/config/locales/geo_concerns.en.yml +0 -4
  88. data/lib/generators/geo_concerns/templates/config/mapnik.yml +0 -24
  89. data/spec/processors/geo_concerns/processors/mapnik_spec.rb +0 -70
@@ -1,10 +1,23 @@
1
1
  module GeoConcerns
2
2
  module Processors
3
3
  module Vector
4
- extend ActiveSupport::Autoload
4
+ class Processor < Hydra::Derivatives::Processors::Processor
5
+ def process
6
+ vector_processor_class.new(source_path,
7
+ directives,
8
+ output_file_service: output_file_service).process
9
+ end
5
10
 
6
- eager_autoload do
7
- autoload :Processor
11
+ # Returns a vector processor class based on mime type passed in the directives object.
12
+ # @return vector processing class
13
+ def vector_processor_class
14
+ case directives.fetch(:input_format)
15
+ when 'application/zip; ogr-format="ESRI Shapefile"'
16
+ GeoConcerns::Processors::Vector::Shapefile
17
+ else
18
+ GeoConcerns::Processors::Vector::Base
19
+ end
20
+ end
8
21
  end
9
22
  end
10
23
  end
@@ -4,9 +4,10 @@ module GeoConcerns
4
4
  class Base < Hydra::Derivatives::Processors::Processor
5
5
  include Hydra::Derivatives::Processors::ShellBasedProcessor
6
6
  include GeoConcerns::Processors::BaseGeoProcessor
7
+ include GeoConcerns::Processors::Image
7
8
  include GeoConcerns::Processors::Ogr
8
9
  include GeoConcerns::Processors::Gdal
9
- include GeoConcerns::Processors::Mapnik
10
+ include GeoConcerns::Processors::Rendering
10
11
  include GeoConcerns::Processors::Zip
11
12
 
12
13
  def self.encode(path, options, output_file)
@@ -21,7 +22,7 @@ module GeoConcerns
21
22
  # Set of commands to run to encode the vector thumbnail.
22
23
  # @return [Array] set of command name symbols
23
24
  def self.encode_queue
24
- [:reproject, :mapnik_vector_thumbnail]
25
+ [:reproject, :vector_thumbnail, :trim, :center]
25
26
  end
26
27
 
27
28
  # Set of commands to run to reproject the vector.
@@ -27,13 +27,19 @@ module GeoConcerns
27
27
  @geom = vector_geom
28
28
  end
29
29
 
30
+ # Returns vector bounds
31
+ # @return [String] bounds
32
+ def bounds
33
+ @bounds = vector_bounds
34
+ end
35
+
30
36
  private
31
37
 
32
38
  # Runs the ogrinfo command and returns the result as a string.
33
39
  # @param path [String] path to vector file or shapefile directory
34
40
  # @return [String] output of ogrinfo
35
41
  def ogrinfo(path)
36
- stdout, _stderr, _status = Open3.capture3("ogrinfo #{path}")
42
+ stdout, _stderr, _status = Open3.capture3("ogrinfo -ro -so -al #{path}")
37
43
  stdout
38
44
  end
39
45
 
@@ -41,7 +47,7 @@ module GeoConcerns
41
47
  # the vector dataset name.
42
48
  # @return [String] vector dataset name
43
49
  def vector_name
44
- match = /(?<=\d:\s).*?((?=\s)|($))/.match(doc)
50
+ match = /(?<=Layer name:\s).*?(?=\n)/.match(doc)
45
51
  match ? match[0] : ''
46
52
  end
47
53
 
@@ -57,9 +63,21 @@ module GeoConcerns
57
63
  # the vector geometry type.
58
64
  # @return [String] vector geom
59
65
  def vector_geom
60
- match = /(?<=\().*?(?=\))/.match(doc)
66
+ match = /(?<=Geometry:\s).*?(?=\n)/.match(doc)
61
67
  match ? match[0] : ''
62
68
  end
69
+
70
+ # Given an output string from the ogrinfo command, returns
71
+ # the vector bounding box.
72
+ # @return [Hash] vector bounds
73
+ def vector_bounds
74
+ match = /(?<=Extent:\s).*?(?=\n)/.match(doc)
75
+ extent = match ? match[0] : ''
76
+
77
+ # remove parens and spaces, split into array, and assign elements to variables
78
+ w, s, e, n = extent.delete(' ').gsub(')-(', ',').delete('(').delete(')').split(',')
79
+ { north: n.to_f, east: e.to_f, south: s.to_f, west: w.to_f }
80
+ end
63
81
  end
64
82
  end
65
83
  end
@@ -27,6 +27,8 @@ module GeoConcerns
27
27
  when :raster
28
28
  publish_raster
29
29
  end
30
+ rescue StandardError => e
31
+ Rails.logger.error("GeoServer delivery job failed with: #{e}")
30
32
  end
31
33
 
32
34
  private
@@ -62,19 +64,54 @@ module GeoConcerns
62
64
  end
63
65
 
64
66
  def datastore
65
- RGeoServer::DataStore.new catalog, workspace: workspace, name: file_set.id
67
+ @datastore ||= RGeoServer::DataStore.new catalog, workspace: workspace,
68
+ name: file_set.id
66
69
  end
67
70
 
68
- def publish_vector
69
- datastore.upload_file file_path, publish: true
71
+ def coveragestore
72
+ @coveragestore ||= RGeoServer::CoverageStore.new catalog, workspace: workspace,
73
+ name: file_set.id
70
74
  end
71
75
 
72
- def coveragestore
73
- RGeoServer::CoverageStore.new catalog, workspace: workspace, name: file_set.id
76
+ def base_path(path)
77
+ path.gsub(CurationConcerns.config.derivatives_path, '')
78
+ end
79
+
80
+ def persist_coveragestore
81
+ url = "file:///#{@config[:derivatives_path]}#{base_path(file_path)}"
82
+ coveragestore.url = url
83
+ coveragestore.enabled = 'true'
84
+ coveragestore.data_type = 'GeoTIFF'
85
+ coveragestore.save
86
+ end
87
+
88
+ def persist_coverage
89
+ coverage = RGeoServer::Coverage.new catalog, workspace: workspace,
90
+ coverage_store: coveragestore,
91
+ name: coveragestore.name
92
+ coverage.title = coveragestore.name
93
+ coverage.metadata_links = []
94
+ coverage.save
95
+ end
96
+
97
+ def publish_vector
98
+ shapefile_dir = "#{File.dirname(file_path)}/shapefile"
99
+
100
+ # Delete existing shapefile
101
+ FileUtils.rm_rf(shapefile_dir)
102
+
103
+ # Unzip derivative shapefiles
104
+ system "unzip -o #{file_path} -d #{shapefile_dir}"
105
+
106
+ shape_path = Dir.glob("#{shapefile_dir}/*.shp").first
107
+ raise Errno::ENOENT, 'Shapefile not found' unless shape_path
108
+ url = "file:///#{@config[:derivatives_path]}#{base_path(shape_path)}"
109
+ datastore.upload_external url, publish: true
74
110
  end
75
111
 
76
112
  def publish_raster
77
- coveragestore.upload file_path
113
+ persist_coveragestore
114
+ persist_coverage
78
115
  end
79
116
  end
80
117
  end
@@ -5,7 +5,8 @@ module GeoConcerns
5
5
  :title, :description, :access_rights, :language, :issued,
6
6
  :publisher, :slug, :solr_coverage, :layer_year,
7
7
  :layer_modified, :geom_type, :format, :resource_type, :wxs_identifier,
8
- :dct_references, :fgdc, :iso19139, :mods, :download, :url, :thumbnail
8
+ :dct_references, :fgdc, :iso19139, :mods, :download, :url, :thumbnail,
9
+ :wxs_identifier, :wms_path, :wfs_path
9
10
 
10
11
  # Cleans the document hash by removing unused fields.
11
12
  # @param [Hash] document hash
@@ -4,17 +4,16 @@ module GeoConcerns
4
4
  attr_reader :geo_concern, :document
5
5
  delegate :to_json, :to_xml, :to_hash, to: :document
6
6
 
7
- def initialize(geo_concern, document, ssl: false)
7
+ def initialize(geo_concern, document)
8
8
  @geo_concern = geo_concern
9
9
  @document = document
10
- @ssl = ssl
11
10
  builders.build(document)
12
11
  end
13
12
 
14
13
  # Returns a document path object. Used to get urls for links in the document.
15
14
  # @return [DocumentPath] geoblacklight document as a json string
16
15
  def root_path
17
- @root_path ||= DocumentPath.new(geo_concern, ssl: @ssl)
16
+ @root_path ||= DocumentPath.new(geo_concern)
18
17
  end
19
18
 
20
19
  # Instantiates a CompositeBuilder object with an array of
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Workaround for setting the identifier in the geoblacklight document
3
+ # Remove once
1
4
  module GeoConcerns
2
5
  module Discovery
3
6
  class DocumentBuilder
@@ -35,13 +38,21 @@ module GeoConcerns
35
38
  # Builds more complex metadata attributes.
36
39
  # @param [AbstractDocument] discovery document
37
40
  def build_complex_attributes(document)
38
- document.identifier = URI.join(I18n.t('geo_concerns.institution.uri'),
39
- geo_concern.id).to_s
41
+ document.identifier = identifier
40
42
  document.description = description
41
43
  document.access_rights = geo_concern.solr_document.visibility
42
44
  document.slug = slug
43
45
  end
44
46
 
47
+ # Returns the work indentifier. This is (usually) different from the hydra/fedora work id.
48
+ # The identifier might be an ARK, DOI, PURL, etc.
49
+ # If identifier is not set, the work id is used.
50
+ # @return [String] identifier
51
+ def identifier
52
+ indentifiers = geo_concern.identifier
53
+ indentifiers.empty? ? geo_concern.id : indentifiers.first
54
+ end
55
+
45
56
  # Returns the work description. If none is available,
46
57
  # a basic description is created.
47
58
  # @return [String] description
@@ -25,6 +25,8 @@ module GeoConcerns
25
25
  date = geo_concern.temporal.first
26
26
  year = date.match(/(?<=\D|^)(\d{4})(?=\D|$)/)
27
27
  year ? year[0].to_i : nil
28
+ rescue
29
+ ''
28
30
  end
29
31
 
30
32
  # Returns the date the work was modified.
@@ -2,23 +2,22 @@ module GeoConcerns
2
2
  module Discovery
3
3
  class DocumentBuilder
4
4
  class DocumentPath
5
- attr_reader :geo_concern, :ssl
6
- def initialize(geo_concern, ssl: false)
5
+ attr_reader :geo_concern
6
+ def initialize(geo_concern)
7
7
  @geo_concern = geo_concern
8
- @ssl = ssl
9
8
  end
10
9
 
11
10
  # Returns url for geo concern show page.
12
11
  # @return [String] geo concern show page url
13
12
  def to_s
14
- helper.polymorphic_url(geo_concern, protocol: protocol)
13
+ helper.polymorphic_url(geo_concern, host: host, protocol: protocol)
15
14
  end
16
15
 
17
16
  # Returns url for downloading the original file.
18
17
  # @return [String] original file download url
19
18
  def file_download
20
19
  return unless file_set
21
- helper.download_url(file_set, protocol: protocol)
20
+ helper.download_url(file_set, host: host, protocol: protocol)
22
21
  end
23
22
 
24
23
  # Returns url for downloading the metadata file.
@@ -26,7 +25,7 @@ module GeoConcerns
26
25
  # @return [String] metadata download url
27
26
  def metadata_download(format)
28
27
  return unless metadata_file_set
29
- path = helper.download_url(metadata_file_set, protocol: protocol)
28
+ path = helper.download_url(metadata_file_set, host: host, protocol: protocol)
30
29
  mime_type = metadata_file_set.solr_document[:geo_mime_type_ssim].first
31
30
  path if MetadataFormatService.label(mime_type) == format
32
31
  end
@@ -64,7 +63,7 @@ module GeoConcerns
64
63
  # Indicates if the ssl is enabled.
65
64
  # @return [Boolean] use ssl
66
65
  def ssl?
67
- @ssl == true
66
+ geo_concern.request.protocol == 'https://'
68
67
  end
69
68
 
70
69
  # Returns protocol to use in url. Depends on ssl status.
@@ -76,6 +75,12 @@ module GeoConcerns
76
75
  :http
77
76
  end
78
77
  end
78
+
79
+ # Returns hostname (with port) to use in url.
80
+ # @return [String] hostname
81
+ def host
82
+ geo_concern.request.host_with_port
83
+ end
79
84
  end
80
85
  end
81
86
  end
@@ -33,12 +33,27 @@ module GeoConcerns
33
33
  document.download = download
34
34
  document.url = url
35
35
  document.thumbnail = thumbnail
36
+ document.wxs_identifier = wxs_identifier
37
+ document.wms_path = wms_path
38
+ document.wfs_path = wfs_path
36
39
  end
37
40
 
38
41
  # Returns the identifier to use with WMS/WFS/WCS services.
39
42
  # @return [String] wxs indentifier
40
43
  def wxs_identifier
41
- geo_concern.id
44
+ wxs.identifier
45
+ end
46
+
47
+ # Returns the wms server url.
48
+ # @return [String] wms server url
49
+ def wms_path
50
+ wxs.wms_path
51
+ end
52
+
53
+ # Returns the wfs server url.
54
+ # @return [String] wfs server url
55
+ def wfs_path
56
+ wxs.wfs_path
42
57
  end
43
58
 
44
59
  # Returns a url to access further descriptive information.
@@ -76,6 +91,10 @@ module GeoConcerns
76
91
  def thumbnail
77
92
  path.thumbnail
78
93
  end
94
+
95
+ def wxs
96
+ @wxs ||= Wxs.new(geo_concern)
97
+ end
79
98
  end
80
99
  end
81
100
  end
@@ -28,6 +28,8 @@ module GeoConcerns
28
28
  # @return [String] coverage in solr format
29
29
  def to_solr
30
30
  "ENVELOPE(#{coverage.w}, #{coverage.e}, #{coverage.n}, #{coverage.s})"
31
+ rescue
32
+ ''
31
33
  end
32
34
  end
33
35
  end
@@ -0,0 +1,81 @@
1
+ module GeoConcerns
2
+ module Discovery
3
+ class DocumentBuilder
4
+ class Wxs
5
+ attr_reader :geo_concern
6
+ def initialize(geo_concern)
7
+ @geo_concern = geo_concern
8
+ @config = fetch_config
9
+ end
10
+
11
+ # Returns the identifier to use with WMS/WFS/WCS services.
12
+ # @return [String] wxs indentifier
13
+ def identifier
14
+ return unless geo_file_set?
15
+ return file_set.id unless @config && visibility
16
+ "#{@config[:workspace]}:#{file_set.id}" if @config[:workspace]
17
+ end
18
+
19
+ # Returns the wms server url.
20
+ # @return [String] wms server url
21
+ def wms_path
22
+ return unless @config && visibility && geo_file_set?
23
+ "#{path}/#{@config[:workspace]}/wms"
24
+ end
25
+
26
+ # Returns the wfs server url.
27
+ # @return [String] wfs server url
28
+ def wfs_path
29
+ return unless @config && visibility && geo_file_set?
30
+ "#{path}/#{@config[:workspace]}/wfs"
31
+ end
32
+
33
+ private
34
+
35
+ # Fetch the geoserver configuration.
36
+ # @return [Hash] geoserver configuration
37
+ def fetch_config
38
+ data = ERB.new(File.read(Rails.root.join('config', 'geoserver.yml'))).result
39
+ YAML.load(data)['geoserver'][visibility].with_indifferent_access if visibility
40
+ end
41
+
42
+ # Gets the representative file set.
43
+ # @return [FileSet] representative file set
44
+ def file_set
45
+ @file_set ||= begin
46
+ representative_id = geo_concern.solr_document.representative_id
47
+ file_set_id = [representative_id]
48
+ geo_concern.member_presenters(file_set_id).first
49
+ end
50
+ end
51
+
52
+ # Tests if the file set is a geo file set.
53
+ # @return [Bool]
54
+ def geo_file_set?
55
+ return false unless file_set
56
+ @file_set_ids ||= geo_concern.geo_file_set_presenters.map(&:id)
57
+ @file_set_ids.include? file_set.id
58
+ end
59
+
60
+ # Returns the file set visibility if it's open and authenticated.
61
+ # @return [String] file set visibility
62
+ def visibility
63
+ return unless file_set
64
+ visibility = file_set.solr_document.visibility
65
+ visibility if valid_visibilities.include? visibility
66
+ end
67
+
68
+ def valid_visibilities
69
+ [Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC,
70
+ Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED]
71
+ end
72
+
73
+ # Geoserver base url.
74
+ # @return [String] geoserver base url
75
+ def path
76
+ @config[:url].chomp('/rest')
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -13,6 +13,7 @@ module GeoConcerns
13
13
  # @param _args [Array<Object>] arguments needed for the renderer, unused here
14
14
  # @return [Hash] geoblacklight document as a hash
15
15
  def to_hash(_args = nil)
16
+ return {} unless rights
16
17
  document
17
18
  end
18
19
 
@@ -20,6 +21,7 @@ module GeoConcerns
20
21
  # @param _args [Array<Object>] arguments needed for the json renderer, unused here
21
22
  # @return [String] geoblacklight document as a json string
22
23
  def to_json(_args = nil)
24
+ return '{}' unless rights
23
25
  document.to_json
24
26
  end
25
27
 
@@ -36,6 +38,7 @@ module GeoConcerns
36
38
  geoblacklight_version: '1.0',
37
39
  dc_identifier_s: identifier,
38
40
  layer_slug_s: slug,
41
+ uuid: slug,
39
42
  dc_title_s: title.first,
40
43
  solr_geom: solr_coverage,
41
44
  dct_provenance_s: provenance,
@@ -73,16 +76,19 @@ module GeoConcerns
73
76
  'http://www.isotc211.org/schemas/2005/gmd/' => iso19139,
74
77
  'http://www.loc.gov/mods/v3' => mods,
75
78
  'http://schema.org/downloadUrl' => download,
76
- 'http://schema.org/thumbnailUrl' => thumbnail
79
+ 'http://schema.org/thumbnailUrl' => thumbnail,
80
+ 'http://www.opengis.net/def/serviceType/ogc/wms' => wms_path,
81
+ 'http://www.opengis.net/def/serviceType/ogc/wfs' => wfs_path
77
82
  }
78
83
  end
79
84
 
80
85
  # Returns the geoblacklight rights field based on work visibility.
81
86
  # @return [String] geoblacklight access rights
82
87
  def rights
83
- if access_rights == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
88
+ case access_rights
89
+ when Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
84
90
  'Public'
85
- else
91
+ when Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
86
92
  'Restricted'
87
93
  end
88
94
  end