easy_data 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +3 -10
- data/Rakefile +0 -4
- data/lib/controllers/easy_datas_controller.rb +117 -27
- data/lib/data_models/data_models.rb +22 -4
- data/lib/data_models/linked_data_graph.rb +83 -0
- data/lib/data_models/model_rdf.rb +6 -4
- data/lib/easy_data/tasks.rb +50 -3
- data/lib/easy_data/templates/easy_datas/_data_publications.html.erb +16 -0
- data/lib/easy_data/templates/easy_datas/_linked_data_model.html.erb +1 -0
- data/lib/easy_data/templates/easy_datas/_linked_datas.html.erb +18 -0
- data/lib/easy_data/templates/easy_datas/_menu.html.erb +8 -0
- data/lib/easy_data/templates/easy_datas/_model_attributes_info.html.erb +16 -0
- data/lib/easy_data/templates/easy_datas/authenticate_user.html.erb +14 -0
- data/lib/easy_data/templates/easy_datas/custom_rdf.html.erb +2 -1
- data/lib/easy_data/templates/easy_datas/info_easy_data.html.erb +7 -0
- data/lib/easy_data/templates/easy_datas/show.xml.builder +1 -1
- data/lib/easy_data/templates/easy_datas/show_all.html.erb +1 -0
- data/lib/easy_data/templates/easy_datas/show_all.xml.builder +16 -0
- data/lib/easy_data/templates/images/easy_data_logo.png +0 -0
- data/lib/easy_data/templates/layouts/easy_data_layout.html.erb +1 -1
- data/lib/easy_data/templates/stylesheets/easy_data_style.css +6 -2
- data/lib/easy_data/version.rb +1 -1
- data/lib/easy_data.rb +9 -23
- data/lib/routes.rb +23 -23
- data/lib/tasks/testing_installation.rb +2 -2
- metadata +15 -4
data/README
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
Installation
|
|
2
2
|
===============
|
|
3
3
|
|
|
4
|
-
copy this lines to config/environment.rb:
|
|
5
|
-
|
|
6
|
-
begin
|
|
7
|
-
require "easy_data"
|
|
8
|
-
rescue LoadError
|
|
9
|
-
end
|
|
10
|
-
|
|
11
4
|
In config/routes.rb at the end of routes declarations include:
|
|
12
5
|
|
|
13
|
-
EasyDataRouting.routes(map)
|
|
6
|
+
EasyDataRouting.routes(map)
|
|
14
7
|
|
|
15
8
|
After, in [RAILS_HOME]/Rakefile copy this line:
|
|
16
9
|
|
|
17
|
-
require "easy_data/tasks"
|
|
10
|
+
require "easy_data/tasks"
|
|
18
11
|
|
|
19
12
|
At the end, execute the next task:
|
|
20
13
|
|
|
21
|
-
rake easy_data:install RAILS_ENV=development
|
|
14
|
+
rake easy_data:install RAILS_ENV=development
|
|
22
15
|
|
|
23
16
|
Commandas and Query
|
|
24
17
|
======================
|
data/Rakefile
CHANGED
|
@@ -5,43 +5,80 @@ require "builder"
|
|
|
5
5
|
class EasyDatasController < ActionController::Base
|
|
6
6
|
|
|
7
7
|
layout 'easy_data_layout'
|
|
8
|
+
|
|
9
|
+
before_filter :authenticated, :only => [:custom_rdf]
|
|
8
10
|
|
|
9
11
|
def show
|
|
10
|
-
|
|
11
|
-
# begin
|
|
12
|
+
|
|
12
13
|
model = eval params[:model].to_s
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
conditions = parser_params(params)
|
|
16
|
+
|
|
14
17
|
rdf = ModelRdf.new
|
|
15
|
-
|
|
18
|
+
|
|
16
19
|
unless conditions.empty?
|
|
17
|
-
@reply = model.find :all, :conditions => conditions
|
|
18
|
-
else
|
|
19
|
-
@reply = model.find :all
|
|
20
|
+
@reply = model.find :all, :conditions => conditions || nil
|
|
20
21
|
end
|
|
22
|
+
|
|
21
23
|
@host="http://"+request.env["HTTP_HOST"]
|
|
22
24
|
|
|
23
25
|
@rdf_model = rdf.get_model_rdf(@reply,params[:model],"http://"+request.env["HTTP_HOST"])
|
|
24
26
|
|
|
25
27
|
@xml = Builder::XmlMarkup.new
|
|
28
|
+
|
|
26
29
|
respond_to do |format|
|
|
27
30
|
format.html
|
|
28
31
|
format.xml # render :template => "/rdf/request.xml.builder"
|
|
29
32
|
end
|
|
30
|
-
|
|
31
|
-
# rescue
|
|
32
|
-
# raise ActionController::RoutingError.new('Not Found')
|
|
33
|
-
# end
|
|
34
|
-
|
|
33
|
+
|
|
35
34
|
end
|
|
36
35
|
|
|
37
|
-
def
|
|
36
|
+
def show_all
|
|
37
|
+
model = eval params[:model].to_s
|
|
38
|
+
|
|
39
|
+
rdf = ModelRdf.new
|
|
40
|
+
|
|
41
|
+
@reply = model.find :all
|
|
42
|
+
|
|
43
|
+
@host="http://"+request.env["HTTP_HOST"]
|
|
44
|
+
|
|
45
|
+
@rdf_model = rdf.get_model_rdf(@reply,params[:model],"http://"+request.env["HTTP_HOST"])
|
|
46
|
+
|
|
47
|
+
@xml = Builder::XmlMarkup.new
|
|
48
|
+
|
|
49
|
+
respond_to do |format|
|
|
50
|
+
format.html
|
|
51
|
+
format.xml # render :template => "/rdf/request.xml.builder"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Show information about data publications
|
|
56
|
+
#
|
|
57
|
+
#
|
|
58
|
+
def info_easy_data
|
|
38
59
|
models = DataModels.load_models
|
|
39
|
-
list =
|
|
60
|
+
@list = []
|
|
61
|
+
|
|
40
62
|
models.each do |mod|
|
|
41
|
-
list
|
|
63
|
+
@list << "#{mod.gsub("::","_")}"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
respond_to do |format|
|
|
67
|
+
format.html
|
|
68
|
+
format.xml
|
|
42
69
|
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Information about access to publicated data
|
|
73
|
+
def access_to_data
|
|
74
|
+
end
|
|
43
75
|
|
|
44
|
-
|
|
76
|
+
# Generate Linked Data Graph
|
|
77
|
+
def linked_data
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# FAQ
|
|
81
|
+
def faq
|
|
45
82
|
end
|
|
46
83
|
|
|
47
84
|
def custom_rdf
|
|
@@ -71,6 +108,15 @@ class EasyDatasController < ActionController::Base
|
|
|
71
108
|
|
|
72
109
|
end
|
|
73
110
|
|
|
111
|
+
def model_attributes_info
|
|
112
|
+
rdf = ModelRdf.new
|
|
113
|
+
|
|
114
|
+
@model_attributes = rdf.get_attributes_model(params[:model])
|
|
115
|
+
@model = params[:model]
|
|
116
|
+
|
|
117
|
+
render :partial => "model_attributes_info",:layout => nil
|
|
118
|
+
end
|
|
119
|
+
|
|
74
120
|
def load_properties
|
|
75
121
|
|
|
76
122
|
unless params[:id] == ""
|
|
@@ -92,8 +138,25 @@ class EasyDatasController < ActionController::Base
|
|
|
92
138
|
render :inline => ""
|
|
93
139
|
end
|
|
94
140
|
end
|
|
95
|
-
|
|
141
|
+
|
|
142
|
+
def load_linked_data_graph
|
|
143
|
+
if params[:model]
|
|
144
|
+
@model = params[:model]
|
|
145
|
+
render :partial => "linked_data_model"
|
|
146
|
+
else
|
|
147
|
+
models = DataModels.load_models
|
|
148
|
+
@list = []
|
|
149
|
+
|
|
150
|
+
models.each do |mod|
|
|
151
|
+
@list << "#{mod.gsub("::","_")}"
|
|
152
|
+
end
|
|
96
153
|
|
|
154
|
+
render :partial => "linked_datas",:layout => nil
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def custom_attributes
|
|
159
|
+
|
|
97
160
|
rdf = ModelRdf.new
|
|
98
161
|
@model = params[:model]
|
|
99
162
|
|
|
@@ -120,22 +183,49 @@ class EasyDatasController < ActionController::Base
|
|
|
120
183
|
render :partial => "model_attributes",:layout => nil
|
|
121
184
|
end
|
|
122
185
|
|
|
186
|
+
def authenticate_user
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def login
|
|
190
|
+
admin = YAML::load(File.open("#{RAILS_ROOT}/config/easy_data/setting.yaml"))
|
|
191
|
+
|
|
192
|
+
if admin["user_admin"]["user"] == params[:nick] && admin["user_admin"]["password"] == params[:pass]
|
|
193
|
+
@current_user = params[:nick]
|
|
194
|
+
session[:easy_data_session] = params[:nick]
|
|
195
|
+
redirect_to :action => "custom_rdf"
|
|
196
|
+
else
|
|
197
|
+
redirect_to :authenticate_user
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def logout
|
|
202
|
+
@current_user = nil
|
|
203
|
+
session[:easy_data_session]=nil if !session[:easy_data_session].nil?
|
|
204
|
+
redirect_to :action => "authenticate_user"
|
|
205
|
+
end
|
|
206
|
+
|
|
123
207
|
private
|
|
124
208
|
|
|
125
|
-
def parser_params (
|
|
209
|
+
def parser_params (parameters = nil)
|
|
126
210
|
|
|
127
211
|
conditions = {}
|
|
128
|
-
|
|
129
|
-
if
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
p = p.split(':')
|
|
135
|
-
conditions[p[0].downcase.to_sym] = p[1]
|
|
212
|
+
|
|
213
|
+
if !parameters.empty?
|
|
214
|
+
parameters.each do |key,value|
|
|
215
|
+
unless ["controller","action","method","format","model"].include?key
|
|
216
|
+
conditions[key.to_sym] = value
|
|
217
|
+
end
|
|
136
218
|
end
|
|
137
|
-
return conditions
|
|
138
219
|
end
|
|
220
|
+
|
|
221
|
+
return conditions
|
|
222
|
+
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def authenticated
|
|
226
|
+
if session[:easy_data_session].nil?
|
|
227
|
+
redirect_to :action => "authenticate_user"
|
|
228
|
+
end
|
|
139
229
|
end
|
|
140
230
|
|
|
141
231
|
end
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
module DataModels
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
def self.load_models
|
|
4
|
+
|
|
4
5
|
models = []
|
|
5
|
-
|
|
6
|
+
models_valids = []
|
|
7
|
+
mod = nil
|
|
8
|
+
|
|
6
9
|
Dir["#{RAILS_ROOT}/app/models/**/*.rb"].each do |file|
|
|
7
10
|
models << file.gsub(RAILS_ROOT+'/app/models/',"").gsub('.rb','').classify
|
|
8
11
|
end
|
|
9
|
-
|
|
10
|
-
models
|
|
12
|
+
|
|
13
|
+
models.each do |model|
|
|
14
|
+
begin
|
|
15
|
+
mod = eval model
|
|
16
|
+
rescue
|
|
17
|
+
begin
|
|
18
|
+
mod = eval model.pluralize
|
|
19
|
+
rescue
|
|
20
|
+
mod = nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
if mod
|
|
24
|
+
models_valids << mod.to_s
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
models_valids
|
|
11
29
|
end
|
|
12
30
|
|
|
13
31
|
def self.model_attributes(model)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
class LinkedDataGraph
|
|
2
|
+
|
|
3
|
+
def self.build(models)
|
|
4
|
+
|
|
5
|
+
models.each do |model|
|
|
6
|
+
graph = {}
|
|
7
|
+
|
|
8
|
+
#graph[:models] = get_attributes_ponderations(models)
|
|
9
|
+
graph[:assoc] = get_associations(model)
|
|
10
|
+
|
|
11
|
+
generate_graph(graph,model) if !graph[:assoc].empty?
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def self.get_attributes_ponderations(model)
|
|
18
|
+
associations = {}
|
|
19
|
+
|
|
20
|
+
model = eval model
|
|
21
|
+
if model.respond_to?:reflections
|
|
22
|
+
associations[model.to_s.gsub("::","_")] = model.reflections.count
|
|
23
|
+
else
|
|
24
|
+
associations[model.to_s.gsub("::","_")] = 0
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.get_associations(model)
|
|
30
|
+
assoc = []
|
|
31
|
+
|
|
32
|
+
model = eval model
|
|
33
|
+
if model.respond_to?:reflections
|
|
34
|
+
model.reflections.each do |name,info|
|
|
35
|
+
mod_assoc = info.name.to_s.camelize
|
|
36
|
+
begin
|
|
37
|
+
eval mod_assoc
|
|
38
|
+
rescue
|
|
39
|
+
begin
|
|
40
|
+
eval (mod_assoc.pluralize)
|
|
41
|
+
mod_assoc = (mod_assoc.pluralize)
|
|
42
|
+
rescue
|
|
43
|
+
(mod_assoc = info.options[:source].to_s.camelize)if info.options[:source]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
if mod_assoc
|
|
47
|
+
assoc << mod_assoc
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
assoc
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.generate_graph(graph_info,model)
|
|
55
|
+
model = model.gsub("::","_")
|
|
56
|
+
file = File.open("#{RAILS_ROOT}/public/images/linked_data_graphs/linked_data_#{model}.dot",'w')
|
|
57
|
+
|
|
58
|
+
file.puts "digraph G {"
|
|
59
|
+
#file.puts 'size="15,15";'
|
|
60
|
+
file.puts "rankdir = LR;"
|
|
61
|
+
file.puts "#{model}[color=green]"
|
|
62
|
+
|
|
63
|
+
#Draw nodes
|
|
64
|
+
|
|
65
|
+
graph_info[:assoc].each do |assoc|
|
|
66
|
+
file.puts "#{assoc} [color=yellow]"
|
|
67
|
+
file.puts '"'+model+'" -> "'+assoc.to_s+'"[dir=none];'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
#Draw associations between nodes
|
|
72
|
+
# graph_info[:assoc].each do |assoc,nodes|
|
|
73
|
+
# file.puts nodes+' [dir=none];'
|
|
74
|
+
# end
|
|
75
|
+
|
|
76
|
+
file.puts "}"
|
|
77
|
+
|
|
78
|
+
file.close
|
|
79
|
+
|
|
80
|
+
system "dot -Tpng #{RAILS_ROOT}/public/images/linked_data_graphs/linked_data_#{model}.dot -o #{RAILS_ROOT}/public/images/linked_data_graphs/linked_data_#{model}.png"
|
|
81
|
+
system "rm #{RAILS_ROOT}/public/images/linked_data_graphs/linked_data_#{model}.dot"
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -50,6 +50,7 @@ class ModelRdf
|
|
|
50
50
|
file.close
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
|
|
53
54
|
#######################################################################
|
|
54
55
|
# Building RDF
|
|
55
56
|
#######################################################################
|
|
@@ -113,14 +114,15 @@ class ModelRdf
|
|
|
113
114
|
def get_associations_tag(element)
|
|
114
115
|
|
|
115
116
|
associations = get_attributes_model(element.class.to_s)
|
|
116
|
-
|
|
117
|
+
class_element = element.class
|
|
117
118
|
if associations.nil?
|
|
118
119
|
associations = get_attributes_model(element.class.base_class.to_s)
|
|
120
|
+
class_element = element.class.base_class
|
|
119
121
|
end
|
|
120
122
|
properties = {}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
|
|
124
|
+
class_element.reflections.each do |ref,value|
|
|
125
|
+
rel = eval "element.#{ref}"
|
|
124
126
|
if exist_info_assoc(rel.to_a,associations["associations"][ref.to_s]) && can_see?(associations["associations"][ref.to_s][:privacy]) && !rel.empty?
|
|
125
127
|
|
|
126
128
|
properties.merge!({"#{associations['associations'][ref.to_s][:namespace]}:#{associations['associations'][ref.to_s][:property]}" => {:model => rel.first.class ,
|
data/lib/easy_data/tasks.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "ftools"
|
|
1
|
+
#require "ftools"
|
|
2
2
|
require 'rake'
|
|
3
3
|
require 'easy_data'
|
|
4
4
|
require 'active_record'
|
|
@@ -9,7 +9,7 @@ namespace :easy_data do
|
|
|
9
9
|
desc <<-END_DESC
|
|
10
10
|
"This tasks install and initialize parameters for run gem."
|
|
11
11
|
END_DESC
|
|
12
|
-
task :install => [:generate_info_initialize,:generate_info_rdf,:copy_style_interface] do
|
|
12
|
+
task :install => [:generate_info_initialize,:generate_info_rdf,:copy_style_interface,:build_linked_data_graph] do
|
|
13
13
|
puts "*** Finish install Easy Data gem in this proyect ***"
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -25,6 +25,7 @@ namespace :easy_data do
|
|
|
25
25
|
puts "Generating info initialize gem"
|
|
26
26
|
|
|
27
27
|
file.puts "#Load templates paths:"
|
|
28
|
+
file.puts "require 'easy_data'"
|
|
28
29
|
file.puts "ActionController::Base.view_paths << EasyData.get_view_path"
|
|
29
30
|
|
|
30
31
|
|
|
@@ -80,7 +81,53 @@ namespace :easy_data do
|
|
|
80
81
|
file_style = EasyData.get_style_path
|
|
81
82
|
#Copy file to public/stylesheets:
|
|
82
83
|
puts "Copy Style File to this proyect"
|
|
83
|
-
|
|
84
|
+
|
|
85
|
+
easy_data_stylesheets = "#{RAILS_ROOT}/public/stylesheets/easy_data"
|
|
86
|
+
easy_data_linked_data_graphs = "#{RAILS_ROOT}/public/images/linked_data_graphs"
|
|
87
|
+
|
|
88
|
+
unless File.exist? easy_data_stylesheets
|
|
89
|
+
Dir.mkdir easy_data_stylesheets
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
FileUtils.copy(File.join(File.dirname(__FILE__), 'templates/stylesheets/easy_data_style.css'),"#{easy_data_stylesheets}/easy_data_style.css")
|
|
93
|
+
FileUtils.cp_r(File.join(File.dirname(__FILE__), 'templates/images/'),"#{easy_data_stylesheets}/")
|
|
94
|
+
|
|
95
|
+
unless File.exist? easy_data_linked_data_graphs
|
|
96
|
+
Dir.mkdir easy_data_linked_data_graphs
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
desc <<-END_DESC
|
|
102
|
+
"Add admin user to configure Rdf Info"
|
|
103
|
+
END_DESC
|
|
104
|
+
task :add_user,:user,:pass, :needs=> :environment do |t,args|
|
|
105
|
+
|
|
106
|
+
args.with_defaults(:user => "admin", :pass => "admin")
|
|
107
|
+
|
|
108
|
+
easy_data_dir = "#{RAILS_ROOT}/config/easy_data"
|
|
109
|
+
|
|
110
|
+
file = File.open("#{easy_data_dir}/setting.yaml","w")
|
|
111
|
+
file.puts "#User admin:"
|
|
112
|
+
|
|
113
|
+
admin = {"user_admin" =>{"user" => args.user,"pass" => args.pass}}
|
|
114
|
+
file.puts admin.to_yaml
|
|
115
|
+
|
|
116
|
+
file.close
|
|
117
|
+
|
|
118
|
+
puts "User #{args.user} added"
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
desc <<-END_DESC
|
|
123
|
+
"Build Linked Data Graph"
|
|
124
|
+
END_DESC
|
|
125
|
+
|
|
126
|
+
task :build_linked_data_graph, :needs => :environment do
|
|
127
|
+
|
|
128
|
+
puts "Generating Linked Data graph..."
|
|
129
|
+
EasyData.build_linked_data_graph
|
|
130
|
+
puts "Ok"
|
|
84
131
|
end
|
|
85
132
|
|
|
86
133
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div id="list_models" class="list_model_info">
|
|
2
|
+
<ul>
|
|
3
|
+
<% list.each do |model|%>
|
|
4
|
+
<li>
|
|
5
|
+
<%= link_to_remote model,:url => {:controller => 'easy_datas',
|
|
6
|
+
:action => :model_attributes_info,
|
|
7
|
+
:model => model},
|
|
8
|
+
:update => "info_models"
|
|
9
|
+
%>
|
|
10
|
+
</li>
|
|
11
|
+
<%end%>
|
|
12
|
+
</ul>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div id="info_models" class="ed_info_models">
|
|
16
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= image_tag(image_path("linked_data_graphs/linked_data_#{@model}.png"))%>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<div id="list_models" class="list_model_info">
|
|
2
|
+
<ul>
|
|
3
|
+
<% @list.each do |model|%>
|
|
4
|
+
<% if File.exists?("public/images/linked_data_graphs/linked_data_#{model}.png")%>
|
|
5
|
+
<li>
|
|
6
|
+
<%= link_to_remote model,:url => {:controller => "easy_datas",
|
|
7
|
+
:action => "load_linked_data_graph",
|
|
8
|
+
:model => model},
|
|
9
|
+
:update => "info_models"
|
|
10
|
+
%>
|
|
11
|
+
</li>
|
|
12
|
+
<%end%>
|
|
13
|
+
<%end%>
|
|
14
|
+
</ul>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<div id="info_models" class="ed_info_models">
|
|
18
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<div class="ed_main_menu">
|
|
2
|
+
<ul>
|
|
3
|
+
<li><%= link_to_remote "Data Publications",:url => {:controller => "easy_datas",:action => "data_publicated"},:update => "information_content"%></li>
|
|
4
|
+
<li><%= link_to_remote "Linked Data",:url => {:controller => "easy_datas",:action => "load_linked_data_graph"},:update => "information_content"%></li>
|
|
5
|
+
<li><%= link_to_remote "Access to Data", :url => {:controller => "easy_datas", :action => "access_to_data"},:update => "information_content"%></li>
|
|
6
|
+
<li><%= link_to_remote "FAQ", :url => {:controller => 'easy_datas',:action => 'faq'},:update => "information_content"%></li>
|
|
7
|
+
</ul>
|
|
8
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<% if @model_attributes["attributes"]%>
|
|
2
|
+
<h2> Attributes: </h2>
|
|
3
|
+
<ul>
|
|
4
|
+
<%@model_attributes["attributes"].keys.each do |att|%>
|
|
5
|
+
<li><%=att%></li>
|
|
6
|
+
<%end%>
|
|
7
|
+
</ul>
|
|
8
|
+
<%end%>
|
|
9
|
+
<%if @model_attributes["associations"] %>
|
|
10
|
+
<h2> Associations: </h2>
|
|
11
|
+
<ul>
|
|
12
|
+
<%@model_attributes["associations"].keys.each do |assoc|%>
|
|
13
|
+
<li><%=assoc%></li>
|
|
14
|
+
<%end%>
|
|
15
|
+
</ul>
|
|
16
|
+
<%end%>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<div class="authenticate">
|
|
2
|
+
<%form_remote_tag :url => {:controller => 'easy_datas',:action => "login"},
|
|
3
|
+
:update => "content" do -%>
|
|
4
|
+
<span>
|
|
5
|
+
<%= label_tag :nick,nil,:class => "lbl_auth" %>
|
|
6
|
+
<%= text_field_tag :nick,nil%>
|
|
7
|
+
</span>
|
|
8
|
+
<span>
|
|
9
|
+
<%= label_tag :password,nil, :class => "lbla_auth"%>
|
|
10
|
+
<%= password_field_tag ":password",nil%>
|
|
11
|
+
</span>
|
|
12
|
+
<%= submit_tag "Send" %>
|
|
13
|
+
<%end%>
|
|
14
|
+
</div>
|
|
@@ -8,7 +8,7 @@ xml.rdf :RDF, @rdf_model[:header] do
|
|
|
8
8
|
end
|
|
9
9
|
prop["associations"].each do |assoc,value|
|
|
10
10
|
value[:id].each do |id|
|
|
11
|
-
xml.tag!(assoc,nil,{"rdf:resource"=>"#{@host}/#{value[:model]}
|
|
11
|
+
xml.tag!(assoc,nil,{"rdf:resource"=>"#{@host}/#{value[:model]}?id=#{id}"})
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>Show template</h1>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
|
|
2
|
+
|
|
3
|
+
xml.rdf :RDF, @rdf_model[:header] do
|
|
4
|
+
@rdf_model[:body].each do |element,prop|
|
|
5
|
+
xml.rdf :Description, {:about => prop["description"]} do
|
|
6
|
+
prop["attributes"].each do |att,value|
|
|
7
|
+
xml.tag!(att,value)
|
|
8
|
+
end
|
|
9
|
+
prop["associations"].each do |assoc,value|
|
|
10
|
+
value[:id].each do |id|
|
|
11
|
+
xml.tag!(assoc,nil,{"rdf:resource"=>"#{@host}/#{value[:model]}?id=#{id}"})
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
Binary file
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
body{width:90%;padding: 2% 5
|
|
2
|
-
|
|
1
|
+
body{width:90%;padding: 2% 5%;background-color:#fbf3b4;font-family:helvetica;}
|
|
2
|
+
.authenticate{background:url("../images/easy_data_logo.png")no-repeat 0 0;padding-top:130px;margin:0 auto;width:400px}
|
|
3
|
+
.authenticate form{background:#767676;width:375px;color:white;overflow:hidden;padding: 20px 30px}
|
|
4
|
+
.authenticate form .lbl_auth{float:left}
|
|
5
|
+
.authenticate form input{float:right}
|
|
6
|
+
.authenticate form span{width:95%;display:block;overflow:hidden}h1{color:red;text-decoration:underline}
|
|
3
7
|
ul{list-style:none;width:90%;float:left;}
|
|
4
8
|
ul li.list_model{color:white;background:grey}
|
|
5
9
|
ul div.list_attributes{overflow:hidden;background-color:white;color:black;padding:0 5%;}
|
data/lib/easy_data/version.rb
CHANGED
data/lib/easy_data.rb
CHANGED
|
@@ -3,8 +3,9 @@ require "data_models/data_models"
|
|
|
3
3
|
require "action_controller"
|
|
4
4
|
require "controllers/easy_datas_controller"
|
|
5
5
|
require "data_models/model_rdf"
|
|
6
|
+
require "data_models/linked_data_graph"
|
|
6
7
|
require "routes"
|
|
7
|
-
require 'ftools'
|
|
8
|
+
#require 'ftools'
|
|
8
9
|
require 'ruby-debug'
|
|
9
10
|
|
|
10
11
|
|
|
@@ -19,28 +20,6 @@ module EasyData
|
|
|
19
20
|
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
def show_linked_data
|
|
23
|
-
models = LinkedData.find :all
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Changes model's attributes with ajax call
|
|
27
|
-
def update_linked_data_model
|
|
28
|
-
|
|
29
|
-
model = LinkedData.find_by_model params[:model]
|
|
30
|
-
|
|
31
|
-
attributes = model["attributes"].to_hash
|
|
32
|
-
attributes[params[:attribute]] = !attributes[params[:attribute]]
|
|
33
|
-
|
|
34
|
-
model["query"] = generate_query(params[:model],attributes)
|
|
35
|
-
model["attributes"] = attributes.to_set
|
|
36
|
-
|
|
37
|
-
if model.valid?
|
|
38
|
-
model.save
|
|
39
|
-
else
|
|
40
|
-
false
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
23
|
def self.yaml_description_model(model_data)
|
|
45
24
|
|
|
46
25
|
attributes = {}
|
|
@@ -76,6 +55,13 @@ module EasyData
|
|
|
76
55
|
def self.get_uri_namespace(namespace)
|
|
77
56
|
eval "RDF::#{namespace.upcase}.get_uri"
|
|
78
57
|
end
|
|
58
|
+
|
|
59
|
+
#######################################################################
|
|
60
|
+
# Building Linked Data Graph
|
|
61
|
+
#######################################################################
|
|
62
|
+
def self.build_linked_data_graph
|
|
63
|
+
LinkedDataGraph.build(DataModels.load_models)
|
|
64
|
+
end
|
|
79
65
|
|
|
80
66
|
private
|
|
81
67
|
|
data/lib/routes.rb
CHANGED
|
@@ -2,38 +2,38 @@ require "action_controller"
|
|
|
2
2
|
|
|
3
3
|
module EasyDataRouting
|
|
4
4
|
def self.routes(map)
|
|
5
|
-
|
|
6
|
-
# map.connect "#{model.gsub("::","_")}/:id.:format", :controller => "easy_datas",
|
|
7
|
-
# :action => 'show',
|
|
8
|
-
# :model => model,
|
|
9
|
-
# :conditions => {:method => :get}
|
|
10
|
-
# end
|
|
11
|
-
# map.connect "list_models.:format", :controller => "easy_datas",
|
|
12
|
-
# :action => 'describe_api'
|
|
13
|
-
#
|
|
14
|
-
# map.connect "custom_rdf", :controller => "easy_datas",
|
|
15
|
-
# :action => "custom_rdf"
|
|
16
|
-
|
|
17
|
-
# map.resources :easy_datas,:member => {:load_properties => :get
|
|
18
|
-
# :model_attributes => :post,
|
|
19
|
-
# :show => :get,
|
|
20
|
-
# :describe_api => :get
|
|
21
|
-
# }
|
|
5
|
+
|
|
22
6
|
map.with_options :controller => 'easy_datas' do |ed_routes|
|
|
23
7
|
ed_routes.with_options :conditions => {:method => :get} do |ed_views|
|
|
24
|
-
ed_views.connect '
|
|
25
|
-
ed_views.connect '
|
|
8
|
+
ed_views.connect 'easy_datas/custom_rdf', :action=> "custom_rdf"
|
|
9
|
+
ed_views.connect 'easy_data', :action => "custom_rdf"
|
|
10
|
+
ed_views.connect 'easy_datas/authenticate_user', :action => "authenticate_user"
|
|
11
|
+
|
|
12
|
+
ed_views.connect 's/data_publications', :action => 'info_easy_data'
|
|
13
|
+
ed_views.connect 'easy_datas/linked_data', :action => 'linked_data'
|
|
14
|
+
ed_views.connect 'easy_datas/access_to_data', :action => 'access_to_data'
|
|
15
|
+
ed_views.connect 'easy_datas/faq', :action => 'faq'
|
|
16
|
+
|
|
17
|
+
ed_views.connect 'easy_datas/logout', :action => 'logout'
|
|
26
18
|
DataModels.load_models.each do |model|
|
|
27
|
-
ed_views.connect "
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
ed_views.connect "s/#{model.gsub("::","_")}", :controller => "easy_datas",
|
|
20
|
+
:action => 'show',
|
|
21
|
+
:model => model,
|
|
22
|
+
:format => 'xml'
|
|
23
|
+
ed_views.connect "s/#{model.gsub("::","_").pluralize}", :controller => "easy_datas",
|
|
24
|
+
:action => 'show_all',
|
|
25
|
+
:model => model,
|
|
26
|
+
:format => 'xml'
|
|
27
|
+
|
|
31
28
|
end
|
|
32
29
|
end
|
|
33
30
|
ed_routes.with_options :conditions => {:method => :post} do |ed_actions|
|
|
31
|
+
ed_actions.connect 'easy_datas/model_attributes_info', :action => "model_attributes_info"
|
|
32
|
+
ed_actions.connect 'easy_datas/load_linked_data_graph', :action => "load_linked_data_graph"
|
|
34
33
|
ed_actions.connect 'easy_datas/model_attributes/:model', :action => 'model_attributes'
|
|
35
34
|
ed_actions.connect 'easy_datas/model_attributes_edit/:model', :action => 'model_attributes_edit'
|
|
36
35
|
ed_actions.connect 'easy_datas/load_properties/:block/:attribute', :action => 'load_properties'
|
|
36
|
+
ed_actions.connect 'easy_datas/login', :action => 'login'
|
|
37
37
|
ed_actions.connect 'easy_datas/custom_attributes/:model', :action => 'custom_attributes'
|
|
38
38
|
end
|
|
39
39
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: easy_data
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 21
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 5
|
|
10
|
+
version: 0.0.5
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- jnillo
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2011-07-
|
|
18
|
+
date: 2011-07-08 00:00:00 +02:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -68,6 +68,7 @@ files:
|
|
|
68
68
|
- easy_data.gemspec
|
|
69
69
|
- lib/controllers/easy_datas_controller.rb
|
|
70
70
|
- lib/data_models/data_models.rb
|
|
71
|
+
- lib/data_models/linked_data_graph.rb
|
|
71
72
|
- lib/data_models/model_rdf.rb
|
|
72
73
|
- lib/data_models/namespaces.rb
|
|
73
74
|
- lib/data_models/namespaces/cc.rb
|
|
@@ -91,13 +92,23 @@ files:
|
|
|
91
92
|
- lib/data_models/parser_rdf.rb
|
|
92
93
|
- lib/easy_data.rb
|
|
93
94
|
- lib/easy_data/tasks.rb
|
|
95
|
+
- lib/easy_data/templates/easy_datas/_data_publications.html.erb
|
|
96
|
+
- lib/easy_data/templates/easy_datas/_linked_data_model.html.erb
|
|
97
|
+
- lib/easy_data/templates/easy_datas/_linked_datas.html.erb
|
|
94
98
|
- lib/easy_data/templates/easy_datas/_list_properties.html.erb
|
|
95
99
|
- lib/easy_data/templates/easy_datas/_list_properties_edit.html.erb
|
|
100
|
+
- lib/easy_data/templates/easy_datas/_menu.html.erb
|
|
96
101
|
- lib/easy_data/templates/easy_datas/_model_attributes.html.erb
|
|
97
102
|
- lib/easy_data/templates/easy_datas/_model_attributes_edit.html.erb
|
|
103
|
+
- lib/easy_data/templates/easy_datas/_model_attributes_info.html.erb
|
|
104
|
+
- lib/easy_data/templates/easy_datas/authenticate_user.html.erb
|
|
98
105
|
- lib/easy_data/templates/easy_datas/custom_rdf.html.erb
|
|
106
|
+
- lib/easy_data/templates/easy_datas/info_easy_data.html.erb
|
|
99
107
|
- lib/easy_data/templates/easy_datas/show.html.erb
|
|
100
108
|
- lib/easy_data/templates/easy_datas/show.xml.builder
|
|
109
|
+
- lib/easy_data/templates/easy_datas/show_all.html.erb
|
|
110
|
+
- lib/easy_data/templates/easy_datas/show_all.xml.builder
|
|
111
|
+
- lib/easy_data/templates/images/easy_data_logo.png
|
|
101
112
|
- lib/easy_data/templates/layouts/easy_data_layout.html.erb
|
|
102
113
|
- lib/easy_data/templates/rdf/request.xml.builder
|
|
103
114
|
- lib/easy_data/templates/rdf/show.builder
|