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.
Files changed (268) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +7 -6
  4. data/Gemfile +2 -3
  5. data/Rakefile +5 -5
  6. data/app/controllers/users/sessions_controller.rb +5 -0
  7. data/app/helpers/models_helper.rb +7 -0
  8. data/app/models/attachment.rb +3 -5
  9. data/app/models/collection.rb +12 -79
  10. data/app/models/component.rb +8 -67
  11. data/app/models/item.rb +8 -73
  12. data/app/models/target.rb +6 -5
  13. data/config/initializers/active_fedora_base.rb +11 -30
  14. data/config/initializers/{active_fedora_datastream.rb → active_fedora_file.rb} +1 -1
  15. data/config/initializers/devise.rb +2 -3
  16. data/config/initializers/subscriptions.rb +2 -19
  17. data/ddr-models.gemspec +10 -14
  18. data/lib/ddr/actions/fixity_check.rb +1 -1
  19. data/lib/ddr/actions/virus_check.rb +17 -10
  20. data/lib/ddr/auth.rb +6 -38
  21. data/lib/ddr/auth/ability.rb +1 -5
  22. data/lib/ddr/auth/ability_definitions/collection_ability_definitions.rb +0 -16
  23. data/lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb +10 -4
  24. data/lib/ddr/auth/ability_definitions/role_based_ability_definitions.rb +16 -9
  25. data/lib/ddr/auth/ability_factory.rb +25 -2
  26. data/lib/ddr/auth/abstract_ability.rb +1 -2
  27. data/lib/ddr/auth/auth_context.rb +0 -18
  28. data/lib/ddr/auth/auth_context_factory.rb +2 -0
  29. data/lib/ddr/auth/group.rb +0 -6
  30. data/lib/ddr/auth/grouper_gateway.rb +0 -24
  31. data/lib/ddr/auth/permissions.rb +1 -12
  32. data/lib/ddr/auth/role_based_access_controls_enforcement.rb +5 -5
  33. data/lib/ddr/auth/roles.rb +1 -11
  34. data/lib/ddr/auth/roles/role_set.rb +0 -7
  35. data/lib/ddr/auth/roles/roles_datastream.rb +9 -0
  36. data/lib/ddr/contacts.rb +25 -0
  37. data/lib/ddr/datastreams.rb +10 -28
  38. data/lib/ddr/datastreams/datastream_behavior.rb +30 -100
  39. data/lib/ddr/datastreams/descriptive_metadata_datastream.rb +28 -31
  40. data/lib/ddr/datastreams/fits_datastream.rb +9 -22
  41. data/lib/ddr/datastreams/metadata_datastream.rb +17 -31
  42. data/lib/ddr/derivatives.rb +13 -16
  43. data/lib/ddr/derivatives/derivative.rb +68 -0
  44. data/lib/ddr/derivatives/{generator.rb → generators/generator.rb} +11 -7
  45. data/lib/ddr/derivatives/generators/png_generator.rb +23 -0
  46. data/lib/ddr/derivatives/generators/ptif_generator.rb +56 -0
  47. data/lib/ddr/derivatives/multires_image.rb +59 -0
  48. data/lib/ddr/derivatives/thumbnail.rb +36 -0
  49. data/lib/ddr/events.rb +0 -1
  50. data/lib/ddr/events/deletion_event.rb +9 -5
  51. data/lib/ddr/events/event.rb +8 -13
  52. data/lib/ddr/events/fixity_check_event.rb +0 -6
  53. data/lib/ddr/events/ingestion_event.rb +9 -5
  54. data/lib/ddr/events/update_event.rb +4 -17
  55. data/lib/ddr/index.rb +4 -4
  56. data/lib/ddr/index/abstract_query_result.rb +4 -3
  57. data/lib/ddr/index/connection.rb +9 -28
  58. data/lib/ddr/index/csv_query_result.rb +32 -47
  59. data/lib/ddr/index/field.rb +1 -11
  60. data/lib/ddr/index/fields.rb +16 -99
  61. data/lib/ddr/index/filter.rb +30 -103
  62. data/lib/ddr/index/filters.rb +19 -0
  63. data/lib/ddr/index/query.rb +11 -58
  64. data/lib/ddr/index/query_builder.rb +36 -147
  65. data/lib/ddr/index/query_clause.rb +19 -79
  66. data/lib/ddr/index/query_result.rb +4 -36
  67. data/lib/ddr/index/query_value.rb +18 -0
  68. data/lib/ddr/index/response.rb +2 -19
  69. data/lib/ddr/jobs.rb +12 -0
  70. data/lib/ddr/jobs/fits_file_characterization.rb +51 -0
  71. data/lib/ddr/jobs/permanent_id.rb +23 -0
  72. data/lib/ddr/managers.rb +1 -0
  73. data/lib/ddr/managers/derivatives_manager.rb +53 -93
  74. data/lib/ddr/managers/permanent_id_manager.rb +91 -0
  75. data/lib/ddr/managers/technical_metadata_manager.rb +10 -24
  76. data/lib/ddr/managers/workflow_manager.rb +10 -29
  77. data/lib/ddr/models.rb +50 -101
  78. data/lib/ddr/models/access_controllable.rb +12 -0
  79. data/lib/ddr/models/admin_set.rb +5 -16
  80. data/lib/ddr/models/base.rb +45 -165
  81. data/lib/ddr/models/describable.rb +19 -21
  82. data/lib/ddr/models/engine.rb +11 -39
  83. data/lib/ddr/models/error.rb +0 -3
  84. data/lib/ddr/models/file_management.rb +36 -72
  85. data/lib/ddr/models/finding_aid.rb +2 -35
  86. data/lib/ddr/models/fixity_checkable.rb +4 -0
  87. data/lib/ddr/models/governable.rb +3 -1
  88. data/lib/ddr/models/has_admin_metadata.rb +82 -56
  89. data/lib/ddr/models/has_attachments.rb +3 -1
  90. data/lib/ddr/models/has_children.rb +3 -7
  91. data/lib/ddr/models/has_content.rb +35 -32
  92. data/lib/ddr/models/has_multires_image.rb +7 -12
  93. data/lib/ddr/models/has_struct_metadata.rb +44 -6
  94. data/lib/ddr/models/has_thumbnail.rb +1 -4
  95. data/lib/ddr/models/indexing.rb +97 -186
  96. data/lib/ddr/models/licenses/admin_policy_license.rb +11 -0
  97. data/lib/ddr/models/licenses/effective_license.rb +9 -0
  98. data/lib/ddr/models/licenses/inherited_license.rb +9 -0
  99. data/lib/ddr/models/licenses/license.rb +21 -0
  100. data/lib/ddr/models/licenses/parent_license.rb +11 -0
  101. data/lib/ddr/models/metadata/descriptive_metadata.rb +50 -0
  102. data/lib/ddr/models/metadata/metadata.rb +37 -0
  103. data/lib/ddr/models/metadata/metadata_mapper.rb +32 -0
  104. data/lib/ddr/models/metadata/metadata_mappers.rb +18 -0
  105. data/lib/ddr/models/metadata/metadata_term.rb +24 -0
  106. data/lib/ddr/models/metadata/metadata_vocabularies.rb +18 -0
  107. data/lib/ddr/models/metadata/metadata_vocabulary.rb +34 -0
  108. data/lib/ddr/models/solr_document.rb +24 -156
  109. data/lib/ddr/models/struct_div.rb +63 -0
  110. data/lib/ddr/models/structure.rb +39 -175
  111. data/lib/ddr/models/version.rb +1 -1
  112. data/lib/ddr/models/year_facet.rb +118 -60
  113. data/lib/ddr/notifications.rb +12 -10
  114. data/lib/ddr/utils.rb +15 -28
  115. data/lib/ddr/vocab.rb +17 -15
  116. data/lib/ddr/vocab/asset.rb +17 -42
  117. data/lib/ddr/vocab/contact.rb +7 -5
  118. data/lib/ddr/vocab/display.rb +8 -6
  119. data/lib/ddr/vocab/duke_terms.rb +10 -8
  120. data/lib/ddr/vocab/rdf_vocabulary_parser.rb +39 -37
  121. data/lib/ddr/vocab/roles.rb +19 -17
  122. data/lib/ddr/vocab/sources/duketerms.rdf +8 -22
  123. data/lib/ddr/vocab/vocabulary.rb +26 -26
  124. data/spec/auth/ability_factory_spec.rb +1 -18
  125. data/spec/auth/ability_spec.rb +15 -119
  126. data/spec/auth/effective_permissions_spec.rb +1 -1
  127. data/spec/auth/effective_roles_spec.rb +1 -1
  128. data/spec/auth/ldap_gateway_spec.rb +9 -0
  129. data/spec/contacts/contacts_spec.rb +26 -0
  130. data/spec/controllers/including_role_based_access_controls_enforcement_spec.rb +5 -5
  131. data/spec/derivatives/multires_image_spec.rb +48 -0
  132. data/spec/derivatives/png_generator_spec.rb +8 -13
  133. data/spec/derivatives/ptif_generator_spec.rb +11 -9
  134. data/spec/derivatives/thumbnail_spec.rb +48 -0
  135. data/spec/dummy/config/environments/test.rb +1 -1
  136. data/spec/dummy/db/schema.rb +23 -25
  137. data/spec/factories/attachment_factories.rb +2 -2
  138. data/spec/factories/collection_factories.rb +2 -3
  139. data/spec/factories/component_factories.rb +2 -2
  140. data/spec/factories/item_factories.rb +2 -2
  141. data/spec/factories/structure_factories.rb +2 -8
  142. data/spec/factories/test_model_factories.rb +12 -4
  143. data/spec/fixtures/fits/document.xml +44 -42
  144. data/spec/fixtures/fits/image.xml +41 -42
  145. data/spec/helpers/models_helper_spec.rb +11 -0
  146. data/spec/index/filter_spec.rb +30 -208
  147. data/spec/index/filters_spec.rb +17 -0
  148. data/spec/index/query_spec.rb +10 -82
  149. data/spec/jobs/fits_file_characterization_spec.rb +52 -0
  150. data/spec/managers/derivatives_manager_spec.rb +105 -107
  151. data/spec/managers/technical_metadata_manager_spec.rb +27 -34
  152. data/spec/models/active_fedora_base_spec.rb +105 -5
  153. data/spec/models/active_fedora_datastream_spec.rb +39 -106
  154. data/spec/models/admin_set_spec.rb +10 -43
  155. data/spec/models/attachment_spec.rb +2 -3
  156. data/spec/models/collection_spec.rb +11 -225
  157. data/spec/models/component_spec.rb +4 -106
  158. data/spec/models/descriptive_metadata_spec.rb +38 -0
  159. data/spec/models/effective_license_spec.rb +64 -0
  160. data/spec/models/events_spec.rb +59 -52
  161. data/spec/models/file_management_spec.rb +13 -113
  162. data/spec/models/finding_aid_spec.rb +8 -31
  163. data/spec/models/has_admin_metadata_spec.rb +122 -131
  164. data/spec/models/has_children_spec.rb +3 -3
  165. data/spec/models/has_struct_metadata_spec.rb +37 -50
  166. data/spec/models/indexing_spec.rb +23 -160
  167. data/spec/models/item_spec.rb +2 -133
  168. data/spec/models/license_spec.rb +24 -0
  169. data/spec/models/solr_document_spec.rb +47 -236
  170. data/spec/models/struct_div_spec.rb +70 -0
  171. data/spec/models/structure_spec.rb +11 -89
  172. data/spec/models/target_spec.rb +2 -4
  173. data/spec/models/year_facet_spec.rb +23 -50
  174. data/spec/spec_helper.rb +13 -17
  175. data/spec/support/ezid_mock_identifier.rb +2 -2
  176. data/spec/support/shared_examples_for_auth_contexts.rb +0 -33
  177. data/spec/support/shared_examples_for_ddr_models.rb +94 -142
  178. data/spec/support/shared_examples_for_describables.rb +36 -31
  179. data/spec/support/shared_examples_for_governables.rb +2 -3
  180. data/spec/support/shared_examples_for_has_content.rb +46 -101
  181. data/spec/support/shared_examples_for_indexing.rb +6 -6
  182. data/spec/support/shared_examples_for_non_collection_models.rb +1 -32
  183. data/spec/support/structural_metadata_helper.rb +59 -230
  184. data/spec/utils_spec.rb +2 -0
  185. metadata +96 -229
  186. data/.ruby-version +0 -1
  187. data/config/initializers/rsolr_monkey_patches.rb +0 -7
  188. data/config/initializers/rubydora_monkey_patch.rb +0 -11
  189. data/config/locales/ddr-models.en.yml +0 -81
  190. data/db/migrate/20161021201011_add_permanent_id_to_events.rb +0 -8
  191. data/lib/ddr/auth/ability_definitions/admin_set_ability_definitions.rb +0 -9
  192. data/lib/ddr/auth/ability_definitions/lock_ability_definitions.rb +0 -13
  193. data/lib/ddr/auth/ability_definitions/publication_ability_definitions.rb +0 -16
  194. data/lib/ddr/datastreams/administrative_metadata_datastream.rb +0 -75
  195. data/lib/ddr/datastreams/caption_datastream.rb +0 -5
  196. data/lib/ddr/datastreams/content_datastream.rb +0 -17
  197. data/lib/ddr/datastreams/delete_external_files.rb +0 -29
  198. data/lib/ddr/datastreams/external_file_datastream.rb +0 -80
  199. data/lib/ddr/datastreams/intermediate_file_datastream.rb +0 -5
  200. data/lib/ddr/datastreams/multires_image_datastream.rb +0 -5
  201. data/lib/ddr/datastreams/streamable_media_datastream.rb +0 -5
  202. data/lib/ddr/derivatives/png_generator.rb +0 -17
  203. data/lib/ddr/derivatives/ptif_generator.rb +0 -55
  204. data/lib/ddr/derivatives/update_derivatives.rb +0 -25
  205. data/lib/ddr/events/deaccession_event.rb +0 -8
  206. data/lib/ddr/index/field_attribute.rb +0 -22
  207. data/lib/ddr/index/query_params.rb +0 -40
  208. data/lib/ddr/index/sort_order.rb +0 -28
  209. data/lib/ddr/models/cache.rb +0 -20
  210. data/lib/ddr/models/captionable.rb +0 -37
  211. data/lib/ddr/models/contact.rb +0 -23
  212. data/lib/ddr/models/file_characterization.rb +0 -37
  213. data/lib/ddr/models/has_intermediate_file.rb +0 -41
  214. data/lib/ddr/models/language.rb +0 -31
  215. data/lib/ddr/models/media_type.rb +0 -22
  216. data/lib/ddr/models/permanent_id.rb +0 -240
  217. data/lib/ddr/models/rights_statement.rb +0 -25
  218. data/lib/ddr/models/streamable.rb +0 -37
  219. data/lib/ddr/models/structures/agent.rb +0 -49
  220. data/lib/ddr/models/structures/component_type_term.rb +0 -29
  221. data/lib/ddr/models/structures/div.rb +0 -64
  222. data/lib/ddr/models/structures/f_locat.rb +0 -54
  223. data/lib/ddr/models/structures/file.rb +0 -52
  224. data/lib/ddr/models/structures/file_grp.rb +0 -35
  225. data/lib/ddr/models/structures/file_sec.rb +0 -22
  226. data/lib/ddr/models/structures/fptr.rb +0 -31
  227. data/lib/ddr/models/structures/mets_hdr.rb +0 -37
  228. data/lib/ddr/models/structures/mptr.rb +0 -49
  229. data/lib/ddr/models/structures/struct_map.rb +0 -40
  230. data/lib/ddr/models/with_content_file.rb +0 -37
  231. data/spec/datastreams/external_file_datastream_spec.rb +0 -48
  232. data/spec/dummy/config/structure_component_type.yml +0 -18
  233. data/spec/fixtures/abcd1234.vtt +0 -38
  234. data/spec/fixtures/arrow1rightred_e0.gif +0 -0
  235. data/spec/fixtures/extractedText1.txt +0 -1
  236. data/spec/fixtures/extractedText2.txt +0 -1
  237. data/spec/fixtures/extractedText3.txt +0 -3
  238. data/spec/fixtures/imageA.jpg +0 -0
  239. data/spec/fixtures/imageB.jpg +0 -0
  240. data/spec/index/csv_query_result_spec.rb +0 -44
  241. data/spec/index/fields_spec.rb +0 -380
  242. data/spec/index/query_builder_spec.rb +0 -140
  243. data/spec/index/query_clause_spec.rb +0 -68
  244. data/spec/models/cache_spec.rb +0 -32
  245. data/spec/models/contact_spec.rb +0 -56
  246. data/spec/models/descriptive_metadata_datastream_spec.rb +0 -139
  247. data/spec/models/file_characterization_spec.rb +0 -39
  248. data/spec/models/language_spec.rb +0 -59
  249. data/spec/models/media_type_spec.rb +0 -46
  250. data/spec/models/permanent_id_spec.rb +0 -432
  251. data/spec/models/rights_statement_spec.rb +0 -55
  252. data/spec/models/structures/agent_spec.rb +0 -30
  253. data/spec/models/structures/component_type_term_spec.rb +0 -14
  254. data/spec/models/structures/div_spec.rb +0 -26
  255. data/spec/models/structures/f_locat_spec.rb +0 -78
  256. data/spec/models/structures/file_grp_spec.rb +0 -23
  257. data/spec/models/structures/file_sec_spec.rb +0 -22
  258. data/spec/models/structures/file_spec.rb +0 -60
  259. data/spec/models/structures/fptr_spec.rb +0 -23
  260. data/spec/models/structures/mets_hdr_spec.rb +0 -26
  261. data/spec/models/structures/mptr_spec.rb +0 -25
  262. data/spec/models/structures/struct_map_spec.rb +0 -24
  263. data/spec/models/with_content_file_spec.rb +0 -37
  264. data/spec/support/shared_examples_for_associations.rb +0 -8
  265. data/spec/support/shared_examples_for_captionable.rb +0 -23
  266. data/spec/support/shared_examples_for_has_intermediate_file.rb +0 -28
  267. data/spec/support/shared_examples_for_publication.rb +0 -43
  268. data/spec/support/shared_examples_for_streamable_media.rb +0 -23
@@ -1,9 +1,11 @@
1
- module Ddr::Vocab
2
- class Contact < RDF::StrictVocabulary("#{BASE_URI}/contact/")
1
+ module Ddr
2
+ module Vocab
3
+ class Contact < RDF::StrictVocabulary("http://repository.lib.duke.edu/vocab/contact/")
3
4
 
4
- property "assistance",
5
- label: "Research Assistance",
6
- comment: "Contact for research assistance with this object."
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
@@ -1,9 +1,11 @@
1
- module Ddr::Vocab
2
- class Display < RDF::StrictVocabulary("#{BASE_URI}/display/")
1
+ module Ddr
2
+ module Vocab
3
+ class Display < RDF::StrictVocabulary("http://repository.lib.duke.edu/vocab/display/")
3
4
 
4
- property "format",
5
- label: "Display Format",
6
- comment: "Format to use when displaying the object."
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
@@ -1,13 +1,15 @@
1
- module Ddr::Vocab
1
+ module Ddr
2
+ module Vocab
2
3
 
3
- class DukeTerms < RDF::StrictVocabulary("http://library.duke.edu/metadata/terms/")
4
+ class DukeTerms < RDF::StrictVocabulary("http://library.duke.edu/metadata/terms/")
4
5
 
5
- RDFVocabularyParser.new(
6
- File.join(File.dirname( __FILE__ ), "sources", "duketerms.rdf"),
7
- "http://library.duke.edu/metadata/terms/").
8
- term_symbols.sort.each do |term|
9
- property term, type: "rdf:Property".freeze
10
- end
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::Vocab
4
- class RDFVocabularyParser
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
@@ -1,25 +1,27 @@
1
- module Ddr::Vocab
2
- class Roles < RDF::StrictVocabulary("#{BASE_URI}/roles/")
1
+ module Ddr
2
+ module Vocab
3
+ class Roles < RDF::StrictVocabulary("http://repository.lib.duke.edu/vocab/roles/")
3
4
 
