geoblacklight_admin 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -11
  3. data/Rakefile +83 -47
  4. data/app/assets/javascripts/geoblacklight_admin/chosen.js +1 -0
  5. data/app/assets/stylesheets/geoblacklight_admin/_core.scss +24 -0
  6. data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +0 -5
  7. data/app/assets/stylesheets/geoblacklight_admin/modules/_tables.scss +1 -1
  8. data/app/controllers/admin/admin_controller.rb +16 -0
  9. data/app/controllers/admin/advanced_search_controller.rb +7 -1
  10. data/app/controllers/admin/assets_controller.rb +47 -32
  11. data/app/controllers/admin/bookmarks_controller.rb +17 -5
  12. data/app/controllers/admin/bulk_actions_controller.rb +32 -1
  13. data/app/controllers/admin/document_accesses_controller.rb +38 -0
  14. data/app/controllers/admin/document_assets_controller.rb +47 -89
  15. data/app/controllers/admin/document_distributions_controller.rb +172 -0
  16. data/app/controllers/admin/documents_controller.rb +43 -57
  17. data/app/controllers/admin/elements_controller.rb +24 -0
  18. data/app/controllers/admin/form_elements_controller.rb +33 -0
  19. data/app/controllers/admin/ids_controller.rb +6 -0
  20. data/app/controllers/admin/import_documents_controller.rb +11 -1
  21. data/app/controllers/admin/imports_controller.rb +34 -4
  22. data/app/controllers/admin/mappings_controller.rb +15 -0
  23. data/app/controllers/admin/notifications_controller.rb +27 -0
  24. data/app/controllers/admin/reference_types_controller.rb +106 -0
  25. data/app/controllers/admin/search_controller.rb +7 -0
  26. data/app/controllers/admin/users_controller.rb +10 -0
  27. data/app/helpers/asset_helper.rb +6 -0
  28. data/app/helpers/bulk_actions_helper.rb +10 -1
  29. data/app/helpers/document_helper.rb +36 -0
  30. data/app/helpers/geoblacklight_admin_helper.rb +88 -8
  31. data/app/helpers/mappings_helper.rb +26 -0
  32. data/app/indexers/document_indexer.rb +22 -2
  33. data/app/javascript/channels/consumer.js +6 -0
  34. data/app/javascript/channels/export_channel.js +30 -0
  35. data/app/javascript/channels/index.js +3 -0
  36. data/app/javascript/controllers/results_controller.js +14 -0
  37. data/app/javascript/index.js +8 -2
  38. data/app/jobs/bulk_action_revert_document_job.rb +4 -12
  39. data/app/jobs/bulk_action_run_document_job.rb +2 -10
  40. data/app/jobs/export_job.rb +35 -8
  41. data/app/jobs/geoblacklight_admin/delete_thumbnail_job.rb +19 -0
  42. data/app/jobs/geoblacklight_admin/remove_parent_dct_references_uri_job.rb +16 -0
  43. data/app/jobs/geoblacklight_admin/set_parent_dct_references_uri_job.rb +17 -0
  44. data/app/jobs/geoblacklight_admin/store_image_job.rb +22 -0
  45. data/app/jobs/import_document_job.rb +1 -4
  46. data/app/jobs/import_run_job.rb +1 -1
  47. data/app/models/admin/bookmark.rb +1 -1
  48. data/app/models/asset.rb +20 -0
  49. data/app/models/bulk_action.rb +2 -1
  50. data/app/models/bulk_actions/change_publication_state.rb +0 -25
  51. data/app/models/bulk_actions/delete_thumbnails.rb +6 -0
  52. data/app/models/bulk_actions/draft_document.rb +6 -0
  53. data/app/models/bulk_actions/harvest_thumbnails.rb +6 -0
  54. data/app/models/bulk_actions/publish_document.rb +6 -0
  55. data/app/models/bulk_actions/unpublish_document.rb +6 -0
  56. data/app/models/document/geom_validator.rb +8 -0
  57. data/app/models/document/reference.rb +65 -65
  58. data/app/models/document.rb +129 -72
  59. data/app/models/document_distribution.rb +145 -0
  60. data/app/models/element.rb +2 -0
  61. data/app/models/geoblacklight_admin/schema.rb +10 -2
  62. data/app/models/import/csv_duplicates_validator.rb +2 -0
  63. data/app/models/import/csv_header_validator.rb +3 -1
  64. data/app/models/import_btaa_aardvark.rb +2 -2
  65. data/app/models/import_document_state_machine.rb +1 -0
  66. data/app/models/import_gblv1.rb +2 -2
  67. data/app/models/reference_type.rb +40 -0
  68. data/app/models/user.rb +4 -2
  69. data/app/services/export_csv_document_distributions_service.rb +61 -0
  70. data/app/services/geoblacklight_admin/image_service/iiif_manifest.rb +39 -43
  71. data/app/services/geoblacklight_admin/image_service/tms.rb +0 -8
  72. data/app/services/geoblacklight_admin/image_service.rb +1 -1
  73. data/app/services/geoblacklight_admin/item_viewer.rb +4 -4
  74. data/app/views/admin/bookmarks/index.html.erb +19 -14
  75. data/app/views/admin/bulk_actions/show.html.erb +1 -1
  76. data/app/views/admin/document_accesses/import.html.erb +6 -2
  77. data/app/views/admin/document_assets/_assets_table.html.erb +49 -0
  78. data/app/views/admin/document_assets/_form.html.erb +2 -3
  79. data/app/views/admin/document_assets/index.html.erb +1 -47
  80. data/app/views/admin/document_distributions/_document_distribution.html.erb +39 -0
  81. data/app/views/admin/document_distributions/_document_distribution.json.jbuilder +2 -0
  82. data/app/views/admin/document_distributions/_form.html.erb +34 -0
  83. data/app/views/admin/document_distributions/destroy_all.html.erb +82 -0
  84. data/app/views/admin/document_distributions/edit.html.erb +12 -0
  85. data/app/views/admin/document_distributions/import.html.erb +80 -0
  86. data/app/views/admin/document_distributions/index.html.erb +143 -0
  87. data/app/views/admin/document_distributions/index.json.jbuilder +1 -0
  88. data/app/views/admin/document_distributions/new.html.erb +11 -0
  89. data/app/views/admin/document_distributions/show.html.erb +10 -0
  90. data/app/views/admin/document_distributions/show.json.jbuilder +1 -0
  91. data/app/views/admin/documents/_document.html.erb +1 -3
  92. data/app/views/admin/documents/_form.html.erb +2 -4
  93. data/app/views/admin/documents/_form_control.html.erb +5 -2
  94. data/app/views/admin/documents/_form_nav.html.erb +14 -5
  95. data/app/views/admin/documents/_form_nav_kithe.html.erb +4 -1
  96. data/app/views/admin/documents/_json_aardvark.jbuilder +1 -1
  97. data/app/views/admin/documents/_json_gbl_v1.jbuilder +1 -1
  98. data/app/views/admin/documents/_result_selected_options.html.erb +5 -2
  99. data/app/views/admin/documents/admin.html.erb +5 -5
  100. data/app/views/admin/documents/features/_document_references.html.erb +23 -0
  101. data/app/views/admin/documents/features/_multiple_download_links.html.erb +29 -26
  102. data/app/views/admin/ids/fetch.json.jbuilder +0 -2
  103. data/app/views/admin/ids/index.json.jbuilder +0 -2
  104. data/app/views/admin/imports/_form.html.erb +1 -1
  105. data/app/views/admin/imports/show.html.erb +1 -1
  106. data/app/views/admin/layouts/application.html.erb +4 -2
  107. data/app/views/admin/mappings/index.html.erb +1 -1
  108. data/app/views/admin/notifications/_notification.html.haml +29 -28
  109. data/app/views/admin/reference_types/_form.html.erb +25 -0
  110. data/app/views/admin/reference_types/_reference_type.html.erb +52 -0
  111. data/app/views/admin/reference_types/_reference_type.json.jbuilder +2 -0
  112. data/app/views/admin/reference_types/edit.html.erb +12 -0
  113. data/app/views/admin/reference_types/index.html.erb +52 -0
  114. data/app/views/admin/reference_types/index.json.jbuilder +1 -0
  115. data/app/views/admin/reference_types/new.html.erb +11 -0
  116. data/app/views/admin/reference_types/show.html.erb +3 -0
  117. data/app/views/admin/reference_types/show.json.jbuilder +1 -0
  118. data/app/views/admin/shared/_footer.html.erb +5 -2
  119. data/app/views/admin/shared/_js_behaviors.html.erb +2 -3
  120. data/app/views/admin/shared/_navbar.html.erb +9 -2
  121. data/app/views/admin/users/index.html.erb +0 -1
  122. data/app/views/catalog/_show_gbl_admin.html.erb +1 -1
  123. data/config/initializers/defaults.yml +310 -0
  124. data/config/initializers/rails_config.rb +8 -0
  125. data/config/locales/documents.en.yml +14 -0
  126. data/config/routes.rb +30 -5
  127. data/db/import_references_schema_support.numbers +0 -0
  128. data/db/migrate/20230316183001_add_geoblacklight_admin_gem.rb +0 -12
  129. data/db/migrate/20241009200524_create_admin_reference_types.rb +13 -0
  130. data/db/migrate/20241010161420_create_document_references.rb +14 -0
  131. data/db/migrate/20241120238823_rename_references_to_distributions.rb +5 -0
  132. data/db/seeds.rb +5 -0
  133. data/db/seeds_elements.csv +1 -1
  134. data/db/seeds_elements.numbers +0 -0
  135. data/db/seeds_reference_types.csv +29 -0
  136. data/db/seeds_reference_types.numbers +0 -0
  137. data/db/structure.sql +1 -38
  138. data/lib/compose.yml +31 -0
  139. data/lib/generators/geoblacklight_admin/config_generator.rb +53 -12
  140. data/lib/generators/geoblacklight_admin/install_generator.rb +8 -0
  141. data/lib/generators/geoblacklight_admin/templates/btaa_sample_records.csv +5 -0
  142. data/lib/generators/geoblacklight_admin/templates/config/database.yml +1 -1
  143. data/lib/generators/geoblacklight_admin/templates/config/initializers/devise.rb +0 -2
  144. data/lib/generators/geoblacklight_admin/templates/config/initializers/mime_types.rb +1 -0
  145. data/lib/generators/geoblacklight_admin/templates/demo-app/Dockerfile +31 -0
  146. data/lib/generators/geoblacklight_admin/templates/demo-app/compose.yml +42 -0
  147. data/lib/generators/geoblacklight_admin/templates/demo-app/start-server.sh +21 -0
  148. data/lib/geoblacklight_admin/engine.rb +4 -0
  149. data/lib/geoblacklight_admin/rake_task.rb +2 -0
  150. data/lib/geoblacklight_admin/tasks/distributions.rake +69 -0
  151. data/lib/geoblacklight_admin/tasks/images.rake +1 -0
  152. data/lib/geoblacklight_admin/tasks/solr.rake +31 -0
  153. data/lib/geoblacklight_admin/version.rb +1 -1
  154. data/lib/geoblacklight_admin.rb +4 -0
  155. metadata +137 -53
  156. data/app/helpers/import_documents_helper.rb +0 -5
  157. data/app/javascript/entrypoints/engine.js +0 -8
  158. data/config/locales/devise_invitable.en.yml +0 -31
  159. data/lib/generators/geoblacklight_admin/templates/devise/invitations/edit.html.erb +0 -15
  160. data/lib/generators/geoblacklight_admin/templates/devise/invitations/new.html.erb +0 -15
  161. data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.html.erb +0 -11
  162. data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.text.erb +0 -11
