rbbt-rest 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +8 -8
  2. data/config.ru +3 -0
  3. data/lib/rbbt/rest/client.rb +9 -10
  4. data/lib/rbbt/rest/common/cache.rb +32 -7
  5. data/lib/rbbt/rest/common/forms.rb +33 -0
  6. data/lib/rbbt/rest/common/locate.rb +4 -0
  7. data/lib/rbbt/rest/common/misc.rb +24 -0
  8. data/lib/rbbt/rest/common/render.rb +26 -9
  9. data/lib/rbbt/rest/common/resources.rb +1 -1
  10. data/lib/rbbt/rest/common/table.rb +87 -26
  11. data/lib/rbbt/rest/common/users.rb +5 -1
  12. data/lib/rbbt/rest/entity.rb +300 -95
  13. data/lib/rbbt/rest/entity/action_controller.rb +6 -1
  14. data/lib/rbbt/rest/entity/entity_list_card.rb +1 -1
  15. data/lib/rbbt/rest/entity/entity_map_card.rb +15 -0
  16. data/lib/rbbt/rest/entity/favourites.rb +57 -1
  17. data/lib/rbbt/rest/entity/finder.rb +1 -1
  18. data/lib/rbbt/rest/entity/helpers.rb +40 -7
  19. data/lib/rbbt/rest/entity/list.rb +8 -0
  20. data/lib/rbbt/rest/entity/locate.rb +114 -0
  21. data/lib/rbbt/rest/entity/map.rb +99 -0
  22. data/lib/rbbt/rest/entity/render.rb +25 -0
  23. data/lib/rbbt/rest/entity/rest.rb +33 -4
  24. data/lib/rbbt/rest/main.rb +27 -4
  25. data/lib/rbbt/rest/workflow.rb +7 -1
  26. data/lib/rbbt/rest/workflow/jobs.rb +21 -1
  27. data/share/views/compass/app.sass +17 -9
  28. data/share/views/compass/entity_card.sass +16 -3
  29. data/share/views/compass/favourites.sass +44 -2
  30. data/share/views/compass/form.sass +11 -0
  31. data/share/views/compass/list_container.sass +1 -1
  32. data/share/views/compass/reveal.sass +31 -0
  33. data/share/views/compass/style.sass +29 -1
  34. data/share/views/compass/style_mixins.sass +18 -6
  35. data/share/views/compass/table.sass +19 -3
  36. data/share/views/compass/topbar.sass +8 -2
  37. data/share/views/entity_map/Default.haml +5 -0
  38. data/share/views/entity_partials/action_card.haml +2 -0
  39. data/share/views/entity_partials/action_controller.haml +8 -1
  40. data/share/views/entity_partials/entity_list_card.haml +8 -6
  41. data/share/views/entity_partials/entity_map_card.haml +63 -0
  42. data/share/views/entity_partials/list_container.haml +3 -2
  43. data/share/views/error.haml +14 -10
  44. data/share/views/help.haml +34 -0
  45. data/share/views/help/entity.haml +193 -0
  46. data/share/views/help/workflow.haml +77 -0
  47. data/share/views/job_result/tsv.haml +3 -2
  48. data/share/views/layout.haml +33 -3
  49. data/share/views/layout/favourites.haml +14 -4
  50. data/share/views/layout/header.haml +4 -0
  51. data/share/views/partials/form.haml +3 -1
  52. data/share/views/partials/table.haml +16 -52
  53. data/share/views/partials/table/column.haml +10 -0
  54. data/share/views/partials/table/files.haml +4 -0
  55. data/share/views/partials/table/filters.haml +11 -0
  56. data/share/views/partials/table/page.haml +37 -0
  57. data/share/views/public/favicon.gif +0 -0
  58. data/share/views/public/js/_ajax_replace.js +76 -4
  59. data/share/views/public/js/_fix_tablesorter_science.js +13 -0
  60. data/share/views/public/js/actions.js +8 -2
  61. data/share/views/public/js/base.js +12 -1
  62. data/share/views/public/js/entities.js +39 -7
  63. data/share/views/public/js/favourites.js +308 -77
  64. data/share/views/public/js/helpers.js +9 -5
  65. data/share/views/public/js/lists.js +12 -12
  66. data/share/views/public/js/maps.js +17 -0
  67. data/share/views/public/js/reveal.js +48 -0
  68. data/share/views/public/js/tables.js +110 -51
  69. data/share/views/public/js/workflow.js +4 -16
  70. data/share/views/public/plugins/underscore/js/underscore.js +1227 -0
  71. data/share/views/tasks.haml +12 -1
  72. data/share/views/wait.haml +7 -0
  73. metadata +17 -2
