]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-249 rename FILTERS.VARIATION_INDEX to FILTERS.PERIOD_INDEX + support variations...
authorsimonbrandhof <simon.brandhof@gmail.com>
Wed, 15 Dec 2010 14:35:33 +0000 (14:35 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Wed, 15 Dec 2010 14:35:33 +0000 (14:35 +0000)
40 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/PastSnapshotFinder.java
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/comments_duplications.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb
plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/chidamber_kemerer.html.erb
plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/file_design.html.erb
plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/package_design.html.erb
pom.xml
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/drilldown_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/drilldown_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/filters_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/models/api/dashboard_configuration.rb
sonar-server/src/main/webapp/WEB-INF/app/models/drilldown.rb
sonar-server/src/main/webapp/WEB-INF/app/models/filter.rb
sonar-server/src/main/webapp/WEB-INF/app/models/filter_context.rb
sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb
sonar-server/src/main/webapp/WEB-INF/app/models/project_measure.rb
sonar-server/src/main/webapp/WEB-INF/app/models/sonar/treemap.rb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_rule_priority.erb
sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/violations.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/filters/_treemap.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/filters/treemap.html.erb
sonar-server/src/main/webapp/WEB-INF/db/migrate/168_add_periods_to_filters.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/db/migrate/168_add_variations_to_filters.rb [deleted file]
sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/Resource.java
sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java
tests/integration/tests/custom-projects/violations-timemachine/v2/src/main/java/org/sonar/tests/violationstimemachine/SecondFileAddedInV2.java [new file with mode: 0644]
tests/integration/tests/src/test/java/org/sonar/tests/integration/VariationsIT.java
tests/integration/tests/src/test/java/org/sonar/tests/integration/ViolationsTimeMachineIT.java

index 15397c8097e4ae4a62f6d3b987abadd357cbf459..2fda1618ed08681e34c77f0329171b699b56d3fa 100644 (file)
@@ -30,7 +30,7 @@ import java.util.Date;
 public class PastSnapshotFinder implements BatchExtension {
 
   /**
-   * IMPORTANT : please update default values in the ruby side too. See app/helpers/FiltersHelper.rb
+   * IMPORTANT : please update default values in the ruby side too. See app/helpers/FiltersHelper.rb, method period_names()
    */
   public static final String DEFAULT_VALUE_1 = PastSnapshotFinderByPreviousAnalysis.MODE;
   public static final String DEFAULT_VALUE_2 = "5";
index 86506a2a9c20a2108f80ce64950c10457f5b76b7..3bab79d5aeb2552a1448a7628ac22a6c10bf85a4 100644 (file)
         <p class="title">Code coverage</p>
         <p>
           <span class="big"><%= format_measure(code_coverage_measure, :suffix => '', :url => url_for_drilldown(Metric::COVERAGE), :default => '-') %></span>
-          <%= dashboard_configuration.variation? ? format_variation(code_coverage_measure) : trend_icon(code_coverage_measure) -%>
+          <%= dashboard_configuration.selected_period? ? format_variation(code_coverage_measure) : trend_icon(code_coverage_measure) -%>
         </p>
         <% line_coverage=measure(Metric::LINE_COVERAGE)
           if line_coverage %>
           <p>
             <%= format_measure(line_coverage, :suffix => ' line coverage', :url => url_for_drilldown(Metric::UNCOVERED_LINES, :highlight =>  Metric::LINE_COVERAGE)) %>
-            <%= dashboard_configuration.variation? ? format_variation(line_coverage) : trend_icon(line_coverage) -%>
+            <%= dashboard_configuration.selected_period? ? format_variation(line_coverage) : trend_icon(line_coverage) -%>
           </p>
         <% end %>
         <% branch_coverage=measure(Metric::BRANCH_COVERAGE)
           if branch_coverage %>
           <p>
             <%= format_measure(branch_coverage, :suffix => ' branch coverage', :url => url_for_drilldown(Metric::UNCOVERED_CONDITIONS, :highlight =>  Metric::BRANCH_COVERAGE)) %>
-            <%= dashboard_configuration.variation? ? format_variation(branch_coverage) : trend_icon(branch_coverage) -%>
+            <%= dashboard_configuration.selected_period? ? format_variation(branch_coverage) : trend_icon(branch_coverage) -%>
           </p>
         <% end %>
         <p>
           <%= format_measure(tests_measure, :suffix => ' tests', :url => url_for_drilldown(Metric::TESTS)) %>
-          <%= dashboard_configuration.variation? ? format_variation(tests_measure) : trend_icon(tests_measure) -%>
+          <%= dashboard_configuration.selected_period? ? format_variation(tests_measure) : trend_icon(tests_measure) -%>
         </p>
         <% skipped_measure=measure(Metric::SKIPPED_TESTS)
            if skipped_measure
         %>
         <p>
           +<%= format_measure(skipped_measure, :suffix => ' skipped', :url => url_for_drilldown(Metric::SKIPPED_TESTS)) %>
-          <%= dashboard_configuration.variation? ? format_variation(skipped_measure) : trend_icon(skipped_measure) -%>
+          <%= dashboard_configuration.selected_period? ? format_variation(skipped_measure) : trend_icon(skipped_measure) -%>
         </p>
         <% end %>
         <p>
           <%= format_measure(execution_time, :suffix => '', :url => url_for_drilldown(Metric::TEST_EXECUTION_TIME)) %>
-          <%= dashboard_configuration.variation? ? format_variation(execution_time) : trend_icon(execution_time) -%>
+          <%= dashboard_configuration.selected_period? ? format_variation(execution_time) : trend_icon(execution_time) -%>
         </p>
       </div>
     </td>
       <h3>Test success</h3>
       <p><span class="big">
         <%= format_measure(success_percentage, :suffix => '', :url => url_for_drilldown(success_percentage)) %></span>
-        <%= dashboard_configuration.variation? ? format_variation(success_percentage) : trend_icon(success_percentage) -%>
+        <%= dashboard_configuration.selected_period? ? format_variation(success_percentage) : trend_icon(success_percentage) -%>
       </p>
       <p>
         <%= format_measure(Metric::TEST_FAILURES, :suffix => ' failures', :url => url_for_drilldown(Metric::TEST_FAILURES)) %>
-        <%= dashboard_configuration.variation? ? format_variation(Metric::TEST_FAILURES) : trend_icon(Metric::TEST_FAILURES) -%>
+        <%= dashboard_configuration.selected_period? ? format_variation(Metric::TEST_FAILURES) : trend_icon(Metric::TEST_FAILURES) -%>
       </p>
       <p>
         <%= format_measure(Metric::TEST_ERRORS, :suffix => ' errors', :url => url_for_drilldown(Metric::TEST_ERRORS)) %>
-        <%= dashboard_configuration.variation? ? format_variation(Metric::TEST_ERRORS) : trend_icon(Metric::TEST_ERRORS) -%>
+        <%= dashboard_configuration.selected_period? ? format_variation(Metric::TEST_ERRORS) : trend_icon(Metric::TEST_ERRORS) -%>
       </p>
   </div>
   <% end %>
index 0f884137877d2e7f68e447d9127edc38556dade4..49fd737da89972c6927b3cb0f4cf2760c6c2cd78 100644 (file)
                      <h3>Comments</h3>
                      <p>
                        <span class="big"><%= format_measure(comment_lines_density, :suffix => '', :url => url_for_drilldown(comment_lines_density)) %></span>
-                       <%= dashboard_configuration.variation? ? format_variation(comment_lines_density) : trend_icon(comment_lines_density) -%>
+                       <%= dashboard_configuration.selected_period? ? format_variation(comment_lines_density) : trend_icon(comment_lines_density) -%>
                      </p>
                      <p>
                        <%= format_measure(comment_lines, :suffix => ' lines', :url => url_for_drilldown(comment_lines)) %>
-                       <%= dashboard_configuration.variation? ? format_variation(comment_lines) : trend_icon(comment_lines) -%>
+                       <%= dashboard_configuration.selected_period? ? format_variation(comment_lines) : trend_icon(comment_lines) -%>
                      </p>
                      <%
                      if comment_blank_lines && comment_blank_lines.value>0
                      %>
                      <p>+<%= format_measure(comment_blank_lines, :suffix => ' blank', :url => url_for_drilldown(comment_blank_lines)) %>
-                     <%= dashboard_configuration.variation? ? format_variation(comment_blank_lines) : trend_icon(comment_blank_lines) -%>
+                     <%= dashboard_configuration.selected_period? ? format_variation(comment_blank_lines) : trend_icon(comment_blank_lines) -%>
                      </p>
                      <% end %>
                      <p>
                        <%= format_measure(public_documented_api_density, :suffix => ' docu. API', :url => url_for_drilldown(Metric::PUBLIC_UNDOCUMENTED_API, :highlight => Metric::PUBLIC_DOCUMENTED_API_DENSITY)) %>
-                       <%= dashboard_configuration.variation? ? format_variation(public_documented_api_density) : trend_icon(public_documented_api_density) -%>
+                       <%= dashboard_configuration.selected_period? ? format_variation(public_documented_api_density) : trend_icon(public_documented_api_density) -%>
                      </p>
                      <p>
                        <%= format_measure(public_undocumented_api, :suffix => ' undocu. API', :url => url_for_drilldown(public_undocumented_api)) %>
-                       <%= dashboard_configuration.variation? ? format_variation(public_undocumented_api) : trend_icon(public_undocumented_api) -%>
+                       <%= dashboard_configuration.selected_period? ? format_variation(public_undocumented_api) : trend_icon(public_undocumented_api) -%>
                      </p>
                      <p>
                        <%= format_measure(commented_out_lines, :suffix => ' commented LOCs', :url => url_for_drilldown(commented_out_lines)) %>
-                       <%= dashboard_configuration.variation? ? format_variation(commented_out_lines) : trend_icon(commented_out_lines) -%>
+                       <%= dashboard_configuration.selected_period? ? format_variation(commented_out_lines) : trend_icon(commented_out_lines) -%>
                      </p>
                    </div>
                    <% end %>
                      <h3>Duplications</h3>
                      <p>
                        <span class="big"><%= format_measure(duplicated_lines_density, :suffix => '', :url => url_for_drilldown(Metric::DUPLICATED_LINES, :highlight =>  'duplicated_lines_density')) %></span>
-                       <%= dashboard_configuration.variation? ? format_variation(duplicated_lines_density) : trend_icon(duplicated_lines_density) -%>
+                       <%= dashboard_configuration.selected_period? ? format_variation(duplicated_lines_density) : trend_icon(duplicated_lines_density) -%>
                      </p>
                      <p>
                        <%= format_measure(duplicated_lines, :suffix => ' lines', :url => url_for_drilldown(duplicated_lines)) %>
-                       <%= dashboard_configuration.variation? ? format_variation(duplicated_lines) : trend_icon(duplicated_lines) -%>
+                       <%= dashboard_configuration.selected_period? ? format_variation(duplicated_lines) : trend_icon(duplicated_lines) -%>
                      </p>
                      <p>
                        <%= format_measure(duplicated_blocks, :suffix => ' blocks', :url => url_for_drilldown(duplicated_blocks)) %>
-                       <%= dashboard_configuration.variation? ? format_variation(duplicated_blocks) : trend_icon(duplicated_blocks) -%>
+                       <%= dashboard_configuration.selected_period? ? format_variation(duplicated_blocks) : trend_icon(duplicated_blocks) -%>
                      </p>
                      <p>
                        <%= format_measure(duplicated_files, :suffix => ' files', :url => url_for_drilldown(duplicated_files)) %>
-                       <%= dashboard_configuration.variation? ? format_variation(duplicated_files) : trend_icon(duplicated_files) -%>
+                       <%= dashboard_configuration.selected_period? ? format_variation(duplicated_files) : trend_icon(duplicated_files) -%>
                      </p>
                    </div>
                    <% end %>
index 9b25bfb986a2afe7678bdf7c7ea0ae50238695ad..89cbda0779508a787f472221982d2dd60374a327 100644 (file)
@@ -17,30 +17,30 @@ complexity=measure('complexity')
          <% if function_complexity %>
            <p>
              <span class="big"><%= format_measure(function_complexity, :suffix => '', :url => url_for_drilldown(function_complexity)) -%></span>/ method
-             <%= dashboard_configuration.variation? ? format_variation(function_complexity) : trend_icon(function_complexity) -%>
+             <%= dashboard_configuration.selected_period? ? format_variation(function_complexity) : trend_icon(function_complexity) -%>
            </p>
          <% end %>
          <% if paragraph_complexity %>
            <p>
               <span class="big"><%= format_measure(paragraph_complexity, :suffix => '', :url => url_for_drilldown(paragraph_complexity)) -%></span>/ paragraph
-              <%= dashboard_configuration.variation? ? format_variation(paragraph_complexity) : trend_icon(paragraph_complexity) -%>
+              <%= dashboard_configuration.selected_period? ? format_variation(paragraph_complexity) : trend_icon(paragraph_complexity) -%>
            </p>
          <% end %>
          <% if class_complexity %>
            <p>
              <span class="big"><%= format_measure(class_complexity, :suffix => '', :url => url_for_drilldown(class_complexity)) -%></span>/ class
-             <%= dashboard_configuration.variation? ? format_variation(class_complexity) : trend_icon(class_complexity) -%>
+             <%= dashboard_configuration.selected_period? ? format_variation(class_complexity) : trend_icon(class_complexity) -%>
            </p>
          <% end %>
          <% if file_complexity %>
            <p>
               <span class="big"><%= format_measure(file_complexity, :suffix => '', :url => url_for_drilldown(file_complexity)) -%></span>/ file
-              <%= dashboard_configuration.variation? ? format_variation(file_complexity) : trend_icon(file_complexity) -%>
+              <%= dashboard_configuration.selected_period? ? format_variation(file_complexity) : trend_icon(file_complexity) -%>
            </p>
          <% end %>
          <% if complexity %>
          <p>
-           Total: <%= format_measure(complexity, :url => url_for_drilldown(complexity)) -%> <%= dashboard_configuration.variation? ? format_variation(complexity) : trend_icon(complexity) -%>
+           Total: <%= format_measure(complexity, :url => url_for_drilldown(complexity)) -%> <%= dashboard_configuration.selected_period? ? format_variation(complexity) : trend_icon(complexity) -%>
          </p>
          <% end %>
         </div>
index 63d343b3c55b1f539b4989d6c0b86709277097e2..ca4d29d18180d880b1b8025e88115b542a28c19d 100644 (file)
                            <span class="big">
                              <%= format_measure(violations, :url => url_for(:controller => 'drilldown', :action => 'violations', :id => @project.key)) -%>
                            </span>
-                           <%= dashboard_configuration.variation? ? format_variation(violations) : trend_icon(violations) -%>
+                           <%= dashboard_configuration.selected_period? ? format_variation(violations) : trend_icon(violations) -%>
                          </div>
         <h3>Rules compliance</h3>
         <div>
           <span class="big">
             <%= format_measure(density, :url => url_for_drilldown(Metric::WEIGHTED_VIOLATIONS, {:highlight => Metric::WEIGHTED_VIOLATIONS})) -%>
           </span>
-          <%= dashboard_configuration.variation? ? format_variation(density) : trend_icon(density) -%>
+          <%= dashboard_configuration.selected_period? ? format_variation(density) : trend_icon(density) -%>
         </div>
                  </div>
                </td>
                <td valign="top" nowrap>
                        <%
         values=[blocker_violations,critical_violations,major_violations,minor_violations,info_violations]
-        if dashboard_configuration.variation?
-          values=values.map{|m| m ? (m.variation(dashboard_configuration.variation_index)||0) : 0}
+        if dashboard_configuration.selected_period?
+          values=values.map{|m| m ? (m.variation(dashboard_configuration.period_index)||0) : 0}
         else
           values=values.map{|m| m ? (m.value||0) : 0}
         end
                                  <%= format_measure(blocker_violations) -%>
                                </td>
                                <td>
-                                 <%= dashboard_configuration.variation? ? format_variation(blocker_violations) : trend_icon(blocker_violations, :empty => true) -%>
+                                 <%= dashboard_configuration.selected_period? ? format_variation(blocker_violations) : trend_icon(blocker_violations, :empty => true) -%>
                                </td>
                                <td align="left" style="padding-bottom:2px; padding-top:2px;">
                                  <% if max > 0 %>
-                                 <% if dashboard_configuration.variation? %>
+                                 <% if dashboard_configuration.selected_period? %>
                                    <%= barchart(:width => 35, :percent => (values[0]<0 ? (100 * values[0] / max).to_i : 0), :color => '#078C00') %>
                                    <%= barchart(:width => 35, :percent => (values[0]>0 ? (100 * values[0] / max).to_i : 0), :color => '#cc0000') %>
                                  <% else %>
                                  <%= format_measure(critical_violations) -%>
                                </td>
                                <td>
-                                 <%= dashboard_configuration.variation? ? format_variation(critical_violations) : trend_icon(critical_violations, :empty => true) -%>
+                                 <%= dashboard_configuration.selected_period? ? format_variation(critical_violations) : trend_icon(critical_violations, :empty => true) -%>
                                </td>
                                <td align="left" style="padding-bottom:2px; padding-top:2px;">
                                  <% if max > 0 %>
-                                 <% if dashboard_configuration.variation? %>
+                                 <% if dashboard_configuration.selected_period? %>
                                    <%= barchart(:width => 35, :percent => (values[1]<0 ? (100 * values[1] / max).to_i : 0), :color => '#078C00') %>
                                    <%= barchart(:width => 35, :percent => (values[1]>0 ? (100 * values[1] / max).to_i : 0), :color => '#cc0000') %>
                                  <% else %>
                                  <%= format_measure(major_violations) -%>
                                </td>
                                <td>
-                                 <%= dashboard_configuration.variation? ? format_variation(major_violations) : trend_icon(major_violations, :empty => true) -%>
+                                 <%= dashboard_configuration.selected_period? ? format_variation(major_violations) : trend_icon(major_violations, :empty => true) -%>
                                </td>
                               <td align="left" style="padding-bottom:2px; padding-top:2px;">
                                 <% if max > 0 %>
-                                 <% if dashboard_configuration.variation? %>
+                                 <% if dashboard_configuration.selected_period? %>
                                    <%= barchart(:width => 35, :percent => (values[2]<0 ? (100 * values[2] / max).to_i : 0), :color => '#078C00') %>
                                    <%= barchart(:width => 35, :percent => (values[2]>0 ? (100 * values[2] / max).to_i : 0), :color => '#cc0000') %>
                                  <% else %>
                                  <%= format_measure(minor_violations) -%>
                                </td>
                                <td>
-                                 <%= dashboard_configuration.variation? ? format_variation(minor_violations) : trend_icon(minor_violations, :empty => true) -%>
+                                 <%= dashboard_configuration.selected_period? ? format_variation(minor_violations) : trend_icon(minor_violations, :empty => true) -%>
                                </td>
                               <td align="left" style="padding-bottom:2px; padding-top:2px;">
                                  <% if max > 0 %>
-                                 <% if dashboard_configuration.variation? %>
+                                 <% if dashboard_configuration.selected_period? %>
                                    <%= barchart(:width => 35, :percent => (values[3]<0 ? (100 * values[3] / max).to_i : 0), :color => '#078C00') %>
                                    <%= barchart(:width => 35, :percent => (values[3]>0 ? (100 * values[3] / max).to_i : 0), :color => '#cc0000') %>
                                  <% else %>
                                  <%= format_measure(info_violations) -%>
                                </td>
                                <td>
-                                 <%= dashboard_configuration.variation? ? format_variation(info_violations) : trend_icon(info_violations, :empty => true) -%>
+                                 <%= dashboard_configuration.selected_period? ? format_variation(info_violations) : trend_icon(info_violations, :empty => true) -%>
                                </td>
                               <td align="left" style="padding-bottom:2px; padding-top:2px;">
                                 <% if max > 0 %>
-                                 <% if dashboard_configuration.variation? %>
+                                 <% if dashboard_configuration.selected_period? %>
                                    <%= barchart(:width => 35, :percent => (values[4]<0 ? (100 * values[4] / max).to_i : 0), :color => '#078C00') %>
                                    <%= barchart(:width => 35, :percent => (values[4]>0 ? (100 * values[4] / max).to_i : 0), :color => '#cc0000') %>
                                  <% else %>
index dd01dc4e71583d188819a6eb567d2d6d9c0718fd..d0d821feabd6614cfdfd036eec98e907a07c6eee 100644 (file)
                            <% if ncloc %>
                              <p>
                                <span class="big"><%= format_measure(ncloc, :suffix => '', :url => url_for_drilldown(ncloc)) -%></span>
-                               <%= dashboard_configuration.variation? ? format_variation(ncloc) : trend_icon(ncloc) -%>
+                               <%= dashboard_configuration.selected_period? ? format_variation(ncloc) : trend_icon(ncloc) -%>
                              </p>
                              <%
                                generated_ncloc=measure('generated_ncloc')
                                if generated_ncloc && generated_ncloc.value>0
                              %>
-                             <p>+<%= format_measure(generated_ncloc, :suffix => ' generated', :url => url_for_drilldown(generated_ncloc)) -%> <%= dashboard_configuration.variation? ? format_variation(generated_ncloc) : trend_icon(generated_ncloc) -%></p>
+                             <p>+<%= format_measure(generated_ncloc, :suffix => ' generated', :url => url_for_drilldown(generated_ncloc)) -%> <%= dashboard_configuration.selected_period? ? format_variation(generated_ncloc) : trend_icon(generated_ncloc) -%></p>
                              <% end %>
-                             <p><%= format_measure(lines, :suffix => ' lines', :url => url_for_drilldown(lines)) -%> <%= dashboard_configuration.variation? ? format_variation(lines) : trend_icon(lines) -%></p>
+                             <p><%= format_measure(lines, :suffix => ' lines', :url => url_for_drilldown(lines)) -%> <%= dashboard_configuration.selected_period? ? format_variation(lines) : trend_icon(lines) -%></p>
                            <% else%>
                              <p><span class="big"><%= format_measure(lines, :suffix => '', :url => url_for_drilldown(lines)) -%> <%= trend_icon(lines) -%></span></p>
                            <% end %>
                              generated_lines=measure('generated_lines')
                              if generated_lines && generated_lines.value>0
                            %>
-                             <p>incl. <%= format_measure(generated_lines, :suffix => ' generated', :url => url_for_drilldown(generated_lines)) -%> <%= dashboard_configuration.variation? ? format_variation(generated_lines) : trend_icon(generated_lines) -%></p>
+                             <p>incl. <%= format_measure(generated_lines, :suffix => ' generated', :url => url_for_drilldown(generated_lines)) -%> <%= dashboard_configuration.selected_period? ? format_variation(generated_lines) : trend_icon(generated_lines) -%></p>
                            <% end %>
                            <% if statements %>
           <p>
-          <%= format_measure(statements, :suffix => ' statements', :url => url_for_drilldown(statements)) -%> <%= dashboard_configuration.variation? ? format_variation(statements) : trend_icon(statements) -%>
+          <%= format_measure(statements, :suffix => ' statements', :url => url_for_drilldown(statements)) -%> <%= dashboard_configuration.selected_period? ? format_variation(statements) : trend_icon(statements) -%>
           </p>
           <% end %>
                            <% if files && measure('classes') %>
-                             <p><%= format_measure(files, :suffix => ' files', :url => url_for_drilldown(files)) -%> <%= dashboard_configuration.variation? ? format_variation(files) : trend_icon(files) -%></p>
+                             <p><%= format_measure(files, :suffix => ' files', :url => url_for_drilldown(files)) -%> <%= dashboard_configuration.selected_period? ? format_variation(files) : trend_icon(files) -%></p>
                            <% end %>
                    </div>
                </td>
                        <h3>Classes</h3>
                        <p>
                          <span class="big"><%= format_measure(classes, :url => url_for_drilldown(classes)) -%></span>
-                         <%= dashboard_configuration.variation? ? format_variation(classes) : trend_icon(classes) -%>
+                         <%= dashboard_configuration.selected_period? ? format_variation(classes) : trend_icon(classes) -%>
                        </p>
-                           <p><%= format_measure(packages, :suffix => ' packages', :url => url_for_drilldown(packages)) -%> <%= dashboard_configuration.variation? ? format_variation(packages) : trend_icon(packages) -%></p>
+                           <p><%= format_measure(packages, :suffix => ' packages', :url => url_for_drilldown(packages)) -%> <%= dashboard_configuration.selected_period? ? format_variation(packages) : trend_icon(packages) -%></p>
                      <% else %>
                        <h3>Files</h3>
                        <p><span class="big"><%= format_measure(files, :url => url_for_drilldown(files)) -%></span>
-                         <%= dashboard_configuration.variation? ? format_variation(files) : trend_icon(files) -%>
+                         <%= dashboard_configuration.selected_period? ? format_variation(files) : trend_icon(files) -%>
                        </p>
-                           <p><%= format_measure('directories', :suffix => ' directories', :url => url_for_drilldown('directories')) -%> <%= dashboard_configuration.variation? ? format_variation('directories') : trend_icon('directories') -%></p>
+                           <p><%= format_measure('directories', :suffix => ' directories', :url => url_for_drilldown('directories')) -%> <%= dashboard_configuration.selected_period? ? format_variation('directories') : trend_icon('directories') -%></p>
                      <% end %>
-                     <p><%= format_measure(functions, :suffix => ' methods', :url => url_for_drilldown(functions)) -%> <%= dashboard_configuration.variation? ? format_variation(functions) : trend_icon(functions) -%></p>
+                     <p><%= format_measure(functions, :suffix => ' methods', :url => url_for_drilldown(functions)) -%> <%= dashboard_configuration.selected_period? ? format_variation(functions) : trend_icon(functions) -%></p>
                      <%
                        if (measure('accessors'))
-                         prefix=(dashboard_configuration.variation? ? '' : '+')
+                         prefix=(dashboard_configuration.selected_period? ? '' : '+')
                      %>
-                       <p><%= format_measure('accessors', :prefix => prefix, :suffix => ' accessors', :url => url_for_drilldown('accessors')) -%> <%= dashboard_configuration.variation? ? format_variation('accessors') : trend_icon('accessors') -%></p>
+                       <p><%= format_measure('accessors', :prefix => prefix, :suffix => ' accessors', :url => url_for_drilldown('accessors')) -%> <%= dashboard_configuration.selected_period? ? format_variation('accessors') : trend_icon('accessors') -%></p>
                      <% end %>
                      <% if measure('paragraphs') %>
-                             <p><%= format_measure('paragraphs', :suffix => ' paragraphs', :url => url_for_drilldown('paragraphs')) -%> <%= dashboard_configuration.variation? ? format_variation('paragraphs') : trend_icon('paragraphs') -%></p>
+                             <p><%= format_measure('paragraphs', :suffix => ' paragraphs', :url => url_for_drilldown('paragraphs')) -%> <%= dashboard_configuration.selected_period? ? format_variation('paragraphs') : trend_icon('paragraphs') -%></p>
                            <% end %>
                    </div>
                </td>
index d1582f9d3c6dd5831c0eaf9451990653a6fcc2b1..c23b968784b5ff051e3540a2f37c38d887e91e4a 100644 (file)
@@ -14,10 +14,10 @@ if lcom || rfc
         <div class="dashbox">
           <h3>LCOM4</h3>
           <p>
-            <span class="big"><%= format_measure(lcom, :suffix => '', :default => '-', :url => url_for_drilldown('lcom4')) -%></span> /class <%= dashboard_configuration.variation? ? format_variation(lcom) : trend_icon(lcom, :big => true) -%>
+            <span class="big"><%= format_measure(lcom, :suffix => '', :default => '-', :url => url_for_drilldown('lcom4')) -%></span> /class <%= dashboard_configuration.selected_period? ? format_variation(lcom) : trend_icon(lcom, :big => true) -%>
           </p>
           <p>
-            <%= format_measure(suspect_lcom4_density, :suffix => ' files having LCOM4>1', :url => url_for_drilldown('lcom4')) %> <%= dashboard_configuration.variation? ? format_variation(suspect_lcom4_density) : trend_icon(suspect_lcom4_density) -%>
+            <%= format_measure(suspect_lcom4_density, :suffix => ' files having LCOM4>1', :url => url_for_drilldown('lcom4')) %> <%= dashboard_configuration.selected_period? ? format_variation(suspect_lcom4_density) : trend_icon(suspect_lcom4_density) -%>
           </p>
         </div>
       </td>
@@ -27,7 +27,7 @@ if lcom || rfc
         <div class="dashbox">
           <h3>RFC</h3>
           <p><span class="big">
-            <%= format_measure(rfc, :suffix => '', :default => '-', :url => url_for_drilldown('rfc')) -%></span> /class <%= dashboard_configuration.variation? ? format_variation(rfc) : trend_icon(rfc, :big => true) -%>
+            <%= format_measure(rfc, :suffix => '', :default => '-', :url => url_for_drilldown('rfc')) -%></span> /class <%= dashboard_configuration.selected_period? ? format_variation(rfc) : trend_icon(rfc, :big => true) -%>
           </p>
         </div>
       </td>
index fd30f977a443ebd72ad9f77be280996da27df021..512a743c133fd9f8e9967235c9cab4134df19f62 100644 (file)
         <div class="dashbox">
           <p class="title">File tangle index</p>
           <p>
-            <span class="big"><%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('file_tangle_index')) -%></span> <%= dashboard_configuration.variation? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%>
+            <span class="big"><%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('file_tangle_index')) -%></span> <%= dashboard_configuration.selected_period? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%>
           </p>
           <% if file_cycles %>
           <p>
