Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
195dbc63
Commit
195dbc63
authored
9 years ago
by
Matheus Agio Nerone
Browse files
Options
Downloads
Patches
Plain Diff
add commentaries
Signed-off-by:
Matheus Agio Nerone
<
man13@inf.ufpr.br
>
parent
b0ce51db
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/learning_objects_controller.rb
+9
-3
9 additions, 3 deletions
app/controllers/learning_objects_controller.rb
with
9 additions
and
3 deletions
app/controllers/learning_objects_controller.rb
+
9
−
3
View file @
195dbc63
...
...
@@ -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",
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment