]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5329 -Removed Key and ExecutionTime fields from Activity
authorStephane Gamard <stephane.gamard@searchbox.com>
Mon, 16 Jun 2014 14:42:47 +0000 (16:42 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Mon, 16 Jun 2014 14:42:47 +0000 (16:42 +0200)
15 files changed:
sonar-core/src/main/java/org/sonar/core/activity/Activity.java
sonar-core/src/main/java/org/sonar/core/activity/ActivityLog.java
sonar-core/src/main/java/org/sonar/core/activity/db/ActivityDto.java
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
sonar-core/src/main/resources/org/sonar/core/activity/db/ActivityMapper.xml
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-server/src/main/java/org/sonar/server/activity/index/ActivityDoc.java
sonar-server/src/main/java/org/sonar/server/activity/index/ActivityNormalizer.java
sonar-server/src/main/java/org/sonar/server/activity/ws/ActivityMapping.java
sonar-server/src/main/java/org/sonar/server/qualityprofile/ActiveRuleChange.java
sonar-server/src/main/webapp/WEB-INF/db/migrate/548_rename_activities_table.rb [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/activity/ActivityBackendMediumTest.java
sonar-server/src/test/java/org/sonar/server/activity/db/ActivityDaoTest.java

index b80fdd157229cc35d2dbf11fcdadfd13a0388adb..fac77c44e0d30c0af6ce01746ec0c70e3650cba4 100644 (file)
@@ -35,8 +35,6 @@ public interface Activity {
 
   String author();
 
-  Integer executionTime();
-
   Map<String, String> details();
 
   String message();
index f55aee14f431da0dc528b48b915066f8c354a936..eae04476a959d802a236efd1fc7201b74f51d8e4 100644 (file)
@@ -28,6 +28,4 @@ public interface ActivityLog {
 
   Map<String, String> getDetails();
 
-  int getExecutionTime();
-
 }
index 3d7d1cedaafd3742f96b39d5c841878af4344721..4427c45e8e2dc92197763db86cdda94634569c1f 100644 (file)
@@ -35,8 +35,6 @@ public final class ActivityDto extends Dto<ActivityKey> {
   private Activity.Type type;
   private String author;
 
-  private Integer executionTime;
-
   private String data;
 
   protected ActivityDto() {
@@ -70,12 +68,7 @@ public final class ActivityDto extends Dto<ActivityKey> {
     return this;
   }
 
-  public Integer getExecutionTime() {
-    return executionTime;
-  }
-
   public ActivityDto setExecutionTime(Integer executionTime) {
-    this.executionTime = executionTime;
     return this;
   }
 
@@ -104,7 +97,6 @@ public final class ActivityDto extends Dto<ActivityKey> {
 
   public static ActivityDto createFor(ActivityLog activityLog) {
     return new ActivityDto()
-      .setData(KeyValueFormat.format(activityLog.getDetails()))
-      .setExecutionTime(activityLog.getExecutionTime());
+      .setData(KeyValueFormat.format(activityLog.getDetails()));
   }
 }
index 1b5b35b874910cc4bfc80cc128aef0974287bb22..3fd3a78ab522301dda4b5ebee685c5158915773b 100644 (file)
@@ -33,7 +33,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 547;
+  public static final int LAST_VERSION = 548;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index 154fbac7bd8d96fc28836ccc98b0913e49dd587c..e438cf7ca031b506cbfc8a591f0d93788e9e06e0 100644 (file)
@@ -203,7 +203,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
     loadAlias(conf, "ActiveRule", ActiveRuleDto.class);
     loadAlias(conf, "ActiveRuleParam", ActiveRuleParamDto.class);
     loadAlias(conf, "RequirementMigration", RequirementMigrationDto.class);
-    loadAlias(conf, "Log", ActivityDto.class);
+    loadAlias(conf, "Activity", ActivityDto.class);
 
     // AuthorizationMapper has to be loaded before IssueMapper because this last one used it
     loadMapper(conf, "org.sonar.core.user.AuthorizationMapper");
index 4595d9288c9771ed58389cf3ebed378b9ebb3922..b532f946bce6f2aac6fa9519ffb11666745db748 100644 (file)
@@ -3,35 +3,33 @@
 
 <mapper namespace="org.sonar.core.activity.db.ActivityMapper">
 
-<insert id="insert" parameterType="Log" useGeneratedKeys="false" lang="raw">
-    insert into logs
-    (created_at, log_type,execution_time_field,user_login,data_field, log_message)
-    values (#{createdAt}, #{type}, #{executionTime}, #{author}, #{data}, #{message})
+  <insert id="insert" parameterType="Activity" useGeneratedKeys="false" lang="raw">
+    insert into activities
+    (created_at, log_type,user_login,data_field, log_message)
+    values (#{createdAt}, #{type}, #{author}, #{data}, #{message})
   </insert>
 
-  <select id="selectByKey" parameterType="map" resultType="Log" lang="raw">
+  <select id="selectByKey" parameterType="map" resultType="Activity" lang="raw">
     SELECT
     l.created_at as "createdAt",
     l.log_type as "type",
-    l.execution_time_field as "executionTime",
     l.user_login as "author",
     l.data_field as "data",
     l.log_message as "message"
-    FROM logs l
+    FROM activities l
     WHERE l.created_at=#{key.createdAt}
     AND l.user_login=#{key.author}
     AND l.log_type=#{key.type}
   </select>
 
-  <select id="selectAll" parameterType="map" resultType="Log" lang="raw">
+  <select id="selectAll" parameterType="map" resultType="Activity" lang="raw">
     SELECT
     l.created_at as "createdAt",
     l.log_type as "type",
-    l.execution_time_field as "executionTime",
     l.user_login as "author",
     l.data_field as "data",
     l.log_message as "message"
-    FROM logs l
+    FROM activities l
   </select>
 </mapper>
 
index 994144ca8f10ff628336d6918fbb266d12a1bc4d..dc37a6e684a279eac18563a0d7a8cdf700093689 100644 (file)
@@ -242,6 +242,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('544');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('545');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('546');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('547');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('548');
 
 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 a609cd530b5f5b6fa23fb8c3992a077098830d33..9d2566dfb29d6090e4a945f671218480c9296b34 100644 (file)
@@ -552,9 +552,8 @@ CREATE TABLE "PERM_TEMPLATES_GROUPS" (
 );
 
 
-CREATE TABLE "LOGS" (
+CREATE TABLE "ACTIVITIES" (
   "CREATED_AT" TIMESTAMP,
-  "EXECUTION_TIME_FIELD" LONG,
   "USER_LOGIN" VARCHAR(30),
   "LOG_TYPE" VARCHAR(250),
   "LOG_MESSAGE" VARCHAR(250),
index e224864ce608a20cc63ff66619352ad3c4201bf9..0ba3834b58acd272033ac27e5f68cecb2b9cf81a 100644 (file)
@@ -45,11 +45,6 @@ public class ActivityDoc extends BaseDoc implements Activity {
     return this.getField(ActivityNormalizer.LogFields.AUTHOR.field());
   }
 
-  @Override
-  public Integer executionTime() {
-    return this.getField(ActivityNormalizer.LogFields.EXECUTION.field());
-  }
-
   @Override
   public Map<String, String> details() {
     return this.getField(ActivityNormalizer.LogFields.DETAILS.field());
index ebfb71007f204b4f0759a2d3b3e4008cae9ac819..c750f0c251a702738db55eb83c524100d3a6e7bf 100644 (file)
@@ -49,10 +49,8 @@ public class ActivityNormalizer extends BaseNormalizer<ActivityDto, ActivityKey>
 
   public static final class LogFields extends Indexable {
 
-    public final static IndexField KEY = addSortableAndSearchable(IndexField.Type.STRING, "key");
     public final static IndexField TYPE = addSortable(IndexField.Type.STRING, "type");
     public final static IndexField DATE = addSortable(IndexField.Type.DATE, "date");
-    public final static IndexField EXECUTION = add(IndexField.Type.NUMERIC, "executionTime");
     public final static IndexField AUTHOR = addSearchable(IndexField.Type.STRING, "author");
     public final static IndexField DETAILS = addSearchable(IndexField.Type.OBJECT, "details");
     public final static IndexField MESSAGE = addSearchable(IndexField.Type.STRING, "message");
@@ -94,11 +92,9 @@ public class ActivityNormalizer extends BaseNormalizer<ActivityDto, ActivityKey>
   public List<UpdateRequest> normalize(ActivityDto dto) {
 
     Map<String, Object> logDoc = new HashMap<String, Object>();
-    logDoc.put(LogFields.KEY.field(), dto.getKey());
     logDoc.put(LogFields.TYPE.field(), dto.getType());
     logDoc.put(LogFields.AUTHOR.field(), dto.getAuthor());
     logDoc.put(LogFields.MESSAGE.field(), dto.getMessage());
-    logDoc.put(LogFields.EXECUTION.field(), dto.getExecutionTime());
     logDoc.put(LogFields.DATE.field(), dto.getCreatedAt());
 
     logDoc.put(LogFields.DETAILS.field(), KeyValueFormat.parse(dto.getData()));
index f416028277523a54f2224e88ed0fa89d34f23f88..9e2cb2fd24325b6eff01edd3284b27458a440111 100644 (file)
@@ -36,12 +36,10 @@ public class ActivityMapping extends BaseMapping {
 
   public ActivityMapping(Languages languages, MacroInterpreter macroInterpreter) {
     super();
-    addIndexStringField("key", ActivityNormalizer.LogFields.KEY.field());
     addIndexStringField("type", ActivityNormalizer.LogFields.TYPE.field());
     addIndexDatetimeField("createdAt", ActivityNormalizer.LogFields.DATE.field());
     addIndexStringField("userLogin", ActivityNormalizer.LogFields.AUTHOR.field());
     addIndexStringField("message", ActivityNormalizer.LogFields.MESSAGE.field());
-    addIndexStringField("executionTime", ActivityNormalizer.LogFields.EXECUTION.field());
     addField("details", new DetailField());
   }
 
index 249295c0a012a1b771b6280d3b40191194379f4c..59650b8ecddf58bb42b3985f23c31de04eae5521 100644 (file)
@@ -120,11 +120,6 @@ public class ActiveRuleChange implements ActivityLog {
     return details;
   }
 
-  @Override
-  public int getExecutionTime() {
-    return (int) (System.currentTimeMillis() - start);
-  }
-
   public static ActiveRuleChange createFor(Type type, ActiveRuleKey key) {
     return new ActiveRuleChange(type, key);
   }
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/548_rename_activities_table.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/548_rename_activities_table.rb
new file mode 100644 (file)
index 0000000..0fae77d
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+#
+# Sonar 2.14
+#
+class RenameActivitiesTable < ActiveRecord::Migration
+
+  def self.up
+    remove_column(:logs, 'execution_time_field')
+    rename_table(:logs, 'activities')
+  end
+
+end
index aeb7e9ff1a11b9a93682652e718fb851edeefca9..69c6cd55b0c42a2a0febeab4feaf39e72755d73e 100644 (file)
@@ -87,10 +87,6 @@ public class ActivityBackendMediumTest {
         return ImmutableMap.of(testKey, testValue);
       }
 
-      @Override
-      public int getExecutionTime() {
-        return 12;
-      }
     });
     dbSession.commit();
 
@@ -99,7 +95,6 @@ public class ActivityBackendMediumTest {
     Activity activity = Iterables.getFirst(index.findAll().getHits(), null);
     assertThat(activity).isNotNull();
     assertThat(activity.details().get(testKey)).isEqualTo(testValue);
-    assertThat(activity.executionTime()).isEqualTo(12);
   }
 
   @Test
index 9e4b67f98af1c85f3797bb4b99cc711df9f2a46e..21afaf413a318fa9e7fdf324ecdb2131edc0eeef 100644 (file)
@@ -103,11 +103,6 @@ public class ActivityDaoTest extends AbstractDaoTestCase {
       public Map<String, String> getDetails() {
         return ImmutableMap.of(testKey, testValue);
       }
-
-      @Override
-      public int getExecutionTime() {
-        return 12;
-      }
     })
       .setAuthor("jUnit")
       .setType(Activity.Type.ACTIVE_RULE);
@@ -117,7 +112,6 @@ public class ActivityDaoTest extends AbstractDaoTestCase {
     assertThat(dao.findAll(session)).hasSize(1);
     ActivityDto newDto = dao.getByKey(session, log.getKey());
     assertThat(newDto.getAuthor()).isEqualTo(log.getAuthor());
-    assertThat(newDto.getExecutionTime()).isEqualTo(12);
     assertThat(newDto.getData()).isNotNull();
     Map<String, String> details = KeyValueFormat.parse(newDto.getData());
     assertThat(details.get(testKey)).isEqualTo(testValue);