curation_concerns 1.0.0.beta1 → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/app/actors/curation_concerns/actors/abstract_actor.rb +30 -0
  3. data/app/actors/curation_concerns/actors/actor_stack.rb +29 -0
  4. data/app/actors/curation_concerns/actors/add_to_collection_actor.rb +40 -0
  5. data/app/actors/curation_concerns/actors/apply_order_actor.rb +26 -0
  6. data/app/actors/curation_concerns/actors/assign_identifier_actor.rb +9 -0
  7. data/app/actors/curation_concerns/actors/assign_representative_actor.rb +20 -0
  8. data/app/actors/curation_concerns/actors/attach_files_actor.rb +41 -0
  9. data/app/actors/curation_concerns/actors/base_actor.rb +78 -0
  10. data/app/actors/curation_concerns/actors/embargo_actor.rb +21 -0
  11. data/app/actors/curation_concerns/actors/file_actor.rb +81 -0
  12. data/app/actors/curation_concerns/actors/file_set_actor.rb +159 -0
  13. data/app/actors/curation_concerns/actors/interpret_visibility_actor.rb +125 -0
  14. data/app/actors/curation_concerns/actors/lease_actor.rb +21 -0
  15. data/app/actors/curation_concerns/actors/root_actor.rb +19 -0
  16. data/app/actors/curation_concerns/actors/work_actor_behavior.rb +12 -0
  17. data/app/actors/curation_concerns/actors.rb +18 -0
  18. data/app/controllers/concerns/curation_concerns/embargoes_controller_behavior.rb +2 -2
  19. data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +21 -15
  20. data/app/controllers/concerns/curation_concerns/leases_controller_behavior.rb +2 -2
  21. data/app/forms/curation_concerns/forms/collection_edit_form.rb +1 -1
  22. data/app/forms/curation_concerns/forms/file_set_edit_form.rb +2 -2
  23. data/app/forms/curation_concerns/forms/work_form.rb +1 -1
  24. data/app/forms/curation_concerns/forms.rb +14 -0
  25. data/app/helpers/curation_concerns/collections_helper.rb +10 -8
  26. data/app/jobs/audit_job.rb +0 -2
  27. data/app/jobs/characterize_job.rb +1 -1
  28. data/app/jobs/create_derivatives_job.rb +1 -1
  29. data/app/jobs/import_url_job.rb +2 -2
  30. data/app/jobs/ingest_file_job.rb +1 -1
  31. data/app/jobs/ingest_local_file_job.rb +2 -2
  32. data/app/jobs/resolrize_job.rb +0 -2
  33. data/app/jobs/visibility_copy_job.rb +0 -2
  34. data/app/models/concerns/curation_concerns/basic_metadata.rb +1 -1
  35. data/app/models/concerns/curation_concerns/characterization.rb +41 -0
  36. data/app/models/concerns/curation_concerns/collection.rb +0 -1
  37. data/app/models/concerns/curation_concerns/file_set_behavior.rb +1 -1
  38. data/app/models/concerns/curation_concerns/solr_document_behavior.rb +6 -5
  39. data/app/presenters/curation_concerns/collection_presenter.rb +1 -1
  40. data/app/presenters/curation_concerns/file_set_presenter.rb +1 -1
  41. data/app/presenters/curation_concerns/presents_attributes.rb +1 -1
  42. data/app/renderers/curation_concerns/renderers/attribute_renderer.rb +100 -0
  43. data/app/renderers/curation_concerns/renderers/configured_microdata.rb +42 -0
  44. data/app/renderers/renderers.rb +11 -0
  45. data/app/services/curation_concerns/actors/actor_factory.rb +26 -0
  46. data/app/services/curation_concerns/curation_concern.rb +1 -1
  47. data/app/services/curation_concerns/thumbnail_path_service.rb +1 -1
  48. data/app/views/collections/show.html.erb +7 -3
  49. data/app/views/curation_concerns/base/_representative_media.html.erb +1 -1
  50. data/app/views/curation_concerns/file_sets/show.html.erb +1 -1
  51. data/config/locales/curation_concerns.en.yml +4 -4
  52. data/curation_concerns.gemspec +1 -4
  53. data/lib/curation_concerns/configuration.rb +7 -0
  54. data/lib/curation_concerns/version.rb +1 -1
  55. data/lib/generators/curation_concerns/templates/catalog_controller.rb +4 -4
  56. data/lib/generators/curation_concerns/work/templates/actor.rb.erb +2 -2
  57. data/lib/generators/curation_concerns/work/templates/actor_spec.rb.erb +1 -1
  58. data/lib/generators/curation_concerns/work/work_generator.rb +2 -2
  59. data/spec/actors/curation_concerns/add_to_collections_actor_spec.rb +6 -6
  60. data/spec/actors/curation_concerns/embargo_actor_spec.rb +1 -1
  61. data/spec/actors/curation_concerns/file_actor_spec.rb +1 -1
  62. data/spec/actors/curation_concerns/file_set_actor_spec.rb +11 -10
  63. data/spec/actors/curation_concerns/interpret_visibility_actor_spec.rb +6 -6
  64. data/spec/actors/curation_concerns/lease_actor_spec.rb +1 -1
  65. data/spec/actors/curation_concerns/work_actor_spec.rb +1 -1
  66. data/spec/controllers/curation_concerns/collections_controller_spec.rb +3 -3
  67. data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +4 -4
  68. data/spec/controllers/embargoes_controller_spec.rb +1 -1
  69. data/spec/controllers/leases_controller_spec.rb +1 -1
  70. data/spec/factories/generic_works.rb +1 -1
  71. data/spec/features/add_file_spec.rb +1 -1
  72. data/spec/features/work_generator_spec.rb +1 -1
  73. data/spec/forms/collection_edit_form_spec.rb +2 -2
  74. data/spec/forms/file_set_edit_form_spec.rb +1 -1
  75. data/spec/forms/work_form_spec.rb +2 -2
  76. data/spec/indexers/file_set_indexer_spec.rb +12 -9
  77. data/spec/jobs/import_url_job_spec.rb +2 -2
  78. data/spec/jobs/ingest_local_file_job_spec.rb +1 -1
  79. data/spec/models/curation_concerns/collection_behavior_spec.rb +12 -3
  80. data/spec/models/file_set_spec.rb +25 -19
  81. data/spec/presenters/curation_concerns/collection_presenter_spec.rb +1 -1
  82. data/spec/presenters/curation_concerns/file_set_presenter_spec.rb +1 -1
  83. data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +2 -2
  84. data/spec/renderers/curation_concerns/{attribute_renderer_spec.rb → renderers/attribute_renderer_spec.rb} +2 -2
  85. data/spec/services/curation_concern_spec.rb +1 -1
  86. data/spec/services/thumbnail_path_service_spec.rb +13 -9
  87. data/spec/support/curation_concerns/factory_helpers.rb +18 -0
  88. metadata +28 -50
  89. data/app/actors/curation_concerns/abstract_actor.rb +0 -28
  90. data/app/actors/curation_concerns/actor_stack.rb +0 -27
  91. data/app/actors/curation_concerns/add_to_collection_actor.rb +0 -38
  92. data/app/actors/curation_concerns/apply_order_actor.rb +0 -24
  93. data/app/actors/curation_concerns/assign_identifier_actor.rb +0 -7
  94. data/app/actors/curation_concerns/assign_representative_actor.rb +0 -18
  95. data/app/actors/curation_concerns/attach_files_actor.rb +0 -39
  96. data/app/actors/curation_concerns/base_actor.rb +0 -76
  97. data/app/actors/curation_concerns/embargo_actor.rb +0 -19
  98. data/app/actors/curation_concerns/file_actor.rb +0 -79
  99. data/app/actors/curation_concerns/file_set_actor.rb +0 -157
  100. data/app/actors/curation_concerns/interpret_visibility_actor.rb +0 -123
  101. data/app/actors/curation_concerns/lease_actor.rb +0 -19
  102. data/app/actors/curation_concerns/root_actor.rb +0 -17
  103. data/app/actors/curation_concerns/work_actor_behavior.rb +0 -8
  104. data/app/renderers/curation_concerns/attribute_renderer.rb +0 -98
  105. data/app/renderers/curation_concerns/configured_microdata.rb +0 -40
  106. data/app/services/curation_concerns/actor_factory.rb +0 -24
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
  require 'rspec/active_model/mocks'
