geoblacklight_admin 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +24 -11
- data/Rakefile +83 -47
- data/app/assets/javascripts/geoblacklight_admin/chosen.js +1 -0
- data/app/assets/stylesheets/geoblacklight_admin/_core.scss +24 -0
- data/app/assets/stylesheets/geoblacklight_admin/modules/_nav.scss +0 -5
- data/app/assets/stylesheets/geoblacklight_admin/modules/_tables.scss +1 -1
- data/app/controllers/admin/admin_controller.rb +16 -0
- data/app/controllers/admin/advanced_search_controller.rb +7 -1
- data/app/controllers/admin/assets_controller.rb +47 -32
- data/app/controllers/admin/bookmarks_controller.rb +17 -5
- data/app/controllers/admin/bulk_actions_controller.rb +32 -1
- data/app/controllers/admin/document_accesses_controller.rb +38 -0
- data/app/controllers/admin/document_assets_controller.rb +47 -89
- data/app/controllers/admin/document_distributions_controller.rb +172 -0
- data/app/controllers/admin/documents_controller.rb +43 -57
- data/app/controllers/admin/elements_controller.rb +24 -0
- data/app/controllers/admin/form_elements_controller.rb +33 -0
- data/app/controllers/admin/ids_controller.rb +6 -0
- data/app/controllers/admin/import_documents_controller.rb +11 -1
- data/app/controllers/admin/imports_controller.rb +34 -4
- data/app/controllers/admin/mappings_controller.rb +15 -0
- data/app/controllers/admin/notifications_controller.rb +27 -0
- data/app/controllers/admin/reference_types_controller.rb +106 -0
- data/app/controllers/admin/search_controller.rb +7 -0
- data/app/controllers/admin/users_controller.rb +10 -0
- data/app/helpers/asset_helper.rb +6 -0
- data/app/helpers/bulk_actions_helper.rb +10 -1
- data/app/helpers/document_helper.rb +36 -0
- data/app/helpers/geoblacklight_admin_helper.rb +88 -8
- data/app/helpers/mappings_helper.rb +26 -0
- data/app/indexers/document_indexer.rb +22 -2
- data/app/javascript/channels/consumer.js +6 -0
- data/app/javascript/channels/export_channel.js +30 -0
- data/app/javascript/channels/index.js +3 -0
- data/app/javascript/controllers/results_controller.js +14 -0
- data/app/javascript/index.js +8 -2
- data/app/jobs/bulk_action_revert_document_job.rb +4 -12
- data/app/jobs/bulk_action_run_document_job.rb +2 -10
- data/app/jobs/export_job.rb +35 -8
- data/app/jobs/geoblacklight_admin/delete_thumbnail_job.rb +19 -0
- data/app/jobs/geoblacklight_admin/remove_parent_dct_references_uri_job.rb +16 -0
- data/app/jobs/geoblacklight_admin/set_parent_dct_references_uri_job.rb +17 -0
- data/app/jobs/geoblacklight_admin/store_image_job.rb +22 -0
- data/app/jobs/import_document_job.rb +1 -4
- data/app/jobs/import_run_job.rb +1 -1
- data/app/models/admin/bookmark.rb +1 -1
- data/app/models/asset.rb +20 -0
- data/app/models/bulk_action.rb +2 -1
- data/app/models/bulk_actions/change_publication_state.rb +0 -25
- data/app/models/bulk_actions/delete_thumbnails.rb +6 -0
- data/app/models/bulk_actions/draft_document.rb +6 -0
- data/app/models/bulk_actions/harvest_thumbnails.rb +6 -0
- data/app/models/bulk_actions/publish_document.rb +6 -0
- data/app/models/bulk_actions/unpublish_document.rb +6 -0
- data/app/models/document/geom_validator.rb +8 -0
- data/app/models/document/reference.rb +65 -65
- data/app/models/document.rb +129 -72
- data/app/models/document_distribution.rb +145 -0
- data/app/models/element.rb +2 -0
- data/app/models/geoblacklight_admin/schema.rb +10 -2
- data/app/models/import/csv_duplicates_validator.rb +2 -0
- data/app/models/import/csv_header_validator.rb +3 -1
- data/app/models/import_btaa_aardvark.rb +2 -2
- data/app/models/import_document_state_machine.rb +1 -0
- data/app/models/import_gblv1.rb +2 -2
- data/app/models/reference_type.rb +40 -0
- data/app/models/user.rb +4 -2
- data/app/services/export_csv_document_distributions_service.rb +61 -0
- data/app/services/geoblacklight_admin/image_service/iiif_manifest.rb +39 -43
- data/app/services/geoblacklight_admin/image_service/tms.rb +0 -8
- data/app/services/geoblacklight_admin/image_service.rb +1 -1
- data/app/services/geoblacklight_admin/item_viewer.rb +4 -4
- data/app/views/admin/bookmarks/index.html.erb +19 -14
- data/app/views/admin/bulk_actions/show.html.erb +1 -1
- data/app/views/admin/document_accesses/import.html.erb +6 -2
- data/app/views/admin/document_assets/_assets_table.html.erb +49 -0
- data/app/views/admin/document_assets/_form.html.erb +2 -3
- data/app/views/admin/document_assets/index.html.erb +1 -47
- data/app/views/admin/document_distributions/_document_distribution.html.erb +39 -0
- data/app/views/admin/document_distributions/_document_distribution.json.jbuilder +2 -0
- data/app/views/admin/document_distributions/_form.html.erb +34 -0
- data/app/views/admin/document_distributions/destroy_all.html.erb +82 -0
- data/app/views/admin/document_distributions/edit.html.erb +12 -0
- data/app/views/admin/document_distributions/import.html.erb +80 -0
- data/app/views/admin/document_distributions/index.html.erb +143 -0
- data/app/views/admin/document_distributions/index.json.jbuilder +1 -0
- data/app/views/admin/document_distributions/new.html.erb +11 -0
- data/app/views/admin/document_distributions/show.html.erb +10 -0
- data/app/views/admin/document_distributions/show.json.jbuilder +1 -0
- data/app/views/admin/documents/_document.html.erb +1 -3
- data/app/views/admin/documents/_form.html.erb +2 -4
- data/app/views/admin/documents/_form_control.html.erb +5 -2
- data/app/views/admin/documents/_form_nav.html.erb +14 -5
- data/app/views/admin/documents/_form_nav_kithe.html.erb +4 -1
- data/app/views/admin/documents/_json_aardvark.jbuilder +1 -1
- data/app/views/admin/documents/_json_gbl_v1.jbuilder +1 -1
- data/app/views/admin/documents/_result_selected_options.html.erb +5 -2
- data/app/views/admin/documents/admin.html.erb +5 -5
- data/app/views/admin/documents/features/_document_references.html.erb +23 -0
- data/app/views/admin/documents/features/_multiple_download_links.html.erb +29 -26
- data/app/views/admin/ids/fetch.json.jbuilder +0 -2
- data/app/views/admin/ids/index.json.jbuilder +0 -2
- data/app/views/admin/imports/_form.html.erb +1 -1
- data/app/views/admin/imports/show.html.erb +1 -1
- data/app/views/admin/layouts/application.html.erb +4 -2
- data/app/views/admin/mappings/index.html.erb +1 -1
- data/app/views/admin/notifications/_notification.html.haml +29 -28
- data/app/views/admin/reference_types/_form.html.erb +25 -0
- data/app/views/admin/reference_types/_reference_type.html.erb +52 -0
- data/app/views/admin/reference_types/_reference_type.json.jbuilder +2 -0
- data/app/views/admin/reference_types/edit.html.erb +12 -0
- data/app/views/admin/reference_types/index.html.erb +52 -0
- data/app/views/admin/reference_types/index.json.jbuilder +1 -0
- data/app/views/admin/reference_types/new.html.erb +11 -0
- data/app/views/admin/reference_types/show.html.erb +3 -0
- data/app/views/admin/reference_types/show.json.jbuilder +1 -0
- data/app/views/admin/shared/_footer.html.erb +5 -2
- data/app/views/admin/shared/_js_behaviors.html.erb +2 -3
- data/app/views/admin/shared/_navbar.html.erb +9 -2
- data/app/views/admin/users/index.html.erb +0 -1
- data/app/views/catalog/_show_gbl_admin.html.erb +1 -1
- data/config/initializers/defaults.yml +310 -0
- data/config/initializers/rails_config.rb +8 -0
- data/config/locales/documents.en.yml +14 -0
- data/config/routes.rb +30 -5
- data/db/import_references_schema_support.numbers +0 -0
- data/db/migrate/20230316183001_add_geoblacklight_admin_gem.rb +0 -12
- data/db/migrate/20241009200524_create_admin_reference_types.rb +13 -0
- data/db/migrate/20241010161420_create_document_references.rb +14 -0
- data/db/migrate/20241120238823_rename_references_to_distributions.rb +5 -0
- data/db/seeds.rb +5 -0
- data/db/seeds_elements.csv +1 -1
- data/db/seeds_elements.numbers +0 -0
- data/db/seeds_reference_types.csv +29 -0
- data/db/seeds_reference_types.numbers +0 -0
- data/db/structure.sql +1 -38
- data/lib/compose.yml +31 -0
- data/lib/generators/geoblacklight_admin/config_generator.rb +53 -12
- data/lib/generators/geoblacklight_admin/install_generator.rb +8 -0
- data/lib/generators/geoblacklight_admin/templates/btaa_sample_records.csv +5 -0
- data/lib/generators/geoblacklight_admin/templates/config/database.yml +1 -1
- data/lib/generators/geoblacklight_admin/templates/config/initializers/devise.rb +0 -2
- data/lib/generators/geoblacklight_admin/templates/config/initializers/mime_types.rb +1 -0
- data/lib/generators/geoblacklight_admin/templates/demo-app/Dockerfile +31 -0
- data/lib/generators/geoblacklight_admin/templates/demo-app/compose.yml +42 -0
- data/lib/generators/geoblacklight_admin/templates/demo-app/start-server.sh +21 -0
- data/lib/geoblacklight_admin/engine.rb +4 -0
- data/lib/geoblacklight_admin/rake_task.rb +2 -0
- data/lib/geoblacklight_admin/tasks/distributions.rake +69 -0
- data/lib/geoblacklight_admin/tasks/images.rake +1 -0
- data/lib/geoblacklight_admin/tasks/solr.rake +31 -0
- data/lib/geoblacklight_admin/version.rb +1 -1
- data/lib/geoblacklight_admin.rb +4 -0
- metadata +137 -53
- data/app/helpers/import_documents_helper.rb +0 -5
- data/app/javascript/entrypoints/engine.js +0 -8
- data/config/locales/devise_invitable.en.yml +0 -31
- data/lib/generators/geoblacklight_admin/templates/devise/invitations/edit.html.erb +0 -15
- data/lib/generators/geoblacklight_admin/templates/devise/invitations/new.html.erb +0 -15
- data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.html.erb +0 -11
- data/lib/generators/geoblacklight_admin/templates/devise/mailer/invitation_instructions.text.erb +0 -11
data/app/javascript/index.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
24
|
+
document = versions[doc.current_version].reify
|
|
25
25
|
document&.skip_callbacks = true
|
|
26
26
|
|
|
27
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
data/app/jobs/export_job.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
@
|
|
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
|
-
|
|
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: "
|
|
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
|
|
45
|
-
notification.record.file.attach(io: @
|
|
46
|
-
content_type: "
|
|
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
|
-
|
|
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
|
data/app/jobs/import_run_job.rb
CHANGED
|
@@ -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
|
|
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
|
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
|
data/app/models/bulk_action.rb
CHANGED
|
@@ -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
|
|
@@ -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
|
-
|
|
11
|
-
label: "
|
|
12
|
-
uri: "
|
|
10
|
+
arcgis_dynamic_map_layer: {
|
|
11
|
+
label: "ArcGIS DynamicMapLayer",
|
|
12
|
+
uri: "urn:x-esri:serviceType:ArcGIS#DynamicMapLayer"
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
label: "
|
|
16
|
-
uri: "
|
|
14
|
+
arcgis_feature_layer: {
|
|
15
|
+
label: "ArcGIS FeatureLayer",
|
|
16
|
+
uri: "urn:x-esri:serviceType:ArcGIS#FeatureLayer"
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
label: "
|
|
20
|
-
uri: "
|
|
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
|
-
|
|
67
|
-
label: "
|
|
68
|
-
uri: "
|
|
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
|
-
|
|
87
|
-
label: "
|
|
88
|
-
uri: "
|
|
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
|
-
|
|
95
|
-
label: "
|
|
96
|
-
uri: "https://
|
|
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
|
-
|
|
103
|
-
label: "
|
|
104
|
-
uri: "
|
|
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
|