Class: BiologicalAssociationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BiologicalAssociationsController
- Defined in:
- app/controllers/biological_associations_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #api_globi ⇒ Object
- #api_index ⇒ Object
- #api_index_extended ⇒ Object
- #api_index_simple ⇒ Object
- #api_resource_relationship ⇒ Object
- #api_show ⇒ Object
-
#batch_update ⇒ Object
PATCH /biological_associations/batch_update.json?biological_association_query=<>&biological_association={}.
- #biological_association_params ⇒ Object private
-
#create ⇒ Object
POST /biological_associations POST /biological_associations.json.
-
#destroy ⇒ Object
DELETE /biological_associations/1 DELETE /biological_associations/1.json.
-
#edit ⇒ Object
GET /biological_associations/1/edit.
-
#index ⇒ Object
GET /biological_associations GET /biological_associations.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /biological_associations/new.
- #search ⇒ Object
- #set_biological_association ⇒ Object private
-
#show ⇒ Object
GET /biological_associations/1 GET /biological_associations/1.json.
-
#update ⇒ Object
PATCH/PUT /biological_associations/1 PATCH/PUT /biological_associations/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#api_globi ⇒ Object
94 95 96 |
# File 'app/controllers/biological_associations_controller.rb', line 94 def api_globi render json: @biological_association.globi_extension_json, status: :ok end |
#api_index ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'app/controllers/biological_associations_controller.rb', line 102 def api_index q = ::Queries::BiologicalAssociation::Filter.new(params.merge!(api: true)).all .where(project_id: sessions_current_project_id) .order('biological_associations.id') respond_to do |format| format.json { @biological_associations = q.page(params[:page]).per(params[:per]) render '/biological_associations/api/v1/index' } format.csv { @biological_associations = q send_data Export::CSV.generate_csv( @biological_associations, exclude_columns: %w{updated_by_id created_by_id project_id}, ), type: 'text', filename: "biological_associations_#{DateTime.now}.tsv" } format.globi { if q.page(params[:page]).per(params[:per]).count < 1001 send_data Export::CSV::Globi.csv(q.page(params[:page]).per(params[:per])), type: 'text', filename: "biological_associations_globi_#{DateTime.now}.tsv" else render json: { msg: 'At present this format is only allowed for 1000 or less records.' }, status: :unprocessable_entity end } end end |
#api_index_extended ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'app/controllers/biological_associations_controller.rb', line 152 def api_index_extended @biological_associations = ::Queries::BiologicalAssociation::Filter.new(params.merge!(api: true)) .all .where(project_id: sessions_current_project_id) .order('biological_associations.id') .page(params[:page]) .per(params[:per]) respond_to do |format| format.json { render '/biological_associations/api/v1/extended' and return } format.csv { send_data Export::CSV::BiologicalAssociations::Extended.csv(@biological_associations), type: 'text', filename: "biological_associations_extended_#{DateTime.now}.tsv" } end end |
#api_index_simple ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'app/controllers/biological_associations_controller.rb', line 134 def api_index_simple @biological_associations = ::Queries::BiologicalAssociation::Filter.new(params.merge!(api: true)) .all .where(project_id: sessions_current_project_id) .order('biological_associations.id') .page(params[:page]) .per(params[:per]) respond_to do |format| format.json { render '/biological_associations/api/v1/simple' and return } format.csv { send_data Export::CSV::BiologicalAssociations::Simple.csv(@biological_associations), type: 'text', filename: "biological_associations_simple_#{DateTime.now}.tsv" } end end |
#api_resource_relationship ⇒ Object
98 99 100 |
# File 'app/controllers/biological_associations_controller.rb', line 98 def api_resource_relationship render json: @biological_association.globi_extension_json, status: :ok end |
#api_show ⇒ Object
90 91 92 |
# File 'app/controllers/biological_associations_controller.rb', line 90 def api_show render '/biological_associations/api/v1/show' end |
#batch_update ⇒ Object
PATCH /biological_associations/batch_update.json?biological_association_query=<>&biological_association={}
171 172 173 174 175 176 177 178 179 180 |
# File 'app/controllers/biological_associations_controller.rb', line 171 def batch_update if r = BiologicalAssociation.batch_update( preview: params[:preview], biological_association: biological_association_params.merge(by: sessions_current_user_id), biological_association_query: params[:biological_association_query] ) render json: r.to_json, status: :ok else render json: {}, status: :unprocessable_entity end end |
#biological_association_params ⇒ Object (private)
188 189 190 191 192 193 194 195 196 197 198 |
# File 'app/controllers/biological_associations_controller.rb', line 188 def biological_association_params params.require(:biological_association).permit( :biological_relationship_id, :biological_association_subject_id, :biological_association_subject_type, :biological_association_object_id, :biological_association_object_type, :subject_global_id, :object_global_id, :rotate, origin_citation_attributes: [:id, :_destroy, :source_id, :pages], citations_attributes: [:id, :is_original, :_destroy, :source_id, :pages, :citation_object_id, :citation_object_type], ) end |
#create ⇒ Object
POST /biological_associations POST /biological_associations.json
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/biological_associations_controller.rb', line 45 def create @biological_association = BiologicalAssociation.new(biological_association_params) respond_to do |format| if @biological_association.save format.html { redirect_to @biological_association, notice: 'Biological association was successfully created.' } format.json { render :show, status: :created, location: @biological_association } else format.html { render :new } format.json { render json: @biological_association.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /biological_associations/1 DELETE /biological_associations/1.json
74 75 76 77 78 79 80 |
# File 'app/controllers/biological_associations_controller.rb', line 74 def destroy @biological_association.destroy respond_to do |format| format.html { redirect_to biological_associations_url, notice: 'Biological association was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /biological_associations/1/edit
36 37 |
# File 'app/controllers/biological_associations_controller.rb', line 36 def edit end |
#index ⇒ Object
GET /biological_associations GET /biological_associations.json
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/biological_associations_controller.rb', line 9 def index respond_to do |format| format.html { @recent_objects = BiologicalAssociation.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' } format.json { @biological_associations = Queries::BiologicalAssociation::Filter.new(params) .all .where(project_id: sessions_current_project_id) .page(params[:page]) .per(params[:per]) } end end |
#list ⇒ Object
39 40 41 |
# File 'app/controllers/biological_associations_controller.rb', line 39 def list @biological_associations = BiologicalAssociation.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10) end |
#new ⇒ Object
GET /biological_associations/new
31 32 33 |
# File 'app/controllers/biological_associations_controller.rb', line 31 def new redirect_to edit_biological_associations_graph_task_path end |
#search ⇒ Object
82 83 84 85 86 87 88 |
# File 'app/controllers/biological_associations_controller.rb', line 82 def search if params[:id].blank? redirect_to biological_associations_path, alert: 'You must select an item from the list with a click or tab press before clicking show.' else redirect_to biological_association_path(params[:id]) end end |
#set_biological_association ⇒ Object (private)
184 185 186 |
# File 'app/controllers/biological_associations_controller.rb', line 184 def set_biological_association @biological_association = BiologicalAssociation.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /biological_associations/1 GET /biological_associations/1.json
27 28 |
# File 'app/controllers/biological_associations_controller.rb', line 27 def show end |
#update ⇒ Object
PATCH/PUT /biological_associations/1 PATCH/PUT /biological_associations/1.json
60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/biological_associations_controller.rb', line 60 def update respond_to do |format| if @biological_association.update(biological_association_params) format.html { redirect_to @biological_association, notice: 'Biological association was successfully updated.' } format.json { render :show, status: :ok, location: @biological_association } else format.html { render :edit } format.json { render json: @biological_association.errors, status: :unprocessable_entity } end end end |