@@ -30,7 +30,11 @@ module Sinatra
30
30
  def self.registered(app)
31
31
  app.helpers RbbtAuth::Helpers
32
32
 
33
- app.set :users, Rbbt.etc.web_users.yaml
33
+ if Rbbt.etc.web_users.exists?
34
+ app.set :users, Rbbt.etc.web_users.yaml
35
+ else
36
+ app.set :users, {}
37
+ end
34
38
 
35
39
  app.get '/login' do
36
40
  "<form class='login' method='POST' action='/login'>" +
@@ -11,16 +11,20 @@ require 'rbbt/rest/entity/locate'
11
11
  require 'rbbt/rest/entity/helpers'
12
12
  require 'rbbt/rest/entity/render'
13
13
  require 'rbbt/rest/entity/list'
14
+ require 'rbbt/rest/entity/map'
14
15
  require 'rbbt/rest/entity/rest'
15
16
  require 'rbbt/rest/entity/favourites'
16
17
  require 'rbbt/rest/entity/finder'
17
18
 
18
19
  require 'rbbt/rest/entity/entity_card'
19
20
  require 'rbbt/rest/entity/entity_list_card'
21
+ require 'rbbt/rest/entity/entity_map_card'
20
22
  require 'rbbt/rest/entity/action_card'
21
23
  require 'rbbt/rest/entity/list_container'
22
24
  require 'rbbt/rest/entity/action_controller'
23
25
 
26
+ require 'rbbt/statistics/rank_product'
27
+
24
28
 
25
29
  module Sinatra
26
30
  module RbbtRESTEntity
@@ -30,6 +34,7 @@ module Sinatra
30
34
 
31
35
  set :favourites_dir, Rbbt.var.find.sinatra.favourites
32
36
  set :favourite_lists_dir, Rbbt.var.find.sinatra.favourite_lists
37
+ set :favourite_maps_dir, Rbbt.var.find.sinatra.favourite_maps
33
38
  set :finder, nil
34
39
 
35
40
  get /^\/entity.*/ do
@@ -37,6 +42,42 @@ module Sinatra
37
42
  pass
38
43
  end
39
44
 
45
+ #{{{ Finder
46
+
47
+ get '/find' do
48
+ halt 200 if params[:term].nil? or params[:term].empty?
49
+
50
+ term = params[:term]
51
+ sorted_results = finder_find(term)
52
+
53
+ raise "No finder defined" unless settings.respond_to? :finder and not settings.finder.nil?
54
+ if request.xhr?
55
+ content_type "application/json"
56
+ halt 200, sorted_results.to_json
57
+ else
58
+ i = sorted_results.first
59
+ raise "Term not recognized: #{ term }" if i.nil?
60
+ redirect to(Entity::REST.entity_url(i[:code], i[:format], i[:namespace]))
61
+ end
62
+ end
63
+
64
+ post '/find' do
65
+ term = consume_parameter :term
66
+ if term =~ /(.*) \[(.*)\]$/
67
+ term = $1
68
+ namespace, format = $2.split(":")
69
+ format, namespace = namespace, nil if format.nil?
70
+
71
+ redirect to(Entity::REST.entity_url(term, format, :organism => namespace))
72
+ else
73
+ sorted_results = finder_find(term)
74
+ i = sorted_results.first
75
+ halt 404, "Term not recognized: #{ term }" if i.nil?
76
+ redirect to(Entity::REST.entity_url(i[:code], i[:format], :organism => i[:namespace]))
77
+ end
78
+ end
79
+
80
+
40
81
  #{{{ Entities