@@ -1,8 +1,14 @@
1
1
  console.log('Vite ⚡️ Rails - GBL Admin')
2
2
 
3
- // Stimulus
3
+ // Import Stimulus and controllers
4
4
  import { Application } from '@hotwired/stimulus'
5
5
  import ResultsController from "./controllers/results_controller"
6
6
 
7
+ // Initialize Stimulus
7
8
  window.Stimulus = Application.start()
8
- Stimulus.register("results", ResultsController)
9
+
10
+ // Register controllers
11
+ Stimulus.register("results", ResultsController)
12
+
13
+ // Import channels
14
+ import '../channels';
@@ -21,18 +21,14 @@ class BulkActionRevertDocumentJob < ApplicationJob
21
21
  logger.debug("Revert PubStatus - #{document.friendlier_id}")
22
22
 
23
23
  versions = document.versions
24
- document = versions[doc.version].reify
24
+ document = versions[doc.current_version].reify
25
25
  document&.skip_callbacks = true
26
26
 
27
- if document&.save
28
- doc.state_machine.transition_to!(:success)
29
- else
30
- doc.state_machine.transition_to!(:failed)
31
- end
27
+ document.save
32
28
  end
33
29
 
34
30
  def revert_delete(doc)
35
- document = Document.new(id: doc.document_id)
31
+ document = Document.find_by!(friendlier_id: doc.friendlier_id)
36
32
 
