def load_authorized_widget_definitions
if @resource
- @authorized_widget_definitions = java_facade.getWidgets(@resource.scope, @resource.qualifier, @resource.language, @snapshot.available_measures)
+ @authorized_widget_definitions = java_facade.getWidgets(@resource.scope, @resource.qualifier, @resource.language, @snapshot.metric_keys.to_java(:string))
@authorized_widget_definitions=@authorized_widget_definitions.select do |widget|
authorized=widget.getUserRoles().size==0
unless authorized
def display_metric_viewers?(resource, metric_key)
return true if resource.file?
- java_facade.getResourceTabsForMetric(resource.scope, resource.qualifier, resource.language, resource.last_snapshot.available_measures, metric_key).each do |tab|
+ java_facade.getResourceTabsForMetric(resource.scope, resource.qualifier, resource.language, resource.last_snapshot.metric_keys.to_java(:string), metric_key).each do |tab|
tab.getUserRoles().each do |role|
if has_role?(role, resource)
return true
def load_extensions
@extensions=[]
- java_facade.getResourceTabs(@resource.scope, @resource.qualifier, @resource.language, @snapshot.available_measures).each do |tab|
+ java_facade.getResourceTabs(@resource.scope, @resource.qualifier, @resource.language, @snapshot.metric_keys.to_java(:string)).each do |tab|
if tab.getUserRoles().empty?
@extensions<<tab
else
end
end
- def metrics
- if @metrics.nil?
- @metrics = []
- measures_hash.each_key do |metric_id|
- @metrics << Metric::by_id(metric_id)
- end
- @metrics.uniq!
- end
- @metrics
- end
-
def measure(metric)
unless metric.is_a? Metric
metric=Metric.by_key(metric)
project_snapshot.send "period#{period_index}_date"
end
- # IMPORTANT: this is method must used only to pass arguments to the java_facade, as it returns
- # an array of java.lang.String objects.
- # It is used to know which views (page, tab, widget, ...) to display on for a given snapshot
- def available_measures
- if @available_measures.nil?
- @available_measures = metrics.map {|m| m.name}.to_java(java.lang.String)
- end
- @available_measures
+ def metrics
+ @metrics ||=
+ begin
+ measures_hash.keys.map { |metric_id| Metric::by_id(metric_id) }.uniq
+ end
+ end
+
+ # metrics of all the available measures
+ def metric_keys
+ @metric_keys ||=
+ begin
+ metrics.map { |m| m.name }
+ end
end
private
<a href="<%= ApplicationController.root_context -%>/drilldown/violations/<%= @project.id -%><%= "?"+period_param if period_param -%>"><%= message('violations_drilldown.page') -%></a></li>
<li class="<%= 'selected' if request.request_uri.include?('/cloud/index') -%>">
<a href="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>"><%= message('clouds.page') -%></a></li>
- <% controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language, @project.last_snapshot.available_measures).each do |page| %>
+ <% controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language, @project.last_snapshot.metric_keys.to_java(:string)).each do |page| %>
<li class="<%= 'selected' if request.request_uri.include?("page=#{page.getId()}") -%>">
<a href="<%= ApplicationController.root_context -%>/plugins/resource/<%= @project.id -%>?page=<%= page.getId() -%>"><%= message(page.getId() + '.page', :default => page.getTitle()) %></a>
</li>