rbbt-rest 1.2.0 → 1.2.1
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.
- checksums.yaml +8 -8
- data/lib/rbbt/rest/common/render.rb +1 -6
- data/lib/rbbt/rest/knowledge_base.rb +7 -156
- data/share/views/layout.haml +0 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDZjZjkwNzc2MzI5YmZjMjhhMWY0ODY3NmQwMjI4NTZiZDQ2ZjA5ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWQzNDM0MTA2MDE1OGI4Nzk0ODk1OTQzZGNiYTNiYjNhNThjNGY1YQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWUyYzc0N2NlODZjMzRhMzU1Zjg0YjY2MTkwMzdjMzFiNmI4ODgzYjA4NjI1
|
10
|
+
NTMzNGUwZjM0YWJiMjVkMmM3NzE4YjIwZjMyZmUyZDM0YjJmOWU3OGRlYjA1
|
11
|
+
MDFhZjRmNWQ2MGMwZGY1N2I4NzI3MDNhOTBmMmYwMWIzMThkYzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGEyNDMwMzE3NzBmMmQ2NDIxMmMxYjA1ODc1OWZiMDE2ZDk3Y2NmMjczZDRl
|
14
|
+
OTM5NGJiZWNjOWIxMmViYmI2M2QyN2MxM2ExMDA5MDg5NzUwNWMyN2QxYmFh
|
15
|
+
MGRlZTk2NTg5OTJlYmViYjExYzQ2YWZlYzMzZDZmZTRjOWY3YTY=
|
@@ -17,16 +17,11 @@ module RbbtRESTHelpers
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def wait_on(job, layout = nil)
|
20
|
-
ddd "wait"
|
21
20
|
3.times do
|
22
21
|
sleep 1
|
23
22
|
end
|
24
|
-
ddd job.status
|
25
|
-
ddd job.done?
|
26
|
-
ddd job.error?
|
27
|
-
raise RbbtRESTHelpers::Retry if job.done? or job.error?
|
28
23
|
|
29
|
-
|
24
|
+
raise RbbtRESTHelpers::Retry if job.done? or job.error?
|
30
25
|
|
31
26
|
layout = @layout if layout.nil?
|
32
27
|
|
@@ -11,6 +11,8 @@ module Sinatra
|
|
11
11
|
base.module_eval do
|
12
12
|
helpers KnowledgeBaseRESTHelpers
|
13
13
|
|
14
|
+
#{{{ Children
|
15
|
+
|
14
16
|
get '/knowledge_base/:name/:database/entity_children/:entity' do
|
15
17
|
name = consume_parameter :name
|
16
18
|
database = consume_parameter :database
|
@@ -30,6 +32,7 @@ module Sinatra
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
35
|
+
# List children
|
33
36
|
post '/knowledge_base/:name/:database/entity_list_children/' do
|
34
37
|
name = consume_parameter :name
|
35
38
|
database = consume_parameter :database
|
@@ -55,6 +58,7 @@ module Sinatra
|
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
61
|
+
# Collection children
|
58
62
|
post '/knowledge_base/:name/:database/entity_collection_children' do
|
59
63
|
name = consume_parameter :name
|
60
64
|
database = consume_parameter :database
|
@@ -86,7 +90,7 @@ module Sinatra
|
|
86
90
|
end
|
87
91
|
end
|
88
92
|
|
89
|
-
# Neighbours
|
93
|
+
#{{{ Neighbours
|
90
94
|
|
91
95
|
get '/knowledge_base/:name/:database/entity_neighbours/:entity' do
|
92
96
|
name = consume_parameter :name
|
@@ -118,7 +122,7 @@ module Sinatra
|
|
118
122
|
|
119
123
|
entities = entities.split("|")
|
120
124
|
|
121
|
-
kb =
|
125
|
+
kb = get_knowledge_base name
|
122
126
|
|
123
127
|
children = {}
|
124
128
|
entities.each do |entity|
|
@@ -145,7 +149,7 @@ module Sinatra
|
|
145
149
|
|
146
150
|
entities = JSON.parse(entities)
|
147
151
|
|
148
|
-
kb =
|
152
|
+
kb = get_knowledge_base name
|
149
153
|
|
150
154
|
neighbours = {}
|
151
155
|
entities.each do |type,list|
|
@@ -179,159 +183,6 @@ module Sinatra
|
|
179
183
|
when :html
|
180
184
|
end
|
181
185
|
end
|
182
|
-
|
183
|
-
#{{{ OLD
|
184
|
-
|
185
|
-
get '/knowledge_base/entity/:name/:database/:entity' do
|
186
|
-
name = consume_parameter :name
|
187
|
-
|
188
|
-
database = consume_parameter :database
|
189
|
-
entity = consume_parameter :entity
|
190
|
-
|
191
|
-
kb = get_kb name
|
192
|
-
found = kb.identify database, entity
|
193
|
-
raise ParameterException, "Entity #{entity} was not found" unless found
|
194
|
-
|
195
|
-
list = kb.neighbours(database, found).values.select{|l| l.any?}.first.target_entity
|
196
|
-
|
197
|
-
case @format
|
198
|
-
when :json
|
199
|
-
content_type "application/json"
|
200
|
-
halt 200, list_json(list || [])
|
201
|
-
when :html
|
202
|
-
template_render('entity_partials/entity_list', :list => list)
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
get '/knowledge_base/entities/:name/:database' do
|
207
|
-
name = consume_parameter :name
|
208
|
-
database = consume_parameter :database
|
209
|
-
entities = consume_parameter(:entities).split("|")
|
210
|
-
|
211
|
-
kb = get_kb name
|
212
|
-
|
213
|
-
entity_neighbours = {}
|
214
|
-
entities.each do |entity|
|
215
|
-
found = kb.identify database, entity
|
216
|
-
next unless found
|
217
|
-
list = kb.neighbours(database, found).values.select{|l| l.any?}.first.target_entity
|
218
|
-
entity_neighbours[entity] = list
|
219
|
-
end
|
220
|
-
|
221
|
-
case @format
|
222
|
-
when :json
|
223
|
-
content_type "application/json"
|
224
|
-
hash = {}
|
225
|
-
entity_neighbours.each do |entity, list|
|
226
|
-
hash[entity] = list_hash(list)
|
227
|
-
end
|
228
|
-
halt 200, hash.to_json
|
229
|
-
when :html
|
230
|
-
template_render('entity_partials/entity_list', :list => list)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
get '/knowledge_base/entity/:name/:entity' do
|
235
|
-
name = consume_parameter :name
|
236
|
-
database = consume_parameter :database
|
237
|
-
entity = consume_parameter :entity
|
238
|
-
|
239
|
-
kb = get_kb name
|
240
|
-
|
241
|
-
lists = {}
|
242
|
-
kb.all_databases.collect do |database|
|
243
|
-
found = kb.identify database, entity
|
244
|
-
next unless found
|
245
|
-
matches = kb.neighbours(database, found).values.select{|l| l.any?}.first
|
246
|
-
next if matches.nil?
|
247
|
-
lists[database] = matches.target_entity
|
248
|
-
end
|
249
|
-
|
250
|
-
case @format
|
251
|
-
when :json
|
252
|
-
content_type "application/json"
|
253
|
-
halt 200, lists.each{|database,entities| lists[database] = list_hash(entities || []) }.to_json
|
254
|
-
when :html
|
255
|
-
template_render('knowledge_base_partials/knowledge_base_matches', :matches => lists, :knowledge_base => kb)
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
#{{{ Hash
|
260
|
-
|
261
|
-
post '/knowledge_base/associations' do
|
262
|
-
knowledge_base = consume_parameter :knowledge_base
|
263
|
-
knowledge_base = get_knowledge_base(knowledge_base)
|
264
|
-
|
265
|
-
namespace = consume_parameter :namespace
|
266
|
-
|
267
|
-
databases = consume_parameter(:databases) || consume_parameter(:database)
|
268
|
-
databases = databases.nil? ? knowledge_base.all_databases : databases.split("|")
|
269
|
-
|
270
|
-
entities = consume_parameter :entities
|
271
|
-
entities = JSON.parse(entities)
|
272
|
-
|
273
|
-
subset = {}
|
274
|
-
databases.each do |database|
|
275
|
-
subset[database] = knowledge_base.subset(database, entities)
|
276
|
-
end
|
277
|
-
|
278
|
-
case @format
|
279
|
-
when :json
|
280
|
-
content_type "application/json"
|
281
|
-
halt 200, subset.each{|database,entities| subset[database] = list_hash(entities || []) }.to_json
|
282
|
-
when :html
|
283
|
-
template_render('entity_partials/associations', :matches => matches, :entities => entities)
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
post '/knowledge_base/neighbours' do
|
288
|
-
knowledge_base = consume_parameter :knowledge_base
|
289
|
-
knowledge_base = get_knowledge_base(knowledge_base)
|
290
|
-
|
291
|
-
namespace = consume_parameter :namespace
|
292
|
-
|
293
|
-
database = consume_parameter(:database)
|
294
|
-
|
295
|
-
entities = consume_parameter :entities
|
296
|
-
entities = JSON.parse(entities)
|
297
|
-
|
298
|
-
all_neighbours = {}
|
299
|
-
entities.collect{|source_type,list|
|
300
|
-
list.each do |entity|
|
301
|
-
|
302
|
-
target_type = knowledge_base.target_type(database)
|
303
|
-
source_type = knowledge_base.source_type(database)
|
304
|
-
|
305
|
-
neighbours = knowledge_base.neighbours(database, entity)
|
306
|
-
|
307
|
-
children = neighbours[:children]
|
308
|
-
if children.any?
|
309
|
-
all_neighbours[target_type] ||= []
|
310
|
-
all_neighbours[target_type].concat children.target
|
311
|
-
end
|
312
|
-
|
313
|
-
parents = neighbours[:parents]
|
314
|
-
if parents and parents.any?
|
315
|
-
all_neighbours[source_type] ||= []
|
316
|
-
all_neighbours[source_type].concat parents.target
|
317
|
-
end
|
318
|
-
end
|
319
|
-
}
|
320
|
-
|
321
|
-
case @format
|
322
|
-
when :json
|
323
|
-
content_type "application/json"
|
324
|
-
halt 200, [].to_json if all_neighbours.empty?
|
325
|
-
entities = {}
|
326
|
-
all_neighbours.each do |type,list|
|
327
|
-
entities[type] = list
|
328
|
-
end
|
329
|
-
|
330
|
-
halt 200, all_neighbours.to_json
|
331
|
-
when :html
|
332
|
-
template_render('entity_partials/neighbours', :matches => matches, :neighbours => all_neighbours)
|
333
|
-
end
|
334
|
-
end
|
335
186
|
end
|
336
187
|
end
|
337
188
|
end
|
data/share/views/layout.haml
CHANGED
@@ -44,9 +44,6 @@
|
|
44
44
|
- %w(dom_update workflow menu fragment favourites page_type modal reveal actions table list map hide).each do |file|
|
45
45
|
- record_js "/js-find/rbbt/#{ file }"
|
46
46
|
|
47
|
-
- %w(knowledge_base).each do |file|
|
48
|
-
- record_js "/js-find/rbbt/#{ file }"
|
49
|
-
|
50
47
|
- record_js "/js-find/app"
|
51
48
|
|
52
49
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|