Commit 76a10b5a064ad13baab929506df0f21caa6c7d8a
Committed by
Rafael Manzo
1 parent
f21dd0b7
Exists in
master
and in
29 other branches
[Mezuro] Adding compound metrics, with script Kalibro Error
Showing
4 changed files
with
93 additions
and
3 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb
... | ... | @@ -13,6 +13,7 @@ class MezuroPluginMyprofileController < ProfileController |
13 | 13 | @collector_name = params[:collector_name] |
14 | 14 | @collector = Kalibro::Client::BaseToolClient.new.base_tool(@collector_name) |
15 | 15 | end |
16 | + | |
16 | 17 | def new_metric_configuration |
17 | 18 | metric_name = params[:metric_name] |
18 | 19 | collector_name = params[:collector_name] |
... | ... | @@ -20,12 +21,14 @@ class MezuroPluginMyprofileController < ProfileController |
20 | 21 | @metric = collector.supported_metrics.find {|metric| metric.name == metric_name} |
21 | 22 | @configuration_name = params[:configuration_name] |
22 | 23 | end |
24 | + | |
23 | 25 | def edit_metric_configuration |
24 | 26 | metric_name = params[:metric_name] |
25 | 27 | @configuration_name = params[:configuration_name] |
26 | 28 | @metric_configuration = Kalibro::Client::MetricConfigurationClient.new.metric_configuration(@configuration_name, metric_name) |
27 | 29 | @metric = @metric_configuration.metric |
28 | 30 | end |
31 | + | |
29 | 32 | def create_metric_configuration |
30 | 33 | @configuration_name = params[:configuration_name] |
31 | 34 | metric_configuration = new_metric_configuration_instance |
... | ... | @@ -99,6 +102,19 @@ class MezuroPluginMyprofileController < ProfileController |
99 | 102 | redirect_to "/#{profile.identifier}/#{configuration_name.downcase.gsub(/\s/, '-')}" |
100 | 103 | end |
101 | 104 | |
105 | + | |
106 | + def new_compound_metric | |
107 | + @configuration_name = params[:configuration_name] | |
108 | + @metric_configurations = Kalibro::Client::ConfigurationClient.new.configuration(@configuration_name).metric_configurations | |
109 | + end | |
110 | + | |
111 | + def create_compound_metric_configuration | |
112 | + @configuration_name = params[:configuration_name] | |
113 | + compound_metric_configuration = new_compound_metric_configuration_instance | |
114 | + # NOT WORKING # Kalibro::Client::MetricConfigurationClient.new.save(compound_metric_configuration, @configuration_name) | |
115 | + redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" | |
116 | + end | |
117 | + | |
102 | 118 | private |
103 | 119 | |
104 | 120 | def new_metric_configuration_instance |
... | ... | @@ -106,8 +122,8 @@ class MezuroPluginMyprofileController < ProfileController |
106 | 122 | metric_configuration.metric = Kalibro::Entities::NativeMetric.new |
107 | 123 | assign_metric_configuration_instance (metric_configuration) |
108 | 124 | end |
109 | - | |
110 | - def assign_metric_configuration_instance (metric_configuration) | |
125 | + | |
126 | + def assign_metric_configuration_instance (metric_configuration) | |
111 | 127 | metric_configuration.metric.name = params[:metric][:name] |
112 | 128 | metric_configuration.metric.description = params[:description] |
113 | 129 | metric_configuration.metric.origin = params[:metric][:origin] |
... | ... | @@ -118,6 +134,23 @@ class MezuroPluginMyprofileController < ProfileController |
118 | 134 | metric_configuration.aggregation_form = params[:metric_configuration][:aggregation_form] |
119 | 135 | metric_configuration |
120 | 136 | end |
137 | + | |
138 | + def new_compound_metric_configuration_instance | |
139 | + metric_configuration = Kalibro::Entities::MetricConfiguration.new | |
140 | + metric_configuration.metric = Kalibro::Entities::CompoundMetric.new | |
141 | + assign_compound_metric_configuration_instance (metric_configuration) | |
142 | + end | |
143 | + | |
144 | + def assign_compound_metric_configuration_instance (metric_configuration) | |
145 | + metric_configuration.metric.name = params[:metric_configuration][:metric_name] | |
146 | + metric_configuration.metric.description = params[:metric_configuration][:description] | |
147 | + metric_configuration.metric.scope = params[:metric_configuration][:scope] | |
148 | + metric_configuration.metric.script = params[:metric_configuration][:script] | |
149 | + metric_configuration.code = params[:metric_configuration][:code] | |
150 | + metric_configuration.weight = params[:metric_configuration][:weight] | |
151 | + metric_configuration.aggregation_form = params[:metric_configuration][:aggregation_form] | |
152 | + metric_configuration | |
153 | + end | |
121 | 154 | |
122 | 155 | def new_range_instance |
123 | 156 | range = Kalibro::Entities::Range.new | ... | ... |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
... | ... | @@ -33,5 +33,5 @@ |
33 | 33 | <td><%= link_to "Remove", :controller => "mezuro_plugin_myprofile", :action => "remove_metric_configuration", :params => |
34 | 34 | {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td> |
35 | 35 | </tr> |
36 | -<% end %> | |
36 | + <% end %> | |
37 | 37 | </table> | ... | ... |
plugins/mezuro/views/mezuro_plugin_myprofile/choose_base_tool.html.erb
1 | 1 | <h2><%= @configuration_name%> Configuration</h2> |
2 | 2 | |
3 | +<%= link_to "* New Compound Metric *", :controller => "mezuro_plugin_myprofile", :action => "new_compound_metric", :params => | |
4 | +{:configuration_name => @configuration_name} %> | |
5 | + | |
3 | 6 | <h5>Base Tools:</h5> |
4 | 7 | <table id="project_info"> |
5 | 8 | <% @tool_names.base_tool_names.each do |collector_name| %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_myprofile/new_compound_metric.html.erb
0 → 100644
... | ... | @@ -0,0 +1,54 @@ |
1 | +<h2><%= @configuration_name %> Configuration</h2> | |
2 | + | |
3 | +<% form_for :metric_configuration, :url => {:action =>"create_compound_metric_configuration", | |
4 | +:controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> | |
5 | + <%= hidden_field_tag :configuration_name, @configuration_name %> | |
6 | + | |
7 | + <p> | |
8 | + <%= f.label :metric_name, "Metric Name:" %> | |
9 | + <%= f.text_field :metric_name %> | |
10 | + </p> | |
11 | + <p> | |
12 | + <%= f.label :description, "Description:" %> | |
13 | + <%= f.text_field :description %> | |
14 | + </p> | |
15 | + <p> | |
16 | + <%= f.label :scope, "scope" %> | |
17 | + <%= f.select :scope, [["Class", "CLASS"]] %> | |
18 | + </p> | |
19 | + <p> | |
20 | + <%= f.label :code, "Code:" %> | |
21 | + <%= f.text_field :code %> | |
22 | + </p> | |
23 | + <p> | |
24 | + <%= f.label :aggregation_form, "Aggregation:" %> | |
25 | + <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | |
26 | + ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | |
27 | + </p> | |
28 | + <p> | |
29 | + <%= f.label :weight, "Weight:" %> | |
30 | + <%= f.text_field :weight %> | |
31 | + </p> | |
32 | + <p> | |
33 | + <%= f.label :script, "Script:" %> | |
34 | + <%= f.text_area :script %> | |
35 | + </p> | |
36 | + | |
37 | + <p> | |
38 | + <%= f.submit "Add" %> | |
39 | + </p> | |
40 | + | |
41 | +<% end %> | |
42 | + | |
43 | +<table> | |
44 | + <tr class="titles"> | |
45 | + <td><h5>Metric Name</h5></td> | |
46 | + <td><h5>Metric Code</h5></td> | |
47 | + </tr> | |
48 | + <% @metric_configurations.each do |metric_configuration| %> | |
49 | + <tr class="metric"> | |
50 | + <td><%= metric_configuration.metric.name %></td> | |
51 | + <td><%= metric_configuration.code %></td> | |
52 | + </tr> | |
53 | + <% end %> | |
54 | +</table> | ... | ... |