ddr-models 2.11.0 → 3.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +7 -6
- data/Gemfile +2 -3
- data/Rakefile +5 -5
- data/app/controllers/users/sessions_controller.rb +5 -0
- data/app/helpers/models_helper.rb +7 -0
- data/app/models/attachment.rb +3 -5
- data/app/models/collection.rb +12 -79
- data/app/models/component.rb +8 -67
- data/app/models/item.rb +8 -73
- data/app/models/target.rb +6 -5
- data/config/initializers/active_fedora_base.rb +11 -30
- data/config/initializers/{active_fedora_datastream.rb → active_fedora_file.rb} +1 -1
- data/config/initializers/devise.rb +2 -3
- data/config/initializers/subscriptions.rb +2 -19
- data/ddr-models.gemspec +10 -14
- data/lib/ddr/actions/fixity_check.rb +1 -1
- data/lib/ddr/actions/virus_check.rb +17 -10
- data/lib/ddr/auth.rb +6 -38
- data/lib/ddr/auth/ability.rb +1 -5
- data/lib/ddr/auth/ability_definitions/collection_ability_definitions.rb +0 -16
- data/lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb +10 -4
- data/lib/ddr/auth/ability_definitions/role_based_ability_definitions.rb +16 -9
- data/lib/ddr/auth/ability_factory.rb +25 -2
- data/lib/ddr/auth/abstract_ability.rb +1 -2
- data/lib/ddr/auth/auth_context.rb +0 -18
- data/lib/ddr/auth/auth_context_factory.rb +2 -0
- data/lib/ddr/auth/group.rb +0 -6
- data/lib/ddr/auth/grouper_gateway.rb +0 -24
- data/lib/ddr/auth/permissions.rb +1 -12
- data/lib/ddr/auth/role_based_access_controls_enforcement.rb +5 -5
- data/lib/ddr/auth/roles.rb +1 -11
- data/lib/ddr/auth/roles/role_set.rb +0 -7
- data/lib/ddr/auth/roles/roles_datastream.rb +9 -0
- data/lib/ddr/contacts.rb +25 -0
- data/lib/ddr/datastreams.rb +10 -28
- data/lib/ddr/datastreams/datastream_behavior.rb +30 -100
- data/lib/ddr/datastreams/descriptive_metadata_datastream.rb +28 -31
- data/lib/ddr/datastreams/fits_datastream.rb +9 -22
- data/lib/ddr/datastreams/metadata_datastream.rb +17 -31
- data/lib/ddr/derivatives.rb +13 -16
- data/lib/ddr/derivatives/derivative.rb +68 -0
- data/lib/ddr/derivatives/{generator.rb → generators/generator.rb} +11 -7
- data/lib/ddr/derivatives/generators/png_generator.rb +23 -0
- data/lib/ddr/derivatives/generators/ptif_generator.rb +56 -0
- data/lib/ddr/derivatives/multires_image.rb +59 -0
- data/lib/ddr/derivatives/thumbnail.rb +36 -0
- data/lib/ddr/events.rb +0 -1
- data/lib/ddr/events/deletion_event.rb +9 -5
- data/lib/ddr/events/event.rb +8 -13
- data/lib/ddr/events/fixity_check_event.rb +0 -6
- data/lib/ddr/events/ingestion_event.rb +9 -5
- data/lib/ddr/events/update_event.rb +4 -17
- data/lib/ddr/index.rb +4 -4
- data/lib/ddr/index/abstract_query_result.rb +4 -3
- data/lib/ddr/index/connection.rb +9 -28
- data/lib/ddr/index/csv_query_result.rb +32 -47
- data/lib/ddr/index/field.rb +1 -11
- data/lib/ddr/index/fields.rb +16 -99
- data/lib/ddr/index/filter.rb +30 -103
- data/lib/ddr/index/filters.rb +19 -0
- data/lib/ddr/index/query.rb +11 -58
- data/lib/ddr/index/query_builder.rb +36 -147
- data/lib/ddr/index/query_clause.rb +19 -79
- data/lib/ddr/index/query_result.rb +4 -36
- data/lib/ddr/index/query_value.rb +18 -0
- data/lib/ddr/index/response.rb +2 -19
- data/lib/ddr/jobs.rb +12 -0
- data/lib/ddr/jobs/fits_file_characterization.rb +51 -0
- data/lib/ddr/jobs/permanent_id.rb +23 -0
- data/lib/ddr/managers.rb +1 -0
- data/lib/ddr/managers/derivatives_manager.rb +53 -93
- data/lib/ddr/managers/permanent_id_manager.rb +91 -0
- data/lib/ddr/managers/technical_metadata_manager.rb +10 -24
- data/lib/ddr/managers/workflow_manager.rb +10 -29
- data/lib/ddr/models.rb +50 -101
- data/lib/ddr/models/access_controllable.rb +12 -0
- data/lib/ddr/models/admin_set.rb +5 -16
- data/lib/ddr/models/base.rb +45 -165
- data/lib/ddr/models/describable.rb +19 -21
- data/lib/ddr/models/engine.rb +11 -39
- data/lib/ddr/models/error.rb +0 -3
- data/lib/ddr/models/file_management.rb +36 -72
- data/lib/ddr/models/finding_aid.rb +2 -35
- data/lib/ddr/models/fixity_checkable.rb +4 -0
- data/lib/ddr/models/governable.rb +3 -1
- data/lib/ddr/models/has_admin_metadata.rb +82 -56
- data/lib/ddr/models/has_attachments.rb +3 -1
- data/lib/ddr/models/has_children.rb +3 -7
- data/lib/ddr/models/has_content.rb +35 -32
- data/lib/ddr/models/has_multires_image.rb +7 -12
- data/lib/ddr/models/has_struct_metadata.rb +44 -6
- data/lib/ddr/models/has_thumbnail.rb +1 -4
- data/lib/ddr/models/indexing.rb +97 -186
- data/lib/ddr/models/licenses/admin_policy_license.rb +11 -0
- data/lib/ddr/models/licenses/effective_license.rb +9 -0
- data/lib/ddr/models/licenses/inherited_license.rb +9 -0
- data/lib/ddr/models/licenses/license.rb +21 -0
- data/lib/ddr/models/licenses/parent_license.rb +11 -0
- data/lib/ddr/models/metadata/descriptive_metadata.rb +50 -0
- data/lib/ddr/models/metadata/metadata.rb +37 -0
- data/lib/ddr/models/metadata/metadata_mapper.rb +32 -0
- data/lib/ddr/models/metadata/metadata_mappers.rb +18 -0
- data/lib/ddr/models/metadata/metadata_term.rb +24 -0
- data/lib/ddr/models/metadata/metadata_vocabularies.rb +18 -0
- data/lib/ddr/models/metadata/metadata_vocabulary.rb +34 -0
- data/lib/ddr/models/solr_document.rb +24 -156
- data/lib/ddr/models/struct_div.rb +63 -0
- data/lib/ddr/models/structure.rb +39 -175
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/models/year_facet.rb +118 -60
- data/lib/ddr/notifications.rb +12 -10
- data/lib/ddr/utils.rb +15 -28
- data/lib/ddr/vocab.rb +17 -15
- data/lib/ddr/vocab/asset.rb +17 -42
- data/lib/ddr/vocab/contact.rb +7 -5
- data/lib/ddr/vocab/display.rb +8 -6
- data/lib/ddr/vocab/duke_terms.rb +10 -8
- data/lib/ddr/vocab/rdf_vocabulary_parser.rb +39 -37
- data/lib/ddr/vocab/roles.rb +19 -17
- data/lib/ddr/vocab/sources/duketerms.rdf +8 -22
- data/lib/ddr/vocab/vocabulary.rb +26 -26
- data/spec/auth/ability_factory_spec.rb +1 -18
- data/spec/auth/ability_spec.rb +15 -119
- data/spec/auth/effective_permissions_spec.rb +1 -1
- data/spec/auth/effective_roles_spec.rb +1 -1
- data/spec/auth/ldap_gateway_spec.rb +9 -0
- data/spec/contacts/contacts_spec.rb +26 -0
- data/spec/controllers/including_role_based_access_controls_enforcement_spec.rb +5 -5
- data/spec/derivatives/multires_image_spec.rb +48 -0
- data/spec/derivatives/png_generator_spec.rb +8 -13
- data/spec/derivatives/ptif_generator_spec.rb +11 -9
- data/spec/derivatives/thumbnail_spec.rb +48 -0
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/schema.rb +23 -25
- data/spec/factories/attachment_factories.rb +2 -2
- data/spec/factories/collection_factories.rb +2 -3
- data/spec/factories/component_factories.rb +2 -2
- data/spec/factories/item_factories.rb +2 -2
- data/spec/factories/structure_factories.rb +2 -8
- data/spec/factories/test_model_factories.rb +12 -4
- data/spec/fixtures/fits/document.xml +44 -42
- data/spec/fixtures/fits/image.xml +41 -42
- data/spec/helpers/models_helper_spec.rb +11 -0
- data/spec/index/filter_spec.rb +30 -208
- data/spec/index/filters_spec.rb +17 -0
- data/spec/index/query_spec.rb +10 -82
- data/spec/jobs/fits_file_characterization_spec.rb +52 -0
- data/spec/managers/derivatives_manager_spec.rb +105 -107
- data/spec/managers/technical_metadata_manager_spec.rb +27 -34
- data/spec/models/active_fedora_base_spec.rb +105 -5
- data/spec/models/active_fedora_datastream_spec.rb +39 -106
- data/spec/models/admin_set_spec.rb +10 -43
- data/spec/models/attachment_spec.rb +2 -3
- data/spec/models/collection_spec.rb +11 -225
- data/spec/models/component_spec.rb +4 -106
- data/spec/models/descriptive_metadata_spec.rb +38 -0
- data/spec/models/effective_license_spec.rb +64 -0
- data/spec/models/events_spec.rb +59 -52
- data/spec/models/file_management_spec.rb +13 -113
- data/spec/models/finding_aid_spec.rb +8 -31
- data/spec/models/has_admin_metadata_spec.rb +122 -131
- data/spec/models/has_children_spec.rb +3 -3
- data/spec/models/has_struct_metadata_spec.rb +37 -50
- data/spec/models/indexing_spec.rb +23 -160
- data/spec/models/item_spec.rb +2 -133
- data/spec/models/license_spec.rb +24 -0
- data/spec/models/solr_document_spec.rb +47 -236
- data/spec/models/struct_div_spec.rb +70 -0
- data/spec/models/structure_spec.rb +11 -89
- data/spec/models/target_spec.rb +2 -4
- data/spec/models/year_facet_spec.rb +23 -50
- data/spec/spec_helper.rb +13 -17
- data/spec/support/ezid_mock_identifier.rb +2 -2
- data/spec/support/shared_examples_for_auth_contexts.rb +0 -33
- data/spec/support/shared_examples_for_ddr_models.rb +94 -142
- data/spec/support/shared_examples_for_describables.rb +36 -31
- data/spec/support/shared_examples_for_governables.rb +2 -3
- data/spec/support/shared_examples_for_has_content.rb +46 -101
- data/spec/support/shared_examples_for_indexing.rb +6 -6
- data/spec/support/shared_examples_for_non_collection_models.rb +1 -32
- data/spec/support/structural_metadata_helper.rb +59 -230
- data/spec/utils_spec.rb +2 -0
- metadata +96 -229
- data/.ruby-version +0 -1
- data/config/initializers/rsolr_monkey_patches.rb +0 -7
- data/config/initializers/rubydora_monkey_patch.rb +0 -11
- data/config/locales/ddr-models.en.yml +0 -81
- data/db/migrate/20161021201011_add_permanent_id_to_events.rb +0 -8
- data/lib/ddr/auth/ability_definitions/admin_set_ability_definitions.rb +0 -9
- data/lib/ddr/auth/ability_definitions/lock_ability_definitions.rb +0 -13
- data/lib/ddr/auth/ability_definitions/publication_ability_definitions.rb +0 -16
- data/lib/ddr/datastreams/administrative_metadata_datastream.rb +0 -75
- data/lib/ddr/datastreams/caption_datastream.rb +0 -5
- data/lib/ddr/datastreams/content_datastream.rb +0 -17
- data/lib/ddr/datastreams/delete_external_files.rb +0 -29
- data/lib/ddr/datastreams/external_file_datastream.rb +0 -80
- data/lib/ddr/datastreams/intermediate_file_datastream.rb +0 -5
- data/lib/ddr/datastreams/multires_image_datastream.rb +0 -5
- data/lib/ddr/datastreams/streamable_media_datastream.rb +0 -5
- data/lib/ddr/derivatives/png_generator.rb +0 -17
- data/lib/ddr/derivatives/ptif_generator.rb +0 -55
- data/lib/ddr/derivatives/update_derivatives.rb +0 -25
- data/lib/ddr/events/deaccession_event.rb +0 -8
- data/lib/ddr/index/field_attribute.rb +0 -22
- data/lib/ddr/index/query_params.rb +0 -40
- data/lib/ddr/index/sort_order.rb +0 -28
- data/lib/ddr/models/cache.rb +0 -20
- data/lib/ddr/models/captionable.rb +0 -37
- data/lib/ddr/models/contact.rb +0 -23
- data/lib/ddr/models/file_characterization.rb +0 -37
- data/lib/ddr/models/has_intermediate_file.rb +0 -41
- data/lib/ddr/models/language.rb +0 -31
- data/lib/ddr/models/media_type.rb +0 -22
- data/lib/ddr/models/permanent_id.rb +0 -240
- data/lib/ddr/models/rights_statement.rb +0 -25
- data/lib/ddr/models/streamable.rb +0 -37
- data/lib/ddr/models/structures/agent.rb +0 -49
- data/lib/ddr/models/structures/component_type_term.rb +0 -29
- data/lib/ddr/models/structures/div.rb +0 -64
- data/lib/ddr/models/structures/f_locat.rb +0 -54
- data/lib/ddr/models/structures/file.rb +0 -52
- data/lib/ddr/models/structures/file_grp.rb +0 -35
- data/lib/ddr/models/structures/file_sec.rb +0 -22
- data/lib/ddr/models/structures/fptr.rb +0 -31
- data/lib/ddr/models/structures/mets_hdr.rb +0 -37
- data/lib/ddr/models/structures/mptr.rb +0 -49
- data/lib/ddr/models/structures/struct_map.rb +0 -40
- data/lib/ddr/models/with_content_file.rb +0 -37
- data/spec/datastreams/external_file_datastream_spec.rb +0 -48
- data/spec/dummy/config/structure_component_type.yml +0 -18
- data/spec/fixtures/abcd1234.vtt +0 -38
- data/spec/fixtures/arrow1rightred_e0.gif +0 -0
- data/spec/fixtures/extractedText1.txt +0 -1
- data/spec/fixtures/extractedText2.txt +0 -1
- data/spec/fixtures/extractedText3.txt +0 -3
- data/spec/fixtures/imageA.jpg +0 -0
- data/spec/fixtures/imageB.jpg +0 -0
- data/spec/index/csv_query_result_spec.rb +0 -44
- data/spec/index/fields_spec.rb +0 -380
- data/spec/index/query_builder_spec.rb +0 -140
- data/spec/index/query_clause_spec.rb +0 -68
- data/spec/models/cache_spec.rb +0 -32
- data/spec/models/contact_spec.rb +0 -56
- data/spec/models/descriptive_metadata_datastream_spec.rb +0 -139
- data/spec/models/file_characterization_spec.rb +0 -39
- data/spec/models/language_spec.rb +0 -59
- data/spec/models/media_type_spec.rb +0 -46
- data/spec/models/permanent_id_spec.rb +0 -432
- data/spec/models/rights_statement_spec.rb +0 -55
- data/spec/models/structures/agent_spec.rb +0 -30
- data/spec/models/structures/component_type_term_spec.rb +0 -14
- data/spec/models/structures/div_spec.rb +0 -26
- data/spec/models/structures/f_locat_spec.rb +0 -78
- data/spec/models/structures/file_grp_spec.rb +0 -23
- data/spec/models/structures/file_sec_spec.rb +0 -22
- data/spec/models/structures/file_spec.rb +0 -60
- data/spec/models/structures/fptr_spec.rb +0 -23
- data/spec/models/structures/mets_hdr_spec.rb +0 -26
- data/spec/models/structures/mptr_spec.rb +0 -25
- data/spec/models/structures/struct_map_spec.rb +0 -24
- data/spec/models/with_content_file_spec.rb +0 -37
- data/spec/support/shared_examples_for_associations.rb +0 -8
- data/spec/support/shared_examples_for_captionable.rb +0 -23
- data/spec/support/shared_examples_for_has_intermediate_file.rb +0 -28
- data/spec/support/shared_examples_for_publication.rb +0 -43
- data/spec/support/shared_examples_for_streamable_media.rb +0 -23
data/lib/ddr/vocab/contact.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
module Ddr
|
2
|
-
|
1
|
+
module Ddr
|
2
|
+
module Vocab
|
3
|
+
class Contact < RDF::StrictVocabulary("http://repository.lib.duke.edu/vocab/contact/")
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
property "assistance",
|
6
|
+
label: "Research Assistance",
|
7
|
+
comment: "Contact for research assistance with this object."
|
7
8
|
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
data/lib/ddr/vocab/display.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
module Ddr
|
2
|
-
|
1
|
+
module Ddr
|
2
|
+
module Vocab
|
3
|
+
class Display < RDF::StrictVocabulary("http://repository.lib.duke.edu/vocab/display/")
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
property "format",
|
6
|
+
label: "Display Format",
|
7
|
+
comment: "Format to use when displaying the object."
|
7
8
|
|
9
|
+
end
|
8
10
|
end
|
9
|
-
end
|
11
|
+
end
|
data/lib/ddr/vocab/duke_terms.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
module Ddr
|
1
|
+
module Ddr
|
2
|
+
module Vocab
|
2
3
|
|
3
|
-
|
4
|
+
class DukeTerms < RDF::StrictVocabulary("http://library.duke.edu/metadata/terms/")
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
RDFVocabularyParser.new(
|
7
|
+
File.join(File.dirname( __FILE__ ), "sources", "duketerms.rdf"),
|
8
|
+
"http://library.duke.edu/metadata/terms/").
|
9
|
+
term_symbols.sort.each do |term|
|
10
|
+
property term, type: "rdf:Property".freeze
|
11
|
+
end
|
11
12
|
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,43 +1,45 @@
|
|
1
1
|
require 'rdf/rdfxml'
|
2
2
|
|
3
|
-
module Ddr
|
4
|
-
|
3
|
+
module Ddr
|
4
|
+
module Vocab
|
5
|
+
class RDFVocabularyParser
|
6
|
+
|
7
|
+
attr_reader :source, :prefix
|
8
|
+
|
9
|
+
def initialize(source, prefix = "")
|
10
|
+
@source = source
|
11
|
+
@prefix = prefix
|
12
|
+
end
|
13
|
+
|
14
|
+
def term_names
|
15
|
+
@term_names ||= terms.collect { |t| t[:resource].to_s.sub(prefix, "") }.freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
def term_symbols
|
19
|
+
term_names.map(&:to_sym)
|
20
|
+
end
|
21
|
+
|
22
|
+
def terms
|
23
|
+
properties.map(&:to_hash)
|
24
|
+
end
|
25
|
+
|
26
|
+
def properties
|
27
|
+
RDF::Query.execute(graph, properties_query)
|
28
|
+
end
|
29
|
+
|
30
|
+
def properties_query
|
31
|
+
{:resource => {
|
32
|
+
RDF.type => RDF.Property,
|
33
|
+
RDF::RDFS.label => :label,
|
34
|
+
RDF::RDFS.comment => :comment
|
35
|
+
}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def graph
|
40
|
+
@graph ||= RDF::Graph.load(source).freeze
|
41
|
+
end
|
5
42
|
|
6
|
-
attr_reader :source, :prefix
|
7
|
-
|
8
|
-
def initialize(source, prefix = "")
|
9
|
-
@source = source
|
10
|
-
@prefix = prefix
|
11
|
-
end
|
12
|
-
|
13
|
-
def term_names
|
14
|
-
@term_names ||= terms.collect { |t| t[:resource].to_s.sub(prefix, "") }.freeze
|
15
|
-
end
|
16
|
-
|
17
|
-
def term_symbols
|
18
|
-
term_names.map(&:to_sym)
|
19
|
-
end
|
20
|
-
|
21
|
-
def terms
|
22
|
-
properties.map(&:to_hash)
|
23
43
|
end
|
24
|
-
|
25
|
-
def properties
|
26
|
-
RDF::Query.execute(graph, properties_query)
|
27
|
-
end
|
28
|
-
|
29
|
-
def properties_query
|
30
|
-
{:resource => {
|
31
|
-
RDF.type => RDF.Property,
|
32
|
-
RDF::RDFS.label => :label,
|
33
|
-
RDF::RDFS.comment => :comment
|
34
|
-
}
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
def graph
|
39
|
-
@graph ||= RDF::Graph.load(source).freeze
|
40
|
-
end
|
41
|
-
|
42
44
|
end
|
43
45
|
end
|
data/lib/ddr/vocab/roles.rb
CHANGED
@@ -1,25 +1,27 @@
|
|
1
|
-
module Ddr
|
2
|
-
|
1
|
+
module Ddr
|
2
|
+
module Vocab
|
3
|
+
class Roles < RDF::StrictVocabulary("http://repository.lib.duke.edu/vocab/roles/")
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
term :Role,
|
6
|
+
label: "Role",
|
7
|
+
comment: "An assertion of a role granted to an agent."
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
property :hasRole,
|
10
|
+
label: "Has Role",
|
11
|
+
comment: "Asserts the granting of a role on the subject to an agent."
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
property :type,
|
14
|
+
label: "Type",
|
15
|
+
comment: "The type of role granted to the agent."
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
property :agent,
|
18
|
+
label: "Agent",
|
19
|
+
comment: "The agent to whom the role is granted."
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
property :scope,
|
22
|
+
label: "Scope",
|
23
|
+
comment: "The scope within which the role applies."
|
23
24
|
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
@@ -843,28 +843,14 @@
|
|
843
843
|
<rdfs:subPropertyOf rdf:resource="http://purl.org/dc/terms/IsPartOf"/>
|
844
844
|
</rdf:Description>
|
845
845
|
|
846
|
-
<rdf:Description rdf:about="http://library.duke.edu/metadata/terms/biblical_book">
|
847
|
-
<rdfs:label xml:lang="en-US">Biblical Book</rdfs:label>
|
848
|
-
<rdfs:comment xml:lang="en-US"></rdfs:comment>
|
849
|
-
<dcterms:description xml:lang="en-US">Recommended best practice is to </dcterms:description>
|
850
|
-
<rdfs:isDefinedBy rdf:resource="http://purl.org/dc/terms/"/>
|
851
|
-
<dcterms:issued>2018-06-01</dcterms:issued>
|
852
|
-
<dcterms:modified>2018-06-01</dcterms:modified>
|
853
|
-
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
|
854
|
-
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
855
|
-
<rdfs:subPropertyOf rdf:resource="http://purl.org/dc/terms/subject"/>
|
856
|
-
</rdf:Description>
|
857
846
|
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
<rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
|
867
|
-
<rdfs:subPropertyOf rdf:resource="http://purl.org/dc/terms/subject"/>
|
868
|
-
</rdf:Description>
|
847
|
+
|
848
|
+
|
849
|
+
|
850
|
+
|
851
|
+
|
852
|
+
|
853
|
+
|
854
|
+
|
869
855
|
|
870
856
|
</rdf:RDF>
|
data/lib/ddr/vocab/vocabulary.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
|
1
|
+
module Ddr
|
2
|
+
module Vocab
|
3
|
+
class Vocabulary
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
+
def self.label(rdf_vocabulary)
|
6
|
+
case rdf_vocabulary.to_uri
|
7
|
+
when RDF::DC.to_uri
|
8
|
+
"DC Terms"
|
9
|
+
when DukeTerms.to_uri
|
10
|
+
"Duke Terms"
|
11
|
+
end
|
12
|
+
end
|
5
13
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
14
|
+
def self.namespace_prefix(rdf_vocabulary)
|
15
|
+
case rdf_vocabulary.to_uri
|
16
|
+
when RDF::DC.to_uri
|
17
|
+
"dcterms"
|
18
|
+
when DukeTerms.to_uri
|
19
|
+
"duke"
|
20
|
+
end
|
12
21
|
end
|
13
|
-
end
|
14
22
|
|
15
|
-
|
16
|
-
|
17
|
-
when RDF::Vocab::DC.to_uri
|
18
|
-
"dcterms"
|
19
|
-
when DukeTerms.to_uri
|
20
|
-
"duke"
|
23
|
+
def self.property_terms(rdf_vocabulary)
|
24
|
+
rdf_vocabulary.properties.select { |p| p.type.include?("http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") }
|
21
25
|
end
|
22
|
-
end
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
def self.term_names(rdf_vocabulary)
|
28
|
+
self.property_terms(rdf_vocabulary).map { |term| self.term_name(rdf_vocabulary, term) }
|
29
|
+
end
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
+
def self.term_name(rdf_vocabulary, term)
|
32
|
+
term.to_s.gsub(rdf_vocabulary.to_uri.to_s, "").to_sym
|
33
|
+
end
|
31
34
|
|
32
|
-
def self.term_name(rdf_vocabulary, term)
|
33
|
-
term.to_s.gsub(rdf_vocabulary.to_uri.to_s, "").to_sym
|
34
35
|
end
|
35
|
-
|
36
36
|
end
|
37
37
|
end
|
@@ -1,24 +1,7 @@
|
|
1
1
|
module Ddr::Auth
|
2
2
|
RSpec.describe AbilityFactory do
|
3
3
|
|
4
|
-
|
5
|
-
subject { described_class.call(user, env) }
|
6
|
-
|
7
|
-
describe "anonymous context" do
|
8
|
-
let(:user) { nil }
|
9
|
-
let(:env) { Hash.new }
|
10
|
-
it { is_expected.to be_a(AnonymousAbility) }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "superuser context" do
|
14
|
-
let(:user) { FactoryGirl.create(:user) }
|
15
|
-
let(:env) { Hash.new }
|
16
|
-
before {
|
17
|
-
allow_any_instance_of(AuthContext).to receive(:superuser?) { true }
|
18
|
-
}
|
19
|
-
it { is_expected.to be_a(SuperuserAbility) }
|
20
|
-
end
|
21
|
-
end
|
4
|
+
# write tests or delete this module
|
22
5
|
|
23
6
|
end
|
24
7
|
end
|
data/spec/auth/ability_spec.rb
CHANGED
@@ -2,7 +2,7 @@ module Ddr::Auth
|
|
2
2
|
RSpec.describe Ability, type: :model, abilities: true do
|
3
3
|
|
4
4
|
subject { described_class.new(auth_context) }
|
5
|
-
|
5
|
+
|
6
6
|
let(:auth_context) { FactoryGirl.build(:auth_context) }
|
7
7
|
|
8
8
|
describe "aliases" do
|
@@ -15,7 +15,7 @@ module Ddr::Auth
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "Datastream abilities" do
|
18
|
-
let(:obj) { FactoryGirl.
|
18
|
+
let(:obj) { FactoryGirl.create(:component) }
|
19
19
|
|
20
20
|
DatastreamAbilityDefinitions::DATASTREAM_DOWNLOAD_ABILITIES.each do |dsid, permission|
|
21
21
|
describe "\"#{dsid}\"" do
|
@@ -32,7 +32,7 @@ module Ddr::Auth
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "non-downloadable datastreams" do
|
35
|
-
(Component.ds_specs.keys - DatastreamAbilityDefinitions::DATASTREAM_DOWNLOAD_ABILITIES.keys).each do |dsid|
|
35
|
+
(Component.ds_specs.keys.map(&:to_s) - DatastreamAbilityDefinitions::DATASTREAM_DOWNLOAD_ABILITIES.keys).each do |dsid|
|
36
36
|
describe "\"#{dsid}\"" do
|
37
37
|
let(:ds) { obj.datastreams[dsid] }
|
38
38
|
before { subject.can :download, obj.pid }
|
@@ -56,58 +56,22 @@ module Ddr::Auth
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe "AdminSet abilities" do
|
60
|
-
describe "export" do
|
61
|
-
describe "when the user is a metadata manager" do
|
62
|
-
before {
|
63
|
-
allow(auth_context).to receive(:metadata_manager?) { true }
|
64
|
-
}
|
65
|
-
it { is_expected.to be_able_to(:export, Ddr::Models::AdminSet) }
|
66
|
-
end
|
67
|
-
describe "when the user is a metadata manager" do
|
68
|
-
before {
|
69
|
-
allow(auth_context).to receive(:metadata_manager?) { false }
|
70
|
-
}
|
71
|
-
it { is_expected.not_to be_able_to(:export, Ddr::Models::AdminSet) }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
59
|
describe "Collection abilities" do
|
77
|
-
|
60
|
+
before do
|
61
|
+
allow(Ddr::Auth).to receive(:collection_creators_group) { "collection_creators" }
|
62
|
+
end
|
63
|
+
describe "when the user is a collection creator" do
|
78
64
|
before do
|
79
|
-
allow(
|
80
|
-
end
|
81
|
-
describe "when the user is a collection creator" do
|
82
|
-
before do
|
83
|
-
allow(auth_context).to receive(:member_of?) { false }
|
84
|
-
allow(auth_context).to receive(:member_of?).with("collection_creators") { true }
|
85
|
-
end
|
86
|
-
it { should be_able_to(:create, Collection) }
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "when the user is not a collection creator" do
|
90
|
-
before do
|
91
|
-
allow(auth_context).to receive(:member_of?) { false }
|
92
|
-
allow(auth_context).to receive(:member_of?).with("collection_creators") { false }
|
93
|
-
end
|
94
|
-
it { should_not be_able_to(:create, Collection) }
|
65
|
+
allow(auth_context).to receive(:member_of?).with("collection_creators") { true }
|
95
66
|
end
|
67
|
+
it { should be_able_to(:create, Collection) }
|
96
68
|
end
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
collection.roles.grant role_type: "Viewer", agent: auth_context.user.to_s, scope: "policy"
|
102
|
-
}
|
103
|
-
it { is_expected.to be_able_to(:export, collection) }
|
104
|
-
end
|
105
|
-
describe "when the user does not have read permission via policy scope role" do
|
106
|
-
before {
|
107
|
-
collection.roles.grant role_type: "Viewer", agent: auth_context.user.to_s
|
108
|
-
}
|
109
|
-
it { is_expected.not_to be_able_to(:export, collection) }
|
69
|
+
|
70
|
+
describe "when the user is not a collection creator" do
|
71
|
+
before do
|
72
|
+
allow(auth_context).to receive(:member_of?).with("collection_creators") { false }
|
110
73
|
end
|
74
|
+
it { should_not be_able_to(:create, Collection) }
|
111
75
|
end
|
112
76
|
end
|
113
77
|
|
@@ -180,74 +144,6 @@ module Ddr::Auth
|
|
180
144
|
end
|
181
145
|
end
|
182
146
|
|
183
|
-
describe "publication abilities" do
|
184
|
-
let(:obj) { Ddr::Models::Base.new }
|
185
|
-
|
186
|
-
describe "publish" do
|
187
|
-
describe "when role-based permissions permit publish" do
|
188
|
-
before do
|
189
|
-
allow(obj).to receive(:effective_permissions) { [ Permissions::PUBLISH ] }
|
190
|
-
end
|
191
|
-
describe "when the object is published" do
|
192
|
-
before { allow(obj).to receive(:published?) { true } }
|
193
|
-
it { should_not be_able_to(:publish, obj) }
|
194
|
-
end
|
195
|
-
describe "when the object is not published" do
|
196
|
-
describe "when the object is publishable" do
|
197
|
-
before { allow(obj).to receive(:publishable?) { true } }
|
198
|
-
it { should be_able_to(:publish, obj) }
|
199
|
-
end
|
200
|
-
describe "when the object is not publishable" do
|
201
|
-
before { allow(obj).to receive(:publishable?) { false } }
|
202
|
-
it { should_not be_able_to(:publish, obj) }
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
describe "when role-based permissions do not permit publish" do
|
207
|
-
before { allow(obj).to receive(:publishable?) { true } }
|
208
|
-
it { should_not be_able_to(:publish, obj) }
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "unpublish" do
|
213
|
-
describe "when role-based permissions permit unpublish" do
|
214
|
-
before do
|
215
|
-
allow(obj).to receive(:effective_permissions) { [ Permissions::UNPUBLISH ] }
|
216
|
-
end
|
217
|
-
describe "when the object is published" do
|
218
|
-
before { allow(obj).to receive(:published?) { true } }
|
219
|
-
it { should be_able_to(:unpublish, obj) }
|
220
|
-
end
|
221
|
-
describe "when the object is not published" do
|
222
|
-
it { should_not be_able_to(:unpublish, obj) }
|
223
|
-
end
|
224
|
-
end
|
225
|
-
describe "when role-based permissions do not permit unpublish" do
|
226
|
-
it { should_not be_able_to(:unpublish, obj) }
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
231
|
-
|
232
|
-
describe "locks" do
|
233
|
-
let(:obj) { Ddr::Models::Base.new }
|
234
|
-
|
235
|
-
describe "effects of locks on abilities" do
|
236
|
-
before do
|
237
|
-
allow(obj).to receive(:effective_permissions) { Permissions::ALL }
|
238
|
-
allow(obj).to receive(:locked?) { true }
|
239
|
-
end
|
240
|
-
it { should be_able_to(:read, obj) }
|
241
|
-
it { should be_able_to(:download, obj) }
|
242
|
-
it { should_not be_able_to(:add_children, obj) }
|
243
|
-
it { should_not be_able_to(:update, obj) }
|
244
|
-
it { should_not be_able_to(:replace, obj) }
|
245
|
-
it { should_not be_able_to(:arrange, obj) }
|
246
|
-
it { should be_able_to(:audit, obj) }
|
247
|
-
it { should_not be_able_to(:grant, obj) }
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
147
|
describe "role based abilities" do
|
252
148
|
shared_examples "it has role based abilities" do
|
253
149
|
describe "when permissions are cached" do
|
@@ -297,7 +193,7 @@ module Ddr::Auth
|
|
297
193
|
let(:cache_key) { obj }
|
298
194
|
let(:perm_obj) { SolrDocument.new({"id"=>"test:1"}) }
|
299
195
|
before do
|
300
|
-
|
196
|
+
allow_any_instance_of(RoleBasedAbilityDefinitions).to receive(:permissions_doc).with(obj) { perm_obj }
|
301
197
|
end
|
302
198
|
it_behaves_like "it has role based abilities"
|
303
199
|
end
|