-            > <%= format_measure(file_cycles, :suffix => ' cycles', :url => url_for_drilldown('file_cycles')) %> <%= dashboard_configuration.variation? ? format_variation(file_cycles) : trend_icon(file_cycles) -%>
+            > <%= format_measure(file_cycles, :suffix => ' cycles', :url => url_for_drilldown('file_cycles')) %> <%= dashboard_configuration.selected_period? ? format_variation(file_cycles) : trend_icon(file_cycles) -%>
           </p>
           <% end %>
         </div>
@@ -25,7 +25,7 @@
         <div class="dashbox">
           <p class="title">Suspect file dependencies</p>
           <p>
-            <span class="big"><%= format_measure(file_feedback_edges, :url => url_for_drilldown('file_feedback_edges')) -%></span> <%= dashboard_configuration.variation? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%>
+            <span class="big"><%= format_measure(file_feedback_edges, :url => url_for_drilldown('file_feedback_edges')) -%></span> <%= dashboard_configuration.selected_period? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%>
           </p>
         </div>
         <% end %>
index 10380f4f8cfcd8e879179760cd3f7f48af0a4691..3e2611d33e5623571754b898b5cacbc6d3982696 100644 (file)
         <div class="dashbox">
           <p class="title">Package tangle index</p>
           <p>
