Class: FromHyraxController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/from_hyrax_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



27
28
29
30
31
32
33
# File 'app/controllers/from_hyrax_controller.rb', line 27

def create
  return unless instances.include? params[:repo]
  # go to: to_spotlight/receive
  @mappings = params[:transfer][:mappings].permit!.to_h.map { |_, v| v unless v['spotlight']['0'].empty? }.compact #use hash.values
  post_options = { transfer: params[:transfer], mappings: @mappings, token: token }
  @res = post_response URI("#{params[:repo]}/to_spotlight/receive"), post_options
end

#hyrax_apiObject



9
10
11
12
13
14
# File 'app/controllers/from_hyrax_controller.rb', line 9

def hyrax_api
  return nil unless instances.include?(params[:repo])
  uri = URI("#{params[:repo]}/to_spotlight/api/#{params[:api_type]}")
  response = get_response(uri)
  render html: response.body.html_safe
end

#indexObject



16
17
18
# File 'app/controllers/from_hyrax_controller.rb', line 16

def index
  instances
end

#newObject



20
21
22
23
24
25
# File 'app/controllers/from_hyrax_controller.rb', line 20

def new
  uri = URI("#{params[:repo]}/to_spotlight/api/fields")
  response = get_response(uri)
  @hyrax_fields = eval(response.body)
  @spotlight_fields = spotlight_fields.map { |f| [f[:label], f[:field_name]] }
end

#receiveObject



35
36
37
38
# File 'app/controllers/from_hyrax_controller.rb', line 35

def receive
  return unless params[:token] == token
  FromHyrax::RunImportJob.perform_later(params[:csv_url], csv_params)
end