diff --git a/app/controllers/chunks_controller.rb b/app/controllers/chunks_controller.rb index 12e03b71f735624192073c259502fde1fe14d3cf..013100214b845aecc51481af0add02ca73f545ef 100644 --- a/app/controllers/chunks_controller.rb +++ b/app/controllers/chunks_controller.rb @@ -81,6 +81,6 @@ class ChunksController < ApplicationController end def set_learning_object - @learning_object = learning_object_repository.find params[:learning_object_id] + @learning_object = LearningObject.find params[:learning_object_id] end end diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 579ac97593418960f11e7cce6a570e003b3116ad..200883b22bad66c752d85c937e778c31cbb709b3 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -41,7 +41,7 @@ class CollectionsController < ApplicationController # POST /collections/1/like def like - collection_repository.like @collection + Collection.like @collection end # POST /collections @@ -63,7 +63,7 @@ class CollectionsController < ApplicationController # PATCH/PUT /collections/1.json def update respond_to do |format| - if collection_repository.update(collection_params) + if Collection.update(collection_params) format.html { redirect_to @collection, notice: 'Coleção atualizada com sucesso.' } else format.html { render :edit } @@ -74,7 +74,7 @@ class CollectionsController < ApplicationController # DELETE /collections/1 # DELETE /collections/1.json def destroy - collection_repository.destroy @collection + Collection.destroy @collection respond_to do |format| format.html { redirect_to me_users_path, notice: 'Coleção excluida com sucesso.' } @@ -187,7 +187,7 @@ class CollectionsController < ApplicationController def publishers_for(user) user_new = Institution.new() - user_new.id = user.rid + user_new.id = user.id user_new.name = user.name [user_new] + user.institutions diff --git a/app/controllers/concerns/reportable.rb b/app/controllers/concerns/reportable.rb index 32f51171804ab332cf141ed9b88e81b372e63bf1..d4f88d977b451fa46d3d1ad879238f9d379cf9a7 100644 --- a/app/controllers/concerns/reportable.rb +++ b/app/controllers/concerns/reportable.rb @@ -6,7 +6,7 @@ module Reportable end def report_object - learning_object_repository.report current_user, @learning_object, message, description + LearningObject.report current_user, @learning_object, message, description end def set_complaint_messages diff --git a/app/controllers/institutions_controller.rb b/app/controllers/institutions_controller.rb index 15c60d0212fde1e5f4dd7893a16bf9a1089d6191..645cc37c083958f49dd1f59676bd07435bb5e977 100644 --- a/app/controllers/institutions_controller.rb +++ b/app/controllers/institutions_controller.rb @@ -4,7 +4,7 @@ class InstitutionsController < ApplicationController # GET /institutions # GET /institutions.json def index - @institutions = institution_repository.all + @institutions = Institution.all end # GET /institutions/1 @@ -27,7 +27,7 @@ class InstitutionsController < ApplicationController @institution = Institution.new(institution_params) respond_to do |format| - if institution_repository.save @institution + if Institution.save @institution format.html { redirect_to @institution, notice: 'Institution was successfully created.' } else format.html { render :new } @@ -39,7 +39,7 @@ class InstitutionsController < ApplicationController # PATCH/PUT /institutions/1.json def update respond_to do |format| - if institution_repository.update(institution_params) + if Institution.update(institution_params) format.html { redirect_to @learning_object, notice: 'Institution was successfully updated.' } else format.html { render :edit } @@ -50,7 +50,7 @@ class InstitutionsController < ApplicationController # DELETE /institutions/1 # DELETE /institutions/1.json def destroy - institution_repository.destroy @institution + Institution.destroy @institution respond_to do |format| format.html { redirect_to institutions_url, notice: 'Learning object was successfully destroyed.' } diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index 61a4ec1d5e46274d8cf8ef1935bf2e0b2acb5f74..53e88d86e9c835f62bb1371799f6dc4e161d67e4 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -21,9 +21,9 @@ class LearningObjectsController < ApplicationController def new @learning_object = LearningObject.new @school_levels = ['Educação Infantil', 'Ensino Fundamental', 'Ensino Médio'] - @subjects = Subject.default_list + # @subjects = Subject.default_list @types = learning_object_repository.types - @languages = language_repository.all + # @languages = language_repository.all end # GET /learning_objects/1/edit @@ -56,7 +56,7 @@ class LearningObjectsController < ApplicationController # PATCH/PUT /learning_objects/1.json def update respond_to do |format| - if learning_object_repository.update(learning_object_params) + if LearningObject.update(learning_object_params) format.html { redirect_to @learning_object, notice: 'Learning object was successfully updated.' } else format.html { render :edit } @@ -67,7 +67,7 @@ class LearningObjectsController < ApplicationController # DELETE /learning_objects/1 # DELETE /learning_objects/1.json def destroy - learning_object_repository.destroy @learning_object + LearningObject.destroy @learning_object respond_to do |format| format.html { redirect_to learning_objects_url, notice: 'Learning object was successfully destroyed.' } @@ -96,7 +96,7 @@ class LearningObjectsController < ApplicationController def bookmarks bookmarks = current_user.bookmarks bookmarks.add @learning_object - collection_repository.save_learning_objects bookmarks + Collection.save_learning_objects bookmarks if request.xhr? render json: {id: params[:id]} diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index b957211398f5a696d79b14b2946cd8c4af2ea09f..8f3607b4a4f1064a16caff22049b05f8fdb97ad0 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -12,7 +12,7 @@ class SubjectsController < ApplicationController @general = [] mainPage = main_page_repository.all.first @general = mainPage["highlights"].take(3).collect do |id| - learning_object_repository.find(id) + LearningObject.find(id) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0d05825874299f4a0adc22779709c322c8ac3035..da4f52219c4a5d60a67c48389532fed96c25e518 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -47,7 +47,7 @@ class UsersController < ApplicationController end def set_user - @user = user_repository.find params[:id] + @user = User.find params[:id] end def check_current_user_page diff --git a/app/models/user.rb b/app/models/user.rb index 571f0048651b9a17914198a8f6a36598f3db24bf..91ffc60a9cdbb9a217e1293691a90c17bdc73c5f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -40,7 +40,7 @@ class User < ActiveRecord::Base private def default_role - # roles << role_repository.find_by_name("teacher") + roles << Role.find_by_name("teacher") end end diff --git a/app/workers/convert_video_worker.rb b/app/workers/convert_video_worker.rb index 6b5e2ab9f5bafa94d215e8f15ed75d622370cd9b..19669276ced266d202027f72ebf11b43261168dd 100644 --- a/app/workers/convert_video_worker.rb +++ b/app/workers/convert_video_worker.rb @@ -6,7 +6,7 @@ class ConvertVideoWorker def perform(id) begin - object = learning_object_repository.find id + object = LearningObject.find id dspace_client = DspaceService.create_client dspace_object = dspace_client.items.find(id: object.id_dspace, expand: 'bitstreams') diff --git a/app/workers/create_relations_worker.rb b/app/workers/create_relations_worker.rb index d232fea32b9e3e478eeb7a14944c12fb28bcb7f7..1f07b2278949fd4224bcf1ee30de8ca392c16a76 100644 --- a/app/workers/create_relations_worker.rb +++ b/app/workers/create_relations_worker.rb @@ -5,7 +5,7 @@ class CreateRelationsWorker def perform(learning_object_id, subjects, attributes) - learning_object = learning_object_repository.find(learning_object_id) + learning_object = LearningObject.find(learning_object_id) learning_object.subjects = [] learning_object.attributes = [] @@ -13,21 +13,21 @@ class CreateRelationsWorker subject = subject_repository.find_by_name(s["name"]) if subject.nil? subject = Subject.new(:name => s["name"]) - subject_repository.create(subject) + Subject.create(subject) end learning_object.subjects << subject end attributes.each do |a| - attribute = attribute_repository.find_by_key_and_value(a["key"], a["value"]).first + attribute = Attribute.find_by_key_and_value(a["key"], a["value"]).first if attribute.nil? attribute = Attribute.new(:key => a["key"], :value => a["value"]) - attribute_repository.create(attribute) + Attribute.create(attribute) end learning_object.attributes << attribute end - learning_object_repository.create_relations learning_object + LearningObject.create_relations learning_object end end diff --git a/app/workers/import_learning_object_worker.rb b/app/workers/import_learning_object_worker.rb index 12ffcd0a5f668f4ffbd8656755662c104dd088d7..1de8f0ea9ba7437d31234f12364e6a410bacf72e 100644 --- a/app/workers/import_learning_object_worker.rb +++ b/app/workers/import_learning_object_worker.rb @@ -4,7 +4,7 @@ class ImportLearningObjectWorker include RepositoriesProxy def perform(rid) - object = learning_object_repository.find(rid) + object = LearningObject.find(rid) LearningObject.create do |o| o.name = object.name diff --git a/app/workers/score_calculator_worker.rb b/app/workers/score_calculator_worker.rb index b0d02b1d31e877881c2888fca95a0993e2e9a763..82f9a880849bc2dd84cf97992f75cf32f703638a 100644 --- a/app/workers/score_calculator_worker.rb +++ b/app/workers/score_calculator_worker.rb @@ -4,7 +4,7 @@ class ScoreCalculatorWorker include RepositoriesProxy def perform(rid) - object = learning_object_repository.find(rid) + object = LearningObject.find(rid) unless object.blank? # Weights to score. Sum must be 1000 @@ -26,26 +26,26 @@ class ScoreCalculatorWorker # range to 250 points, for normalized likes ( maxLikes/actualLike => [0..1] ) score += divide_by_max( - learning_object_repository.count('Likes', object), - learning_object_repository.max('Likes'), + LearningObject.count('Likes', object), + LearningObject.max('Likes'), weights[:likes] ) # range to 200 points, for normalized views ( maxLikes/actualLike => [0..1] ) score += divide_by_max( - learning_object_repository.count('Views', object), - learning_object_repository.max('Views'), + LearningObject.count('Views', object), + LearningObject.max('Views'), weights[:views] ) # downloads score += divide_by_max( - learning_object_repository.count('Downloads', object), - learning_object_repository.max('Downloads'), + LearningObject.count('Downloads', object), + LearningObject.max('Downloads'), weights[:downloads] ) - learning_object_repository.update_property(object, 'score', score) + LearningObject.update_property(object, 'score', score) end end