4
- term :Role,
5
- label: "Role",
6
- comment: "An assertion of a role granted to an agent."
5
+ term :Role,
6
+ label: "Role",
7
+ comment: "An assertion of a role granted to an agent."
7
8
 
8
- property :hasRole,
9
- label: "Has Role",
10
- comment: "Asserts the granting of a role on the subject to an agent."
9
+ property :hasRole,
10
+ label: "Has Role",
11
+ comment: "Asserts the granting of a role on the subject to an agent."
11
12
 
12
- property :type,
13
- label: "Type",
14
- comment: "The type of role granted to the agent."
13
+ property :type,
14
+ label: "Type",
15
+ comment: "The type of role granted to the agent."
15
16
 
16
- property :agent,
17
- label: "Agent",
18
- comment: "The agent to whom the role is granted."
17
+ property :agent,
18
+ label: "Agent",
19
+ comment: "The agent to whom the role is granted."
19
20
 
20
- property :scope,
21
- label: "Scope",
22
- comment: "The scope within which the role applies."
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
- <rdf:Description rdf:about="http://library.duke.edu/metadata/terms/chapter_and_verse">
859
- <rdfs:label xml:lang="en-US">Chapter and Verse</rdfs:label>
860
- <rdfs:comment xml:lang="en-US"></rdfs:comment>
861
- <dcterms:description xml:lang="en-US">Recommended best practice is to </dcterms:description>
862
- <rdfs:isDefinedBy rdf:resource="http://purl.org/dc/terms/"/>
863
- <dcterms:issued>2018-06-01</dcterms:issued>
864
- <dcterms:modified>2018-06-01</dcterms:modified>
865
- <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
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>
@@ -1,37 +1,37 @@
1
- require 'rdf/vocab'
1
+ module Ddr
2
+ module Vocab
3
+ class Vocabulary
2
4
 
3
- module Ddr::Vocab
4
- class Vocabulary
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
- def self.label(rdf_vocabulary)
7
- case rdf_vocabulary.to_uri
8
- when RDF::Vocab::DC.to_uri
9
- "DC Terms"
10
- when DukeTerms.to_uri
11
- "Duke Terms"
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
- def self.namespace_prefix(rdf_vocabulary)
16
- case rdf_vocabulary.to_uri
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
- def self.property_terms(rdf_vocabulary)
25
- rdf_vocabulary.properties.select { |p| p.type.include?("http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") }
26
- end
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
- def self.term_names(rdf_vocabulary)
29
- self.property_terms(rdf_vocabulary).map { |term| self.term_name(rdf_vocabulary, term) }
30
- end
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
- describe ".call" do
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
@@ -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.build(:component) }
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
- describe "create" do
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(Ddr::Auth).to receive(:collection_creators_group) { "collection_creators" }
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
- describe "export" do
98
- let(:collection) { FactoryGirl.build(:collection) }
99
- describe "when the user has read permission via policy scope role" do
100
- before {
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
- allow(SolrDocument).to receive(:find).with("test:1") { perm_obj }
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