-            <span class="big"><%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('package_tangle_index')) -%></span> <%= dashboard_configuration.variation? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index, :big => true) -%>
+            <span class="big"><%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => url_for_drilldown('package_tangle_index')) -%></span> <%= dashboard_configuration.selected_period? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index, :big => true) -%>
           </p>
           <% if package_cycles %>
           <p>
-            > <%= format_measure(package_cycles, :suffix => ' cycles', :url => url_for_drilldown('package_cycles')) %> <%= dashboard_configuration.variation? ? format_variation(package_cycles) : trend_icon(package_cycles) -%>
+            > <%= format_measure(package_cycles, :suffix => ' cycles', :url => url_for_drilldown('package_cycles')) %> <%= dashboard_configuration.selected_period? ? format_variation(package_cycles) : trend_icon(package_cycles) -%>
           </p>
           <% end %>
         </div>
           <p class="title">Dependencies to cut</p>
           <p>
             <%= format_measure(package_feedback_edges, :suffix => ' between packages', :url => url_for_drilldown('package_feedback_edges')) %>
-            <%= dashboard_configuration.variation? ? format_variation(package_feedback_edges) : trend_icon(package_feedback_edges) -%>
+            <%= dashboard_configuration.selected_period? ? format_variation(package_feedback_edges) : trend_icon(package_feedback_edges) -%>
           </p>
           <p>
             <%= format_measure(package_tangles, :suffix => ' between files', :url => url_for_drilldown('package_tangles')) %>