37
33
  logger.debug("Revert Delete - #{document.id}")
38
34
 
@@ -40,10 +36,6 @@ class BulkActionRevertDocumentJob < ApplicationJob
40
36
  document = versions.last.reify
41
37
  document.skip_callbacks = true
42
38
 
43
- if document.save
44
- doc.state_machine.transition_to!(:success)
45
- else
46
- doc.state_machine.transition_to!(:failed)
47
- end
39
+ document.save
48
40
  end
49
41
  end
@@ -25,11 +25,7 @@ class BulkActionRunDocumentJob < ApplicationJob
25
25
 
26
26
  logger.debug("Update PubStatus - #{document.friendlier_id} => #{field_value}")
27
27
 
28
- if document.update!(publication_state: field_value.to_sym)
29
- doc.state_machine.transition_to!(:success)
30
- else
31
- doc.state_machine.transition_to!(:failed)
32
- end
28
+ document.update!(publication_state: field_value.to_sym)
33
29
  end
34
30
 
35
31
  def update_delete(doc, field_value)
@@ -37,10 +33,6 @@ class BulkActionRunDocumentJob < ApplicationJob
37
33
 
38
34
  logger.debug("Update Delete - #{document.friendlier_id} => #{field_value}")
39
35
 
40
- if document.destroy
41
- doc.state_machine.transition_to!(:success)
42
- else
43
- doc.state_machine.transition_to!(:failed)
44
- end
36
+ document.destroy
45
37
  end
