1 class Arvados::V1::GroupsController < ApplicationController
3 def self._contents_requires_parameters
4 _index_requires_parameters.
7 type: 'string', required: false, default: nil
10 type: 'boolean', required: false, default: false
15 def render_404_if_no_object
16 if params[:action] == 'contents' and !params[:uuid]
26 load_searchable_objects(owner_uuid: @object.andand.uuid,
27 include_linked: params[:include_linked])
28 sql = 'link_class=? and head_uuid in (?)'
29 sql_params = ['name', @objects.collect(&:uuid)]
31 sql += ' and tail_uuid=?'
32 sql_params << @object.uuid
34 @links = Link.where sql, *sql_params
36 :kind => "arvados#objectList",
39 :links => @links.as_api_response(nil),
42 :items_available => @items_available,
43 :items => @objects.as_api_response(nil)
45 render json: @object_list
50 def load_searchable_objects opts
54 # Trick apply_where_limit_order_params into applying suitable
55 # per-table values. *_all are the real ones we'll apply to the
62 Job, PipelineInstance, PipelineTemplate,
64 Human, Specimen, Trait].each do |klass|
65 @objects = klass.readable_by(*@read_users)
67 @objects = @objects.where(group_class: 'project')
72 conds << "#{klass.table_name}.owner_uuid = ?"
73 cond_params << opts[:owner_uuid]
74 if opts[:include_linked]
75 haslink = "#{klass.table_name}.uuid IN (SELECT head_uuid FROM links WHERE link_class=#{klass.sanitize 'name'}"
76 haslink += " AND links.tail_uuid=#{klass.sanitize opts[:owner_uuid]}"
81 cond_sql = '(' + conds.join(') OR (') + ')'
82 @objects = @objects.where(cond_sql, *cond_params)
86 @objects = @objects.order("#{klass.table_name}.uuid")
87 @limit = limit_all - all_objects.count
88 apply_where_limit_order_params
89 klass_items_available = @objects.
90 except(:limit).except(:offset).
91 count(:id, distinct: true)
92 @items_available += klass_items_available
93 @offset = [@offset - klass_items_available, 0].max
95 all_objects += @objects.to_a
98 @objects = all_objects