From 341bc8ebd3e02f48206546d18355f3e92f53ddf5 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Fri, 23 Jan 2015 14:55:40 +0100 Subject: [PATCH] delete component ids from the issues table --- .../computation/dbcleaner/ProjectCleaner.java | 9 +- .../computation/AnalysisReportService.java | 1 - .../computation/step/PersistIssuesStep.java | 4 +- .../server/issue/ServerIssueStorage.java | 2 +- .../issue/index/IssueResultSetIterator.java | 4 +- .../server/issue/ServerIssueStorageTest.java | 9 +- .../sonar/server/issue/db/IssueDaoTest.java | 8 +- .../return_only_manual_severity.xml | 4 +- .../server/batch/IssuesActionTest/shared.xml | 13 ++- .../should_insert_new_issues-result.xml | 2 - .../should_update_issues-result.xml | 6 +- .../should_update_issues.xml | 8 +- .../db/IssueDaoTest/find_by_action_plan.xml | 4 +- .../issue/db/IssueDaoTest/get_by_key.xml | 4 +- .../issue/db/IssueDaoTest/insert-result.xml | 2 - ...elect_non_closed_issues_by_module_uuid.xml | 24 ++--- ...lect_non_closed_issues_by_project_uuid.xml | 24 ++--- .../issue/db/IssueDaoTest/update-result.xml | 29 ++++++ .../server/issue/db/IssueDaoTest/update.xml | 28 ++++++ .../issue/index/IssueIndexerTest/index.xml | 9 +- .../extract_directory_path.xml | 12 +-- .../IssueResultSetIteratorTest/shared.xml | 8 +- .../migrate/773_remove_issue_component_ids.rb | 34 +++++++ .../sonar/batch/scan/report/JSONReport.java | 9 +- .../dbcleaner/DefaultPurgeTask.java | 16 ++-- .../org/sonar/core/issue/db/IssueDto.java | 67 ++++--------- .../core/issue/db/UpdateConflictResolver.java | 2 +- .../core/persistence/DatabaseVersion.java | 2 +- .../persistence/PreviewDatabaseFactory.java | 8 +- .../org/sonar/core/purge/IdUuidPairs.java | 29 +++--- .../org/sonar/core/purge/PurgeCommands.java | 41 ++++---- .../sonar/core/purge/PurgeConfiguration.java | 21 ++-- .../java/org/sonar/core/purge/PurgeDao.java | 48 +++++----- .../org/sonar/core/purge/PurgeMapper.java | 17 ++-- .../sonar/core/issue/db/IssueChangeMapper.xml | 4 +- .../org/sonar/core/issue/db/IssueMapper.xml | 47 ++++----- .../org/sonar/core/persistence/rows-h2.sql | 1 + .../org/sonar/core/persistence/schema-h2.ddl | 10 +- .../org/sonar/core/purge/PurgeMapper.xml | 52 +++++----- .../dbcleaner/DefaultPurgeTaskTest.java | 12 +-- .../org/sonar/core/issue/db/IssueDaoTest.java | 2 - .../org/sonar/core/issue/db/IssueDtoTest.java | 7 +- .../sonar/core/issue/db/IssueMapperTest.java | 21 ++-- .../sonar/core/issue/db/IssueStorageTest.java | 25 ++--- .../issue/db/UpdateConflictResolverTest.java | 3 +- .../sonar/core/purge/PurgeCommandsTest.java | 13 ++- .../core/purge/PurgeConfigurationTest.java | 6 +- .../org/sonar/core/purge/PurgeDaoTest.java | 24 +++-- .../should_find_by_project.xml | 11 ++- .../select_issue_changelog_by_module.xml | 28 +++--- ..._by_module_are_sorted_by_creation_date.xml | 6 +- .../IssueDaoTest/find_rules_by_component.xml | 12 +-- .../find_severities_by_component.xml | 12 +-- .../db/IssueDaoTest/should_select_by_key.xml | 4 +- .../should_select_issue_and_component_ids.xml | 12 +-- ...uld_select_non_closed_issues_by_module.xml | 20 ++-- ...ed_issues_by_module_on_removed_project.xml | 16 ++-- .../db/IssueMapperTest/testInsert-result.xml | 6 +- .../db/IssueMapperTest/testUpdate-result.xml | 6 +- .../issue/db/IssueMapperTest/testUpdate.xml | 6 +- ...eforeSelectedDate_with_conflict-result.xml | 6 +- ...updateBeforeSelectedDate_with_conflict.xml | 6 +- .../should_select_assignees.xml | 12 +-- .../should_insert_new_issues-result.xml | 6 +- ...ld_resolve_conflicts_on_updates-result.xml | 6 +- .../should_resolve_conflicts_on_updates.xml | 6 +- .../should_update_issues-result.xml | 6 +- .../IssueStorageTest/should_update_issues.xml | 6 +- .../multi-modules-with-issues.xml | 60 ++++++------ .../should_create_database_with_issues.xml | 12 ++- .../shouldDeleteResource.xml | 14 +-- ...resources_without_last_snapshot-result.xml | 87 ++++++++++------- ...isable_resources_without_last_snapshot.xml | 24 ++--- .../PurgeDaoTest/shouldDeleteProject.xml | 6 +- ...should_delete_all_closed_issues-result.xml | 56 ++++++----- .../should_delete_all_closed_issues.xml | 32 +++---- ...should_delete_old_closed_issues-result.xml | 28 +++--- .../should_delete_old_closed_issues.xml | 96 +++++++++++-------- .../api/issue/internal/DefaultIssue.java | 14 --- .../api/issue/internal/DefaultIssueTest.java | 2 - 80 files changed, 695 insertions(+), 664 deletions(-) create mode 100644 server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update-result.xml create mode 100644 server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update.xml create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/db/migrate/773_remove_issue_component_ids.rb diff --git a/server/sonar-server/src/main/java/org/sonar/core/computation/dbcleaner/ProjectCleaner.java b/server/sonar-server/src/main/java/org/sonar/core/computation/dbcleaner/ProjectCleaner.java index dbeb19e65ff..021f88ebdaf 100644 --- a/server/sonar-server/src/main/java/org/sonar/core/computation/dbcleaner/ProjectCleaner.java +++ b/server/sonar-server/src/main/java/org/sonar/core/computation/dbcleaner/ProjectCleaner.java @@ -34,7 +34,6 @@ import org.sonar.server.properties.ProjectSettingsFactory; import org.sonar.server.search.IndexClient; import javax.annotation.Nullable; - import java.util.Date; import static org.sonar.core.purge.PurgeConfiguration.newDefaultPurgeConfiguration; @@ -50,7 +49,7 @@ public class ProjectCleaner implements ServerComponent { private final IndexClient indexClient; public ProjectCleaner(PurgeDao purgeDao, DefaultPeriodCleaner periodCleaner, PurgeProfiler profiler, PurgeListener purgeListener, - ProjectSettingsFactory projectSettingsFactory, IndexClient indexClient) { + ProjectSettingsFactory projectSettingsFactory, IndexClient indexClient) { this.purgeDao = purgeDao; this.periodCleaner = periodCleaner; this.profiler = profiler; @@ -64,9 +63,9 @@ public class ProjectCleaner implements ServerComponent { profiler.reset(); Settings settings = projectSettingsFactory.newProjectSettings(session, idUuidPair.getId()); - PurgeConfiguration configuration = newDefaultPurgeConfiguration(settings, idUuidPair.getId()); + PurgeConfiguration configuration = newDefaultPurgeConfiguration(settings, idUuidPair); - cleanHistoricalData(session, configuration.rootProjectId(), settings); + cleanHistoricalData(session, configuration.rootProjectIdUuid().getId(), settings); doPurge(session, configuration); deleteIndexedIssuesBefore(idUuidPair.getUuid(), configuration.maxLiveDateOfClosedIssues()); @@ -105,7 +104,7 @@ public class ProjectCleaner implements ServerComponent { purgeDao.purge(session, configuration, purgeListener); } catch (Exception e) { // purge errors must no fail the report analysis - LOG.error("Fail to purge data [id=" + configuration.rootProjectId() + "]", e); + LOG.error("Fail to purge data [id=" + configuration.rootProjectIdUuid().getId() + "]", e); } } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportService.java b/server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportService.java index 9fa4fdcda50..29fc0933b16 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportService.java @@ -137,7 +137,6 @@ public class AnalysisReportService { private DefaultIssue setComponent(DefaultIssue issue, @Nullable ReportComponent component) { if (component != null) { - issue.setComponentId((long) component.id()); issue.setComponentUuid(component.uuid()); } return issue; diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java index ecfae85a8fc..8f56637cfa5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java @@ -70,11 +70,11 @@ public class PersistIssuesStep implements ComputationStep { boolean saved = false; if (issue.isNew()) { Integer ruleId = ruleCache.get(issue.ruleKey()).getId(); - mapper.insert(IssueDto.toDtoForComputationInsert(issue, issue.componentId(), context.getProject().getId(), ruleId, system2.now())); + mapper.insert(IssueDto.toDtoForComputationInsert(issue, ruleId, system2.now())); count++; saved = true; } else if (issue.isChanged()) { - IssueDto dto = IssueDto.toDtoForUpdate(issue, context.getProject().getId(), system2.now()); + IssueDto dto = IssueDto.toDtoForUpdate(issue, system2.now()); if (Issue.STATUS_CLOSED.equals(issue.status()) || issue.selectedAt() == null) { // Issue is closed by scan or changed by end-user mapper.update(dto); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ServerIssueStorage.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ServerIssueStorage.java index aed1124e1c4..ca7b48f31a2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ServerIssueStorage.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ServerIssueStorage.java @@ -56,7 +56,7 @@ public class ServerIssueStorage extends IssueStorage implements ServerComponent @Override protected void doUpdate(DbSession session, long now, DefaultIssue issue) { - IssueDto dto = IssueDto.toDtoForUpdate(issue, project(session, issue).getId(), now); + IssueDto dto = IssueDto.toDtoForUpdate(issue, now); dbClient.issueDao().update(session, dto); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java index 072639ef48f..7bb8c882c9d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueResultSetIterator.java @@ -80,8 +80,8 @@ class IssueResultSetIterator extends ResultSetIterator { private static final String SQL_ALL = "select " + StringUtils.join(FIELDS, ",") + " from issues i " + "inner join rules r on r.id=i.rule_id " + - "inner join projects p on p.id=i.component_id " + - "inner join projects root on root.id=i.root_component_id"; + "inner join projects p on p.uuid=i.component_uuid " + + "inner join projects root on root.uuid=i.project_uuid"; private static final String SQL_AFTER_DATE = SQL_ALL + " where i.updated_at>?"; diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ServerIssueStorageTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ServerIssueStorageTest.java index 7c8025960e6..f4a9f6372f4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ServerIssueStorageTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ServerIssueStorageTest.java @@ -124,7 +124,7 @@ public class ServerIssueStorageTest extends AbstractDaoTestCase { storage.save(issue); - checkTables("should_insert_new_issues", new String[]{"id", "created_at", "updated_at", "issue_change_creation_date"}, "issues", "issue_changes"); + checkTables("should_insert_new_issues", new String[] {"id", "created_at", "updated_at", "issue_change_creation_date"}, "issues", "issue_changes"); } @Test @@ -143,8 +143,9 @@ public class ServerIssueStorageTest extends AbstractDaoTestCase { .setNew(false) .setChanged(true) - // updated fields + // updated fields .setLine(5000) + .setProjectUuid("CDEF") .setDebt(Duration.create(10L)) .setChecksum("FFFFF") .setAuthorLogin("simon") @@ -160,14 +161,14 @@ public class ServerIssueStorageTest extends AbstractDaoTestCase { .setUpdateDate(date) .setCloseDate(date) - // unmodifiable fields + // unmodifiable fields .setRuleKey(RuleKey.of("xxx", "unknown")) .setComponentKey("struts:Action") .setProjectKey("struts"); storage.save(issue); - checkTables("should_update_issues", new String[]{"id", "created_at", "updated_at", "issue_change_creation_date"}, "issues", "issue_changes"); + checkTables("should_update_issues", new String[] {"id", "created_at", "updated_at", "issue_change_creation_date"}, "issues", "issue_changes"); } static class FakeRuleFinder implements RuleFinder { diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueDaoTest.java index 0a51301d34a..9717ea91993 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueDaoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueDaoTest.java @@ -62,8 +62,8 @@ public class IssueDaoTest extends AbstractDaoTestCase { IssueDto issue = sut.selectByKey(session, "ABCDE"); assertThat(issue.getKee()).isEqualTo("ABCDE"); assertThat(issue.getId()).isEqualTo(100L); - assertThat(issue.getComponentId()).isEqualTo(401); - assertThat(issue.getProjectId()).isEqualTo(399); + assertThat(issue.getComponentUuid()).isEqualTo("CDEF"); + assertThat(issue.getProjectUuid()).isEqualTo("ABCD"); assertThat(issue.getRuleId()).isEqualTo(500); assertThat(issue.getLanguage()).isEqualTo("java"); assertThat(issue.getSeverity()).isEqualTo("BLOCKER"); @@ -107,8 +107,8 @@ public class IssueDaoTest extends AbstractDaoTestCase { IssueDto issue = issues.get(0); assertThat(issue.getKee()).isEqualTo("ABCDE"); assertThat(issue.getActionPlanKey()).isEqualTo("AP-1"); - assertThat(issue.getComponentId()).isEqualTo(401); - assertThat(issue.getProjectId()).isEqualTo(399); + assertThat(issue.getComponentUuid()).isEqualTo("CDEF"); + assertThat(issue.getProjectUuid()).isEqualTo("ABCD"); assertThat(issue.getRuleId()).isEqualTo(500); assertThat(issue.getLanguage()).isEqualTo("java"); assertThat(issue.getSeverity()).isEqualTo("BLOCKER"); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/IssuesActionTest/return_only_manual_severity.xml b/server/sonar-server/src/test/resources/org/sonar/server/batch/IssuesActionTest/return_only_manual_severity.xml index 798a1eb398b..c6aae18497d 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/IssuesActionTest/return_only_manual_severity.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/IssuesActionTest/return_only_manual_severity.xml @@ -13,8 +13,8 @@ - - + - @@ -13,8 +16,8 @@ + /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/find_by_action_plan.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/find_by_action_plan.xml index b9421a4cb4c..6d676713435 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/find_by_action_plan.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/find_by_action_plan.xml @@ -3,8 +3,8 @@ + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update.xml new file mode 100644 index 00000000000..9c41f1922cc --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update.xml @@ -0,0 +1,28 @@ + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml index 791b02efb2b..fc04143b522 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml @@ -5,7 +5,8 @@ + uuid="THE_FILE" module_uuid="THE_PROJECT" module_uuid_path=".THE_PROJECT." + path="src/main/java/TheFile.java"/> + /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/extract_directory_path.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/extract_directory_path.xml index 47fc2609e1e..fc425638e3d 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/extract_directory_path.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/extract_directory_path.xml @@ -20,8 +20,8 @@ technical_debt="10" message="[null]" line="444" - component_id="100" - root_component_id="10" + component_uuid="FILE1" + project_uuid="PROJECT1" rule_id="200" reporter="[null]" issue_attributes="JIRA=http://jira.com" @@ -47,8 +47,8 @@ technical_debt="15" message="[null]" line="444" - component_id="101" - root_component_id="10" + component_uuid="ROOT_FILE1" + project_uuid="PROJECT1" rule_id="200" reporter="[null]" issue_attributes="JIRA=http://jira.com" @@ -74,8 +74,8 @@ technical_debt="15" message="[null]" line="444" - component_id="10" - root_component_id="10" + component_uuid="PROJECT1" + project_uuid="PROJECT1" rule_id="200" reporter="[null]" issue_attributes="JIRA=http://jira.com" diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/shared.xml index d6f9ba92098..e3e8b7c52f2 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueResultSetIteratorTest/shared.xml @@ -19,8 +19,8 @@ technical_debt="10" message="[null]" line="444" - component_id="100" - root_component_id="10" + component_uuid="FILE1" + project_uuid="PROJECT1" rule_id="200" reporter="[null]" issue_attributes="JIRA=http://jira.com" @@ -46,8 +46,8 @@ technical_debt="15" message="[null]" line="444" - component_id="100" - root_component_id="10" + component_uuid="FILE1" + project_uuid="PROJECT1" rule_id="200" reporter="[null]" issue_attributes="JIRA=http://jira.com" diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/773_remove_issue_component_ids.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/773_remove_issue_component_ids.rb new file mode 100644 index 00000000000..123c1556ced --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/773_remove_issue_component_ids.rb @@ -0,0 +1,34 @@ +# +# 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 +# +class RemoveIssueComponentIds < ActiveRecord::Migration + + def self.up + remove_index 'issues', :name => 'issues_component_id' + remove_index 'issues', :name => 'issues_root_component_id' + remove_column 'issues', 'component_id' + remove_column 'issues', 'root_component_id' + change_column 'issues', :component_uuid, :string, :limit => 50, :null => false + change_column 'issues', :project_uuid, :string, :limit => 50, :null => false + end +end diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java index 043507a6db4..975b313e3ab 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java @@ -47,12 +47,7 @@ import org.sonar.batch.scan.filesystem.InputPathCache; import org.sonar.batch.user.User; import org.sonar.batch.user.UserRepository; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; +import java.io.*; import java.util.ArrayList; import java.util.Collection; import java.util.Set; @@ -80,7 +75,7 @@ public class JSONReport implements Reporter { private final UserRepository userRepository; public JSONReport(Settings settings, FileSystem fileSystem, Server server, ActiveRules activeRules, IssueCache issueCache, - Project rootModule, InputPathCache fileCache, UserRepository userRepository) { + Project rootModule, InputPathCache fileCache, UserRepository userRepository) { this.settings = settings; this.fileSystem = fileSystem; this.server = server; diff --git a/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTask.java b/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTask.java index c9e317ec9df..cab746aa79b 100644 --- a/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTask.java +++ b/sonar-core/src/main/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTask.java @@ -72,11 +72,11 @@ public class DefaultPurgeTask implements PurgeTask { @Override public DefaultPurgeTask purge(long resourceId) { long start = System.currentTimeMillis(); - String resourceQualifier = resourceDao.getResource(resourceId).getQualifier(); - if (isNotViewNorSubview(resourceQualifier)) { + ResourceDto component = resourceDao.getResource(resourceId); + if (isNotViewNorSubview(component.getQualifier())) { profiler.reset(); cleanHistoricalData(resourceId); - doPurge(resourceId); + doPurge(new IdUuidPair(component.getId(), component.getUuid())); if (settings.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY)) { long duration = System.currentTimeMillis() - start; LOG.info("\n -------- Profiling for purge: " + TimeUtils.formatDuration(duration) + " --------\n"); @@ -96,16 +96,16 @@ public class DefaultPurgeTask implements PurgeTask { } } - private void doPurge(long resourceId) { + private void doPurge(IdUuidPair componentIdUuid) { try { - purgeDao.purge(newPurgeConfigurationOnResource(resourceId), PurgeListener.EMPTY); + purgeDao.purge(newPurgeConfigurationOnResource(componentIdUuid), PurgeListener.EMPTY); } catch (Exception e) { // purge errors must not fail the report analysis - LOG.error("Fail to purge data [id=" + resourceId + "]", e); + LOG.error("Fail to purge data [id=" + componentIdUuid + "]", e); } } - public PurgeConfiguration newPurgeConfigurationOnResource(long resourceId) { - return newDefaultPurgeConfiguration(settings, resourceId); + public PurgeConfiguration newPurgeConfigurationOnResource(IdUuidPair componentIdUuid) { + return newDefaultPurgeConfiguration(settings, componentIdUuid); } } diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java index 4b0b0db2ba6..d683a64cc11 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java @@ -37,7 +37,6 @@ import org.sonar.core.rule.RuleDto; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - import java.io.Serializable; import java.util.Collection; import java.util.Date; @@ -53,8 +52,8 @@ public final class IssueDto implements Serializable { private Long id; private String kee; - private Long componentId; - private Long projectId; + private String componentUuid; + private String projectUuid; private Integer ruleId; private String severity; private boolean manualSeverity; @@ -88,11 +87,9 @@ public final class IssueDto implements Serializable { private String ruleRepo; private String language; private String componentKey; - private String componentUuid; private String moduleUuid; private String moduleUuidPath; private String projectKey; - private String projectUuid; private String filePath; private String tags; @@ -118,12 +115,7 @@ public final class IssueDto implements Serializable { return this; } - public Long getComponentId() { - return componentId; - } - public IssueDto setComponent(ComponentDto component) { - this.componentId = component.getId(); this.componentKey = component.getKey(); this.componentUuid = component.uuid(); this.moduleUuid = component.moduleUuid(); @@ -132,33 +124,12 @@ public final class IssueDto implements Serializable { return this; } - /** - * please use setComponent(ComponentDto component) - */ - public IssueDto setComponentId(Long componentId) { - this.componentId = componentId; - return this; - } - - public Long getProjectId() { - return projectId; - } - public IssueDto setProject(ComponentDto project) { - this.projectId = project.getId(); this.projectKey = project.getKey(); this.projectUuid = project.uuid(); return this; } - /** - * please use setProject - */ - public IssueDto setProjectId(Long projectId) { - this.projectId = projectId; - return this; - } - public Integer getRuleId() { return ruleId; } @@ -433,7 +404,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setRule(org.sonar.core.rule.RuleDto)} instead */ public IssueDto setRuleKey(String repo, String rule) { @@ -444,7 +415,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setRule(org.sonar.core.rule.RuleDto)} instead */ public IssueDto setLanguage(String language) { @@ -454,7 +425,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setComponent(org.sonar.core.component.ComponentDto)} instead */ public IssueDto setComponentKey(String componentKey) { @@ -464,7 +435,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setComponent(org.sonar.core.component.ComponentDto)} instead */ public IssueDto setComponentUuid(@Nullable String componentUuid) { @@ -474,7 +445,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setComponent(org.sonar.core.component.ComponentDto)} instead */ public IssueDto setModuleUuid(@Nullable String moduleUuid) { @@ -484,7 +455,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setComponent(org.sonar.core.component.ComponentDto)} instead */ public IssueDto setModuleUuidPath(@Nullable String moduleUuidPath) { @@ -494,7 +465,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setProject(org.sonar.core.component.ComponentDto)} instead */ public IssueDto setProjectKey(String projectKey) { @@ -504,7 +475,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setProject(org.sonar.core.component.ComponentDto)} instead */ public IssueDto setProjectUuid(@Nullable String projectUuid) { @@ -514,7 +485,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setProject(org.sonar.core.component.ComponentDto)} instead */ public String getFilePath() { @@ -523,7 +494,7 @@ public final class IssueDto implements Serializable { /** * Should only be used to persist in E/S - * + *

* Please use {@link #setProject(org.sonar.core.component.ComponentDto)} instead */ public IssueDto setFilePath(String filePath) { @@ -561,7 +532,7 @@ public final class IssueDto implements Serializable { /** * On batch side, component keys and uuid are useless */ - public static IssueDto toDtoForComputationInsert(DefaultIssue issue, long componentId, long projectId, int ruleId, long now) { + public static IssueDto toDtoForComputationInsert(DefaultIssue issue, int ruleId, long now) { return new IssueDto() .setKee(issue.key()) .setLine(issue.line()) @@ -579,13 +550,11 @@ public final class IssueDto implements Serializable { .setRuleKey(issue.ruleKey().repository(), issue.ruleKey().rule()) .setTags(issue.tags()) .setComponentUuid(issue.componentUuid()) - .setComponentId(componentId) .setComponentKey(issue.componentKey()) .setModuleUuid(issue.moduleUuid()) .setModuleUuidPath(issue.moduleUuidPath()) .setComponentUuid(issue.componentUuid()) .setProjectUuid(issue.projectUuid()) - .setProjectId(projectId) .setProjectKey(issue.projectKey()) .setActionPlanKey(issue.actionPlanKey()) .setIssueAttributes(KeyValueFormat.format(issue.attributes())) @@ -604,12 +573,12 @@ public final class IssueDto implements Serializable { * On server side, we need component keys and uuid */ public static IssueDto toDtoForServerInsert(DefaultIssue issue, ComponentDto component, ComponentDto project, int ruleId, long now) { - return toDtoForComputationInsert(issue, component.getId(), project.getId(), ruleId, now) + return toDtoForComputationInsert(issue, ruleId, now) .setComponent(component) .setProject(project); } - public static IssueDto toDtoForUpdate(DefaultIssue issue, Long rootComponentId, long now) { + public static IssueDto toDtoForUpdate(DefaultIssue issue, long now) { // Invariant fields, like key and rule, can't be updated return new IssueDto() .setKee(issue.key()) @@ -635,13 +604,12 @@ public final class IssueDto implements Serializable { .setModuleUuidPath(issue.moduleUuidPath()) .setProjectUuid(issue.projectUuid()) .setProjectKey(issue.projectKey()) - .setProjectId(rootComponentId) .setIssueCreationDate(issue.creationDate()) .setIssueCloseDate(issue.closeDate()) .setIssueUpdateDate(issue.updateDate()) .setSelectedAt(issue.selectedAt()) - // technical date + // technical date .setUpdatedAt(now); } @@ -659,7 +627,6 @@ public final class IssueDto implements Serializable { issue.setAssignee(assignee); issue.setAttributes(KeyValueFormat.parse(Objects.firstNonNull(issueAttributes, ""))); issue.setComponentKey(componentKey); - issue.setComponentId(componentId); issue.setComponentUuid(componentUuid); issue.setModuleUuid(moduleUuid); issue.setModuleUuidPath(moduleUuidPath); @@ -681,7 +648,7 @@ public final class IssueDto implements Serializable { public static IssueDto createFor(Project project, RuleDto rule) { return new IssueDto() - .setProjectId(Long.valueOf(project.getId())) + .setProjectUuid(project.getUuid()) .setRuleId(rule.getId()) .setKee(Uuids.create()); } diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/UpdateConflictResolver.java b/sonar-core/src/main/java/org/sonar/core/issue/db/UpdateConflictResolver.java index 6ce04317fb0..5c4457e3637 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/UpdateConflictResolver.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/UpdateConflictResolver.java @@ -38,7 +38,7 @@ public class UpdateConflictResolver { IssueDto dbIssue = mapper.selectByKey(issue.key()); if (dbIssue != null) { mergeFields(dbIssue, issue); - mapper.update(IssueDto.toDtoForUpdate(issue, dbIssue.getProjectId(), System.currentTimeMillis())); + mapper.update(IssueDto.toDtoForUpdate(issue, System.currentTimeMillis())); } } diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index f51fae850ba..fbb2b1be49f 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -33,7 +33,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 772; + public static final int LAST_VERSION = 773; /** * List of all the tables.n diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/PreviewDatabaseFactory.java b/sonar-core/src/main/java/org/sonar/core/persistence/PreviewDatabaseFactory.java index 8b1cbf45992..e9996cf7201 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/PreviewDatabaseFactory.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/PreviewDatabaseFactory.java @@ -34,10 +34,10 @@ import java.io.File; import java.sql.SQLException; public class PreviewDatabaseFactory implements ServerComponent { + public static final String H2_FILE_SUFFIX = ".h2.db"; private static final String DIALECT = "h2"; private static final String DRIVER = "org.h2.Driver"; private static final String URL = "jdbc:h2:"; - public static final String H2_FILE_SUFFIX = ".h2.db"; private static final String SONAR = "sonar"; private static final String USER = SONAR; private static final String PASSWORD = SONAR; @@ -111,7 +111,7 @@ public class PreviewDatabaseFactory implements ServerComponent { .append(" INNER JOIN (") .append(projectQuery(projectId, true)) .append(") resources") - .append(" ON issues.component_id=resources.id") + .append(" ON issues.component_uuid=resources.uuid") .append(" AND status <> '").append(Issue.STATUS_CLOSED).append("'"); template.copyTable(source, dest, "issues", issueQuery.toString()); } @@ -119,12 +119,12 @@ public class PreviewDatabaseFactory implements ServerComponent { private String projectQuery(Long projectId, boolean returnOnlyIds) { return new StringBuilder() - .append("SELECT p.").append(returnOnlyIds ? "id" : "*") + .append("SELECT p.").append(returnOnlyIds ? "id, p.uuid" : "*") .append(" FROM projects p INNER JOIN snapshots s ON p.id = s.project_id") .append(" WHERE s.islast=").append(database.getDialect().getTrueSqlValue()) .append(" AND s.root_project_id=").append(projectId) .append(" UNION") - .append(" SELECT p.").append(returnOnlyIds ? "id" : "*") + .append(" SELECT p.").append(returnOnlyIds ? "id, p.uuid" : "*") .append(" FROM projects p") .append(" WHERE p.id=").append(projectId) .append(" OR p.root_id=").append(projectId).toString(); diff --git a/sonar-core/src/main/java/org/sonar/core/purge/IdUuidPairs.java b/sonar-core/src/main/java/org/sonar/core/purge/IdUuidPairs.java index 1ad2939d073..856072a2483 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/IdUuidPairs.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/IdUuidPairs.java @@ -20,6 +20,7 @@ package org.sonar.core.purge; +import com.google.common.base.Function; import com.google.common.collect.Lists; import java.util.List; @@ -29,22 +30,20 @@ public class IdUuidPairs { } public static List ids(List pairs) { - List ids = Lists.newArrayList(); - - for (IdUuidPair idUuidPair : pairs) { - ids.add(idUuidPair.getId()); - } - - return ids; + return Lists.transform(pairs, new Function() { + @Override + public Long apply(IdUuidPair pair) { + return pair.getId(); + } + }); } - public static List uuids(List idUuidPairList) { - List uuids = Lists.newArrayList(); - - for (IdUuidPair idUuidPair : idUuidPairList) { - uuids.add(idUuidPair.getUuid()); - } - - return uuids; + public static List uuids(List pairs) { + return Lists.transform(pairs, new Function() { + @Override + public String apply(IdUuidPair pair) { + return pair.getUuid(); + } + }); } } diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java index 546cf8c3d33..687788e415d 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java @@ -49,104 +49,105 @@ class PurgeCommands { return purgeMapper.selectSnapshotIds(query); } - void deleteResources(List resourceIds) { - List> resourceIdsPartition = Lists.partition(resourceIds, MAX_RESOURCES_PER_QUERY); + void deleteResources(List componentIdUuids) { + List> componentIdPartitions = Lists.partition(IdUuidPairs.ids(componentIdUuids), MAX_RESOURCES_PER_QUERY); + List> componentUuidsPartitions = Lists.partition(IdUuidPairs.uuids(componentIdUuids), MAX_RESOURCES_PER_QUERY); // Note : do not merge the delete statements into a single loop of resource ids. It's // voluntarily grouped by tables in order to benefit from JDBC batch mode. // Batch requests can only relate to the same PreparedStatement. - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { deleteSnapshots(purgeMapper.selectSnapshotIdsByResource(partResourceIds)); } // possible missing optimization: filter requests according to resource scope profiler.start("deleteResourceLinks (project_links)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResourceLinks(partResourceIds); } session.commit(); profiler.stop(); profiler.start("deleteResourceProperties (properties)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResourceProperties(partResourceIds); } session.commit(); profiler.stop(); profiler.start("deleteResourceIndex (resource_index)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResourceIndex(partResourceIds); } session.commit(); profiler.stop(); profiler.start("deleteResourceGroupRoles (group_roles)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResourceGroupRoles(partResourceIds); } session.commit(); profiler.stop(); profiler.start("deleteResourceUserRoles (user_roles)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResourceUserRoles(partResourceIds); } session.commit(); profiler.stop(); profiler.start("deleteResourceManualMeasures (manual_measures)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResourceManualMeasures(partResourceIds); } session.commit(); profiler.stop(); - profiler.start("deleteResourceIssueChanges (issue_changes)"); - for (List partResourceIds : resourceIdsPartition) { - purgeMapper.deleteResourceIssueChanges(partResourceIds); + profiler.start("deleteComponentIssueChanges (issue_changes)"); + for (List componentUuidPartition : componentUuidsPartitions) { + purgeMapper.deleteComponentIssueChanges(componentUuidPartition); } session.commit(); profiler.stop(); - profiler.start("deleteResourceIssues (issues)"); - for (List partResourceIds : resourceIdsPartition) { - purgeMapper.deleteResourceIssues(partResourceIds); + profiler.start("deleteComponentIssues (issues)"); + for (List componentUuidPartition : componentUuidsPartitions) { + purgeMapper.deleteComponentIssues(componentUuidPartition); } session.commit(); profiler.stop(); profiler.start("deleteResourceActionPlans (action_plans)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResourceActionPlans(partResourceIds); } session.commit(); profiler.stop(); profiler.start("deleteResourceEvents (events)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResourceEvents(partResourceIds); } session.commit(); profiler.stop(); profiler.start("deleteResourceGraphs (graphs)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResourceGraphs(partResourceIds); } session.commit(); profiler.stop(); profiler.start("deleteResource (projects)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteResource(partResourceIds); } session.commit(); profiler.stop(); profiler.start("deleteAuthors (authors)"); - for (List partResourceIds : resourceIdsPartition) { + for (List partResourceIds : componentIdPartitions) { purgeMapper.deleteAuthors(partResourceIds); } session.commit(); diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeConfiguration.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeConfiguration.java index 772d3670c88..ba0248ff139 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeConfiguration.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeConfiguration.java @@ -27,38 +27,37 @@ import org.sonar.api.utils.System2; import org.sonar.core.computation.dbcleaner.DbCleanerConstants; import javax.annotation.CheckForNull; - import java.util.Date; public class PurgeConfiguration { - private final long rootProjectId; + private final IdUuidPair rootProjectIdUuid; private final String[] scopesWithoutHistoricalData; private final int maxAgeInDaysOfClosedIssues; private final System2 system2; - public PurgeConfiguration(long rootProjectId, String[] scopesWithoutHistoricalData, int maxAgeInDaysOfClosedIssues) { + public PurgeConfiguration(IdUuidPair rootProjectId, String[] scopesWithoutHistoricalData, int maxAgeInDaysOfClosedIssues) { this(rootProjectId, scopesWithoutHistoricalData, maxAgeInDaysOfClosedIssues, System2.INSTANCE); } @VisibleForTesting - PurgeConfiguration(long rootProjectId, String[] scopesWithoutHistoricalData, int maxAgeInDaysOfClosedIssues, System2 system2) { - this.rootProjectId = rootProjectId; + PurgeConfiguration(IdUuidPair rootProjectId, String[] scopesWithoutHistoricalData, int maxAgeInDaysOfClosedIssues, System2 system2) { + this.rootProjectIdUuid = rootProjectId; this.scopesWithoutHistoricalData = scopesWithoutHistoricalData; this.maxAgeInDaysOfClosedIssues = maxAgeInDaysOfClosedIssues; this.system2 = system2; } - public static PurgeConfiguration newDefaultPurgeConfiguration(Settings settings, long resourceId) { - String[] scopes = new String[] {Scopes.FILE}; + public static PurgeConfiguration newDefaultPurgeConfiguration(Settings settings, IdUuidPair idUuidPair) { + String[] scopes = new String[]{Scopes.FILE}; if (settings.getBoolean(DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY)) { - scopes = new String[] {Scopes.DIRECTORY, Scopes.FILE}; + scopes = new String[]{Scopes.DIRECTORY, Scopes.FILE}; } - return new PurgeConfiguration(resourceId, scopes, settings.getInt(DbCleanerConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES)); + return new PurgeConfiguration(idUuidPair, scopes, settings.getInt(DbCleanerConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES)); } - public long rootProjectId() { - return rootProjectId; + public IdUuidPair rootProjectIdUuid() { + return rootProjectIdUuid; } public String[] scopesWithoutHistoricalData() { diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java index 2e9b914d605..65685305942 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java @@ -68,7 +68,7 @@ public class PurgeDao { public void purge(DbSession session, PurgeConfiguration conf, PurgeListener purgeListener) { PurgeMapper mapper = session.getMapper(PurgeMapper.class); PurgeCommands commands = new PurgeCommands(session, mapper, profiler); - List projects = getProjects(conf.rootProjectId(), session); + List projects = getProjects(conf.rootProjectIdUuid().getId(), session); for (ResourceDto project : projects) { LOG.info("-> Clean " + project.getLongName() + " [id=" + project.getId() + "]"); deleteAbortedBuilds(project, commands); @@ -82,8 +82,8 @@ public class PurgeDao { private void deleteOldClosedIssues(PurgeConfiguration conf, PurgeMapper mapper) { Date toDate = conf.maxLiveDateOfClosedIssues(); - mapper.deleteOldClosedIssueChanges(conf.rootProjectId(), toDate); - mapper.deleteOldClosedIssues(conf.rootProjectId(), toDate); + mapper.deleteOldClosedIssueChanges(conf.rootProjectIdUuid().getUuid(), toDate); + mapper.deleteOldClosedIssues(conf.rootProjectIdUuid().getUuid(), toDate); } private void deleteAbortedBuilds(ResourceDto project, PurgeCommands commands) { @@ -91,7 +91,7 @@ public class PurgeDao { LOG.info("<- Delete aborted builds"); PurgeSnapshotQuery query = PurgeSnapshotQuery.create() .setIslast(false) - .setStatus(new String[] {"U"}) + .setStatus(new String[]{"U"}) .setRootProjectId(project.getId()); commands.deleteSnapshots(query); } @@ -100,7 +100,7 @@ public class PurgeDao { private boolean hasAbortedBuilds(Long projectId, PurgeCommands commands) { PurgeSnapshotQuery query = PurgeSnapshotQuery.create() .setIslast(false) - .setStatus(new String[] {"U"}) + .setStatus(new String[]{"U"}) .setResourceId(projectId); return !commands.selectSnapshotIds(query).isEmpty(); } @@ -111,7 +111,7 @@ public class PurgeDao { .setResourceId(project.getId()) .setIslast(false) .setNotPurged(true) - ); + ); for (final Long projectSnapshotId : projectSnapshotIds) { LOG.info("<- Clean snapshot " + projectSnapshotId); if (!ArrayUtils.isEmpty(scopesWithoutHistoricalData)) { @@ -131,13 +131,13 @@ public class PurgeDao { } private void disableOrphanResources(final ResourceDto project, final SqlSession session, final PurgeMapper purgeMapper, final PurgeListener purgeListener) { - session.select("org.sonar.core.purge.PurgeMapper.selectResourceIdsToDisable", project.getId(), new ResultHandler() { + session.select("org.sonar.core.purge.PurgeMapper.selectComponentIdUuidsToDisable", project.getId(), new ResultHandler() { @Override public void handleResult(ResultContext resultContext) { - IdUuidPair resourceIdUuid = (IdUuidPair) resultContext.getResultObject(); - if (resourceIdUuid.getId() != null) { - disableResource(resourceIdUuid, purgeMapper); - purgeListener.onComponentDisabling(resourceIdUuid.getUuid()); + IdUuidPair componentIdUuid = (IdUuidPair) resultContext.getResultObject(); + if (componentIdUuid.getId() != null) { + disableResource(componentIdUuid, purgeMapper); + purgeListener.onComponentDisabling(componentIdUuid.getUuid()); } } }); @@ -167,7 +167,7 @@ public class PurgeDao { final DbSession session = mybatis.openSession(true); final PurgeMapper mapper = session.getMapper(PurgeMapper.class); try { - deleteProject(rootIdUuid.getId(), mapper, new PurgeCommands(session, profiler)); + deleteProject(rootIdUuid, mapper, new PurgeCommands(session, profiler)); deleteFileSources(rootIdUuid.getUuid(), new PurgeCommands(session, profiler)); return this; } finally { @@ -179,23 +179,23 @@ public class PurgeDao { commands.deleteFileSources(rootUuid); } - private void deleteProject(long rootProjectId, PurgeMapper mapper, PurgeCommands commands) { - List childrenIds = mapper.selectProjectIdsByRootId(rootProjectId); - for (Long childId : childrenIds) { + private void deleteProject(IdUuidPair rootProjectId, PurgeMapper mapper, PurgeCommands commands) { + List childrenIdUuid = mapper.selectProjectIdUuidsByRootId(rootProjectId.getId()); + for (IdUuidPair childId : childrenIdUuid) { deleteProject(childId, mapper, commands); } - List resourceIds = mapper.selectResourceIdsByRootId(rootProjectId); - commands.deleteResources(resourceIds); + List componentIdUuids = mapper.selectComponentIdUuidsByRootId(rootProjectId.getId()); + commands.deleteResources(componentIdUuids); } - private void disableResource(IdUuidPair resourceIdUuid, PurgeMapper mapper) { - long resourceId = resourceIdUuid.getId(); - mapper.deleteResourceIndex(Arrays.asList(resourceId)); - mapper.setSnapshotIsLastToFalse(resourceId); - mapper.deleteFileSourcesByUuid(resourceIdUuid.getUuid()); - mapper.disableResource(resourceId); - mapper.resolveResourceIssuesNotAlreadyResolved(resourceId, new Date(system2.now()), system2.now()); + private void disableResource(IdUuidPair componentIdUuid, PurgeMapper mapper) { + long componentId = componentIdUuid.getId(); + mapper.deleteResourceIndex(Arrays.asList(componentId)); + mapper.setSnapshotIsLastToFalse(componentId); + mapper.deleteFileSourcesByUuid(componentIdUuid.getUuid()); + mapper.disableResource(componentId); + mapper.resolveResourceIssuesNotAlreadyResolved(componentIdUuid.getUuid(), new Date(system2.now()), system2.now()); } public PurgeDao deleteSnapshots(PurgeSnapshotQuery query) { diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java index 54cffca45c3..c73cc86dd82 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java @@ -22,7 +22,6 @@ package org.sonar.core.purge; import org.apache.ibatis.annotations.Param; import javax.annotation.Nullable; - import java.util.Date; import java.util.List; @@ -32,7 +31,9 @@ public interface PurgeMapper { List selectSnapshotIdsByResource(@Param("resourceIds") List resourceIds); - List selectProjectIdsByRootId(long rootResourceId); + List selectProjectIdUuidsByRootId(long rootResourceId); + + List selectComponentIdUuidsByRootId(long rootProjectId); void deleteSnapshot(@Param("snapshotIds") List snapshotIds); @@ -58,7 +59,7 @@ public interface PurgeMapper { void disableResource(long resourceId); - void resolveResourceIssuesNotAlreadyResolved(@Param("resourceId") long resourceId, @Param("date") Date date, @Param("dateAsLong") Long dateAsLong); + void resolveResourceIssuesNotAlreadyResolved(@Param("componentUuid") String componentUuid, @Param("date") Date date, @Param("dateAsLong") Long dateAsLong); void deleteResourceIndex(@Param("resourceIds") List resourceIds); @@ -90,15 +91,13 @@ public interface PurgeMapper { List selectPurgeableSnapshotsWithoutEvents(long resourceId); - List selectResourceIdsByRootId(long rootProjectId); - - void deleteResourceIssueChanges(@Param("resourceIds") List resourceIds); + void deleteComponentIssueChanges(@Param("componentUuids") List componentUuids); - void deleteResourceIssues(@Param("resourceIds") List resourceIds); + void deleteComponentIssues(@Param("componentUuids") List componentUuids); - void deleteOldClosedIssueChanges(@Param("rootProjectId") long rootProjectId, @Nullable @Param("toDate") Date toDate); + void deleteOldClosedIssueChanges(@Param("projectUuid") String projectUuid, @Nullable @Param("toDate") Date toDate); - void deleteOldClosedIssues(@Param("rootProjectId") long rootProjectId, @Nullable @Param("toDate") Date toDate); + void deleteOldClosedIssues(@Param("projectUuid") String projectUuid, @Nullable @Param("toDate") Date toDate); void deleteFileSourcesByProjectUuid(String rootProjectUuid); diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueChangeMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueChangeMapper.xml index c1cfc09fb36..47d0bc96d71 100644 --- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueChangeMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueChangeMapper.xml @@ -48,8 +48,8 @@ from issue_changes c inner join issues i on i.kee = c.issue_key - inner join (select p.id,p.kee from projects p where (p.root_id=#{componentId} and p.qualifier <> 'BRC') or - (p.id=#{componentId})) p on p.id=i.component_id + inner join (select p.id, p.uuid, p.kee from projects p where (p.root_id=#{componentId} and p.qualifier <> 'BRC') or + (p.id=#{componentId})) p on p.uuid=i.component_uuid and c.change_type=#{changeType} and i.status <> 'CLOSED' diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml index 5ea815e5c94..8217084291c 100644 --- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml @@ -7,8 +7,6 @@ i.id, i.kee as kee, - i.component_id as componentId, - i.root_component_id as projectId, i.rule_id as ruleId, i.action_plan_key as actionPlanKey, i.severity as severity, @@ -34,12 +32,12 @@ r.plugin_name as ruleRepo, r.language as language, p.kee as componentKey, - p.uuid as componentUuid, + i.component_uuid as componentUuid, p.module_uuid as moduleUuid, p.module_uuid_path as moduleUuidPath, p.path as filePath, root.kee as projectKey, - root.uuid as projectUuid + i.project_uuid as projectUuid @@ -68,12 +66,12 @@ - INSERT INTO issues (kee, component_id, root_component_id, rule_id, action_plan_key, severity, manual_severity, + INSERT INTO issues (kee, rule_id, action_plan_key, severity, manual_severity, message, line, effort_to_fix, technical_debt, status, tags, resolution, checksum, reporter, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date, issue_close_date, created_at, updated_at, component_uuid, project_uuid) - VALUES (#{kee,jdbcType=VARCHAR}, #{componentId,jdbcType=BIGINT}, #{projectId,jdbcType=BIGINT}, - #{ruleId,jdbcType=INTEGER}, #{actionPlanKey,jdbcType=VARCHAR}, #{severity,jdbcType=VARCHAR}, + VALUES (#{kee,jdbcType=VARCHAR}, #{ruleId,jdbcType=INTEGER}, #{actionPlanKey,jdbcType=VARCHAR}, + #{severity,jdbcType=VARCHAR}, #{manualSeverity,jdbcType=BOOLEAN}, #{message,jdbcType=VARCHAR}, #{line,jdbcType=INTEGER}, #{effortToFix,jdbcType=DOUBLE}, #{debt,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR}, #{tagsString,jdbcType=VARCHAR}, #{resolution,jdbcType=VARCHAR}, #{checksum,jdbcType=VARCHAR}, @@ -103,7 +101,6 @@ assignee=#{assignee}, author_login=#{authorLogin}, tags=#{tagsString}, - root_component_id=#{projectId}, project_uuid=#{projectUuid}, issue_attributes=#{issueAttributes}, issue_creation_date=#{issueCreationDate}, @@ -132,7 +129,6 @@ assignee=#{assignee}, author_login=#{authorLogin}, tags=#{tagsString}, - root_component_id=#{projectId}, project_uuid=#{projectUuid}, issue_attributes=#{issueAttributes}, issue_creation_date=#{issueCreationDate}, @@ -147,8 +143,8 @@ from issues i inner join rules r on r.id=i.rule_id - inner join projects p on p.id=i.component_id - inner join projects root on root.id=i.root_component_id + inner join projects p on p.uuid=i.component_uuid + inner join projects root on root.uuid=i.project_uuid where i.kee=#{kee} @@ -156,8 +152,6 @@ select i.id, i.kee as kee, - i.component_id as componentId, - i.root_component_id as projectId, i.rule_id as ruleId, i.component_uuid as componentUuid, i.project_uuid as projectUuid, @@ -186,10 +180,10 @@ p.kee as componentKey, root.kee as projectKey from issues i - inner join (select p.id,p.kee from projects p where (p.root_id=#{id} and p.qualifier <> 'BRC') or - (p.id=#{id})) p on p.id=i.component_id + inner join (select p.id, p.uuid,p.kee from projects p where (p.root_id=#{id} and p.qualifier <> 'BRC') or + (p.id=#{id})) p on p.uuid=i.component_uuid inner join rules r on r.id=i.rule_id - left outer join projects root on root.id=i.root_component_id + left outer join projects root on root.uuid=i.project_uuid where i.status <> 'CLOSED' @@ -209,8 +203,8 @@ r.plugin_name as ruleRepo, component.kee as componentKey FROM issues i - INNER JOIN (SELECT p.id,p.kee FROM projects p WHERE p.module_uuid=#{uuid} OR p.uuid=#{uuid}) component ON - component.id=i.component_id + INNER JOIN (SELECT p.id,p.uuid, p.kee FROM projects p WHERE p.module_uuid=#{uuid} OR p.uuid=#{uuid}) component ON + component.uuid=i.component_uuid INNER JOIN rules r ON r.id=i.rule_id WHERE i.status <> 'CLOSED' @@ -231,10 +225,9 @@ r.plugin_name as ruleRepo, component.kee as componentKey FROM issues i - INNER JOIN projects component on component.id=i.component_id - INNER JOIN projects project on project.uuid=component.project_uuid AND project.uuid=#{uuid} + INNER JOIN projects component on component.uuid=i.component_uuid INNER JOIN rules r ON r.id=i.rule_id - WHERE i.status <> 'CLOSED' + WHERE i.status <> 'CLOSED' AND i.project_uuid=#{uuid} SELECT i.severity FROM issues i - INNER JOIN projects on projects.id=i.component_id + INNER JOIN projects on projects.uuid=i.component_uuid INNER JOIN rules on rules.id=i.rule_id WHERE projects.kee=#{componentKey} diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index 206704d1de6..5fa95735f7c 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -301,6 +301,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('769'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('770'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('771'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('772'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('773'); 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; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl index 5e1b3a7521a..d30b14e1a78 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl @@ -442,10 +442,8 @@ CREATE TABLE "GRAPHS" ( CREATE TABLE "ISSUES" ( "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "KEE" VARCHAR(50) UNIQUE NOT NULL, - "COMPONENT_ID" INTEGER NOT NULL, - "COMPONENT_UUID" VARCHAR(50), - "ROOT_COMPONENT_ID" INTEGER, - "PROJECT_UUID" VARCHAR(50), + "COMPONENT_UUID" VARCHAR(50) NOT NULL, + "PROJECT_UUID" VARCHAR(50) NOT NULL, "RULE_ID" INTEGER, "SEVERITY" VARCHAR(10), "MANUAL_SEVERITY" BOOLEAN NOT NULL, @@ -660,12 +658,8 @@ CREATE UNIQUE INDEX "GRAPHS_PERSPECTIVES" ON "GRAPHS" ("SNAPSHOT_ID", "PERSPECTI CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE"); -CREATE INDEX "ISSUES_COMPONENT_ID" ON "ISSUES" ("COMPONENT_ID"); - CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID"); -CREATE INDEX "ISSUES_ROOT_COMPONENT_ID" ON "ISSUES" ("ROOT_COMPONENT_ID"); - CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES" ("PROJECT_UUID"); CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID"); diff --git a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml index c3464bee196..2bd8f7e9aae 100644 --- a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml @@ -72,7 +72,7 @@ not exists(select e.id from events e where e.snapshot_id=s.id) - select p.id, p.uuid from projects p where (p.id=#{id} or p.root_id=#{id}) and p.enabled=${_true} and not exists(select s.project_id from snapshots s where s.islast=${_true} and s.project_id=p.id) @@ -88,12 +88,12 @@ select id from metrics where delete_historical_data=${_true} - + select id, uuid from projects where root_id=#{id} and scope='PRJ' - + select id, uuid from projects where root_id=#{id} or id=#{id} @@ -179,7 +179,7 @@ UPDATE issues SET status='CLOSED',resolution='REMOVED',updated_at=#{dateAsLong},issue_close_date=#{date}, issue_update_date=#{date} - WHERE component_id=#{resourceId} AND resolution IS NULL + WHERE component_uuid=#{componentUuid} AND resolution IS NULL @@ -270,37 +270,37 @@ update snapshots set islast=${_false} where project_id=#{id} - + delete from issue_changes ic - where exists (select * from issues i where i.kee=ic.issue_key and i.component_id in - - #{resourceId} + where exists (select * from issues i where i.kee=ic.issue_key and i.component_uuid in + + #{componentUuid} ) - + delete issue_changes from issue_changes inner join issues on issue_changes.issue_key=issues.kee - where issues.component_id in - - #{resourceId} + where issues.component_uuid in + + #{componentUuid} - - delete ic from issue_changes as ic, issues as i where ic.issue_key=i.kee and i.component_id in - - #{resourceId} + + delete ic from issue_changes as ic, issues as i where ic.issue_key=i.kee and i.component_uuid in + + #{componentUuid} - - delete from issues where component_id in - - #{resourceId} + + delete from issues where component_uuid in + + #{componentUuid} @@ -316,7 +316,7 @@ delete from issue_changes ic where exists ( select * from issues i - where i.root_component_id=#{rootProjectId} and i.kee=ic.issue_key + where i.project_uuid=#{projectUuid} and i.kee=ic.issue_key and i.issue_close_date is not null @@ -332,7 +332,7 @@ delete issue_changes from issue_changes inner join issues on issue_changes.issue_key=issues.kee - where issues.root_component_id=#{rootProjectId} + where issues.project_uuid=#{projectUuid} and issues.issue_close_date is not null @@ -347,7 +347,7 @@ delete ic from issue_changes as ic, issues as i - where i.root_component_id=#{rootProjectId} + where i.project_uuid=#{projectUuid} and ic.issue_key=i.kee @@ -361,7 +361,7 @@ delete from issues - where root_component_id=#{rootProjectId} + where project_uuid=#{projectUuid} and issue_close_date is not null diff --git a/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTaskTest.java b/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTaskTest.java index 1742a7e3729..a65dda0382d 100644 --- a/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTaskTest.java +++ b/sonar-core/src/test/java/org/sonar/core/computation/dbcleaner/DefaultPurgeTaskTest.java @@ -29,8 +29,8 @@ import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.Settings; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Scopes; -import org.sonar.core.purge.*; import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner; +import org.sonar.core.purge.*; import org.sonar.core.resource.ResourceDao; import org.sonar.core.resource.ResourceDto; @@ -53,7 +53,7 @@ public class DefaultPurgeTaskTest { public void before() throws Exception { this.purgeDao = mock(PurgeDao.class); this.resourceDao = mock(ResourceDao.class); - when(resourceDao.getResource(anyLong())).thenReturn(new ResourceDto().setQualifier(Qualifiers.PROJECT)); + when(resourceDao.getResource(anyLong())).thenReturn(new ResourceDto().setQualifier(Qualifiers.PROJECT).setUuid("1").setId(1L)); this.settings = mock(Settings.class); this.periodCleaner = mock(DefaultPeriodCleaner.class); @@ -75,7 +75,7 @@ public class DefaultPurgeTaskTest { @Override public boolean matches(Object o) { PurgeConfiguration conf = (PurgeConfiguration) o; - return conf.rootProjectId() == 1L && conf.scopesWithoutHistoricalData().length == 1 && conf.scopesWithoutHistoricalData()[0].equals(Scopes.FILE); + return conf.rootProjectIdUuid().getId() == 1L && conf.scopesWithoutHistoricalData().length == 1 && conf.scopesWithoutHistoricalData()[0].equals(Scopes.FILE); } }), any(PurgeListener.class)); } @@ -92,7 +92,7 @@ public class DefaultPurgeTaskTest { @Override public boolean matches(Object o) { PurgeConfiguration conf = (PurgeConfiguration) o; - return conf.rootProjectId() == 1L && + return conf.rootProjectIdUuid().getId() == 1L && conf.scopesWithoutHistoricalData().length == 2 && conf.scopesWithoutHistoricalData()[0].equals(Scopes.DIRECTORY) && conf.scopesWithoutHistoricalData()[1].equals(Scopes.FILE); @@ -103,7 +103,7 @@ public class DefaultPurgeTaskTest { @Test public void shouldNotFailOnErrors() { PurgeDao purgeDao = mock(PurgeDao.class); - when(purgeDao.purge(any(PurgeConfiguration.class),any(PurgeListener.class))).thenThrow(new RuntimeException()); + when(purgeDao.purge(any(PurgeConfiguration.class), any(PurgeListener.class))).thenThrow(new RuntimeException()); DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, resourceDao, new Settings(), mock(DefaultPeriodCleaner.class), mock(PurgeProfiler.class)); task.purge(1L); @@ -113,7 +113,7 @@ public class DefaultPurgeTaskTest { @Test public void shouldDumpProfiling() { - PurgeConfiguration conf = new PurgeConfiguration(1L, new String[0], 30); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30); PurgeDao purgeDao = mock(PurgeDao.class); when(purgeDao.purge(conf, PurgeListener.EMPTY)).thenThrow(new RuntimeException()); Settings settings = new Settings(new PropertyDefinitions(DataCleanerProperties.all())); diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java index 70a3765d66c..785b52b7e67 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java @@ -77,12 +77,10 @@ public class IssueDaoTest extends AbstractDaoTestCase { assertThat(issue.getRule()).isEqualTo("AvoidCycle"); assertThat(issue.getComponentUuid()).isEqualTo("CDEF"); assertThat(issue.getComponentKey()).isEqualTo("Action.java"); - assertThat(issue.getComponentId()).isEqualTo(401); assertThat(issue.getModuleUuid()).isEqualTo("BCDE"); assertThat(issue.getModuleUuidPath()).isEqualTo(".ABCD.BCDE."); assertThat(issue.getProjectKey()).isEqualTo("struts"); // ABCD assertThat(issue.getProjectUuid()).isEqualTo("ABCD"); // null - assertThat(issue.getProjectId()).isEqualTo(399); } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java index aee61d1fc0f..edac8a2dd84 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java @@ -64,12 +64,10 @@ public class IssueDtoTest { .setLanguage("xoo") .setComponentKey("org.sonar.sample:Sample") .setComponentUuid("CDEF") + .setProjectUuid("GHIJ") .setModuleUuid("BCDE") .setModuleUuidPath("ABCD.BCDE.") - .setProjectUuid("ABCD") .setProjectKey("org.sonar.sample") - .setComponentId(1l) - .setProjectId(1l) .setStatus(Issue.STATUS_CLOSED) .setResolution(Issue.RESOLUTION_FALSE_POSITIVE) .setEffortToFix(15.0) @@ -91,11 +89,10 @@ public class IssueDtoTest { assertThat(issue.ruleKey().toString()).isEqualTo("squid:AvoidCycle"); assertThat(issue.language()).isEqualTo("xoo"); assertThat(issue.componentUuid()).isEqualTo("CDEF"); + assertThat(issue.projectUuid()).isEqualTo("GHIJ"); assertThat(issue.componentKey()).isEqualTo("org.sonar.sample:Sample"); - assertThat(issue.componentId()).isEqualTo(1L); assertThat(issue.moduleUuid()).isEqualTo("BCDE"); assertThat(issue.moduleUuidPath()).isEqualTo("ABCD.BCDE."); - assertThat(issue.projectUuid()).isEqualTo("ABCD"); assertThat(issue.projectKey()).isEqualTo("org.sonar.sample"); assertThat(issue.status()).isEqualTo(Issue.STATUS_CLOSED); assertThat(issue.resolution()).isEqualTo(Issue.RESOLUTION_FALSE_POSITIVE); diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java index 86004c2bec9..b09958301cf 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java @@ -48,10 +48,8 @@ public class IssueMapperTest extends AbstractDaoTestCase { @Test public void insert() throws Exception { IssueDto dto = new IssueDto(); - dto.setComponentId(123l); - dto.setComponentUuid("component-uuid"); - dto.setProjectId(100l); - dto.setProjectUuid("project-uuid"); + dto.setComponentUuid("uuid-123"); + dto.setProjectUuid("uuid-100"); dto.setRuleId(200); dto.setKee("ABCDE"); dto.setLine(500); @@ -85,9 +83,8 @@ public class IssueMapperTest extends AbstractDaoTestCase { setupData("testUpdate"); IssueDto dto = new IssueDto(); - dto.setComponentId(123l); - dto.setProjectId(101l); - dto.setProjectUuid("project-uuid-2"); + dto.setComponentUuid("uuid-123"); + dto.setProjectUuid("uuid-101"); dto.setRuleId(200); dto.setKee("ABCDE"); dto.setLine(500); @@ -121,9 +118,8 @@ public class IssueMapperTest extends AbstractDaoTestCase { setupData("testUpdate"); IssueDto dto = new IssueDto(); - dto.setComponentId(123l); - dto.setProjectId(101l); - dto.setProjectUuid("project-uuid-2"); + dto.setComponentUuid("uuid-123"); + dto.setProjectUuid("uuid-101"); dto.setRuleId(200); dto.setKee("ABCDE"); dto.setLine(500); @@ -160,9 +156,8 @@ public class IssueMapperTest extends AbstractDaoTestCase { setupData("updateBeforeSelectedDate_with_conflict"); IssueDto dto = new IssueDto(); - dto.setComponentId(123l); - dto.setProjectId(101l); - dto.setProjectUuid("project-uuid-2"); + dto.setComponentUuid("uuid-123"); + dto.setProjectUuid("uuid-101"); dto.setRuleId(200); dto.setKee("ABCDE"); dto.setLine(500); diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueStorageTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueStorageTest.java index 240aa0e8596..8ec847c3c86 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueStorageTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueStorageTest.java @@ -81,8 +81,8 @@ public class IssueStorageTest extends AbstractDaoTestCase { .setUpdateDate(date) .setCloseDate(date) - .setComponentUuid("component-uuid") - .setProjectUuid("project-uuid") + .setComponentUuid("uuid-100") + .setProjectUuid("uuid-10") .setComponentKey("struts:Action"); saver.save(issue); @@ -116,8 +116,8 @@ public class IssueStorageTest extends AbstractDaoTestCase { .setUpdateDate(date) .setCloseDate(date) - .setComponentUuid("component-uuid") - .setProjectUuid("project-uuid") + .setComponentUuid("uuid-100") + .setProjectUuid("uuid-10") .setComponentKey("struts:Action"); saver.save(session, issue); @@ -128,8 +128,8 @@ public class IssueStorageTest extends AbstractDaoTestCase { @Test public void server_insert_new_issues_with_session() throws Exception { - ComponentDto project = new ComponentDto().setId(10L).setUuid("project-uuid"); - ComponentDto component = new ComponentDto().setId(100L).setUuid("component-uuid"); + ComponentDto project = new ComponentDto().setId(10L).setUuid("uuid-10"); + ComponentDto component = new ComponentDto().setId(100L).setUuid("uuid-100"); FakeServerSaver saver = new FakeServerSaver(getMyBatis(), new FakeRuleFinder(), component, project); DefaultIssueComment comment = DefaultIssueComment.create("ABCDE", "emmerik", "the comment"); @@ -196,6 +196,8 @@ public class IssueStorageTest extends AbstractDaoTestCase { .setCreationDate(date) .setUpdateDate(date) .setCloseDate(date) + .setComponentUuid("uuid-100") + .setProjectUuid("uuid-10") // unmodifiable fields .setRuleKey(RuleKey.of("xxx", "unknown")) @@ -210,8 +212,8 @@ public class IssueStorageTest extends AbstractDaoTestCase { public void server_update_issues() throws Exception { setupData("should_update_issues"); - ComponentDto project = new ComponentDto().setId(10L); - ComponentDto component = new ComponentDto().setId(100L); + ComponentDto project = new ComponentDto().setId(10L).setUuid("whatever-uuid"); + ComponentDto component = new ComponentDto().setId(100L).setUuid("whatever-uuid-2"); FakeServerSaver saver = new FakeServerSaver(getMyBatis(), new FakeRuleFinder(), component, project); DefaultIssueComment comment = DefaultIssueComment.create("ABCDE", "emmerik", "the comment"); @@ -240,6 +242,7 @@ public class IssueStorageTest extends AbstractDaoTestCase { .setCreationDate(date) .setUpdateDate(date) .setCloseDate(date) + .setProjectUuid("uuid-10") // unmodifiable fields .setRuleKey(RuleKey.of("xxx", "unknown")) @@ -259,14 +262,14 @@ public class IssueStorageTest extends AbstractDaoTestCase { @Override protected void doInsert(DbSession session, long now, DefaultIssue issue) { int ruleId = rule(issue).getId(); - IssueDto dto = IssueDto.toDtoForComputationInsert(issue, 100l, 10l, ruleId, now); + IssueDto dto = IssueDto.toDtoForComputationInsert(issue, ruleId, now); session.getMapper(IssueMapper.class).insert(dto); } @Override protected void doUpdate(DbSession session, long now, DefaultIssue issue) { - IssueDto dto = IssueDto.toDtoForUpdate(issue, 10l, now); + IssueDto dto = IssueDto.toDtoForUpdate(issue, now); session.getMapper(IssueMapper.class).update(dto); } } @@ -292,7 +295,7 @@ public class IssueStorageTest extends AbstractDaoTestCase { @Override protected void doUpdate(DbSession session, long now, DefaultIssue issue) { - IssueDto dto = IssueDto.toDtoForUpdate(issue, 10l, now); + IssueDto dto = IssueDto.toDtoForUpdate(issue, now); session.getMapper(IssueMapper.class).update(dto); } } diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/UpdateConflictResolverTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/UpdateConflictResolverTest.java index f3a251acca3..ba6599d789d 100644 --- a/sonar-core/src/test/java/org/sonar/core/issue/db/UpdateConflictResolverTest.java +++ b/sonar-core/src/test/java/org/sonar/core/issue/db/UpdateConflictResolverTest.java @@ -48,7 +48,6 @@ public class UpdateConflictResolverTest { .setKee("ABCDE") .setRuleId(10) .setRuleKey("squid", "AvoidCycles") - .setComponentId(100L) .setComponentKey("struts:org.apache.struts.Action") .setLine(10) .setStatus(Issue.STATUS_OPEN) @@ -94,7 +93,7 @@ public class UpdateConflictResolverTest { .setKee("ABCDE") .setRuleId(10) .setRuleKey("squid", "AvoidCycles") - .setComponentId(100L) + .setComponentUuid("100") .setComponentKey("struts:org.apache.struts.Action") .setLine(10) .setResolution(Issue.RESOLUTION_FALSE_POSITIVE) diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java index 42fa52604aa..d7d285e42fa 100644 --- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeCommandsTest.java @@ -25,7 +25,6 @@ import org.junit.Test; import org.sonar.core.persistence.AbstractDaoTestCase; import org.sonar.core.persistence.MyBatis; -import java.util.Arrays; import java.util.List; import static com.google.common.collect.Lists.newArrayList; @@ -118,7 +117,7 @@ public class PurgeCommandsTest extends AbstractDaoTestCase { setupData("shouldDeleteResource"); SqlSession session = getMyBatis().openSession(); try { - new PurgeCommands(session, profiler).deleteResources(Arrays.asList(1L)); + new PurgeCommands(session, profiler).deleteResources(newArrayList(new IdUuidPair(1L, "1"))); } finally { MyBatis.closeQuietly(session); } @@ -132,13 +131,21 @@ public class PurgeCommandsTest extends AbstractDaoTestCase { public void should_not_fail_when_deleting_huge_number_of_resources() { SqlSession session = getMyBatis().openSession(); try { - new PurgeCommands(session, profiler).deleteResources(getHugeNumberOfIds()); + new PurgeCommands(session, profiler).deleteResources(getHugeNumberOfIdUuids()); } finally { MyBatis.closeQuietly(session); } // The goal of this test is only to check that the query do no fail, not to check result } + private List getHugeNumberOfIdUuids() { + List hugeNbOfSnapshotIds = newArrayList(); + for (long i = 0; i < 4500; i++) { + hugeNbOfSnapshotIds.add(new IdUuidPair(i, String.valueOf(i))); + } + return hugeNbOfSnapshotIds; + } + private List getHugeNumberOfIds() { List hugeNbOfSnapshotIds = newArrayList(); for (long i = 0; i < 4500; i++) { diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeConfigurationTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeConfigurationTest.java index d545ed63d0a..71dc8567ba1 100644 --- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeConfigurationTest.java +++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeConfigurationTest.java @@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; public class PurgeConfigurationTest { @Test public void should_delete_all_closed_issues() throws Exception { - PurgeConfiguration conf = new PurgeConfiguration(1L, new String[0], 0); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 0); assertThat(conf.maxLiveDateOfClosedIssues()).isNull(); - conf = new PurgeConfiguration(1L, new String[0], -1); + conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], -1); assertThat(conf.maxLiveDateOfClosedIssues()).isNull(); } @@ -40,7 +40,7 @@ public class PurgeConfigurationTest { public void should_delete_only_old_closed_issues() throws Exception { Date now = DateUtils.parseDate("2013-05-18"); - PurgeConfiguration conf = new PurgeConfiguration(1L, new String[0], 30); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30); Date toDate = conf.maxLiveDateOfClosedIssues(now); assertThat(toDate.getYear()).isEqualTo(113);//=2013 diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java index 0683bade2de..0e57b5654e3 100644 --- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java @@ -58,6 +58,7 @@ public class PurgeDaoTest extends AbstractDaoTestCase { sut = new PurgeDao(getMyBatis(), new ResourceDao(getMyBatis(), system2), new PurgeProfiler(), system2); } + @After public void after() { MyBatis.closeQuietly(dbSession); @@ -66,35 +67,44 @@ public class PurgeDaoTest extends AbstractDaoTestCase { @Test public void shouldDeleteAbortedBuilds() { setupData("shouldDeleteAbortedBuilds"); - sut.purge(new PurgeConfiguration(1L, new String[0], 30), PurgeListener.EMPTY); + sut.purge(newConfigurationWith30Days(), PurgeListener.EMPTY); checkTables("shouldDeleteAbortedBuilds", "snapshots"); } @Test public void should_purge_project() { setupData("shouldPurgeProject"); - sut.purge(new PurgeConfiguration(1L, new String[0], 30), PurgeListener.EMPTY); + sut.purge(newConfigurationWith30Days(), PurgeListener.EMPTY); checkTables("shouldPurgeProject", "projects", "snapshots"); } + private PurgeConfiguration newConfigurationWith30Days() { + return new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30); + } + + private PurgeConfiguration newConfigurationWith30Days(System2 system2) { + return new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30, system2); + } + + @Test public void delete_file_sources_of_disabled_resources() { setupData("delete_file_sources_of_disabled_resources"); - sut.purge(new PurgeConfiguration(1L, new String[0], 30, system2), PurgeListener.EMPTY); + sut.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY); checkTables("delete_file_sources_of_disabled_resources", "file_sources"); } @Test public void shouldDeleteHistoricalDataOfDirectoriesAndFiles() { setupData("shouldDeleteHistoricalDataOfDirectoriesAndFiles"); - sut.purge(new PurgeConfiguration(1L, new String[] {Scopes.DIRECTORY, Scopes.FILE}, 30), PurgeListener.EMPTY); + sut.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[]{Scopes.DIRECTORY, Scopes.FILE}, 30), PurgeListener.EMPTY); checkTables("shouldDeleteHistoricalDataOfDirectoriesAndFiles", "projects", "snapshots"); } @Test public void disable_resources_without_last_snapshot() { setupData("disable_resources_without_last_snapshot"); - sut.purge(new PurgeConfiguration(1L, new String[0], 30, system2), PurgeListener.EMPTY); + sut.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY); checkTables("disable_resources_without_last_snapshot", new String[]{"issue_close_date", "issue_update_date"}, "projects", "snapshots", "issues"); } @@ -129,14 +139,14 @@ public class PurgeDaoTest extends AbstractDaoTestCase { @Test public void should_delete_old_closed_issues() { setupData("should_delete_old_closed_issues"); - sut.purge(new PurgeConfiguration(1L, new String[0], 30), PurgeListener.EMPTY); + sut.purge(newConfigurationWith30Days(), PurgeListener.EMPTY); checkTables("should_delete_old_closed_issues", "issues", "issue_changes"); } @Test public void should_delete_all_closed_issues() { setupData("should_delete_all_closed_issues"); - sut.purge(new PurgeConfiguration(1L, new String[0], 0), PurgeListener.EMPTY); + sut.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 0), PurgeListener.EMPTY); checkTables("should_delete_all_closed_issues", "issues", "issue_changes"); } diff --git a/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml b/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml index de7167141e7..e945efb6ab0 100644 --- a/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml +++ b/sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml @@ -1,12 +1,13 @@ + user_login="igor" status="OPEN" created_at="[null]" updated_at="[null]"/> - - - - + + + + - + diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml index cf7f9a41062..d086991945a 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml @@ -9,19 +9,25 @@ What has been changed : - + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" + deprecated_kee="[null]" authorization_updated_at="[null]"/> - + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" + deprecated_kee="[null]" authorization_updated_at="[null]"/> - + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" + deprecated_kee="[null]" authorization_updated_at="[null]"/> + depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" + build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/> + depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" + build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/> + depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" + build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/> + resolution="REMOVED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="1450000000000" issue_creation_date="2013-04-16" issue_update_date="2014-04-09" + created_at="1450000000000" tags="[null]"/> + resolution="REMOVED" line="[null]" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="1450000000000" issue_creation_date="2013-04-16" issue_update_date="2014-04-09" + created_at="1450000000000" tags="[null]"/> + resolution="REMOVED" line="[null]" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="1450000000000" issue_creation_date="2013-04-16" issue_update_date="2014-04-09" + created_at="1450000000000" tags="[null]"/> + resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="1450000000000" issue_creation_date="2013-04-16" issue_update_date="2014-04-08" + created_at="1450000000000" tags="[null]"/> diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml index 121c1148321..b99d22d0a1b 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml @@ -48,10 +48,8 @@ not to be updated --> - - - + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" + authorization_updated_at="[null]"/> + depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" + build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/> - + resolution="[null]" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" tags="[null]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" + created_at="1400000000000"/> + - + resolution="[null]" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" tags="[null]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" + created_at="1400000000000"/> + - @@ -17,8 +17,8 @@ do not purge --> - + description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" + authorization_updated_at="[null]"/> + depth="[null]" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" + build_date="2008-12-02 13:58:00.00" version="[null]" path="[null]"/> - + resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" + created_at="1400000000000"/> + - + resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" + created_at="1400000000000"/> + - + resolution="[null]" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" + created_at="1400000000000"/> + - + resolution="[null]" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" + created_at="1400000000000"/> + - + resolution="FIXED" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" + manual_severity="[false]" + message="[null]" action_plan_key="[null]" effort_to_fix="[null]" technical_debt="[null]" + issue_attributes="[null]" checksum="[null]" author_login="[null]" + updated_at="[null]" issue_creation_date="2013-04-16" issue_update_date="2013-04-16" + created_at="1400000000000"/> + diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java index 9ba69fd9cc6..05d5d0fc5bd 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java @@ -55,7 +55,6 @@ public class DefaultIssue implements Issue { private String componentUuid; private String componentKey; - private Long componentId; private String moduleUuid; private String moduleUuidPath; @@ -147,19 +146,6 @@ public class DefaultIssue implements Issue { return this; } - /** - * The component id not populated on batch side - */ - @CheckForNull - public Long componentId() { - return componentId; - } - - public DefaultIssue setComponentId(@Nullable Long s) { - this.componentId = s; - return this; - } - @CheckForNull public String moduleUuid() { return moduleUuid; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java index 673aac868af..998d89e1451 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/issue/internal/DefaultIssueTest.java @@ -43,7 +43,6 @@ public class DefaultIssueTest { public void test_setters_and_getters() throws Exception { issue.setKey("ABCD") .setComponentKey("org.sample.Sample") - .setComponentId(1L) .setProjectKey("Sample") .setRuleKey(RuleKey.of("squid", "S100")) .setLanguage("xoo") @@ -72,7 +71,6 @@ public class DefaultIssueTest { assertThat(issue.key()).isEqualTo("ABCD"); assertThat(issue.componentKey()).isEqualTo("org.sample.Sample"); - assertThat(issue.componentId()).isEqualTo(1L); assertThat(issue.projectKey()).isEqualTo("Sample"); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("squid", "S100")); assertThat(issue.language()).isEqualTo("xoo"); -- 2.39.5