geo_concerns 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc +8 -0
  3. data/.gitignore +1 -2
  4. data/.rubocop.yml +1 -0
  5. data/.travis.yml +7 -8
  6. data/Gemfile +1 -3
  7. data/README.md +3 -2
  8. data/app/assets/javascripts/geo_concerns/application.js +0 -1
  9. data/app/assets/javascripts/geo_concerns/bounding_box_selector.js +1 -2
  10. data/app/assets/javascripts/geo_concerns/es6-modules.js +7 -0
  11. data/app/assets/javascripts/geo_concerns/geo_concerns_boot.es6 +8 -0
  12. data/app/assets/javascripts/geo_concerns/relationships.js +3 -0
  13. data/app/assets/javascripts/geo_concerns/relationships/child_works.es6 +20 -0
  14. data/app/assets/javascripts/geo_concerns/relationships/parent_works.es6 +20 -0
  15. data/app/assets/javascripts/geo_concerns/relationships/related_works.es6 +187 -0
  16. data/app/assets/stylesheets/geo_concerns/related_works.scss +29 -0
  17. data/app/assets/stylesheets/geo_concerns/thumbnails.scss +12 -6
  18. data/app/helpers/geo_concerns/populate_metadata_helper.rb +7 -0
  19. data/app/jobs/delivery_job.rb +18 -0
  20. data/app/models/concerns/geo_concerns/file_set/derivatives.rb +9 -0
  21. data/app/models/concerns/geo_concerns/metadata_extraction_helper.rb +7 -8
  22. data/app/models/concerns/geo_concerns/solr_document_behavior.rb +17 -1
  23. data/app/presenters/geo_concerns/geo_concerns_show_presenter.rb +9 -1
  24. data/app/processors/geo_concerns/processors/base_geo_processor.rb +7 -7
  25. data/app/services/geo_concerns/delivery/geoserver.rb +64 -0
  26. data/app/services/geo_concerns/delivery_service.rb +11 -0
  27. data/app/services/geo_concerns/derivative_path.rb +1 -1
  28. data/app/services/geo_concerns/discovery/abstract_document.rb +4 -4
  29. data/app/services/geo_concerns/discovery/document_builder/basic_metadata_builder.rb +5 -12
  30. data/app/services/geo_concerns/discovery/document_builder/date_builder.rb +19 -8
  31. data/app/services/geo_concerns/discovery/document_builder/spatial_builder.rb +3 -8
  32. data/app/services/geo_concerns/discovery/geoblacklight_document.rb +32 -17
  33. data/app/views/curation_concerns/image_works/show.html.erb +1 -5
  34. data/app/views/curation_concerns/raster_works/_show_actions.html.erb +0 -14
  35. data/app/views/curation_concerns/raster_works/show.html.erb +1 -5
  36. data/app/views/curation_concerns/vector_works/show.html.erb +1 -5
  37. data/app/views/geo_concerns/_form_additional_information.html.erb +8 -8
  38. data/app/views/geo_concerns/_form_populate_metadata.html.erb +1 -1
  39. data/app/views/geo_concerns/_form_required_information.html.erb +0 -2
  40. data/app/views/geo_concerns/_related.html.erb +4 -0
  41. data/app/views/geo_concerns/file_sets/actions/_image_actions.html.erb +1 -1
  42. data/app/views/geo_concerns/file_sets/actions/_raster_actions.html.erb +2 -2
  43. data/app/views/geo_concerns/file_sets/actions/_vector_actions.html.erb +2 -2
  44. data/app/views/geo_concerns/related/_child_member.html.erb +13 -0
  45. data/app/views/geo_concerns/related/_child_works.html.erb +24 -0
  46. data/app/views/geo_concerns/related/_external_metadata_file_member.html.erb +8 -0
  47. data/app/views/geo_concerns/{_related_external_metadata_files.html.erb → related/_external_metadata_files.html.erb} +1 -2
  48. data/app/views/geo_concerns/{_related_geo_files.html.erb → related/_geo_files.html.erb} +0 -0
  49. data/app/views/geo_concerns/related/_new_child_member.html.erb +22 -0
  50. data/app/views/geo_concerns/related/_new_parent_member.html.erb +13 -0
  51. data/app/views/geo_concerns/related/_parent_member.html.erb +13 -0
  52. data/app/views/geo_concerns/related/_parent_works.html.erb +22 -0
  53. data/geo_concerns.gemspec +9 -6
  54. data/lib/generators/geo_concerns/install_generator.rb +10 -8
  55. data/lib/generators/geo_concerns/templates/config/geoserver.yml +17 -0
  56. data/lib/generators/geo_concerns/templates/config/locales/geo_concerns.en.yml +4 -0
  57. data/lib/geo_concerns/version.rb +1 -1
  58. data/spec/factories/collections.rb +17 -0
  59. data/spec/features/create_raster_work_spec.rb +5 -2
  60. data/spec/forms/geo_concerns/image_work_form_spec.rb +2 -2
  61. data/spec/helpers/geo_concerns/populate_metadata_helper_spec.rb +31 -0
  62. data/spec/jobs/delivery_job_spec.rb +25 -0
  63. data/spec/models/concerns/geo_concerns/file_set/derivatives_spec.rb +9 -0
  64. data/spec/models/image_work_spec.rb +1 -1
  65. data/spec/models/raster_work_spec.rb +1 -1
  66. data/spec/models/solr_document_spec.rb +2 -2
  67. data/spec/models/vector_work_spec.rb +1 -5
  68. data/spec/presenters/raster_work_show_presenter_spec.rb +22 -0
  69. data/spec/processors/geo_concerns/processors/base_geo_processor_spec.rb +14 -5
  70. data/spec/services/derivative_path_spec.rb +19 -5
  71. data/spec/services/geo_concerns/delivery/geoserver_spec.rb +72 -0
  72. data/spec/services/geo_concerns/delivery_service_spec.rb +15 -0
  73. data/spec/services/geo_concerns/discovery/document_builder_spec.rb +56 -38
  74. data/spec/services/geo_concerns/discovery/geoblacklight_document_spec.rb +7 -5
  75. data/template.rb +1 -1
  76. metadata +94 -19
  77. data/app/views/geo_concerns/_related_geo_works.html.erb +0 -32
  78. data/lib/generators/geo_concerns/templates/config/discovery/geoblacklight_schema.json +0 -168
  79. data/lib/generators/geo_concerns/templates/jobs/characterize_job.rb +0 -19
