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)



52
53
54
55
56
# File 'app/controllers/tasks/dwca_import/dwca_import_controller.rb', line 52

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

#indexObject

GET



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

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



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

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

  render json: settings
end

#update_catalog_number_collection_code_namespaceObject

POST



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

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

  render json: {success: true}
end

#update_catalog_number_namespaceObject

POST



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

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



20
21
# File 'app/controllers/tasks/dwca_import/dwca_import_controller.rb', line 20

def upload
end