aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2012-03-20 17:52:36 +0100
committerFabrice Bellingard <bellingard@gmail.com>2012-03-20 17:56:51 +0100
commit3d8328d2e842a9bb15d35e428235f45fb9d9da1d (patch)
tree47c90fe4a4ffe2d8655523cc42a3344efc922436 /sonar-server/src/main/webapp/WEB-INF
parent73b2bff83aa9fcac6fe1985ddccd76d62a246f2f (diff)
downloadsonarqube-3d8328d2e842a9bb15d35e428235f45fb9d9da1d.tar.gz
sonarqube-3d8328d2e842a9bb15d35e428235f45fb9d9da1d.zip
SONAR-3006 Remove ChartsControler and related code
This is useless now the TimeMachine service has been replaced.
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/charts_controller.rb59
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/chart_helper.rb22
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/trends_chart.rb53
3 files changed, 0 insertions, 134 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/charts_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/charts_controller.rb
deleted file mode 100644
index 4327242c00c..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/charts_controller.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Sonar, entreprise quality control tool.
-# Copyright (C) 2008-2012 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# Sonar is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 3 of the License, or (at your option) any later version.
-#
-# Sonar is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with Sonar; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
-#
-
-class ChartsController < ApplicationController
-
- DEFAULT_TRENDS_WIDTH = 700
- DEFAULT_TRENDS_HEIGHT = 250
-
- CHART_COLORS = ["4192D9", "800000", "A7B307", "913C9F", "329F4D"]
-
- def trends
- resource=Project.by_key(params[:id])
- bad_request("Unknown resource") unless resource
- access_denied unless has_role?(:user, resource)
-
- metric_keys=params[:metrics]
- metrics=[]
- if metric_keys
- metric_keys.split(',').each do |key|
- metric=Metric.by_key(key)
- metrics<<metric if metric
- end
- end
-
- bad_request("Unknown metrics") if metrics.empty?
-
- width=(params[:w] ? params[:w].to_i : DEFAULT_TRENDS_WIDTH)
- height=(params[:h] ? params[:h].to_i : DEFAULT_TRENDS_HEIGHT)
- display_legend = (params[:legend] ? params[:legend]=='true' : true)
-
- options={}
- if params[:from]
- options[:from]=Date::strptime(params[:from])
- end
- if params[:to]
- options[:to]=Date::strptime(params[:to])
- end
-
- stream = TrendsChart.png_chart(width, height, resource, metrics, params[:locale] || I18n.locale.to_s, display_legend, options)
- send_data stream, :type => 'image/png', :disposition => 'inline'
- end
-end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/chart_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/chart_helper.rb
deleted file mode 100644
index 3f0594566f9..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/chart_helper.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Sonar, entreprise quality control tool.
-# Copyright (C) 2008-2012 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# Sonar is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 3 of the License, or (at your option) any later version.
-#
-# Sonar is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with Sonar; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
-#
-module ChartHelper
-
-end \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/trends_chart.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/trends_chart.rb
index 0780d64a390..207c695598d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/trends_chart.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/trends_chart.rb
@@ -19,26 +19,6 @@
#
class TrendsChart
- def self.png_chart(width, height, resource, metrics, locale, display_legend, options={})
- java_chart = Java::OrgSonarServerChartsJruby::TrendsChart.new(width, height, locale.to_s.gsub(/\-/, '_'), display_legend)
-
- init_series(java_chart, metrics)
- metric_ids=metrics.map{|m| m.id}
- add_measures(java_chart, time_machine_measures(resource, metric_ids, options))
- add_labels(java_chart, resource);
-
- export_chart_as_png(java_chart)
- end
-
-
- protected
-
- def self.init_series(java_chart, metrics)
- metrics.each do |metric|
- java_chart.initSerie(metric.id, metric.short_name, metric.val_type==Metric::VALUE_TYPE_PERCENT)
- end
- end
-
def self.time_machine_measures(resource, metric_ids, options={})
unless metric_ids.empty?
sql= "select s.created_at as created_at, m.value as value, m.metric_id as metric_id, s.id as sid " +
@@ -65,38 +45,5 @@ class TrendsChart
ProjectMeasure.connection.select_all(Project.send(:sanitize_sql, conditions))
end
end
-
- def self.add_measures(java_chart, sqlresult)
- if sqlresult && sqlresult.size>0
- sqlresult.each do |hash|
- value = hash["value"].to_f
- time = Time.parse( hash["created_at"].to_s )
- serie_id=hash["metric_id"].to_i
- java_chart.addMeasure(value, time, serie_id)
- end
- end
- end
-
- def self.add_labels(java_chart, resource)
- categories=EventCategory.categories(true)
- category_names=categories.map{|cat| cat.name}
- Event.find(:all, :conditions => {:resource_id => resource.id}).each do |event|
- if category_names.include?(event.category)
- time = Time.parse( event.event_date.to_s )
- java_chart.addLabel(time, event.name, event.category==EventCategory::KEY_ALERT)
- end
- end
- end
-
- def self.export_chart_as_png(java_chart)
- java_int_array_to_bytes(java_chart.exportChartAsPNG())
- end
-
- def self.java_int_array_to_bytes( java_int_array )
- # pack does not exists on the return java array proxy object
- # the java proxy array contains integers, they must be packed
- # to return a correct byte array stream (c*)
- [].concat(java_int_array).pack("c*")
- end
end \ No newline at end of file