@@ -0,0 +1,18 @@
1
+ require 'uri'
2
+
3
+ ##
4
+ # Delivers derivatives to external services, like GeoServer
5
+ ##
6
+ class DeliveryJob < ActiveJob::Base
7
+ queue_as CurationConcerns.config.ingest_queue_name
8
+
9
+ ##
10
+ # Precondition is that all derivatives are created and saved.
11
+ # @param [FileSet] file_set
12
+ # @param [String] content_url contains the display copy to deliver
13
+ def perform(file_set, content_url)
14
+ uri = URI.parse(content_url)
15
+ raise NotImplementedError, 'Only supports file URLs' unless uri.scheme == 'file'
16
+ GeoConcerns::DeliveryService.new.publish(file_set.id, uri.path)
17
+ end
18
+ end
@@ -3,18 +3,27 @@ module GeoConcerns
3
3
  module Derivatives
4
4
  extend ActiveSupport::Concern
5
5
 
6
+ # rubocop:disable Metrics/MethodLength
6
7
  def create_derivatives(filename)
8
+ content_url = nil
7
9
  case geo_mime_type
8
10
  when *GeoConcerns::ImageFormatService.select_options.map(&:last)
9
11
  image_derivatives(filename)
10
12
  when *GeoConcerns::RasterFormatService.select_options.map(&:last)
