Class: CurationConcerns::Actors::FileSetActor
- Inherits:
-
Object
- Object
- CurationConcerns::Actors::FileSetActor
show all
- Includes:
- Lockable
- Defined in:
- app/actors/curation_concerns/actors/file_set_actor.rb
Overview
Actions are decoupled from controller logic so that they may be called from a controller or a background job.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Lockable
#acquire_lock_for, #lock_manager
Constructor Details
#initialize(file_set, user) ⇒ FileSetActor
Returns a new instance of FileSetActor.
9
10
11
12
|
# File 'app/actors/curation_concerns/actors/file_set_actor.rb', line 9
def initialize(file_set, user)
@file_set = file_set
@user = user
end
|
Instance Attribute Details
#attributes ⇒ Object
7
8
9
|
# File 'app/actors/curation_concerns/actors/file_set_actor.rb', line 7
def attributes
@attributes
end
|
#file_set ⇒ Object
7
8
9
|
# File 'app/actors/curation_concerns/actors/file_set_actor.rb', line 7
def file_set
@file_set
end
|
#user ⇒ Object
7
8
9
|
# File 'app/actors/curation_concerns/actors/file_set_actor.rb', line 7
def user
@user
end
|
Instance Method Details
#create_content(file, relation = 'original_file') ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/actors/curation_concerns/actors/file_set_actor.rb', line 37
def create_content(file, relation = 'original_file')
file_set.label ||= file.respond_to?(:original_filename) ? file.original_filename : ::File.basename(file)
file_set.title = [file_set.label] if file_set.title.blank?
return false unless file_set.save
file_actor_class.new(file_set, relation, user).ingest_file(file)
true
end
|
Adds the appropriate metadata, visibility and relationships to file_set
Note: In past versions of Sufia this method did not perform a save because it is mainly used in conjunction with create_content, which also performs a save. However, due to the relationship between Hydra::PCDM objects, we have to save both the parent work and the file_set in order to record the “metadata” relationship between them.
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/actors/curation_concerns/actors/file_set_actor.rb', line 23
def create_metadata(work, file_set_params = {})
file_set.apply_depositor_metadata(user)
now = CurationConcerns::TimeService.time_in_utc
file_set.date_uploaded = now
file_set.date_modified = now
file_set.creator = [user.user_key]
Actors::ActorStack.new(file_set, user, [InterpretVisibilityActor]).create(file_set_params) if assign_visibility?(file_set_params)
attach_file_to_work(work, file_set, file_set_params) if work
yield(file_set) if block_given?
end
|
#destroy ⇒ Object
76
77
78
79
80
|
# File 'app/actors/curation_concerns/actors/file_set_actor.rb', line 76
def destroy
unlink_from_work
file_set.destroy
CurationConcerns.config.callback.run(:after_destroy, file_set.id, user)
end
|
#file_actor_class ⇒ Object
#revert_content(revision_id, relation = 'original_file') ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'app/actors/curation_concerns/actors/file_set_actor.rb', line 51
def revert_content(revision_id, relation = 'original_file')
file_actor = file_actor_class.new(file_set, relation, user)
if file_actor.revert_to(revision_id)
CurationConcerns.config.callback.run(:after_revert_content, file_set, user, revision_id)
true
else
false
end
end
|
#update_content(file, relation = 'original_file') ⇒ Object
63
64
65
66
67
|
# File 'app/actors/curation_concerns/actors/file_set_actor.rb', line 63
def update_content(file, relation = 'original_file')
file_actor_class.new(file_set, relation, user).ingest_file(file)
CurationConcerns.config.callback.run(:after_update_content, file_set, user)
true
end
|