3
3
 
4
4
  describe CurationConcerns::CollectionBehavior do
5
+ include CurationConcerns::FactoryHelpers
6
+
5
7
  # All behavior for Collection are defined in CC::CollectionBehavior, so we use
6
8
  # a Collection instance to test.
7
9
  let(:collection) { FactoryGirl.build(:collection) }
@@ -31,13 +33,20 @@ describe CurationConcerns::CollectionBehavior do
31
33
  # Calculating the size of the Collection should only hit Solr.
32
34
  # This base case querries solr in an integration test
33
35
  context 'with indexed Works and FileSets', :integration do
34
- let(:file1) { FactoryGirl.build(:file_set, file_size: ['100']) }
35
- let(:file2) { FactoryGirl.build(:file_set, file_size: ['100']) }
36
- let(:file3) { FactoryGirl.build(:file_set, file_size: ['9000'], id: 'fumid') }
36
+ let(:file1) { FactoryGirl.build(:file_set) }
37
+ let(:file2) { FactoryGirl.build(:file_set) }
38
+ let(:file3) { FactoryGirl.build(:file_set, id: 'fumid') }
37
39
  let(:work1) { FactoryGirl.build(:generic_work) }
38
40
  let(:work2) { FactoryGirl.build(:generic_work) }
39
41
  let(:work3) { FactoryGirl.build(:generic_work, id: 'dumid') }
