Class: EasyDatasController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- EasyDatasController
- Defined in:
- lib/controllers/easy_datas_controller.rb
Instance Method Summary collapse
-
#access_to_data ⇒ Object
Information about access to publicated data.
- #authenticate_user ⇒ Object
- #custom_attributes ⇒ Object
- #custom_rdf ⇒ Object
- #custom_settings ⇒ Object
-
#faq ⇒ Object
FAQ.
-
#info_easy_data ⇒ Object
Show information about data publications.
-
#linked_data ⇒ Object
Generate Linked Data Graph.
- #load_linked_data_graph ⇒ Object
- #load_properties ⇒ Object
- #login ⇒ Object
- #logout ⇒ Object
- #model_attributes ⇒ Object
- #model_attributes_edit ⇒ Object
- #model_attributes_info ⇒ Object
- #refresh_information ⇒ Object
- #settings ⇒ Object
- #show ⇒ Object
- #show_all ⇒ Object
- #view_settings ⇒ Object
Instance Method Details
#access_to_data ⇒ Object
Information about access to publicated data
92 93 |
# File 'lib/controllers/easy_datas_controller.rb', line 92 def access_to_data end |
#authenticate_user ⇒ Object
280 281 |
# File 'lib/controllers/easy_datas_controller.rb', line 280 def authenticate_user end |
#custom_attributes ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/controllers/easy_datas_controller.rb', line 192 def custom_attributes rdf = ModelRdf.new @model = params[:model] params["rdf_type_attributes"].each do |att,value| rdf.update_attributes_model(params[:model],att,'namespace',value) if value != "" if params["attributes_property"] && !params["attributes_property"][att].nil? rdf.update_attributes_model(params[:model],att,'property',params["attributes_property"][att]) end rdf.update_attributes_model(params[:model],att,'privacy',params[:privacy][att]) end params["rdf_type_associations"].each do |assoc,value| if value != "" rdf.update_associations_model(params[:model],assoc,'namespace',value) end if params["associations_property"] && params["associations_property"][assoc] rdf.update_associations_model(params[:model],assoc,'property',params["associations_property"][assoc]) end rdf.update_associations_model(params[:model],assoc,'privacy',params[:privacy][assoc]) end rdf.update_model(params[:model],"privacy",params[:privacy][params[:model]]) if params[:privacy][params[:model]] if params[:property] rdf.update_model(params[:model],"namespace",params[:namespace][params[:model]]) rdf.update_model(params[:model],"property",params[:property][params[:model]]) end rdf.save @model_attributes = rdf.get_attributes_model(@model) render :partial => "model_attributes",:layout => nil end |
#custom_rdf ⇒ Object
103 104 105 106 107 |
# File 'lib/controllers/easy_datas_controller.rb', line 103 def custom_rdf @models = DataModels.load_models @settings ||= YAML::load(File.open("#{Rails.root}/config/easy_data/setting.yaml")) end |
#custom_settings ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/controllers/easy_datas_controller.rb', line 244 def custom_settings @settings = YAML::load(File.open("#{Rails.root}/config/easy_data/setting.yaml")) if !params["project"]["project"].empty? && params["project"]["project"]!=@settings["project"]["name"] @settings["project"]["name"] = params["project"]["project"] end if !params["project"]["logo"].empty? && params["project"]["logo"]!=@settings["project"]["logo"] @settings["project"]["logo"] = params["project"]["logo"] end if !params["project"]["description"].empty? && params["project"]["description"]!=@settings["project"]["description"] @settings["project"]["description"] = params["project"]["description"] end if !params["project"]["email"].empty? && params["project"]["email"]!=@settings["project"]["contact_email"] @settings["project"]["contact_email"] = params["project"]["email"] end if !params["user_admin"]["user"].empty? && !params["user_admin"]["pass"].empty? (@settings["user_admin"]["user"] = params["user_admin"]["user"]) if @settings["user_admin"]["user"]!=params["user_admin"]["user"] (@settings["user_admin"]["pass"] = params["user_admin"]["pass"]) if @settings["user_admin"]["pass"]!=params["user_admin"]["pass"] end (@settings["access"]["ip"] = params["access"]["ip"]) if params["access"]["ip"]!=@settings["access"]["ip"] && params["access"]["ip"]!= "" save_settings(@settings) render :template => "easy_datas/view_settings",:layout => false end |
#faq ⇒ Object
FAQ
100 101 |
# File 'lib/controllers/easy_datas_controller.rb', line 100 def faq end |
#info_easy_data ⇒ Object
Show information about data publications
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/controllers/easy_datas_controller.rb', line 75 def info_easy_data rdf = ModelRdf.new models = rdf.get_not_hidden_models @list = [] @settings ||= YAML::load(File.open("#{Rails.root}/config/easy_data/setting.yaml")) models.each do |mod| @list << "#{mod.gsub("::","_")}" end respond_to do |format| format.html format.xml end end |
#linked_data ⇒ Object
Generate Linked Data Graph
96 97 |
# File 'lib/controllers/easy_datas_controller.rb', line 96 def linked_data end |
#load_linked_data_graph ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/controllers/easy_datas_controller.rb', line 169 def load_linked_data_graph if params[:model] @model = params[:model] @associations = ModelRdf.new.get_associations_model(@model) @host = "http://"+request.env["HTTP_HOST"] render :partial => "linked_data_model" else rdf = ModelRdf.new models = [] DataModels.load_models.each do |mod| unless rdf.hidden?(mod) models << mod end end @list = [] models.each do |mod| @list << "#{mod.gsub("::","_")}" end render :partial => "linked_datas",:layout => nil end end |
#load_properties ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/controllers/easy_datas_controller.rb', line 139 def load_properties unless params[:id] == "" namespace = "EasyData::RDF::#{params[:id].upcase}" rdf = ModelRdf.new @namespace = params[:id] @model_attributes = rdf.get_attributes_model(params[:model]) properties = (eval namespace).properties_form if params[:attribute]!=params[:model] render :inline => "<span>Property:</span><%= select type+'_property',attribute,properties,{:prompt => 'Select a property...'} -%><span class='rdf_info'>(Current value: <%= current_value%>)</span>", :locals => {:properties => properties, :type => params[:type], :attribute => params[:attribute], :current_value => @model_attributes[params[:type]][params[:attribute]][:property]} else render :inline => "<span>Property:</span><%= select 'property',attribute,properties,{:prompt => 'Select a property...'} -%><span class='rdf_info'>(Current value: <%= current_value%>)</span><br />", :locals => {:properties => properties, :attribute => params[:model], :current_value => @model_attributes[:property]} end else render :inline => "" end end |
#login ⇒ Object
283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/controllers/easy_datas_controller.rb', line 283 def login @admin = YAML::load(File.open("#{Rails.root}/config/easy_data/setting.yaml")) if @admin["user_admin"]["user"] == params[:nick] && @admin["user_admin"]["password"] == params[:pass] @current_user = params[:nick] session[:easy_data_session] = params[:nick] redirect_to :action => "custom_rdf" else redirect_to :authenticate_user end end |
#logout ⇒ Object
295 296 297 298 299 |
# File 'lib/controllers/easy_datas_controller.rb', line 295 def logout @current_user = nil session[:easy_data_session]=nil if !session[:easy_data_session].nil? redirect_to :action => "authenticate_user" end |
#model_attributes ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'lib/controllers/easy_datas_controller.rb', line 109 def model_attributes rdf = ModelRdf.new @model_attributes = rdf.get_attributes_model(params[:model]) @model = params[:model] render :partial => "model_attributes",:layout => nil end |
#model_attributes_edit ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/controllers/easy_datas_controller.rb', line 118 def model_attributes_edit rdf = ModelRdf.new @model_attributes = rdf.get_attributes_model(params[:model]) @model = params[:model] @namespaces = EasyData::RDF::Namespaces.list_form render :partial => "model_attributes_edit",:layout => nil end |
#model_attributes_info ⇒ Object
130 131 132 133 134 135 136 137 |
# File 'lib/controllers/easy_datas_controller.rb', line 130 def model_attributes_info rdf = ModelRdf.new @model_attributes = rdf.get_attributes_model(params[:model]) @model = params[:model] render :partial => "model_attributes_info",:layout => nil end |
#refresh_information ⇒ Object
275 276 277 278 |
# File 'lib/controllers/easy_datas_controller.rb', line 275 def refresh_information EasyData.refresh_information redirect_to :action => "custom_rdf" end |
#settings ⇒ Object
238 239 240 241 242 |
# File 'lib/controllers/easy_datas_controller.rb', line 238 def settings @settings ||= YAML::load(File.open("#{Rails.root}/config/easy_data/setting.yaml")) @images = Dir["#{Rails.root}/public/images/*"].map{|img| [img.gsub("#{Rails.root}/public/images/",""),img.gsub("#{Rails.root}/public/images/","")]} render :partial => "settings",:layout => nil end |
#show ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/controllers/easy_datas_controller.rb', line 10 def show begin model = (eval params[:model].to_s) conditions = parser_params(params) rdf = ModelRdf.new no_valid = lambda{|c| c.nil?||c.empty?} @reply = model.find :all, :conditions => {:id => params[:id]} unless @reply.nil? @host="http://"+request.env["HTTP_HOST"] @rdf_model = rdf.get_model_rdf(@reply,params[:model],"http://"+request.env["HTTP_HOST"]) end @xml = Builder::XmlMarkup.new if no_valid.call(@rdf_model[:header]) || @reply.nil? # If the URI not available or data no publicated render :nothing => true, :status => 400 else respond_to do |format| format.html format.xml # render :template => "/rdf/request.xml.builder" end end rescue render :nothing => true, :status => 404 end end |
#show_all ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/controllers/easy_datas_controller.rb', line 43 def show_all begin model = eval params[:model].to_s rdf = ModelRdf.new no_valid = lambda{|c| c.nil?||c.empty?} @reply = model.find :all || nil @host="http://"+request.env["HTTP_HOST"] @rdf_model = rdf.get_model_rdf(@reply,params[:model],"http://"+request.env["HTTP_HOST"]) @xml = Builder::XmlMarkup.new if no_valid.call(@rdf_model[:header]) || @reply.nil? # If the URI not available or data no publicated render :nothing => true, :status => 404 else respond_to do |format| format.html format.xml # render :template => "/rdf/request.xml.builder" end end rescue render :nothing => true, :status => 404 end end |
#view_settings ⇒ Object
233 234 235 236 |
# File 'lib/controllers/easy_datas_controller.rb', line 233 def view_settings @settings ||= YAML::load(File.open("#{Rails.root}/config/easy_data/setting.yaml")) render :template => "easy_datas/view_settings", :layout => false end |