-            <%= dashboard_configuration.variation? ? format_variation(package_tangles) : trend_icon(package_tangles) -%>
+            <%= dashboard_configuration.selected_period? ? format_variation(package_tangles) : trend_icon(package_tangles) -%>
           </p>
         </div>
         <% end %>
diff --git a/pom.xml b/pom.xml
index cec5aa37a45958fed82c2850e4f389a451bd7603..4032ae534157af3e61f3ad17f337b85f425ac701 100644 (file)
--- a/pom.xml
+++ b/pom.xml
           <artifactId>maven-enforcer-plugin</artifactId>
           <version>1.0</version>
         </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-failsafe-plugin</artifactId>
+          <version>2.6</version>
+        </plugin>
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
           <artifactId>gwt-maven-plugin</artifactId>
index 83097d23c359014566c3c5d612c2185c168b5708..2daf8b9d5683c515adf9c3ea3f163a7adf755363 100644 (file)
@@ -350,9 +350,16 @@ class Api::ResourcesController < Api::ApiController
           json_measure[:alert]=measure.alert_status
           json_measure[:alert_text]=measure.alert_text
         end
-        if include_trends && measure.tendency
-          json_measure[:trend]=measure.tendency_qualitative
-          json_measure[:var]=measure.tendency
+        if include_trends
+          if measure.tendency
+            json_measure[:trend]=measure.tendency_qualitative
+            json_measure[:var]=measure.tendency
+          end
+          json_measure[:var1]=measure.variation_value_1.to_f if measure.variation_value_1
+          json_measure[:var2]=measure.variation_value_2.to_f if measure.variation_value_2
+          json_measure[:var3]=measure.variation_value_3.to_f if measure.variation_value_3
+          json_measure[:var4]=measure.variation_value_4.to_f if measure.variation_value_4
+          json_measure[:var5]=measure.variation_value_5.to_f if measure.variation_value_5
         end
         if measure.rule_id
           rule = rules_by_id[measure.rule_id]
@@ -391,6 +398,29 @@ class Api::ResourcesController < Api::ApiController
       xml.date(format_datetime(snapshot.created_at))
       xml.description(resource.description) if include_descriptions && resource.description
       xml.copy(resource.copy_resource_id) if resource.copy_resource_id
+
+      if include_trends
+        xml.period1(snapshot.period1_mode) if snapshot.period1_mode
+        xml.period1_param(snapshot.period1_param) if snapshot.period1_param
+        xml.period1_date(format_datetime(snapshot.period1_date)) if snapshot.period1_date
+
+        xml.period2(snapshot.period2_mode) if snapshot.period2_mode
+        xml.period2_param(snapshot.period2_param) if snapshot.period2_param
+        xml.period2_date(format_datetime(snapshot.period2_date)) if snapshot.period2_date
+
+        xml.period3(snapshot.period3_mode) if snapshot.period3_mode
+        xml.period3_param(snapshot.period3_param) if snapshot.period3_param
+        xml.period3_date(format_datetime(snapshot.period3_date)) if snapshot.period3_date
+
+        xml.period4(snapshot.period4_mode) if snapshot.period4_mode
+        xml.period4_param(snapshot.period4_param) if snapshot.period4_param
+        xml.period4_date(format_datetime(snapshot.period4_date)) if snapshot.period4_date
+
+        xml.period5(snapshot.period5_mode) if snapshot.period5_mode
+        xml.period5_param(snapshot.period5_param) if snapshot.period5_param
+        xml.period5_date(format_datetime(snapshot.period5_date)) if snapshot.period5_date
+      end
+
       if measures
         measures.each do |measure|
           xml.msr do
@@ -405,9 +435,16 @@ class Api::ResourcesController < Api::ApiController
               xml.alert(measure.alert_status) if measure.alert_status
               xml.alert_text(measure.alert_text) if measure.alert_text
             end
