end
def update
attrs_to_update = resource_attrs.reject { |k,v|
[:kind, :etag, :href].index k
}
end
def update
attrs_to_update = resource_attrs.reject { |k,v|
[:kind, :etag, :href].index k
}
if @object and @object.errors and @object.errors.full_messages and not @object.errors.full_messages.empty?
errors = @object.errors.full_messages
else
if @object and @object.errors and @object.errors.full_messages and not @object.errors.full_messages.empty?
errors = @object.errors.full_messages
else
raise ArgumentError.new("Invalid attribute '#{attr}' in condition")
end
case operator.downcase
when '=', '<', '<=', '>', '>=', 'like'
if operand.is_a? String
cond_out << "#{table_name}.#{attr} #{operator} ?"
raise ArgumentError.new("Invalid attribute '#{attr}' in condition")
end
case operator.downcase
when '=', '<', '<=', '>', '>=', 'like'
if operand.is_a? String
cond_out << "#{table_name}.#{attr} #{operator} ?"
- if operator.match(/[<=>]/) and
- model_class.attribute_column(attr).type == :datetime
+ if (# any operator that operates on value rather than
+ # representation:
+ operator.match(/[<=>]/) and
+ model_class.attribute_column(attr).type == :datetime)
+ when 'is_a'
+ operand = [operand] unless operand.is_a? Array
+ cond = []
+ operand.each do |op|
+ cl = ArvadosModel::kind_class op
+ if cl
+ cond << "#{table_name}.#{attr} like ?"
+ param_out << cl.uuid_like_pattern
+ else
+ cond << "1=0"
+ end
+ end
+ cond_out << cond.join(' OR ')
if @where.is_a? Hash and @where.any?
conditions = ['1=1']
@where.each do |attr,value|
if @where.is_a? Hash and @where.any?
conditions = ['1=1']
@where.each do |attr,value|
- @objects = @objects.limit(params[:limit].to_i)
+ @limit = params[:limit].to_i
+ rescue
+ raise ArgumentError.new("Invalid value for limit parameter")
+ end
+ else
+ @limit = 100
+ end
+ @objects = @objects.limit(@limit)
+
+ orders = []
+
+ if params[:offset]
+ begin
+ @objects = @objects.offset(params[:offset].to_i)
+ @offset = params[:offset].to_i
if supplied_token
api_client_auth = ApiClientAuthorization.
includes(:api_client, :user).
if supplied_token
api_client_auth = ApiClientAuthorization.
includes(:api_client, :user).
session[:api_client_authorization_id] = api_client_auth.id
user = api_client_auth.user
api_client = api_client_auth.api_client
session[:api_client_authorization_id] = api_client_auth.id
user = api_client_auth.user
api_client = api_client_auth.api_client
- @object_list[:items_available] = @objects.except(:limit).count
+ @object_list[:items_available] = @objects.
+ except(:limit).except(:offset).
+ count(:id, distinct: true)
where: { type: 'object', required: false },
order: { type: 'string', required: false }
}
end
where: { type: 'object', required: false },
order: { type: 'string', required: false }
}
end
def client_accepts_plain_text_stream
(request.headers['Accept'].split(' ') &
['text/plain', '*/*']).count > 0
end
def render *opts
def client_accepts_plain_text_stream
(request.headers['Accept'].split(' ') &
['text/plain', '*/*']).count > 0
end
def render *opts
- response = opts.first[:json]
- if response.is_a?(Hash) &&
- params[:_profile] &&
- Thread.current[:request_starttime]
- response[:_profile] = {
- request_time: Time.now - Thread.current[:request_starttime]
- }
+ if opts.first
+ response = opts.first[:json]
+ if response.is_a?(Hash) &&
+ params[:_profile] &&
+ Thread.current[:request_starttime]
+ response[:_profile] = {
+ request_time: Time.now - Thread.current[:request_starttime]
+ }
+ end