Class: Tasks::Dwc::DashboardController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Tasks::Dwc::DashboardController
- Includes:
- TaskControllerConfiguration
- Defined in:
- app/controllers/tasks/dwc/dashboard_controller.rb
Instance Method Summary collapse
- #accepted_name_mode_options ⇒ Object
- #checklist_extensions ⇒ Object
-
#create_index ⇒ Object
TODO: throttle to 5k.
- #generate_checklist_download ⇒ Object
-
#generate_download ⇒ Object
/tasks/dwc/dashboard/generate_download.json !! Run rails jobs:work in the terminal to complete builds.
-
#index ⇒ Object
DWC_TASK.
- #index_versions ⇒ Object
- #predicate_extension_params ⇒ Object private
- #taxonworks_extension_methods ⇒ Object
- #taxonworks_extension_params ⇒ Object private
Methods included from TaskControllerConfiguration
Instance Method Details
#accepted_name_mode_options ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 84 def = [ { value: ::Export::Dwca::Checklist::Data::REPLACE_WITH_ACCEPTED_NAME, label: 'Replace invalid names with valid names' }, { value: ::Export::Dwca::Checklist::Data::ACCEPTED_NAME_USAGE_ID, label: 'Classify synonyms using acceptedNameUsageID' } ] render json: , status: :ok end |
#checklist_extensions ⇒ Object
80 81 82 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 80 def checklist_extensions render json: ::Export::Dwca::Checklist::Data::CHECKLIST_EXTENSION_OPTIONS, status: :ok end |
#create_index ⇒ Object
TODO: throttle to 5k.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 59 def create_index q = ::Queries::CollectionObject::Filter.new(params) q.project_id = nil if q.all(true) q.project_id = sessions_current_project_id = ::Export::Dwca.build_index_async(CollectionObject, q.all) render json: , status: :ok else render json: {}, status: :unprocessable_content end end |
#generate_checklist_download ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 98 def generate_checklist_download core_otu_scope_params = Queries::Otu::Filter.new(params[:otu_query] || {}).params extensions = (params[:extensions] || []).map(&:to_sym) accepted_name_mode = params[:accepted_name_mode] || ::Export::Dwca::Checklist::Data::REPLACE_WITH_ACCEPTED_NAME description_topics = params[:description_topics] || [] download_name = params[:download_name].presence download_description = params[:download_description].presence @download = ::Export::Dwca.checklist_download_async( core_otu_scope_params, request.url, extensions:, accepted_name_mode:, description_topics:, download_name:, download_description:, project_id: sessions_current_project_id ) render '/downloads/show' end |
#generate_download ⇒ Object
/tasks/dwc/dashboard/generate_download.json !! Run rails jobs:work in the terminal to complete builds
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 10 def generate_download q = ::Queries::DwcOccurrence::Filter.new(params) biological_associations_query = nil if params[:biological_associations_extension] # TODO: this should include field occurrences as well, but they won't # actually be exported until core (q) includes field occurrences. biological_associations_query = { core_params: q.params, collection_objects_query: ::Queries::BiologicalAssociation::Filter.new( collection_object_query: ::Queries::CollectionObject::Filter.new( dwc_occurrence_query: q.params ).params ).all.to_sql } end media_query = nil if params[:media_extension] if sessions_current_project.api_access_token.nil? render json: { note: 'A project API Acess Token is required for exporting media - contact your project administrator for details' }, status: :unprocessable_content return end media_query = { collection_objects: ::Queries::CollectionObject::Filter.new( dwc_occurrence_query: q.params ).all.to_sql, field_occurrences: ::Queries::FieldOccurrence::Filter.new( dwc_occurrence_query: q.params ).all.to_sql } end @download = ::Export::Dwca.download_async( q.all, request.url, predicate_extensions: predicate_extension_params, taxonworks_extensions: taxonworks_extension_params, extension_scopes: { biological_associations: biological_associations_query, media: media_query }, project_id: sessions_current_project_id, user_id: sessions_current_user_id ) render '/downloads/show' end |
#index ⇒ Object
DWC_TASK
5 6 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 5 def index end |
#index_versions ⇒ Object
72 73 74 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 72 def index_versions render json: ::Export::Dwca::INDEX_VERSION, status: :ok end |
#predicate_extension_params ⇒ Object (private)
122 123 124 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 122 def predicate_extension_params params.permit(collecting_event_predicate_id: [], collection_object_predicate_id: []).to_h.symbolize_keys end |
#taxonworks_extension_methods ⇒ Object
76 77 78 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 76 def taxonworks_extension_methods render json: ::CollectionObject::DwcExtensions::TaxonworksExtensions::EXTENSION_FIELDS, status: :ok end |
#taxonworks_extension_params ⇒ Object (private)
126 127 128 129 |
# File 'app/controllers/tasks/dwc/dashboard_controller.rb', line 126 def taxonworks_extension_params a = params.permit(taxonworks_extension_methods: []).dig(:taxonworks_extension_methods) a&.map(&:to_sym) || [] end |