41
82
 
42
83
  get '/entity/:entity_type/:entity' do
@@ -100,6 +141,8 @@ module Sinatra
100
141
 
101
142
  list = Entity::List.load_list(entity_type.split(":").first, list_id, user)
102
143
 
144
+ raise "List not found" if list.nil?
145
+
103
146
  case @format
104
147
  when :raw, :literal
105
148
  content_type "text/tab-separated-values"
@@ -111,30 +154,20 @@ module Sinatra
111
154
 
112
155
  raise "List file not found: #{ list_id }"
113
156
  when :json
114
- list = Entity::List.load_list(entity_type.split(":").first, list_id, user)
115
157
  list_info = {:entities => list, :info => list.info}
116
158
  halt 200, list_info.to_json
117
159
  when :info
118
- list = Entity::List.load_list(entity_type.split(":").first, list_id, user)
119
160
  halt 200, list.info.to_json
120
161
  when :list
121
- list = Entity::List.load_list(entity_type.split(":").first, list_id, user)
122
-
123
162
  content_type "text/plain"
124
163
  halt 200, list * "\n"
125
164
  when :name
126
- list = Entity::List.load_list(entity_type.split(":").first, list_id, user)
127
-
128
165
  content_type "text/plain"
129
-
130
166
  halt 200, list.name * "\n"
131
167
  when :ensembl
132
- list = Entity::List.load_list(entity_type.split(":").first, list_id, user)
133
-
134
168
  content_type "text/plain"
135
169
  halt 200, list.ensembl * "\n"
136
170
  else
137
- list = Entity::List.load_list(entity_type.split(":").first, list_id, user)
138
171
  entity_list_render(list, list_id)
139
172
  end
140
173
  end
@@ -154,6 +187,8 @@ module Sinatra
154
187
  post '/entity_list/:entity_type/:list_id' do
155
188
  list_id = consume_parameter :list_id
156
189
 
190
+ list_id = list_id.gsub("'", '"')
191
+
157
192
  entity_type = consume_parameter :entity_type
158
193
  entity_type = Entity::REST.restore_element(entity_type)
159
194
 
@@ -179,6 +214,234 @@ module Sinatra
179
214
  redirect to(Entity::REST.entity_list_url(list_id, type))
180
215
  end
181
216
 