-            if include_trends && measure.tendency
-              xml.trend(measure.tendency_qualitative)
-              xml.var(measure.tendency)
+            if include_trends
+              if measure.tendency
+                xml.trend(measure.tendency_qualitative)
+                xml.var(measure.tendency)
+              end
+              xml.var1(measure.variation_value_1.to_f) if measure.variation_value_1
+              xml.var2(measure.variation_value_2.to_f) if measure.variation_value_2
+              xml.var3(measure.variation_value_3.to_f) if measure.variation_value_3
+              xml.var4(measure.variation_value_4.to_f) if measure.variation_value_4
+              xml.var5(measure.variation_value_5.to_f) if measure.variation_value_5
             end
             if measure.rule_id
               rule = rules_by_id[measure.rule_id]
index 2ac65f9e3baf0f443daf60994d6b0e6414d574de..c56dab9ba683925ddd6504d3d53a1386db63c4e5 100644 (file)
@@ -169,7 +169,7 @@ class DashboardController < ApplicationController
       end
     end
     @dashboard=(@active ? @active.dashboard : nil)
-    @dashboard_configuration=Api::DashboardConfiguration.new(@dashboard, :variation_index => params[:var])
+    @dashboard_configuration=Api::DashboardConfiguration.new(@dashboard, :period_index => params[:period])
   end
 
   def load_resource
index f5fb0714d83482217bbdf32bcd060c1a9f6fadab..636f55c531ea049a1dd7c53ab67269da26ae71a9 100644 (file)
@@ -65,11 +65,11 @@ class DrilldownController < ApplicationController
     @rule=Rule.by_key_or_id(params[:rule])
 
     # variation measures
-    if params[:var].blank?
-      @variation_index=nil
+    if params[:period].blank?
+      @period_index=nil
       metric_prefix = ''
     else
-      @variation_index=params[:var].to_i
+      @period_index=params[:period].to_i
       metric_prefix = 'new_'
     end
 
@@ -93,7 +93,7 @@ class DrilldownController < ApplicationController
 
 
     # options for Drilldown
-    options={:exclude_zero_value => true, :variation_index => @variation_index}
+    options={:exclude_zero_value => true, :period_index => @period_index}
     if @rule
       params[:rule]=@rule.key  # workaround for SONAR-1767 : the javascript hash named "rp" in the HTML source must contain the rule key, but not the rule id
       options[:rule_id]=@rule.id
index d1be0ad873e3012523df8a965340838f503cfbe9..30cc0c010388f6daa1ff6de691f6d5b1a170534f 100644 (file)
@@ -51,8 +51,8 @@ class FiltersController < ApplicationController
     load_filter_from_params(@filter, params)
 
     @filter.columns.build(:family => 'name', :order_index => 1, :sort_direction => 'ASC')
-    @filter.columns.build(:family => 'metric', :kee => 'ncloc', :order_index => 2, :variation => @filter.default_period?)
-    @filter.columns.build(:family => 'metric', :kee => 'violations_density', :order_index => 3, :variation => @filter.default_period?)
+    @filter.columns.build(:family => 'metric', :kee => 'ncloc', :order_index => 2, :variation => @filter.period?)
+    @filter.columns.build(:family => 'metric', :kee => 'violations_density', :order_index => 3, :variation => @filter.period?)
     @filter.columns.build(:family => 'date', :order_index => 4)
 
     column_index=0
@@ -408,7 +408,7 @@ class FiltersController < ApplicationController
     @width=(params[:width]||'800').to_i
     @height=(params[:height]||'500').to_i
 
-    treemap_options={:variation_index => @filter_context.variation_index}
+    treemap_options={:period_index => @filter_context.period_index}
     @treemap=Sonar::Treemap.new(@filter_context.measures_by_snapshot, @width, @height, @size_metric, @color_metric, treemap_options)
     render :action => "treemap", :layout => false
   end
@@ -428,7 +428,7 @@ class FiltersController < ApplicationController
     filter.favourites=params[:favourites].present?
     filter.resource_id=(params[:path_id].present? ? Project.by_key(params[:path_id]).id : nil) 
     filter.user_id=current_user.id
-    filter.variation_index=params[:variation_index].to_i
+    filter.period_index=params[:period_index].to_i
     filter.criteria=[]
     filter.criteria<<Criterion.new_for_qualifiers(params['qualifiers'])
     filter.criteria<<Criterion.new(:family => 'date', :operator => params['date_operator'], :value => params['date_value']) if params['date_operator'].present?
@@ -484,7 +484,7 @@ class FiltersController < ApplicationController
     end
 
     @filter=nil
-    @variation_index=params[:var].to_i
+    @period_index=params[:period].to_i
     if @active
       @filter=@active.filter
       unless @filter.ajax_loading?
index d240996c7c0901d5aad5ae0f5cb4a4cebd9eff85..242be6bc1f583c6f037de38fbc81eea2ce3d61c4 100644 (file)
@@ -440,8 +440,8 @@ module ApplicationHelper
     end
 
     index=options[:index]
-    if index.nil? && defined?(@dashboard_configuration) && @dashboard_configuration.variation?
-      index = @dashboard_configuration.variation_index
+    if index.nil? && defined?(@dashboard_configuration) && @dashboard_configuration.selected_period?
+      index = @dashboard_configuration.period_index
     end
 
     m.variation(index)
index 0cebecfe02a5ff1dd7cfe27f438c27b06a53403d..f49827b46cbb98bd3611a6b52fd642cb37b60d40 100644 (file)
@@ -28,7 +28,7 @@ module DashboardHelper
     @snapshot.measure(metric_key)
   end
 
-  def variation_select_option(snapshot, index)
+  def period_select_options(snapshot, index)
     return nil if snapshot.nil? || snapshot.project_snapshot.nil?
     mode=snapshot.project_snapshot.send "period#{index}_mode"
     mode_param=snapshot.project_snapshot.send "period#{index}_param"
@@ -44,7 +44,7 @@ module DashboardHelper
         label = "Compare to #{localize(Date.parse(mode_param))}"
       end
       if label
-        selected=(params[:var]==index.to_s ? 'selected' : '')
+        selected=(params[:period]==index.to_s ? 'selected' : '')
         "<option value='#{index}' #{selected}>#{label}</option>"
       end
     else
index 1959e5709aea37bb83b39b1d708bf1cbbfbc6795..0016d5e791932e65b406d002d662f7a7f5e6b2b1 100644 (file)
@@ -19,7 +19,7 @@
  #
 module DrilldownHelper
 
-  def variation_select_option(snapshot, index)
+  def period_select_options(snapshot, index)
     return nil if snapshot.nil? || snapshot.project_snapshot.nil?
     mode=snapshot.project_snapshot.send "period#{index}_mode"
     mode_param=snapshot.project_snapshot.send "period#{index}_param"
@@ -35,7 +35,7 @@ module DrilldownHelper
         label = "New violations since #{localize(Date.parse(mode_param))}"
       end
       if label
-        selected=(params[:var]==index.to_s ? 'selected' : '')
+        selected=(params[:period]==index.to_s ? 'selected' : '')
         "<option value='#{index}' #{selected}>#{label}</option>"
       end
     else
@@ -46,7 +46,7 @@ module DrilldownHelper
 
   def measure_or_variation_value(measure)
     if measure
-      @variation_index ? measure.variation(@variation_index) : measure.value
+      @period_index ? measure.variation(@period_index) : measure.value
     else
       nil
     end
index 159341710d10a54a06cd3aa65956bd0925ee0fea..b6a2b77c04b8eeb9dac2fc13b5fe9eb0313eb345 100644 (file)
@@ -98,7 +98,7 @@ module FiltersHelper
 
 
     #----- VARIATION
-    java_filter.setSortedVariationIndex(filter_context.variation_index)
+    java_filter.setSortedVariationIndex(filter_context.period_index)
 
     #----- EXECUTION
     java_result=java_facade.execute_filter(java_filter)
@@ -160,9 +160,9 @@ module FiltersHelper
   end
 
   def period_names
-    p1=Property.value('sonar.timemachine.variation1', nil, 'previous_analysis')
-    p2=Property.value('sonar.timemachine.variation2', nil, '5')
-    p3=Property.value('sonar.timemachine.variation3', nil, '30')
+    p1=Property.value('sonar.timemachine.period1', nil, 'previous_analysis')
+    p2=Property.value('sonar.timemachine.period2', nil, '5')
+    p3=Property.value('sonar.timemachine.period3', nil, '30')
     [period_name(p1), period_name(p2), period_name(p3)]
   end
 
index 8e7bd6c4d7b11583fc818898a19bfe55b12705df..623c92856d93a1b4314e6ce3cc8ca4325de00add 100644 (file)
 #
 class Api::DashboardConfiguration
 
-  attr_accessor :dashboard, :variation_index, :variation
+  attr_accessor :dashboard, :period_index, :selected_period
 
   def initialize(dashboard, options={})
     @dashboard=dashboard
-    @variation_index=options[:variation_index].to_i
-    @variation=(@variation_index>0)
+    @period_index=options[:period_index].to_i
+    @selected_period=(@period_index>0)
   end
 
   def name
