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,25 +0,0 @@
|
|
1
|
-
require "active_resource"
|
2
|
-
|
3
|
-
module Ddr::Models
|
4
|
-
class RightsStatement < ActiveResource::Base
|
5
|
-
|
6
|
-
self.site = ENV["DDR_AUX_API_URL"]
|
7
|
-
|
8
|
-
def self.call(obj)
|
9
|
-
if obj.rights.present?
|
10
|
-
new get(:find, url: obj.rights.first)
|
11
|
-
end
|
12
|
-
rescue ActiveResource::ResourceNotFound => e
|
13
|
-
raise Ddr::Models::NotFoundError, e
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.keys
|
17
|
-
all.map(&:url)
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_s
|
21
|
-
title
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Ddr::Models
|
2
|
-
module Streamable
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
has_file_datastream name: Ddr::Datastreams::STREAMABLE_MEDIA,
|
7
|
-
type: Ddr::Datastreams::StreamableMediaDatastream,
|
8
|
-
versionable: true,
|
9
|
-
label: "Streamable media file for this object",
|
10
|
-
control_group: "E"
|
11
|
-
end
|
12
|
-
|
13
|
-
def streamable_media_type
|
14
|
-
datastreams[Ddr::Datastreams::STREAMABLE_MEDIA].mimeType
|
15
|
-
end
|
16
|
-
|
17
|
-
def streamable_media_extension
|
18
|
-
extensions = Ddr::Models.preferred_file_extensions
|
19
|
-
if extensions.include? streamable_media_type
|
20
|
-
extensions[streamable_media_type]
|
21
|
-
else
|
22
|
-
streamable_media_extension_default
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def streamable_media_path
|
27
|
-
datastreams[Ddr::Datastreams::STREAMABLE_MEDIA].file_path
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def streamable_media_extension_default
|
33
|
-
datastreams[Ddr::Datastreams::STREAMABLE_MEDIA].default_file_extension
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Ddr::Models::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'agent' node
|
4
|
-
#
|
5
|
-
class Agent < SimpleDelegator
|
6
|
-
|
7
|
-
ROLE_CREATOR = 'CREATOR'.freeze
|
8
|
-
|
9
|
-
NAME_REPOSITORY_DEFAULT = 'REPOSITORY DEFAULT'.freeze
|
10
|
-
|
11
|
-
def id
|
12
|
-
self['ID']
|
13
|
-
end
|
14
|
-
|
15
|
-
def role
|
16
|
-
self['ROLE']
|
17
|
-
end
|
18
|
-
|
19
|
-
def otherrole
|
20
|
-
self['OTHERROLE']
|
21
|
-
end
|
22
|
-
|
23
|
-
def type
|
24
|
-
self['TYPE']
|
25
|
-
end
|
26
|
-
|
27
|
-
def othertype
|
28
|
-
self['OTHERTYPE']
|
29
|
-
end
|
30
|
-
|
31
|
-
def name
|
32
|
-
xpath('xmlns:name').first.content
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.build(args)
|
36
|
-
node = Nokogiri::XML::Node.new('agent', args[:document])
|
37
|
-
node['ID'] = args[:id] if args[:id]
|
38
|
-
node['ROLE'] = args[:role] if args[:role]
|
39
|
-
node['OTHERROLE'] = args[:otherrole] if args[:otherrole]
|
40
|
-
node['TYPE'] = args[:type] if args[:type]
|
41
|
-
node['OTHERTYPE'] = args[:othertype] if args[:othertype]
|
42
|
-
name_node = Nokogiri::XML::Node.new('name', args[:document])
|
43
|
-
name_node.content = args[:name]
|
44
|
-
node.add_child(name_node)
|
45
|
-
node
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Ddr::Models::Structures
|
2
|
-
class ComponentTypeTerm
|
3
|
-
|
4
|
-
CONFIG_FILE = ::File.join(Rails.root, 'config', 'structure_component_type.yml')
|
5
|
-
|
6
|
-
@@lookup = {}
|
7
|
-
|
8
|
-
def self.term(media_type)
|
9
|
-
hit = lookup_table.detect { |k,v| media_type =~ k }
|
10
|
-
hit.last if hit
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.lookup_table
|
14
|
-
load_lookup if @@lookup.empty?
|
15
|
-
@@lookup
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.load_lookup
|
19
|
-
config = YAML::load(::File.read(CONFIG_FILE))
|
20
|
-
config.each do |type_term, media_types|
|
21
|
-
media_types.each do |media_type|
|
22
|
-
lookup_key = Regexp.new("\\A#{media_type.gsub('*', '.*')}\\Z")
|
23
|
-
@@lookup[lookup_key] = type_term
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module Ddr::Models::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'div' node
|
4
|
-
#
|
5
|
-
class Div < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def label
|
12
|
-
self['LABEL']
|
13
|
-
end
|
14
|
-
|
15
|
-
def order
|
16
|
-
self['ORDER']
|
17
|
-
end
|
18
|
-
|
19
|
-
def orderlabel
|
20
|
-
self['ORDERLABEL']
|
21
|
-
end
|
22
|
-
|
23
|
-
def type
|
24
|
-
self['TYPE']
|
25
|
-
end
|
26
|
-
|
27
|
-
def divs
|
28
|
-
xpath('xmlns:div').map { |node| Div.new(node) }
|
29
|
-
end
|
30
|
-
|
31
|
-
def fptrs
|
32
|
-
xpath('xmlns:fptr').map { |node| Fptr.new(node) }
|
33
|
-
end
|
34
|
-
|
35
|
-
def mptrs
|
36
|
-
xpath('xmlns:mptr').map { |node| Mptr.new(node) }
|
37
|
-
end
|
38
|
-
|
39
|
-
def <=>(other)
|
40
|
-
order.to_i <=> other.order.to_i
|
41
|
-
end
|
42
|
-
|
43
|
-
def dereferenced_hash
|
44
|
-
contents = []
|
45
|
-
contents.concat(divs.map { |div| div.dereferenced_hash }) unless divs.empty?
|
46
|
-
contents.concat(fptrs.map { |fptr| fptr.dereferenced_hash }) unless fptrs.empty?
|
47
|
-
contents.concat(mptrs.map { |mptr| mptr.dereferenced_hash }) unless mptrs.empty?
|
48
|
-
dh = { id: id, label: label, order: order, orderlabel: orderlabel, type: type }.compact
|
49
|
-
dh[:contents] = contents unless contents.empty?
|
50
|
-
dh
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.build(args)
|
54
|
-
node = Nokogiri::XML::Node.new('div', args[:document])
|
55
|
-
node['ID'] = args[:id] if args[:id]
|
56
|
-
node['LABEL'] = args[:label] if args[:label]
|
57
|
-
node['ORDER'] = args[:order] if args[:order]
|
58
|
-
node['ORDERLABEL'] = args[:orderlabel] if args[:orderlabel]
|
59
|
-
node['TYPE'] = args[:type] if args[:type]
|
60
|
-
node
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Ddr::Models::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'FLocat' node
|
4
|
-
#
|
5
|
-
class FLocat < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def loctype
|
12
|
-
self['LOCTYPE']
|
13
|
-
end
|
14
|
-
|
15
|
-
def otherloctype
|
16
|
-
self['OTHERLOCTYPE']
|
17
|
-
end
|
18
|
-
|
19
|
-
def use
|
20
|
-
self['USE']
|
21
|
-
end
|
22
|
-
|
23
|
-
def href
|
24
|
-
self['xlink:href']
|
25
|
-
end
|
26
|
-
|
27
|
-
def ark?
|
28
|
-
loctype == 'ARK'
|
29
|
-
end
|
30
|
-
|
31
|
-
def ark
|
32
|
-
href if ark?
|
33
|
-
end
|
34
|
-
|
35
|
-
def effective_use
|
36
|
-
use ? use : File.new(parent).effective_use
|
37
|
-
end
|
38
|
-
|
39
|
-
def repo_id
|
40
|
-
SolrDocument.find_by_permanent_id(ark).id if ark?
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.build(args)
|
44
|
-
node = Nokogiri::XML::Node.new('FLocat', args[:document])
|
45
|
-
node['ID'] = args[:id] if args[:id]
|
46
|
-
node['LOCTYPE'] = args[:loctype] if args[:loctype]
|
47
|
-
node['OTHERLOCTYPE'] = args[:otherloctype] if args[:otherloctype]
|
48
|
-
node['USE'] = args[:use] if args[:use]
|
49
|
-
node['xlink:href'] = args[:href] if args[:href]
|
50
|
-
node
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module Ddr::Models::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'file' node
|
4
|
-
#
|
5
|
-
class File < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def use
|
12
|
-
self['USE']
|
13
|
-
end
|
14
|
-
|
15
|
-
def files
|
16
|
-
xpath('xmlns:file').map { |node| File.new(node) }
|
17
|
-
end
|
18
|
-
|
19
|
-
def flocats
|
20
|
-
xpath('xmlns:FLocat').map { |node| FLocat.new(node) }
|
21
|
-
end
|
22
|
-
|
23
|
-
def effective_use
|
24
|
-
if use
|
25
|
-
use
|
26
|
-
else
|
27
|
-
case parent.name
|
28
|
-
when "file"
|
29
|
-
File.new(parent).effective_use
|
30
|
-
when "fileGrp"
|
31
|
-
FileGrp.new(parent).effective_use
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def repo_ids
|
37
|
-
flocats.map(&:repo_id)
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.build(args)
|
41
|
-
node = Nokogiri::XML::Node.new('file', args[:document])
|
42
|
-
node['ID'] = args[:id] if args[:id]
|
43
|
-
node['USE'] = args[:use] if args[:use]
|
44
|
-
node
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.find(structure, fileid)
|
48
|
-
structure.files[fileid]
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Ddr::Models::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'fileGrp' node
|
4
|
-
#
|
5
|
-
class FileGrp < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def use
|
12
|
-
self['USE']
|
13
|
-
end
|
14
|
-
|
15
|
-
def filegrps
|
16
|
-
xpath('xmlns:filegrp').map { |node| FileGrp.new(node) }
|
17
|
-
end
|
18
|
-
|
19
|
-
def files
|
20
|
-
xpath('xmlns:file').map { |node| File.new(node) }
|
21
|
-
end
|
22
|
-
|
23
|
-
def effective_use
|
24
|
-
use
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.build(args)
|
28
|
-
node = Nokogiri::XML::Node.new('fileGrp', args[:document])
|
29
|
-
node['ID'] = args[:id] if args[:id]
|
30
|
-
node['USE'] = args[:use] if args[:use]
|
31
|
-
node
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Ddr::Models::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'fileSec' node
|
4
|
-
#
|
5
|
-
class FileSec < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def filegrps
|
12
|
-
xpath('xmlns:fileGrp').map { |node| FileGrp.new(node) }
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.build(args)
|
16
|
-
node = Nokogiri::XML::Node.new('fileSec', args[:document])
|
17
|
-
node['ID'] = args[:id] if args[:id]
|
18
|
-
node
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Ddr::Models::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'fptr' node
|
4
|
-
#
|
5
|
-
class Fptr < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def fileid
|
12
|
-
self['FILEID']
|
13
|
-
end
|
14
|
-
|
15
|
-
def dereferenced_hash
|
16
|
-
structure = Ddr::Models::Structure.new(document)
|
17
|
-
file = File.find(structure, fileid)
|
18
|
-
repo_id = file.repo_ids.first
|
19
|
-
use = file.flocats.first.effective_use
|
20
|
-
{ id: id, repo_id: repo_id, use: use }.compact
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.build(args)
|
24
|
-
node = Nokogiri::XML::Node.new('fptr', args[:document])
|
25
|
-
node['ID'] = args[:id] if args[:id]
|
26
|
-
node['FILEID'] = args[:fileid] if args[:fileid]
|
27
|
-
node
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Ddr::Models::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'metsHdr' node
|
4
|
-
#
|
5
|
-
class MetsHdr < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def createdate
|
12
|
-
self['CREATEDATE']
|
13
|
-
end
|
14
|
-
|
15
|
-
def lastmoddate
|
16
|
-
self['LASTMODDATE']
|
17
|
-
end
|
18
|
-
|
19
|
-
def recordstatus
|
20
|
-
self['RECORDSTATUS']
|
21
|
-
end
|
22
|
-
|
23
|
-
def agents
|
24
|
-
xpath('xmlns:agent').map { |node| Agent.new(node) }
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.build(args)
|
28
|
-
node = Nokogiri::XML::Node.new('metsHdr', args[:document])
|
29
|
-
node['ID'] = args[:id] if args[:id]
|
30
|
-
node['CREATEDATE'] = args[:createdate] if args[:createdate]
|
31
|
-
node['LASTMODDATE'] = args[:lastmoddate] if args[:lastmoddate]
|
32
|
-
node['RECORDSTATUS'] = args[:recordstatus] if args[:recordstatus]
|
33
|
-
node
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|