Skip to content
Snippets Groups Projects
Commit ff427e21 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

refactoring learning object publisher

parent c57948fb
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,12 @@ class LearningObjectPublisher
#create a learning object with draft status
#if draft#type is 'external link', then the draft is published.
def create_draft(draft)
item = @dspace.collections.create_item(build_dspace_item(draft), id: DspaceService::TEST_COLLECTION)
item = create_dspace_item draft
# save on postgres
draft.id_dspace = item.id
draft.save!
publish! draft if draft.has_url_reference?
draft
end
......@@ -25,19 +28,23 @@ class LearningObjectPublisher
#this method will create thumbnails, change state to published and will save it.
def publish!(learning_object)
if learning_object.is_draft?
create_thumbnail! learning_object
#create_thumbnail! learning_object
learning_object.publish
end
learning_object.save
end
def create_thumbnail!(learning_object)
#call thumbnail worker
end
private
def create_dspace_item(draft)
item = @dspace.collections.create_item(build_dspace_item(draft), id: DspaceService::TEST_COLLECTION)
# update dspace metadata
metadata = [::Dspace::Metadata.new({'key' => 'dc.title', 'value' => draft.name, 'language' => draft.language.name}]
@dspace.items.add_metadata(metadata, id: item.id)
def create_thumbnail!(learning_object)
#call thumbnail worker
item
end
def build_dspace_item(draft)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment