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 | 48 | end |
49 | 49 | |
50 | 50 | def new_metric_configuration |
51 | - @metric_name = params[:metric_name] | |
51 | + | |
52 | + metric_name = params[:metric_name] | |
52 | 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 | 58 | end |
55 | 59 | |
56 | 60 | def edit_metric_configuration |
57 | 61 | @metric_configuration_code = params[:metric_code] |
58 | 62 | @configuration_name = params[:configuration_name] |
59 | - | |
60 | 63 | @metric_configuration = Kalibro::Entities::MetricConfiguration.new |
61 | 64 | @metric_configuration.code = @metric_configuration_code |
62 | 65 | @metric_configuration.aggregation_form = "MEDIAN" |
... | ... | @@ -75,6 +78,19 @@ class MezuroPluginProfileController < ProfileController |
75 | 78 | |
76 | 79 | def create_metric_configuration |
77 | 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 | 94 | redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" |
79 | 95 | end |
80 | 96 | |
... | ... | @@ -96,3 +112,4 @@ class MezuroPluginProfileController < ProfileController |
96 | 112 | @range.comments = params[:range][:comments] |
97 | 113 | end |
98 | 114 | end |
115 | + | ... | ... |
plugins/mezuro/test/fixtures/range_fixtures.rb
... | ... | @@ -27,7 +27,7 @@ class RangeFixtures |
27 | 27 | end |
28 | 28 | |
29 | 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 | 31 | end |
32 | 32 | |
33 | 33 | end | ... | ... |
plugins/mezuro/views/mezuro_plugin_profile/new_metric_configuration.html.erb
... | ... | @@ -2,19 +2,23 @@ |
2 | 2 | |
3 | 3 | <% form_for :metric_configuration, :url => {:action =>"create_metric_configuration", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %> |
4 | 4 | <%= hidden_field_tag :configuration_name, @configuration_name %> |
5 | + <%= hidden_field_tag :scope, @metric.scope %> | |
6 | + <%= hidden_field_tag :language, @metric.language %> | |
7 | + | |
5 | 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 | 12 | </p> |
10 | 13 | <p> |
11 | 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 | 17 | </p> |
15 | 18 | <p> |
16 | 19 | <%= f.label :description, "Description:" %> |
17 | - <%= f.text_field :description %> | |
20 | + <%= @metric.description %> | |
21 | + <%= text_field_tag :description %> | |
18 | 22 | </p> |
19 | 23 | <p> |
20 | 24 | <%= f.label :code, "Code:" %> |
... | ... | @@ -29,6 +33,7 @@ |
29 | 33 | <%= f.label :weight, "Weight:" %> |
30 | 34 | <%= f.text_field :weight %> |
31 | 35 | </p> |
36 | + | |
32 | 37 | <p> |
33 | 38 | <%= f.submit "Add" %> |
34 | 39 | </p> | ... | ... |