]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 add EVENTS.EVENT_DATA to store links on quality profile changes
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 23 Jun 2014 22:15:21 +0000 (00:15 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 23 Jun 2014 22:26:49 +0000 (00:26 +0200)
19 files changed:
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/events.html.erb
sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java
sonar-batch/src/test/java/org/sonar/batch/rule/QProfileEventsDecoratorTest.java
sonar-batch/src/test/resources/org/sonar/batch/components/PastSnapshotFinderByPreviousVersionTest/no-previous-version.xml
sonar-batch/src/test/resources/org/sonar/batch/components/PastSnapshotFinderByPreviousVersionTest/with-previous-version-deleted.xml
sonar-batch/src/test/resources/org/sonar/batch/components/PastSnapshotFinderByPreviousVersionTest/with-previous-version.xml
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
sonar-core/src/main/resources/org/sonar/l10n/core.properties
sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteSnapshot.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldPurgeSnapshot.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldSelectPurgeableSnapshots.xml
sonar-plugin-api/src/main/java/org/sonar/api/batch/Event.java
sonar-server/src/main/webapp/WEB-INF/db/migrate/555_add_event_data_column.rb [new file with mode: 0644]

index 6cdfe968f9195be439e50c78359fb6200eccf1a6..e1cf3f78383a9ef6d17dcaf6f1c9df39e6f4e758 100644 (file)
 <%
    events.each do |event|
      categ = event.category
+     profile_data={}
+     if categ=='Profile' && event.event_data
+       profile_data=Hash[*(event.event_data.split(';').map { |elt| elt.split('=') }.flatten)]
+     end
 %>
 <tr class="<%= cycle 'even','odd' -%> event cat_<%= categ.parameterize -%>">
     <td x="<%= event.event_date -%>"><%= l(event.event_date.to_date) %></td>
     <td><%= h message('event.category.' + categ, :default => categ) %></td>
-    <td><%= event.name %></td>
+    <td>
+      <%= link_to_if profile_data['key'] && profile_data['from'] && profile_data['to'], event.name,
+                             :controller => 'profiles', :action => 'changelog', :key => profile_data['key'],
+                             :since =>  profile_data['from'], :to => profile_data['to'] -%>
+    </td>
     <td>
       <% unless event.description.blank? %>
         <i class="icon-info" title="<%= h event.description -%>"></i>
index 68aa7d907cd5d9ed60375fa10bf339bda177eba7..3774f9f1b5e6f17b3e27e8eab26ef1ff3b825f3c 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.batch.rule;
 
+import com.google.common.collect.ImmutableSortedMap;
 import org.sonar.api.batch.Decorator;
 import org.sonar.api.batch.DecoratorContext;
 import org.sonar.api.batch.DependsUpon;
@@ -33,6 +34,9 @@ import org.sonar.api.resources.Languages;
 import org.sonar.api.resources.Project;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.Resource;
+import org.sonar.api.utils.KeyValueFormat;
+import org.sonar.batch.index.PersistenceManager;
+import org.sonar.core.UtcDateUtils;
 
 import javax.annotation.CheckForNull;
 
@@ -43,10 +47,12 @@ public class QProfileEventsDecorator implements Decorator {
 
   private final TimeMachine timeMachine;
   private final Languages languages;
+  private final PersistenceManager persistenceManager;
 
-  public QProfileEventsDecorator(TimeMachine timeMachine, Languages languages) {
+  public QProfileEventsDecorator(TimeMachine timeMachine, Languages languages, PersistenceManager pm) {
     this.timeMachine = timeMachine;
     this.languages = languages;
+    this.persistenceManager = pm;
   }
 
   @DependsUpon
@@ -81,31 +87,40 @@ public class QProfileEventsDecorator implements Decorator {
       QProfile previousProfile = previousProfiles.get(profile.getKey());
       if (previousProfile != null) {
         if (profile.getRulesUpdatedAt().after(previousProfile.getRulesUpdatedAt())) {
-          markAsUsed(context, profile);
+          markAsChanged(context, previousProfile, profile);
         }
       } else {
-        markAsUsed(context, profile);
+        markAsAdded(context, profile);
       }
     }
 
     // Detect profiles that are not used anymore
     for (QProfile previousProfile : previousProfiles.values()) {
       if (!currentProfiles.containsKey(previousProfile.getKey())) {
-        markAsUnused(context, previousProfile);
+        markAsRemoved(context, previousProfile);
       }
     }
   }
 
-  private void markAsUnused(DecoratorContext context, QProfile profile) {
-    Language language = languages.get(profile.getLanguage());
-    String languageName = language != null ? language.getName() : profile.getLanguage();
-    context.createEvent("Stop using " + profile.getName() + " (" + languageName + ")", profile.getName() + " no more used for " + languageName, Event.CATEGORY_PROFILE, null);
+  private void markAsChanged(DecoratorContext context, QProfile previousProfile, QProfile profile) {
+    // DecoratorContext does not allow to set event data, so SonarIndex must be used
+    Event event = new Event();
+    event.setName(String.format("Changes in %s", profileLabel(profile)));
+    event.setCategory(Event.CATEGORY_PROFILE);
+    String data = KeyValueFormat.format(ImmutableSortedMap.of(
+      "key", profile.getKey(),
+      "from", UtcDateUtils.formatDateTime(previousProfile.getRulesUpdatedAt()),
+      "to", UtcDateUtils.formatDateTime(profile.getRulesUpdatedAt())));
+    event.setData(data);
+    persistenceManager.saveEvent(context.getResource(), event);
   }
 
-  private void markAsUsed(DecoratorContext context, QProfile profile) {
-    Language language = languages.get(profile.getLanguage());
-    String languageName = language != null ? language.getName() : profile.getLanguage();
-    context.createEvent("Use " + profile.getName() + " (" + languageName + ")", profile.getName() + " used for " + languageName, Event.CATEGORY_PROFILE, null);
+  private void markAsRemoved(DecoratorContext context, QProfile profile) {
+    context.createEvent(String.format("Stop using %s", profileLabel(profile)), null, Event.CATEGORY_PROFILE, null);
+  }
+
+  private void markAsAdded(DecoratorContext context, QProfile profile) {
+    context.createEvent(String.format("Use %s", profileLabel(profile)), null, Event.CATEGORY_PROFILE, null);
   }
 
   @CheckForNull
@@ -120,6 +135,12 @@ public class QProfileEventsDecorator implements Decorator {
     return measures.get(0);
   }
 
+  private String profileLabel(QProfile profile) {
+    Language language = languages.get(profile.getLanguage());
+    String languageName = language != null ? language.getName() : profile.getLanguage();
+    return String.format("'%s' (%s)", profile.getName(), languageName);
+  }
+
   @Override
   public String toString() {
     return getClass().getSimpleName();
index c0010d823f01a67abbb4b9d5172cd627045e44a0..c1afcb1e2eed9ddab936d779b358e8741b28ae1d 100644 (file)
@@ -38,6 +38,8 @@
  */
 package org.sonar.batch.rule;
 
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
 import org.junit.Test;
 import org.sonar.api.batch.DecoratorContext;
 import org.sonar.api.batch.Event;
@@ -48,6 +50,8 @@ import org.sonar.api.measures.Measure;
 import org.sonar.api.resources.Java;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Resource;
+import org.sonar.batch.index.PersistenceManager;
 
 import java.util.Arrays;
 import java.util.Date;
@@ -58,6 +62,7 @@ import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.same;
 import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.argThat;
 
 public class QProfileEventsDecoratorTest {
 
@@ -69,11 +74,14 @@ public class QProfileEventsDecoratorTest {
   DecoratorContext decoratorContext = mock(DecoratorContext.class);
   TimeMachine timeMachine = mock(TimeMachine.class);
   Languages languages = mock(Languages.class);
-  QProfileEventsDecorator decorator = new QProfileEventsDecorator(timeMachine, languages);
+  PersistenceManager persistenceManager = mock(PersistenceManager.class);
+  QProfileEventsDecorator decorator = new QProfileEventsDecorator(timeMachine, languages, persistenceManager);
 
   @Test
-  public void execute_on_all_projects() {
+  public void basic_tests() {
     assertThat(decorator.shouldExecuteOnProject(project)).isTrue();
+    assertThat(decorator.toString()).isEqualTo("QProfileEventsDecorator");
+    assertThat(decorator.dependsUpon()).isNotNull();
   }
 
   @Test
@@ -104,17 +112,26 @@ public class QProfileEventsDecoratorTest {
 
     decorator.decorate(project, decoratorContext);
 
-    verify(decoratorContext).createEvent(
-      eq("Use Java One (Java)"),
-      eq("Java One used for Java"),
-      same(Event.CATEGORY_PROFILE), any(Date.class));
+    verify(persistenceManager).saveEvent(any(Resource.class), argThat(new BaseMatcher<Event>() {
+      @Override
+      public void describeTo(Description description) {
+      }
+
+      @Override
+      public boolean matches(Object item) {
+        Event event = (Event) item;
+        return event.getCategory().equals(Event.CATEGORY_PROFILE) &&
+          "Changes in 'Java One' (Java)".equals(event.getName()) &&
+          "from=2014-01-15T12:00:00+0000;key=J1;to=2014-02-20T12:00:00+0000".equals(event.getData());
+      }
+    }));
   }
 
   @Test
   public void generate_event_if_profile_not_used_anymore() {
     Measure previousMeasure = new Measure(CoreMetrics.QUALITY_PROFILES, "[" + JAVA_V1_JSON + "]");
     // Different profile
-    Measure newMeasure = new Measure(CoreMetrics.QUALITY_PROFILES, "[" +  JAVA_OTHER_JSON + "]");
+    Measure newMeasure = new Measure(CoreMetrics.QUALITY_PROFILES, "[" + JAVA_OTHER_JSON + "]");
 
     when(timeMachine.getMeasures(any(TimeMachineQuery.class)))
       .thenReturn(Arrays.asList(previousMeasure));
@@ -125,8 +142,8 @@ public class QProfileEventsDecoratorTest {
     decorator.decorate(project, decoratorContext);
 
     verify(decoratorContext).createEvent(
-      eq("Stop using Java One (Java)"),
-      eq("Java One no more used for Java"),
+      eq("Stop using 'Java One' (Java)"),
+      eq((String) null),
       same(Event.CATEGORY_PROFILE), any(Date.class));
   }
 
index 08566ee2bf16bb824f4cde5306aece910540b4f0..eca7da3d44491419c1706eb592bc2eaa627db288 100644 (file)
              scope="PRJ" qualifier="TRK" created_at="2008-11-09 13:58:00.00" build_date="2008-11-09 13:58:00.00" version="1.2-SNAPSHOT" path=""
              status="U" islast="true" depth="0" />
   
-  <events id="2" name="Foo" resource_id="1" snapshot_id="1000" category="Other" event_date="2008-11-03 13:58:00.00" created_at="2008-11-03 13:58:00.00" description=""/>
-  <events id="4" name="Bar" resource_id="1" snapshot_id="1001" category="Other" event_date="2008-11-05 13:58:00.00" created_at="2008-11-05 13:58:00.00" description=""/>
-  <events id="5" name="Uhh" resource_id="1" snapshot_id="1002" category="Other" event_date="2008-11-07 13:58:00.00" created_at="2008-11-07 13:58:00.00" description=""/>
-  <events id="6" name="1.2-SNAPSHOT" resource_id="1" snapshot_id="1003" category="Version" event_date="2008-11-09 13:58:00.00" created_at="2008-11-09 13:58:00.00" description=""/>
+  <events id="2" name="Foo" resource_id="1" snapshot_id="1000" category="Other" event_date="2008-11-03 13:58:00.00" created_at="2008-11-03 13:58:00.00" description=""
+          event_data="[null]"/>
+  <events id="4" name="Bar" resource_id="1" snapshot_id="1001" category="Other" event_date="2008-11-05 13:58:00.00" created_at="2008-11-05 13:58:00.00" description=""
+          event_data="[null]"/>
+  <events id="5" name="Uhh" resource_id="1" snapshot_id="1002" category="Other" event_date="2008-11-07 13:58:00.00" created_at="2008-11-07 13:58:00.00" description=""
+          event_data="[null]"/>
+  <events id="6" name="1.2-SNAPSHOT" resource_id="1" snapshot_id="1003" category="Version" event_date="2008-11-09 13:58:00.00" created_at="2008-11-09 13:58:00.00" description=""
+          event_data="[null]"/>
 
-</dataset>
\ No newline at end of file
+</dataset>
index 6c282cf30e3a92c43d7adef54c59e83a238ee29c..0612f65e11f72c476dcd5323b20876d3e0792812 100644 (file)
              scope="PRJ" qualifier="TRK" created_at="2008-11-09 13:58:00.00" build_date="2008-11-09 13:58:00.00" version="1.2-SNAPSHOT" path=""
              status="U" islast="true" depth="0" />
   
-  <events id="1" name="1.0" resource_id="1" snapshot_id="1000" category="Version" event_date="2008-11-02 13:58:00.00" created_at="2008-11-02 13:58:00.00" description=""/>
-  <events id="2" name="Foo" resource_id="1" snapshot_id="1000" category="Other" event_date="2008-11-03 13:58:00.00" created_at="2008-11-03 13:58:00.00" description=""/>
+  <events id="1" name="1.0" resource_id="1" snapshot_id="1000" category="Version" event_date="2008-11-02 13:58:00.00" created_at="2008-11-02 13:58:00.00" description=""
+          event_data="[null]"/>
+  <events id="2" name="Foo" resource_id="1" snapshot_id="1000" category="Other" event_date="2008-11-03 13:58:00.00" created_at="2008-11-03 13:58:00.00" description=""
+          event_data="[null]"/>
   <!-- The "1.1" version was deleted from the history :  -->
   <!-- events id="3" name="1.1" resource_id="1" snapshot_id="1001" category="Version" event_date="2008-11-04 13:58:00.00" created_at="2008-11-04 13:58:00.00" description=""/-->
-  <events id="4" name="Bar" resource_id="1" snapshot_id="1001" category="Other" event_date="2008-11-05 13:58:00.00" created_at="2008-11-05 13:58:00.00" description=""/>
-  <events id="5" name="Uhh" resource_id="1" snapshot_id="1002" category="Other" event_date="2008-11-07 13:58:00.00" created_at="2008-11-07 13:58:00.00" description=""/>
-  <events id="6" name="1.2-SNAPSHOT" resource_id="1" snapshot_id="1003" category="Version" event_date="2008-11-09 13:58:00.00" created_at="2008-11-09 13:58:00.00" description=""/>
+  <events id="4" name="Bar" resource_id="1" snapshot_id="1001" category="Other" event_date="2008-11-05 13:58:00.00" created_at="2008-11-05 13:58:00.00" description=""
+          event_data="[null]"/>
+  <events id="5" name="Uhh" resource_id="1" snapshot_id="1002" category="Other" event_date="2008-11-07 13:58:00.00" created_at="2008-11-07 13:58:00.00" description=""
+          event_data="[null]"/>
+  <events id="6" name="1.2-SNAPSHOT" resource_id="1" snapshot_id="1003" category="Version" event_date="2008-11-09 13:58:00.00" created_at="2008-11-09 13:58:00.00" description=""
+          event_data="[null]"/>
 
-</dataset>
\ No newline at end of file
+</dataset>
index 077b4eea7f0c64ce31ac57466c2f13c34c268e6c..a708a476c077955484db591a285e41fd9376a6cb 100644 (file)
              scope="PRJ" qualifier="TRK" created_at="2008-11-09 13:58:00.00" build_date="2008-11-09 13:58:00.00" version="1.2-SNAPSHOT" path=""
              status="U" islast="true" depth="0" />
   
-  <events id="1" name="1.0" resource_id="1" snapshot_id="1000" category="Version" event_date="2008-11-02 13:58:00.00" created_at="2008-11-02 13:58:00.00" description=""/>
-  <events id="2" name="Foo" resource_id="1" snapshot_id="1000" category="Other" event_date="2008-11-03 13:58:00.00" created_at="2008-11-03 13:58:00.00" description=""/>
-  <events id="3" name="1.1" resource_id="1" snapshot_id="1001" category="Version" event_date="2008-11-04 13:58:00.00" created_at="2008-11-04 13:58:00.00" description=""/>
-  <events id="4" name="Bar" resource_id="1" snapshot_id="1001" category="Other" event_date="2008-11-05 13:58:00.00" created_at="2008-11-05 13:58:00.00" description=""/>
-  <events id="5" name="Uhh" resource_id="1" snapshot_id="1002" category="Other" event_date="2008-11-07 13:58:00.00" created_at="2008-11-07 13:58:00.00" description=""/>
-  <events id="6" name="1.2-SNAPSHOT" resource_id="1" snapshot_id="1003" category="Version" event_date="2008-11-09 13:58:00.00" created_at="2008-11-09 13:58:00.00" description=""/>
+  <events id="1" name="1.0" resource_id="1" snapshot_id="1000" category="Version" event_date="2008-11-02 13:58:00.00" created_at="2008-11-02 13:58:00.00" description="" event_data="[null]"/>
+  <events id="2" name="Foo" resource_id="1" snapshot_id="1000" category="Other" event_date="2008-11-03 13:58:00.00" created_at="2008-11-03 13:58:00.00" description="" event_data="[null]"/>
+  <events id="3" name="1.1" resource_id="1" snapshot_id="1001" category="Version" event_date="2008-11-04 13:58:00.00" created_at="2008-11-04 13:58:00.00" description="" event_data="[null]"/>
+  <events id="4" name="Bar" resource_id="1" snapshot_id="1001" category="Other" event_date="2008-11-05 13:58:00.00" created_at="2008-11-05 13:58:00.00" description="" event_data="[null]"/>
+  <events id="5" name="Uhh" resource_id="1" snapshot_id="1002" category="Other" event_date="2008-11-07 13:58:00.00" created_at="2008-11-07 13:58:00.00" description="" event_data="[null]"/>
+  <events id="6" name="1.2-SNAPSHOT" resource_id="1" snapshot_id="1003" category="Version" event_date="2008-11-09 13:58:00.00" created_at="2008-11-09 13:58:00.00" description="" event_data="[null]"/>
 
-</dataset>
\ No newline at end of file
+</dataset>
index bfc0a38e0959893038905e41860f9e5ab1dc34fa..c7ff86a5f0c1598bef0b96ef93371676baaebd55 100644 (file)
@@ -33,7 +33,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 554;
+  public static final int LAST_VERSION = 555;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index 0acc327fe71b3de2bc97e436c2c488bd4167d155..e93794de62f46405aab0cf722930c74f07aacfc8 100644 (file)
@@ -247,6 +247,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('551');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('552');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('553');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('554');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('555');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index d9335527a2310933d0a1e8a756f8dc39e7ab4aea..a740173f02bc407c883ac4e11729fee546e7c2df 100644 (file)
@@ -177,7 +177,8 @@ CREATE TABLE "EVENTS" (
   "CATEGORY" VARCHAR(50),
   "EVENT_DATE" TIMESTAMP,
   "CREATED_AT" TIMESTAMP,
-  "DESCRIPTION" VARCHAR(4000)
+  "DESCRIPTION" VARCHAR(4000),
+  "EVENT_DATA"  VARCHAR(4000)
 );
 
 CREATE TABLE "QUALITY_GATES" (
index e7362ab8fcdb65f447db28827b16092d9f467186..01b31759a948160947da8d14b224539fcc5635dd 100644 (file)
@@ -387,7 +387,7 @@ project_links.scm_dev=Developer connection
 
 event.category.Version=Version
 event.category.Alert=Quality Gate
-event.category.Profile=Profile
+event.category.Profile=Quality Profile
 event.category.Other=Other
 
 
index 897c196100f8e90a1e1008be2e03e8782db1aeae..abae88d3a70d710643b70fb812490ff65f202465 100644 (file)
@@ -22,9 +22,9 @@
 
   <project_measures id="1" value="10" metric_id="1" snapshot_id="1000" />
 
-  <events id="1" name="1.0-SNAPSHOT" resource_id="123" />
-  <events id="2" name="2.0-SNAPSHOT" resource_id="123" />
-  <events id="3" name="1.0-SNAPSHOT" resource_id="456" />
+  <events id="1" name="1.0-SNAPSHOT" resource_id="123" event_data="[null]"/>
+  <events id="2" name="2.0-SNAPSHOT" resource_id="123" event_data="[null]" />
+  <events id="3" name="1.0-SNAPSHOT" resource_id="456" event_data="[null]" />
 
   <users id="1" login="julien" name="Julien" crypted_password="foo" active="1" />
   <users id="2" login="simon" name="Simon" active="1" />
index 2827a85e45f19f1a5640129e626771967c39c08f..17cab18f3343dc3e6ceb7f4198469c42ecd7d60a 100644 (file)
@@ -16,7 +16,7 @@
              version="[null]" path="[null]"/>
 
   <events id="1" name="Version 1.0" resource_id="1" snapshot_id="1" category="VERSION" description="[null]"
-          event_date="2008-12-02 13:58:00.00" created_at="[null]"/>
+          event_date="2008-12-02 13:58:00.00" created_at="[null]" event_data="[null]"/>
 
   <issues id="1" kee="ABCDE" component_id="1" status="CLOSED" resolution="[null]" line="200" severity="BLOCKER"
           reporter="perceval" assignee="arthur" rule_id="500"
@@ -33,4 +33,4 @@
 
   <authors id="1" person_id="1" login="tartanpion" created_at="[null]" updated_at="[null]" />
   <authors id="2" person_id="1" login="fanfoue" created_at="[null]" updated_at="[null]" />
-</dataset>
\ No newline at end of file
+</dataset>
index dbbab34b4f9c493602317d30c2760d19a6c8d66b..9987056896c90aaa6a4aea1af408c553f26529b4 100644 (file)
@@ -27,7 +27,7 @@
                 parent_dependency_id="[null]" project_snapshot_id="1"
                 dep_usage="USES" dep_weight="1" from_scope="PRJ" to_scope="LIB"/>
   <events id="1" name="Version 1.0" resource_id="1" snapshot_id="1" category="VERSION" description="[null]"
-          event_date="2008-12-02 13:58:00.00" created_at="[null]"/>
+          event_date="2008-12-02 13:58:00.00" created_at="[null]" event_data="[null]"/>
   <duplications_index id="1" project_snapshot_id="1" snapshot_id="1" hash="bb" index_in_file="0" start_line="0" end_line="0"/>
   <snapshot_data id="1" resource_id="1" snapshot_id="1" snapshot_data="0,10,k" data_type="highlight_syntax" created_at="[null]" updated_at="[null]" />
 
index bfdbc9c5f63664339489597d8ffbdfc0c3730455..501a124192cf21eeaef31b92f6078f85a6b13f10 100644 (file)
@@ -25,7 +25,7 @@
                 parent_dependency_id="[null]" project_snapshot_id="1"
                 dep_usage="USES" dep_weight="1" from_scope="PRJ" to_scope="LIB"/>
   <events id="1" name="Version 1.0" resource_id="1" snapshot_id="1" category="VERSION" description="[null]"
-          event_date="2008-12-02 13:58:00.00" created_at="[null]"/>
+          event_date="2008-12-02 13:58:00.00" created_at="[null]" event_data="[null]"/>
   <duplications_index id="1" project_snapshot_id="1" snapshot_id="1" hash="bb" index_in_file="0" start_line="0" end_line="0"/>
   <snapshot_data id="1" resource_id="1" snapshot_id="1" snapshot_data="0,10,k" data_type="highlight_syntax" created_at="[null]" updated_at="[null]" />
 
@@ -58,7 +58,7 @@
                 parent_dependency_id="[null]" project_snapshot_id="5"
                 dep_usage="USES" dep_weight="1" from_scope="PRJ" to_scope="LIB"/>
   <events id="2" name="Version 1.0" resource_id="5" snapshot_id="5" category="VERSION" description="[null]"
-          event_date="2008-12-02 13:58:00.00" created_at="[null]"/>
+          event_date="2008-12-02 13:58:00.00" created_at="[null]" event_data="[null]"/>
   <duplications_index id="2" project_snapshot_id="5" snapshot_id="5" hash="bb" index_in_file="0" start_line="0" end_line="0"/>
   <snapshot_data id="2" resource_id="5" snapshot_id="5" snapshot_data="0,10,k" data_type="highlight_syntax" created_at="[null]" updated_at="[null]" />
 
index 54257ab7f5df480e1d6505ef260ae66ff80df9bd..f2ab60752db6807df2296e4b1ee7f3d34f5ea736 100644 (file)
@@ -40,7 +40,8 @@ Note that measures, events and reviews are not deleted.
   <!--dep_usage="USES" dep_weight="1" from_scope="LIB" to_scope="PRJ"/>-->
 
   <events id="1" resource_id="1" snapshot_id="1"
-          category="VERSION" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"/>
+          category="VERSION" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"
+          event_data="[null]"/>
 
   <!--<duplications_index id="1" project_snapshot_id="1" snapshot_id="1"-->
   <!--hash="bb" index_in_file="0" start_line="0" end_line="0"/>-->
@@ -74,7 +75,8 @@ Note that measures, events and reviews are not deleted.
                 dep_usage="USES" dep_weight="1" from_scope="LIB" to_scope="PRJ"/>
 
   <events id="2" resource_id="2" snapshot_id="2"
-          category="VERSION" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"/>
+          category="VERSION" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"
+          event_data="[null]"/>
 
   <duplications_index id="2" project_snapshot_id="2" snapshot_id="2"
                       hash="bb" index_in_file="0" start_line="0" end_line="0"/>
index 4a2123e1412baa97ff802697a2b04811dd20b0db..5b651f5ea327cea6b32d724458d114cb17d0bfaf 100644 (file)
@@ -27,7 +27,8 @@
                 dep_usage="USES" dep_weight="1" from_scope="LIB" to_scope="PRJ"/>
 
   <events id="1" resource_id="1" snapshot_id="1"
-          category="VERSION" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"/>
+          category="VERSION" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"
+          event_data="[null]"/>
 
   <duplications_index id="1" project_snapshot_id="1" snapshot_id="1"
                       hash="bb" index_in_file="0" start_line="0" end_line="0"/>
@@ -63,7 +64,8 @@
                   dep_usage="USES" dep_weight="1" from_scope="LIB" to_scope="PRJ"/>
 
     <events id="2" resource_id="2" snapshot_id="2"
-            category="VERSION" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"/>
+            category="VERSION" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"
+            event_data="[null]"/>
 
     <duplications_index id="2" project_snapshot_id="2" snapshot_id="2"
                         hash="bb" index_in_file="0" start_line="0" end_line="0"/>
index 4ea5c8e1726762f996e97bc08c894902efd91406..bd873bcdc5791c5e1139c951a0b1394faa68521d 100644 (file)
@@ -56,6 +56,7 @@
              depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/>
 
   <events id="2" resource_id="1" snapshot_id="5"
-          category="Version" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"/>
+          category="Version" description="[null]" name="Version 1.0" event_date="2008-12-02 13:58:00.00" created_at="[null]"
+          event_data="[null]"/>
 
-</dataset>
\ No newline at end of file
+</dataset>
index 9ca3c52b180a466ebf788897d3609949a9611273..01d17a9fbe804d2e1f1b0b23df3aac686a66480c 100644 (file)
@@ -52,6 +52,9 @@ public class Event extends BaseIdentifiable {
   @Column(name = "created_at", updatable = true, nullable = true)
   private Date createdAt;
 
+  @Column(name = "event_data", updatable = true, nullable = true)
+  private String data;
+
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "snapshot_id", updatable = true, nullable = true)
   private Snapshot snapshot;
@@ -160,6 +163,14 @@ public class Event extends BaseIdentifiable {
     return this;
   }
 
+  public String getData() {
+    return data;
+  }
+
+  public void setData(String data) {
+    this.data = data;
+  }
+
   @Override
   public String toString() {
     return new ToStringBuilder(this)
@@ -170,8 +181,4 @@ public class Event extends BaseIdentifiable {
         .append("resource", resourceId)
         .toString();
   }
-
-  public boolean isLinkedToSnapshot() {
-    return snapshot != null;
-  }
 }
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/555_add_event_data_column.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/555_add_event_data_column.rb
new file mode 100644 (file)
index 0000000..117b1c5
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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 this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# SonarQube 4.4
+#
+class AddEventDataColumn < ActiveRecord::Migration
+
+  def self.up
+    add_column :events, :event_data, :string, :null => true, :limit => 4000
+  end
+
+end