1 class Arvados::V1::LinksController < ApplicationController
3 def check_uuid_kind uuid, kind
4 if kind and ArvadosModel::resource_class_for_uuid(uuid).andand.kind != kind
5 render :json => { errors: ["'#{kind}' does not match uuid '#{uuid}', expected '#{ArvadosModel::resource_class_for_uuid(uuid).andand.kind}'"] }.to_json, status: 422
13 return if ! check_uuid_kind resource_attrs[:head_uuid], resource_attrs[:head_kind]
14 return if ! check_uuid_kind resource_attrs[:tail_uuid], resource_attrs[:tail_kind]
16 resource_attrs.delete :head_kind
17 resource_attrs.delete :tail_kind
23 # Overrides ApplicationController load_where_param
27 # head_kind and tail_kind columns are now virtual,
28 # equivilent functionality is now provided by
29 # 'is_a', so fix up any old-style 'where' clauses.
33 @filters << ['head_uuid', 'is_a', @where[:head_kind]]
34 @where.delete :head_kind
37 @filters << ['tail_uuid', 'is_a', @where[:tail_kind]]
38 @where.delete :tail_kind
43 # Overrides ApplicationController load_filters_param
44 def load_filters_param
47 # head_kind and tail_kind columns are now virtual,
48 # equivilent functionality is now provided by
49 # 'is_a', so fix up any old-style 'filter' clauses.
50 @filters = @filters.map do |k|
51 if k[0] == 'head_kind' and k[1] == '='
52 ['head_uuid', 'is_a', k[2]]
53 elsif k[0] == 'tail_kind' and k[1] == '='
54 ['tail_uuid', 'is_a', k[2]]