11
13
  raster_derivatives(filename)
14
+ content_url = derivative_url('display_raster')
12
15
  when *GeoConcerns::VectorFormatService.select_options.map(&:last)
13
16
  vector_derivatives(filename)
17
+ content_url = derivative_url('display_vector')
14
18
  end
15
19
 
16
20
  super
21
+
22
+ # Once all the derivatives are created, we can run a job to
23
+ # deliver them to external services
24
+ DeliveryJob.perform_later(self, content_url) if content_url.present?
17
25
  end
26
+ # rubocop:enable Metrics/MethodLength
18
27
 
19
28
  def image_derivatives(filename)
20
29
  Hydra::Derivatives::ImageDerivatives
@@ -2,16 +2,15 @@ module GeoConcerns
2
2
  module MetadataExtractionHelper
3
3
  # Extracts properties from the constitutent external metadata file
4
4
  # @return [Hash]
5
- def extract_metadata
5
+ def extract_metadata(id)
6
6
  return {} if metadata_files.blank?
7
- # TODO: Does not support multiple external metadata files
8
- raise NotImplementedError if metadata_files.length > 1
9
- metadata_files.first.extract_metadata
7
+ metadata_file = metadata_files.find { |f| f.id == id }
8
+ metadata_file.extract_metadata if metadata_file
10
9
  end
11
10
 
12
11
  # Sets properties from the constitutent external metadata file
13
- def populate_metadata
14
- extract_metadata.each do |k, v|
12
+ def populate_metadata(id)
13
+ extract_metadata(id).each do |k, v|
15
14
  send("#{k}=".to_sym, v) # set each property
16
15
  end
17
16
  end
@@ -19,9 +18,9 @@ module GeoConcerns
19
18
  attr_accessor :should_populate_metadata
20
19
 
21
20
  def should_populate_metadata=(args)
22
- @should_populate_metadata = args.present?
21
+ @should_populate_metadata = args.present? && args != ''
23
22
  return unless should_populate_metadata
24
- populate_metadata
23
+ populate_metadata(args)
25
24
  save
26
25
  end
27
26
  end
@@ -1,25 +1,41 @@
1
1
  module GeoConcerns
2
2
  module SolrDocumentBehavior
3
3
  extend ActiveSupport::Concern
4
+ include CurationConcerns::SolrDocumentBehavior
4
5
 
6
+ # @return [Array<String>]
5
7
  def spatial
6
8
  fetch(Solrizer.solr_name('spatial'), [])
7
9
  end
8
10
 
11
+ # @return [Array<String>]
9
12
  def temporal
10
13
  fetch(Solrizer.solr_name('temporal'), [])
11
14
  end
12
15
 
16
+ # @return [String]
13
17
  def issued
14
18
  fetch(Solrizer.solr_name('issued'), nil)
15
19
  end
16
20
 
21
+ # @return [String]
17
22
  def coverage
18
23
  fetch(Solrizer.solr_name('coverage'), nil)
19
24
  end
20
25
 
26
+ # @return [String]
21
27
  def provenance
22
- fetch(Solrizer.solr_name('provenance'), nil)
28
+ name = I18n.t('curation_concerns.institution.name')
29
+ raise ArgumentError, "Provenance required in configuration" unless name.present?
30
+ name
31
+ end
32
+
33
+ # @return [DateTime]
34
+ def layer_modified
35
+ # TODO: `date_modified` isn't working correctly -- it's stored as a string not a date
36
+ # @see 'https://github.com/projecthydra/curation_concerns/issues/957'
37
+ dt = first(Solrizer.solr_name('system_modified', :stored_sortable, type: :date))
38
+ dt.nil? ? nil : DateTime.parse(dt).utc
23
39
  end
24
40
  end
25
41
  end