42
+ let(:of1) { mock_file_factory(file_size: ['100']) }
43
+ let(:of2) { mock_file_factory(file_size: ['100']) }
44
+ let(:of3) { mock_file_factory(file_size: ['9000']) }
45
+
40
46
  before do
47
+ allow(file1).to receive(:original_file).and_return(of1)
48
+ allow(file2).to receive(:original_file).and_return(of2)
49
+ allow(file3).to receive(:original_file).and_return(of3)
41
50
  # Save collection to get ids
42
51
  collection.save
43
52
  # Create relationships so member_ids are created
@@ -4,6 +4,8 @@ require 'spec_helper'
4
4
  # It includes the CurationConcerns::FileSetBehavior module and nothing else
5
5
  # So this test covers both the FileSetBehavior module and the generated FileSet model
6
6
  describe FileSet do
7
+ include CurationConcerns::FactoryHelpers
8
+
7
9
  let(:user) { create(:user) }
8
10
 
9
11
  describe 'rdf type' do
@@ -105,6 +107,7 @@ describe FileSet do
105
107
  expect(subject).to respond_to(:well_formed)
106
108
  expect(subject).to respond_to(:page_count)
107
109
  expect(subject).to respond_to(:file_title)
110
+ # :creator is characterization metadata?
108
111
  expect(subject).to respond_to(:creator)
109
112
  end
110
113
 
@@ -168,7 +171,7 @@ describe FileSet do
168
171
  end
169
172
 
170
173
  it 'supports multi-valued fields in solr' do
171
- subject.tag = %w(tag1 tag2)
174
+ subject.keyword = %w(keyword1 keyword2)
172
175
  expect { subject.save }.not_to raise_error
173
176
  subject.delete
174
177
  end
@@ -357,7 +360,7 @@ describe FileSet do
357
360
  context 'when file contains a virus' do
358
361
  before do
359
362
  allow(subject).to receive(:warn) # suppress virus warnings
360
- allow(ClamAV.instance).to receive(:scanfile).and_return('EL CRAPO VIRUS')
363
+ allow(Hydra::Works::VirusCheckerService).to receive(:file_has_virus?) { true }
361
364
  # TODO: Test that this works with Hydra::Works::UploadFileToFileSet. see https://github.com/projecthydra-labs/hydra-works/pull/139
362
365
  # Hydra::Works::UploadFileToFileSet.call(subject, file_path, original_name: 'small_file.txt')
363
366
  of = subject.build_original_file
@@ -366,7 +369,7 @@ describe FileSet do
366
369
 
367
370
  it 'populates the errors hash during validation' do
368
371
  expect(subject).to_not be_valid
369
- expect(subject.errors.messages[:base].first).to match(/A virus was found in .*: EL CRAPO VIRUS/)
372
+ expect(subject.errors.messages[:base].first).to eq "Failed to verify uploaded file is not a virus"
370
373
  end
371
374
 
372
375
  it 'does not save the file or create a new version' do
@@ -555,77 +558,80 @@ describe FileSet do
555
558
  end
556
559
 
557
560
  describe 'mime type recognition' do
561
+ let(:mock_file) { mock_file_factory(mime_type: mime_type) }
562
+ before { allow(subject).to receive(:original_file).and_return(mock_file) }
563
+
558
564
  context '#image?' do
559
565
  context 'when image/jp2' do
560
- before { subject.mime_type = 'image/jp2' }
566
+ let(:mime_type) { 'image/jp2' }
561
567
  it { should be_image }
562
568
  end
563
569
  context 'when image/jpg' do
564
- before { subject.mime_type = 'image/jpg' }
570
+ let(:mime_type) { 'image/jpg' }
565
571
  it { should be_image }
566
572
  end
567
573
  context 'when image/png' do
568
- before { subject.mime_type = 'image/png' }
574
+ let(:mime_type) { 'image/png' }
569
575
  it { should be_image }
570
576
  end
571
577
  context 'when image/tiff' do
