ddr-models 2.11.0 → 3.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +7 -6
- data/Gemfile +2 -3
- data/Rakefile +5 -5
- data/app/controllers/users/sessions_controller.rb +5 -0
- data/app/helpers/models_helper.rb +7 -0
- data/app/models/attachment.rb +3 -5
- data/app/models/collection.rb +12 -79
- data/app/models/component.rb +8 -67
- data/app/models/item.rb +8 -73
- data/app/models/target.rb +6 -5
- data/config/initializers/active_fedora_base.rb +11 -30
- data/config/initializers/{active_fedora_datastream.rb → active_fedora_file.rb} +1 -1
- data/config/initializers/devise.rb +2 -3
- data/config/initializers/subscriptions.rb +2 -19
- data/ddr-models.gemspec +10 -14
- data/lib/ddr/actions/fixity_check.rb +1 -1
- data/lib/ddr/actions/virus_check.rb +17 -10
- data/lib/ddr/auth.rb +6 -38
- data/lib/ddr/auth/ability.rb +1 -5
- data/lib/ddr/auth/ability_definitions/collection_ability_definitions.rb +0 -16
- data/lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb +10 -4
- data/lib/ddr/auth/ability_definitions/role_based_ability_definitions.rb +16 -9
- data/lib/ddr/auth/ability_factory.rb +25 -2
- data/lib/ddr/auth/abstract_ability.rb +1 -2
- data/lib/ddr/auth/auth_context.rb +0 -18
- data/lib/ddr/auth/auth_context_factory.rb +2 -0
- data/lib/ddr/auth/group.rb +0 -6
- data/lib/ddr/auth/grouper_gateway.rb +0 -24
- data/lib/ddr/auth/permissions.rb +1 -12
- data/lib/ddr/auth/role_based_access_controls_enforcement.rb +5 -5
- data/lib/ddr/auth/roles.rb +1 -11
- data/lib/ddr/auth/roles/role_set.rb +0 -7
- data/lib/ddr/auth/roles/roles_datastream.rb +9 -0
- data/lib/ddr/contacts.rb +25 -0
- data/lib/ddr/datastreams.rb +10 -28
- data/lib/ddr/datastreams/datastream_behavior.rb +30 -100
- data/lib/ddr/datastreams/descriptive_metadata_datastream.rb +28 -31
- data/lib/ddr/datastreams/fits_datastream.rb +9 -22
- data/lib/ddr/datastreams/metadata_datastream.rb +17 -31
- data/lib/ddr/derivatives.rb +13 -16
- data/lib/ddr/derivatives/derivative.rb +68 -0
- data/lib/ddr/derivatives/{generator.rb → generators/generator.rb} +11 -7
- data/lib/ddr/derivatives/generators/png_generator.rb +23 -0
- data/lib/ddr/derivatives/generators/ptif_generator.rb +56 -0
- data/lib/ddr/derivatives/multires_image.rb +59 -0
- data/lib/ddr/derivatives/thumbnail.rb +36 -0
- data/lib/ddr/events.rb +0 -1
- data/lib/ddr/events/deletion_event.rb +9 -5
- data/lib/ddr/events/event.rb +8 -13
- data/lib/ddr/events/fixity_check_event.rb +0 -6
- data/lib/ddr/events/ingestion_event.rb +9 -5
- data/lib/ddr/events/update_event.rb +4 -17
- data/lib/ddr/index.rb +4 -4
- data/lib/ddr/index/abstract_query_result.rb +4 -3
- data/lib/ddr/index/connection.rb +9 -28
- data/lib/ddr/index/csv_query_result.rb +32 -47
- data/lib/ddr/index/field.rb +1 -11
- data/lib/ddr/index/fields.rb +16 -99
- data/lib/ddr/index/filter.rb +30 -103
- data/lib/ddr/index/filters.rb +19 -0
- data/lib/ddr/index/query.rb +11 -58
- data/lib/ddr/index/query_builder.rb +36 -147
- data/lib/ddr/index/query_clause.rb +19 -79
- data/lib/ddr/index/query_result.rb +4 -36
- data/lib/ddr/index/query_value.rb +18 -0
- data/lib/ddr/index/response.rb +2 -19
- data/lib/ddr/jobs.rb +12 -0
- data/lib/ddr/jobs/fits_file_characterization.rb +51 -0
- data/lib/ddr/jobs/permanent_id.rb +23 -0
- data/lib/ddr/managers.rb +1 -0
- data/lib/ddr/managers/derivatives_manager.rb +53 -93
- data/lib/ddr/managers/permanent_id_manager.rb +91 -0
- data/lib/ddr/managers/technical_metadata_manager.rb +10 -24
- data/lib/ddr/managers/workflow_manager.rb +10 -29
- data/lib/ddr/models.rb +50 -101
- data/lib/ddr/models/access_controllable.rb +12 -0
- data/lib/ddr/models/admin_set.rb +5 -16
- data/lib/ddr/models/base.rb +45 -165
- data/lib/ddr/models/describable.rb +19 -21
- data/lib/ddr/models/engine.rb +11 -39
- data/lib/ddr/models/error.rb +0 -3
- data/lib/ddr/models/file_management.rb +36 -72
- data/lib/ddr/models/finding_aid.rb +2 -35
- data/lib/ddr/models/fixity_checkable.rb +4 -0
- data/lib/ddr/models/governable.rb +3 -1
- data/lib/ddr/models/has_admin_metadata.rb +82 -56
- data/lib/ddr/models/has_attachments.rb +3 -1
- data/lib/ddr/models/has_children.rb +3 -7
- data/lib/ddr/models/has_content.rb +35 -32
- data/lib/ddr/models/has_multires_image.rb +7 -12
- data/lib/ddr/models/has_struct_metadata.rb +44 -6
- data/lib/ddr/models/has_thumbnail.rb +1 -4
- data/lib/ddr/models/indexing.rb +97 -186
- data/lib/ddr/models/licenses/admin_policy_license.rb +11 -0
- data/lib/ddr/models/licenses/effective_license.rb +9 -0
- data/lib/ddr/models/licenses/inherited_license.rb +9 -0
- data/lib/ddr/models/licenses/license.rb +21 -0
- data/lib/ddr/models/licenses/parent_license.rb +11 -0
- data/lib/ddr/models/metadata/descriptive_metadata.rb +50 -0
- data/lib/ddr/models/metadata/metadata.rb +37 -0
- data/lib/ddr/models/metadata/metadata_mapper.rb +32 -0
- data/lib/ddr/models/metadata/metadata_mappers.rb +18 -0
- data/lib/ddr/models/metadata/metadata_term.rb +24 -0
- data/lib/ddr/models/metadata/metadata_vocabularies.rb +18 -0
- data/lib/ddr/models/metadata/metadata_vocabulary.rb +34 -0
- data/lib/ddr/models/solr_document.rb +24 -156
- data/lib/ddr/models/struct_div.rb +63 -0
- data/lib/ddr/models/structure.rb +39 -175
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/models/year_facet.rb +118 -60
- data/lib/ddr/notifications.rb +12 -10
- data/lib/ddr/utils.rb +15 -28
- data/lib/ddr/vocab.rb +17 -15
- data/lib/ddr/vocab/asset.rb +17 -42
- data/lib/ddr/vocab/contact.rb +7 -5
- data/lib/ddr/vocab/display.rb +8 -6
- data/lib/ddr/vocab/duke_terms.rb +10 -8
- data/lib/ddr/vocab/rdf_vocabulary_parser.rb +39 -37
- data/lib/ddr/vocab/roles.rb +19 -17
- data/lib/ddr/vocab/sources/duketerms.rdf +8 -22
- data/lib/ddr/vocab/vocabulary.rb +26 -26
- data/spec/auth/ability_factory_spec.rb +1 -18
- data/spec/auth/ability_spec.rb +15 -119
- data/spec/auth/effective_permissions_spec.rb +1 -1
- data/spec/auth/effective_roles_spec.rb +1 -1
- data/spec/auth/ldap_gateway_spec.rb +9 -0
- data/spec/contacts/contacts_spec.rb +26 -0
- data/spec/controllers/including_role_based_access_controls_enforcement_spec.rb +5 -5
- data/spec/derivatives/multires_image_spec.rb +48 -0
- data/spec/derivatives/png_generator_spec.rb +8 -13
- data/spec/derivatives/ptif_generator_spec.rb +11 -9
- data/spec/derivatives/thumbnail_spec.rb +48 -0
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/schema.rb +23 -25
- data/spec/factories/attachment_factories.rb +2 -2
- data/spec/factories/collection_factories.rb +2 -3
- data/spec/factories/component_factories.rb +2 -2
- data/spec/factories/item_factories.rb +2 -2
- data/spec/factories/structure_factories.rb +2 -8
- data/spec/factories/test_model_factories.rb +12 -4
- data/spec/fixtures/fits/document.xml +44 -42
- data/spec/fixtures/fits/image.xml +41 -42
- data/spec/helpers/models_helper_spec.rb +11 -0
- data/spec/index/filter_spec.rb +30 -208
- data/spec/index/filters_spec.rb +17 -0
- data/spec/index/query_spec.rb +10 -82
- data/spec/jobs/fits_file_characterization_spec.rb +52 -0
- data/spec/managers/derivatives_manager_spec.rb +105 -107
- data/spec/managers/technical_metadata_manager_spec.rb +27 -34
- data/spec/models/active_fedora_base_spec.rb +105 -5
- data/spec/models/active_fedora_datastream_spec.rb +39 -106
- data/spec/models/admin_set_spec.rb +10 -43
- data/spec/models/attachment_spec.rb +2 -3
- data/spec/models/collection_spec.rb +11 -225
- data/spec/models/component_spec.rb +4 -106
- data/spec/models/descriptive_metadata_spec.rb +38 -0
- data/spec/models/effective_license_spec.rb +64 -0
- data/spec/models/events_spec.rb +59 -52
- data/spec/models/file_management_spec.rb +13 -113
- data/spec/models/finding_aid_spec.rb +8 -31
- data/spec/models/has_admin_metadata_spec.rb +122 -131
- data/spec/models/has_children_spec.rb +3 -3
- data/spec/models/has_struct_metadata_spec.rb +37 -50
- data/spec/models/indexing_spec.rb +23 -160
- data/spec/models/item_spec.rb +2 -133
- data/spec/models/license_spec.rb +24 -0
- data/spec/models/solr_document_spec.rb +47 -236
- data/spec/models/struct_div_spec.rb +70 -0
- data/spec/models/structure_spec.rb +11 -89
- data/spec/models/target_spec.rb +2 -4
- data/spec/models/year_facet_spec.rb +23 -50
- data/spec/spec_helper.rb +13 -17
- data/spec/support/ezid_mock_identifier.rb +2 -2
- data/spec/support/shared_examples_for_auth_contexts.rb +0 -33
- data/spec/support/shared_examples_for_ddr_models.rb +94 -142
- data/spec/support/shared_examples_for_describables.rb +36 -31
- data/spec/support/shared_examples_for_governables.rb +2 -3
- data/spec/support/shared_examples_for_has_content.rb +46 -101
- data/spec/support/shared_examples_for_indexing.rb +6 -6
- data/spec/support/shared_examples_for_non_collection_models.rb +1 -32
- data/spec/support/structural_metadata_helper.rb +59 -230
- data/spec/utils_spec.rb +2 -0
- metadata +96 -229
- data/.ruby-version +0 -1
- data/config/initializers/rsolr_monkey_patches.rb +0 -7
- data/config/initializers/rubydora_monkey_patch.rb +0 -11
- data/config/locales/ddr-models.en.yml +0 -81
- data/db/migrate/20161021201011_add_permanent_id_to_events.rb +0 -8
- data/lib/ddr/auth/ability_definitions/admin_set_ability_definitions.rb +0 -9
- data/lib/ddr/auth/ability_definitions/lock_ability_definitions.rb +0 -13
- data/lib/ddr/auth/ability_definitions/publication_ability_definitions.rb +0 -16
- data/lib/ddr/datastreams/administrative_metadata_datastream.rb +0 -75
- data/lib/ddr/datastreams/caption_datastream.rb +0 -5
- data/lib/ddr/datastreams/content_datastream.rb +0 -17
- data/lib/ddr/datastreams/delete_external_files.rb +0 -29
- data/lib/ddr/datastreams/external_file_datastream.rb +0 -80
- data/lib/ddr/datastreams/intermediate_file_datastream.rb +0 -5
- data/lib/ddr/datastreams/multires_image_datastream.rb +0 -5
- data/lib/ddr/datastreams/streamable_media_datastream.rb +0 -5
- data/lib/ddr/derivatives/png_generator.rb +0 -17
- data/lib/ddr/derivatives/ptif_generator.rb +0 -55
- data/lib/ddr/derivatives/update_derivatives.rb +0 -25
- data/lib/ddr/events/deaccession_event.rb +0 -8
- data/lib/ddr/index/field_attribute.rb +0 -22
- data/lib/ddr/index/query_params.rb +0 -40
- data/lib/ddr/index/sort_order.rb +0 -28
- data/lib/ddr/models/cache.rb +0 -20
- data/lib/ddr/models/captionable.rb +0 -37
- data/lib/ddr/models/contact.rb +0 -23
- data/lib/ddr/models/file_characterization.rb +0 -37
- data/lib/ddr/models/has_intermediate_file.rb +0 -41
- data/lib/ddr/models/language.rb +0 -31
- data/lib/ddr/models/media_type.rb +0 -22
- data/lib/ddr/models/permanent_id.rb +0 -240
- data/lib/ddr/models/rights_statement.rb +0 -25
- data/lib/ddr/models/streamable.rb +0 -37
- data/lib/ddr/models/structures/agent.rb +0 -49
- data/lib/ddr/models/structures/component_type_term.rb +0 -29
- data/lib/ddr/models/structures/div.rb +0 -64
- data/lib/ddr/models/structures/f_locat.rb +0 -54
- data/lib/ddr/models/structures/file.rb +0 -52
- data/lib/ddr/models/structures/file_grp.rb +0 -35
- data/lib/ddr/models/structures/file_sec.rb +0 -22
- data/lib/ddr/models/structures/fptr.rb +0 -31
- data/lib/ddr/models/structures/mets_hdr.rb +0 -37
- data/lib/ddr/models/structures/mptr.rb +0 -49
- data/lib/ddr/models/structures/struct_map.rb +0 -40
- data/lib/ddr/models/with_content_file.rb +0 -37
- data/spec/datastreams/external_file_datastream_spec.rb +0 -48
- data/spec/dummy/config/structure_component_type.yml +0 -18
- data/spec/fixtures/abcd1234.vtt +0 -38
- data/spec/fixtures/arrow1rightred_e0.gif +0 -0
- data/spec/fixtures/extractedText1.txt +0 -1
- data/spec/fixtures/extractedText2.txt +0 -1
- data/spec/fixtures/extractedText3.txt +0 -3
- data/spec/fixtures/imageA.jpg +0 -0
- data/spec/fixtures/imageB.jpg +0 -0
- data/spec/index/csv_query_result_spec.rb +0 -44
- data/spec/index/fields_spec.rb +0 -380
- data/spec/index/query_builder_spec.rb +0 -140
- data/spec/index/query_clause_spec.rb +0 -68
- data/spec/models/cache_spec.rb +0 -32
- data/spec/models/contact_spec.rb +0 -56
- data/spec/models/descriptive_metadata_datastream_spec.rb +0 -139
- data/spec/models/file_characterization_spec.rb +0 -39
- data/spec/models/language_spec.rb +0 -59
- data/spec/models/media_type_spec.rb +0 -46
- data/spec/models/permanent_id_spec.rb +0 -432
- data/spec/models/rights_statement_spec.rb +0 -55
- data/spec/models/structures/agent_spec.rb +0 -30
- data/spec/models/structures/component_type_term_spec.rb +0 -14
- data/spec/models/structures/div_spec.rb +0 -26
- data/spec/models/structures/f_locat_spec.rb +0 -78
- data/spec/models/structures/file_grp_spec.rb +0 -23
- data/spec/models/structures/file_sec_spec.rb +0 -22
- data/spec/models/structures/file_spec.rb +0 -60
- data/spec/models/structures/fptr_spec.rb +0 -23
- data/spec/models/structures/mets_hdr_spec.rb +0 -26
- data/spec/models/structures/mptr_spec.rb +0 -25
- data/spec/models/structures/struct_map_spec.rb +0 -24
- data/spec/models/with_content_file_spec.rb +0 -37
- data/spec/support/shared_examples_for_associations.rb +0 -8
- data/spec/support/shared_examples_for_captionable.rb +0 -23
- data/spec/support/shared_examples_for_has_intermediate_file.rb +0 -28
- data/spec/support/shared_examples_for_publication.rb +0 -43
- data/spec/support/shared_examples_for_streamable_media.rb +0 -23
data/lib/ddr/events.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
module Ddr
|
2
|
-
|
3
|
-
|
1
|
+
module Ddr
|
2
|
+
module Events
|
3
|
+
class DeletionEvent < Event
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
include PreservationEventBehavior
|
6
|
+
|
7
|
+
self.description = "Object deleted"
|
8
|
+
self.preservation_event_type = :del
|
9
|
+
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
data/lib/ddr/events/event.rb
CHANGED
@@ -39,20 +39,10 @@ module Ddr
|
|
39
39
|
# Receive message sent by ActiveSupport::Notifications
|
40
40
|
def self.call(*args)
|
41
41
|
notification = ActiveSupport::Notifications::Event.new(*args)
|
42
|
-
|
43
|
-
payload[:event_date_time] ||= notification.time
|
44
|
-
create do |event|
|
45
|
-
event.attributes = payload.select { |k, v| event.has_attribute?(k) }
|
46
|
-
yield [event, notification] if block_given?
|
47
|
-
end
|
42
|
+
create(notification.payload)
|
48
43
|
end
|
49
44
|
|
50
|
-
#
|
51
|
-
def self.repository_software
|
52
|
-
@@repository_software ||= ActiveFedora::Base.connection_for_pid(0).repository_profile
|
53
|
-
.values_at(:repositoryName, :repositoryVersion)
|
54
|
-
.join(" ")
|
55
|
-
end
|
45
|
+
# Scopes
|
56
46
|
|
57
47
|
def self.for_object(obj)
|
58
48
|
for_pid(obj.pid)
|
@@ -62,6 +52,8 @@ module Ddr
|
|
62
52
|
where(pid: pid)
|
63
53
|
end
|
64
54
|
|
55
|
+
# Rendering methods
|
56
|
+
|
65
57
|
def display_type
|
66
58
|
# Ddr::Events::UpdateEvent => "Update"
|
67
59
|
@display_type ||= self.class.to_s.split("::").last.sub("Event", "").titleize
|
@@ -75,6 +67,8 @@ module Ddr
|
|
75
67
|
comment.present? ? comment : summary
|
76
68
|
end
|
77
69
|
|
70
|
+
# Outcome methods
|
71
|
+
|
78
72
|
def success!
|
79
73
|
self.outcome = SUCCESS
|
80
74
|
end
|
@@ -91,6 +85,7 @@ module Ddr
|
|
91
85
|
outcome == FAILURE
|
92
86
|
end
|
93
87
|
|
88
|
+
# Object getter and setter
|
94
89
|
def object
|
95
90
|
@object ||= ActiveFedora::Base.find(pid) if pid
|
96
91
|
end
|
@@ -121,7 +116,7 @@ module Ddr
|
|
121
116
|
protected
|
122
117
|
|
123
118
|
def set_defaults
|
124
|
-
self.attributes = defaults.reject { |attr, val| attribute_present?
|
119
|
+
self.attributes = defaults.reject { |attr, val| attribute_present? attr }
|
125
120
|
end
|
126
121
|
|
127
122
|
def defaults
|
@@ -1,8 +1,12 @@
|
|
1
|
-
module Ddr
|
2
|
-
|
3
|
-
|
1
|
+
module Ddr
|
2
|
+
module Events
|
3
|
+
class IngestionEvent < Event
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
include PreservationEventBehavior
|
6
|
+
|
7
|
+
self.preservation_event_type = :ing
|
8
|
+
self.description = "Object ingested into the repository"
|
9
|
+
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
@@ -1,22 +1,9 @@
|
|
1
|
-
module Ddr
|
2
|
-
|
1
|
+
module Ddr
|
2
|
+
module Events
|
3
|
+
class UpdateEvent < Event
|
3
4
|
|
4
|
-
|
5
|
+
self.description = "Object updated"
|
5
6
|
|
6
|
-
def self.call(*args)
|
7
|
-
super do |event, notification|
|
8
|
-
attrs_changed = notification.payload[:attributes_changed]
|
9
|
-
ds_changed = notification.payload[:datastreams_changed]
|
10
|
-
detail = [
|
11
|
-
"Datastreams changed: #{ds_changed.join(', ')}",
|
12
|
-
event.detail,
|
13
|
-
]
|
14
|
-
if attrs_changed.present?
|
15
|
-
detail << "Attributes changed: #{attrs_changed}"
|
16
|
-
end
|
17
|
-
event.detail = detail.compact.join("\n\n")
|
18
|
-
end
|
19
7
|
end
|
20
|
-
|
21
8
|
end
|
22
9
|
end
|
data/lib/ddr/index.rb
CHANGED
@@ -7,20 +7,20 @@ module Ddr
|
|
7
7
|
autoload :CSVQueryResult
|
8
8
|
autoload :DocumentBuilder
|
9
9
|
autoload :Field
|
10
|
-
autoload :FieldAttribute
|
11
10
|
autoload :Fields
|
12
11
|
autoload :Filter
|
12
|
+
autoload :Filters
|
13
|
+
autoload :LegacyLicenseFields
|
13
14
|
autoload :Query
|
14
15
|
autoload :QueryBuilder
|
15
16
|
autoload :QueryClause
|
16
|
-
autoload :QueryParams
|
17
17
|
autoload :QueryResult
|
18
|
+
autoload :QueryValue
|
18
19
|
autoload :Response
|
19
|
-
autoload :SortOrder
|
20
20
|
autoload :UniqueKeyField
|
21
21
|
|
22
22
|
def self.pids
|
23
|
-
builder = QueryBuilder.new
|
23
|
+
builder = QueryBuilder.new
|
24
24
|
query = builder.query
|
25
25
|
query.pids
|
26
26
|
end
|
@@ -2,15 +2,16 @@ module Ddr::Index
|
|
2
2
|
class AbstractQueryResult
|
3
3
|
include Enumerable
|
4
4
|
|
5
|
-
attr_reader :query
|
5
|
+
attr_reader :query, :conn
|
6
6
|
delegate :params, to: :query
|
7
7
|
|
8
8
|
def initialize(query)
|
9
|
-
@query = query
|
9
|
+
@query = query
|
10
|
+
@conn = Connection.new
|
10
11
|
end
|
11
12
|
|
12
13
|
def count
|
13
|
-
response =
|
14
|
+
response = conn.select(params, rows: 0)
|
14
15
|
response.num_found
|
15
16
|
end
|
16
17
|
|
data/lib/ddr/index/connection.rb
CHANGED
@@ -1,36 +1,17 @@
|
|
1
|
-
require "rsolr"
|
2
|
-
require "forwardable"
|
3
|
-
|
4
1
|
module Ddr::Index
|
5
|
-
|
6
|
-
# Wraps an RSolr connection
|
7
|
-
#
|
8
|
-
class Connection
|
9
|
-
|
10
|
-
module Methods
|
11
|
-
extend Forwardable
|
12
|
-
|
13
|
-
delegate [:get, :post, :paginate] => :solr
|
14
|
-
|
15
|
-
def solr
|
16
|
-
RSolr.connect(ActiveFedora.solr_config)
|
17
|
-
end
|
2
|
+
class Connection < SimpleDelegator
|
18
3
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def page(*args)
|
24
|
-
Response.new paginate(*args)
|
25
|
-
end
|
4
|
+
def initialize
|
5
|
+
super RSolr.connect(ActiveFedora.solr_config)
|
6
|
+
end
|
26
7
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
8
|
+
def select(params, extra={})
|
9
|
+
Response.new get("select", params: params.merge(extra))
|
30
10
|
end
|
31
11
|
|
32
|
-
|
33
|
-
|
12
|
+
def page(*args)
|
13
|
+
Response.new paginate(*args)
|
14
|
+
end
|
34
15
|
|
35
16
|
end
|
36
17
|
end
|
@@ -3,73 +3,58 @@ require "csv"
|
|
3
3
|
module Ddr::Index
|
4
4
|
class CSVQueryResult < AbstractQueryResult
|
5
5
|
|
6
|
-
MAX_ROWS
|
7
|
-
CSV_MV_SEPARATOR = ";"
|
6
|
+
MAX_ROWS = 10**8
|
8
7
|
|
9
|
-
|
8
|
+
COL_SEP = CSV::DEFAULT_OPTIONS[:col_sep].freeze
|
9
|
+
QUOTE_CHAR = CSV::DEFAULT_OPTIONS[:quote_char].freeze
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
SOLR_CSV_OPTS = {
|
12
|
+
"csv.header" => "false",
|
13
|
+
"csv.mv.separator" => "|",
|
14
|
+
"wt" => "csv",
|
15
|
+
}.freeze
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
CSV_OPTS = {
|
18
|
+
return_headers: true,
|
19
|
+
write_headers: true,
|
20
|
+
}.freeze
|
18
21
|
|
19
|
-
|
20
|
-
table.by_col_or_row![index_or_header]
|
21
|
-
end
|
22
|
+
attr_reader :csv_opts, :solr_csv_opts
|
22
23
|
|
23
|
-
def
|
24
|
-
|
25
|
-
end
|
24
|
+
def initialize(query, **opts)
|
25
|
+
super(query)
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
converters: [convert_semicolons, convert_escaped_newlines],
|
30
|
-
return_headers: false,
|
31
|
-
write_headers: true,
|
32
|
-
}
|
33
|
-
end
|
27
|
+
@solr_csv_opts = SOLR_CSV_OPTS.dup
|
28
|
+
@solr_csv_opts[:rows] ||= MAX_ROWS
|
34
29
|
|
35
|
-
|
36
|
-
|
37
|
-
"csv.header" => solr_csv_header?,
|
38
|
-
"rows" => solr_csv_rows,
|
39
|
-
"wt" => "csv",
|
40
|
-
}
|
41
|
-
end
|
30
|
+
@csv_opts = CSV_OPTS.dup
|
31
|
+
@csv_opts[:headers] = query.fields.map(&:label)
|
42
32
|
|
43
|
-
|
44
|
-
|
33
|
+
# Set column separator and quote character consistently
|
34
|
+
@csv_opts[:col_sep] = @solr_csv_opts["csv.separator"] = opts.fetch(:col_sep, COL_SEP)
|
35
|
+
@csv_opts[:quote_char] = @solr_csv_opts["csv.encapsulator"] = opts.fetch(:quote_char, QUOTE_CHAR)
|
45
36
|
end
|
46
37
|
|
47
|
-
def
|
48
|
-
|
38
|
+
def csv
|
39
|
+
CSV.new(data, csv_opts)
|
49
40
|
end
|
50
41
|
|
51
|
-
def
|
52
|
-
|
42
|
+
def each
|
43
|
+
csv.each
|
53
44
|
end
|
54
45
|
|
55
|
-
def
|
56
|
-
|
46
|
+
def to_s
|
47
|
+
csv.string
|
57
48
|
end
|
58
49
|
|
59
|
-
|
50
|
+
private
|
51
|
+
|
52
|
+
def csv_params
|
60
53
|
params.merge(solr_csv_opts)
|
61
54
|
end
|
62
55
|
|
63
56
|
def data
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
def convert_semicolons
|
68
|
-
lambda { |f| f.gsub(/\\#{CSV_MV_SEPARATOR}/, CSV_MV_SEPARATOR) rescue f }
|
69
|
-
end
|
70
|
-
|
71
|
-
def convert_escaped_newlines
|
72
|
-
lambda { |f| f.gsub(/\\r/, "\r").gsub(/\\n/, "\n") rescue f }
|
57
|
+
conn.get "select", params: csv_params
|
73
58
|
end
|
74
59
|
|
75
60
|
end
|
data/lib/ddr/index/field.rb
CHANGED
@@ -16,17 +16,7 @@ module Ddr::Index
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def label
|
19
|
-
I18n.t "
|
20
|
-
end
|
21
|
-
|
22
|
-
def heading
|
23
|
-
I18n.t "#{i18n_base}.heading", default: base
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def i18n_base
|
29
|
-
"ddr.index.fields.#{base}"
|
19
|
+
I18n.t "ddr.index.fields.#{base}", default: base.titleize
|
30
20
|
end
|
31
21
|
|
32
22
|
end
|
data/lib/ddr/index/fields.rb
CHANGED
@@ -1,169 +1,86 @@
|
|
1
1
|
module Ddr::Index
|
2
2
|
module Fields
|
3
|
-
|
3
|
+
|
4
|
+
def self.get(name)
|
5
|
+
const_get(name.to_s.upcase, false)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.techmd
|
9
|
+
constants(false)
|
10
|
+
.select { |c| c =~ /\ATECHMD_/ }
|
11
|
+
.map { |c| const_get(c) }
|
12
|
+
end
|
4
13
|
|
5
14
|
ID = UniqueKeyField.instance
|
15
|
+
PID = UniqueKeyField.instance
|
6
16
|
|
7
17
|
ACCESS_ROLE = Field.new :access_role, :stored_sortable
|
8
18
|
ACTIVE_FEDORA_MODEL = Field.new :active_fedora_model, :stored_sortable
|
9
19
|
ADMIN_SET = Field.new :admin_set, :stored_sortable
|
10
20
|
ADMIN_SET_FACET = Field.new :admin_set_facet, :facetable
|
11
|
-
ADMIN_SET_TITLE = Field.new :admin_set_title, :stored_sortable
|
12
|
-
AFFILIATION = Field.new :affiliation, :stored_searchable
|
13
|
-
AFFILIATION_FACET = Field.new :affiliation_facet, :facetable
|
14
|
-
ALEPH_ID = Field.new :aleph_id, :stored_sortable
|
15
|
-
ALL_TEXT = Field.new :all_text, solr_name: "all_text_timv"
|
16
|
-
ARRANGER_FACET = Field.new :arranger_facet, :facetable
|
17
|
-
ASPACE_ID = Field.new :aspace_id, :stored_sortable
|
18
|
-
ATTACHED_FILES_HAVING_CONTENT =
|
19
|
-
Field.new :attached_files_having_content, :symbol
|
20
|
-
BIBLICAL_BOOK_FACET = Field.new :biblical_book_facet, :facetable
|
21
21
|
BOX_NUMBER_FACET = Field.new :box_number_facet, :facetable
|
22
|
-
CATEGORY_FACET = Field.new :category_facet, :facetable
|
23
|
-
CHAPTER_AND_VERSE_FACET = Field.new :chapter_and_verse_facet, :facetable
|
24
22
|
COLLECTION_FACET = Field.new :collection_facet, :facetable
|
25
|
-
COLLECTION_TITLE = Field.new :collection_title, :stored_sortable
|
26
23
|
COLLECTION_URI = Field.new :collection_uri, :symbol
|
27
|
-
|
28
|
-
COMPOSER_FACET = Field.new :composer_facet, :facetable
|
29
|
-
CONTENT_CONTROL_GROUP = Field.new :content_control_group, :searchable, type: :string
|
30
|
-
CONTENT_CREATE_DATE = Field.new :content_create_date, :stored_sortable, type: :date
|
31
|
-
CONTENT_SIZE = Field.new :content_size, solr_name: "content_size_lsi"
|
24
|
+
CONTENT_SIZE = Field.new :content_size, :stored_sortable, type: :integer
|
32
25
|
CONTENT_SIZE_HUMAN = Field.new :content_size_human, :symbol
|
33
|
-
CONTRIBUTOR_FACET = Field.new :contributor_facet, :facetable
|
34
26
|
CREATOR_FACET = Field.new :creator_facet, :facetable
|
35
27
|
DATE_FACET = Field.new :date_facet, :facetable
|
36
28
|
DATE_SORT = Field.new :date_sort, :sortable
|
37
|
-
DC_IS_PART_OF = Field.new :isPartOf, :symbol
|
38
29
|
DEPOSITOR = Field.new :depositor, :stored_sortable
|
39
30
|
DISPLAY_FORMAT = Field.new :display_format, :stored_sortable
|
40
31
|
DOI = Field.new :doi, :symbol
|
41
32
|
EAD_ID = Field.new :ead_id, :stored_sortable
|
42
|
-
|
43
|
-
EXTRACTED_TEXT = Field.new :extracted_text, solr_name: "extracted_text_tsm"
|
44
|
-
FOLDER_FACET = Field.new :folder_facet, :facetable
|
45
|
-
FORMAT_FACET = Field.new :format_facet, :facetable
|
46
|
-
GENRE_FACET = Field.new :genre_facet, :facetable
|
33
|
+
EXTRACTED_TEXT = Field.new :extracted_text, :searchable, type: :text
|
47
34
|
HAS_MODEL = Field.new :has_model, :symbol
|
48
35
|
IDENTIFIER_ALL = Field.new :identifier_all, :symbol
|
49
|
-
ILLUSTRATED_FACET = Field.new :illustrated_facet, :facetable
|
50
|
-
ILLUSTRATOR_FACET = Field.new :illustrator_facet, :facetable
|
51
|
-
INGESTED_BY = Field.new :ingested_by, :stored_sortable
|
52
|
-
INGESTION_DATE = Field.new :ingestion_date, :stored_sortable, type: :date
|
53
|
-
INSTRUMENTATION_FACET = Field.new :instrumentation_facet, :facetable
|
54
|
-
INTERNAL_URI = Field.new :internal_uri, :stored_sortable
|
55
|
-
INTERVIEWER_NAME_FACET = Field.new :interviewer_name_facet, :facetable
|
56
36
|
IS_ATTACHED_TO = Field.new :is_attached_to, :symbol
|
57
37
|
IS_EXTERNAL_TARGET_FOR = Field.new :is_external_target_for, :symbol
|
58
|
-
|
59
|
-
IS_GOVERNED_BY = Field.new :is_governed_by, :symbol
|
60
|
-
IS_LOCKED = Field.new :is_locked, :stored_sortable
|
38
|
+
IS_GOVERNED_BY = Field.new :is_governed_by, solr_name: "isGovernedBy_ssim"
|
61
39
|
IS_MEMBER_OF = Field.new :is_member_of, :symbol
|
62
40
|
IS_MEMBER_OF_COLLECTION = Field.new :is_member_of_collection, :symbol
|
63
41
|
IS_PART_OF = Field.new :is_part_of, :symbol
|
64
|
-
LANGUAGE_FACET = Field.new :language_facet, :facetable
|
65
|
-
LANGUAGE_NAME = Field.new :language_name, :stored_searchable
|
66
42
|
LAST_FIXITY_CHECK_ON = Field.new :last_fixity_check_on, :stored_sortable, type: :date
|
67
43
|
LAST_FIXITY_CHECK_OUTCOME = Field.new :last_fixity_check_outcome, :symbol
|
68
44
|
LAST_VIRUS_CHECK_ON = Field.new :last_virus_check_on, :stored_sortable, type: :date
|
69
45
|
LAST_VIRUS_CHECK_OUTCOME = Field.new :last_virus_check_outcome, :symbol
|
70
46
|
LICENSE = Field.new :license, :stored_sortable
|
71
|
-
LITHOGRAPHER_FACET = Field.new :lithographer_facet, :facetable
|
72
47
|
LOCAL_ID = Field.new :local_id, :stored_sortable
|
73
|
-
LYRICIST_FACET = Field.new :lyricist_facet, :facetable
|
74
48
|
MEDIA_SUB_TYPE = Field.new :content_media_sub_type, :facetable
|
75
49
|
MEDIA_MAJOR_TYPE = Field.new :content_media_major_type, :facetable
|
76
50
|
MEDIA_TYPE = Field.new :content_media_type, :symbol
|
77
|
-
MEDIUM_FACET = Field.new :medium_facet, :facetable
|
78
51
|
MULTIRES_IMAGE_FILE_PATH = Field.new :multires_image_file_path, :stored_sortable
|
79
|
-
NESTED_PATH = Field.new :nested_path, :stored_sortable
|
80
|
-
NESTED_PATH_TEXT = Field.new :nested_path_text, :searchable
|
81
52
|
OBJECT_PROFILE = Field.new :object_profile, :displayable
|
82
53
|
OBJECT_STATE = Field.new :object_state, :stored_sortable
|
83
54
|
OBJECT_CREATE_DATE = Field.new :system_create, :stored_sortable, type: :date
|
84
55
|
OBJECT_MODIFIED_DATE = Field.new :system_modified, :stored_sortable, type: :date
|
85
|
-
ORIGINAL_FILENAME = Field.new :original_filename, solr_name: "admin_metadata__original_filename_ssi"
|
86
|
-
PERFORMER_FACET = Field.new :performer_facet, :facetable
|
87
56
|
PERMANENT_ID = Field.new :permanent_id, :stored_sortable, type: :string
|
88
57
|
PERMANENT_URL = Field.new :permanent_url, :stored_sortable, type: :string
|
89
|
-
PLACEMENT_COMPANY_FACET = Field.new :placement_company_facet, :facetable
|
90
58
|
POLICY_ROLE = Field.new :policy_role, :symbol
|
91
|
-
PRODUCER_FACET = Field.new :producer_facet, :facetable
|
92
|
-
PRODUCT_FACET = Field.new :product_facet, :facetable
|
93
|
-
PUBLICATION_FACET = Field.new :publication_facet, :facetable
|
94
59
|
PUBLISHER_FACET = Field.new :publisher_facet, :facetable
|
95
60
|
RESEARCH_HELP_CONTACT = Field.new :research_help_contact, :stored_sortable
|
96
61
|
RESOURCE_ROLE = Field.new :resource_role, :symbol
|
97
|
-
RIGHTS_NOTE = Field.new :rights_note, :stored_searchable
|
98
|
-
ROLL_NUMBER_FACET = Field.new :roll_number_facet, :facetable
|
99
62
|
SERIES_FACET = Field.new :series_facet, :facetable
|
100
|
-
SETTING_FACET = Field.new :setting_facet, :facetable
|
101
63
|
SPATIAL_FACET = Field.new :spatial_facet, :facetable
|
102
|
-
|
103
|
-
STRUCTURE = Field.new :structure, solr_name: "structure_ss"
|
104
|
-
STRUCTURE_SOURCE = Field.new :structure_source, :stored_sortable
|
105
|
-
SUBJECT_FACET = Field.new :subject_facet, :facetable
|
106
|
-
SUBSERIES_FACET = Field.new :subseries_facet, :facetable
|
64
|
+
STRUCT_MAPS = Field.new :struct_maps, :stored_sortable
|
107
65
|
TECHMD_COLOR_SPACE = Field.new :techmd_color_space, :symbol
|
108
66
|
TECHMD_CREATING_APPLICATION = Field.new :techmd_creating_application, :symbol
|
109
67
|
TECHMD_CREATION_TIME = Field.new :techmd_creation_time, :stored_searchable, type: :date
|
110
|
-
TECHMD_FILE_SIZE = Field.new :techmd_file_size,
|
68
|
+
TECHMD_FILE_SIZE = Field.new :techmd_file_size, :stored_searchable, type: :integer
|
111
69
|
TECHMD_FITS_VERSION = Field.new :techmd_fits_version, :stored_sortable
|
112
70
|
TECHMD_FITS_DATETIME = Field.new :techmd_fits_datetime, :stored_sortable, type: :date
|
113
71
|
TECHMD_FORMAT_LABEL = Field.new :techmd_format_label, :symbol
|
114
72
|
TECHMD_FORMAT_VERSION = Field.new :techmd_format_version, :symbol
|
115
|
-
TECHMD_ICC_PROFILE_NAME = Field.new :techmd_icc_profile_name, :symbol
|
116
|
-
TECHMD_ICC_PROFILE_VERSION = Field.new :techmd_icc_profile_version, :symbol
|
117
73
|
TECHMD_IMAGE_HEIGHT = Field.new :techmd_image_height, :stored_searchable, type: :integer
|
118
74
|
TECHMD_IMAGE_WIDTH = Field.new :techmd_image_width, :stored_searchable, type: :integer
|
119
|
-
TECHMD_MD5 = Field.new :techmd_md5, :stored_sortable
|
120
75
|
TECHMD_MEDIA_TYPE = Field.new :techmd_media_type, :symbol
|
121
76
|
TECHMD_MODIFICATION_TIME = Field.new :techmd_modification_time, :stored_searchable, type: :date
|
122
77
|
TECHMD_PRONOM_IDENTIFIER = Field.new :techmd_pronom_identifier, :symbol
|
123
78
|
TECHMD_VALID = Field.new :techmd_valid, :symbol
|
124
79
|
TECHMD_WELL_FORMED = Field.new :techmd_well_formed, :symbol
|
125
|
-
TEMPORAL_FACET = Field.new :temporal_facet, :facetable
|
126
80
|
TITLE = Field.new :title, :stored_sortable
|
127
|
-
TONE_FACET = Field.new :tone_facet, :facetable
|
128
81
|
TYPE_FACET = Field.new :type_facet, :facetable
|
129
|
-
VOLUME_FACET = Field.new :volume_facet, :facetable
|
130
82
|
WORKFLOW_STATE = Field.new :workflow_state, :stored_sortable
|
131
83
|
YEAR_FACET = Field.new :year_facet, solr_name: "year_facet_iim"
|
132
84
|
|
133
|
-
def self.get(name)
|
134
|
-
const_get(name.to_s.upcase, false)
|
135
|
-
end
|
136
|
-
|
137
|
-
def self.techmd
|
138
|
-
@techmd ||= constants(false).select { |c| c =~ /\ATECHMD_/ }.map { |c| const_get(c) }.freeze
|
139
|
-
end
|
140
|
-
|
141
|
-
def self.descmd
|
142
|
-
@descmd ||= Ddr::Datastreams::DescriptiveMetadataDatastream.properties.map do |base, config|
|
143
|
-
Field.new base, *(config.behaviors)
|
144
|
-
end.freeze
|
145
|
-
end
|
146
|
-
|
147
|
-
def self.adminmd
|
148
|
-
@adminmd ||= Ddr::Datastreams::AdministrativeMetadataDatastream.properties.map do |base, config|
|
149
|
-
begin
|
150
|
-
get(base)
|
151
|
-
rescue NameError
|
152
|
-
Field.new base, *(config.behaviors)
|
153
|
-
end
|
154
|
-
end.freeze
|
155
|
-
end
|
156
|
-
|
157
|
-
def self.const_missing(name)
|
158
|
-
if name == :PID
|
159
|
-
Deprecation.warn(Ddr::Index::Fields,
|
160
|
-
"`Ddr::Index::Fields::#{name}` is deprecated." \
|
161
|
-
" Use `Ddr::Index::Fields::ID` instead.")
|
162
|
-
ID
|
163
|
-
else
|
164
|
-
super
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
85
|
end
|
169
86
|
end
|