Class: DwcOccurrencesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DwcOccurrencesController
- Defined in:
- app/controllers/dwc_occurrences_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
-
#api_index ⇒ Object
GET /api/v1/dwc_occurrences.json.
-
#attributes ⇒ Object
TODO: extract this all, unify with Concerns::IsData model, and re-use in DwcOccurrence.
- #collector_id_metadata ⇒ Object
-
#create ⇒ Object
TODO: remove.
-
#download ⇒ Object
GET /dwc_occurence/download.
-
#index ⇒ Object
.json only.
- #metadata ⇒ Object
- #predicates ⇒ Object
- #set_object ⇒ Object protected
- #status ⇒ Object
-
#sweep ⇒ Object
POST /dwc_occurrence/sweep (admin).
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_index ⇒ Object
GET /api/v1/dwc_occurrences.json
54 55 56 57 58 59 60 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 54 def api_index @dwc_occurrences = Queries::DwcOccurrence::Filter.new(params.merge!(api: true)) .all .where(project_id: sessions_current_project_id) .page(params[:page]).per(params[:per] || 1000) render '/dwc_occurrences/api/v1/index' end |
#attributes ⇒ Object
TODO: extract this all, unify with Concerns::IsData model, and re-use in DwcOccurrence
75 76 77 78 79 80 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 75 def attributes i = Queries::DwcOccurrence::Filter::ATTRIBUTES render json: ::DwcOccurrence.columns.select{ |a| i.include?(a.name.to_sym) }.collect{|b| {'name' => b.name, 'type' => b.type } } end |
#collector_id_metadata ⇒ Object
36 37 38 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 36 def render json: helpers. end |
#create ⇒ Object
TODO: remove
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 41 def create respond_to do |format| format.html do @object.set_dwc_occurrence # TODO: If sync is complete this is not needed. redirect_to browse_collection_objects_task_path(collection_object_id: @object.id) end format.json { render status: :found and return } end end |
#download ⇒ Object
GET /dwc_occurence/download
63 64 65 66 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 63 def download send_data Export::CSV.generate_csv( DwcOccurrence.where(project_id: sessions_current_project_id)), type: 'text', filename: "dwc_occurrence_#{DateTime.now}.tsv" end |
#index ⇒ Object
.json only
10 11 12 13 14 15 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 10 def index @dwc_occurrences = Queries::DwcOccurrence::Filter.new(params).all .where(project_id: sessions_current_project_id) .page(params[:page]) .per(params[:per] || 1) end |
#metadata ⇒ Object
17 18 19 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 17 def @dwc_occurrences = DwcOccurrence.where(project_id: sessions_current_project_id) end |
#predicates ⇒ Object
21 22 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 21 def predicates end |
#set_object ⇒ Object (protected)
84 85 86 87 88 89 90 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 84 def set_object @object = GlobalID::Locator.locate(params[:object_global_id]) if @object.nil? || (@object.project_id != sessions_current_project_id) render status: :not_found and return end end |
#status ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 24 def status if @object render json: { object: params[:object_global_id], id: @object.dwc_occurrence&.id, updated_at: @object.dwc_occurrence&.updated_at } else render json: {}, status: :unprocessable_entity end end |
#sweep ⇒ Object
POST /dwc_occurrence/sweep (admin)
69 70 71 72 |
# File 'app/controllers/dwc_occurrences_controller.rb', line 69 def sweep DwcOccurrence.sweep redirect_to administration_data_health_task_path and return end |