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
@@ -1,55 +1,22 @@
|
|
1
|
-
require "nokogiri"
|
2
|
-
|
3
1
|
module Ddr::Models
|
4
2
|
class FindingAid
|
5
3
|
|
6
4
|
attr_reader :ead_id
|
7
5
|
|
8
|
-
EAD_XMLNS = "urn:isbn:1-931666-22-9"
|
9
|
-
|
10
6
|
def initialize(ead_id)
|
11
7
|
@ead_id = ead_id
|
12
8
|
end
|
13
9
|
|
14
10
|
def url
|
15
|
-
doc.css("eadid").attr("url").text
|
11
|
+
@url ||= doc.css("eadid").attr("url").text
|
16
12
|
end
|
17
13
|
|
18
|
-
# The finding aid title
|
19
14
|
def title
|
20
|
-
doc.css("titleproper").children.first.text.strip
|
21
|
-
end
|
22
|
-
|
23
|
-
def repository
|
24
|
-
collection.xpath('ead:did/ead:repository/ead:corpname', ead: EAD_XMLNS).text
|
25
|
-
end
|
26
|
-
|
27
|
-
def collection_date_span
|
28
|
-
collection.xpath('ead:did/ead:unitdate[@type="inclusive"]', ead: EAD_XMLNS).text
|
29
|
-
end
|
30
|
-
|
31
|
-
def collection_number
|
32
|
-
collection.xpath('ead:did/ead:unitid', ead: EAD_XMLNS).text
|
33
|
-
end
|
34
|
-
|
35
|
-
def collection_title
|
36
|
-
collection.xpath('ead:did/ead:unittitle', ead: EAD_XMLNS).text
|
37
|
-
end
|
38
|
-
|
39
|
-
def extent
|
40
|
-
collection.xpath('ead:did/ead:physdesc/ead:extent', ead: EAD_XMLNS).map(&:text).join("; ")
|
41
|
-
end
|
42
|
-
|
43
|
-
def abstract
|
44
|
-
collection.xpath('ead:did/ead:abstract', ead: EAD_XMLNS).text
|
15
|
+
@title ||= doc.css("titleproper").children.first.text.strip
|
45
16
|
end
|
46
17
|
|
47
18
|
private
|
48
19
|
|
49
|
-
def collection
|
50
|
-
doc.xpath('//ead:archdesc[@level="collection"]', ead: EAD_XMLNS)
|
51
|
-
end
|
52
|
-
|
53
20
|
# @raise [OpenURI::HTTPError] if 404, etc.
|
54
21
|
def doc
|
55
22
|
@doc ||= Nokogiri::XML(open(ead_xml_url))
|
@@ -4,7 +4,9 @@ module Ddr
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
belongs_to :admin_policy,
|
7
|
+
belongs_to :admin_policy,
|
8
|
+
predicate: ActiveFedora::RDF::ProjectHydra.isGovernedBy,
|
9
|
+
class_name: "Collection"
|
8
10
|
end
|
9
11
|
|
10
12
|
def inherited_permissions
|
@@ -1,47 +1,75 @@
|
|
1
|
+
require "resque"
|
2
|
+
require "rdf/vocab"
|
3
|
+
|
1
4
|
module Ddr::Models
|
2
5
|
module HasAdminMetadata
|
3
6
|
extend ActiveSupport::Concern
|
4
|
-
extend Deprecation
|
5
|
-
|
6
|
-
self.deprecation_horizon = 'ddr-models v3.0'
|
7
7
|
|
8
8
|
included do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
9
|
+
contains "accessRoles", class_name: "Ddr::Auth::Roles::RolesDatastream"
|
10
|
+
|
11
|
+
property :admin_set,
|
12
|
+
predicate: Ddr::Vocab::Asset.adminSet,
|
13
|
+
multiple: false
|
14
|
+
|
15
|
+
property :depositor,
|
16
|
+
predicate: RDF::Vocab::MARCRelators.dpt,
|
17
|
+
multiple: false
|
18
|
+
|
19
|
+
property :display_format,
|
20
|
+
predicate: Ddr::Vocab::Display.format,
|
21
|
+
multiple: false
|
22
|
+
|
23
|
+
property :doi,
|
24
|
+
predicate: RDF::Vocab::Identifiers.doi
|
25
|
+
|
26
|
+
property :ead_id,
|
27
|
+
predicate: Ddr::Vocab::Asset.eadId,
|
28
|
+
multiple: false
|
29
|
+
|
30
|
+
property :license,
|
31
|
+
predicate: RDF::DC.license,
|
32
|
+
multiple: false
|
33
|
+
|
34
|
+
property :local_id,
|
35
|
+
predicate: RDF::Vocab::Identifiers.local,
|
36
|
+
multiple: false
|
37
|
+
|
38
|
+
# XXX Is this admin metadata?
|
39
|
+
property :original_filename,
|
40
|
+
predicate: Ddr::Vocab::PREMIS.hasOriginalName,
|
41
|
+
multiple: false do |index|
|
42
|
+
index.as :stored_sortable
|
43
|
+
end
|
44
|
+
|
45
|
+
property :permanent_id,
|
46
|
+
predicate: Ddr::Vocab::Asset.permanentId,
|
47
|
+
multiple: false
|
48
|
+
|
49
|
+
property :permanent_url,
|
50
|
+
predicate: Ddr::Vocab::Asset.permanentUrl,
|
51
|
+
multiple: false
|
52
|
+
|
53
|
+
property :research_help_contact,
|
54
|
+
predicate: Ddr::Vocab::Contact.assistance,
|
55
|
+
multiple: false
|
56
|
+
|
57
|
+
property :workflow_state,
|
58
|
+
predicate: Ddr::Vocab::Asset.workflowState,
|
59
|
+
multiple: false
|
60
|
+
|
61
|
+
delegate :publish, :publish!, :unpublish, :unpublish!, :published?, to: :workflow
|
62
|
+
|
63
|
+
after_create :assign_permanent_id!, if: "Ddr::Models.auto_assign_permanent_ids"
|
64
|
+
around_destroy :update_permanent_id_on_destroy, if: "permanent_id.present?"
|
65
|
+
end
|
66
|
+
|
67
|
+
def permanent_id_manager
|
68
|
+
@permanent_id_manager ||= Ddr::Managers::PermanentIdManager.new(self)
|
41
69
|
end
|
42
70
|
|
43
71
|
def roles
|
44
|
-
Ddr::Auth::Roles::PropertyRoleSet.new(
|
72
|
+
Ddr::Auth::Roles::PropertyRoleSet.new(accessRoles.roles)
|
45
73
|
end
|
46
74
|
|
47
75
|
def inherited_roles
|
@@ -52,6 +80,10 @@ module Ddr::Models
|
|
52
80
|
@workflow ||= Ddr::Managers::WorkflowManager.new(self)
|
53
81
|
end
|
54
82
|
|
83
|
+
def assign_permanent_id!
|
84
|
+
permanent_id_manager.assign_later
|
85
|
+
end
|
86
|
+
|
55
87
|
def grant_roles_to_creator(creator)
|
56
88
|
roles.grant type: Ddr::Auth::Roles::EDITOR,
|
57
89
|
agent: creator,
|
@@ -67,35 +99,29 @@ module Ddr::Models
|
|
67
99
|
end
|
68
100
|
|
69
101
|
def research_help
|
70
|
-
Ddr::
|
71
|
-
end
|
72
|
-
|
73
|
-
def finding_aid
|
74
|
-
if ead_id
|
75
|
-
FindingAid.new(ead_id)
|
76
|
-
end
|
102
|
+
Ddr::Contacts.get(research_help_contact) if research_help_contact
|
77
103
|
end
|
78
104
|
|
79
|
-
def
|
80
|
-
|
105
|
+
def effective_license
|
106
|
+
EffectiveLicense.call(self)
|
81
107
|
end
|
82
108
|
|
83
|
-
def
|
84
|
-
self
|
109
|
+
def inherited_license
|
110
|
+
InheritedLicense.call(self)
|
85
111
|
end
|
86
112
|
|
87
|
-
def
|
88
|
-
|
113
|
+
def finding_aid
|
114
|
+
if ead_id
|
115
|
+
FindingAid.new(ead_id)
|
116
|
+
end
|
89
117
|
end
|
90
118
|
|
91
|
-
|
92
|
-
lock
|
93
|
-
save
|
94
|
-
end
|
119
|
+
private
|
95
120
|
|
96
|
-
def
|
97
|
-
|
98
|
-
|
121
|
+
def update_permanent_id_on_destroy
|
122
|
+
@permanent_id = permanent_id
|
123
|
+
yield
|
124
|
+
Resque.enqueue(Ddr::Jobs::PermanentId::MakeUnavailable, @permanent_id, "deleted")
|
99
125
|
end
|
100
126
|
|
101
127
|
end
|
@@ -4,7 +4,9 @@ module Ddr
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
has_many :attachments,
|
7
|
+
has_many :attachments,
|
8
|
+
predicate: ::RDF::URI("http://projecthydra.org/ns/relations#isAttachedTo"),
|
9
|
+
class_name: 'Attachment'
|
8
10
|
end
|
9
11
|
|
10
12
|
end
|
@@ -2,14 +2,10 @@ module Ddr
|
|
2
2
|
module Models
|
3
3
|
module HasChildren
|
4
4
|
|
5
|
-
DEFAULT_SORT = "#{Ddr::Index::Fields::LOCAL_ID} ASC, #{Ddr::Index::Fields::OBJECT_CREATE_DATE} ASC"
|
6
|
-
|
7
5
|
def first_child
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def sorted_children
|
12
|
-
ActiveFedora::SolrService.query(association_query(:children), sort: DEFAULT_SORT, rows: 999999)
|
6
|
+
child_class = self.class.reflect_on_association(:children).klass
|
7
|
+
solr_field = child_class.reflect_on_association(:parent).solr_key
|
8
|
+
child_class.where(solr_field => id).order("#{Ddr::Index::Fields::LOCAL_ID} ASC").first
|
13
9
|
end
|
14
10
|
|
15
11
|
end
|
@@ -1,44 +1,41 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
1
3
|
module Ddr
|
2
4
|
module Models
|
3
5
|
module HasContent
|
4
6
|
extend ActiveSupport::Concern
|
5
7
|
|
8
|
+
MASTER_FILE_TYPES = [ "image/tiff" ]
|
9
|
+
|
10
|
+
def master_file?
|
11
|
+
if respond_to?(:file_use) && file_use.present?
|
12
|
+
file_use == Ddr::Models::HasStructMetadata::FILE_USE_MASTER
|
13
|
+
else
|
14
|
+
MASTER_FILE_TYPES.include?(content_type)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
6
18
|
included do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
versionable: true,
|
11
|
-
label: "Content file for this object",
|
12
|
-
control_group: "E"
|
13
|
-
|
14
|
-
has_file_datastream \
|
15
|
-
name: Ddr::Datastreams::EXTRACTED_TEXT,
|
16
|
-
type: Ddr::Datastreams::PlainTextDatastream,
|
17
|
-
versionable: true,
|
18
|
-
label: "Text extracted from the content file",
|
19
|
-
control_group: "M"
|
20
|
-
|
21
|
-
has_metadata \
|
22
|
-
name: Ddr::Datastreams::FITS,
|
23
|
-
type: Ddr::Datastreams::FitsDatastream,
|
24
|
-
versionable: false,
|
25
|
-
label: "FITS Output for content file",
|
26
|
-
control_group: "M"
|
27
|
-
|
28
|
-
has_attributes :original_filename, datastream: "adminMetadata", multiple: false
|
19
|
+
contains Ddr::Datastreams::CONTENT
|
20
|
+
contains Ddr::Datastreams::EXTRACTED_TEXT, class_name: 'Ddr::Datastreams::PlainTextDatastream'
|
21
|
+
contains Ddr::Datastreams::FITS, class_name: 'Ddr::Datastreams::FitsDatastream'
|
29
22
|
|
30
23
|
include FileManagement
|
31
24
|
|
25
|
+
around_save :update_derivatives, if: :content_changed?
|
26
|
+
|
27
|
+
around_save :characterize_file, if: [ :content_changed?, "Ddr::Models.characterize_files?" ]
|
28
|
+
|
32
29
|
delegate :validate_checksum!, to: :content
|
33
30
|
end
|
34
31
|
|
35
32
|
# Convenience method wrapping FileManagement#add_file
|
36
|
-
def upload
|
37
|
-
add_file(file, Ddr::Datastreams::CONTENT
|
33
|
+
def upload(file, opts={})
|
34
|
+
add_file(file, opts.merge(path: Ddr::Datastreams::CONTENT))
|
38
35
|
end
|
39
36
|
|
40
37
|
# Set content to file and save
|
41
|
-
def upload!
|
38
|
+
def upload!(file, opts={})
|
42
39
|
upload(file, opts)
|
43
40
|
save
|
44
41
|
end
|
@@ -52,7 +49,7 @@ module Ddr
|
|
52
49
|
end
|
53
50
|
|
54
51
|
def content_size
|
55
|
-
content.
|
52
|
+
content.size
|
56
53
|
end
|
57
54
|
|
58
55
|
def content_human_size
|
@@ -60,7 +57,7 @@ module Ddr
|
|
60
57
|
end
|
61
58
|
|
62
59
|
def content_type
|
63
|
-
content.
|
60
|
+
content.mime_type
|
64
61
|
end
|
65
62
|
|
66
63
|
def content_major_type
|
@@ -100,18 +97,24 @@ module Ddr
|
|
100
97
|
end
|
101
98
|
|
102
99
|
def content_changed?
|
103
|
-
content.
|
100
|
+
content.content_changed?
|
104
101
|
end
|
105
102
|
|
106
103
|
def has_extracted_text?
|
107
|
-
extractedText.
|
104
|
+
!extractedText.empty?
|
108
105
|
end
|
109
106
|
|
110
|
-
|
111
|
-
|
107
|
+
protected
|
108
|
+
|
109
|
+
def update_derivatives
|
110
|
+
yield
|
111
|
+
derivatives.update_derivatives(:later)
|
112
112
|
end
|
113
113
|
|
114
|
-
|
114
|
+
def characterize_file
|
115
|
+
yield
|
116
|
+
Resque.enqueue(Ddr::Jobs::FitsFileCharacterization, pid)
|
117
|
+
end
|
115
118
|
|
116
119
|
def default_content_type
|
117
120
|
"application/octet-stream"
|
@@ -1,17 +1,12 @@
|
|
1
|
-
module Ddr
|
2
|
-
module
|
3
|
-
|
1
|
+
module Ddr
|
2
|
+
module Models
|
3
|
+
module HasMultiresImage
|
4
|
+
extend ActiveSupport::Concern
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
label: "Multi-resolution image derivative for this object",
|
9
|
-
control_group: "E"
|
10
|
-
end
|
6
|
+
included do
|
7
|
+
property :multires_image_file_path, predicate: Ddr::Vocab::Asset.multiresImageFilePath, multiple: false
|
8
|
+
end
|
11
9
|
|
12
|
-
def multires_image_file_path
|
13
|
-
datastreams[Ddr::Datastreams::MULTIRES_IMAGE].file_path
|
14
10
|
end
|
15
|
-
|
16
11
|
end
|
17
12
|
end
|
@@ -4,18 +4,56 @@ module Ddr
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
8
|
-
type: Ddr::Datastreams::StructuralMetadataDatastream
|
7
|
+
contains Ddr::Datastreams::STRUCT_METADATA, class_name: 'Ddr::Datastreams::StructuralMetadataDatastream'
|
9
8
|
end
|
10
9
|
|
11
10
|
def structure
|
12
|
-
|
13
|
-
|
11
|
+
unless @structure
|
12
|
+
if datastreams[Ddr::Datastreams::STRUCT_METADATA].content
|
13
|
+
@structure = Ddr::Models::Structure.new(Nokogiri::XML(datastreams[Ddr::Datastreams::STRUCT_METADATA].content))
|
14
|
+
end
|
14
15
|
end
|
16
|
+
@structure
|
15
17
|
end
|
16
18
|
|
17
|
-
def
|
18
|
-
::
|
19
|
+
def build_default_structure
|
20
|
+
structure = Ddr::Models::Structure.new(Ddr::Models::Structure.template)
|
21
|
+
children = find_children
|
22
|
+
children.each do |child|
|
23
|
+
add_to_struct_map(structure, child)
|
24
|
+
end
|
25
|
+
structure
|
26
|
+
end
|
27
|
+
|
28
|
+
def multires_image_file_paths(type='default')
|
29
|
+
::SolrDocument.find(pid).multires_image_file_paths(type)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def find_children
|
35
|
+
query = association_query(:children)
|
36
|
+
sort = "#{Ddr::Index::Fields::LOCAL_ID} ASC, #{Ddr::Index::Fields::OBJECT_CREATE_DATE} ASC"
|
37
|
+
ActiveFedora::SolrService.query(query, sort: sort, rows: 999999)
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_to_struct_map(stru, child)
|
41
|
+
div = create_div(stru)
|
42
|
+
create_fptr(stru, div, child['id'])
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_div(stru)
|
46
|
+
div_count = stru.structMap_node('default').xpath('xmlns:div').size
|
47
|
+
div = Nokogiri::XML::Node.new('div', stru.as_xml_document)
|
48
|
+
div['ORDER'] = div_count + 1
|
49
|
+
stru.structMap_node('default').add_child(div)
|
50
|
+
div
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_fptr(stru, div, pid)
|
54
|
+
fptr = Nokogiri::XML::Node.new('fptr', stru.as_xml_document)
|
55
|
+
fptr['CONTENTIDS'] = "info:fedora/#{pid}"
|
56
|
+
div.add_child(fptr)
|
19
57
|
end
|
20
58
|
|
21
59
|
end
|