@@ -43,8 +43,8 @@ class Api::DashboardConfiguration
     @dashboard.number_of_columns
   end
 
-  def variation?
-    @variation
+  def selected_period?
+    @selected_period
   end
 
 end
index d424ce3ccc762d35a70d7e3af47cded87d540835..7f916b07d1a765b956ec69e89530db1eb2806990 100644 (file)
@@ -45,7 +45,7 @@ class DrilldownColumn
     @scope=scope
     @snapshot = snapshot
 
-    value_column = (options[:variation_index] ? "variation_value_#{options[:variation_index]}" : 'value')
+    value_column = (options[:period_index] ? "variation_value_#{options[:period_index]}" : 'value')
     order="project_measures.#{value_column}"
     if metric.direction<0
       order += ' DESC'
index 1809b9c7d435ecaf1d907c00fbcc6920416733e8..3cf5c83907f33116cc2b5e822f057de44cc77293 100644 (file)
@@ -125,20 +125,20 @@ class Filter < ActiveRecord::Base
   def advanced_search?
     @advanced_search ||=
       begin
-        !(criterion('language').nil?) || favourites || !(criterion('name').nil?) || !(criterion('key').nil?) || !(criterion('date').nil?) || default_period?
+        !(criterion('language').nil?) || favourites || !(criterion('name').nil?) || !(criterion('key').nil?) || !(criterion('date').nil?) || period?
       end
   end
 
-  def variation_index=(vi)
+  def period_index=(vi)
     if vi && vi>0
-      write_attribute(:variation_index, vi)
+      write_attribute(:period_index, vi)
     else
-      write_attribute(:variation_index, nil)
+      write_attribute(:period_index, nil)
     end
   end
 
-  def default_period?
-    variation_index && variation_index>0
+  def period?
+    period_index && period_index>0
   end
 
   protected
index 1503cabb4add6575b9e6393e15495a9fd2a289fd..3145b1c26f3d18f06d68795fe8bc6962d81757dd 100644 (file)
@@ -18,7 +18,7 @@
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
  #
  class FilterContext
-  attr_accessor :filter, :page_size, :page_id, :security_exclusions, :variation_index, :user, :sorted_column_id, :ascending_sort
+  attr_accessor :filter, :page_size, :page_id, :security_exclusions, :period_index, :user, :sorted_column_id, :ascending_sort
 
   def initialize(filter, options={})
     @filter = filter
@@ -27,7 +27,7 @@
     @sorted_column_id=(options[:sort].blank? ? nil : options[:sort].to_i)
     @ascending_sort=(options[:asc].blank? ? nil : options[:asc]=='true')
     @user=options[:user]
-    @variation_index = (options[:var] ? options[:var].to_i : @filter.variation_index )
+    @period_index = (options[:period] ? options[:period].to_i : @filter.period_index )
     @metric_ids=(options[:metric_ids] || @filter.columns.map{|col| col.metric ? col.metric.id : nil}.compact.uniq)
   end
 
     @security_exclusions==true
   end
 
-  def variation?
-    @variation_index && @variation_index>0
+  def selected_period?
+    @period_index && @period_index>0
   end
 
 
index 4f8afc58f6546eb3b3f6b5a4333fe8aa9e70aac6..d7971393cf62677cb672e6586677cbb6acd6f578 100644 (file)
@@ -28,7 +28,7 @@ class MeasureColor
   # Options :
   #  * min : min value, else the metric worst_value
   #  * max : max value, else the metric best_value
-  #  * variation_index: integer between 1 and 5 if set, else nil
+  #  * period_index: integer between 1 and 5 if set, else nil
   #  * check_alert_status: true|false. Default is true.
   #
   def self.color(measure, options={})
@@ -38,9 +38,9 @@ class MeasureColor
     min_value = options[:min] || measure.metric.worst_value
     percent=-1.0
     
-    if options[:variation_index]
+    if options[:period_index]
       if min_value && max_value
-        value=measure.variation(options[:variation_index])
+        value=measure.variation(options[:period_index])
         percent = value_to_percent(value, min_value, max_value)
       end
     else
index 5c45f336390e402f93c824a8c3b116c04b4ae50c..0089401ff7cb986ea756c07558ef3197200fc933 100644 (file)
@@ -110,9 +110,9 @@ class ProjectMeasure < ActiveRecord::Base
     end
   end
 
-  def variation(variation_index)
+  def variation(period_index)
     result = nil
-    case variation_index
+    case period_index
     when 1
       result=variation_value_1
     when 2
index a7b6c931adb7dfc900fa9546378044ee4018a878..cb9d2bfaa555a066a299c565eab0982e2b4b1bae 100644 (file)
@@ -29,8 +29,8 @@ class Sonar::Treemap
     @width = width
     @height = height
 
-    if options[:variation_index] && options[:variation_index]>0
-      @variation_index = options[:variation_index]
+    if options[:period_index] && options[:period_index]>0
+      @period_index = options[:period_index]
     end
   end
   
@@ -91,8 +91,8 @@ class Sonar::Treemap
   end
 
   def size_value(measure)
-    if @variation_index
-      var=measure.variation(@variation_index)
+    if @period_index
+      var=measure.variation(@period_index)
       var ? var.to_f.abs : 0.0
     elsif measure.value
       measure.value.to_f.abs||0.0
index 2753b7b92f7c9803dbe12ba90a3a9a6d2a1d5b96..958fb837c7b964992492dde6959f8a60b951ede7 100644 (file)
   <% if @snapshot %>
   <div id="snapshot_title" class="page_title">
   <h4>
-  <%
-     profile_measure=@snapshot.measure(Metric::PROFILE)
-   %>
   <%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
-  <% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
   <% if @snapshot.project_snapshot.periods? %>
     -
-    <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
-    <select id="select-comparison" name="var" onchange="submit()" class="small">
+    <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline">
+    <select id="select-comparison" name="period" onchange="submit()" class="small">
       <option value="">Display trends</option>
-      <%= variation_select_option(@snapshot, 1) -%>
-      <%= variation_select_option(@snapshot, 2) -%>
-      <%= variation_select_option(@snapshot, 3) -%>
-      <%= variation_select_option(@snapshot, 4) -%>
-      <%= variation_select_option(@snapshot, 5) -%>
+      <%= period_select_options(@snapshot, 1) -%>
+      <%= period_select_options(@snapshot, 2) -%>
+      <%= period_select_options(@snapshot, 3) -%>
+      <%= period_select_options(@snapshot, 4) -%>
+      <%= period_select_options(@snapshot, 5) -%>
     </select>
       </form>
     <% end %>
   </h4>
   </div>
   <% end %>
-</div>
-
-
-
+</div>
\ No newline at end of file
index c6e52fd8faa2d5d06c144f1217ac565dd54d6b88..e9e8533335724cc9e8c258a795e2f6ba2fba9bb3 100644 (file)
@@ -1,8 +1,8 @@
 <tr class="<%= css -%> <%= 'selected' if Sonar::RulePriority.to_s(priority_id)==params[:priority] -%>">
        <td><%= image_tag "priority/#{priority_id}.png" %></td>
-  <td><%= link_to label, {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :var => @variation_index} %></td>
+  <td><%= link_to label, {:controller => 'drilldown', :action => 'violations', :id => @project.id, :priority => Sonar::RulePriority.to_s(priority_id), :period => @period_index} %></td>
   <td style="padding-left: 10px;" align="right">
-         <%= @variation_index ? format_variation(measure, :index => @variation_index) : format_measure(measure) -%>
+         <%= @period_index ? format_variation(measure, :index => @period_index) : format_measure(measure) -%>
   </td>
   <td align="left">
     <% value = measure_or_variation_value(measure) %>
index 84dd2eef2fff005a0e18befb415fdbb642a8c6f9..131eb5227ee1fd9a7cd76b5a5ca390f70e088abe 100644 (file)
@@ -6,14 +6,14 @@
 <%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
 <% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
 <% if @snapshot.project_snapshot.periods? %>
-- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
-    <select id="select-comparison" name="var" onchange="submit()" class="small">
+- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:period => nil} -%>" style="display: inline">
+    <select id="select-comparison" name="period" onchange="submit()" class="small">
       <option value="">All violations</option>
-      <%= variation_select_option(@snapshot, 1) -%>
-      <%= variation_select_option(@snapshot, 2) -%>
-      <%= variation_select_option(@snapshot, 3) -%>
-      <%= variation_select_option(@snapshot, 4) -%>
-      <%= variation_select_option(@snapshot, 5) -%>
+      <%= period_select_options(@snapshot, 1) -%>
+      <%= period_select_options(@snapshot, 2) -%>
+      <%= period_select_options(@snapshot, 3) -%>
+      <%= period_select_options(@snapshot, 4) -%>
+      <%= period_select_options(@snapshot, 5) -%>
     </select>
   </form>
 <% end %>
@@ -28,9 +28,9 @@
   <td align="left" width="1%" nowrap class="column first">
 
        <%
-         value_column = (@variation_index ? "variation_value_#{@variation_index}" : 'value')
+         value_column = (@period_index ? "variation_value_#{@period_index}" : 'value')
                max = 0