46
38
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "csv"
4
+ require "zip"
4
5
 
5
6
  # ExportJob
6
7
  class ExportJob < ApplicationJob
@@ -23,27 +24,53 @@ class ExportJob < ApplicationJob
23
24
  logger.debug("Document Ids: #{document_ids}")
24
25
 
25
26
  # Send progress
26
- file_content = export_service.call(document_ids)
27
+ file_content_documents = export_service.call(document_ids)
28
+ file_content_document_distributions = ExportCsvDocumentDistributionsService.call(document_ids)
27
29
 
28
- # Write into tempfile
29
- @tempfile = Tempfile.new(["export-#{Time.zone.today}", ".csv"]).tap do |file|
30
+ # Write Documents into tempfile
31
+ @tempfile_documents = Tempfile.new(["documents-#{Time.zone.today}", ".csv"]).tap do |file|
30
32
  CSV.open(file, "wb") do |csv|
31
- file_content.each do |row|
33
+ file_content_documents.each do |row|
32
34
  csv << row
33
35
  end
34
36
  end
37
+ logger.debug("Tempfile Documents Path: #{file.path}")
38
+ logger.debug("Tempfile Documents Size: #{File.size(file.path)} bytes")
35
39
  end
36
40
 
41
+ # Write DocumentDistributions into tempfile
42
+ @tempfile_document_distributions = Tempfile.new(["document-distributions-#{Time.zone.today}", ".csv"]).tap do |file|
43
+ CSV.open(file, "wb") do |csv|
44
+ file_content_document_distributions.each do |row|
45
+ csv << row
46
+ end
47
+ end
48
+ logger.debug("Tempfile Document Distributions Path: #{file.path}")
49
+ logger.debug("Tempfile Document Distributions Size: #{File.size(file.path)} bytes")
50
+ end
51
+
52
+ # Create a zip file containing both tempfiles
53
+ zipfile_name = "export-#{Time.zone.today}.zip"
54
+ tmp_dir = Rails.root.join("tmp")
55
+ @tempfile_zip = Tempfile.new([zipfile_name, ".zip"], tmp_dir)
56
+
57
+ Zip::File.open(@tempfile_zip.path, Zip::File::CREATE) do |zipfile|
58
+ zipfile.add("documents.csv", @tempfile_documents.path)
59
+ zipfile.add("document-distributions.csv", @tempfile_document_distributions.path)
60
+ end
61
+ logger.debug("Zipfile Path: #{@tempfile_zip.path}")
62
+ logger.debug("Zipfile Size: #{File.size(@tempfile_zip.path)} bytes")
63
+
37
64
  # Create notification
38
65
  # Message: "Download Type|Row Count|Button Label"
39
- notification = ExportNotification.with(message: "CSV (#{export_service.short_name})|#{ActionController::Base.helpers.number_with_delimiter(file_content.size - 1)} rows|CSV")
66
+ notification = ExportNotification.with(message: "ZIP (#{export_service.short_name})|#{ActionController::Base.helpers.number_with_delimiter(file_content_documents.size - 1)} rows|ZIP")
40
67
 
41
68
  # Deliver notification
42
69
  notification.deliver(current_user)
43
70
 
44
- # Attach CSV file (can only attach after persisted)
45
- notification.record.file.attach(io: @tempfile, filename: "geomg-export-#{Time.zone.today}.csv",
46
- content_type: "text/csv")
71
+ # Attach ZIP file (can only attach after persisted)
72
+ notification.record.file.attach(io: File.open(@tempfile_zip), filename: zipfile_name,
73
+ content_type: "application/zip")
47
74
 
