iqvoc 4.15.0 → 4.16.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/CHANGELOG.md +17 -0
- data/Gemfile +6 -4
- data/app/aides/skos_exporter.rb +71 -43
- data/app/assets/builds/application.css +22548 -0
- data/app/assets/builds/application.js +18468 -0
- data/app/assets/builds/application.js.map +7 -0
- data/app/assets/builds/manifest.js +17848 -0
- data/app/assets/builds/manifest.js.map +7 -0
- data/app/controllers/concerns/controller_extensions.rb +11 -0
- data/app/controllers/exports_controller.rb +2 -4
- data/app/controllers/remote_labels_controller.rb +14 -2
- data/app/controllers/search_results_controller.rb +22 -11
- data/app/exceptions/service_unavailable_error.rb +8 -0
- data/app/helpers/link_helper.rb +4 -0
- data/app/helpers/rdf_helper.rb +9 -2
- data/app/jobs/export_job.rb +1 -1
- data/app/jobs/reverse_match_job.rb +3 -3
- data/app/models/concept/base.rb +4 -3
- data/app/models/dataset/adaptors/iqvoc/label_adaptor.rb +4 -2
- data/app/models/dataset/iqvoc_dataset.rb +6 -1
- data/app/models/export.rb +8 -1
- data/app/models/note/base.rb +6 -0
- data/app/models/note/skos/base.rb +1 -1
- data/app/models/note/skos/change_note.rb +1 -1
- data/app/views/exports/index.html.erb +13 -4
- data/app/views/hierarchy/show.iqrdf +1 -1
- data/config/application.rb +2 -2
- data/config/engine.rb +2 -1
- data/config/initializers/iqvoc.rb +1 -0
- data/config/initializers/linked_data.rb +13 -1
- data/config/locales/activerecord.de.yml +1 -0
- data/config/locales/activerecord.en.yml +1 -0
- data/config/locales/de.yml +3 -0
- data/config/locales/en.yml +3 -0
- data/db/migrate/20260723172701_add_zip_to_exports.rb +5 -0
- data/db/schema.rb +64 -161
- data/iqvoc.gemspec +6 -5
- data/lib/generators/app/template.rb +1 -0
- data/lib/iqvoc/configuration/additional_associations.rb +54 -0
- data/lib/iqvoc/configuration/concept.rb +15 -3
- data/lib/iqvoc/configuration/core.rb +1 -0
- data/lib/iqvoc/environments/production.rb +1 -1
- data/lib/iqvoc/environments/test.rb +1 -1
- data/lib/iqvoc/version.rb +1 -1
- data/lib/iqvoc.rb +1 -0
- data/lib/tasks/exporter.rake +14 -4
- data/test/controllers/remote_labels_controller_test.rb +90 -0
- data/test/integration/reverse_match_job_test.rb +1 -1
- data/test/integration_test_helper.rb +2 -2
- data/test/models/additional_associations_test.rb +67 -0
- data/test/models/skos_export_link_test.rb +93 -0
- data/test/models/skos_export_test.rb +71 -0
- metadata +51 -20
- data/Gemfile.lock +0 -607
- data/test/models/hygiene_test.rb +0 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a27e9eb52dbc92be01a2194a08bb1a92c3442b3313e6713f260eb1768717521
|
|
4
|
+
data.tar.gz: d7bdcfb9a215af609f10ec61ee4a2371a31411d06c46880416a3ab9287b12c67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1341cc25b7788bab29de5a9a5d9516c5e178111cbe59b3f431fdba8068a9efb931763b41c37369eb864a6fbaf47e428ae01f0b475967d098410d5dd0e07ccea2
|
|
7
|
+
data.tar.gz: e6c0a6e1015024ce4dd3b6650dbe31198a17012cc1015049750f186d2e7b017d18c0914ba52c33457e8538f892ddebc2b0776fc1083f64c33c3f69d90b554a92
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [4.16.0]
|
|
2
|
+
|
|
3
|
+
* export SKOS as a ZIP archive, via `rake iqvoc:export ZIP=true` and the web interface
|
|
4
|
+
* add `LINK` to `rake iqvoc:export`, keeping a symlink on the newest dump
|
|
5
|
+
* add `Iqvoc.export_file_prefix` to name dumps after the hosting application
|
|
6
|
+
* speed up the SKOS export on a large thesaurus
|
|
7
|
+
* restore preloading of concept associations, which had silently become a no-op
|
|
8
|
+
* let additional associations declare their `inverse_of`, so that rendering a
|
|
9
|
+
child no longer reloads the record it belongs to
|
|
10
|
+
* look up the concept scheme once per export instead of once per concept
|
|
11
|
+
* sort note annotations in Ruby, so that preloaded annotations are used
|
|
12
|
+
* no longer load ActiveStorage and ActionText, which were unused
|
|
13
|
+
* upgrade to Faraday v2
|
|
14
|
+
* render 503 when a remote label target is unreachable
|
|
15
|
+
* fix rendering the concept scheme
|
|
16
|
+
* fix i18n glitches in exports
|
|
17
|
+
|
|
1
18
|
## [4.15.0]
|
|
2
19
|
|
|
3
20
|
* upgrade to Rails v8.1
|
data/Gemfile
CHANGED
|
@@ -19,7 +19,7 @@ source 'https://rubygems.org'
|
|
|
19
19
|
# TODO: The following dependencies could be included by the "gemspec" command.
|
|
20
20
|
# There is only one problem: gemspec puts the dependencies automatically to a
|
|
21
21
|
# group (:development by default). This is not what we need.
|
|
22
|
-
gem 'rails', '
|
|
22
|
+
gem 'rails', '>= 8.1.2', '< 9'
|
|
23
23
|
gem 'puma', '>= 5.0'
|
|
24
24
|
gem 'kaminari'
|
|
25
25
|
gem 'authlogic'
|
|
@@ -27,11 +27,12 @@ gem 'scrypt'
|
|
|
27
27
|
gem 'cancancan'
|
|
28
28
|
gem 'iq_rdf'
|
|
29
29
|
gem 'iq_triplestorage'
|
|
30
|
-
|
|
30
|
+
# TODO: Remove once a Rails 8.1.x release with the fix shipped: https://github.com/rails/rails/pull/58601
|
|
31
|
+
gem 'json', '< 3'
|
|
31
32
|
gem 'csv'
|
|
32
33
|
gem 'rails_autolink'
|
|
33
|
-
gem 'faraday', '
|
|
34
|
-
gem '
|
|
34
|
+
gem 'faraday', '~> 2.0'
|
|
35
|
+
gem 'faraday-follow_redirects', '~> 0.5'
|
|
35
36
|
gem 'nokogiri'
|
|
36
37
|
gem 'linkeddata'
|
|
37
38
|
gem 'rdf-vocab'
|
|
@@ -41,6 +42,7 @@ gem 'apipie-rails'
|
|
|
41
42
|
gem 'maruku', require: false # needed for apipie documentation
|
|
42
43
|
gem 'database_cleaner'
|
|
43
44
|
gem 'delayed_job_active_record'
|
|
45
|
+
gem 'rubyzip'
|
|
44
46
|
gem 'carrierwave'
|
|
45
47
|
gem 'carrierwave-i18n'
|
|
46
48
|
gem 'faucet_pipeline_rails'
|
data/app/aides/skos_exporter.rb
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
require 'iq_rdf'
|
|
2
2
|
require 'uri'
|
|
3
3
|
require 'fileutils'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
require 'zip'
|
|
4
6
|
|
|
5
7
|
class SkosExporter
|
|
6
8
|
include RdfHelper # necessary to use render_concept helper
|
|
7
9
|
include RdfNamespacesHelper
|
|
8
10
|
include Rails.application.routes.url_helpers
|
|
9
11
|
|
|
10
|
-
def initialize(file_path, type, default_namespace_url, logger = Rails.logger)
|
|
12
|
+
def initialize(file_path, type, default_namespace_url, logger = Rails.logger, zip: false, entry_name: nil, link_path: nil, batch_size: 500)
|
|
11
13
|
default_url_options[:port] = URI.parse(default_namespace_url).port
|
|
12
14
|
default_url_options[:host] = URI.parse(default_namespace_url).to_s.gsub(/\/$/, '')
|
|
13
15
|
|
|
14
16
|
@file_path = file_path
|
|
15
17
|
@type = type
|
|
16
18
|
@logger = logger
|
|
19
|
+
@zip = zip
|
|
20
|
+
@entry_name = entry_name
|
|
21
|
+
@link_path = link_path
|
|
22
|
+
@batch_size = batch_size
|
|
17
23
|
@document = IqRdf::Document.new
|
|
18
24
|
|
|
19
25
|
unless ['ttl', 'nt', 'xml'].include? @type
|
|
@@ -48,6 +54,7 @@ class SkosExporter
|
|
|
48
54
|
|
|
49
55
|
# saving export to disk
|
|
50
56
|
save_file(@file_path, @type, @document)
|
|
57
|
+
update_link(@link_path, @file_path) if @link_path
|
|
51
58
|
|
|
52
59
|
done = Time.now
|
|
53
60
|
@logger.info "Export Job finished in #{(done - start).to_i} seconds."
|
|
@@ -69,67 +76,88 @@ class SkosExporter
|
|
|
69
76
|
def add_collections(document)
|
|
70
77
|
@logger.info 'Exporting collections...'
|
|
71
78
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
collections = Iqvoc::Collection.base_class.published.order('id').limit(100).offset(offset)
|
|
75
|
-
limit = collections.size < 100 ? collections.size : 100
|
|
76
|
-
break if collections.size == 0
|
|
77
|
-
|
|
79
|
+
total = 0
|
|
80
|
+
Iqvoc::Collection.base_class.published.find_in_batches(batch_size: @batch_size) do |collections|
|
|
78
81
|
# Todo: Preloading???
|
|
79
|
-
collections.each
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
@logger.info "Collections #{offset+1}-#{offset+limit} exported."
|
|
84
|
-
offset += collections.size # Size is important!
|
|
82
|
+
collections.each { |collection| render_collection(document, collection) }
|
|
83
|
+
@logger.info "Collections #{total + 1}-#{total + collections.size} exported."
|
|
84
|
+
total += collections.size
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
@logger.info "Finished exporting collections (#{
|
|
87
|
+
@logger.info "Finished exporting collections (#{total} collections exported)."
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
def add_concepts(document)
|
|
91
91
|
@logger.info 'Exporting concepts...'
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
# one query. We don't want that! So let's do it manually :-)
|
|
101
|
-
Iqvoc::Concept.base_class.preload(concepts,
|
|
102
|
-
Iqvoc::Concept.base_class.default_includes + [
|
|
93
|
+
total = 0
|
|
94
|
+
Iqvoc::Concept.base_class.published.find_in_batches(batch_size: @batch_size) do |concepts|
|
|
95
|
+
# rendering touches every association below, so preload them per batch
|
|
96
|
+
# rather than letting each concept load them one by one. Note that this
|
|
97
|
+
# has to be the Preloader: Model.preload builds a relation and would
|
|
98
|
+
# leave the records passed to it untouched.
|
|
99
|
+
associations = Iqvoc::Concept.base_class.default_includes + [
|
|
103
100
|
:matches,
|
|
104
101
|
:collection_members,
|
|
105
102
|
:notations,
|
|
106
|
-
{ relations: :target, labelings: :target
|
|
107
|
-
]
|
|
103
|
+
{ relations: :target, labelings: :target }
|
|
104
|
+
] + Iqvoc::Concept.additional_association_preloads
|
|
105
|
+
# notes are rendered behind the same condition, see render_concept
|
|
106
|
+
associations << { notes: :annotations } if Iqvoc.rdf_show_change_notes
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
render_concept(document, concept, true)
|
|
111
|
-
end
|
|
108
|
+
ActiveRecord::Associations::Preloader.new(records: concepts, associations: associations).call
|
|
112
109
|
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
concepts.each { |concept| render_concept(document, concept, true) }
|
|
111
|
+
@logger.info "Concepts #{total + 1}-#{total + concepts.size} exported."
|
|
112
|
+
total += concepts.size
|
|
115
113
|
end
|
|
116
114
|
|
|
117
|
-
@logger.info "Finished exporting concepts (#{
|
|
115
|
+
@logger.info "Finished exporting concepts (#{total} concepts exported)."
|
|
118
116
|
end
|
|
119
117
|
|
|
120
118
|
def save_file(file_path, type, content)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
# e.g not writable
|
|
130
|
-
ensure
|
|
131
|
-
file.close unless file == nil
|
|
119
|
+
serialized = serialize_rdf(content, type)
|
|
120
|
+
create_directory(file_path)
|
|
121
|
+
|
|
122
|
+
@logger.info "Saving export to '#{file_path}'"
|
|
123
|
+
if @zip
|
|
124
|
+
save_zipped(file_path, serialized)
|
|
125
|
+
else
|
|
126
|
+
File.write(file_path, serialized)
|
|
132
127
|
end
|
|
128
|
+
rescue IOError, SystemCallError, Zip::Error => e
|
|
129
|
+
@logger.error "Failed to save export: #{e.message}"
|
|
130
|
+
raise
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def save_zipped(file_path, serialized)
|
|
134
|
+
entry_name = @entry_name || File.basename(file_path, '.zip')
|
|
135
|
+
Zip::OutputStream.open(file_path) do |zos|
|
|
136
|
+
zos.put_next_entry(entry_name)
|
|
137
|
+
zos.write(serialized)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# points the symlink at the file just written, so that a stable URL can serve
|
|
142
|
+
# the most recent export while its file name carries the creation date
|
|
143
|
+
def update_link(link_path, file_path)
|
|
144
|
+
link_dir = File.dirname(File.expand_path(link_path))
|
|
145
|
+
FileUtils.mkdir_p(link_dir)
|
|
146
|
+
|
|
147
|
+
# a relative target survives the export directory being moved
|
|
148
|
+
target = Pathname.new(File.expand_path(file_path)).
|
|
149
|
+
relative_path_from(Pathname.new(link_dir)).to_s
|
|
150
|
+
|
|
151
|
+
# symlink under a temporary name, then rename it into place: rename is
|
|
152
|
+
# atomic, so a concurrent download never sees a missing link
|
|
153
|
+
tmp_path = "#{link_path}.tmp#{Process.pid}"
|
|
154
|
+
File.symlink(target, tmp_path)
|
|
155
|
+
File.rename(tmp_path, link_path)
|
|
156
|
+
|
|
157
|
+
@logger.info "Updated symlink '#{link_path}' -> '#{target}'"
|
|
158
|
+
rescue IOError, SystemCallError => e
|
|
159
|
+
@logger.error "Failed to update symlink: #{e.message}"
|
|
160
|
+
raise
|
|
133
161
|
end
|
|
134
162
|
|
|
135
163
|
def create_directory(file_path)
|