end
def dispatchers_for_scope(scope)
- notification_service.getDispatcherKeysForProperty(scope, "true").sort {|x,y| dispatcher_name(x) <=> dispatcher_name(y)}
+ notification_service.getDispatcherKeysForProperty(scope, "true").to_a.sort {|x,y| dispatcher_name(x) <=> dispatcher_name(y)}
end
def dispatcher_name(dispatcher_key)
end
def user_plugins
- java_facade.getPluginsMetadata().select{|plugin| !plugin.isCore()}.sort
+ java_facade.getPluginsMetadata().select{|plugin| !plugin.isCore()}.to_a.sort
end
end
class Api::WidgetsController < Api::ApiController
def index
- widget_definitions = java_facade.getWidgets().sort_by{|w| w.getId()}
+ widget_definitions = java_facade.getWidgets().to_a.sort_by{|w| w.getId()}
render :json => jsonp(widgets_to_json(widget_definitions))
end
end
def load_widget_definitions(filter_on_category)
- @widget_definitions=java_facade.getWidgets().sort {|w1,w2| widgetL10nName(w1) <=> widgetL10nName(w2)}
+ @widget_definitions=java_facade.getWidgets().to_a.sort {|w1,w2| widgetL10nName(w1) <=> widgetL10nName(w2)}
- @widget_categories=@widget_definitions.map(&:getWidgetCategories).flatten.uniq.sort
+ @widget_categories=@widget_definitions.map(&:getWidgetCategories).to_a.flatten.uniq.sort
unless filter_on_category.blank?
@widget_definitions=@widget_definitions.select { |definition| definition.getWidgetCategories().to_a.include?(filter_on_category) }
end
# GET (modal form)
#
def default_templates_form
- all_templates = Internal.permission_templates.selectAllPermissionTemplates
+ all_templates = Internal.permission_templates.selectAllPermissionTemplates.to_a
@permission_templates_options = all_templates.sort_by {|t| t.name.downcase}.collect {|t| [t.name, t.key]}
@root_qualifiers = get_root_qualifiers
private
def get_root_qualifiers
- Java::OrgSonarServerUi::JRubyFacade.getInstance().getResourceRootTypes().map {|type| type.getQualifier()}.sort
+ Java::OrgSonarServerUi::JRubyFacade.getInstance().getResourceRootTypes().map {|type| type.getQualifier()}.to_a.sort
end
def get_default_templates_per_qualifier(root_qualifiers)
params['qualifiers'] ||= 'TRK'
@query_result = Internal.component_api.findWithUncompleteProjects(params)
- @available_qualifiers = java_facade.getQualifiersWithProperty('hasRolePolicy').collect { |qualifier| [message("qualifiers.#{qualifier}"), qualifier] }.sort
+ @available_qualifiers = java_facade.getQualifiersWithProperty('hasRolePolicy').collect { |qualifier| [message("qualifiers.#{qualifier}"), qualifier] }.to_a.sort
# For the moment, we return projects from rails models, but it should be replaced to return java components (this will need methods on ComponentQueryResult to return roles from component)
@projects = Project.all(
if @components && @components.size == 1
project = Project.by_key(@components.first)
- @permission_templates = Internal.permission_templates.selectAllPermissionTemplates(project.key).sort_by {|t| t.name.downcase}.collect {|pt| [pt.name, pt.key]}
+ @permission_templates = Internal.permission_templates.selectAllPermissionTemplates(project.key).to_a.sort_by {|t| t.name.downcase}.collect {|pt| [pt.name, pt.key]}
else
- @permission_templates = Internal.permission_templates.selectAllPermissionTemplates().sort_by {|t| t.name.downcase}.collect {|pt| [pt.name, pt.key]}
+ @permission_templates = Internal.permission_templates.selectAllPermissionTemplates().to_a.sort_by {|t| t.name.downcase}.collect {|pt| [pt.name, pt.key]}
end
render :partial => 'apply_template_form'
@current_rules = result.rules
- @select_repositories = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.name(), repo.key()] }.sort
+ @select_repositories = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.name(), repo.key()] }.to_a.sort
@select_priority = ANY_SELECTION + RULE_PRIORITIES
@select_activation = [[message('active'), STATUS_ACTIVE], [message('inactive'), STATUS_INACTIVE]]
@select_inheritance = [[message('any'), 'any'], [message('rules_configuration.not_inherited'), 'NOT'], [message('rules_configuration.inherited'), 'INHERITED'],
[message('rules.status.deprecated'), Rule::STATUS_DEPRECATED],
[message('rules.status.ready'), Rule::STATUS_READY]]
@select_sort_by = [[message('rules_configuration.rule_name'), Rule::SORT_BY_RULE_NAME], [message('rules_configuration.creation_date'), Rule::SORT_BY_CREATION_DATE]]
- @select_tags = ANY_SELECTION + Internal.rule_tags.listAllTags().sort
+ @select_tags = ANY_SELECTION + Internal.rule_tags.listAllTags().to_a.sort
end
end
end
def tag_selection_for_rule(rule)
- Internal.rule_tags.listAllTags().sort.collect do |tag|
+ Internal.rule_tags.listAllTags().to_a.sort.collect do |tag|
{
:value => tag,
:selected => (rule.systemTags.contains?(tag) || rule.adminTags.contains?(tag)),
# Api::Utils.insensitive_sort([foo, bar]) { |elt| elt.nullable_field_to_compare }
#
def self.insensitive_sort(arr)
+ ruby_array = arr
+ if arr.respond_to? :to_a
+ ruby_array = arr.to_a
+ end
if block_given?
- arr.sort do |a, b|
+ ruby_array.sort do |a, b|
a_string=yield(a) || ''
b_string=yield(b) || ''
a_string.downcase <=> b_string.downcase || a_string <=> b_string
end
else
- arr.sort do |a, b|
+ ruby_array.sort do |a, b|
a_string=a || ''
b_string=b || ''
a_string.downcase <=> b_string.downcase || a_string <=> b_string