@@ -1,6 +1,7 @@
1
1
  module GeoConcerns
2
2
  class GeoConcernsShowPresenter < CurationConcerns::WorkShowPresenter
3
- delegate :spatial, :temporal, :issued, :coverage, :provenance, to: :solr_document
3
+ delegate :spatial, :temporal, :issued, :coverage, :provenance, :layer_modified,
4
+ to: :solr_document
4
5
  class_attribute :file_format_service
5
6
 
6
7
  def geo_file_set_presenters
@@ -17,6 +18,13 @@ module GeoConcerns
17
18
  end
18
19
  end
19
20
 
21
+ def parent_work_presenters
22
+ # filter out collection presenters
23
+ collection_presenters.select do |member|
24
+ member.model_name.name != "Collection"
25
+ end
26
+ end
27
+
20
28
  def attribute_to_html(field, options = {})
21
29
  if field == :coverage
22
30
  GeoConcerns::CoverageRenderer.new(field, send(field), options).render
@@ -37,23 +37,23 @@ module GeoConcerns
37
37
  "#{File.dirname(path)}/#{File.basename(path, File.extname(path))}_#{time}"
38
38
  end
39
39
 
40
- # Uses imagemagick to resize an image and convert it to jpeg format.
40
+ # Uses imagemagick to resize an image and convert it to the output format.
41
41
  # Keeps the aspect ratio of the original image and adds padding to
42
- # to the ouput image.
42
+ # to the output image. The file extension is the output format.
43
43
  # @param in_path [String] file input path
44
- # @param out_path [String] processor output file path
44
+ # @param out_path [String] processor output file path.
45
45
  # @param options [Hash] creation options
46
+ # @option options [String] `:output_size` as "w h" or "wxh"
46
47
  def self.convert(in_path, out_path, options)
47
- size = options[:output_size].tr(' ', 'x')
48
- # byebug
49
- image = MiniMagick::Image.open(in_path)
50
- image.format 'jpg'
48
+ image = MiniMagick::Image.open(in_path) # copies image
51
49
  image.combine_options do |i|
50
+ size = options[:output_size].tr(' ', 'x')
52
51
  i.resize size
53
52
  i.background 'white'
54
53
  i.gravity 'center'
55
54
  i.extent size
56
55
  end
56
+ image.format File.extname(out_path).gsub(/^\./, '')
57
57
  image.write(out_path)
58
58
  end
59
59
  end
@@ -0,0 +1,64 @@
1
+ require 'active_support/core_ext/hash/indifferent_access'
2
+ require 'rgeoserver'
3
+ require 'yaml'
4
+
5
+ module GeoConcerns
6
+ module Delivery
7
+ class Geoserver
8
+ DEFAULT_CONFIG = {
9
+ url: 'http://localhost:8181/geoserver/rest',
10
+ user: 'admin',
11
+ password: 'geoserver'
12
+ }.with_indifferent_access.freeze
13
+
14
+ attr_reader :config
15
+
16
+ def initialize
17
+ begin
18
+ data = File.read(Rails.root.join('config', 'geoserver.yml'))
19
+ @config = YAML.load(data)['geoserver'].with_indifferent_access.freeze
20
+ rescue Errno::ENOENT
21
+ @config = DEFAULT_CONFIG
22
+ end
23
+ validate!
24
+ end
25
+
26
+ def catalog
27
+ @catalog ||= RGeoServer.catalog(config)
28
+ end
29
+
30
+ def publish(id, filename, type = :vector)
31
+ case type
32
+ when :vector
33
+ publish_vector(id, filename)
34
+ when :raster
35
+ publish_raster(id, filename)
36
+ else
37
+ raise ArgumentError, "Unknown file type #{type}"
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def validate!
44
+ %w(url user password).map(&:to_sym).each do |k|
45
+ raise ArgumentError, "Missing #{k} in configuration" unless config[k].present?
46
+ end
47
+ end
48
+
49
+ def publish_vector(id, filename)
50
+ raise ArgumentError, "Not ZIPed Shapefile: #{filename}" unless filename =~ /\.zip$/
51
+
52
+ workspace = RGeoServer::Workspace.new catalog, name: 'geo'
53
+ workspace.save if workspace.new?
54
+ datastore = RGeoServer::DataStore.new catalog, workspace: workspace, name: id
55
+ datastore.upload_file filename, publish: true
56
+ end
57
+
58
+ def publish_raster(_id, filename)
59
+ raise ArgumentError, "Not GeoTIFF: #{filename}" unless filename =~ /\.tif$/
60
+ raise NotImplementedError
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,11 @@
1
+ module GeoConcerns
2
+ class DeliveryService
3
+ attr_reader :geoserver
4
+
5
+ def initialize
6
+ @geoserver = GeoConcerns::Delivery::Geoserver.new
7
+ end
8
+
9
+ delegate :publish, to: :geoserver
10
+ end
11
+ end
@@ -1,6 +1,6 @@
1
1
  module GeoConcerns
