]> source.dussan.org Git - sonarqube.git/commitdiff
add new column data_type in file_sources table - SONAR-6255
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Mon, 20 Apr 2015 09:16:25 +0000 (11:16 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 28 Apr 2015 10:17:59 +0000 (12:17 +0200)
37 files changed:
server/sonar-server/src/main/java/org/sonar/server/db/migrations/MigrationSteps.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v52/FeedFileSourcesDataType.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/es/EsUtils.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/source/db/FileSourceDaoTest.java
server/sonar-server/src/test/resources/org/sonar/server/component/db/ComponentDaoTest/select_module_files_tree.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/issue/SourceLinesCacheTest/load_data.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/IndexSourceLinesStepTest/index_source.xml
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest/migrate-result.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest/migrate.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest/schema.sql [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/source/db/FileSourceDaoTest/insert-result.xml
server/sonar-server/src/test/resources/org/sonar/server/source/db/FileSourceDaoTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/source/db/FileSourceDaoTest/update-result.xml
server/sonar-server/src/test/resources/org/sonar/server/source/db/FileSourceDaoTest/update_date_when_updated_date_is_zero-result.xml
server/sonar-server/src/test/resources/org/sonar/server/source/db/FileSourceDaoTest/update_date_when_updated_date_is_zero.xml
server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceFileResultSetIteratorTest/filter_by_project.xml
server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceFileResultSetIteratorTest/filter_by_project_and_date.xml
server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceFileResultSetIteratorTest/schema.sql
server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceFileResultSetIteratorTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/source/index/SourceLineIndexerTest/db.xml
server/sonar-server/src/test/resources/org/sonar/server/source/ws/HashActionTest/shared.xml
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/912_add_file_sources_data_type.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/913_feed_file_sources_data_type.rb [new file with mode: 0644]
sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/file_sources_missing_src_hash.xml
sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shared.xml
sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistDontTouchUnchanged-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistEmptyFile-result.xml
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.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/core/source/db/FileSourceMapper.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/select_purgeable_file_uuids.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml

index 2da008de6de2c9d572062a0d9fb15dc64ee1dff0..c333435dbf5efc30b3c4611dca33c6f0691abdb5 100644 (file)
@@ -68,6 +68,7 @@ import org.sonar.server.db.migrations.v52.AddDependenciesComponentUuidColumns;
 import org.sonar.server.db.migrations.v52.DropDependenciesComponentColumns;
 import org.sonar.server.db.migrations.v52.FeedDependenciesComponentUuids;
 import org.sonar.server.db.migrations.v52.FeedEventsComponentUuid;
+import org.sonar.server.db.migrations.v52.FeedFileSourcesDataType;
 import org.sonar.server.db.migrations.v52.FeedProjectLinksComponentUuid;
 import org.sonar.server.db.migrations.v52.MoveProjectProfileAssociation;
 
@@ -141,6 +142,7 @@ public interface MigrationSteps {
     MoveProjectProfileAssociation.class,
     AddDependenciesComponentUuidColumns.class,
     FeedDependenciesComponentUuids.class,
-    DropDependenciesComponentColumns.class
+    DropDependenciesComponentColumns.class,
+    FeedFileSourcesDataType.class
     );
 }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v52/FeedFileSourcesDataType.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v52/FeedFileSourcesDataType.java
new file mode 100644 (file)
index 0000000..44ca514
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v52;
+
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+
+import java.sql.SQLException;
+
+public class FeedFileSourcesDataType extends BaseDataChange {
+
+  public FeedFileSourcesDataType(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.prepareUpsert("update file_sources set data_type = 'SOURCE'").execute().commit();
+  }
+}
index 05b17e4a73e6502f10b6a8d1c9ac3f455c5f7604..ac066ab5f7ba970cb68f67b3a234e0622230a462 100644 (file)
@@ -29,7 +29,12 @@ import org.sonar.server.search.BaseDoc;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-import java.util.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 
 public class EsUtils {
 
diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest.java
new file mode 100644 (file)
index 0000000..f770363
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v52;
+
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonar.core.persistence.DbTester;
+import org.sonar.server.db.migrations.MigrationStep;
+
+public class FeedFileSourcesDataTypeTest {
+
+  @ClassRule
+  public static DbTester db = new DbTester().schema(FeedFileSourcesDataTypeTest.class, "schema.sql");
+
+  MigrationStep migration;
+
+  @Before
+  public void setUp() throws Exception {
+    db.executeUpdateSql("truncate table file_sources");
+
+    migration = new FeedFileSourcesDataType(db.database());
+  }
+
+  @Test
+  public void migrate_empty_db() throws Exception {
+    migration.execute();
+  }
+
+  @Test
+  public void migrate() throws Exception {
+    db.prepareDbUnit(this.getClass(), "migrate.xml");
+    migration.execute();
+    db.assertDbUnit(this.getClass(), "migrate-result.xml", "file_sources");
+  }
+}
index 56fbcaa91b5521b1df77fd59acf3eb83c38a9320..dbf2968ebddb96ab5908d42e12690384f386e3ed 100644 (file)
@@ -64,6 +64,7 @@ public class FileSourceDaoTest extends AbstractDaoTestCase {
     assertThat(fileSourceDto.getFileUuid()).isEqualTo("FILE1_UUID");
     assertThat(fileSourceDto.getCreatedAt()).isEqualTo(1500000000000L);
     assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(1500000000000L);
+    assertThat(fileSourceDto.getDataType()).isEqualTo(FileSourceDto.Type.SOURCE);
   }
 
   @Test
@@ -107,26 +108,29 @@ public class FileSourceDaoTest extends AbstractDaoTestCase {
       .setDataHash("FILE2_DATA_HASH")
       .setLineHashes("LINE1_HASH\\nLINE2_HASH")
       .setSrcHash("FILE2_HASH")
+      .setDataType(FileSourceDto.Type.SOURCE)
       .setCreatedAt(1500000000000L)
       .setUpdatedAt(1500000000001L));
 
-    checkTable("insert", "file_sources", "project_uuid", "file_uuid", "data_hash", "line_hashes", "src_hash", "created_at", "updated_at");
+    checkTable("insert", "file_sources", "project_uuid", "file_uuid", "data_hash", "line_hashes", "src_hash", "created_at", "updated_at", "data_type");
   }
 
   @Test
   public void update() throws Exception {
     setupData("shared");
 
-    dao.update(new FileSourceDto().setId(101L)
+    dao.update(new FileSourceDto()
+      .setId(101L)
       .setProjectUuid("PRJ_UUID")
       .setFileUuid("FILE1_UUID")
       .setBinaryData("updated data".getBytes())
       .setDataHash("NEW_DATA_HASH")
       .setSrcHash("NEW_FILE_HASH")
       .setLineHashes("NEW_LINE_HASHES")
+      .setDataType(FileSourceDto.Type.SOURCE)
       .setUpdatedAt(1500000000002L));
 
-    checkTable("update", "file_sources", "project_uuid", "file_uuid", "data_hash", "line_hashes", "src_hash", "created_at", "updated_at");
+    checkTable("update", "file_sources", "project_uuid", "file_uuid", "data_hash", "line_hashes", "src_hash", "created_at", "updated_at", "data_type");
   }
 
   @Test
index 20e8797e9d443f171217bba0946f2acf1876d6eb..1370ae1ee614dab2a378f2f6072108ed3ad9ead8 100644 (file)
@@ -24,7 +24,7 @@
                 line_hashes="lineEFGHI"
                 data_hash="dataEFGHI"
                 src_hash="srcEFGHI"
-                created_at="1412952242000" updated_at="1412952242000"/>
+                created_at="1412952242000" updated_at="1412952242000" data_type="SOURCE" />
 
   <!-- sub module -->
   <projects id="4" root_id="1" kee="org.struts:struts-data" name="Struts Data"
@@ -51,6 +51,6 @@
                 line_hashes="lineHIJK"
                 data_hash="dataHIJK"
                 src_hash="srcHIJK"
-                created_at="1412952242000" updated_at="1412952242000"/>
+                created_at="1412952242000" updated_at="1412952242000" data_type="SOURCE" />
 
 </dataset>
index 24e4d0c14d030fc488692315554e9952aa860128..25d680c3e460b164f416743d74f2becc86f0e062 100644 (file)
@@ -9,5 +9,5 @@
                 line_hashes="8d7b3d6b83c0a517eac07e1aac94b773&#10;9a0364b9e99bb480dd25e1f0284c8555"
                 data_hash="0263047cd758c68c27683625f072f010"
                 src_hash="123456"
-                created_at="1412952242000" updated_at="1412952242000"/>
+                created_at="1412952242000" updated_at="1412952242000" data_type="SOURCE" />
 </dataset>
index 62401136eb3ec2e8ed557900a00718be6c3207d1..c1785bed889d51cda8a5550ec322d611ff7a4436 100644 (file)
@@ -2,10 +2,10 @@
 
   <file_sources id="101" project_uuid="ABCD" file_uuid="FILE1_UUID"
                 binary_data="abcde" data_hash="hash" line_hashes="ABC\nDEF\nGHI" src_hash="FILE_HASH"
-                created_at="1500000000000" updated_at="0"/>
+                created_at="1500000000000" updated_at="0" data_type="SOURCE" />
 
   <file_sources id="102" project_uuid="DCBA" file_uuid="FILE2_UUID"
                 binary_data="edcba" data_hash="hash2" line_hashes="CBA\nFDE\nIHG" src_hash="FILE2_HASH"
-                created_at="1500000000000" updated_at="0"/>
+                created_at="1500000000000" updated_at="0" data_type="SOURCE" />
 
 </dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest/migrate-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest/migrate-result.xml
new file mode 100644 (file)
index 0000000..3788fbf
--- /dev/null
@@ -0,0 +1,10 @@
+<dataset>
+
+  <file_sources id="1" project_uuid="project-1" file_uuid="file-1" data_type="SOURCE" created_at="123456789"
+                updated_at="456456456"/>
+  <file_sources id="2" project_uuid="project-2" file_uuid="file-2" data_type="SOURCE" created_at="123456789"
+                updated_at="456456456"/>
+  <file_sources id="3" project_uuid="project-3" file_uuid="file-3" data_type="SOURCE" created_at="123456789"
+                updated_at="456456456"/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest/migrate.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest/migrate.xml
new file mode 100644 (file)
index 0000000..402bb36
--- /dev/null
@@ -0,0 +1,7 @@
+<dataset>
+
+  <file_sources id="1" project_uuid="project-1" file_uuid="file-1" data_type="[null]" created_at="123456789" updated_at="456456456" />
+  <file_sources id="2" project_uuid="project-2" file_uuid="file-2" data_type="SOURCE" created_at="123456789" updated_at="456456456" />
+  <file_sources id="3" project_uuid="project-3" file_uuid="file-3" data_type="[null]" created_at="123456789" updated_at="456456456" />
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest/schema.sql b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v52/FeedFileSourcesDataTypeTest/schema.sql
new file mode 100644 (file)
index 0000000..84eb774
--- /dev/null
@@ -0,0 +1,8 @@
+CREATE TABLE "FILE_SOURCES" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "PROJECT_UUID" VARCHAR(50) NOT NULL,
+  "FILE_UUID" VARCHAR(50) NOT NULL,
+  "DATA_TYPE" VARCHAR(20),
+  "CREATED_AT" BIGINT NOT NULL,
+  "UPDATED_AT" BIGINT NOT NULL
+);
index 74bca5ec788c7024e24fefbb0636bb1039243c78..4f347782dcadc5abb5fbd3936b3a73923faf5b8c 100644 (file)
@@ -4,7 +4,7 @@
                 binary_data="abcde" data_hash="hash"
                 line_hashes="ABC\nDEF\nGHI"
                 src_hash="FILE_HASH"
-                created_at="1500000000000" updated_at="1500000000000" />
+                created_at="1500000000000" updated_at="1500000000000"  data_type="SOURCE" />
 
 
   <file_sources id="102" project_uuid="PRJ_UUID" file_uuid="FILE2_UUID"
@@ -12,6 +12,6 @@
                 data_hash="FILE2_DATA_HASH"
                 line_hashes="LINE1_HASH\nLINE2_HASH"
                 src_hash="FILE2_HASH"
-                created_at="1500000000000" updated_at="1500000000001" />
+                created_at="1500000000000" updated_at="1500000000001"  data_type="SOURCE" />
 
 </dataset>
index 79a340f841d4f0034a8fdceb1a3834c925930cf8..5187ca217af840746cb5e05f9f1b3846a6a98924 100644 (file)
@@ -4,6 +4,6 @@
                   binary_data="abcde" data_hash="hash"
                   line_hashes="ABC\nDEF\nGHI"
                   src_hash="FILE_HASH"
-                  created_at="1500000000000" updated_at="1500000000000" />
+                  created_at="1500000000000" updated_at="1500000000000"  data_type="SOURCE" />
 
 </dataset>
index 40cbfa91a43b6f6db4fd62e1932f6e7360af152d..8dbe32d946d8735a148dedf63c5231fc16d360f2 100644 (file)
@@ -5,7 +5,7 @@
                 data_hash="NEW_DATA_HASH"
                 line_hashes="NEW_LINE_HASHES"
                 src_hash="NEW_FILE_HASH"
-                created_at="1500000000000" updated_at="1500000000002" />
+                created_at="1500000000000" updated_at="1500000000002"  data_type="SOURCE" />
 
 
 </dataset>
index 931bab04e180f9d1700afb59739448577402aca5..1ba1fe63a55b2132e76b201095bc3c7917d6e4bd 100644 (file)
@@ -3,16 +3,16 @@
   <!-- Updated -->
   <file_sources id="101" project_uuid="ABCD" file_uuid="FILE1_UUID"
                 binary_data="abcde" data_hash="hash" line_hashes="ABC\nDEF\nGHI" src_hash="FILE_HASH"
-                created_at="1500000000000" updated_at="1500000000002"/>
+                created_at="1500000000000" updated_at="1500000000002" data_type="SOURCE" />
 
   <!-- Not updated because updated_at is not null -->
   <file_sources id="102" project_uuid="ABCD" file_uuid="FILE2_UUID"
                 binary_data="abcde" data_hash="hash" line_hashes="ABC\nDEF\nGHI" src_hash="FILE_HASH"
-                created_at="1500000000000" updated_at="1500000000000"/>
+                created_at="1500000000000" updated_at="1500000000000" data_type="SOURCE" />
 
   <!-- Not updated because on another project -->
   <file_sources id="103" project_uuid="BCDE" file_uuid="FILE3_UUID"
                 binary_data="abcde" data_hash="hash" line_hashes="ABC\nDEF\nGHI" src_hash="FILE_HASH"
-                created_at="1500000000000" updated_at="0"/>
+                created_at="1500000000000" updated_at="0" data_type="SOURCE" />
 
 </dataset>
index 9782d5c383783b89233da53b9fcacddced28aebe..77a1f85b06ae16c43c24612608a418e5f593d980 100644 (file)
@@ -3,14 +3,14 @@
   <!-- Only this source should be updated -->
   <file_sources id="101" project_uuid="ABCD" file_uuid="FILE1_UUID"
                 binary_data="abcde" data_hash="hash" line_hashes="ABC\nDEF\nGHI" src_hash="FILE_HASH"
-                created_at="1500000000000" updated_at="0"/>
+                created_at="1500000000000" updated_at="0" data_type="SOURCE" />
 
   <file_sources id="102" project_uuid="ABCD" file_uuid="FILE2_UUID"
                 binary_data="abcde" data_hash="hash" line_hashes="ABC\nDEF\nGHI" src_hash="FILE_HASH"
-                created_at="1500000000000" updated_at="1500000000000"/>
+                created_at="1500000000000" updated_at="1500000000000" data_type="SOURCE" />
 
   <file_sources id="103" project_uuid="BCDE" file_uuid="FILE3_UUID"
                 binary_data="abcde" data_hash="hash" line_hashes="ABC\nDEF\nGHI" src_hash="FILE_HASH"
-                created_at="1500000000000" updated_at="0"/>
+                created_at="1500000000000" updated_at="0" data_type="SOURCE" />
 
 </dataset>
index aeeffbdc05a8f1c659861710ba52e4231a3e16c8..1f0032170a04d71493312ce46d4aafe2c3b2409c 100644 (file)
@@ -1,9 +1,9 @@
 <dataset>
 
   <file_sources id="1" project_uuid="P1" file_uuid="F1" created_at="1416238020000" updated_at="1416239042000"
-                binary_data="" data_hash="" />
+                binary_data="" data_hash=""  data_type="SOURCE" />
 
   <file_sources id="2" project_uuid="P2" file_uuid="F2" created_at="1416238020000" updated_at="1416239042000"
-                binary_data="" data_hash="" />
+                binary_data="" data_hash=""  data_type="SOURCE" />
 
 </dataset>
index db7a9977db39307ae9f562879e1ead92f0aa1792..e6289cd994c044deb86bd7cc3d74739e5d673b55 100644 (file)
@@ -1,9 +1,9 @@
 <dataset>
 
   <file_sources id="1" project_uuid="P1" file_uuid="F1" created_at="1416238020000" updated_at="1416239042000"
-                binary_data="" data_hash="" />
+                binary_data="" data_hash=""  data_type="SOURCE" />
 
   <file_sources id="2" project_uuid="P1" file_uuid="F2" created_at="1416238020000" updated_at="1300000000000"
-                binary_data="" data_hash="" />
+                binary_data="" data_hash=""  data_type="SOURCE" />
 
 </dataset>
index 859eefe362544adce633ef7e82cd207a7863944c..99f823ff74d2cd4d35bd6e9e4e53ac05215410a3 100644 (file)
@@ -5,6 +5,7 @@ CREATE TABLE "FILE_SOURCES" (
   "FILE_UUID" VARCHAR(50) NOT NULL,
   "BINARY_DATA" BINARY(167772150),
   "DATA_HASH" VARCHAR(50) NOT NULL,
+  "DATA_TYPE" VARCHAR(50),
   "CREATED_AT" BIGINT NOT NULL,
   "UPDATED_AT" BIGINT NOT NULL
 );
index f56c7f5a796068ba550b3a1892a3b5bab6f01a84..053270327d685af46d37c34ded103560397e5c99 100644 (file)
@@ -1,6 +1,6 @@
 <dataset>
 
   <file_sources id="1" project_uuid="P1" file_uuid="F1" created_at="1416238020000" updated_at="1416239042000"
-    binary_data="" data_hash="" />
+    binary_data="" data_hash=""  data_type="SOURCE" />
 
 </dataset>
index 48e58478ab6ccdf2f251783200bb7f100964c2a1..bea210dc670576cb7e637ee96af06f81c2836dd6 100644 (file)
@@ -1,6 +1,6 @@
 <dataset>
 
   <file_sources id="1" project_uuid="PROJECT_UUID" file_uuid="FILE_UUID" created_at="1416238020000" updated_at="1416239042000"
-                binary_data="" data_hash="DATA_HASH" />
+                binary_data="" data_hash="DATA_HASH"  data_type="SOURCE" />
 
 </dataset>
index 4dcc5c21ee0bf1a75248b98a11d4f9a3dc8080a7..2c1b4111c26e45a9ed9e7cfd0f190975fded558d 100644 (file)
@@ -8,6 +8,6 @@
                 binary_data="" data_hash="hash"
                 line_hashes="987654"
                 src_hash="12345"
-                created_at="1414597442000" updated_at="1414683842000"/>
+                created_at="1414597442000" updated_at="1414683842000" data_type="SOURCE" />
 
 </dataset>
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/912_add_file_sources_data_type.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/912_add_file_sources_data_type.rb
new file mode 100644 (file)
index 0000000..21da15f
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# 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 5.2
+# SONAR-6255
+#
+class AddFileSourcesDataType < ActiveRecord::Migration
+
+  def self.up
+    add_column 'file_sources', 'data_type', :string, :limit => 20
+    remove_index_quietly('file_sources_file_uuid_uniq')
+    add_index 'file_sources', ['file_uuid', 'data_type'], :name => 'file_sources_uuid_type', :unique => true
+  end
+
+  def self.remove_index_quietly(name)
+    begin
+      remove_index('file_sources', :name => name)
+    rescue
+      # probably already removed
+    end
+  end
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/913_feed_file_sources_data_type.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/913_feed_file_sources_data_type.rb
new file mode 100644 (file)
index 0000000..08a4e97
--- /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.
+#
+
+#
+# SonarQube 5.2
+# SONAR-6255
+#
+class FeedFileSourcesDataType < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.server.db.migrations.v52.FeedFileSourcesDataType')
+  end
+
+end
index 4879192217c9f870eb8f9a993874bf8cf61a8f50..9fac445981be45378ce15e7eaebf820a15ba36f1 100644 (file)
@@ -4,6 +4,6 @@
                 line_hashes="8d7b3d6b83c0a517eac07e1aac94b773&#10;9a0364b9e99bb480dd25e1f0284c8555"
                 data_hash="0263047cd758c68c27683625f072f010"
                 src_hash="[null]"
-                created_at="1412952242000" updated_at="1412952242000"/>
+                created_at="1412952242000" updated_at="1412952242000" data_type="SOURCE" />
 
 </dataset>
index 1223c1869cd71597f2b7ed2df51acb5e09acac2d..dd27702d8b171a12f5567eda02c9fc90dff296f0 100644 (file)
@@ -4,6 +4,6 @@
                 line_hashes="8d7b3d6b83c0a517eac07e1aac94b773&#10;9a0364b9e99bb480dd25e1f0284c8555"
                 data_hash="0263047cd758c68c27683625f072f010"
                 src_hash="123456"
-                created_at="1412952242000" updated_at="1412952242000"/>
+                created_at="1412952242000" updated_at="1412952242000" data_type="SOURCE" />
 
 </dataset>
index b70d53511d00bba748b144093141b8be94574e00..b5e2373c6829efbdf45b3b8d32493bb4b47ef985 100644 (file)
@@ -5,6 +5,6 @@
                 line_hashes="8d7b3d6b83c0a517eac07e1aac94b773&#10;9a0364b9e99bb480dd25e1f0284c8555"
                 data_hash="0263047cd758c68c27683625f072f010"
                 src_hash="123456"
-                created_at="1412952242000" updated_at="1412952242000"/>
+                created_at="1412952242000" updated_at="1412952242000" data_type="SOURCE" />
 
 </dataset>
index 9b3a8b549a89a99ab9a3f6442b1ea21dc4a5666b..6516bd139ca480b689a4a6a01cc07c9b3e1c9230 100644 (file)
@@ -4,12 +4,12 @@
                 line_hashes="8d7b3d6b83c0a517eac07e1aac94b773&#10;9a0364b9e99bb480dd25e1f0284c8555"
                 data_hash="0263047cd758c68c27683625f072f010"
                 src_hash="123456"
-                created_at="1412952242000" updated_at="1412952242000"/>
+                created_at="1412952242000" updated_at="1412952242000" data_type="SOURCE" />
 
   <file_sources id="102" project_uuid="projectUuid" file_uuid="uuidempty" binary_data="[null]"
                 line_hashes="[null]"
                 src_hash="abcd"
-                data_hash="0" created_at="1414597442000" updated_at="1414597442000"/>
+                data_hash="0" created_at="1414597442000" updated_at="1414597442000" data_type="SOURCE" />
 </dataset>
 
 
index 531a662b6bffdc4a9bb89e3afc9963b970b02378..2ba0d7afbba02fd57ebc948601d88b943572eb69 100644 (file)
@@ -33,7 +33,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 911;
+  public static final int LAST_VERSION = 913;
 
   /**
    * List of all the tables.n
index 7840d213df61757d61a4723766bb511b0bd1be79..3efeb1e1db6c0e7b9b9285deee6e0c097c2ac5e8 100644 (file)
@@ -42,6 +42,7 @@ public class FileSourceDto {
   private String lineHashes;
   private String srcHash;
   private byte[] binaryData;
+  private String dataType;
   private String dataHash;
 
   public Long getId() {
@@ -188,4 +189,18 @@ public class FileSourceDto {
     this.updatedAt = updatedAt;
     return this;
   }
+
+  public String getDataType() {
+    return dataType;
+  }
+
+  public FileSourceDto setDataType(String dataType) {
+    this.dataType = dataType;
+    return this;
+  }
+
+  public static class Type {
+    public final static String SOURCE = "SOURCE";
+    public final static String TEST = "TEST";
+  }
 }
index 97fa66aea45b7735bba9fad5d6610a51f98979e1..8c2c12a0befa23e85910b58c4640364c451b03dc 100644 (file)
@@ -335,6 +335,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('908');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('909');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('910');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('911');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('912');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('913');
 
 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', '1418215735482', '1418215735482', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index 77e26efde37177917e03afe2bbfc84193acc3149..5636c21f8895c48e091631078a23b65398849059 100644 (file)
@@ -562,6 +562,7 @@ CREATE TABLE "FILE_SOURCES" (
   "FILE_UUID" VARCHAR(50) NOT NULL,
   "LINE_HASHES" CLOB(2147483647),
   "BINARY_DATA" BLOB(167772150),
+  "DATA_TYPE" VARCHAR(20),
   "DATA_HASH" VARCHAR(50) NOT NULL,
   "SRC_HASH" VARCHAR(50) NULL,
   "CREATED_AT" BIGINT NOT NULL,
@@ -714,7 +715,7 @@ CREATE UNIQUE INDEX "PROFILE_UNIQUE_KEY" ON "RULES_PROFILES" ("KEE");
 
 CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID");
 
-CREATE UNIQUE INDEX "FILE_SOURCES_FILE_UUID_UNIQ" ON "FILE_SOURCES" ("FILE_UUID");
+CREATE UNIQUE INDEX "FILE_SOURCES_UUID_TYPE_UNIQUE" ON "FILE_SOURCES" ("FILE_UUID", "DATA_TYPE");
 
 CREATE INDEX "FILE_SOURCES_UPDATED_AT" ON "FILE_SOURCES" ("UPDATED_AT");
 
index 061c84eb19de5e7a55cad8b9ef32fa5235d21113..383fe29178adc7a60896079a840edd3699f20933 100644 (file)
@@ -6,22 +6,22 @@
 
   <select id="select" parameterType="string" resultType="org.sonar.core.source.db.FileSourceDto">
     SELECT id, project_uuid as projectUuid, file_uuid as fileUuid, created_at as createdAt, updated_at as updatedAt,
-    binary_data as binaryData, line_hashes as lineHashes, data_hash as dataHash, src_hash as srcHash
+    binary_data as binaryData, line_hashes as lineHashes, data_hash as dataHash, src_hash as srcHash, data_type as dataType
     FROM file_sources
     WHERE file_uuid = #{fileUuid}
   </select>
   
   <select id="selectHashesForProject" parameterType="string" resultType="org.sonar.core.source.db.FileSourceDto">
-    SELECT id, file_uuid as fileUuid, data_hash as dataHash, src_hash as srcHash, updated_at as updatedAt
+    SELECT id, file_uuid as fileUuid, data_type as dataType, data_hash as dataHash, src_hash as srcHash, updated_at as updatedAt
     FROM file_sources
     WHERE project_uuid = #{projectUuid}
   </select>
   
   <insert id="insert" parameterType="org.sonar.core.source.db.FileSourceDto" useGeneratedKeys="false">
-    INSERT INTO file_sources (project_uuid, file_uuid, created_at, updated_at, binary_data, line_hashes, data_hash, src_hash)
+    INSERT INTO file_sources (project_uuid, file_uuid, created_at, updated_at, binary_data, line_hashes, data_hash, src_hash, data_type)
     VALUES (#{projectUuid,jdbcType=VARCHAR}, #{fileUuid,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT},
     #{updatedAt,jdbcType=BIGINT}, #{binaryData,jdbcType=BLOB}, #{lineHashes,jdbcType=CLOB},
-    #{dataHash,jdbcType=VARCHAR}, #{srcHash,jdbcType=VARCHAR})
+    #{dataHash,jdbcType=VARCHAR}, #{srcHash,jdbcType=VARCHAR},#{dataType,jdbcType=VARCHAR})
   </insert>
   
   <update id="update" parameterType="org.sonar.core.source.db.FileSourceDto" useGeneratedKeys="false">
@@ -30,7 +30,8 @@
       binary_data = #{binaryData,jdbcType=BLOB},
       line_hashes = #{lineHashes,jdbcType=CLOB},
       data_hash = #{dataHash,jdbcType=VARCHAR},
-      src_hash = #{srcHash,jdbcType=VARCHAR}
+      src_hash = #{srcHash,jdbcType=VARCHAR},
+      data_type = #{dataType,jdbcType=VARCHAR}
     WHERE id = #{id}
   </update>
 
index 7caaa52651310aee0fe28d2ef680d24ce1d3b0b8..584b01091971aeab16550425e6f9e8111e196b07 100644 (file)
@@ -1,5 +1,5 @@
 <dataset>
 
   <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" binary_data="[null]" line_hashes="[null]" data_hash="321654988"
-                created_at="123456789" updated_at="123456789" src_hash="123456"/>
+                created_at="123456789" updated_at="123456789" src_hash="123456" data_type="SOURCE" />
 </dataset>
index aaae9915d98ca140221fbcb3450c2268a910c5ed..f9a5fcbb2aee7256e5eec85e33546ab58b0f929c 100644 (file)
@@ -73,7 +73,7 @@
              build_date="1228222680000" version="[null]" path="[null]"/>
 
   <file_sources id="1" project_uuid="ABCD" file_uuid="GHIJ" binary_data="[null]" line_hashes="[null]" data_hash="321654987"
-                created_at="123456789" updated_at="123456789" src_hash="12345"/>
+                created_at="123456789" updated_at="123456789" src_hash="12345" data_type="SOURCE" />
   <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" binary_data="[null]" line_hashes="[null]" data_hash="321654988"
-                created_at="123456789" updated_at="123456789" src_hash="123456"/>
+                created_at="123456789" updated_at="123456789" src_hash="123456" data_type="SOURCE" />
 </dataset>
index 5bbb5aa58913b23ab27a03f09f5c9a324baa185f..f6573e509dd3c35d6570b3ffb3631a1b4a48b9e5 100644 (file)
@@ -80,7 +80,7 @@
              build_date="1228222680000" version="[null]" path="[null]"/>
 
   <file_sources id="1" project_uuid="ABCD" file_uuid="GHIJ" binary_data="[null]" line_hashes="[null]" data_hash="321654987"
-                created_at="123456789" updated_at="123456789"/>
+                created_at="123456789" updated_at="123456789" data_type="SOURCE" />
   <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" binary_data="[null]" line_hashes="[null]" data_hash="321654988"
-                created_at="123456789" updated_at="123456789"/>
+                created_at="123456789" updated_at="123456789" data_type="SOURCE" />
 </dataset>
index d50cc3926f5b062ec00f0accf80c5fbdf7b36a21..26abe5662f0b10f80e1ad7b46c18f0f73eb20fd0 100644 (file)
              build_date="1228222680000"
              version="[null]" path="[null]"/>
   <file_sources id="1" project_uuid="A" file_uuid="D" binary_data="[null]" line_hashes="[null]" data_hash="321654987"
-                created_at="123456789" updated_at="123456789"/>
+                created_at="123456789" updated_at="123456789" data_type="SOURCE" />
 </dataset>