217
+ #{{{ List Management
218
+
219
+ get '/entity_list/intersect/:entity_type/:list_id' do
220
+ entity_type = consume_parameter :entity_type
221
+ list_id = consume_parameter :list_id
222
+ other_list_id = consume_parameter :other_list_id
223
+
224
+ entity_type = Entity::REST.restore_element(entity_type)
225
+ type = entity_type.split(":").first
226
+
227
+ list_id = Entity::REST.restore_element(list_id)
228
+ list = Entity::List.load_list(type, list_id, user)
229
+
230
+ other_list_id = Entity::REST.restore_element(other_list_id)
231
+ other_list = Entity::List.load_list(type, other_list_id, user)
232
+
233
+ new_list = list.subset(other_list)
234
+ new_list_id = [list_id, other_list_id] * " ^ "
235
+ new_list_id = [Misc.digest(list_id), Misc.digest(other_list_id)] * " ^ " if new_list_id.length > 200
236
+
237
+ Entity::List.save_list(type, new_list_id, new_list, user)
238
+
239
+ redirect to(Entity::REST.entity_list_url(new_list_id, type))
240
+ end
241
+
242
+ get '/entity_list/remove/:entity_type/:list_id' do
243
+ entity_type = consume_parameter :entity_type
244
+ list_id = consume_parameter :list_id
245
+ other_list_id = consume_parameter :other_list_id
246
+
247
+ entity_type = Entity::REST.restore_element(entity_type)
248
+ type = entity_type.split(":").first
249
+
250
+ list_id = Entity::REST.restore_element(list_id)
251
+ list = Entity::List.load_list(type, list_id, user)
252
+
253
+ other_list_id = Entity::REST.restore_element(other_list_id)
254
+ other_list = Entity::List.load_list(type, other_list_id, user)
255
+
256
+ new_list = list.remove(other_list)
257
+ new_list_id = [list_id, other_list_id] * " - "
258
+ new_list_id = [Misc.digest(list_id), Misc.digest(other_list_id)] * " ~ " if new_list_id.length > 200
259
+
260
+ Entity::List.save_list(type, new_list_id, new_list, user)
261
+
262
+ redirect to(Entity::REST.entity_list_url(new_list_id, type))
263
+ end
264
+
265
+ get '/entity_list/add/:entity_type/:list_id' do
266
+ entity_type = consume_parameter :entity_type
267
+ list_id = consume_parameter :list_id
268
+ other_list_id = consume_parameter :other_list_id
269
+
270
+ entity_type = Entity::REST.restore_element(entity_type)
271
+ type = entity_type.split(":").first
272
+
273
+ list_id = Entity::REST.restore_element(list_id)
274
+ list = Entity::List.load_list(type, list_id, user)
275
+
276
+ other_list_id = Entity::REST.restore_element(other_list_id)
277
+ other_list = Entity::List.load_list(type, other_list_id, user)
278
+
279
+ new_list = list.concat(other_list)
280
+ new_list_id = [list_id, other_list_id] * " PLUS "
281
+ new_list_id = [Misc.digest(list_id), Misc.digest(other_list_id)] * " PLUS " if new_list_id.length > 200
282
+
283
+ Entity::List.save_list(type, new_list_id, new_list, user)
284
+
285
+ redirect to(Entity::REST.entity_list_url(new_list_id, type))
286
+ end
287
+
288
+ #{{{ Entity maps
289
+
290
+ get '/entity_map/:entity_type/:column/:map_id' do
291
+ entity_type = consume_parameter :entity_type
292
+ map_id = consume_parameter :map_id
293
+ column = consume_parameter :column
294
+
295
+ entity_type = Entity::REST.restore_element(entity_type)
296
+ column = Entity::REST.restore_element(column)
297
+ map_id = Entity::REST.restore_element(map_id)
298
+
299
+ map = Entity::Map.load_map(entity_type.split(":").first, column, map_id, user)
300
+
301
+ case @format
302
+ when :name
303
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, user)
304
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, nil) unless File.exists? file
305
+ new = TSVWorkflow.job(:change_id, "Map #{ map_id }", :format => "Associated Gene Name", :tsv => TSV.open(file)).exec
306
+ new_id = map_id << " [Names]"
307
+ Entity::Map.save_map(entity_type, column, new_id, new, user)
308
+ redirect to(Entity::REST.entity_map_url(new_id, entity_type, column))
309
+ when :ensembl
310
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, user)
311
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, nil) unless File.exists? file
312
+ new = TSVWorkflow.job(:change_id, "Map #{ map_id }", :format => "Ensembl Gene ID", :tsv => TSV.open(file)).exec
313
+ new_id = map_id << " [Ensembl]"
314
+ Entity::Map.save_map(entity_type, column, new_id, new, user)
315
+ redirect to(Entity::REST.entity_map_url(new_id, entity_type, column))
316
+ when :pvalue_score
317
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, user)
318
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, nil) unless File.exists? file
319
+ tsv = TSV.open(file)
320
+ tsv.process tsv.fields.first do |value|
321
+ value = value.flatten.first if Array === value
322
+ (1 - value.to_f) / value.to_f
323
+ end
324
+ tsv.fields = [tsv.fields.first + " score"]
325
+ tsv.type = :single
326
+ tsv.cast = :to_f
327
+ new_id = map_id << " [Pvalue score]"
328
+ column = 'Pvalue Score'
329
+ Entity::Map.save_map(entity_type, column, new_id, tsv, user)
330
+ redirect to(Entity::REST.entity_map_url(new_id, entity_type, column))
331
+ when :ranks
332
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, user)
333
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, nil) unless File.exists? file
334
+ tsv = TSV.open(file)
335
+ new = tsv.ranks_for(tsv.fields.first)
336
+ new_id = map_id << " [Ranks]"
337
+ column = 'Ranks'
338
+ Entity::Map.save_map(entity_type, column, new_id, new, user)
339
+ redirect to(Entity::REST.entity_map_url(new_id, entity_type, column))
340
+ when :invert_ranks
341
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, user)
342
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, nil) unless File.exists? file
343
+ tsv = TSV.open(file)
344
+ size = tsv.size
345
+ tsv.process "Rank" do |v|
346
+ if Array === v
347
+ [(size - v.first.to_i).to_s]
348
+ else
349
+ (size - v.to_i).to_s
350
+ end
351
+ end
352
+ new_id = map_id.dup
353
+ column = 'Ranks'
354
+ Entity::Map.save_map(entity_type, column, new_id, tsv, user)
355
+ redirect to(Entity::REST.entity_map_url(new_id, entity_type, column))
356
+ when :raw, :literal
357
+ content_type "text/tab-separated-values"
358
+ user_file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, user)
359
+ send_file user_file if File.exists? user_file
360
+
361
+ global_file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, nil)
362
+ send_file global_file if File.exists? global_file
363
+
364
+ raise "Map file not found: #{ map_id }"
365
+ when :json
366
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, user)
367
+ file = Entity::Map.map_file(entity_type.split(":").first, column, map_id, nil) unless File.exists? file
368
+
369
+ content_type "application/json"
370
+ halt 200, TSV.open(file).to_json
371
+ else
372
+ map = Entity::Map.load_map(entity_type.split(":").first, column, map_id, user)
373
+ entity_map_render(map_id, entity_type.split(":").first, column)
374
+ end
375
+ end
376
+
377
+ get '/entity_map_action/:entity_type/:column/:action/:map_id' do
378
+ action = consume_parameter :action
379
+
380
+ entity_type = Entity::REST.restore_element(consume_parameter :entity_type)
381
+ column = Entity::REST.restore_element(consume_parameter :column)
382
+ map_id = Entity::REST.restore_element(consume_parameter :map_id)
383
+
384
+ map = Entity::Map.load_map(entity_type.split(":").first, column, map_id, user)
385
+
386
+ entity_map_action_render(map, action, map_id, @clean_params)
387
+ end
388
+
389
+
390
+ get '/entity_map/rename/:entity_type/:column/:map_id' do
391
+ new_id = params[:new_name]
392
+
393
+ entity_type = Entity::REST.restore_element(params[:entity_type])
394
+ column = Entity::REST.restore_element(params[:column])
395
+ map_id = Entity::REST.restore_element(params[:map_id])
396
+
397
+ map = Entity::Map.load_map(entity_type.split(":").first, column, map_id, user)
398
+
399
+ Entity::Map.save_map(entity_type, column, new_id, map, user)
400
+
401
+ redirect to(Entity::REST.entity_map_url(new_id, entity_type, column))
402
+ end
403
+
404
+ get '/entity_map/rank_products' do
405
+ map1 = consume_parameter :map1
406
+ map2 = consume_parameter :map2
407
+
408
+ map1 = Entity::REST.restore_element(map1)
409
+ map2 = Entity::REST.restore_element(map2)
410
+
411
+ entity_type = consume_parameter :entity_type
412
+ column = consume_parameter :column
413
+ entity_type = Entity::REST.restore_element(entity_type)
414
+ column = Entity::REST.restore_element(column)
415
+
416
+ file1 = Entity::Map.map_file(entity_type.split(":").first, column, map1, user)
417
+ file1 = Entity::Map.map_file(entity_type.split(":").first, column, map1, nil) unless File.exists? file1
418
+ tsv1 = TSV.open(file1)
419
+
420
+ file2 = Entity::Map.map_file(entity_type.split(":").first, column, map2, user)
421
+ file2 = Entity::Map.map_file(entity_type.split(":").first, column, map2, nil) unless File.exists? file2
422
+ tsv2 = TSV.open(file2)
423
+
424
+ tsv1.attach tsv2, :fields => tsv2.fields
425
+
426
+ new = TSV.setup(tsv1.rank_product(tsv1.fields), :key_field => tsv1.key_field, :fields => ["Log rank-product"], :type => :single, :cast => :to_f)
427
+ new.entity_options = tsv1.entity_options
428
+ new.namespace = tsv1.namespace
429
+
430
+ new_id = "Rank products of #{ map1 } ~ #{ map2 }"
431
+ if new_id.length > 200
432
+ new_id = "Rank products of #{ Misc.digest(map1) } ~ #{ Misc.digest(map2) }"
433
+ end
434
+
435
+ column = 'Log rank-product'
436
+ Entity::Map.save_map(entity_type, column, new_id, new, user)
437
+ redirect to(Entity::REST.entity_map_url(new_id, entity_type, column))
438
+ end
439
+
440
+ #{{{{{{{{{{{{{{
441
+ #{{{ FAVOURITES
442
+ #{{{{{{{{{{{{{{
443
+
444
+
182
445
  #{{{ Favourite entities