2
2
  class DerivativePath < CurationConcerns::DerivativePath
3
- def self.extension(destination_name)
3
+ def extension
4
4
  case destination_name
5
5
  when 'thumbnail'
6
6
  ".#{MIME::Types.type_for('jpg').first.extensions.first}"
@@ -1,10 +1,10 @@
1
1
  module GeoConcerns
2
2
  module Discovery
3
3
  class AbstractDocument
4
- attr_accessor :id, :provenance, :creator, :subject, :spatial, :temporal,
5
- :title, :identifier, :description, :access_rights, :language,
6
- :publisher, :slug, :solr_coverage, :geo_rss_coverage, :layer_year,
7
- :date_modified, :geom_type, :format, :resource_type, :wxs_identifier,
4
+ attr_accessor :identifier, :provenance, :creator, :subject, :spatial, :temporal,
5
+ :title, :description, :access_rights, :language, :issued,
6
+ :publisher, :slug, :solr_coverage, :layer_year,
7
+ :layer_modified, :geom_type, :format, :resource_type, :wxs_identifier,
8
8
  :dct_references, :fgdc, :iso19139, :mods, :download, :url, :thumbnail
9
9
 
10
10
  # Cleans the document hash by removing unused fields.
@@ -20,7 +20,7 @@ module GeoConcerns
20
20
  # Returns an array of attributes to add to document.
21
21
  # @return [Array] attributes
22
22
  def simple_attributes
