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
@@ -0,0 +1,91 @@
|
|
1
|
+
require "ezid-client"
|
2
|
+
require "resque"
|
3
|
+
|
4
|
+
module Ddr
|
5
|
+
module Managers
|
6
|
+
#
|
7
|
+
# PermanentIdManager is responsible for managing the permanent id for an object.
|
8
|
+
#
|
9
|
+
# @api private
|
10
|
+
#
|
11
|
+
class PermanentIdManager
|
12
|
+
|
13
|
+
PERMANENT_URL_BASE = "http://id.library.duke.edu/"
|
14
|
+
ASSIGN_EVENT_SUMMARY = "Permanent ID assignment"
|
15
|
+
SOFTWARE = Ezid::Client.version
|
16
|
+
|
17
|
+
attr_reader :object
|
18
|
+
|
19
|
+
def initialize(object)
|
20
|
+
@object = object
|
21
|
+
end
|
22
|
+
|
23
|
+
def assign_later
|
24
|
+
Resque.enqueue(AssignmentJob, object.pid)
|
25
|
+
end
|
26
|
+
|
27
|
+
def assign
|
28
|
+
raise Ddr::Models::Error, "Permanent ID already assigned." if object.permanent_id
|
29
|
+
ActiveSupport::Notifications.instrument(Ddr::Notifications::UPDATE,
|
30
|
+
pid: object.pid,
|
31
|
+
software: SOFTWARE,
|
32
|
+
summary: ASSIGN_EVENT_SUMMARY
|
33
|
+
) do |payload|
|
34
|
+
|
35
|
+
assign!
|
36
|
+
payload[:detail] = <<-EOS
|
37
|
+
Permanent ID: #{object.permanent_id}
|
38
|
+
Permanent URL: #{object.permanent_url}
|
39
|
+
EZID Metadata:
|
40
|
+
#{record.metadata}
|
41
|
+
EOS
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# A job class for background execution
|
46
|
+
class AssignmentJob
|
47
|
+
@queue = :permanent_id
|
48
|
+
|
49
|
+
def self.perform(pid)
|
50
|
+
object = ActiveFedora::Base.find(pid)
|
51
|
+
object.permanent_id_manager.assign
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def default_metadata
|
56
|
+
{ profile: "dc",
|
57
|
+
export: "no"
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def record
|
62
|
+
return @record if @record
|
63
|
+
if object.permanent_id
|
64
|
+
@record = Ezid::Identifier.find(object.permanent_id.to_s)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def assign!
|
71
|
+
@record = mint
|
72
|
+
object.permanent_id = record.id
|
73
|
+
object.permanent_url = (PERMANENT_URL_BASE + object.permanent_id)
|
74
|
+
object.save!
|
75
|
+
end
|
76
|
+
|
77
|
+
# @return [Ezid::Identifier]
|
78
|
+
def mint
|
79
|
+
ezid = Ezid::Identifier.create(default_metadata)
|
80
|
+
ezid.target = default_target_url(ezid.id)
|
81
|
+
ezid.save
|
82
|
+
ezid
|
83
|
+
end
|
84
|
+
|
85
|
+
def default_target_url(id)
|
86
|
+
Ddr::Models.permanent_id_target_url_base + id
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -5,21 +5,10 @@ module Ddr::Managers
|
|
5
5
|
|
6
6
|
delegate :content, :fits, to: :object
|
7
7
|
|
8
|
-
delegate :
|
9
|
-
:
|
10
|
-
:creating_application,
|
11
|
-
:
|
12
|
-
:format_label,
|
13
|
-
:format_version,
|
14
|
-
:icc_profile_name,
|
15
|
-
:icc_profile_version,
|
16
|
-
:image_height,
|
17
|
-
:image_width,
|
18
|
-
:media_type,
|
19
|
-
:modified,
|
20
|
-
:pronom_identifier,
|
21
|
-
:valid,
|
22
|
-
:well_formed,
|
8
|
+
delegate :valid, :well_formed,
|
9
|
+
:media_type, :format_label, :format_version, :pronom_identifier,
|
10
|
+
:created, :modified, :creating_application, :extent,
|
11
|
+
:image_width, :image_height, :color_space,
|
23
12
|
to: :fits
|
24
13
|
|
25
14
|
alias_method :last_modified, :modified
|
@@ -50,16 +39,12 @@ module Ddr::Managers
|
|
50
39
|
end
|
51
40
|
end
|
52
41
|
|
53
|
-
def md5
|
54
|
-
fits.md5.first
|
55
|
-
end
|
56
|
-
|
57
42
|
def checksum_digest
|
58
|
-
|
43
|
+
checksum_uri.split(":")[1].upcase rescue nil
|
59
44
|
end
|
60
45
|
|
61
46
|
def checksum_value
|
62
|
-
|
47
|
+
checksum_uri.split(":").last rescue nil
|
63
48
|
end
|
64
49
|
|
65
50
|
def invalid?
|
@@ -96,11 +81,8 @@ module Ddr::Managers
|
|
96
81
|
Ddr::Index::Fields::TECHMD_FILE_SIZE => file_size,
|
97
82
|
Ddr::Index::Fields::TECHMD_FORMAT_LABEL => format_label,
|
98
83
|
Ddr::Index::Fields::TECHMD_FORMAT_VERSION => format_version,
|
99
|
-
Ddr::Index::Fields::TECHMD_ICC_PROFILE_NAME => icc_profile_name,
|
100
|
-
Ddr::Index::Fields::TECHMD_ICC_PROFILE_VERSION => icc_profile_version,
|
101
84
|
Ddr::Index::Fields::TECHMD_IMAGE_HEIGHT => image_height,
|
102
85
|
Ddr::Index::Fields::TECHMD_IMAGE_WIDTH => image_width,
|
103
|
-
Ddr::Index::Fields::TECHMD_MD5 => md5,
|
104
86
|
Ddr::Index::Fields::TECHMD_MEDIA_TYPE => media_type,
|
105
87
|
Ddr::Index::Fields::TECHMD_PRONOM_IDENTIFIER => pronom_identifier,
|
106
88
|
Ddr::Index::Fields::TECHMD_VALID => valid,
|
@@ -117,5 +99,9 @@ module Ddr::Managers
|
|
117
99
|
nil
|
118
100
|
end
|
119
101
|
|
102
|
+
def checksum_uri
|
103
|
+
content.digest.first.to_s
|
104
|
+
end
|
105
|
+
|
120
106
|
end
|
121
107
|
end
|
@@ -9,43 +9,24 @@ module Ddr
|
|
9
9
|
object.workflow_state == PUBLISHED
|
10
10
|
end
|
11
11
|
|
12
|
-
def unpublished?
|
13
|
-
object.workflow_state == UNPUBLISHED
|
14
|
-
end
|
15
|
-
|
16
|
-
def publish!(include_descendants: true)
|
17
|
-
unless published?
|
18
|
-
publish
|
19
|
-
object.save!
|
20
|
-
end
|
21
|
-
if include_descendants && object.respond_to?(:children)
|
22
|
-
solr_results = object.children(response_format: :solr)
|
23
|
-
ActiveFedora::SolrService.lazy_reify_solr_results(solr_results).each do |child|
|
24
|
-
child.publish!(include_descendants: include_descendants)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def unpublish!
|
30
|
-
if published?
|
31
|
-
unpublish
|
32
|
-
object.save!
|
33
|
-
end
|
34
|
-
if object.respond_to?(:children)
|
35
|
-
object.children.each { |child| child.unpublish! }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
12
|
def publish
|
42
13
|
object.workflow_state = PUBLISHED
|
43
14
|
end
|
44
15
|
|
16
|
+
def publish!
|
17
|
+
publish
|
18
|
+
object.save
|
19
|
+
end
|
20
|
+
|
45
21
|
def unpublish
|
46
22
|
object.workflow_state = UNPUBLISHED
|
47
23
|
end
|
48
24
|
|
25
|
+
def unpublish!
|
26
|
+
unpublish
|
27
|
+
object.save
|
28
|
+
end
|
29
|
+
|
49
30
|
end
|
50
31
|
end
|
51
32
|
end
|
data/lib/ddr/models.rb
CHANGED
@@ -1,51 +1,44 @@
|
|
1
1
|
require 'ddr/models/engine'
|
2
2
|
require 'ddr/models/version'
|
3
|
-
|
3
|
+
|
4
|
+
# Awful hack to make Hydra::AccessControls::Permissions accessible
|
5
|
+
# $: << Gem.loaded_specs['hydra-access-controls'].full_gem_path + "/app/models/concerns"
|
6
|
+
|
4
7
|
require 'active_record'
|
8
|
+
|
5
9
|
require 'hydra-core'
|
6
10
|
require 'hydra/validations'
|
7
11
|
|
8
12
|
module Ddr
|
9
13
|
extend ActiveSupport::Autoload
|
10
|
-
extend Deprecation
|
11
14
|
|
12
15
|
autoload :Actions
|
13
16
|
autoload :Auth
|
17
|
+
autoload :Contacts
|
14
18
|
autoload :Datastreams
|
15
19
|
autoload :Derivatives
|
16
20
|
autoload :Events
|
17
21
|
autoload :Index
|
22
|
+
autoload :IndexFields
|
23
|
+
autoload :Jobs
|
18
24
|
autoload :Managers
|
19
25
|
autoload :Metadata
|
20
26
|
autoload :Notifications
|
21
27
|
autoload :Utils
|
22
28
|
autoload :Vocab
|
23
29
|
|
24
|
-
def self.const_missing(name)
|
25
|
-
if name == :IndexFields
|
26
|
-
Deprecation.warn(Ddr::Models, "`Ddr::IndexFields` is deprecated and will be removed in ddr-models 3.0." \
|
27
|
-
" Use `Ddr::Index::Fields` instead.")
|
28
|
-
Index::Fields
|
29
|
-
else
|
30
|
-
super
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
30
|
module Models
|
35
31
|
extend ActiveSupport::Autoload
|
36
32
|
|
33
|
+
autoload :AccessControllable
|
37
34
|
autoload :AdminSet
|
38
35
|
autoload :Base
|
39
|
-
autoload :Cache
|
40
|
-
autoload :Captionable
|
41
36
|
autoload :ChecksumInvalid, 'ddr/models/error'
|
42
|
-
autoload :Contact
|
43
37
|
autoload :ContentModelError, 'ddr/models/error'
|
44
38
|
autoload :DerivativeGenerationFailure, 'ddr/models/error'
|
45
39
|
autoload :Describable
|
46
40
|
autoload :Error
|
47
41
|
autoload :EventLoggable
|
48
|
-
autoload :FileCharacterization
|
49
42
|
autoload :FileManagement
|
50
43
|
autoload :FindingAid
|
51
44
|
autoload :FixityCheckable
|
@@ -54,42 +47,50 @@ module Ddr
|
|
54
47
|
autoload :HasAttachments
|
55
48
|
autoload :HasChildren
|
56
49
|
autoload :HasContent
|
57
|
-
autoload :HasIntermediateFile
|
58
50
|
autoload :HasMultiresImage
|
59
51
|
autoload :HasStructMetadata
|
60
52
|
autoload :HasThumbnail
|
61
53
|
autoload :Indexing
|
62
|
-
autoload :Language
|
63
|
-
autoload :MediaType
|
64
|
-
autoload :NotFoundError, 'ddr/models/error'
|
65
|
-
autoload :PermanentId
|
66
|
-
autoload :RightsStatement
|
67
54
|
autoload :SolrDocument
|
68
|
-
autoload :
|
55
|
+
autoload :StructDiv
|
69
56
|
autoload :Structure
|
70
|
-
autoload :WithContentFile
|
71
57
|
autoload :YearFacet
|
72
58
|
|
73
|
-
|
74
|
-
|
75
|
-
autoload :
|
76
|
-
autoload :
|
77
|
-
autoload :
|
78
|
-
autoload :
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
autoload :
|
83
|
-
autoload :
|
84
|
-
autoload :
|
85
|
-
autoload :
|
59
|
+
autoload_under "licenses" do
|
60
|
+
autoload :AdminPolicyLicense
|
61
|
+
autoload :EffectiveLicense
|
62
|
+
autoload :License
|
63
|
+
autoload :InheritedLicense
|
64
|
+
autoload :ParentLicense
|
65
|
+
end
|
66
|
+
|
67
|
+
autoload_under "metadata" do
|
68
|
+
autoload :DescriptiveMetadata
|
69
|
+
autoload :Metadata
|
70
|
+
autoload :MetadataMapper
|
71
|
+
autoload :MetadataMappers
|
72
|
+
autoload :MetadataTerm
|
73
|
+
autoload :MetadataVocabulary
|
74
|
+
autoload :MetadataVocabularies
|
86
75
|
end
|
87
76
|
|
77
|
+
# Base directory of default external file store
|
78
|
+
mattr_accessor :external_file_store
|
79
|
+
|
80
|
+
# Base directory of external file store for multires image derivatives
|
81
|
+
mattr_accessor :multires_image_external_file_store
|
82
|
+
|
83
|
+
# Regexp for building external file subpath from hex digest
|
84
|
+
mattr_accessor :external_file_subpath_regexp
|
85
|
+
|
88
86
|
# Image server URL
|
89
87
|
mattr_accessor :image_server_url
|
90
88
|
|
89
|
+
# Whether permanent IDs should be automatically assigned on create
|
90
|
+
mattr_accessor :auto_assign_permanent_ids
|
91
|
+
|
91
92
|
mattr_accessor :permanent_id_target_url_base do
|
92
|
-
"https://repository.duke.edu/id/"
|
93
|
+
"https://repository.lib.duke.edu/id/"
|
93
94
|
end
|
94
95
|
|
95
96
|
# Home directory for FITS
|
@@ -104,69 +105,7 @@ module Ddr
|
|
104
105
|
end
|
105
106
|
|
106
107
|
mattr_accessor :ead_xml_base_url do
|
107
|
-
"
|
108
|
-
end
|
109
|
-
|
110
|
-
# Application temp dir - defaults to system temp dir
|
111
|
-
mattr_accessor :tempdir do
|
112
|
-
Dir.tmpdir
|
113
|
-
end
|
114
|
-
|
115
|
-
# Is repository locked? Default is false.
|
116
|
-
# A locked repository behaves as though each object in the repository is locked.
|
117
|
-
mattr_accessor :repository_locked do
|
118
|
-
false
|
119
|
-
end
|
120
|
-
|
121
|
-
mattr_accessor :auto_assign_permanent_id do
|
122
|
-
false
|
123
|
-
end
|
124
|
-
|
125
|
-
mattr_accessor :auto_update_permanent_id do
|
126
|
-
false
|
127
|
-
end
|
128
|
-
|
129
|
-
# File path to vips
|
130
|
-
mattr_accessor :vips_path
|
131
|
-
|
132
|
-
mattr_accessor :default_mime_type do
|
133
|
-
"application/octet-stream"
|
134
|
-
end
|
135
|
-
|
136
|
-
# Maps file extensions to preferred media types
|
137
|
-
mattr_accessor :preferred_media_types do
|
138
|
-
{
|
139
|
-
'.aac' => 'audio/mp4',
|
140
|
-
'.f4a' => 'audio/mp4',
|
141
|
-
'.flv' => 'video/flv',
|
142
|
-
'.m4a' => 'audio/mp4',
|
143
|
-
'.mov' => 'video/quicktime',
|
144
|
-
'.mp3' => 'audio/mpeg',
|
145
|
-
'.mp4' => 'video/mp4',
|
146
|
-
'.oga' => 'audio/ogg',
|
147
|
-
'.ogg' => 'audio/ogg',
|
148
|
-
'.srt' => 'text/plain',
|
149
|
-
'.vtt' => 'text/vtt',
|
150
|
-
'.wav' => 'audio/wav',
|
151
|
-
'.webm' => 'video/webm',
|
152
|
-
'.zip' => 'application/zip'
|
153
|
-
}
|
154
|
-
end
|
155
|
-
|
156
|
-
# Maps media types to preferred file extensions
|
157
|
-
mattr_accessor :preferred_file_extensions do
|
158
|
-
{
|
159
|
-
'application/zip' => 'zip',
|
160
|
-
'audio/mp4' => 'm4a',
|
161
|
-
'audio/mpeg' => 'mp3',
|
162
|
-
'audio/ogg' => 'ogg',
|
163
|
-
'audio/wav' => 'wav',
|
164
|
-
'text/vtt' => 'vtt',
|
165
|
-
'video/flv' => 'flv',
|
166
|
-
'video/mp4' => 'mp4',
|
167
|
-
'video/quicktime' => 'mov',
|
168
|
-
'video/webm' => 'webm'
|
169
|
-
}
|
108
|
+
"http://library.duke.edu/rubenstein/findingaids/"
|
170
109
|
end
|
171
110
|
|
172
111
|
# Yields an object with module configuration accessors
|
@@ -174,7 +113,17 @@ module Ddr
|
|
174
113
|
yield self
|
175
114
|
end
|
176
115
|
|
116
|
+
def self.external_file_subpath_pattern= (pattern)
|
117
|
+
unless /^-{1,2}(\/-{1,2}){0,3}$/ =~ pattern
|
118
|
+
raise "Invalid external file subpath pattern: #{pattern}"
|
119
|
+
end
|
120
|
+
re = pattern.split("/").map { |x| "(\\h{#{x.length}})" }.join("")
|
121
|
+
self.external_file_subpath_regexp = Regexp.new("^#{re}")
|
122
|
+
end
|
123
|
+
|
177
124
|
end
|
178
125
|
end
|
179
126
|
|
127
|
+
ActiveFedora::Predicates.set_predicates(Ddr::Metadata::PREDICATES)
|
128
|
+
|
180
129
|
Dir[Ddr::Models::Engine.root.to_s + "/app/models/*.rb"].each { |m| require m }
|
data/lib/ddr/models/admin_set.rb
CHANGED
@@ -1,23 +1,12 @@
|
|
1
|
-
require "
|
1
|
+
require "ddr_aux/client"
|
2
2
|
|
3
3
|
module Ddr::Models
|
4
|
-
class AdminSet <
|
5
|
-
|
6
|
-
self.site = ENV["DDR_AUX_API_URL"]
|
4
|
+
class AdminSet < DdrAux::Client::AdminSet
|
7
5
|
|
8
6
|
def self.call(obj)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.find_by_code(code)
|
15
|
-
return unless code
|
16
|
-
new get(:find, code: code)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.keys
|
20
|
-
all.map(&:code)
|
7
|
+
if obj.admin_set
|
8
|
+
find(code: obj.admin_set)
|
9
|
+
end
|
21
10
|
end
|
22
11
|
|
23
12
|
def to_s
|