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

remove save method from learning object repository and improve create method

parent f795811a
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,6 @@ module OrientDb ...@@ -25,7 +25,6 @@ module OrientDb
# Usage: # Usage:
# learning_object = repository.for(:learning_objects).get_by_dspace_id 123 # learning_object = repository.for(:learning_objects).get_by_dspace_id 123
#
def get_by_dspace_id(id_dspace) def get_by_dspace_id(id_dspace)
result = select_by_property(odb_class, "id_dspace", id_dspace) result = select_by_property(odb_class, "id_dspace", id_dspace)
build_object result.first build_object result.first
...@@ -58,17 +57,6 @@ module OrientDb ...@@ -58,17 +57,6 @@ module OrientDb
attribute_repository.find_all_by_learning_object learning_object attribute_repository.find_all_by_learning_object learning_object
end end
def create_relations(learning_object)
relations = OrientDb::LearningObject::RelationsChain.new(learning_object, connection)
relations.create
end
def save(learning_object)
if learning_object.valid?
connection.command "INSERT INTO LearningObject CONTENT #{learning_object.to_json}"
end
end
def types def types
Rails.cache.fetch("learning_object/types", expires_in: 1.days) do Rails.cache.fetch("learning_object/types", expires_in: 1.days) do
query = "SELECT DISTINCT(type) FROM LearningObject GROUP BY type" query = "SELECT DISTINCT(type) FROM LearningObject GROUP BY type"
...@@ -80,5 +68,18 @@ module OrientDb ...@@ -80,5 +68,18 @@ module OrientDb
end end
end end
def create(object)
super(object)
create_relations object
object
end
private
def create_relations(learning_object)
relations = OrientDb::Associations::LearningObjectAssociations.new(learning_object, connection)
relations.create
end
end end
end end
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