Class: SearchController

Inherits:
ApplicationController show all
Defined in:
app/controllers/search_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/search_controller.rb', line 3

def index
  @rule =  SEARCHRULES[params[:rule]]
  result = @rule.model.query(@rule.fields, params)
  @features = result[:features]
  @quality = result[:quality]

  respond_to do |format|
    format.html # index.html.erb
    format.json { render :json => {:success => true, :features => features_for_json_reader(@features), :quality => @quality} }
  end
end

#soapObject



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
# File 'app/controllers/search_controller.rb', line 19

def soap
  soap_action = nil
  soap_params = nil
  if params[:Envelope] && params[:Envelope][:Body]
    params[:Envelope][:Body].each do |key, value|
      soap_action = key
      soap_params = value
    end
  end

  if soap_action.nil? || soap_params.nil?
    # TODO: error response
    render :xml => "Invalid SOAP request"
    return
  end

  @rule =  SEARCHRULES[params[:rule]]
  result = @rule.model.soap_query(@rule.fields, soap_params, soap_action)
  if result[:error]
    #TODO: error response
    render :xml => result[:error]
  else
    @feature = result[:feature]
    @hits = result[:hits]
    @quality = result[:quality]
    @features = result[:features]
    render result[:template]
  end
end

#soap_wsdlObject



15
16
17
# File 'app/controllers/search_controller.rb', line 15

def soap_wsdl
  render "#{params[:rule]}_wsdl.xml"
end