183
446
 
184
447
  post '/add_favourite_entity/:entity_type/:entity' do
@@ -232,6 +495,8 @@ module Sinatra
232
495
  entity_type = consume_parameter :entity_type
233
496
  list = consume_parameter :list
234
497
 
498
+ list = Entity::REST.restore_element(list)
499
+
235
500
  entity_type = Entity::REST.restore_element(entity_type).split(":").first
236
501
 
237
502
  add_favourite_entity_list(entity_type, list)
@@ -243,6 +508,7 @@ module Sinatra
243
508
  entity_type = consume_parameter :entity_type
244
509
  list = consume_parameter :list
245
510
 
511
+ list = Entity::REST.restore_element(list)
246
512
  entity_type = Entity::REST.restore_element(entity_type).split(":").first
247
513
 
248
514
  remove_favourite_entity_list(entity_type, list)
@@ -259,109 +525,48 @@ module Sinatra
259
525
  favs.to_json
260
526
  end
261
527
 
262
- #{{{ Finder
263
-
264
-
265
- get '/find' do
266
- halt 200 if params[:term].nil? or params[:term].empty?
528
+ #{{{ Favourite entity maps
529
+
530
+ post '/add_favourite_entity_map/:entity_type/:column/:map' do
531
+ entity_type = consume_parameter :entity_type
532
+ column = consume_parameter :column
533
+ map = consume_parameter :map
267
534
 