572
- before { subject.mime_type = 'image/tiff' }
578
+ let(:mime_type) { 'image/tiff' }
573
579
  it { should be_image }
574
580
  end
575
581
  end
576
582
 
577
583
  describe '#pdf?' do
578
- before { subject.mime_type = 'application/pdf' }
584
+ let(:mime_type) { 'application/pdf' }
579
585
  it { should be_pdf }
580
586
  end
581
587
 
582
588
  describe '#audio?' do
583
589
  context 'when x-wave' do
584
- before { subject.mime_type = 'audio/x-wave' }
590
+ let(:mime_type) { 'audio/x-wave' }
585
591
  it { should be_audio }
586
592
  end
587
593
  context 'when x-wav' do
588
- before { subject.mime_type = 'audio/x-wav' }
594
+ let(:mime_type) { 'audio/x-wav' }
589
595
  it { should be_audio }
590
596
  end
591
597
  context 'when mpeg' do
592
- before { subject.mime_type = 'audio/mpeg' }
598
+ let(:mime_type) { 'audio/mpeg' }
593
599
  it { should be_audio }
594
600
  end
595
601
  context 'when mp3' do
596
- before { subject.mime_type = 'audio/mp3' }
602
+ let(:mime_type) { 'audio/mp3' }
597
603
  it { should be_audio }
598
604
  end
599
605
  context 'when ogg' do
600
- before { subject.mime_type = 'audio/ogg' }
606
+ let(:mime_type) { 'audio/ogg' }
601
607
  it { should be_audio }
602
608
  end
603
609
  end
604
610
 
605
611
  describe '#video?' do
606
612
  context 'should be true for avi' do
607
- before { subject.mime_type = 'video/avi' }
613
+ let(:mime_type) { 'video/avi' }
608
614
  it { should be_video }
609
615
  end
610
616
 
611
617
  context 'should be true for webm' do
612
- before { subject.mime_type = 'video/webm' }
618
+ let(:mime_type) { 'video/webm' }
613
619
  it { should be_video }
614
620
  end
615
621
  context 'should be true for mp4' do
616
- before { subject.mime_type = 'video/mp4' }
622
+ let(:mime_type) { 'video/mp4' }
617
623
  it { should be_video }
618
624
  end
619
625
  context 'should be true for mpeg' do
620
- before { subject.mime_type = 'video/mpeg' }
626
+ let(:mime_type) { 'video/mpeg' }
621
627
  it { should be_video }
622
628
  end
623
629
  context 'should be true for quicktime' do
624
- before { subject.mime_type = 'video/quicktime' }
630
+ let(:mime_type) { 'video/quicktime' }
625
631
  it { should be_video }
626
632
  end
627
633
  context 'should be true for mxf' do
628
- before { subject.mime_type = 'application/mxf' }
634
+ let(:mime_type) { 'application/mxf' }
629
635
  it { should be_video }
630
636
  end
631
637
  end
@@ -18,7 +18,7 @@ describe CurationConcerns::CollectionPresenter do
18
18
 
19
19
  describe '#title' do
20
20
  subject { presenter.title }
21
- it { is_expected.to eq 'A clever title' }
21
+ it { is_expected.to eq ['A clever title'] }
22
22
  end
23
23
 
24
24
  describe '#to_key' do
@@ -45,7 +45,7 @@ describe CurationConcerns::FileSetPresenter do
45
45
 
46
46
  describe "properties delegated to solr_document" do
47
47
  let(:solr_properties) do
48
- ["date_uploaded", "depositor", "tags", "title_or_label",
48
+ ["date_uploaded", "depositor", "keyword", "title_or_label",
49
49
  "contributor", "creator", "title", "description", "publisher",
50
50
  "subject", "language", "rights"]
51
51
  end
@@ -131,8 +131,8 @@ describe CurationConcerns::WorkShowPresenter do
131
131
 
132
132
  context 'with an existing field' do
133
133
  before do
134
- allow(CurationConcerns::AttributeRenderer).to receive(:new)
135
- .with(:title, "foo bar", {})
134
+ allow(CurationConcerns::Renderers::AttributeRenderer).to receive(:new)
135
+ .with(:title, ["foo bar"], {})
136
136
  .and_return(renderer)
137
137
  end
138
138
 
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe CurationConcerns::AttributeRenderer do
3
+ describe CurationConcerns::Renderers::AttributeRenderer do
4
4
  let(:field) { :name }
5
5
  let(:renderer) { described_class.new(field, ['Bob', 'Jessica']) }
6
- let(:yml_path) { File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'locales', '*.{rb,yml}') }
6
+ let(:yml_path) { File.join(File.dirname(__FILE__), '..', '..', '..', 'fixtures', 'locales', '*.{rb,yml}') }
7
7
  before do