-               if @variation_index
+               if @period_index
       blocker_violations=@snapshot.measure('new_blocker_violations')
       critical_violations=@snapshot.measure('new_critical_violations')
       major_violations=@snapshot.measure('new_major_violations')
@@ -63,7 +63,7 @@
    <div class="scrollable">
        <table class="spacedicon" width="100%" id="col_rules">
              <%
-               if @variation_index
+               if @period_index
                  rule_measures=@snapshot.rule_measures(Metric.by_key('new_violations'), @priority_id)
                else
                  rule_measures=@snapshot.rule_measures(Metric.by_key('violations'), @priority_id)
                          <%= link_to(rule.name, {:overwrite_params => {:rule => rule.key, :sid => nil, :priority => Sonar::RulePriority.to_s(@priority_id)}}, :title => "#{rule.plugin_name}: #{rule.plugin_rule_key}") %>
                    </td>
                    <td class="right" nowrap="nowrap">
-                       <span><%= @variation_index ? format_variation(rule_measure, :index => @variation_index) : rule_measure.formatted_value -%></span>
+                       <span><%= @period_index ? format_variation(rule_measure, :index => @period_index) : rule_measure.formatted_value -%></span>
                    </td>
                    <td class="left last">
                          <%= barchart(:width => 70, :percent => (100 * value / max).to_i, :color => '#777')  if max>0 %>
    <% end %>
    </td>
    <td class="right last" nowrap>
-       <%= @variation_index ? format_variation(measure, :index => @variation_index) : measure.formatted_value -%>
+       <%= @period_index ? format_variation(measure, :index => @period_index) : measure.formatted_value -%>
        <!--[if IE]> &nbsp; &nbsp; <![endif]-->
    </td>
 </tr>
index d6016ab67d62f4e2d994fae35a46ba6841d52f00..f608d3a7da9b908caa183a42860ab2c8062b4f0c 100644 (file)
@@ -1,11 +1,11 @@
 <% filter=@filter_context.filter %>
 <div>
 Period:
-<form action="<%= url_for :overwrite_params => {:var => nil} -%>" style="display: inline" method="get">
-  <select name="var" onchange="submit()" class="small">
+<form action="<%= url_for :overwrite_params => {:period => nil} -%>" style="display: inline" method="get">
+  <select name="period" onchange="submit()" class="small">
       <option value="">None</option>
       <% period_names.each_with_index do |name, index| %>
-         <option value="<%= index+1 -%>" <%= 'selected' if @filter_context.variation_index==index+1 -%>><%= name -%></value>
+         <option value="<%= index+1 -%>" <%= 'selected' if @filter_context.period_index==index+1 -%>><%= name -%></value>
       <% end %>
   </select>
 </form>
@@ -84,11 +84,11 @@ Period:
              measure = @filter_context.measure(snapshot, column.metric)
         %>
           <% if column.variation %>
-            <%= format_variation(measure, :index => @filter_context.variation_index) -%>
+            <%= format_variation(measure, :index => @filter_context.period_index) -%>
           <% else %>
             <%= format_measure(measure) -%>
-            <% if @filter_context.variation? %>
-              <%= format_variation(measure, :index => @filter_context.variation_index) -%>
+            <% if @filter_context.selected_period? %>
+              <%= format_variation(measure, :index => @filter_context.period_index) -%>
             <% else %>
               <%= trend_icon(measure, :empty => true) -%>
             <% end %>
index ee040078283460c812070007b80f0dcb25b6f70a..846634e6fa3061308b58881314ef0b75654d485f 100644 (file)
@@ -10,12 +10,12 @@ color_metric=metrics[1]
 <script>
 var treemap_width = $('treemap').getDimensions().width - 15;
 var treemap_height = document.viewport.getDimensions().height - 220;
