From b3147826d0715bab3be5b5cb2b9fbcc1cbeccf9c Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Wed, 21 Jan 2015 18:00:21 +0100 Subject: issues - add component and project uuids to issues table --- .../java/org/sonar/core/issue/db/IssueDto.java | 6 +- .../sonar/core/persistence/DatabaseVersion.java | 2 +- .../org/sonar/core/issue/db/IssueMapper.xml | 26 ++++++-- .../org/sonar/core/persistence/rows-h2.sql | 3 + .../org/sonar/core/persistence/schema-h2.ddl | 6 ++ .../org/sonar/core/issue/db/IssueMapperTest.java | 17 +++-- .../org/sonar/core/issue/db/IssueStorageTest.java | 14 ++-- .../issue/db/IssueMapperTest/testInsert-result.xml | 2 + .../issue/db/IssueMapperTest/testUpdate-result.xml | 2 + .../core/issue/db/IssueMapperTest/testUpdate.xml | 2 + ...dateBeforeSelectedDate_with_conflict-result.xml | 2 + .../updateBeforeSelectedDate_with_conflict.xml | 2 + .../should_insert_new_issues-result.xml | 45 +++++++------ .../should_resolve_conflicts_on_updates-result.xml | 4 +- .../should_resolve_conflicts_on_updates.xml | 6 +- .../should_update_issues-result.xml | 7 +- .../db/IssueStorageTest/should_update_issues.xml | 4 +- ...able_resources_without_last_snapshot-result.xml | 8 +++ .../disable_resources_without_last_snapshot.xml | 8 +++ .../should_delete_all_closed_issues-result.xml | 4 ++ .../should_delete_all_closed_issues.xml | 76 +++++++++++++++------- .../should_delete_old_closed_issues-result.xml | 6 ++ .../should_delete_old_closed_issues.xml | 8 +++ 23 files changed, 190 insertions(+), 70 deletions(-) (limited to 'sonar-core') 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 5c6c46ed641..4b0b0db2ba6 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 @@ -561,7 +561,7 @@ public final class IssueDto implements Serializable { /** * On batch side, component keys and uuid are useless */ - public static IssueDto toDtoForBatchInsert(DefaultIssue issue, long componentId, long projectId, int ruleId, long now) { + public static IssueDto toDtoForComputationInsert(DefaultIssue issue, long componentId, long projectId, int ruleId, long now) { return new IssueDto() .setKee(issue.key()) .setLine(issue.line()) @@ -603,8 +603,8 @@ 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, Integer ruleId, long now) { - return toDtoForBatchInsert(issue, component.getId(), project.getId(), ruleId, now) + public static IssueDto toDtoForServerInsert(DefaultIssue issue, ComponentDto component, ComponentDto project, int ruleId, long now) { + return toDtoForComputationInsert(issue, component.getId(), project.getId(), ruleId, now) .setComponent(component) .setProject(project); } 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 d45867e74e0..f51fae850ba 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 = 770; + public static final int LAST_VERSION = 772; /** * List of all the tables.n 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 bd1a61b84d7..fd487317b1f 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 @@ -71,11 +71,17 @@ INSERT INTO issues (kee, component_id, root_component_id, 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) - VALUES (#{kee,jdbcType=VARCHAR}, #{componentId,jdbcType=BIGINT}, #{projectId,jdbcType=BIGINT}, #{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}, #{reporter,jdbcType=VARCHAR}, #{assignee,jdbcType=VARCHAR}, #{authorLogin,jdbcType=VARCHAR}, #{issueAttributes,jdbcType=VARCHAR}, #{issueCreationDate,jdbcType=TIMESTAMP}, - #{issueUpdateDate,jdbcType=TIMESTAMP}, #{issueCloseDate,jdbcType=TIMESTAMP}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}) + 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}, + #{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}, + #{reporter,jdbcType=VARCHAR}, #{assignee,jdbcType=VARCHAR}, #{authorLogin,jdbcType=VARCHAR}, + #{issueAttributes,jdbcType=VARCHAR}, + #{issueCreationDate,jdbcType=TIMESTAMP},#{issueUpdateDate,jdbcType=TIMESTAMP}, #{issueCloseDate,jdbcType=TIMESTAMP}, + #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, + #{componentUuid,jdbcType=VARCHAR}, #{projectUuid,jdbcType=VARCHAR}) not to be updated --> 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="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-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml index 7d2e4cd652e..95d93990575 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml @@ -40,6 +40,8 @@ do not purge --> to be purged --> do not purge -->