Skip to content
Snippets Groups Projects
Commit 195dbc63 authored by Matheus Agio Nerone's avatar Matheus Agio Nerone
Browse files

add commentaries

parent b0ce51db
No related branches found
No related tags found
No related merge requests found
......@@ -30,17 +30,18 @@ class LearningObjectsController < ApplicationController
# POST /learning_objects
# POST /learning_objects.json
def create
# Create struct with id of the collection
collection_struct = Struct.new(:id)
collection = collection_struct.new('4')
repo = Dspace::Client.instance.repository.collection_repository
strategy = DSpaceRest::Strategies::Uploads::CurlStrategy.new(repo.rest_client.url,repo.rest_client.options[:headers][:rest_dspace_token])
# Manage the attributes necessary to create a new Item
args = {}
args['name'] = learning_object_params[:name]
args['type'] = learning_object_params[:type]
args['last_modified'] = Time.now.to_s
args['metadata'] = []
# trata o form do learning object
params[:learning_object][:date_created] = Time.now
params[:learning_object][:date_available] = Time.now
params[:learning_object][:type] = get_file_type params[:learning_object][:file]
......@@ -58,15 +59,20 @@ class LearningObjectsController < ApplicationController
end
end
response = repo.create_item_for(collection, lo)
# Now upload the file to the create item in DSpace
file = params[:learning_object][:file]
bitstream_response = {}
repo = Dspace::Client.instance.repository.item_repository
dspace_bitstream_response = repo.create_bitstream_for(response, file.tempfile.path, strategy).as_json
dspace_bitstream_response.each do |v,k|
bitstream_response[v.camelize(:lower)] = k
end
# repo = Dspace::Client.instance.repository.bitstream_repository
# bitstream_response["name"] = file.original_filename
# bitstream_response["format"] = file.content_type
# repo.update(DSpaceRest::Bitstream.new bitstream_response)
# Create the object inside OrientDB
subjects = []
params[:learning_object][:subjects].each do |subject|
subjects << subject_repository.find_by_name(subject)
......@@ -174,11 +180,11 @@ class LearningObjectsController < ApplicationController
"dc.contributor.author" => "author",
"dc.date.accessioned" => "date_created",
"dc.date.available" => "date_available",
#dc.identifier.uri
"dc.language" => "language",
"dc.title" => "name",
"dc.type" => "type",
"dc.subject.category" => "subjects"
# dc.identifier.uri
# "dc.description" => "description",
# "dc.source" => "source",
# "dc.date.issued" => "date",
......
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