268
- term = params[:term]
269
- sorted_results = finder_find(term)
535
+ map = Entity::REST.restore_element(map)
270
536
 
271
- raise "No finder defined" unless settings.respond_to? :finder and not settings.finder.nil?
272
- if request.xhr?
273
- content_type "application/json"
274
- halt 200, sorted_results.to_json
275
- else
276
- i = sorted_results.first
277
- raise "Term not recognized: #{ term }" if i.nil?
278
- redirect to(Entity::REST.entity_url(i[:code], i[:format], i[:namespace]))
279
- end
280
- end
537
+ entity_type = Entity::REST.restore_element(entity_type).split(":").first
538
+ column = Entity::REST.restore_element(column)
281
539
 
282
- post '/find' do
283
- term = consume_parameter :term
284
- if term =~ /(.*) \[(.*)\]$/
285
- term = $1
286
- namespace, format = $2.split(":")
287
- format, namespace = namespace, nil if format.nil?
540
+ add_favourite_entity_map(entity_type, column, map)
288
541
 
289
- redirect to(Entity::REST.entity_url(term, format, :organism => namespace))
290
- else
291
- sorted_results = finder_find(term)
292
- i = sorted_results.first
293
- halt 404, "Term not recognized: #{ term }" if i.nil?
294
- redirect to(Entity::REST.entity_url(i[:code], i[:format], :organism => i[:namespace]))
295
- end
542
+ halt 200
296
543
  end