-function load_treemap(size_metric, color_metric, hide_form, variation_index) {
+function load_treemap(size_metric, color_metric, hide_form, period_index) {
   $('treemap_loading').show();
   $('treemap').hide();
   <%= remote_function :update => 'treemap', :url => {:action => 'treemap', :id => @filter.id, :show_periods => true},
    :complete => "$('treemap_loading').hide();$('treemap').show();",
-   :with => "'width=' + treemap_width + '&height=' + treemap_height + '&size_metric=' + size_metric + '&color_metric=' + color_metric + '&hide_form=' + hide_form + '&var=' + variation_index" %>
+   :with => "'width=' + treemap_width + '&height=' + treemap_height + '&size_metric=' + size_metric + '&color_metric=' + color_metric + '&hide_form=' + hide_form + '&period=' + period_index" %>
 }
-load_treemap('<%= size_metric.key -%>', '<%= color_metric.key -%>', <%= edit_mode -%>, <%= params[:var].to_i -%>);
+load_treemap('<%= size_metric.key -%>', '<%= color_metric.key -%>', <%= edit_mode -%>, <%= params[:period].to_i -%>);
 </script>
\ No newline at end of file
index 9e4bda43fd51e3943054ab19f1d721ae41ae29cb..88b99c28c9ed4833d6003741a8058b25b870d77c 100644 (file)
@@ -102,10 +102,10 @@ table#columns td {
         <tr>
           <td class="first">Default period:</td>
           <td>
-            <select id="variation_index" name="variation_index">
+            <select id="period_index" name="period_index">
               <option value="">None</option>
               <% period_names.each_with_index do |name, index| %>
-                 <option value="<%= index+1 -%>" <%= 'selected' if @filter.variation_index==index+1 -%>><%= name -%></value>
+                 <option value="<%= index+1 -%>" <%= 'selected' if @filter.period_index==index+1 -%>><%= name -%></value>
               <% end %>
             </select>
           </td>
index 4fa5b299e5908c87f78a09c43e43ff503ef45762..5c881d2f96e16a4476ef67b602633c41858a185a 100644 (file)
     <td>
       <span class="comments">Period:</span>
       <br/>
-      <select name="var" onchange="submit()" class="small">
+      <select name="period" onchange="submit()" class="small">
         <option value="">None</option>
         <% period_names.each_with_index do |name, index| %>
-           <option value="<%= index+1 -%>" <%= 'selected' if params[:var].to_i==index+1 -%>><%= name -%></value>
+           <option value="<%= index+1 -%>" <%= 'selected' if params[:period].to_i==index+1 -%>><%= name -%></value>
         <% end %>
       </select>
     </td>
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/168_add_periods_to_filters.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/168_add_periods_to_filters.rb
new file mode 100644 (file)
index 0000000..23be6b3
--- /dev/null
@@ -0,0 +1,37 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2009 SonarSource SA
+# 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
+#
+
+#
+# Sonar 2.5
+#
+class AddPeriodsToFilters < ActiveRecord::Migration
+
+  def self.up
+    add_column :filters, :period_index, :integer, :null => true
+    Filter.reset_column_information
+
+    add_column :filter_columns, :variation, :boolean, :null => true
+    FilterColumn.reset_column_information
+
+    add_column :criteria, :variation, :boolean, :null => true
+    Criterion.reset_column_information
+  end
+
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/168_add_variations_to_filters.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/168_add_variations_to_filters.rb
deleted file mode 100644 (file)
index 905407f..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Sonar, entreprise quality control tool.
-# Copyright (C) 2009 SonarSource SA
-# 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
-#
-
-#
-# Sonar 2.5
-#
-class AddVariationsToFilters < ActiveRecord::Migration
-
-  def self.up
-    add_column :filters, :variation_index, :integer, :null => true
-    Filter.reset_column_information
-
-    add_column :filter_columns, :variation, :boolean, :null => true
-    FilterColumn.reset_column_information
-
-    add_column :criteria, :variation, :boolean, :null => true
-    Criterion.reset_column_information
-  end
-
-end
index ca9d187920668bc9b963de411ff6ce22f533a599..7679100cd56b24cd84280a0d55003c1f7e9c6160 100644 (file)
@@ -44,6 +44,8 @@ public class Measure extends Model {
    */
   private String ruleCategory;
 
+  private Double variation1, variation2, variation3, variation4, variation5;
+
   public String getMetricKey() {
     return metricKey;
   }
@@ -223,6 +225,86 @@ public class Measure extends Model {
     return this;
   }
 
+  /**
+   * Variation value on period 1. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
+   * @since 2.5
+   */
+  public Double getVariation1() {
+    return variation1;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Measure setVariation1(Double variation1) {
+    this.variation1 = variation1;
+    return this;
+  }
+
+  /**
+   * Variation value on period 2. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
+   * @since 2.5
+   */
+  public Double getVariation2() {
+    return variation2;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Measure setVariation2(Double variation2) {
+    this.variation2 = variation2;
+    return this;
+  }
+
+  /**
+   * Variation value on period 3. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
+   * @since 2.5
+   */
+  public Double getVariation3() {
+    return variation3;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Measure setVariation3(Double variation3) {
+    this.variation3 = variation3;
+    return this;
+  }
+
+  /**
+   * Variation value on period 4. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
+   * @since 2.5
+   */
+  public Double getVariation4() {
+    return variation4;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Measure setVariation4(Double variation4) {
+    this.variation4 = variation4;
+    return this;
+  }
+
+  /**
+   * Variation value on period 5. The value is loaded if ResourceQuery#setIncludeTrends() is set to true.
+   * @since 2.5
+   */
+  public Double getVariation5() {
+    return variation5;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Measure setVariation5(Double variation5) {
+    this.variation5 = variation5;
+    return this;
+  }
+
   @Override
   public String toString() {
     return new StringBuilder().append("Measure{")
index 27f6ba6b209612e631b7cb47096b0e2446a492e6..6df1d4d744b3aaf8cc66c34c66a50346976684ce 100644 (file)
@@ -29,7 +29,7 @@ public class Resource extends Model {
   public static final String SCOPE_SET = "PRJ";
   public static final String SCOPE_SPACE = "DIR";
   public static final String SCOPE_ENTITY = "FIL";
-  
+
   /* QUALIFIERS */
   public static final String QUALIFIER_VIEW = "VW";
   public static final String QUALIFIER_SUBVIEW = "SVW";
@@ -58,6 +58,11 @@ public class Resource extends Model {
   private Date date;
   private List<Measure> measures;
 
+  // periods used for variations and tracking of violations
+  private String period1Mode, period2Mode, period3Mode, period4Mode, period5Mode;
+  private String period1Param, period2Param, period3Param, period4Param, period5Param;
+  private Date period1Date, period2Date, period3Date, period4Date, period5Date;
+
   public Integer getId() {
     return id;
   }
@@ -208,6 +213,231 @@ public class Resource extends Model {
     this.measures = measures;
   }
 
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod1Mode() {
+    return period1Mode;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod1Mode(String period1Mode) {
+    this.period1Mode = period1Mode;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod2Mode() {
+    return period2Mode;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod2Mode(String period2Mode) {
+    this.period2Mode = period2Mode;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod3Mode() {
+    return period3Mode;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod3Mode(String period3Mode) {
+    this.period3Mode = period3Mode;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod4Mode() {
+    return period4Mode;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod4Mode(String period4Mode) {
+    this.period4Mode = period4Mode;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod5Mode() {
+    return period5Mode;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod5Mode(String period5Mode) {
+    this.period5Mode = period5Mode;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod1Param() {
+    return period1Param;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod1Param(String period1Param) {
+    this.period1Param = period1Param;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod2Param() {
+    return period2Param;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod2Param(String period2Param) {
+    this.period2Param = period2Param;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod3Param() {
+    return period3Param;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod3Param(String period3Param) {
+    this.period3Param = period3Param;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod4Param() {
+    return period4Param;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod4Param(String period4Param) {
+    this.period4Param = period4Param;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public String getPeriod5Param() {
+    return period5Param;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod5Param(String period5Param) {
+    this.period5Param = period5Param;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public Date getPeriod1Date() {
+    return period1Date;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod1Date(Date period1Date) {
+    this.period1Date = period1Date;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public Date getPeriod2Date() {
+    return period2Date;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod2Date(Date period2Date) {
+    this.period2Date = period2Date;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public Date getPeriod3Date() {
+    return period3Date;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod3Date(Date period3Date) {
+    this.period3Date = period3Date;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public Date getPeriod4Date() {
+    return period4Date;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod4Date(Date period4Date) {
+    this.period4Date = period4Date;
+    return this;
+  }
+
+  /**
+   * @since 2.5 only on projects, else null
+   */
+  public Date getPeriod5Date() {
+    return period5Date;
+  }
+
+  /**
+   * @since 2.5
+   */
+  public Resource setPeriod5Date(Date period5Date) {
+    this.period5Date = period5Date;
+    return this;
+  }
+
   @Override
   public String toString() {
     return new StringBuilder()
index 81b86cd8b12bbd998cc30516139c31adb34f5480..fba424d4bbe03625db313c06982ba0d822493dfc 100644 (file)
@@ -47,7 +47,22 @@ public class ResourceUnmarshaller extends AbstractUnmarshaller<Resource> {
         .setLanguage(JsonUtils.getString(json, "lang"))
         .setDescription(JsonUtils.getString(json, "description"))
         .setDate(JsonUtils.getDateTime(json, "date"))
-        .setVersion(JsonUtils.getString(json, "version"));
+        .setVersion(JsonUtils.getString(json, "version"))
+        .setPeriod1Mode(JsonUtils.getString(json, "p1"))
+        .setPeriod1Param(JsonUtils.getString(json, "p1p"))
+        .setPeriod1Date(JsonUtils.getDateTime(json, "p1d"))
+        .setPeriod2Mode(JsonUtils.getString(json, "p2"))
+        .setPeriod2Param(JsonUtils.getString(json, "p2p"))
+        .setPeriod2Date(JsonUtils.getDateTime(json, "p2d"))
+        .setPeriod3Mode(JsonUtils.getString(json, "p3"))
+        .setPeriod3Param(JsonUtils.getString(json, "p3p"))
+        .setPeriod3Date(JsonUtils.getDateTime(json, "p3d"))
+        .setPeriod4Mode(JsonUtils.getString(json, "p4"))
+        .setPeriod4Param(JsonUtils.getString(json, "p4p"))
+        .setPeriod4Date(JsonUtils.getDateTime(json, "p4d"))
+        .setPeriod5Mode(JsonUtils.getString(json, "p5"))
+        .setPeriod5Param(JsonUtils.getString(json, "p5p"))
+        .setPeriod5Date(JsonUtils.getDateTime(json, "p5d"));
   }
 
   private void parseMeasures(JSONObject json, Resource resource) {
@@ -85,7 +100,12 @@ public class ResourceUnmarshaller extends AbstractUnmarshaller<Resource> {
         .setRuleCategory(JsonUtils.getString(json, "rule_category"))
         .setRuleSeverity(JsonUtils.getString(json, "rule_priority"))
         .setCharacteristicKey(JsonUtils.getString(json, "ctic_key"))
-        .setCharacteristicName(JsonUtils.getString(json, "ctic_name"));
+        .setCharacteristicName(JsonUtils.getString(json, "ctic_name"))
+        .setVariation1(JsonUtils.getDouble(json, "var1"))
+        .setVariation2(JsonUtils.getDouble(json, "var2"))
+        .setVariation3(JsonUtils.getDouble(json, "var3"))
+        .setVariation4(JsonUtils.getDouble(json, "var4"))
+        .setVariation5(JsonUtils.getDouble(json, "var5"));
     return measure;
   }
 }
diff --git a/tests/integration/tests/custom-projects/violations-timemachine/v2/src/main/java/org/sonar/tests/violationstimemachine/SecondFileAddedInV2.java b/tests/integration/tests/custom-projects/violations-timemachine/v2/src/main/java/org/sonar/tests/violationstimemachine/SecondFileAddedInV2.java
new file mode 100644 (file)
index 0000000..bddd7f0
--- /dev/null
@@ -0,0 +1,10 @@
+package org.sonar.tests.violationstimemachine;
+
+public class SecondFileAddedInV2 {
+
+  public void hasOneViolation() {
+    int i = 0; // unused local variable
+    i++;
+  }
+
+}
index 20307d6367a91a89de1fb2cfafda2deea2627591..e794306ddadf3334f0bccba7773e8c112c5f113c 100644 (file)
  */
 package org.sonar.tests.integration;
 
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.sonar.wsclient.Sonar;
+import org.sonar.wsclient.services.Resource;
+import org.sonar.wsclient.services.ResourceQuery;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+import static org.junit.Assert.assertThat;
+
 public class VariationsIT {
+
+  private static final String TIMEMACHINE_PROJECT = "org.sonar.tests:violations-timemachine";
+
+  private static Sonar sonar;
+
+  @BeforeClass
+  public static void buildServer() {
+    sonar = ITUtils.createSonarWsClient();
+  }
+
+  @Test
+  public void checkBaseVariations() {
+
+    Resource project = getProject("files", "ncloc", "violations");
+
+    // period 1 : previous analysis
+    assertThat(project.getPeriod1Mode(), is("previous_analysis"));
+    assertThat(project.getPeriod1Date(), notNullValue());
+
+    // variations from previous analysis
+    assertThat(project.getMeasure("files").getVariation1(), is(1.0));
+    assertThat(project.getMeasure("ncloc").getVariation1(), is(8.0));
+    assertThat(project.getMeasure("violations").getVariation1(), greaterThan(0.0));
+  }
+
+  private Resource getProject(String... metricKeys) {
+    return sonar.find(ResourceQuery.createForMetrics(TIMEMACHINE_PROJECT, metricKeys).setIncludeTrends(true));
+  }
+
 }
index 14d2774abf7b3a1728940be4c168e3764baab3b1..f3b07ef6d6c08deb7e68901c1fe645f11e0721b7 100644 (file)
@@ -48,7 +48,7 @@ public class ViolationsTimeMachineIT {
     assertThat(snapshot1.getValues(), is(Arrays.asList("0.0", "0.0", "3.0", "4.0", "0.0")));
 
     assertThat(snapshot2.getDate().getMonth(), is(10));
-    assertThat(snapshot2.getValues(), is(Arrays.asList("0.0", "0.0", "4.0", "3.0", "0.0")));
+    assertThat(snapshot2.getValues(), is(Arrays.asList("0.0", "0.0", "5.0", "4.0", "0.0")));
   }
 
   @Test