8
8
  I18n.load_path += Dir[File.join(yml_path)]
9
9
  I18n.reload!
@@ -6,6 +6,6 @@ describe CurationConcerns::CurationConcern do
6
6
 
7
7
  describe ".actor" do
8
8
  subject { described_class.actor(work, user) }
9
- it { is_expected.to be_kind_of CurationConcerns::ActorStack }
9
+ it { is_expected.to be_kind_of CurationConcerns::Actors::ActorStack }
10
10
  end
11
11
  end
@@ -1,35 +1,39 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CurationConcerns::ThumbnailPathService do
4
+ include CurationConcerns::FactoryHelpers
5
+
4
6
  subject { described_class.call(object) }
5
7
 
6
8
  context "with a FileSet" do
7
- let(:object) { FileSet.new(id: '999', mime_type: mime_type) }
8
- let(:mime_type) { 'image/jpeg' }
9
+ let(:object) { build(:file_set, id: '999') }
10
+ before { allow(object).to receive(:original_file).and_return(original_file) }
9
11
  context "that has a thumbnail" do
10
- before do
11
- allow(File).to receive(:exist?).and_return(true)
12
- end
12
+ let(:original_file) { mock_file_factory(mime_type: 'image/jpeg') }
13
+ before { allow(File).to receive(:exist?).and_return(true) }
13
14
  it { is_expected.to eq '/downloads/999?file=thumbnail' }
14
15
  end
15
16
 
16
17
  context "that is an audio" do
17
- let(:mime_type) { 'audio/x-wav' }
18
+ let(:original_file) { mock_file_factory(mime_type: 'audio/x-wav') }
18
19
  it { is_expected.to match %r{/assets/audio-.+.png} }
19
20
  end
20
21
 
21
22
  context "that has no thumbnail" do
23
+ let(:original_file) { mock_model('MockFile', mime_type: nil) }
22
24
  it { is_expected.to match %r{/assets/default-.+.png} }
23
25
  end
24
26
  end
25
27
 
26
28
  context "with a Work" do
27
29
  context "that has a thumbnail" do
28
- let(:object) { GenericWork.new(thumbnail_id: '999') }
29
- let(:representative) { FileSet.new(id: '777') }
30
+ let(:object) { GenericWork.new(thumbnail_id: '999') }
31
+ let(:representative) { build(:file_set, id: '777') }
32
+ let(:original_file) { mock_file_factory(mime_type: 'image/jpeg') }
30
33
  before do
31
34
  allow(File).to receive(:exist?).and_return(true)
32
- allow(FileSet).to receive(:load_instance_from_solr).with('999').and_return(representative)
35
+ allow(FileSet).to receive(:find).with('999').and_return(representative)
36
+ allow(representative).to receive(:original_file).and_return(original_file)
33
37
  end
34
38
 
35
39
  it { is_expected.to eq '/downloads/999?file=thumbnail' }
@@ -11,5 +11,23 @@ module CurationConcerns
11
11
  let(:public_work_factory_name) { "public_#{curation_concern_type_underscore}".to_sym }
12
12
  end
13
13
  end
14
+
15
+ def mock_file_factory(opts = {})
16
+ mock_model('MockFile',
17
+ mime_type: opts.fetch(:mime_type, 'text/plain'),
18
+ content: opts.fetch(:content, 'content'),
19
+ file_size: opts.fetch(:file_size, []),
20
+ format_label: opts.fetch(:format_label, []),
21
+ height: opts.fetch(:height, []),
22
+ width: opts.fetch(:width, []),
23
+ filename: opts.fetch(:filename, []),
24
+ well_formed: opts.fetch(:well_formed, []),
25
+ page_count: opts.fetch(:page_count, []),
26
+ file_title: opts.fetch(:file_title, []),
27
+ last_modified: opts.fetch(:last_modified, []),
28
+ original_checksum: opts.fetch(:original_checksum, []),
29
+ digest: opts.fetch(:digest, [])
30
+ )
31
+ end
14
32
  end
15
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curation_concerns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
4
+ version: 1.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-05-11 00:00:00.000000000 Z
13
+ date: 2016-05-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hydra-head
@@ -176,42 +176,16 @@ dependencies:
176
176
  name: hydra-works
177
177
  requirement: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - "~>"
180
- - !ruby/object:Gem::Version
181
- version: '0.8'
182
179
  - - ">="
183
180
  - !ruby/object:Gem::Version
184
- version: 0.8.1
181
+ version: 0.10.0
185
182
  type: :runtime
186
183
  prerelease: false
