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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e01f1e7203428a8aa492b3233b2a2553dd288e7
|
4
|
+
data.tar.gz: 0ab1b89cd5aa345325aa2a3127573c2ba4353dd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62c5980174044c9c9199d41c4b38085f4a049352415c2f934a391d9eb2ba764299f67fa497f3586fefa97762c2bb83750d4c85b82d48d84a93025cef5b33bf82
|
7
|
+
data.tar.gz: e8f92ceecd6aa506d8f88092469a8bcac6d788eeebc39542401e8e630d29522ad94a37d95d9f2bf9f6877710112117ae3ed9a5fd7d88884625a6fa994874d6a7
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
language: ruby
|
2
2
|
before_install:
|
3
|
-
- sudo apt-get update -qq
|
4
3
|
- sudo apt-get install libvips-dev
|
5
|
-
- gem install bundler
|
6
|
-
bundler_args: --without production
|
7
4
|
rvm:
|
8
|
-
- 2.
|
5
|
+
- 2.1
|
9
6
|
script: "bundle exec rake ci"
|
10
|
-
|
11
|
-
-
|
7
|
+
cache:
|
8
|
+
- bundler
|
9
|
+
- apt
|
10
|
+
notifications:
|
11
|
+
email:
|
12
|
+
- lib-drs@duke.edu
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -9,11 +9,11 @@ Bundler::GemHelper.install_tasks
|
|
9
9
|
APP_ROOT = File.dirname(__FILE__)
|
10
10
|
|
11
11
|
JETTY_CONFIG = {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
jetty_home: File.join(APP_ROOT, "jetty"),
|
13
|
+
jetty_port: 8983,
|
14
|
+
startup_wait: 60,
|
15
|
+
quiet: true,
|
16
|
+
java_opts: ["-Xmx256m", "-XX:MaxPermSize=128m"]
|
17
17
|
}
|
18
18
|
|
19
19
|
require 'rspec/core/rake_task'
|
data/app/models/attachment.rb
CHANGED
@@ -7,10 +7,8 @@ class Attachment < Ddr::Models::Base
|
|
7
7
|
|
8
8
|
include Ddr::Models::HasContent
|
9
9
|
|
10
|
-
belongs_to :attached_to,
|
11
|
-
|
12
|
-
|
13
|
-
false
|
14
|
-
end
|
10
|
+
belongs_to :attached_to,
|
11
|
+
predicate: ::RDF::URI("http://projecthydra.org/ns/relations#isAttachedTo"),
|
12
|
+
class_name: "ActiveFedora::Base"
|
15
13
|
|
16
14
|
end
|
data/app/models/collection.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'htmlentities'
|
2
1
|
#
|
3
2
|
# A Collection is a conceptual and administrative entity containing a set of items.
|
4
3
|
#
|
@@ -6,23 +5,25 @@ class Collection < Ddr::Models::Base
|
|
6
5
|
|
7
6
|
include Ddr::Models::HasChildren
|
8
7
|
include Ddr::Models::HasAttachments
|
9
|
-
include Ddr::Models::HasStructMetadata
|
10
8
|
|
11
|
-
has_many :children,
|
12
|
-
|
9
|
+
has_many :children,
|
10
|
+
predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection,
|
11
|
+
class_name: "Item",
|
12
|
+
as: :parent
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
has_many :targets,
|
15
|
+
predicate: ::RDF::URI("http://www.loc.gov/mix/v20/externalTarget#isExternalTargetFor"),
|
16
|
+
class_name: "Target"
|
16
17
|
|
17
|
-
after_create :set_admin_policy
|
18
|
+
after_create :set_admin_policy
|
18
19
|
|
19
|
-
validates_presence_of :
|
20
|
+
validates_presence_of :dc_title
|
20
21
|
|
21
22
|
# Returns the SolrDocuments for Components associated with the Collection.
|
22
23
|
#
|
23
24
|
# @return A lazy enumerator of SolrDocuments.
|
24
25
|
def components_from_solr
|
25
|
-
query = "#{Ddr::Index::Fields::COLLECTION_URI}:#{RSolr.solr_escape(
|
26
|
+
query = "#{Ddr::Index::Fields::COLLECTION_URI}:#{RSolr.solr_escape(id)}"
|
26
27
|
filter = ActiveFedora::SolrService.construct_query_for_rel(:has_model => Component.to_class_uri)
|
27
28
|
results = ActiveFedora::SolrService.query(query, fq: filter, rows: 100000)
|
28
29
|
results.lazy.map {|doc| SolrDocument.new(doc)}
|
@@ -45,83 +46,15 @@ class Collection < Ddr::Models::Base
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def grant_roles_to_creator(creator)
|
49
|
+
roles.grant type: Ddr::Auth::Roles::CURATOR, agent: creator.agent, scope: Ddr::Auth::Roles::RESOURCE_SCOPE
|
48
50
|
roles.grant type: Ddr::Auth::Roles::CURATOR, agent: creator.agent, scope: Ddr::Auth::Roles::POLICY_SCOPE
|
49
51
|
end
|
50
52
|
|
51
|
-
def publishable?
|
52
|
-
true
|
53
|
-
end
|
54
|
-
|
55
|
-
def default_structure
|
56
|
-
build_default_structure
|
57
|
-
end
|
58
|
-
|
59
53
|
private
|
60
54
|
|
61
|
-
def default_roles
|
62
|
-
super.tap do |roles|
|
63
|
-
if Ddr::Auth.metadata_managers_group
|
64
|
-
roles << { type: Ddr::Auth::Roles::METADATA_EDITOR,
|
65
|
-
agent: Ddr::Auth.metadata_managers_group,
|
66
|
-
scope: Ddr::Auth::Roles::POLICY_SCOPE }
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
55
|
def set_admin_policy
|
72
|
-
reload
|
73
56
|
self.admin_policy = self
|
74
|
-
save
|
75
|
-
end
|
76
|
-
|
77
|
-
def build_default_structure
|
78
|
-
document = Ddr::Models::Structure.xml_template
|
79
|
-
structure = Ddr::Models::Structure.new(document)
|
80
|
-
metshdr = structure.add_metshdr
|
81
|
-
structure.add_agent(parent: metshdr, role: Ddr::Models::Structures::Agent::ROLE_CREATOR,
|
82
|
-
name: Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT)
|
83
|
-
structmap = structure.add_structmap(type: Ddr::Models::Structure::TYPE_DEFAULT)
|
84
|
-
add_items_to_structure(structure, structmap)
|
85
|
-
structure
|
86
|
-
end
|
87
|
-
|
88
|
-
def add_items_to_structure(structure, structmap)
|
89
|
-
sorted_items_for_structure.each do |item|
|
90
|
-
if path = item[Ddr::Index::Fields::NESTED_PATH]
|
91
|
-
nest = path.split(File::SEPARATOR)
|
92
|
-
else
|
93
|
-
nest = []
|
94
|
-
end
|
95
|
-
find_or_create_div(structure, structmap, nest, item[Ddr::Index::Fields::PERMANENT_ID])
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def find_or_create_div(structure, parent, nest, permanent_id)
|
100
|
-
label = nest.shift
|
101
|
-
order = parent.elements.count + 1
|
102
|
-
if nest.empty?
|
103
|
-
div = structure.add_div(parent: parent, order: order)
|
104
|
-
add_mptr(structure, div, permanent_id)
|
105
|
-
else
|
106
|
-
label = HTMLEntities.new.encode(label)
|
107
|
-
div = parent.xpath(%Q[xmlns:div[@LABEL="#{label}"]]).first ||
|
108
|
-
structure.add_div(parent: parent, type: 'Directory', label: label, order: order)
|
109
|
-
find_or_create_div(structure, div, nest, permanent_id)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def add_mptr(structure, div, permanent_id)
|
114
|
-
structure.add_mptr(parent: div, href: permanent_id)
|
115
|
-
end
|
116
|
-
|
117
|
-
def sorted_items_for_structure
|
118
|
-
ActiveFedora::SolrService.query(association_query(:children), sort: item_sort_for_structure, rows: 999999)
|
119
|
-
end
|
120
|
-
|
121
|
-
def item_sort_for_structure
|
122
|
-
"#{Ddr::Index::Fields::NESTED_PATH} ASC,
|
123
|
-
#{Ddr::Index::Fields::LOCAL_ID} ASC,
|
124
|
-
#{Ddr::Index::Fields::OBJECT_CREATE_DATE} ASC"
|
57
|
+
self.save
|
125
58
|
end
|
126
59
|
|
127
60
|
end
|
data/app/models/component.rb
CHANGED
@@ -5,83 +5,24 @@
|
|
5
5
|
#
|
6
6
|
class Component < Ddr::Models::Base
|
7
7
|
|
8
|
-
include Ddr::Models::Captionable
|
9
8
|
include Ddr::Models::HasContent
|
10
|
-
include Ddr::Models::HasIntermediateFile
|
11
9
|
include Ddr::Models::HasMultiresImage
|
12
10
|
include Ddr::Models::HasStructMetadata
|
13
|
-
include Ddr::Models::Streamable
|
14
11
|
|
15
|
-
belongs_to :parent,
|
16
|
-
|
12
|
+
belongs_to :parent,
|
13
|
+
predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf,
|
14
|
+
class_name: "Item"
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
STRUCTURALLY_RELEVANT_DATASTREAMS = [ Ddr::Datastreams::CAPTION, Ddr::Datastreams::CONTENT,
|
22
|
-
Ddr::Datastreams::INTERMEDIATE_FILE, Ddr::Datastreams::MULTIRES_IMAGE,
|
23
|
-
Ddr::Datastreams::STREAMABLE_MEDIA, Ddr::Datastreams::THUMBNAIL ]
|
16
|
+
belongs_to :target,
|
17
|
+
predicate: ::RDF::URI("http://www.loc.gov/mix/v20/externalTarget#hasExternalTarget"),
|
18
|
+
class_name: "Target"
|
24
19
|
|
25
20
|
def collection
|
26
21
|
self.parent.parent rescue nil
|
27
22
|
end
|
28
23
|
|
29
|
-
def
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def publishable?
|
34
|
-
parent.present? && parent.published?
|
35
|
-
end
|
36
|
-
|
37
|
-
def default_structure
|
38
|
-
build_default_structure
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def build_default_structure
|
44
|
-
document = Ddr::Models::Structure.xml_template
|
45
|
-
structure = Ddr::Models::Structure.new(document)
|
46
|
-
metshdr = structure.add_metshdr
|
47
|
-
structure.add_agent(parent: metshdr, role: Ddr::Models::Structures::Agent::ROLE_CREATOR,
|
48
|
-
name: Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT)
|
49
|
-
structmap = structure.add_structmap(type: Ddr::Models::Structure::TYPE_DEFAULT)
|
50
|
-
if has_content?
|
51
|
-
filesec = structure.add_filesec
|
52
|
-
div = structure.add_div(parent: structmap)
|
53
|
-
filegrp = structure.add_filegrp(parent: filesec)
|
54
|
-
add_use_to_structure(structure, filegrp, div, Ddr::Models::Structure::USE_ORIGINAL_FILE,
|
55
|
-
Ddr::Datastreams::CONTENT)
|
56
|
-
add_use_to_structure(structure, filegrp, div, Ddr::Models::Structure::USE_PRESERVATION_MASTER_FILE,
|
57
|
-
Ddr::Datastreams::CONTENT)
|
58
|
-
add_use_to_structure(structure, filegrp, div, Ddr::Models::Structure::USE_INTERMEDIATE_FILE,
|
59
|
-
Ddr::Datastreams::INTERMEDIATE_FILE) if has_intermediate_file?
|
60
|
-
add_service_file_uses_to_default_structure(structure, filegrp, div)
|
61
|
-
add_use_to_structure(structure, filegrp, div, Ddr::Models::Structure::USE_THUMBNAIL_IMAGE,
|
62
|
-
Ddr::Datastreams::THUMBNAIL) if has_thumbnail?
|
63
|
-
add_use_to_structure(structure, filegrp, div, Ddr::Models::Structure::USE_TRANSCRIPT,
|
64
|
-
Ddr::Datastreams::CAPTION) if captioned?
|
65
|
-
|
66
|
-
end
|
67
|
-
structure
|
68
|
-
end
|
69
|
-
|
70
|
-
def add_service_file_uses_to_default_structure(structure, filegrp, div)
|
71
|
-
add_use_to_structure(structure, filegrp, div, Ddr::Models::Structure::USE_SERVICE_FILE,
|
72
|
-
Ddr::Datastreams::MULTIRES_IMAGE) if has_multires_image?
|
73
|
-
add_use_to_structure(structure, filegrp, div, Ddr::Models::Structure::USE_SERVICE_FILE,
|
74
|
-
Ddr::Datastreams::STREAMABLE_MEDIA) if streamable?
|
75
|
-
if !has_multires_image? && !streamable?
|
76
|
-
add_use_to_structure(structure, filegrp, div, Ddr::Models::Structure::USE_SERVICE_FILE,
|
77
|
-
Ddr::Datastreams::CONTENT)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def add_use_to_structure(structure, filegrp, div, use, datastream_name)
|
82
|
-
file = structure.add_file(parent: filegrp, use: use)
|
83
|
-
structure.add_flocat(parent: file, loctype: 'OTHER', otherloctype: 'AttachedFile', href: datastream_name)
|
84
|
-
structure.add_fptr(parent: div, fileid: file['ID'])
|
24
|
+
def collection_id
|
25
|
+
collection.id rescue nil
|
85
26
|
end
|
86
27
|
|
87
28
|
end
|
data/app/models/item.rb
CHANGED
@@ -8,78 +8,13 @@ class Item < Ddr::Models::Base
|
|
8
8
|
include Ddr::Models::HasChildren
|
9
9
|
include Ddr::Models::HasStructMetadata
|
10
10
|
|
11
|
-
has_many :children,
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
alias_method :collection, :parent
|
21
|
-
alias_method :collection_id, :parent_id
|
22
|
-
alias_method :collection=, :parent=
|
23
|
-
|
24
|
-
def publishable?
|
25
|
-
parent.present? && parent.published?
|
26
|
-
end
|
27
|
-
|
28
|
-
def children_having_extracted_text
|
29
|
-
Ddr::Index::Query.build(self) do |item|
|
30
|
-
is_part_of item
|
31
|
-
where attached_files_having_content: "extractedText"
|
32
|
-
fields :id, :extracted_text
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def all_text
|
37
|
-
children_having_extracted_text.docs.map(&:extracted_text).flatten
|
38
|
-
end
|
39
|
-
|
40
|
-
def default_structure
|
41
|
-
build_default_structure
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def build_default_structure
|
47
|
-
document = Ddr::Models::Structure.xml_template
|
48
|
-
structure = Ddr::Models::Structure.new(document)
|
49
|
-
metshdr = structure.add_metshdr
|
50
|
-
structure.add_agent(parent: metshdr, role: Ddr::Models::Structures::Agent::ROLE_CREATOR,
|
51
|
-
name: Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT)
|
52
|
-
structmap = structure.add_structmap(type: Ddr::Models::Structure::TYPE_DEFAULT)
|
53
|
-
add_components_to_structure(structure, structmap)
|
54
|
-
structure
|
55
|
-
end
|
56
|
-
|
57
|
-
def add_components_to_structure(structure, structmap)
|
58
|
-
component_structure_types(sorted_children).each do |type_term, children|
|
59
|
-
div = structure.add_div(parent: structmap, type: type_term)
|
60
|
-
children.each_with_index do |child, index|
|
61
|
-
sub_div = structure.add_div(parent: div, order: index + 1)
|
62
|
-
structure.add_mptr(parent: sub_div, href: child[Ddr::Index::Fields::PERMANENT_ID])
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def component_structure_types(sorted_children)
|
68
|
-
type_divs = {}
|
69
|
-
sorted_children.each do |child|
|
70
|
-
term = type_term(child) || "Other"
|
71
|
-
if type_divs.has_key?(term)
|
72
|
-
type_divs[term] << child
|
73
|
-
else
|
74
|
-
type_divs[term] = [ child ]
|
75
|
-
end
|
76
|
-
end
|
77
|
-
type_divs
|
78
|
-
end
|
79
|
-
|
80
|
-
def type_term(component_doc)
|
81
|
-
media_type = component_doc[Ddr::Index::Fields::MEDIA_TYPE].first
|
82
|
-
Ddr::Models::Structures::ComponentTypeTerm.term(media_type)
|
83
|
-
end
|
11
|
+
has_many :children,
|
12
|
+
predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf,
|
13
|
+
class_name: "Component",
|
14
|
+
as: :parent
|
15
|
+
|
16
|
+
belongs_to :parent,
|
17
|
+
predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection,
|
18
|
+
class_name: "Collection"
|
84
19
|
|
85
20
|
end
|
data/app/models/target.rb
CHANGED
@@ -9,11 +9,12 @@ class Target < Ddr::Models::Base
|
|
9
9
|
|
10
10
|
include Ddr::Models::HasContent
|
11
11
|
|
12
|
-
has_many :components,
|
13
|
-
|
12
|
+
has_many :components,
|
13
|
+
predicate: ::RDF::URI("http://www.loc.gov/mix/v20/externalTarget#hasExternalTarget"),
|
14
|
+
class_name: "Component"
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
belongs_to :collection,
|
17
|
+
predicate: ::RDF::URI("http://www.loc.gov/mix/v20/externalTarget#isExternalTargetFor"),
|
18
|
+
class_name: "Collection"
|
18
19
|
|
19
20
|
end
|
@@ -18,7 +18,7 @@ module ActiveFedora
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def can_have_content?
|
21
|
-
datastreams.
|
21
|
+
datastreams.key? "content"
|
22
22
|
end
|
23
23
|
|
24
24
|
def has_content?
|
@@ -37,54 +37,35 @@ module ActiveFedora
|
|
37
37
|
governable? && admin_policy.present?
|
38
38
|
end
|
39
39
|
|
40
|
+
def has_rights_metadata?
|
41
|
+
ds = self.datastreams[Ddr::Datastreams::RIGHTS_METADATA]
|
42
|
+
ds && ds.size && ds.size > 0
|
43
|
+
end
|
44
|
+
|
40
45
|
def can_have_struct_metadata?
|
41
|
-
datastreams.
|
46
|
+
datastreams.key? Ddr::Datastreams::STRUCT_METADATA
|
42
47
|
end
|
43
48
|
|
44
49
|
def has_struct_metadata?
|
45
50
|
can_have_struct_metadata? && structMetadata.has_content?
|
46
51
|
end
|
47
52
|
|
48
|
-
def can_have_intermediate_file?
|
49
|
-
datastreams.include? Ddr::Datastreams::INTERMEDIATE_FILE
|
50
|
-
end
|
51
|
-
|
52
|
-
def has_intermediate_file?
|
53
|
-
can_have_intermediate_file? && datastreams[Ddr::Datastreams::INTERMEDIATE_FILE].has_content?
|
54
|
-
end
|
55
|
-
|
56
53
|
def can_have_multires_image?
|
57
|
-
|
54
|
+
respond_to? :multires_image_file_path
|
58
55
|
end
|
59
56
|
|
60
57
|
def has_multires_image?
|
61
|
-
can_have_multires_image? &&
|
58
|
+
can_have_multires_image? && multires_image_file_path.present?
|
62
59
|
end
|
63
|
-
|
60
|
+
|
64
61
|
def can_have_thumbnail?
|
65
|
-
datastreams.
|
62
|
+
datastreams.key? "thumbnail"
|
66
63
|
end
|
67
64
|
|
68
65
|
def has_thumbnail?
|
69
66
|
can_have_thumbnail? && thumbnail.has_content?
|
70
67
|
end
|
71
68
|
|
72
|
-
def captionable?
|
73
|
-
datastreams.include? Ddr::Datastreams::CAPTION
|
74
|
-
end
|
75
|
-
|
76
|
-
def captioned?
|
77
|
-
captionable? && datastreams[Ddr::Datastreams::CAPTION].has_content?
|
78
|
-
end
|
79
|
-
|
80
|
-
def can_be_streamable?
|
81
|
-
datastreams.include? Ddr::Datastreams::STREAMABLE_MEDIA
|
82
|
-
end
|
83
|
-
|
84
|
-
def streamable?
|
85
|
-
can_be_streamable? && datastreams[Ddr::Datastreams::STREAMABLE_MEDIA].has_content?
|
86
|
-
end
|
87
|
-
|
88
69
|
def safe_id
|
89
70
|
id.sub(/:/, "-")
|
90
71
|
end
|