class Sufia::Arkivo::Actor
Attributes
item[R]
user[R]
Public Class Methods
new(user, item)
click to toggle source
# File lib/sufia/arkivo/actor.rb, line 14 def initialize(user, item) @user = user @item = item end
Public Instance Methods
create_work_from_item()
click to toggle source
# File lib/sufia/arkivo/actor.rb, line 19 def create_work_from_item work = Sufia.primary_work_type.new work_actor = CurationConcerns::CurationConcern.actor(work, user) create_attrs = attributes.merge(arkivo_checksum: item['file']['md5']) raise "Unable to create work. #{work.errors.messages}" unless work_actor.create(create_attrs) file_set = ::FileSet.new file_actor = ::CurationConcerns::Actors::FileSetActor.new(file_set, user) file_actor.create_metadata(work) file_set.label = item['file']['filename'] file_actor.create_content(file) # item['file']['contentType'] work end
destroy_work(work)
click to toggle source
# File lib/sufia/arkivo/actor.rb, line 45 def destroy_work(work) work.destroy end
update_work_from_item(work)
click to toggle source
# File lib/sufia/arkivo/actor.rb, line 34 def update_work_from_item(work) reset_metadata(work) work_actor = CurationConcerns::CurationConcern.actor(work, user) work_attributes = attributes.merge(arkivo_checksum: item['file']['md5']) work_actor.update(work_attributes) file_set = work.file_sets.first file_actor = ::CurationConcerns::Actors::FileSetActor.new(file_set, user) file_actor.update_content(file) work end
Private Instance Methods
attributes()
click to toggle source
# File lib/sufia/arkivo/actor.rb, line 71 def attributes Sufia::Arkivo::MetadataMunger.new(item['metadata']).call end
default_visibility()
click to toggle source
# File lib/sufia/arkivo/actor.rb, line 67 def default_visibility Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC end
extract_file_from_item()
click to toggle source
# File lib/sufia/arkivo/actor.rb, line 79 def extract_file_from_item encoded = item['file']['base64'] content = Base64.decode64(encoded) tmp = Tempfile.new(item['file']['md5'], encoding: Encoding::UTF_8) tmp.binmode tmp.original_filename = item['file']['filename'] tmp.content_type = item['file']['contentType'] tmp.write(content) tmp.rewind tmp end
file()
click to toggle source
# File lib/sufia/arkivo/actor.rb, line 75 def file extract_file_from_item end
reset_metadata(work)
click to toggle source
# File lib/sufia/arkivo/actor.rb, line 51 def reset_metadata(work) work.resource_type = [] work.title = [] work.rights = [] work.keyword = [] work.creator = [] work.description = [] work.publisher = [] work.date_created = [] work.based_near = [] work.identifier = [] work.related_url = [] work.language = [] work.contributor = [] end