187
184
  version_requirements: !ruby/object:Gem::Requirement
188
- requirements:
189
- - - "~>"
190
- - !ruby/object:Gem::Version
191
- version: '0.8'
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: 0.8.1
195
- - !ruby/object:Gem::Dependency
196
- name: hydra-pcdm
197
- requirement: !ruby/object:Gem::Requirement
198
185
  requirements:
199
186
  - - ">="
200
187
  - !ruby/object:Gem::Version
201
- version: 0.8.0.beta1
202
- - - "<"
203
- - !ruby/object:Gem::Version
204
- version: '1'
205
- type: :runtime
206
- prerelease: false
207
- version_requirements: !ruby/object:Gem::Requirement
208
- requirements:
209
- - - ">="
210
- - !ruby/object:Gem::Version
211
- version: 0.8.0.beta1
212
- - - "<"
213
- - !ruby/object:Gem::Version
214
- version: '1'
188
+ version: 0.10.0
215
189
  - !ruby/object:Gem::Dependency
216
190
  name: active_fedora-noid
217
191
  requirement: !ruby/object:Gem::Requirement
@@ -612,21 +586,22 @@ files:
612
586
  - RELEASING.md
613
587
  - Rakefile
614
588
  - app/actors/concerns/curation_concerns/manages_embargoes_actor.rb
615
- - app/actors/curation_concerns/abstract_actor.rb
616
- - app/actors/curation_concerns/actor_stack.rb
617
- - app/actors/curation_concerns/add_to_collection_actor.rb
618
- - app/actors/curation_concerns/apply_order_actor.rb
619
- - app/actors/curation_concerns/assign_identifier_actor.rb
620
- - app/actors/curation_concerns/assign_representative_actor.rb
621
- - app/actors/curation_concerns/attach_files_actor.rb
622
- - app/actors/curation_concerns/base_actor.rb
623
- - app/actors/curation_concerns/embargo_actor.rb
624
- - app/actors/curation_concerns/file_actor.rb
625
- - app/actors/curation_concerns/file_set_actor.rb
626
- - app/actors/curation_concerns/interpret_visibility_actor.rb
627
- - app/actors/curation_concerns/lease_actor.rb
628
- - app/actors/curation_concerns/root_actor.rb
629
- - app/actors/curation_concerns/work_actor_behavior.rb
589
+ - app/actors/curation_concerns/actors.rb
590
+ - app/actors/curation_concerns/actors/abstract_actor.rb
591
+ - app/actors/curation_concerns/actors/actor_stack.rb
592
+ - app/actors/curation_concerns/actors/add_to_collection_actor.rb
593
+ - app/actors/curation_concerns/actors/apply_order_actor.rb
594
+ - app/actors/curation_concerns/actors/assign_identifier_actor.rb
595
+ - app/actors/curation_concerns/actors/assign_representative_actor.rb
596
+ - app/actors/curation_concerns/actors/attach_files_actor.rb
597
+ - app/actors/curation_concerns/actors/base_actor.rb
598
+ - app/actors/curation_concerns/actors/embargo_actor.rb
599
+ - app/actors/curation_concerns/actors/file_actor.rb
600
+ - app/actors/curation_concerns/actors/file_set_actor.rb
601
+ - app/actors/curation_concerns/actors/interpret_visibility_actor.rb
602
+ - app/actors/curation_concerns/actors/lease_actor.rb
603
+ - app/actors/curation_concerns/actors/root_actor.rb
604
+ - app/actors/curation_concerns/actors/work_actor_behavior.rb
630
605
  - app/assets/images/audio.png
631
606
  - app/assets/images/default.png
632
607
  - app/assets/images/loading.gif
@@ -696,6 +671,7 @@ files:
696
671
  - app/controllers/embargoes_controller.rb
697
672
  - app/controllers/leases_controller.rb
698
673
  - app/controllers/welcome_controller.rb
674
+ - app/forms/curation_concerns/forms.rb
699
675
  - app/forms/curation_concerns/forms/collection_edit_form.rb
700
676
  - app/forms/curation_concerns/forms/file_set_edit_form.rb
701
677
  - app/forms/curation_concerns/forms/work_form.rb
@@ -734,6 +710,7 @@ files:
734
710
  - app/models/collection.rb
735
711
  - app/models/concerns/curation_concerns/ability.rb
736
712
  - app/models/concerns/curation_concerns/basic_metadata.rb
713
+ - app/models/concerns/curation_concerns/characterization.rb
737
714
  - app/models/concerns/curation_concerns/collection.rb
738
715
  - app/models/concerns/curation_concerns/collection_behavior.rb
