]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5883 Drop snapshot data
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 15 Jan 2015 11:12:53 +0000 (12:12 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 15 Jan 2015 14:12:15 +0000 (15:12 +0100)
34 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java [deleted file]
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/768_drop_snapshot_data.rb [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/index/FileHashesPersister.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoader.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/index/FileHashesPersisterTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/referential/DefaultProjectReferentialsLoaderTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoaderTest.java [deleted file]
sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.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/java/org/sonar/core/persistence/PreviewDatabaseFactory.java
sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java
sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
sonar-core/src/main/java/org/sonar/core/source/SnapshotDataTypes.java
sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDao.java [deleted file]
sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDto.java [deleted file]
sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataMapper.java [deleted file]
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/purge/PurgeMapper.xml
sonar-core/src/test/java/org/sonar/core/persistence/PreviewDatabaseFactoryTest.java
sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java
sonar-core/src/test/java/org/sonar/core/source/db/SnapshotDataDaoTest.java [deleted file]
sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.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

index fb1eb26c69d59a3de4937aa882d7ecfff4a1bae0..cd9f54ee85734b70e2e5f213c58e7cc2d1436d65 100644 (file)
@@ -53,7 +53,6 @@ import org.sonar.plugins.core.sensors.BranchCoverageDecorator;
 import org.sonar.plugins.core.sensors.CommentDensityDecorator;
 import org.sonar.plugins.core.sensors.CoverageDecorator;
 import org.sonar.plugins.core.sensors.DirectoriesDecorator;
-import org.sonar.plugins.core.sensors.FileHashSensor;
 import org.sonar.plugins.core.sensors.FilesDecorator;
 import org.sonar.plugins.core.sensors.ItBranchCoverageDecorator;
 import org.sonar.plugins.core.sensors.ItCoverageDecorator;
@@ -373,7 +372,6 @@ public final class CorePlugin extends SonarPlugin {
       DirectoriesDecorator.class,
       FilesDecorator.class,
       ManualMeasureDecorator.class,
-      FileHashSensor.class,
 
       // time machine
       TendencyDecorator.class,
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/FileHashSensor.java
deleted file mode 100644 (file)
index 5f0bfb3..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.plugins.core.sensors;
-
-import com.google.common.collect.Maps;
-import org.sonar.api.batch.Sensor;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
-import org.sonar.api.resources.Project;
-import org.sonar.api.utils.KeyValueFormat;
-import org.sonar.batch.index.ComponentDataCache;
-import org.sonar.batch.scan.filesystem.InputPathCache;
-import org.sonar.core.DryRunIncompatible;
-import org.sonar.core.source.SnapshotDataTypes;
-
-import java.util.Map;
-
-/**
- * This sensor will retrieve hash of each file of the current module and store it in DB
- * in order to compare it during next analysis and see if the file was modified.
- * This is used by the incremental preview mode.
- *
- * @since 4.0
- */
-@DryRunIncompatible
-public final class FileHashSensor implements Sensor {
-
-  private final InputPathCache fileCache;
-  private final ComponentDataCache componentDataCache;
-
-  public FileHashSensor(InputPathCache fileCache, ComponentDataCache componentDataCache) {
-    this.fileCache = fileCache;
-    this.componentDataCache = componentDataCache;
-  }
-
-  @Override
-  public boolean shouldExecuteOnProject(Project project) {
-    return true;
-  }
-
-  @Override
-  public void analyse(Project project, SensorContext context) {
-    Map<String, String> map = Maps.newHashMap();
-    for (InputFile inputFile : fileCache.filesByModule(project.key())) {
-      String hash = ((DeprecatedDefaultInputFile) inputFile).hash();
-      if (hash != null) {
-        map.put(inputFile.relativePath(), hash);
-      }
-    }
-    if (!map.isEmpty()) {
-      String data = KeyValueFormat.format(map);
-      componentDataCache.setStringData(project.key(), SnapshotDataTypes.FILE_HASHES, data);
-    }
-  }
-
-  @Override
-  public String toString() {
-    return getClass().getSimpleName();
-  }
-}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/FileHashSensorTest.java
deleted file mode 100644 (file)
index f0c32fa..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.plugins.core.sensors;
-
-import com.google.common.collect.Lists;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
-import org.sonar.api.resources.Project;
-import org.sonar.batch.index.ComponentDataCache;
-import org.sonar.batch.scan.filesystem.InputPathCache;
-import org.sonar.core.source.SnapshotDataTypes;
-
-import java.util.Collections;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
-public class FileHashSensorTest {
-
-  @Rule
-  public TemporaryFolder temp = new TemporaryFolder();
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  Project project = new Project("struts");
-  InputPathCache fileCache = mock(InputPathCache.class);
-  ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
-  FileHashSensor sensor = new FileHashSensor(fileCache, componentDataCache);
-
-  @Test
-  public void store_file_hashes() throws Exception {
-    when(fileCache.filesByModule("struts")).thenReturn(Lists.<InputFile>newArrayList(
-      new DeprecatedDefaultInputFile("foo", "src/Foo.java").setFile(temp.newFile()).setHash("ABC"),
-      new DeprecatedDefaultInputFile("foo", "src/Bar.java").setFile(temp.newFile()).setHash("DEF")));
-
-    SensorContext sensorContext = mock(SensorContext.class);
-    sensor.analyse(project, sensorContext);
-
-    verify(componentDataCache).setStringData("struts", SnapshotDataTypes.FILE_HASHES, "src/Foo.java=ABC;src/Bar.java=DEF");
-    verifyZeroInteractions(sensorContext);
-  }
-
-  @Test
-  public void store_file_hashes_for_branches() throws Exception {
-    project = new Project("struts", "branch-2.x", "Struts 2.x");
-    when(fileCache.filesByModule("struts:branch-2.x")).thenReturn(Lists.<InputFile>newArrayList(
-      new DeprecatedDefaultInputFile("foo", "src/Foo.java").setFile(temp.newFile()).setHash("ABC"),
-      new DeprecatedDefaultInputFile("foo", "src/Bar.java").setFile(temp.newFile()).setHash("DEF")));
-
-    SensorContext sensorContext = mock(SensorContext.class);
-    sensor.analyse(project, sensorContext);
-
-    verify(componentDataCache).setStringData("struts:branch-2.x", SnapshotDataTypes.FILE_HASHES, "src/Foo.java=ABC;src/Bar.java=DEF");
-    verifyZeroInteractions(sensorContext);
-  }
-
-  @Test
-  public void various_tests() throws Exception {
-    assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
-    assertThat(sensor.toString()).isEqualTo("FileHashSensor");
-  }
-
-  @Test
-  public void dont_save_hashes_if_no_files() throws Exception {
-    when(fileCache.filesByModule("struts")).thenReturn(Collections.<InputFile>emptyList());
-
-    SensorContext sensorContext = mock(SensorContext.class);
-    sensor.analyse(project, sensorContext);
-
-    verifyZeroInteractions(componentDataCache);
-    verifyZeroInteractions(sensorContext);
-  }
-}
index 78a1b297eb10295e47341c0976dac627842d3335..2335fbc5e60335ed20949fcc93d4f12573e07765 100644 (file)
@@ -37,7 +37,7 @@ public class BackendCleanup implements ServerComponent {
   private static final String[] INSPECTION_TABLES = {
     "action_plans", "authors", "dependencies", "duplications_index", "events", "graphs", "issues", "issue_changes", "manual_measures",
     "notifications", "project_links", "project_measures", "projects", "resource_index",
-    "semaphores", "snapshots", "snapshot_data", "file_sources"
+    "semaphores", "snapshots", "file_sources"
   };
   private static final String[] RESOURCE_RELATED_TABLES = {
     "group_roles", "user_roles", "properties"
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/768_drop_snapshot_data.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/768_drop_snapshot_data.rb
new file mode 100644 (file)
index 0000000..23f3e33
--- /dev/null
@@ -0,0 +1,32 @@
+#
+# 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.1
+# SONAR-5883
+#
+class DropSnapshotData < ActiveRecord::Migration
+
+  def self.up
+    remove_index :snapshot_data, :name => 'snapshot_data_resource_id'
+    drop_table :snapshot_data
+  end
+
+end
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/FileHashesPersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/FileHashesPersister.java
deleted file mode 100644 (file)
index 526ce7b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.batch.index;
-
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.source.SnapshotDataTypes;
-import org.sonar.core.source.db.SnapshotDataDao;
-import org.sonar.core.source.db.SnapshotDataDto;
-
-/**
- * Store file hashes in snapshot_data for reuse in next analysis to know if a file is modified
- */
-public class FileHashesPersister implements ScanPersister {
-  private final ComponentDataCache data;
-  private final ResourceCache resourceCache;
-  private final SnapshotDataDao dao;
-  private final MyBatis mybatis;
-
-  public FileHashesPersister(ComponentDataCache data, ResourceCache resourceCache,
-    SnapshotDataDao dao, MyBatis mybatis) {
-    this.data = data;
-    this.resourceCache = resourceCache;
-    this.dao = dao;
-    this.mybatis = mybatis;
-  }
-
-  @Override
-  public void persist() {
-    try (DbSession session = mybatis.openSession(true)) {
-      for (BatchResource batchResource : resourceCache.all()) {
-        String componentKey = batchResource.resource().getEffectiveKey();
-        String fileHashesdata = data.getStringData(componentKey, SnapshotDataTypes.FILE_HASHES);
-        if (fileHashesdata != null) {
-          SnapshotDataDto dto = new SnapshotDataDto();
-          dto.setSnapshotId(batchResource.snapshotId());
-          dto.setResourceId(batchResource.resource().getId());
-          dto.setDataType(SnapshotDataTypes.FILE_HASHES);
-          dto.setData(fileHashesdata);
-          dao.insert(session, dto);
-        }
-      }
-      session.commit();
-    }
-  }
-}
index cfae1f932764d52654e3c9a6c50c493331a67b29..90a10bc1191a73c7525c110ed25181aeff94786d 100644 (file)
@@ -31,26 +31,22 @@ import org.sonar.api.database.model.Snapshot;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.batch.bootstrap.AnalysisMode;
 import org.sonar.batch.bootstrap.ServerClient;
 import org.sonar.batch.bootstrap.TaskProperties;
 import org.sonar.batch.protocol.input.FileData;
 import org.sonar.batch.protocol.input.ProjectReferentials;
 import org.sonar.batch.rule.ModuleQProfiles;
-import org.sonar.core.source.SnapshotDataTypes;
-import org.sonar.core.source.db.SnapshotDataDao;
-import org.sonar.core.source.db.SnapshotDataDto;
 
 import javax.annotation.CheckForNull;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoader {
 
@@ -60,22 +56,18 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad
 
   private final ServerClient serverClient;
   private final AnalysisMode analysisMode;
-  private final SnapshotDataDao dao;
   private final DatabaseSession session;
 
-  public DefaultProjectReferentialsLoader(DatabaseSession session, ServerClient serverClient, AnalysisMode analysisMode,
-    SnapshotDataDao dao) {
+  public DefaultProjectReferentialsLoader(DatabaseSession session, ServerClient serverClient, AnalysisMode analysisMode) {
     this.session = session;
     this.serverClient = serverClient;
     this.analysisMode = analysisMode;
-    this.dao = dao;
   }
 
   public DefaultProjectReferentialsLoader(ServerClient serverClient, AnalysisMode analysisMode) {
     this.session = null;
     this.serverClient = serverClient;
     this.analysisMode = analysisMode;
-    this.dao = null;
   }
 
   @Override
@@ -93,9 +85,9 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad
     if (session != null) {
       for (ProjectDefinition module : reactor.getProjects()) {
 
-        for (Map.Entry<String, String> hashByPaths : hashByRelativePath(module.getKeyWithBranch()).entrySet()) {
-          String path = hashByPaths.getKey();
-          String hash = hashByPaths.getValue();
+        for (Entry<String, FileData> fileDataByPaths : ref.fileDataByPath(module.getKeyWithBranch()).entrySet()) {
+          String path = fileDataByPaths.getKey();
+          FileData fileData = fileDataByPaths.getValue();
           String lastCommits = null;
           String revisions = null;
           String authors = null;
@@ -110,7 +102,7 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad
               authors = ((MeasureModel) measureByKey[1]).getData(CoreMetrics.SCM_AUTHORS_BY_LINE);
             }
           }
-          ref.addFileData(module.getKeyWithBranch(), path, new FileData(hash, authors == null, lastCommits, revisions, authors));
+          ref.addFileData(module.getKeyWithBranch(), path, new FileData(fileData.hash(), authors == null, lastCommits, revisions, authors));
         }
       }
       ref.setLastAnalysisDate(lastSnapshotCreationDate(projectKey));
@@ -118,20 +110,6 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad
     return ref;
   }
 
-  public Map<String, String> hashByRelativePath(String projectKey) {
-    Map<String, String> map = Maps.newHashMap();
-    Collection<SnapshotDataDto> selectSnapshotData = dao.selectSnapshotDataByComponentKey(
-      projectKey,
-      Arrays.asList(SnapshotDataTypes.FILE_HASHES)
-      );
-    if (!selectSnapshotData.isEmpty()) {
-      SnapshotDataDto snapshotDataDto = selectSnapshotData.iterator().next();
-      String data = snapshotDataDto.getData();
-      map = KeyValueFormat.parse(data);
-    }
-    return map;
-  }
-
   public List<Object[]> query(String resourceKey, String... metricKeys) {
     StringBuilder sb = new StringBuilder();
     Map<String, Object> params = Maps.newHashMap();
index 98598f57f33b87b44a933685cd79d87ddb863324..a7af5621465deba27635ac40ff352f3737f926fe 100644 (file)
@@ -91,7 +91,6 @@ import org.sonar.batch.scan.filesystem.InputFileBuilderFactory;
 import org.sonar.batch.scan.filesystem.LanguageDetectionFactory;
 import org.sonar.batch.scan.filesystem.ModuleFileSystemInitializer;
 import org.sonar.batch.scan.filesystem.ModuleInputFileCache;
-import org.sonar.batch.scan.filesystem.PreviousFileHashLoader;
 import org.sonar.batch.scan.filesystem.ProjectFileSystemAdapter;
 import org.sonar.batch.scan.filesystem.StatusDetectionFactory;
 import org.sonar.batch.scan.maven.MavenPluginsConfigurator;
@@ -162,7 +161,6 @@ public class ModuleScanContainer extends ComponentContainer {
       InputFileBuilderFactory.class,
       StatusDetectionFactory.class,
       LanguageDetectionFactory.class,
-      PreviousFileHashLoader.class,
       FileIndexer.class,
       ComponentIndexer.class,
       LanguageVerifier.class,
index a1f115568b64f072cf95078c900e55b90efd8c1b..397e074d54624220c2cada7278e3cb61df41b565 100644 (file)
@@ -51,7 +51,6 @@ import org.sonar.batch.index.DefaultIndex;
 import org.sonar.batch.index.DependencyPersister;
 import org.sonar.batch.index.DuplicationPersister;
 import org.sonar.batch.index.EventPersister;
-import org.sonar.batch.index.FileHashesPersister;
 import org.sonar.batch.index.LinkPersister;
 import org.sonar.batch.index.MeasurePersister;
 import org.sonar.batch.index.ResourceCache;
@@ -146,7 +145,6 @@ public class ProjectScanContainer extends ComponentContainer {
       Caches.class,
       ResourceCache.class,
       ComponentDataCache.class,
-      FileHashesPersister.class,
 
       // file system
       InputPathCache.class,
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoader.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoader.java
deleted file mode 100644 (file)
index 79b1019..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.batch.scan.filesystem;
-
-import com.google.common.collect.Maps;
-import org.sonar.api.BatchComponent;
-import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.Project;
-import org.sonar.api.utils.KeyValueFormat;
-import org.sonar.batch.components.PastSnapshot;
-import org.sonar.batch.components.PastSnapshotFinder;
-import org.sonar.batch.index.ResourceCache;
-import org.sonar.core.source.SnapshotDataTypes;
-import org.sonar.core.source.db.SnapshotDataDao;
-import org.sonar.core.source.db.SnapshotDataDto;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-
-public class PreviousFileHashLoader implements BatchComponent {
-
-  private final SnapshotDataDao dao;
-  private final PastSnapshotFinder pastSnapshotFinder;
-  private final Project project;
-  private final ResourceCache resourceCache;
-
-  public PreviousFileHashLoader(Project project, ResourceCache resourceCache, SnapshotDataDao dao, PastSnapshotFinder pastSnapshotFinder) {
-    this.project = project;
-    this.resourceCache = resourceCache;
-    this.dao = dao;
-    this.pastSnapshotFinder = pastSnapshotFinder;
-  }
-
-  /**
-   * Extract hash of the files parsed during the previous analysis
-   */
-  public Map<String, String> hashByRelativePath() {
-    Snapshot snapshot = resourceCache.get(project.getEffectiveKey()).snapshot();
-    Map<String, String> map = Maps.newHashMap();
-    PastSnapshot pastSnapshot = pastSnapshotFinder.findPreviousAnalysis(snapshot);
-    if (pastSnapshot.isRelatedToSnapshot()) {
-      Collection<SnapshotDataDto> selectSnapshotData = dao.selectSnapshotData(
-        pastSnapshot.getProjectSnapshot().getId().longValue(),
-        Arrays.asList(SnapshotDataTypes.FILE_HASHES)
-        );
-      if (!selectSnapshotData.isEmpty()) {
-        SnapshotDataDto snapshotDataDto = selectSnapshotData.iterator().next();
-        String data = snapshotDataDto.getData();
-        map = KeyValueFormat.parse(data);
-      }
-    }
-    return map;
-  }
-
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/FileHashesPersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/FileHashesPersisterTest.java
deleted file mode 100644 (file)
index 5d01dde..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.batch.index;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.Project;
-import org.sonar.core.persistence.AbstractDaoTestCase;
-import org.sonar.core.source.SnapshotDataTypes;
-import org.sonar.core.source.db.SnapshotDataDao;
-
-public class FileHashesPersisterTest extends AbstractDaoTestCase {
-
-  @ClassRule
-  public static TemporaryFolder temp = new TemporaryFolder();
-
-  ResourceCache resourceCache;
-  ComponentDataCache data;
-  Caches caches;
-
-  @Before
-  public void start() throws Exception {
-    resourceCache = new ResourceCache();
-    caches = CachesTest.createCacheOnTemp(temp);
-    caches.start();
-  }
-
-  @After
-  public void stop() {
-    caches.stop();
-  }
-
-  @Test
-  public void should_persist_component_data() throws Exception {
-    setupData("should_persist_component_data");
-    Snapshot snapshot = new Snapshot();
-    snapshot.setId(100);
-    snapshot.setResourceId(200);
-    resourceCache.add(new Project("myProject").setId(200), null).setSnapshot(snapshot);
-
-    data = new ComponentDataCache(caches);
-    data.setStringData("myProject", SnapshotDataTypes.FILE_HASHES, "org/struts/Action.java=123ABC");
-
-    SnapshotDataDao dataDao = new SnapshotDataDao(getMyBatis());
-    FileHashesPersister persister = new FileHashesPersister(data, resourceCache, dataDao, getMyBatis());
-    persister.persist();
-
-    checkTables("should_persist_component_data", new String[] {"id", "created_at", "updated_at"}, "snapshot_data");
-  }
-}
index 9da2dbf5cb7a14caf42643055e402c8b51aeabef..2a66a09cc59c28ead399249d6ef1e49b936a98f9 100644 (file)
@@ -29,7 +29,6 @@ import org.sonar.batch.bootstrap.AnalysisMode;
 import org.sonar.batch.bootstrap.ServerClient;
 import org.sonar.batch.bootstrap.TaskProperties;
 import org.sonar.batch.rule.ModuleQProfiles;
-import org.sonar.core.source.db.SnapshotDataDao;
 
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.doReturn;
@@ -50,7 +49,7 @@ public class DefaultProjectReferentialsLoaderTest {
   public void prepare() {
     serverClient = mock(ServerClient.class);
     analysisMode = mock(AnalysisMode.class);
-    loader = new DefaultProjectReferentialsLoader(mock(DatabaseSession.class), serverClient, analysisMode, mock(SnapshotDataDao.class));
+    loader = new DefaultProjectReferentialsLoader(mock(DatabaseSession.class), serverClient, analysisMode);
     loader = spy(loader);
     doReturn(null).when(loader).lastSnapshotCreationDate(anyString());
     when(serverClient.request(anyString())).thenReturn("{}");
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoaderTest.java
deleted file mode 100644 (file)
index efcd5b3..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.batch.scan.filesystem;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.Project;
-import org.sonar.batch.components.PastSnapshot;
-import org.sonar.batch.components.PastSnapshotFinder;
-import org.sonar.batch.index.ResourceCache;
-import org.sonar.core.source.SnapshotDataTypes;
-import org.sonar.core.source.db.SnapshotDataDao;
-import org.sonar.core.source.db.SnapshotDataDto;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class PreviousFileHashLoaderTest {
-
-  @Rule
-  public TemporaryFolder temp = new TemporaryFolder();
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  private PastSnapshotFinder pastSnapshotFinder = mock(PastSnapshotFinder.class);
-  private Snapshot snapshot = mock(Snapshot.class);
-  private SnapshotDataDao snapshotDataDao = mock(SnapshotDataDao.class);
-  private Project project = new Project("foo");
-  private ResourceCache resourceCache;
-  private PreviousFileHashLoader loader;
-
-  @Before
-  public void prepare() {
-    resourceCache = new ResourceCache();
-    resourceCache.add(project, null).setSnapshot(snapshot);
-    loader = new PreviousFileHashLoader(project, resourceCache, snapshotDataDao, pastSnapshotFinder);
-  }
-
-  @Test
-  public void should_return_null_if_no_previous_snapshot() throws Exception {
-    when(pastSnapshotFinder.findPreviousAnalysis(snapshot)).thenReturn(new PastSnapshot("foo"));
-
-    Map<String, String> hashByRelativePath = loader.hashByRelativePath();
-    assertThat(hashByRelativePath.get("src/main/java/foo/Bar.java")).isNull();
-  }
-
-  @Test
-  public void should_return_null_if_no_remote_hashes() throws Exception {
-    Snapshot previousSnapshot = mock(Snapshot.class);
-    PastSnapshot pastSnapshot = new PastSnapshot("foo", new Date(), previousSnapshot);
-    when(pastSnapshotFinder.findPreviousAnalysis(snapshot)).thenReturn(pastSnapshot);
-
-    Map<String, String> hashByRelativePath = loader.hashByRelativePath();
-    assertThat(hashByRelativePath.get("src/main/java/foo/Bar.java")).isNull();
-  }
-
-  @Test
-  public void should_return_remote_hash() throws Exception {
-    Snapshot previousSnapshot = mock(Snapshot.class);
-    when(previousSnapshot.getId()).thenReturn(123);
-    PastSnapshot pastSnapshot = new PastSnapshot("foo", new Date(), previousSnapshot);
-    when(pastSnapshotFinder.findPreviousAnalysis(snapshot)).thenReturn(pastSnapshot);
-
-    SnapshotDataDto snapshotDataDto = new SnapshotDataDto();
-    snapshotDataDto.setData("src/main/java/foo/Bar.java=abcd1234");
-    when(snapshotDataDao.selectSnapshotData(123, Arrays.asList(SnapshotDataTypes.FILE_HASHES)))
-      .thenReturn(Arrays.asList(snapshotDataDto));
-
-    Map<String, String> hashByRelativePath = loader.hashByRelativePath();
-    assertThat(hashByRelativePath.get("src/main/java/foo/Bar.java")).isEqualTo("abcd1234");
-  }
-}
index b7436623a00a727d9a673d48ebf11fc3efce29d6..be4df84ff01165c8812a9f56a9b5259c19e60eb2 100644 (file)
@@ -42,7 +42,6 @@ import org.sonar.core.resource.ResourceIndexerDao;
 import org.sonar.core.resource.ResourceKeyUpdaterDao;
 import org.sonar.core.rule.RuleDao;
 import org.sonar.core.source.db.FileSourceDao;
-import org.sonar.core.source.db.SnapshotDataDao;
 import org.sonar.core.technicaldebt.db.CharacteristicDao;
 import org.sonar.core.template.LoadedTemplateDao;
 import org.sonar.core.user.AuthorDao;
@@ -91,7 +90,6 @@ public final class DaoUtils {
       RoleDao.class,
       RuleDao.class,
       SemaphoreDao.class,
-      SnapshotDataDao.class,
       UserDao.class
       );
   }
index 0c9e72388310957f258d30571c5882b5ac09ab8a..7e8d536c4d7e69125be9e7ae04f61f790429ad2b 100644 (file)
@@ -33,7 +33,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 767;
+  public static final int LAST_VERSION = 768;
 
   /**
    * List of all the tables.n
@@ -84,7 +84,6 @@ public class DatabaseVersion implements BatchComponent, ServerComponent {
     "semaphores",
     "schema_migrations",
     "snapshots",
-    "snapshot_data",
     "users",
     "user_roles",
     "widgets",
index 922ac8e7be2f890465c8a3810a70edbdfa61a17a..62e559e59fc00716e9bcea778c4cdacaa7fe58b2 100644 (file)
@@ -25,7 +25,11 @@ import com.google.common.io.Closeables;
 import org.apache.ibatis.builder.xml.XMLMapperBuilder;
 import org.apache.ibatis.logging.LogFactory;
 import org.apache.ibatis.mapping.Environment;
-import org.apache.ibatis.session.*;
+import org.apache.ibatis.session.Configuration;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.apache.ibatis.session.SqlSessionFactoryBuilder;
 import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
 import org.apache.ibatis.type.JdbcType;
 import org.slf4j.LoggerFactory;
@@ -43,7 +47,14 @@ import org.sonar.core.component.db.SnapshotMapper;
 import org.sonar.core.computation.db.AnalysisReportDto;
 import org.sonar.core.computation.db.AnalysisReportMapper;
 import org.sonar.core.config.Logback;
-import org.sonar.core.dashboard.*;
+import org.sonar.core.dashboard.ActiveDashboardDto;
+import org.sonar.core.dashboard.ActiveDashboardMapper;
+import org.sonar.core.dashboard.DashboardDto;
+import org.sonar.core.dashboard.DashboardMapper;
+import org.sonar.core.dashboard.WidgetDto;
+import org.sonar.core.dashboard.WidgetMapper;
+import org.sonar.core.dashboard.WidgetPropertyDto;
+import org.sonar.core.dashboard.WidgetPropertyMapper;
 import org.sonar.core.dependency.DependencyDto;
 import org.sonar.core.dependency.DependencyMapper;
 import org.sonar.core.dependency.ResourceSnapshotDto;
@@ -52,11 +63,32 @@ import org.sonar.core.duplication.DuplicationMapper;
 import org.sonar.core.duplication.DuplicationUnitDto;
 import org.sonar.core.graph.jdbc.GraphDto;
 import org.sonar.core.graph.jdbc.GraphDtoMapper;
-import org.sonar.core.issue.db.*;
-import org.sonar.core.measure.db.*;
+import org.sonar.core.issue.db.ActionPlanDto;
+import org.sonar.core.issue.db.ActionPlanMapper;
+import org.sonar.core.issue.db.ActionPlanStatsDto;
+import org.sonar.core.issue.db.ActionPlanStatsMapper;
+import org.sonar.core.issue.db.IssueChangeDto;
+import org.sonar.core.issue.db.IssueChangeMapper;
+import org.sonar.core.issue.db.IssueDto;
+import org.sonar.core.issue.db.IssueFilterDto;
+import org.sonar.core.issue.db.IssueFilterFavouriteDto;
+import org.sonar.core.issue.db.IssueFilterFavouriteMapper;
+import org.sonar.core.issue.db.IssueFilterMapper;
+import org.sonar.core.issue.db.IssueMapper;
+import org.sonar.core.measure.db.MeasureDto;
+import org.sonar.core.measure.db.MeasureFilterDto;
+import org.sonar.core.measure.db.MeasureFilterMapper;
+import org.sonar.core.measure.db.MeasureMapper;
+import org.sonar.core.measure.db.MetricDto;
+import org.sonar.core.measure.db.MetricMapper;
 import org.sonar.core.notification.db.NotificationQueueDto;
 import org.sonar.core.notification.db.NotificationQueueMapper;
-import org.sonar.core.permission.*;
+import org.sonar.core.permission.GroupWithPermissionDto;
+import org.sonar.core.permission.PermissionTemplateDto;
+import org.sonar.core.permission.PermissionTemplateGroupDto;
+import org.sonar.core.permission.PermissionTemplateMapper;
+import org.sonar.core.permission.PermissionTemplateUserDto;
+import org.sonar.core.permission.UserWithPermissionDto;
 import org.sonar.core.persistence.dialect.Dialect;
 import org.sonar.core.persistence.migration.v44.Migration44Mapper;
 import org.sonar.core.persistence.migration.v45.Migration45Mapper;
@@ -66,21 +98,44 @@ import org.sonar.core.properties.PropertyDto;
 import org.sonar.core.purge.IdUuidPair;
 import org.sonar.core.purge.PurgeMapper;
 import org.sonar.core.purge.PurgeableSnapshotDto;
-import org.sonar.core.qualitygate.db.*;
-import org.sonar.core.qualityprofile.db.*;
-import org.sonar.core.resource.*;
+import org.sonar.core.qualitygate.db.ProjectQgateAssociationDto;
+import org.sonar.core.qualitygate.db.ProjectQgateAssociationMapper;
+import org.sonar.core.qualitygate.db.QualityGateConditionDto;
+import org.sonar.core.qualitygate.db.QualityGateConditionMapper;
+import org.sonar.core.qualitygate.db.QualityGateDto;
+import org.sonar.core.qualitygate.db.QualityGateMapper;
+import org.sonar.core.qualityprofile.db.ActiveRuleDto;
+import org.sonar.core.qualityprofile.db.ActiveRuleMapper;
+import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
+import org.sonar.core.qualityprofile.db.QualityProfileDto;
+import org.sonar.core.qualityprofile.db.QualityProfileMapper;
+import org.sonar.core.resource.ResourceDto;
+import org.sonar.core.resource.ResourceIndexDto;
+import org.sonar.core.resource.ResourceIndexerMapper;
+import org.sonar.core.resource.ResourceKeyUpdaterMapper;
+import org.sonar.core.resource.ResourceMapper;
 import org.sonar.core.rule.RuleDto;
 import org.sonar.core.rule.RuleMapper;
 import org.sonar.core.rule.RuleParamDto;
 import org.sonar.core.source.db.FileSourceMapper;
-import org.sonar.core.source.db.SnapshotDataDto;
-import org.sonar.core.source.db.SnapshotDataMapper;
 import org.sonar.core.technicaldebt.db.CharacteristicDto;
 import org.sonar.core.technicaldebt.db.CharacteristicMapper;
 import org.sonar.core.technicaldebt.db.RequirementMigrationDto;
 import org.sonar.core.template.LoadedTemplateDto;
 import org.sonar.core.template.LoadedTemplateMapper;
-import org.sonar.core.user.*;
+import org.sonar.core.user.AuthorDto;
+import org.sonar.core.user.AuthorMapper;
+import org.sonar.core.user.GroupDto;
+import org.sonar.core.user.GroupMapper;
+import org.sonar.core.user.GroupMembershipDto;
+import org.sonar.core.user.GroupMembershipMapper;
+import org.sonar.core.user.GroupRoleDto;
+import org.sonar.core.user.RoleMapper;
+import org.sonar.core.user.UserDto;
+import org.sonar.core.user.UserGroupDto;
+import org.sonar.core.user.UserGroupMapper;
+import org.sonar.core.user.UserMapper;
+import org.sonar.core.user.UserRoleDto;
 
 import java.io.InputStream;
 
@@ -166,7 +221,6 @@ public class MyBatis implements BatchComponent, ServerComponent {
     loadAlias(conf, "IssueChange", IssueChangeDto.class);
     loadAlias(conf, "IssueFilter", IssueFilterDto.class);
     loadAlias(conf, "IssueFilterFavourite", IssueFilterFavouriteDto.class);
-    loadAlias(conf, "SnapshotData", SnapshotDataDto.class);
     loadAlias(conf, "ActionPlanIssue", ActionPlanDto.class);
     loadAlias(conf, "ActionPlanStats", ActionPlanStatsDto.class);
     loadAlias(conf, "PermissionTemplate", PermissionTemplateDto.class);
@@ -196,7 +250,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
       LoadedTemplateMapper.class, MeasureFilterMapper.class, Migration44Mapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class,
       ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class, ResourceSnapshotMapper.class, RoleMapper.class, RuleMapper.class,
       SchemaMigrationMapper.class, SemaphoreMapper.class, UserMapper.class, GroupMapper.class, UserGroupMapper.class, WidgetMapper.class, WidgetPropertyMapper.class,
-      org.sonar.api.database.model.MeasureMapper.class, SnapshotDataMapper.class, FileSourceMapper.class, ActionPlanMapper.class,
+      org.sonar.api.database.model.MeasureMapper.class, FileSourceMapper.class, ActionPlanMapper.class,
       ActionPlanStatsMapper.class,
       NotificationQueueMapper.class, CharacteristicMapper.class,
       GroupMembershipMapper.class, QualityProfileMapper.class, ActiveRuleMapper.class,
index a61f4d8f0811e9dbbf45fd2674ea601a0cd65d75..8b1cbf45992ad91681c1fc3219a79a2fa130b24f 100644 (file)
@@ -26,7 +26,6 @@ import org.sonar.api.utils.SonarException;
 import org.sonar.core.profiling.Profiling;
 import org.sonar.core.profiling.Profiling.Level;
 import org.sonar.core.profiling.StopWatch;
-import org.sonar.core.source.SnapshotDataTypes;
 
 import javax.annotation.Nullable;
 import javax.sql.DataSource;
@@ -100,31 +99,9 @@ public class PreviewDatabaseFactory implements ServerComponent {
       StringBuilder snapshotQuery = new StringBuilder()
         // All snapshots of root_project for alerts on differential periods
         .append("SELECT * FROM snapshots WHERE project_id=")
-        .append(projectId)
-        // Plus all last snapshots of all modules having hash data for partial analysis
-        .append(" UNION SELECT snap.* FROM snapshots snap")
-        .append(" INNER JOIN (")
-        .append(projectQuery(projectId, true))
-        .append(") res")
-        .append(" ON snap.project_id=res.id")
-        .append(" INNER JOIN snapshot_data data")
-        .append(" ON snap.id=data.snapshot_id")
-        .append(" AND data.data_type='").append(SnapshotDataTypes.FILE_HASHES).append("'")
-        .append(" AND snap.islast=").append(database.getDialect().getTrueSqlValue());
+        .append(projectId);
       template.copyTable(source, dest, "snapshots", snapshotQuery.toString());
 
-      StringBuilder snapshotDataQuery = new StringBuilder()
-        .append("SELECT data.* FROM snapshot_data data")
-        .append(" INNER JOIN snapshots s")
-        .append(" ON s.id=data.snapshot_id")
-        .append(" AND s.islast=").append(database.getDialect().getTrueSqlValue())
-        .append(" INNER JOIN (")
-        .append(projectQuery(projectId, true))
-        .append(") res")
-        .append(" ON data.resource_id=res.id")
-        .append(" AND data.data_type='").append(SnapshotDataTypes.FILE_HASHES).append("'");
-      template.copyTable(source, dest, "snapshot_data", snapshotDataQuery.toString());
-
       // All measures of snapshots of root project for alerts on differential periods
       template.copyTable(source, dest, "project_measures", "SELECT m.* FROM project_measures m INNER JOIN snapshots s on m.snapshot_id=s.id "
         + "WHERE s.project_id=" + projectId);
index 3bdb2248a16255238f09793e9028eb4b87832f77..546cf8c3d333960142085df0672372a2a619c24d 100644 (file)
@@ -182,8 +182,6 @@ class PurgeCommands {
 
     deleteSnapshotGraphs(snapshotIdsPartition);
 
-    deleteSnapshotData(snapshotIdsPartition);
-
     profiler.start("deleteSnapshot (snapshots)");
     for (List<Long> partSnapshotIds : snapshotIdsPartition) {
       purgeMapper.deleteSnapshot(partSnapshotIds);
@@ -207,8 +205,6 @@ class PurgeCommands {
 
     deleteSnapshotGraphs(snapshotIdsPartition);
 
-    deleteSnapshotData(snapshotIdsPartition);
-
     profiler.start("deleteSnapshotWastedMeasures (project_measures)");
     List<Long> metricIdsWithoutHistoricalData = purgeMapper.selectMetricIdsWithoutHistoricalData();
     for (List<Long> partSnapshotIds : snapshotIdsPartition) {
@@ -225,15 +221,6 @@ class PurgeCommands {
     profiler.stop();
   }
 
-  private void deleteSnapshotData(final List<List<Long>> snapshotIdsPartition) {
-    profiler.start("deleteSnapshotData (snapshot_data)");
-    for (List<Long> partSnapshotIds : snapshotIdsPartition) {
-      purgeMapper.deleteSnapshotData(partSnapshotIds);
-    }
-    session.commit();
-    profiler.stop();
-  }
-
   private void deleteSnapshotGraphs(final List<List<Long>> snapshotIdsPartition) {
     profiler.start("deleteSnapshotGraphs (graphs)");
     for (List<Long> partSnapshotIds : snapshotIdsPartition) {
index 81e0d2d973eababc0461a26b08f49e8bf0a43277..54cffca45c36e1b95d37502a000d90618fd09971 100644 (file)
@@ -50,8 +50,6 @@ public interface PurgeMapper {
 
   void deleteSnapshotGraphs(@Param("snapshotIds") List<Long> snapshotIds);
 
-  void deleteSnapshotData(@Param("snapshotIds") List<Long> snapshotIds);
-
   List<Long> selectMetricIdsWithoutHistoricalData();
 
   void deleteSnapshotWastedMeasures(@Param("snapshotIds") List<Long> snapshotIds, @Param("mids") List<Long> metricIds);
index 745b21b8c973cd092129a2ad3ccabc22b30872fc..96d11d51652d737c050f0c4b637b984d05a98f98 100644 (file)
@@ -24,10 +24,4 @@ public interface SnapshotDataTypes {
 
   String SYNTAX_HIGHLIGHTING = "highlight_syntax";
   String SYMBOL_HIGHLIGHTING = "symbol";
-
-  /**
-   * Key-values [relative path, hash] of all files. Stored on modules.
-   * @since 4.0
-   */
-  String FILE_HASHES = "file_hashes";
 }
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDao.java b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDao.java
deleted file mode 100644 (file)
index 0b9ad50..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.core.source.db;
-
-import org.apache.ibatis.session.SqlSession;
-import org.sonar.api.BatchComponent;
-import org.sonar.api.ServerComponent;
-import org.sonar.core.persistence.MyBatis;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @since 3.6
- */
-public class SnapshotDataDao implements BatchComponent, ServerComponent {
-
-  private final MyBatis mybatis;
-
-  public SnapshotDataDao(MyBatis mybatis) {
-    this.mybatis = mybatis;
-  }
-
-  public Collection<SnapshotDataDto> selectSnapshotData(long snapshotId, List<String> dataTypes) {
-    SqlSession session = mybatis.openSession(false);
-    try {
-      SnapshotDataMapper mapper = session.getMapper(SnapshotDataMapper.class);
-      return mapper.selectSnapshotData(snapshotId, dataTypes);
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-  }
-
-
-  public Collection<SnapshotDataDto> selectSnapshotDataByComponentKey(String componentKey, List<String> dataTypes) {
-    SqlSession session = mybatis.openSession(false);
-    try {
-      return selectSnapshotDataByComponentKey(componentKey, dataTypes, session);
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-  }
-
-  public Collection<SnapshotDataDto> selectSnapshotDataByComponentKey(String componentKey, List<String> dataTypes, SqlSession session) {
-    SnapshotDataMapper mapper = session.getMapper(SnapshotDataMapper.class);
-    return mapper.selectSnapshotDataByComponentKey(componentKey, dataTypes);
-  }
-
-  void insert(SnapshotDataDto snapshotData) {
-    SqlSession session = mybatis.openSession(false);
-    try {
-      insert(session, snapshotData);
-      session.commit();
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-  }
-
-  public void insert(SqlSession session, SnapshotDataDto snapshotData) {
-    SnapshotDataMapper mapper = session.getMapper(SnapshotDataMapper.class);
-    mapper.insert(snapshotData);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDto.java b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDto.java
deleted file mode 100644 (file)
index 8770b50..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.core.source.db;
-
-/**
- * @since 3.6
- */
-public class SnapshotDataDto {
-
-  private long id;
-  private long snapshotId;
-  private long resourceId;
-  private String data;
-  private String dataType;
-
-  public long getSnapshotId() {
-    return snapshotId;
-  }
-
-  public long getResourceId() {
-    return resourceId;
-  }
-
-  public String getData() {
-    return data;
-  }
-
-  public String getDataType() {
-    return dataType;
-  }
-
-  public long getId() {
-    return id;
-  }
-
-  public void setId(long id) {
-    this.id = id;
-  }
-
-  public void setSnapshotId(long snapshotId) {
-    this.snapshotId = snapshotId;
-  }
-
-  public void setResourceId(long resourceId) {
-    this.resourceId = resourceId;
-  }
-
-  public void setData(String data) {
-    this.data = data;
-  }
-
-  public void setDataType(String dataType) {
-    this.dataType = dataType;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataMapper.java b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataMapper.java
deleted file mode 100644 (file)
index d840bb3..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.core.source.db;
-
-import org.apache.ibatis.annotations.Param;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @since 3.6
- */
-public interface SnapshotDataMapper {
-
-  void insert(SnapshotDataDto snapshotData);
-
-  Collection<SnapshotDataDto> selectSnapshotData(@Param("sid") long snapshotId, @Param("dataTypes") List<String> dataTypes);
-
-  Collection<SnapshotDataDto> selectSnapshotDataByComponentKey(@Param("componentKey") String componentKey, @Param("dataTypes") List<String> dataTypes);
-}
index c5d83d903167748845259553cb7720aaf0a89dc5..39ac9d738fc7f66aa3bcb7f59ece3bd0daffd235 100644 (file)
@@ -296,6 +296,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('764');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('765');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('766');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('767');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('768');
 
 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 8a6fae8a07fefd5cb79281582666b0179e248706..835280c178715e810a3061626a2bf8224ff4c891 100644 (file)
@@ -497,16 +497,6 @@ CREATE TABLE "ISSUE_FILTER_FAVOURITES" (
   "CREATED_AT" TIMESTAMP
 );
 
-CREATE TABLE "SNAPSHOT_DATA" (
-  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "SNAPSHOT_ID" INTEGER,
-  "RESOURCE_ID" INTEGER,
-  "SNAPSHOT_DATA" VARCHAR(16777215),
-  "DATA_TYPE" VARCHAR(50),
-  "CREATED_AT" TIMESTAMP,
-  "UPDATED_AT" TIMESTAMP,
-);
-
 CREATE TABLE "PERMISSION_TEMPLATES" (
   "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
   "NAME" VARCHAR(100) NOT NULL,
@@ -712,8 +702,6 @@ CREATE UNIQUE INDEX "QUALITY_GATES_UNIQUE" ON "QUALITY_GATES" ("NAME");
 
 CREATE UNIQUE INDEX "ACTIVE_RULES_UNIQUE" ON "ACTIVE_RULES" ("PROFILE_ID","RULE_ID");
 
-CREATE INDEX "SNAPSHOT_DATA_RESOURCE_IDS" ON "SNAPSHOT_DATA" ("RESOURCE_ID");
-
 CREATE UNIQUE INDEX "PROFILE_UNIQUE_KEY" ON "RULES_PROFILES" ("KEE");
 
 CREATE INDEX "FILE_SOURCES_PROJECT_UUID" ON "FILE_SOURCES" ("PROJECT_UUID");
index 95aeeebeb3c952fc56e79925f1804b9bad8bd353..c3464bee19688a4e9e121b3f7d0cedc5c7a21c4f 100644 (file)
     update snapshots set islast=${_false} where project_id=#{id}
   </update>
 
-  <delete id="deleteSnapshotData" parameterType="map">
-    delete from snapshot_data where snapshot_id in
-    <foreach collection="snapshotIds" open="(" close=")" item="snapshotId" separator=",">
-      #{snapshotId}
-    </foreach>
-  </delete>
-
   <delete id="deleteResourceIssueChanges" parameterType="map">
     delete from issue_changes ic
     where exists (select * from issues i where i.kee=ic.issue_key and i.component_id in
index 1df75d5fadea154a48fad4caee56d8fc7e24d419..de7a7241fb1b2d042a22509fe8f28a376011ed59 100644 (file)
@@ -32,6 +32,7 @@ import org.sonar.api.config.Settings;
 import org.sonar.core.profiling.Profiling;
 
 import javax.sql.DataSource;
+
 import java.io.File;
 import java.io.IOException;
 import java.sql.Connection;
@@ -110,8 +111,7 @@ public class PreviewDatabaseFactoryTest extends AbstractDaoTestCase {
     dataSource = createDatabase(database);
     assertThat(countRows("issues")).isEqualTo(1);
     assertThat(countRows("projects")).isEqualTo(4);
-    assertThat(countRows("snapshots")).isEqualTo(4);
-    assertThat(countRows("snapshot_data")).isEqualTo(2);
+    assertThat(countRows("snapshots")).isEqualTo(2);
     assertThat(countRows("project_measures")).isEqualTo(4);
   }
 
index 704c13903db64ccf87ef091a23adb1cb1e27f53e..42fa52604aae2173fb857456cbb4ab01ecc86fe8 100644 (file)
@@ -52,8 +52,7 @@ public class PurgeCommandsTest extends AbstractDaoTestCase {
     } finally {
       MyBatis.closeQuietly(session);
     }
-    checkTables("shouldDeleteSnapshot",
-      "snapshots", "project_measures", "duplications_index", "events", "dependencies", "snapshot_data");
+    checkTables("shouldDeleteSnapshot", "snapshots", "project_measures", "duplications_index", "events", "dependencies");
   }
 
   /**
@@ -84,7 +83,7 @@ public class PurgeCommandsTest extends AbstractDaoTestCase {
       MyBatis.closeQuietly(session);
     }
     checkTables("shouldPurgeSnapshot",
-      "snapshots", "project_measures", "duplications_index", "events", "dependencies", "snapshot_data");
+      "snapshots", "project_measures", "duplications_index", "events", "dependencies");
   }
 
   @Test
diff --git a/sonar-core/src/test/java/org/sonar/core/source/db/SnapshotDataDaoTest.java b/sonar-core/src/test/java/org/sonar/core/source/db/SnapshotDataDaoTest.java
deleted file mode 100644 (file)
index 5f567aa..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.core.source.db;
-
-import com.google.common.collect.Lists;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.core.persistence.AbstractDaoTestCase;
-
-import java.util.Collection;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SnapshotDataDaoTest extends AbstractDaoTestCase {
-
-  private SnapshotDataDao dao;
-
-  @Before
-  public void createDao() {
-    dao = new SnapshotDataDao(getMyBatis());
-    setupData("shared");
-  }
-
-  @Test
-  public void select_snapshot_data_by_snapshot_id() throws Exception {
-    Collection<SnapshotDataDto> data = dao.selectSnapshotData(10L, Lists.newArrayList("highlight_syntax", "symbol"));
-
-    assertThat(data).extracting("snapshotId").containsOnly(10L, 10L);
-    assertThat(data).extracting("dataType").containsOnly("highlight_syntax", "symbol");
-    assertThat(data).extracting("data").containsOnly("0,10,k;", "20,25,20,35,45;");
-  }
-
-  @Test
-  public void serialize_snapshot_data() throws Exception {
-    String data = "0,10,k;";
-    String dataType = "highlight_syntax";
-
-    SnapshotDataDto dto = new SnapshotDataDto();
-    dto.setResourceId(1L);
-    dto.setSnapshotId(11L);
-    dto.setData(data);
-    dto.setDataType(dataType);
-
-    dao.insert(dto);
-
-    Collection<SnapshotDataDto> serializedData = dao.selectSnapshotData(11L, Lists.newArrayList("highlight_syntax"));
-
-    assertThat(serializedData).extracting("snapshotId").containsOnly(11L);
-    assertThat(serializedData).extracting("dataType").containsOnly(dataType);
-    assertThat(serializedData).extracting("data").containsOnly(data);
-  }
-
-  @Test
-  public void select_snapshot_data_by_project_id() throws Exception {
-    Collection<SnapshotDataDto> data = dao.selectSnapshotDataByComponentKey("org.apache.struts:struts:Dispatcher", Lists.newArrayList("highlight_syntax", "symbol"));
-
-    assertThat(data).isNotEmpty();
-    assertThat(data).extracting("snapshotId").containsOnly(10L, 10L);
-    assertThat(data).extracting("dataType").containsOnly("highlight_syntax", "symbol");
-    assertThat(data).extracting("data").containsOnly("0,10,k;", "20,25,20,35,45;");
-  }
-}
index 8ec9c6a4e0e7f781de69645a02a3e40526f42a08..121c528c36626d9771b3bcbe4eb43cfb475bcb39 100644 (file)
   <snapshots id="3012" project_id="302" root_project_id="300" root_snapshot_id="3010" path="3010." islast="[false]"/>
   <snapshots id="3013" project_id="303" root_project_id="300" root_snapshot_id="3010" path="3010.3011." islast="[false]"/>
 
-  <snapshot_data id="1" snapshot_id="3001" resource_id="301" snapshot_data="foo=AB12" data_type="file_hashes" />
-  <snapshot_data id="2" snapshot_id="3001" resource_id="301" snapshot_data="bar" data_type="other" />
-  <snapshot_data id="3" snapshot_id="3002" resource_id="302" snapshot_data="bar=DC12" data_type="file_hashes" />
-
-  <snapshot_data id="4" snapshot_id="3011" resource_id="301" snapshot_data="foo=CD34" data_type="file_hashes" />
-  <snapshot_data id="5" snapshot_id="3012" resource_id="302" snapshot_data="bar=EF78" data_type="file_hashes" />
-
   <project_measures id="1" value="12" metric_id="1" snapshot_id="3000" />
   <project_measures id="2" value="5" metric_id="1" snapshot_id="3001" />
   <project_measures id="3" value="7" metric_id="1" snapshot_id="3002" />
index d2711e0850641549b8fe2d26cf7e26565d07496c..0cbd194c972b93db167e7f2404575a5710bc600f 100644 (file)
@@ -29,7 +29,4 @@
           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]"/>
-
 </dataset>
index 2ff3064a175fd8a5af27d1f3faa548d022747e03..972a17da0ebc94e3735f293c87e23de6ff721ef4 100644 (file)
@@ -28,8 +28,6 @@
           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]"/>
 
 
   <!-- snapshot to remove, id 5 on resource 5-->
@@ -63,8 +61,6 @@
           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]"/>
 
 
 </dataset>
index d48051136b5839d3b2fcab28d0dd637eba819832..b7e8e2ecc67032ffe247a74124c6998db86b3308 100644 (file)
@@ -88,7 +88,4 @@ Note that measures, events and reviews are not deleted.
   <duplications_index id="2" project_snapshot_id="2" snapshot_id="2"
                       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]"/>
-
 </dataset>
index 262efa6af051e8bcbfa1800c2a8f698309a6de91..2eac727f667045c6dbbc60d07b508decf234d46e 100644 (file)
@@ -34,9 +34,6 @@
   <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]"/>
-
 
   <!-- The following is not purged but is kept for DBUnit -->
   <snapshots id="2"
@@ -75,7 +72,4 @@
   <duplications_index id="2" project_snapshot_id="2" snapshot_id="2"
                       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]"/>
-
 </dataset>