curation_concerns-models 0.11.0 → 0.12.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/actors/concerns/curation_concerns/manages_embargoes_actor.rb +3 -66
- data/app/actors/curation_concerns/abstract_actor.rb +28 -0
- data/app/actors/curation_concerns/add_to_collection_actor.rb +38 -0
- data/app/actors/curation_concerns/apply_order_actor.rb +24 -0
- data/app/actors/curation_concerns/assign_identifier_actor.rb +7 -0
- data/app/actors/curation_concerns/assign_representative_actor.rb +18 -0
- data/app/actors/curation_concerns/attach_files_actor.rb +39 -0
- data/app/actors/curation_concerns/base_actor.rb +17 -28
- data/app/actors/curation_concerns/file_set_actor.rb +7 -16
- data/app/actors/curation_concerns/interpret_visibility_actor.rb +123 -0
- data/app/actors/curation_concerns/root_actor.rb +17 -0
- data/app/actors/curation_concerns/work_actor_behavior.rb +4 -95
- data/lib/curation_concerns/models/version.rb +1 -1
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dec0847b3aa12c5c48e251ea115b6e82412af96
|
4
|
+
data.tar.gz: 2691544f9ef15ac45d29d1dee7623fe42d8b1dcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba78b4f524e0e67269c5464761da644868bbc0189a667548abfd3684f57b1e114b642a73af249eaae983dede84f22b1ab7efcaa6859e4894bc7461d1c166705b
|
7
|
+
data.tar.gz: 9b42e31b848ff7b56a0ab75a46d650b3d27871008f2898215907bc3bc61f4a0db7ab696a914e3a1d8b14fcdff4122bf44cb067a459999c8e0b21dde5939e8dcf
|
@@ -19,73 +19,10 @@ module CurationConcerns
|
|
19
19
|
#
|
20
20
|
module ManagesEmbargoesActor
|
21
21
|
extend ActiveSupport::Concern
|
22
|
+
extend Deprecation
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
def interpret_visibility(attributes = self.attributes)
|
26
|
-
should_continue = interpret_embargo_visibility(attributes) && interpret_lease_visibility(attributes)
|
27
|
-
if attributes[:visibility]
|
28
|
-
curation_concern.visibility = attributes[:visibility]
|
29
|
-
end
|
30
|
-
should_continue
|
31
|
-
end
|
32
|
-
|
33
|
-
# If user has set visibility to embargo, interprets the relevant information and applies it
|
34
|
-
# Returns false if there are any errors and sets an error on the curation_concern
|
35
|
-
def interpret_embargo_visibility(attributes = self.attributes)
|
36
|
-
if attributes[:visibility] == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
|
37
|
-
if !attributes[:embargo_release_date]
|
38
|
-
curation_concern.errors.add(:visibility, 'When setting visibility to "embargo" you must also specify embargo release date.')
|
39
|
-
should_continue = false
|
40
|
-
else
|
41
|
-
attributes.delete(:visibility)
|
42
|
-
curation_concern.apply_embargo(attributes[:embargo_release_date], attributes.delete(:visibility_during_embargo),
|
43
|
-
attributes.delete(:visibility_after_embargo))
|
44
|
-
if curation_concern.embargo
|
45
|
-
curation_concern.embargo.save # See https://github.com/projecthydra/hydra-head/issues/226
|
46
|
-
end
|
47
|
-
should_continue = true
|
48
|
-
end
|
49
|
-
else
|
50
|
-
should_continue = true
|
51
|
-
# clear embargo_release_date if it isn't being used. Otherwise it sets the embargo_date
|
52
|
-
# even though they didn't select embargo on the form.
|
53
|
-
attributes.delete(:embargo_release_date)
|
54
|
-
end
|
55
|
-
|
56
|
-
attributes.delete(:visibility_during_embargo)
|
57
|
-
attributes.delete(:visibility_after_embargo)
|
58
|
-
|
59
|
-
should_continue
|
60
|
-
end
|
61
|
-
|
62
|
-
# If user has set visibility to lease, interprets the relevant information and applies it
|
63
|
-
# Returns false if there are any errors and sets an error on the curation_concern
|
64
|
-
def interpret_lease_visibility(attributes = self.attributes)
|
65
|
-
if attributes[:visibility] == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE
|
66
|
-
if !attributes[:lease_expiration_date]
|
67
|
-
curation_concern.errors.add(:visibility, 'When setting visibility to "lease" you must also specify lease expiration date.')
|
68
|
-
should_continue = false
|
69
|
-
else
|
70
|
-
curation_concern.apply_lease(attributes[:lease_expiration_date], attributes.delete(:visibility_during_lease),
|
71
|
-
attributes.delete(:visibility_after_lease))
|
72
|
-
if curation_concern.lease
|
73
|
-
curation_concern.lease.save # See https://github.com/projecthydra/hydra-head/issues/226
|
74
|
-
end
|
75
|
-
attributes.delete(:visibility)
|
76
|
-
should_continue = true
|
77
|
-
end
|
78
|
-
else
|
79
|
-
# clear lease_expiration_date if it isn't being used. Otherwise it sets the lease_expiration
|
80
|
-
# even though they didn't select lease on the form.
|
81
|
-
attributes.delete(:lease_expiration_date)
|
82
|
-
should_continue = true
|
83
|
-
end
|
84
|
-
|
85
|
-
attributes.delete(:visibility_during_lease)
|
86
|
-
attributes.delete(:visibility_after_lease)
|
87
|
-
|
88
|
-
should_continue
|
24
|
+
included do
|
25
|
+
Deprecation.warn(ManagesEmbargoesActor, "ManagesEmbargoesActor is deprecated and will be removed in CurationConcerns 1.0")
|
89
26
|
end
|
90
27
|
end
|
91
28
|
end
|
@@ -0,0 +1,28 @@
|
|
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
|
@@ -0,0 +1,38 @@
|
|
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
|
@@ -0,0 +1,24 @@
|
|
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
|
@@ -0,0 +1,18 @@
|
|
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
|
@@ -0,0 +1,39 @@
|
|
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
|
@@ -1,34 +1,23 @@
|
|
1
|
-
|
2
1
|
module CurationConcerns
|
3
|
-
# The CurationConcern base actor
|
2
|
+
# The CurationConcern base actor responds to two primary actions:
|
4
3
|
# * #create
|
5
4
|
# * #update
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
@curation_concern = curation_concern
|
11
|
-
@user = user
|
12
|
-
@attributes = input_attributes.dup.with_indifferent_access
|
13
|
-
@visibility = attributes[:visibility]
|
14
|
-
@cloud_resources = attributes.delete(:cloud_resources.to_s)
|
15
|
-
end
|
5
|
+
# it must instantiate the next actor in the chain and instantiate it.
|
6
|
+
# it should respond to curation_concern, user and attributes.
|
7
|
+
class BaseActor < AbstractActor
|
8
|
+
attr_reader :cloud_resources
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
delegate :visibility_changed?, to: :curation_concern
|
21
|
-
|
22
|
-
def create
|
10
|
+
def create(attributes)
|
11
|
+
@cloud_resources = attributes.delete(:cloud_resources.to_s)
|
23
12
|
apply_creation_data_to_curation_concern
|
24
|
-
apply_save_data_to_curation_concern
|
25
|
-
save
|
13
|
+
apply_save_data_to_curation_concern(attributes)
|
14
|
+
next_actor.create(attributes) && save
|
26
15
|
end
|
27
16
|
|
28
|
-
def update
|
17
|
+
def update(attributes)
|
29
18
|
apply_update_data_to_curation_concern
|
30
|
-
apply_save_data_to_curation_concern
|
31
|
-
save
|
19
|
+
apply_save_data_to_curation_concern(attributes)
|
20
|
+
next_actor.update(attributes) && save
|
32
21
|
end
|
33
22
|
|
34
23
|
protected
|
@@ -55,9 +44,9 @@ module CurationConcerns
|
|
55
44
|
curation_concern.save
|
56
45
|
end
|
57
46
|
|
58
|
-
def apply_save_data_to_curation_concern
|
47
|
+
def apply_save_data_to_curation_concern(attributes)
|
59
48
|
attributes[:rights] = Array(attributes[:rights]) if attributes.key? :rights
|
60
|
-
remove_blank_attributes!
|
49
|
+
remove_blank_attributes!(attributes)
|
61
50
|
curation_concern.attributes = attributes.symbolize_keys
|
62
51
|
curation_concern.date_modified = CurationConcerns::TimeService.time_in_utc
|
63
52
|
end
|
@@ -68,14 +57,14 @@ module CurationConcerns
|
|
68
57
|
# remove_blank_attributes!
|
69
58
|
# self.attributes
|
70
59
|
# => { 'title' => ['first', 'second'] }
|
71
|
-
def remove_blank_attributes!
|
72
|
-
multivalued_form_attributes.each_with_object(attributes) do |(k, v), h|
|
60
|
+
def remove_blank_attributes!(attributes)
|
61
|
+
multivalued_form_attributes(attributes).each_with_object(attributes) do |(k, v), h|
|
73
62
|
h[k] = v.instance_of?(Array) ? v.select(&:present?) : v
|
74
63
|
end
|
75
64
|
end
|
76
65
|
|
77
66
|
# Return the hash of attributes that are multivalued and not uploaded files
|
78
|
-
def multivalued_form_attributes
|
67
|
+
def multivalued_form_attributes(attributes)
|
79
68
|
attributes.select { |_, v| v.respond_to?(:select) && !v.respond_to?(:read) }
|
80
69
|
end
|
81
70
|
end
|
@@ -1,15 +1,11 @@
|
|
1
1
|
module CurationConcerns
|
2
2
|
# Actions are decoupled from controller logic so that they may be called from a controller or a background job.
|
3
3
|
class FileSetActor
|
4
|
-
include CurationConcerns::ManagesEmbargoesActor
|
5
4
|
include CurationConcerns::Lockable
|
6
5
|
|
7
|
-
attr_reader :file_set, :user, :attributes
|
6
|
+
attr_reader :file_set, :user, :attributes
|
8
7
|
|
9
8
|
def initialize(file_set, user)
|
10
|
-
# we're setting attributes and curation_concern to bridge the difference
|
11
|
-
# between CurationConcerns::FileSetActor and ManagesEmbargoesActor
|
12
|
-
@curation_concern = file_set
|
13
9
|
@file_set = file_set
|
14
10
|
@user = user
|
15
11
|
end
|
@@ -30,7 +26,7 @@ module CurationConcerns
|
|
30
26
|
file_set.date_modified = now
|
31
27
|
file_set.creator = [user.user_key]
|
32
28
|
|
33
|
-
|
29
|
+
CurationConcern::ActorStack.new(file_set, user, [InterpretVisibilityActor]).create(file_set_params) if assign_visibility?(file_set_params)
|
34
30
|
attach_file_to_work(work, file_set, file_set_params) if work
|
35
31
|
yield(file_set) if block_given?
|
36
32
|
end
|
@@ -70,13 +66,13 @@ module CurationConcerns
|
|
70
66
|
end
|
71
67
|
|
72
68
|
def update_metadata(attributes)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
save do
|
69
|
+
stack = CurationConcern::ActorStack.new(file_set,
|
70
|
+
user,
|
71
|
+
[InterpretVisibilityActor, BaseActor])
|
72
|
+
if result = stack.update(attributes)
|
78
73
|
CurationConcerns.config.callback.run(:after_update_metadata, file_set, user)
|
79
74
|
end
|
75
|
+
result
|
80
76
|
end
|
81
77
|
|
82
78
|
def destroy
|
@@ -128,11 +124,6 @@ module CurationConcerns
|
|
128
124
|
!((file_set_params || {}).keys & %w(visibility embargo_release_date lease_expiration_date)).empty?
|
129
125
|
end
|
130
126
|
|
131
|
-
# This method can be overridden in case there is a custom approach for visibility (e.g. embargo)
|
132
|
-
def update_visibility(attributes)
|
133
|
-
interpret_visibility(attributes) # relies on CurationConcerns::ManagesEmbargoesActor to interpret and apply visibility
|
134
|
-
end
|
135
|
-
|
136
127
|
# copy visibility from source_concern to destination_concern
|
137
128
|
def copy_visibility(source_concern, destination_concern)
|
138
129
|
destination_concern.visibility = source_concern.visibility
|
@@ -0,0 +1,123 @@
|
|
1
|
+
module CurationConcerns
|
2
|
+
class InterpretVisibilityActor < AbstractActor
|
3
|
+
class Intention
|
4
|
+
def initialize(attributes)
|
5
|
+
@attributes = attributes
|
6
|
+
end
|
7
|
+
|
8
|
+
# returns a copy of attributes with the necessary params removed
|
9
|
+
# If the lease or embargo is valid, or if they selected something besides lease
|
10
|
+
# or embargo, remove all the params.
|
11
|
+
def sanitize_params
|
12
|
+
if valid_lease?
|
13
|
+
@attributes.except(:visibility,
|
14
|
+
:embargo_release_date,
|
15
|
+
:visibility_during_embargo,
|
16
|
+
:visibility_after_embargo)
|
17
|
+
elsif valid_embargo?
|
18
|
+
@attributes.except(:visibility,
|
19
|
+
:lease_expiration_date,
|
20
|
+
:visibility_during_lease,
|
21
|
+
:visibility_after_lease)
|
22
|
+
elsif !wants_lease? && !wants_embargo?
|
23
|
+
@attributes.except(:lease_expiration_date,
|
24
|
+
:visibility_during_lease,
|
25
|
+
:visibility_after_lease,
|
26
|
+
:embargo_release_date,
|
27
|
+
:visibility_during_embargo,
|
28
|
+
:visibility_after_embargo)
|
29
|
+
else
|
30
|
+
@attributes
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def wants_lease?
|
35
|
+
visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE
|
36
|
+
end
|
37
|
+
|
38
|
+
def wants_embargo?
|
39
|
+
visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
|
40
|
+
end
|
41
|
+
|
42
|
+
def valid_lease?
|
43
|
+
wants_lease? && @attributes[:lease_expiration_date].present?
|
44
|
+
end
|
45
|
+
|
46
|
+
def valid_embargo?
|
47
|
+
wants_embargo? && @attributes[:embargo_release_date].present?
|
48
|
+
end
|
49
|
+
|
50
|
+
def lease_params
|
51
|
+
[:lease_expiration_date,
|
52
|
+
:visibility_during_lease,
|
53
|
+
:visibility_after_lease].map { |key| @attributes[key] }
|
54
|
+
end
|
55
|
+
|
56
|
+
def embargo_params
|
57
|
+
[:embargo_release_date,
|
58
|
+
:visibility_during_embargo,
|
59
|
+
:visibility_after_embargo].map { |key| @attributes[key] }
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def visibility
|
65
|
+
@attributes[:visibility]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def create(attributes)
|
70
|
+
@intention = Intention.new(attributes)
|
71
|
+
attributes = @intention.sanitize_params
|
72
|
+
validate && apply_visibility(attributes) && next_actor.create(attributes)
|
73
|
+
end
|
74
|
+
|
75
|
+
def update(attributes)
|
76
|
+
@intention = Intention.new(attributes)
|
77
|
+
attributes = @intention.sanitize_params
|
78
|
+
validate && apply_visibility(attributes) && next_actor.update(attributes)
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def validate
|
84
|
+
validate_lease && validate_embargo
|
85
|
+
end
|
86
|
+
|
87
|
+
def apply_visibility(attributes)
|
88
|
+
result = apply_lease && apply_embargo
|
89
|
+
if attributes[:visibility]
|
90
|
+
curation_concern.visibility = attributes[:visibility]
|
91
|
+
end
|
92
|
+
result
|
93
|
+
end
|
94
|
+
|
95
|
+
def validate_lease
|
96
|
+
return true unless @intention.wants_lease? && !@intention.valid_lease?
|
97
|
+
curation_concern.errors.add(:visibility, 'When setting visibility to "lease" you must also specify lease expiration date.')
|
98
|
+
false
|
99
|
+
end
|
100
|
+
|
101
|
+
def validate_embargo
|
102
|
+
return true unless @intention.wants_embargo? && !@intention.valid_embargo?
|
103
|
+
curation_concern.errors.add(:visibility, 'When setting visibility to "embargo" you must also specify embargo release date.')
|
104
|
+
false
|
105
|
+
end
|
106
|
+
|
107
|
+
# If they want a lease, we can assume it's valid
|
108
|
+
def apply_lease
|
109
|
+
return true unless @intention.wants_lease?
|
110
|
+
curation_concern.apply_lease(*@intention.lease_params)
|
111
|
+
return unless curation_concern.lease
|
112
|
+
curation_concern.lease.save # see https://github.com/projecthydra/hydra-head/issues/226
|
113
|
+
end
|
114
|
+
|
115
|
+
# If they want an embargo, we can assume it's valid
|
116
|
+
def apply_embargo
|
117
|
+
return true unless @intention.wants_embargo?
|
118
|
+
curation_concern.apply_embargo(*@intention.embargo_params)
|
119
|
+
return unless curation_concern.embargo
|
120
|
+
curation_concern.embargo.save # see https://github.com/projecthydra/hydra-head/issues/226
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module CurationConcerns
|
2
|
+
class RootActor
|
3
|
+
attr_reader :curation_concern, :user, :cloud_resources
|
4
|
+
def initialize(curation_concern, user, _more_actors)
|
5
|
+
@curation_concern = curation_concern
|
6
|
+
@user = user
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(_)
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def update(_)
|
14
|
+
true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,99 +1,8 @@
|
|
1
1
|
module CurationConcerns::WorkActorBehavior
|
2
|
-
|
3
|
-
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
extend Deprecation
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
files && attributes.delete(:files)
|
8
|
-
self.raw_attributes = attributes.dup
|
9
|
-
# Files must be attached before saving in order to persist their relationship to the work
|
10
|
-
assign_pid && interpret_visibility && attach_files && super && assign_representative
|
5
|
+
included do
|
6
|
+
Deprecation.warn(CurationConcerns::WorkActorBehavior, "CurationConcerns::WorkActorBehavior is deprecated and will be removed in CurationConcerns 1.0")
|
11
7
|
end
|
12
|
-
|
13
|
-
def update
|
14
|
-
add_to_collections(attributes.delete(:collection_ids)) &&
|
15
|
-
interpret_visibility && apply_order(attributes.delete(:ordered_member_ids)) && super && attach_files
|
16
|
-
end
|
17
|
-
|
18
|
-
delegate :visibility_changed?, to: :curation_concern
|
19
|
-
|
20
|
-
protected
|
21
|
-
|
22
|
-
# Is this here to ensure that the curation_concern has a pid set before any of the other methods are executed?
|
23
|
-
def assign_pid
|
24
|
-
curation_concern.send(:assign_id)
|
25
|
-
end
|
26
|
-
|
27
|
-
def files
|
28
|
-
return @files if defined?(@files)
|
29
|
-
@files = [attributes[:files]].flatten.compact
|
30
|
-
end
|
31
|
-
|
32
|
-
def attach_files
|
33
|
-
files.all? do |file|
|
34
|
-
attach_file(file)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def apply_order(new_order)
|
39
|
-
return true unless new_order
|
40
|
-
curation_concern.ordered_member_proxies.each_with_index do |proxy, index|
|
41
|
-
unless new_order[index]
|
42
|
-
proxy.prev.next = curation_concern.ordered_member_proxies.last.next
|
43
|
-
break
|
44
|
-
end
|
45
|
-
proxy.proxy_for = ActiveFedora::Base.id_to_uri(new_order[index])
|
46
|
-
proxy.target = nil
|
47
|
-
end
|
48
|
-
curation_concern.list_source.order_will_change!
|
49
|
-
true
|
50
|
-
end
|
51
|
-
|
52
|
-
# The default behavior of active_fedora's aggregates association,
|
53
|
-
# when assigning the id accessor (e.g. collection_ids = ['foo:1']) is to add
|
54
|
-
# to new collections, but not remove from old collections.
|
55
|
-
# This method ensures it's removed from the old collections.
|
56
|
-
def add_to_collections(new_collection_ids)
|
57
|
-
return true unless new_collection_ids
|
58
|
-
# remove from old collections
|
59
|
-
# TODO: Implement in_collection_ids https://github.com/projecthydra-labs/hydra-pcdm/issues/157
|
60
|
-
(curation_concern.in_collections.map(&:id) - new_collection_ids).each do |old_id|
|
61
|
-
collection = Collection.find(old_id)
|
62
|
-
collection.members.delete(curation_concern)
|
63
|
-
collection.save
|
64
|
-
end
|
65
|
-
|
66
|
-
# add to new
|
67
|
-
new_collection_ids.each do |coll_id|
|
68
|
-
collection = Collection.find(coll_id)
|
69
|
-
collection.members << curation_concern
|
70
|
-
collection.save
|
71
|
-
end
|
72
|
-
true
|
73
|
-
end
|
74
|
-
|
75
|
-
def assign_representative
|
76
|
-
@file_sets ||= []
|
77
|
-
unless curation_concern.representative_id
|
78
|
-
curation_concern.representative = @file_sets.first unless @file_sets.empty?
|
79
|
-
end
|
80
|
-
curation_concern.save
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
def attach_file(file)
|
86
|
-
file_set = ::FileSet.new
|
87
|
-
file_set_actor = CurationConcerns::FileSetActor.new(file_set, user)
|
88
|
-
file_set_actor.create_metadata(curation_concern, visibility_attributes)
|
89
|
-
file_set_actor.create_content(file)
|
90
|
-
@file_sets ||= []
|
91
|
-
@file_sets << file_set # This is so that other methods like assign_representative can access the file_sets without reloading them from fedora
|
92
|
-
end
|
93
|
-
|
94
|
-
# The attributes used for visibility - used to send as initial params to
|
95
|
-
# created FileSets.
|
96
|
-
def visibility_attributes
|
97
|
-
raw_attributes.slice(:visibility, :visibility_during_lease, :visibility_after_lease, :lease_expiration_date, :embargo_release_date, :visibility_during_embargo, :visibility_after_embargo)
|
98
|
-
end
|
99
8
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curation_concerns-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|
@@ -198,11 +198,19 @@ files:
|
|
198
198
|
- README.md
|
199
199
|
- Rakefile
|
200
200
|
- app/actors/concerns/curation_concerns/manages_embargoes_actor.rb
|
201
|
+
- app/actors/curation_concerns/abstract_actor.rb
|
202
|
+
- app/actors/curation_concerns/add_to_collection_actor.rb
|
203
|
+
- app/actors/curation_concerns/apply_order_actor.rb
|
204
|
+
- app/actors/curation_concerns/assign_identifier_actor.rb
|
205
|
+
- app/actors/curation_concerns/assign_representative_actor.rb
|
206
|
+
- app/actors/curation_concerns/attach_files_actor.rb
|
201
207
|
- app/actors/curation_concerns/base_actor.rb
|
202
208
|
- app/actors/curation_concerns/embargo_actor.rb
|
203
209
|
- app/actors/curation_concerns/file_actor.rb
|
204
210
|
- app/actors/curation_concerns/file_set_actor.rb
|
211
|
+
- app/actors/curation_concerns/interpret_visibility_actor.rb
|
205
212
|
- app/actors/curation_concerns/lease_actor.rb
|
213
|
+
- app/actors/curation_concerns/root_actor.rb
|
206
214
|
- app/actors/curation_concerns/work_actor_behavior.rb
|
207
215
|
- app/indexers/curation_concerns/collection_indexer.rb
|
208
216
|
- app/indexers/curation_concerns/file_set_indexer.rb
|
@@ -297,9 +305,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
297
305
|
version: '0'
|
298
306
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
307
|
requirements:
|
300
|
-
- - "
|
308
|
+
- - ">"
|
301
309
|
- !ruby/object:Gem::Version
|
302
|
-
version:
|
310
|
+
version: 1.3.1
|
303
311
|
requirements: []
|
304
312
|
rubyforge_project:
|
305
313
|
rubygems_version: 2.5.1
|