739
716
  - app/models/concerns/curation_concerns/file_set/belongs_to_works.rb
@@ -770,8 +747,9 @@ files:
770
747
  - app/presenters/curation_concerns/version_list_presenter.rb
771
748
  - app/presenters/curation_concerns/version_presenter.rb
772
749
  - app/presenters/curation_concerns/work_show_presenter.rb
773
- - app/renderers/curation_concerns/attribute_renderer.rb
774
- - app/renderers/curation_concerns/configured_microdata.rb
750
+ - app/renderers/curation_concerns/renderers/attribute_renderer.rb
751
+ - app/renderers/curation_concerns/renderers/configured_microdata.rb
752
+ - app/renderers/renderers.rb
775
753
  - app/search_builders/curation_concerns/collection_member_search_builder.rb
776
754
  - app/search_builders/curation_concerns/collection_search_builder.rb
777
755
  - app/search_builders/curation_concerns/deactivated_embargo_search_builder.rb
@@ -788,7 +766,7 @@ files:
788
766
  - app/search_builders/curation_concerns/single_result.rb
789
767
  - app/search_builders/curation_concerns/single_use_link_search_builder.rb
790
768
  - app/search_builders/curation_concerns/work_search_builder.rb
791
- - app/services/curation_concerns/actor_factory.rb
769
+ - app/services/curation_concerns/actors/actor_factory.rb
792
770
  - app/services/curation_concerns/curation_concern.rb
793
771
  - app/services/curation_concerns/derivative_path.rb
794
772
  - app/services/curation_concerns/embargo_service.rb
@@ -1142,7 +1120,7 @@ files:
1142
1120
  - spec/presenters/curation_concerns/work_show_presenter_spec.rb
1143
1121
  - spec/presenters/embargo_presenter_spec.rb
1144
1122
  - spec/presenters/lease_presenter_spec.rb
1145
- - spec/renderers/curation_concerns/attribute_renderer_spec.rb
1123
+ - spec/renderers/curation_concerns/renderers/attribute_renderer_spec.rb
1146
1124
  - spec/routing/curation_concerns/routes_spec.rb
1147
1125
  - spec/routing/route_spec.rb
1148
1126
  - spec/search_builders/curation_concerns/embargo_search_builder_spec.rb
@@ -1343,7 +1321,7 @@ test_files:
1343
1321
  - spec/presenters/curation_concerns/work_show_presenter_spec.rb
1344
1322
  - spec/presenters/embargo_presenter_spec.rb
1345
1323
  - spec/presenters/lease_presenter_spec.rb
1346
- - spec/renderers/curation_concerns/attribute_renderer_spec.rb
1324
+ - spec/renderers/curation_concerns/renderers/attribute_renderer_spec.rb
1347
1325
  - spec/routing/curation_concerns/routes_spec.rb
1348
1326
  - spec/routing/route_spec.rb
1349
1327
  - spec/search_builders/curation_concerns/embargo_search_builder_spec.rb
@@ -1,28 +0,0 @@
1
- module CurationConcerns
2
- # The CurationConcern Abstract actor responds to two primary actions:
3
- # * #create
4
- # * #update
5
- #
6
- # and the following attributes
7
- #
8
- # * next_actor
9
- # * curation_concern
10
- # * user
11
- #
12
- # it must instantiate the next actor in the chain and instantiate it.
13
- # it should respond to curation_concern, user and attributes.
14
- # it ha to next_actor
15
- class AbstractActor
16
- attr_reader :next_actor
17
-
18
- def initialize(_curation_concern, _user, next_actor)
19
- @next_actor = next_actor
20
- end
21
-
22
- delegate :curation_concern, :user, to: :next_actor
23
-
24
- delegate :create, to: :next_actor
25
-
26
- delegate :update, to: :next_actor
27
- end
28
- end
@@ -1,27 +0,0 @@
1
- module CurationConcerns
2
- class ActorStack
3
- attr_reader :curation_concern, :user, :first_actor_class, :more_actors
4
- def initialize(curation_concern, user, more_actors)
5
- @curation_concern = curation_concern
6
- @user = user
7
- @more_actors = more_actors
8
- @first_actor_class = @more_actors.shift || RootActor
9
- end
10
-
11
- def inner_stack
12
- ActorStack.new(curation_concern, user, more_actors)
13
- end
14
-
15
- def actor
16
- first_actor_class.new(curation_concern, user, inner_stack)
17
- end
18
-
19
- def create(attributes)
20
- actor.create(attributes.with_indifferent_access)
21
- end
22
-
23
- def update(attributes)
24
- actor.update(attributes.with_indifferent_access)
25
- end
26
- end
27
- end
@@ -1,38 +0,0 @@
1
- module CurationConcerns
2
- class AddToCollectionActor < AbstractActor
3
- def create(attributes)
4
- collection_ids = attributes.delete(:collection_ids)
5
- next_actor.create(attributes) && add_to_collections(collection_ids)
6
- end
7
-
8
- def update(attributes)
9
- collection_ids = attributes.delete(:collection_ids)
10
- add_to_collections(collection_ids) && next_actor.update(attributes)
11
- end
12
-
13
- private
14
-
15
- # The default behavior of active_fedora's aggregates association,
16
- # when assigning the id accessor (e.g. collection_ids = ['foo:1']) is to add
17
- # to new collections, but not remove from old collections.
18
- # This method ensures it's removed from the old collections.
19
- def add_to_collections(new_collection_ids)
20
- return true unless new_collection_ids
21
- # remove from old collections
22
- # TODO: Implement in_collection_ids https://github.com/projecthydra-labs/hydra-pcdm/issues/157
23
- (curation_concern.in_collections.map(&:id) - new_collection_ids).each do |old_id|
24
- collection = ::Collection.find(old_id)
25
- collection.members.delete(curation_concern)
26
- collection.save
27
- end
28
-
29
- # add to new
30
- new_collection_ids.each do |coll_id|
31
- collection = ::Collection.find(coll_id)
32
- collection.members << curation_concern
33
- collection.save
34
- end
35
- true
36
- end
37
- end
38
- end
@@ -1,24 +0,0 @@
1
- module CurationConcerns
2
- class ApplyOrderActor < AbstractActor
3
- def update(attributes)
4
- ordered_member_ids = attributes.delete(:ordered_member_ids)
5
- apply_order(ordered_member_ids) && next_actor.update(attributes)
6
- end
7
-
8
- private
9
-
10
- def apply_order(new_order)
11
- return true unless new_order
12
- curation_concern.ordered_member_proxies.each_with_index do |proxy, index|
13
- unless new_order[index]
14
- proxy.prev.next = curation_concern.ordered_member_proxies.last.next
15
- break
16
- end
17
- proxy.proxy_for = ActiveFedora::Base.id_to_uri(new_order[index])
18
- proxy.target = nil
19
- end
20
- curation_concern.list_source.order_will_change!
21
- true
22
- end
23
- end
24
- end
@@ -1,7 +0,0 @@
1
- module CurationConcerns
2
- class AssignIdentifierActor < AbstractActor
3
- def create(attributes)
4
- curation_concern.assign_id && next_actor.create(attributes)
5
- end
6
- end
7
- end
@@ -1,18 +0,0 @@
1
- module CurationConcerns
2
- class AssignRepresentativeActor < AbstractActor
3
- def create(attributes)
4
- next_actor.create(attributes) && assign_representative
5
- end
6
-
7
- private
8
-
9
- def assign_representative
10
- unless curation_concern.representative_id
11
- # TODO: Possible optimization here. Does this cause a fetch of ordered_members if they're already loaded?
12
- representative = nil # curation_concern.ordered_members.association.reader.first.target
13
- curation_concern.representative = representative if representative
14
- end
15
- curation_concern.save
16
- end
17
- end
18
- end
@@ -1,39 +0,0 @@
1
- module CurationConcerns
2
- class AttachFilesActor < AbstractActor
3
- def create(attributes)
4
- files = [attributes.delete(:files)].flatten.compact
5
- attach_files(files, visibility_attributes(attributes)) &&
6
- next_actor.create(attributes)
7
- end
8
-
9
- def update(attributes)
10
- files = [attributes.delete(:files)].flatten.compact
11
- next_actor.update(attributes) &&
12
- attach_files(files, visibility_attributes(attributes))
13
- end
14
-
15
- private
16
-
17
- def attach_files(files, visibility_attr)
18
- files.all? do |file|
19
- attach_file(file, visibility_attr)
20
- end
21
- end
22
-
23
- def attach_file(file, visibility_attr)
24
- file_set = ::FileSet.new
25
- file_set_actor = CurationConcerns::FileSetActor.new(file_set, user)
26
- file_set_actor.create_metadata(curation_concern, visibility_attr)
27
- file_set_actor.create_content(file)
28
- end
29
-
30
- # The attributes used for visibility - used to send as initial params to
31
- # created FileSets.
32
- def visibility_attributes(attributes)
33
- attributes.slice(:visibility, :visibility_during_lease,
34
- :visibility_after_lease, :lease_expiration_date,
35
- :embargo_release_date, :visibility_during_embargo,
36
- :visibility_after_embargo)
37
- end
38
- end
39
- end