297
544
 
298
- #{{{ List Management
299
-
300
- get '/entity_list/intersect/:entity_type/:list_id' do
545
+ post '/remove_favourite_entity_map/:entity_type/:column/:map' do
301
546
  entity_type = consume_parameter :entity_type
302
- list_id = consume_parameter :list_id
303
- other_list_id = consume_parameter :other_list_id
547
+ column = consume_parameter :column
548
+ map = consume_parameter :map
304
549
 
305
- entity_type = Entity::REST.restore_element(entity_type)
306
- type = entity_type.split(":").first
307
-
308
- list_id = Entity::REST.restore_element(list_id)
309
- list = Entity::List.load_list(type, list_id, user)
310
-
311
- other_list_id = Entity::REST.restore_element(other_list_id)
312
- other_list = Entity::List.load_list(type, other_list_id, user)
550
+ map = Entity::REST.restore_element(map)
313
551
 
314
- new_list = list.subset(other_list)
315
- new_list_id = [list_id, other_list_id] * " ^ "
552
+ entity_type = Entity::REST.restore_element(entity_type).split(":").first
553
+ column = Entity::REST.restore_element(column)
316
554
 
317
- Entity::List.save_list(type, new_list_id, new_list, user)
555
+ remove_favourite_entity_map(entity_type, column, map)
318
556
 
319
- redirect to(Entity::REST.entity_list_url(new_list_id, type))
557
+ halt 200
320
558
  end
321
-
322
- get '/entity_list/remove/:entity_type/:list_id' do
323
- entity_type = consume_parameter :entity_type
324
- list_id = consume_parameter :list_id
325
- other_list_id = consume_parameter :other_list_id
326
-
327
- entity_type = Entity::REST.restore_element(entity_type)
328
- type = entity_type.split(":").first
329
559
 
330
- list_id = Entity::REST.restore_element(list_id)
331
- list = Entity::List.load_list(type, list_id, user)
332
560
 
333
- other_list_id = Entity::REST.restore_element(other_list_id)
334
- other_list = Entity::List.load_list(type, other_list_id, user)
335
-
336
- new_list = list.remove(other_list)
337
- new_list_id = [list_id, other_list_id] * " - "
561
+ get '/favourite_entity_maps' do
562
+ content_type "application/json"
338
563
 
339
- Entity::List.save_list(type, new_list_id, new_list, user)
564
+ favs = favourite_entity_maps
340
565
 
341
- redirect to(Entity::REST.entity_list_url(new_list_id, type))
566
+ favs.to_json
342
567
  end
343
-
344
- get '/entity_list/add/:entity_type/:list_id' do
345
- entity_type = consume_parameter :entity_type
346
- list_id = consume_parameter :list_id
347
- other_list_id = consume_parameter :other_list_id
348
568
 
349
- entity_type = Entity::REST.restore_element(entity_type)
350
- type = entity_type.split(":").first
351
-
352
- list_id = Entity::REST.restore_element(list_id)
353
- list = Entity::List.load_list(type, list_id, user)
354
-
355
- other_list_id = Entity::REST.restore_element(other_list_id)
356
- other_list = Entity::List.load_list(type, other_list_id, user)
357
-
358
- new_list = list.concat(other_list)
359
- new_list_id = [list_id, other_list_id] * " PLUS "
360
-
361
- Entity::List.save_list(type, new_list_id, new_list, user)
362
-
363
- redirect to(Entity::REST.entity_list_url(new_list_id, type))
364
- end
569
+
365
570
  end
366
571
  end
367
572
  end