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

adding language repository and builders, adding language associations with...

adding language repository and builders, adding language associations with learning object, fixing form and controller to create learning objects properly

Signed-off-by: default avatarman13 <man13@inf.ufpr.br>
parent cff9823f
No related branches found
No related tags found
No related merge requests found
class LanguageBuilder < Builder
##
# receive a list of ids and return a list of languages
# useful for create a new learning object
#
def self.build(objects = [])
super(language_repository, objects, true, 'rid')
end
def self.build_from_orientdb(args = {})
super(args) do
obj = Language.new(
id: args['@rid'],
name: args['name'],
code: args['code']
)
obj
end
end
private
end
......@@ -23,6 +23,7 @@ class LearningObjectsController < ApplicationController
@school_levels = ['Educação Infantil', 'Ensino Fundamental', 'Ensino Médio']
@subjects = Subject.default_list
@types = learning_object_repository.types
@languages = language_repository.all
end
# GET /learning_objects/1/edit
......
class Language
include ActiveModel::Model
include RepositoriesProxy
include OrientDbSerializable
include Metadatable
attr_accessor :id, :name, :code
end
\ No newline at end of file
class OrientDb::Associations::LanguagesAssociation < OrientDb::Association
def can_create?
true
end
protected
def execute
create_edge("HasLang", @object.id, @object.language)
end
end
......@@ -4,7 +4,8 @@ class OrientDb::Associations::LearningObjectAssociations < OrientDb::Association
[
OrientDb::Associations::SubjectsAssociation.new(object, connection),
OrientDb::Associations::AttributesAssociation.new(object, connection),
OrientDb::Associations::PublisherAssociation.new(object, connection)
OrientDb::Associations::PublisherAssociation.new(object, connection),
OrientDb::Associations::LanguagesAssociation.new(object, connection)
]
end
......
require 'json'
module OrientDb
class LanguageRepository < Base
include OrientDb::Methods::SocialMethods
include OrientDb::Methods::EdgeMethods
include OrientDb::Methods::CountableMethods
include RepositoriesProxy
def all
result = connection.query("Select from Language")
build_objects result
end
end
end
......@@ -27,8 +27,8 @@
<%= f.label :description, "Descreva seu objeto" %>
<%= f.text_area :description, class: "form-control" %><br>
<%= f.label :language, "Idioma do objeto" %>
<%= f.text_field :language, class: "form-control" %><br>
<%= f.label :language, "Idioma do objeto" %><br>
<%= f.collection_select(:language, @languages, :id, :name, prompt: "Por favor informe o idioma do objeto ") %><br>
<%= f.label :author, "Autor" %>
<%= f.text_field :author, class: "form-control" %><br>
......
......@@ -4,6 +4,7 @@ orientdb_client = OrientdbService.create_client
repositories = {
learning_object: OrientDb::LearningObjectRepository.new(orientdb_client),
language: OrientDb::LanguageRepository.new(orientdb_client),
user: UserRepositoryProxy.new(OrientDb::UserRepository.new(orientdb_client)),
subject: OrientDb::SubjectRepository.new(orientdb_client),
institution: OrientDb::InstitutionRepository.new(orientdb_client),
......
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