Class: Tasks::DwcaImport::DwcaImportController

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

Instance Method Summary collapse

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#dwc_import_paramsObject (private)



41
42
43
44
45
# File 'app/controllers/tasks/dwca_import/dwca_import_controller.rb', line 41

def dwc_import_params
  params.require(:dwc_import).permit(
    :file, :name
  )
end

#indexObject

GET



5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/tasks/dwca_import/dwca_import_controller.rb', line 5

def index
  respond_to do |format|
    format.html
    format.json {
      @datasets = ImportDataset::DarwinCore
        .where(project_id: sessions_current_project_id)
        .order(:updated_at, :description)
        .page(params[:page]).per(params[:per] || 25)
    }
  end
end

#set_import_settingsObject

POST



22
23
24
25
26
27
28
# File 'app/controllers/tasks/dwca_import/dwca_import_controller.rb', line 22

def set_import_settings
  import_dataset = ImportDataset::DarwinCore::Occurrences.find(params[:import_dataset_id])
  settings = import_dataset.set_import_settings(params[:import_settings])
  import_dataset.save!

  render json: settings
end

#update_catalog_number_namespaceObject

POST



31
32
33
34
35
36
37
# File 'app/controllers/tasks/dwca_import/dwca_import_controller.rb', line 31

def update_catalog_number_namespace
  ImportDataset::DarwinCore::Occurrences
    .find(params[:import_dataset_id])
    .update_catalog_number_namespace(params[:institutionCode], params[:collectionCode], params[:namespace_id])

  render json: {success: true}
end

#uploadObject

POST



18
19
# File 'app/controllers/tasks/dwca_import/dwca_import_controller.rb', line 18

def upload
end