Class: Tasks::ControlledVocabularies::BiocurationController

Inherits:
ApplicationController
  • Object
show all
Includes:
TaskControllerConfiguration
Defined in:
app/controllers/tasks/controlled_vocabularies/biocuration_controller.rb

Instance Method Summary collapse

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#build_biocuration_groupObject

POST build_biocuration_group_path



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/tasks/controlled_vocabularies/biocuration_controller.rb', line 11

def build_biocuration_group
  t = Tag.new(params.require(:tag).permit(:keyword_id, :tag_object_type, :tag_object_id))
  t.save
  if t.valid?
    flash[:notice] = "Successfully added bicoruation class '#{t.keyword.name}' to biocuration group '#{t.tag_object.name}'."
  else
    flash[:notice] = 'Failed to add biocuration class to biocuration group.'
  end
  redirect_to build_biocuration_groups_task_path
end

#build_collectionObject

GET build_biocuration_groups_task_path



7
8
# File 'app/controllers/tasks/controlled_vocabularies/biocuration_controller.rb', line 7

def build_collection
end

#controlled_vocabulary_term_paramsObject (protected)



55
56
57
# File 'app/controllers/tasks/controlled_vocabularies/biocuration_controller.rb', line 55

def controlled_vocabulary_term_params
  params.require(:controlled_vocabulary_term).permit(:type, :name, :definition, :uri, :uri_relation)
end

#create_biocuration_classObject



33
34
35
36
37
38
39
40
41
# File 'app/controllers/tasks/controlled_vocabularies/biocuration_controller.rb', line 33

def create_biocuration_class
  biocuration_class = BiocurationClass.new(controlled_vocabulary_term_params)
  if biocuration_class.save
    redirect_to build_biocuration_groups_task_path, notice: "Successfully added biocuration class #{biocuration_class.name}" 
  else
    @new_biocuration_class = biocuration_class
    render 'build_collection' 
  end
end

#create_biocuration_groupObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/tasks/controlled_vocabularies/biocuration_controller.rb', line 23

def create_biocuration_group
  biocuration_group = BiocurationGroup.new(controlled_vocabulary_term_params)
  if biocuration_group.save
    redirect_to build_biocuration_groups_task_path, notice: "Successfully added biocuration group #{biocuration_group.name}" 
  else
    @new_biocuration_group = biocuration_group
    render 'build_collection' 
  end
end

#set_view_variablesObject (protected)



45
46
47
48
49
50
51
52
53
# File 'app/controllers/tasks/controlled_vocabularies/biocuration_controller.rb', line 45

def set_view_variables
  @new_biocuration_group = BiocurationGroup.new
  @new_biocuration_class = BiocurationClass.new
  @biocuration_groups = BiocurationGroup.with_project_id(sessions_current_project_id).all
  @biocuration_classes = BiocurationClass.with_project_id(sessions_current_project_id)
  @available_biocuration_classes = @biocuration_groups.inject({}) {|hsh, bg| hsh.merge( bg =>  (@biocuration_classes - bg.biocuration_classes) )  }
  @biocuration_classes_without_groups = @biocuration_classes.without_tags 
  @new_tag = Tag.new
end