23
- [:id, :creator, :subject, :spatial, :temporal,
23
+ [:creator, :subject, :spatial, :temporal,
24
24
  :title, :provenance, :language, :publisher]
25
25
  end
26
26
 
@@ -35,7 +35,8 @@ module GeoConcerns
35
35
  # Builds more complex metadata attributes.
36
36
  # @param [AbstractDocument] discovery document
37
37
  def build_complex_attributes(document)
38
- document.identifier = identifier
38
+ document.identifier = URI.join(I18n.t('geo_concerns.institution.uri'),
39
+ geo_concern.id).to_s
39
40
  document.description = description
40
41
  document.access_rights = geo_concern.solr_document.visibility
41
42
  document.slug = slug
@@ -52,16 +53,8 @@ module GeoConcerns
52
53
  # Returns the document slug for use in discovery systems.
53
54
  # @return [String] document slug
54
55
  def slug
55
- return unless geo_concern.provenance
56
- "#{geo_concern.provenance[0].downcase.tr(' ', '-')}-#{geo_concern.id}"
57
- end
58
-
59
- # Returns the document identifier. If there is no identifier,
60
- # the work id is used instead.
61
- # @return [String] document identifier
62
- def identifier
63
- field = geo_concern.solr_document[:identifier_tesim]
64
- field ? field.first : geo_concern.id
56
+ return geo_concern.id unless geo_concern.provenance
57
+ "#{geo_concern.provenance.parameterize}-#{geo_concern.id}"
65
58
  end
66
59
  end
67
60
  end
@@ -12,25 +12,36 @@ module GeoConcerns
12
12
  # @param [AbstractDocument] discovery document
13
13
  def build(document)
14
14
  document.layer_year = layer_year
15
- document.date_modified = date_modified
15
+ document.layer_modified = layer_modified
16
+ document.issued = issued
16
17
  end
17
18
 
18
19
  private
19
20
 
20
21
  # Returns a year associated with the layer. Taken from first
21
- # value in temporal or from date uploaded. If neither is valid,
22
- # the current year is used.
22
+ # value in temporal.
23
23
  # @return [Integer] year
24
24
  def layer_year
25
- date = geo_concern.temporal.first || geo_concern.date_uploaded
25
+ date = geo_concern.temporal.first
26
26
  year = date.match(/(?<=\D|^)(\d{4})(?=\D|$)/)
27
- year ? year[0].to_i : Time.current.year
27
+ year ? year[0].to_i : nil
28
28
  end
29
29
 
30
30
  # Returns the date the work was modified.
31
- # @return [String] date in rfc3339 format.
32
- def date_modified
33
- DateTime.rfc3339(geo_concern.solr_document[:date_modified_dtsi]).to_s
31
+ # @return [String] date in XMLSchema format.
32
+ def layer_modified
33
+ geo_concern.layer_modified.try(:xmlschema)
34
+ end
35
+
36
+ # Returns the date the layer was issued.
37
+ # @return [String] date in XMLSchema format.
38
+ def issued
39
+ datetime = geo_concern.issued.first
40
+ datetime = DateTime.parse(datetime.to_s).utc
41
+ # TODO: Rails 4 doesn't implement the timezone correctly -- it adds "+00:00" not "Z"
42
+ Rails::VERSION::MAJOR == 4 ? datetime.utc.strftime('%FT%TZ') : datetime.utc.xmlschema
43
+ rescue
44
+ ''
34
45
  end
35
46
  end
36
47
  end
@@ -11,7 +11,6 @@ module GeoConcerns
11
11
  # Builds spatial fields such as bounding box and solr geometry.
12
12
  # @param [AbstractDocument] discovery document
13
13
  def build(document)
14
- document.geo_rss_coverage = to_geo_rss
15
14
  document.solr_coverage = to_solr
16
15
  end
17
16
 
@@ -23,13 +22,9 @@ module GeoConcerns
23
22
  @coverage ||= GeoConcerns::Coverage.parse(geo_concern.coverage.first)
24
23
  end
25
24
 
26
- # Returns the coverage as georss.
27
- # @return [String] coverage in georss format
28
- def to_geo_rss
29
- "#{coverage.s} #{coverage.w} #{coverage.n} #{coverage.e}"
30
- end
31
-
32
- # Returns the coverage in solr format.
25
+ # Returns the coverage in solr format. For example:
26
+ # `ENVELOPE(minX, maxX, maxY, minY)`
27
+ # @see 'https://cwiki.apache.org/confluence/display/solr/Spatial+Search'
33
28
  # @return [String] coverage in solr format
34
29
  def to_solr
35
30
  "ENVELOPE(#{coverage.w}, #{coverage.e}, #{coverage.n}, #{coverage.s})"
@@ -1,8 +1,14 @@
1
1
  require 'json-schema'
2
+ require 'open-uri'
2
3
 
3
4
  module GeoConcerns
4
5
  module Discovery
6
+ # For details on the schema,
7
+ # @see 'https://github.com/geoblacklight/geoblacklight/wiki/Schema'
5
8
  class GeoblacklightDocument < AbstractDocument
9
+ GEOBLACKLIGHT_RELEASE_VERSION = 'v1.1.2'.freeze
10
+ GEOBLACKLIGHT_SCHEMA = JSON.parse(open("https://raw.githubusercontent.com/geoblacklight/geoblacklight/#{GEOBLACKLIGHT_RELEASE_VERSION}/schema/geoblacklight-schema.json").read).freeze
11
+
6
12
  # Implements the to_hash method on the abstract document.
7
13
  # @param _args [Array<Object>] arguments needed for the renderer, unused here
8
14
  # @return [Hash] geoblacklight document as a hash
@@ -21,30 +27,39 @@ module GeoConcerns
21
27
 
22
28
  # Builds the geoblacklight document hash.
23
29
  # @return [Hash] geoblacklight document as a hash
24
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
25
30
  def document_hash
31
+ document_hash_required.merge(document_hash_optional)
32
+ end
33
+
34
+ def document_hash_required
26
35
  {
27
- uuid: id,
36
+ geoblacklight_version: '1.0',
28
37
  dc_identifier_s: identifier,
38
+ layer_slug_s: slug,
29
39
  dc_title_s: title.first,
40
+ solr_geom: solr_coverage,
41
+ dct_provenance_s: provenance,
42
+ dc_rights_s: rights
43
+ }
44
+ end
45
+
46
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
47
+ def document_hash_optional
48
+ {
30
49
  dc_description_s: description,
31
- dc_rights_s: rights,
32
- dct_provenance_s: provenance.first,
33
50
  dc_creator_sm: creator,
34
- dc_language_s: language.first,
35
- dc_publisher_s: publisher.first,
51
+ dc_language_s: language.try(:first),
52
+ dc_publisher_s: publisher.try(:first),
36
53
  dc_subject_sm: subject,
37
54
  dct_spatial_sm: spatial,
38
55
  dct_temporal_sm: temporal,
39
- layer_slug_s: slug,
40
- georss_box_s: geo_rss_coverage,
41
- solr_geom: solr_coverage,
42
56
  solr_year_i: layer_year,
43
- layer_modified_dt: date_modified,
57
+ layer_modified_dt: layer_modified,
44
58
  layer_id_s: wxs_identifier,
45
- dct_references_s: clean_document(references).to_json,
59
+ dct_references_s: clean_document(references).to_json.to_s,
46
60
  layer_geom_type_s: geom_type,
47
- dc_format_s: process_format_codes(format)
61
+ dc_format_s: process_format_codes(format),
62
+ dct_issued_dt: issued
48
63
  }
49
64
  end
50
65
  # rubocop:enable Metrics/LineLength, Metrics/AbcSize
@@ -87,22 +102,22 @@ module GeoConcerns
87
102
  end
88
103
  end
89
104
 
90
- # Returns the location of geoblacklight json schema document.
91
- # @return [String] geoblacklight json schema document path
105
+ # Returns the content of geoblacklight JSON-Schema document.
106
+ # @return [Hash] geoblacklight json schema
92
107
  def schema
93
- Rails.root.join('config', 'discovery', 'geoblacklight_schema.json').to_s
108
+ GEOBLACKLIGHT_SCHEMA
94
109
  end
95
110
 
96
111
  # Validates the geoblacklight document against the json schema.
97
112
  # @return [Boolean] is the document valid?
98
113
  def valid?(doc)
99
- JSON::Validator.validate(schema, doc, validate_schema: true)
114
+ JSON::Validator.validate(schema, doc, fragment: '#/properties/layer')
100
115
  end
101
116
 
102
117
  # Returns a hash of errors from json schema validation.
103
118
  # @return [Hash] json schema validation errors
104
119
  def schema_errors(doc)
105
- { error: JSON::Validator.fully_validate(schema, doc) }
120
+ { error: JSON::Validator.fully_validate(schema, doc, fragment: '#/properties/layer') }
106
121
  end
107
122
 
108
123
  # Cleans the geoblacklight document hash by removing unused fields,