48
75
  # Update UI
49
76
  ActionCable.server.broadcast("export_channel", {
@@ -1,11 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ ##
4
+ # Module for GeoblacklightAdmin related jobs.
3
5
  module GeoblacklightAdmin
6
+ ##
7
+ # A job to delete the thumbnail associated with a Solr document.
8
+ #
9
+ # This job is enqueued with a priority queue and can optionally handle
10
+ # a bad document ID to transition its state.
4
11
  class DeleteThumbnailJob < ApplicationJob
12
+ ##
13
+ # Determines the queue to use based on the last argument.
5
14
  queue_as do
6
15
  arguments.last
7
16
  end
8
17
 
18
+ ##
19
+ # Performs the job to delete a thumbnail.
20
+ #
21
+ # @param solr_document_id [String] the ID of the Solr document
22
+ # @param bad_id [String, nil] optional ID of a bad document to transition
23
+ # @param queue [Symbol] the queue to use, defaults to :priority
24
+ #
25
+ # If the document has a thumbnail, it will be destroyed.
26
+ # If a bad_id is provided, it will transition the state of the
27
+ # BulkActionDocument to :success.
9
28
  def perform(solr_document_id, bad_id = nil, queue = :priority)
10
29
  document = Document.find_by_friendlier_id(solr_document_id)
11
30
  if document.thumbnail.present?
@@ -1,9 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ ##
4
+ # Module for GeoblacklightAdmin jobs.
3
5
  module GeoblacklightAdmin
6
+ ##
7
+ # Job to remove a specific DCT references URI from the parent asset.
8
+ #
9
+ # This job is queued with a priority level and is responsible for
10
+ # removing a DCT references URI from the parent of a given asset.
4
11
  class RemoveParentDctReferencesUriJob < ApplicationJob
5
12
  queue_as :priority
6
13
 
14
+ ##
15
+ # Performs the job of removing the DCT references URI from the parent asset.
16
+ #
17
+ # This method checks if the asset has a `dct_references_uri_key` present.
18
+ # If present, it deletes the URI from the parent's `dct_references_s` array
19
+ # if it matches the asset's full file URL, and then saves the parent asset.
20
+ #
21
+ # @param asset [Object] The asset whose parent's DCT references URI is to be removed.
22
+ # @raise [StandardError] Logs an error if an exception occurs during the process.
7
23
  def perform(asset)
8
24
  if asset.dct_references_uri_key.present?
9
25
  asset.parent.dct_references_s.delete_if { |i| i.value == asset.full_file_url }
@@ -1,9 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ ##
4
+ # Module for GeoblacklightAdmin jobs.
3
5
  module GeoblacklightAdmin
6
+ ##
7
+ # Job to set the parent DCT references URI for a given asset.
8
+ #
9
+ # This job is responsible for creating a new reference for the asset's
10
+ # DCT references URI key and appending it to the parent asset's
11
+ # `dct_references_s` array. It then saves the parent asset.
12
+ #
13
+ # If an error occurs during the process, it logs the error message.
4
14
  class SetParentDctReferencesUriJob < ApplicationJob
15
+ # Sets the queue for this job to :priority
5
16
  queue_as :priority
6
17
 
18
+ ##
19
+ # Performs the job to set the parent DCT references URI.
20
+ #
21
+ # @param asset [Object] The asset for which the DCT references URI is to be set.
22
+ #
23
+ # @return [void]
7
24
  def perform(asset)
8
25
  if asset.dct_references_uri_key.present?
9
26
  reference = Document::Reference.new
@@ -1,11 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ ##
4
+ # Module for GeoblacklightAdmin jobs.
3
5
  module GeoblacklightAdmin
6
+ ##
7
+ # StoreImageJob is responsible for handling the storage of images
8
+ # associated with a Solr document. It manages the lifecycle of the
9
+ # image storage process, including state transitions and error handling.
4
10
  class StoreImageJob < ApplicationJob
11
+ ##
12
+ # Sets the queue for the job based on the last argument provided.
5
13
  queue_as do
6
14
  arguments.last
7
15
  end
8
16
 
17
+ ##
18
+ # Performs the job to store an image for a given Solr document.
19
+ #
20
+ # @param solr_document_id [String] the ID of the Solr document
21
+ # @param bad_id [String, nil] optional ID for a BulkActionDocument
22
+ # @param queue [Symbol] the queue to use for the job, defaults to :default
23
+ #
24
+ # This method:
25
+ # - Finds the document by its friendlier ID.
26
+ # - Deletes any existing thumbnail.
27
+ # - Transitions the document's thumbnail state to 'queued'.
28
+ # - Waits for a random period to ensure polite crawling.
29
+ # - Stores the image using the ImageService.
30
+ # - Transitions the BulkActionDocument state to 'success' if a bad_id is provided.
9
31
  def perform(solr_document_id, bad_id = nil, queue = :default)
10
32
  # Find the document
11
33
  document = Document.find_by_friendlier_id(solr_document_id)
@@ -5,10 +5,7 @@ class ImportDocumentJob < ApplicationJob
5
5
  queue_as :priority
6
6
 
7
7
  def perform(import_document)
8
- # @TODO: Check for friendlier_id or raise error
9
- document = Document.where(
10
- friendlier_id: import_document.friendlier_id
11
- ).first_or_create
8
+ document = Document.find_or_create_by(friendlier_id: import_document.friendlier_id)
12
9
 
13
10
  # Set the geom
14
11
  document.set_geometry
@@ -5,7 +5,7 @@ class ImportRunJob < ApplicationJob
5
5
  queue_as :priority
6
6
 
7
7
  def perform(import)
8
- data = CSV.parse(import.csv_file.download.force_encoding("UTF-8"), headers: true)
8
+ data = CSV.parse(import.csv_file.download, headers: true)
9
9
 
10
10
  data.each do |doc|
11
11
  extract_hash = doc.to_h
@@ -8,7 +8,7 @@ module Admin
8
8
  validates :user_id, presence: true
9
9
 
10
10
  def document_id
11
- document_id
11
+ document.id
12
12
  end
13
13
 
14
14
  def document_type
data/app/models/asset.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  class Asset < Kithe::Asset
2
+ belongs_to :parent, class_name: "Document", optional: true
3
+
2
4
  include AttrJson::Record::QueryScopes
3
5
  include Rails.application.routes.url_helpers
4
6
 
@@ -17,6 +19,8 @@ class Asset < Kithe::Asset
17
19
  "public" => :kithe_derivatives
18
20
  }.freeze
19
21
 
22
+ scope :to_aardvark_references, -> { where(parent_id: pluck(:parent_id)).map(&:to_aardvark_reference) }
23
+
20
24
  def full_file_url
21
25
  if Rails.env.development?
22
26
  "http://localhost:3000" + file.url
@@ -45,6 +49,22 @@ class Asset < Kithe::Asset
45
49
  def reindex_parent
46
50
  parent.save if parent.present?
47
51
  end
52
+
53
+ def to_aardvark_reference
54
+ hash = {}
55
+ if dct_references_uri_key.present?
56
+ reference_type = ReferenceType.find_by_name(dct_references_uri_key)
57
+ hash[reference_type.reference_uri.to_s] = if reference_type.reference_uri.to_s == "http://schema.org/downloadUrl"
58
+ {
59
+ "url" => full_file_url,
60
+ "label" => label.present? ? label : file.metadata["filename"]
61
+ }
62
+ else
63
+ full_file_url
64
+ end
65
+ end
66
+ hash
67
+ end
48
68
  end
49
69
 
50
70
  # Allow DocumentAsset to be used as a synonym for Asset
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "uri"
4
4
  require "cgi"
5
+ require "statesman"
5
6
 
6
7
  # BulkAction
7
8
  class BulkAction < ApplicationRecord
@@ -19,7 +20,7 @@ class BulkAction < ApplicationRecord
19
20
  validates :scope, :field_name, :field_value, presence: true
20
21
 
21
22
  # States
22
- include Statesman::Adapters::ActiveRecordQueries[
23
+ include ::Statesman::Adapters::ActiveRecordQueries[
23
24
  transition_class: BulkActionTransition,
24
25
  initial_state: :created
25
26
  ]
@@ -3,29 +3,4 @@ module BulkActions
3
3
  class ChangePublicationState < BulkAction
4
4
  # Add specific methods and validations for ChangePublicationState here
5
5
  end
6
-
7
- # Subclass for PublishDocument
8
- class PublishDocument < BulkAction
9
- # Add specific methods and validations for PublishDocument here
10
- end
11
-
12
- # Subclass for UnpublishDocument
13
- class UnpublishDocument < BulkAction
14
- # Add specific methods and validations for UnpublishDocument here
15
- end
16
-
17
- # Subclass for DraftDocument
18
- class DraftDocument < BulkAction
19
- # Add specific methods and validations for DraftDocument here
20
- end
21
-
22
- # Subclass for HarvestThumbnails
23
- class HarvestThumbnails < BulkAction
24
- # Add specific methods and validations for HarvestThumbnails here
25
- end
26
-
27
- # Subclass for DeleteThumbnails
28
- class DeleteThumbnails < BulkAction
29
- # Add specific methods and validations for DeleteThumbnails here
30
- end
31
6
  end
@@ -0,0 +1,6 @@
1
+ module BulkActions
2
+ # Subclass for DeleteThumbnails
3
+ class DeleteThumbnails < BulkAction
4
+ # Add specific methods and validations for DeleteThumbnails here
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module BulkActions
2
+ # Subclass for DraftDocument
3
+ class DraftDocument < BulkAction
4
+ # Add specific methods and validations for DraftDocument here
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module BulkActions
2
+ # Subclass for HarvestThumbnails
3
+ class HarvestThumbnails < BulkAction
4
+ # Add specific methods and validations for HarvestThumbnails here
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module BulkActions
2
+ # Subclass for PublishDocument
3
+ class PublishDocument < ChangePublicationState
4
+ # Add specific methods and validations for PublishDocument here
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module BulkActions
2
+ # Subclass for UnpublishDocument
3
+ class UnpublishDocument < BulkAction
4
+ # Add specific methods and validations for UnpublishDocument here
5
+ end
6
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rgeo"
4
+ require "rgeo/wkrep/wkt_parser"
4
5
 
5
6
  # GEOM Validation
6
7
  #
@@ -65,6 +66,13 @@ class Document
65
66
  "Invalid polygon: all points are coplanar input, Solr will not index")
66
67
  end
67
68
 
69
+ # Guard against coplanar points
70
+ if geom == "POLYGON((-180.0 90.0, 180.0 90.0, 180.0 -90.0, -180.0 -90.0, -180.0 90.0))"
71
+ valid_geom = false
72
+ record.errors.add(GeoblacklightAdmin::Schema.instance.solr_fields[:geometry],
73
+ "Invalid polygon: all points are coplanar input, Solr will not index")
74
+ end
75
+
68
76
  valid_geom
69
77
  end
70
78
 
@@ -7,17 +7,37 @@ class Document
7
7
  # Via GBL Wiki
8
8
  # https://github.com/geoblacklight/geoblacklight/wiki/External-references
9
9
  REFERENCE_VALUES = {
10
- wcs: {
11
- label: "Web Coverage Service (WCS)",
12
- uri: "http://www.opengis.net/def/serviceType/ogc/wcs"
10
+ arcgis_dynamic_map_layer: {
11
+ label: "ArcGIS DynamicMapLayer",
12
+ uri: "urn:x-esri:serviceType:ArcGIS#DynamicMapLayer"
13
13
  },
14
- wms: {
15
- label: "Web Mapping Service (WMS)",
16
- uri: "http://www.opengis.net/def/serviceType/ogc/wms"
14
+ arcgis_feature_layer: {
15
+ label: "ArcGIS FeatureLayer",
16
+ uri: "urn:x-esri:serviceType:ArcGIS#FeatureLayer"
17
17
  },
18
- wfs: {
19
- label: "Web Feature Service (WFS)",
20
- uri: "http://www.opengis.net/def/serviceType/ogc/wfs"
18
+ arcgis_image_map_layer: {
19
+ label: "ArcGIS ImageMapLayer",
20
+ uri: "urn:x-esri:serviceType:ArcGIS#ImageMapLayer"
21
+ },
22
+ arcgis_tiled_map_layer: {
23
+ label: "ArcGIS TiledMapLayer",
24
+ uri: "urn:x-esri:serviceType:ArcGIS#TiledMapLayer"
25
+ },
26
+ cog: {
27
+ label: "COG",
28
+ uri: "https://github.com/cogeotiff/cog-spec"
29
+ },
30
+ documentation_download: {
31
+ label: "Data dictionary / documentation download",
32
+ uri: "http://lccn.loc.gov/sh85035852"
33
+ },
34
+ documentation_external: {
35
+ label: "Full layer description",
36
+ uri: "http://schema.org/url"
37
+ },
38
+ download: {
39
+ label: "Direct download file",
40
+ uri: "http://schema.org/downloadUrl"
21
41
  },
22
42
  iiif_image: {
23
43
  label: "IIIF Image API",
@@ -31,81 +51,37 @@ class Document
31
51
  label: "Image file",
32
52
  uri: "http://schema.org/image"
33
53
  },
34
- download: {
35
- label: "Direct download file",
36
- uri: "http://schema.org/downloadUrl"
37
- },
38
- thumbnail: {
39
- label: "Thumbnail file",
40
- uri: "http://schema.org/thumbnailUrl"
41
- },
42
- documentation_download: {
43
- label: "Data dictionary / documentation download",
44
- uri: "http://lccn.loc.gov/sh85035852"
45
- },
46
- documentation_external: {
47
- label: "Full layer description",
48
- uri: "http://schema.org/url"
49
- },
50
- metadata_iso: {
51
- label: "Metadata in ISO 19139",
52
- uri: "http://www.isotc211.org/schemas/2005/gmd/"
53
- },
54
54
  metadata_fgdc: {
55
55
  label: "Metadata in FGDC",
56
56
  uri: "http://www.opengis.net/cat/csw/csdgm"
57
57
  },
58
- metadata_mods: {
59
- label: "Metadata in MODS",
60
- uri: "http://www.loc.gov/mods/v3"
61
- },
62
58
  metadata_html: {
63
59
  label: "Metadata in HTML",
64
60
  uri: "http://www.w3.org/1999/xhtml"
65
61
  },
66
- arcgis_feature_layer: {
67
- label: "ArcGIS FeatureLayer",
68
- uri: "urn:x-esri:serviceType:ArcGIS#FeatureLayer"
69
- },
70
- arcgis_tiled_map_layer: {
71
- label: "ArcGIS TiledMapLayer",
72
- uri: "urn:x-esri:serviceType:ArcGIS#TiledMapLayer"
73
- },
74
- arcgis_dynamic_map_layer: {
75
- label: "ArcGIS DynamicMapLayer",
76
- uri: "urn:x-esri:serviceType:ArcGIS#DynamicMapLayer"
77
- },
78
- arcgis_image_map_layer: {
79
- label: "ArcGIS ImageMapLayer",
80
- uri: "urn:x-esri:serviceType:ArcGIS#ImageMapLayer"
81
- },
82
- harvard_download: {
83
- label: "Harvard Download",
84
- uri: "http://schema.org/DownloadAction"
62
+ metadata_iso: {
63
+ label: "Metadata in ISO 19139",
64
+ uri: "http://www.isotc211.org/schemas/2005/gmd/"
85
65
  },
86
- open_index_map: {
87
- label: "OpenIndexMap",
88
- uri: "https://openindexmaps.org"
66
+ metadata_mods: {
67
+ label: "Metadata in MODS",
68
+ uri: "http://www.loc.gov/mods/v3"
89
69
  },
90
70
  oembed: {
91
71
  label: "oEmbed",
92
72
  uri: "https://oembed.com"
93
73
  },
94
- cog: {
95
- label: "COG",
96
- uri: "https://github.com/cogeotiff/cog-spec"
74
+ open_index_map: {
75
+ label: "OpenIndexMap",
76
+ uri: "https://openindexmaps.org"
97
77
  },
98
78
  pmtiles: {
99
79
  label: "PMTiles",
100
80
  uri: "https://github.com/protomaps/PMTiles"
101
81
  },
102
- xyz_tiles: {
103
- label: "XYZ Tiles",
104
- uri: "https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames"
105
- },
106
- wmts: {
107
- label: "WMTS",
108
- uri: "http://www.opengis.net/def/serviceType/ogc/wmts"
82
+ thumbnail: {
83
+ label: "Thumbnail file",
84
+ uri: "http://schema.org/thumbnailUrl"
109
85
  },
110
86
  tile_json: {
111
87
  label: "TileJSON",
@@ -114,6 +90,26 @@ class Document
114
90
  tile_map_service: {
115
91
  label: "Tile Map Service",
116
92
  uri: "https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification"
93
+ },
94
+ wcs: {
95
+ label: "Web Coverage Service (WCS)",
96
+ uri: "http://www.opengis.net/def/serviceType/ogc/wcs"
97
+ },
98
+ wfs: {
99
+ label: "Web Feature Service (WFS)",
100
+ uri: "http://www.opengis.net/def/serviceType/ogc/wfs"
101
+ },
102
+ wmts: {
103
+ label: "WMTS",
104
+ uri: "http://www.opengis.net/def/serviceType/ogc/wmts"
105
+ },
106
+ wms: {
107
+ label: "Web Mapping Service (WMS)",
108
+ uri: "http://www.opengis.net/def/serviceType/ogc/wms"
109
+ },
110
+ xyz_tiles: {
111
+ label: "XYZ Tiles",
112
+ uri: "https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames"
117
113
  }
118
114
  }.freeze
119
115
 
@@ -127,5 +123,9 @@ class Document
127
123
 
128
124
  attr_json :category, :string
129
125
  attr_json :value, :string
126
+
127
+ def self.reference_values
128
+ REFERENCE_VALUES
129
+ end
130
130
  end
131
131
  end