Class: ExplorerController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ExplorerController
- Defined in:
- app/controllers/explorer_controller.rb
Overview
require “rdb_concat”
Instance Method Summary collapse
- #add_keyname ⇒ Object
- #categorized_search ⇒ Object
- #del_keyname ⇒ Object
- #get_keyvalue ⇒ Object
- #index ⇒ Object
- #nodetype_selection ⇒ Object
- #queryconditions_selection ⇒ Object
- #search(querytype, desc) ⇒ Object
- #search_freeword ⇒ Object
- #search_kname ⇒ Object
- #search_kw ⇒ Object
- #search_path ⇒ Object
- #search_space ⇒ Object
- #search_time ⇒ Object
Instance Method Details
#add_keyname ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/explorer_controller.rb', line 22 def add_keyname @results=session[:results] @results.keynames.push(params[:keyname]) @results.keynames.uniq! session[:results]=@results valuelist=@results.get_keyvalue_list(params[:keyname]) if valuelist.size>0 then render :update do |page| valuelist.each{ |v| page.insert_html(:bottom,"kw_#{params[:keyname]}","<li><a href=\"/explorer/search_kw?keyname=#{params[:keyname]}&keyvalue=#{v.value}\">#{v.value}(#{v.cnt})</a></li>") } page.show("kw_#{params[:keyname]}_close") end end end |
#categorized_search ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'app/controllers/explorer_controller.rb', line 158 def categorized_search descriptions=Array.new queries=params[:query] queries.keys.each{|k| if queries[k]!=nil then descriptions.push(queries[k]) end } =Hash.new if params["show_kwfacets"] then ["show_kwfacets"]=params["show_kwfacets"] else ["show_kwfacets"]=0 end if params["show_kwvalues"] then ["show_kwvalues"]=params["show_kwvalues"] else ["show_kwvalue"]=0 end if params["show_spfacets"] then ["show_spfacets"]=params["show_spfacets"] else ["show_spfacets"]=0 end user = (login=session[:user]) && User.find_by_login(login) eq=ExplorerQuery.new qstr = eq.make_query(descriptions,user) rnodes=Node.find_by_sql(qstr) expres=ExplorerResult.new(-1) expres.put_results(rnodes) session[:result]=expres results=eq.generate_results(rnodes,expres,) render :xml => results end |
#del_keyname ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/explorer_controller.rb', line 38 def del_keyname @results=session[:results] @results.keynames.delete(params[:keyname]) session[:results]=@results render :update do |page| page.replace_html("kw_#{params[:keyname]}","") page.hide("kw_#{params[:keyname]}_close") end end |
#get_keyvalue ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/explorer_controller.rb', line 47 def get_keyvalue @results=ExplorerResult.new(0) # @results=session[:result] @results.keynames.push(params["keyname"]) @results.keynames.uniq! session[:result]=@results @valuelist=@results.get_keyvalue_list(params["keyname"]) render :xml=>@valuelist end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/explorer_controller.rb', line 7 def index session[:previd]=nil @previd=nil @qargs=nil @results=ExplorerResult.new(0) @queryconditions=Array.new session[:results]=@results session[:result]=@results session[:qsetid]=1 session[:queryconditions]=@queryconditions session[:qcond_selection]=Array.new session[:nodetype_selection]=Array.new session[:qcno]=0 end |
#nodetype_selection ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'app/controllers/explorer_controller.rb', line 110 def nodetype_selection num=0 types=Array.new @nodetypes=Hash.new ntypes=["data","knowledge","function","draw_method"] ntypes.each{ |nt| value=params["nodetype_#{nt}"] if value then if params["nodetype_#{nt}"]=="1" then types.push(nt) num=num+1 @nodetypes[nt]=1 else @nodetypes[nt]=0 end else @nodetypes[nt]=0 end } if num==0 then redirect_to :action=>"index" else types_str=types.join(",") search("nodetype","[N]#{types_str}") end end |
#queryconditions_selection ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'app/controllers/explorer_controller.rb', line 93 def queryconditions_selection num=0 for i in 0..session[:qcno].to_i-1 if params["qcond_selection_#{i}"]=="1" then session[:qcond_selection][i]=1 num=num+1 else session[:qcond_selection][i]=0 end end if num==0 then redirect_to :action=>"index" else search("qcond_selection",params[:queryset_id].to_i) end end |
#search(querytype, desc) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'app/controllers/explorer_controller.rb', line 137 def search(querytype,desc) if session[:queryconditions] then @queryconditions=session[:queryconditions] if querytype!="qcond_selection" then @queryconditions.push(desc) end end user = (login=session[:user]) && User.find_by_login(login) eq=ExplorerQuery.new qstr = eq.make_query(@queryconditions,user) if qstr!="" then @results=ExplorerResult.new(@qsetid) @results.put_results(Node.find_by_sql(qstr)) end session[:results]=@results render :action=>"index.rhtml" end |
#search_freeword ⇒ Object
66 67 68 69 |
# File 'app/controllers/explorer_controller.rb', line 66 def search_freeword desc="[F]#{params[:freeword]}" search("freeword",desc) end |
#search_kname ⇒ Object
78 79 80 81 |
# File 'app/controllers/explorer_controller.rb', line 78 def search_kname desc="[K]#{params[:keyname]}" search("keyname",desc) end |
#search_kw ⇒ Object
72 73 74 75 |
# File 'app/controllers/explorer_controller.rb', line 72 def search_kw desc="[K]#{params[:keyname]}=#{params[:keyvalue]}" search("keyword",desc) end |
#search_path ⇒ Object
61 62 63 64 |
# File 'app/controllers/explorer_controller.rb', line 61 def search_path desc="[P]#{params[:path]}" search("path",desc) end |
#search_space ⇒ Object
83 84 85 86 |
# File 'app/controllers/explorer_controller.rb', line 83 def search_space desc = "[S](#{params[:start_lon]},#{params[:start_lat]})-(#{params[:end_lon]},#{params[:end_lat]})" search("space",desc) end |
#search_time ⇒ Object
88 89 90 91 |
# File 'app/controllers/explorer_controller.rb', line 88 def search_time desc="[T]#{params[:starttime]}~#{params[:endtime]}" search("time",desc) end |