Commit 30734ee5a6ae18d18ace3f0e9c29c0e13cce36bf
Committed by
Alessandro Palmeira
1 parent
65f1356b
Exists in
master
and in
29 other branches
[Mezuro]Saving Metric configuration on Configuration in KalibroService
Showing
3 changed files
with
32 additions
and
10 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -48,15 +48,18 @@ class MezuroPluginProfileController < ProfileController | @@ -48,15 +48,18 @@ class MezuroPluginProfileController < ProfileController | ||
48 | end | 48 | end |
49 | 49 | ||
50 | def new_metric_configuration | 50 | def new_metric_configuration |
51 | - @metric_name = params[:metric_name] | 51 | + |
52 | + metric_name = params[:metric_name] | ||
52 | @configuration_name = params[:configuration_name] | 53 | @configuration_name = params[:configuration_name] |
53 | - @collector_name = params[:collector_name] | 54 | + collector_name = params[:collector_name] |
55 | + | ||
56 | + collector = Kalibro::Client::BaseToolClient.new.base_tool(collector_name) | ||
57 | + @metric = collector.supported_metrics.find {|metric| metric.name == metric_name} | ||
54 | end | 58 | end |
55 | 59 | ||
56 | def edit_metric_configuration | 60 | def edit_metric_configuration |
57 | @metric_configuration_code = params[:metric_code] | 61 | @metric_configuration_code = params[:metric_code] |
58 | @configuration_name = params[:configuration_name] | 62 | @configuration_name = params[:configuration_name] |
59 | - | ||
60 | @metric_configuration = Kalibro::Entities::MetricConfiguration.new | 63 | @metric_configuration = Kalibro::Entities::MetricConfiguration.new |
61 | @metric_configuration.code = @metric_configuration_code | 64 | @metric_configuration.code = @metric_configuration_code |
62 | @metric_configuration.aggregation_form = "MEDIAN" | 65 | @metric_configuration.aggregation_form = "MEDIAN" |
@@ -75,6 +78,19 @@ class MezuroPluginProfileController < ProfileController | @@ -75,6 +78,19 @@ class MezuroPluginProfileController < ProfileController | ||
75 | 78 | ||
76 | def create_metric_configuration | 79 | def create_metric_configuration |
77 | @configuration_name = params[:configuration_name] | 80 | @configuration_name = params[:configuration_name] |
81 | + metric_configuration = Kalibro::Entities::MetricConfiguration.new | ||
82 | + metric_configuration.metric = Kalibro::Entities::NativeMetric.new | ||
83 | + metric_configuration.metric.name = params[:metric][:name] | ||
84 | + metric_configuration.metric.description = params[:description] | ||
85 | + metric_configuration.metric.origin = params[:metric][:origin] | ||
86 | + metric_configuration.metric.scope = params[:scope] | ||
87 | + metric_configuration.metric.language = params[:language] | ||
88 | + metric_configuration.code = params[:metric_configuration][:code] | ||
89 | + metric_configuration.weight = params[:metric_configuration][:weight] | ||
90 | + metric_configuration.aggregation_form = params[:metric_configuration][:aggregation] | ||
91 | + | ||
92 | + Kalibro::Client::MetricConfigurationClient.new.save(metric_configuration, @configuration_name) | ||
93 | + | ||
78 | redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" | 94 | redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" |
79 | end | 95 | end |
80 | 96 | ||
@@ -96,3 +112,4 @@ class MezuroPluginProfileController < ProfileController | @@ -96,3 +112,4 @@ class MezuroPluginProfileController < ProfileController | ||
96 | @range.comments = params[:range][:comments] | 112 | @range.comments = params[:range][:comments] |
97 | end | 113 | end |
98 | end | 114 | end |
115 | + |
plugins/mezuro/test/fixtures/range_fixtures.rb
@@ -27,7 +27,7 @@ class RangeFixtures | @@ -27,7 +27,7 @@ class RangeFixtures | ||
27 | end | 27 | end |
28 | 28 | ||
29 | def self.amloc_bad_hash | 29 | def self.amloc_bad_hash |
30 | - {:beginning => 19.5, :end => Infinity, :label => 'Bad',:grade => 0.0, :color => 'ffff0000'} | 30 | + {:beginning => 19.5, :end => "INF", :label => 'Bad',:grade => 0.0, :color => 'ffff0000'} |
31 | end | 31 | end |
32 | 32 | ||
33 | end | 33 | end |
plugins/mezuro/views/mezuro_plugin_profile/new_metric_configuration.html.erb
@@ -2,19 +2,23 @@ | @@ -2,19 +2,23 @@ | ||
2 | 2 | ||
3 | <% form_for :metric_configuration, :url => {:action =>"create_metric_configuration", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %> | 3 | <% form_for :metric_configuration, :url => {:action =>"create_metric_configuration", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %> |
4 | <%= hidden_field_tag :configuration_name, @configuration_name %> | 4 | <%= hidden_field_tag :configuration_name, @configuration_name %> |
5 | + <%= hidden_field_tag :scope, @metric.scope %> | ||
6 | + <%= hidden_field_tag :language, @metric.language %> | ||
7 | + | ||
5 | <p> | 8 | <p> |
6 | - <%= f.label :collector_name, "Collector Name:" %> | ||
7 | - <%= @collector_name %> | ||
8 | - <%= f.hidden_field :collector_name, :value => @collector_name %> | 9 | + <%= f.label :origin, "Collector Name:" %> |
10 | + <%= @metric.origin %> | ||
11 | + <%= hidden_field_tag "metric[origin]", @metric.origin %> | ||
9 | </p> | 12 | </p> |
10 | <p> | 13 | <p> |
11 | <%= f.label :metric_name, "Metric Name:" %> | 14 | <%= f.label :metric_name, "Metric Name:" %> |
12 | - <%= @metric_name %> | ||
13 | - <%= f.hidden_field :metric_name, :value => @metric_name %> | 15 | + <%= @metric.name %> |
16 | + <%= hidden_field_tag "metric[name]", @metric.name %> | ||
14 | </p> | 17 | </p> |
15 | <p> | 18 | <p> |
16 | <%= f.label :description, "Description:" %> | 19 | <%= f.label :description, "Description:" %> |
17 | - <%= f.text_field :description %> | 20 | + <%= @metric.description %> |
21 | + <%= text_field_tag :description %> | ||
18 | </p> | 22 | </p> |
19 | <p> | 23 | <p> |
20 | <%= f.label :code, "Code:" %> | 24 | <%= f.label :code, "Code:" %> |
@@ -29,6 +33,7 @@ | @@ -29,6 +33,7 @@ | ||
29 | <%= f.label :weight, "Weight:" %> | 33 | <%= f.label :weight, "Weight:" %> |
30 | <%= f.text_field :weight %> | 34 | <%= f.text_field :weight %> |
31 | </p> | 35 | </p> |
36 | + | ||
32 | <p> | 37 | <p> |
33 | <%= f.submit "Add" %> | 38 | <%= f.submit "Add" %> |
34 | </p> | 39 | </p> |