From: Teryk Bellahsene Date: Wed, 21 Jan 2015 17:00:21 +0000 (+0100) Subject: issues - add component and project uuids to issues table X-Git-Tag: latest-silver-master-#65~102 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b3147826d0715bab3be5b5cb2b9fbcc1cbeccf9c;p=sonarqube.git issues - add component and project uuids to issues table --- 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 98af67b2546..ef8391f12ff 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 @@ -136,7 +136,7 @@ public class AnalysisReportService { private DefaultIssue setComponent(DefaultIssue issue, @Nullable ReportComponent component) { if (component != null) { - issue.setComponentId((long)component.id()); + 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 d081874346a..ecfae85a8fc 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,7 +70,7 @@ public class PersistIssuesStep implements ComputationStep { boolean saved = false; if (issue.isNew()) { Integer ruleId = ruleCache.get(issue.ruleKey()).getId(); - mapper.insert(IssueDto.toDtoForBatchInsert(issue, issue.componentId(), context.getProject().getId(), ruleId, system2.now())); + mapper.insert(IssueDto.toDtoForComputationInsert(issue, issue.componentId(), context.getProject().getId(), ruleId, system2.now())); count++; saved = true; } else if (issue.isChanged()) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java index 35482f7072c..f2cb0d801f1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java @@ -83,6 +83,7 @@ public interface DatabaseMigrations { CopyScmAccountsFromAuthorsToUsers.class, FeedIssueChangesLongDates.class, FeedAnalysisReportsLongDates.class, - UpdateProjectsModuleUuidPath.class + UpdateProjectsModuleUuidPath.class, + FeedIssueComponentUuids.class ); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuids.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuids.java new file mode 100644 index 00000000000..8e07193b67c --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuids.java @@ -0,0 +1,58 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.db.migrations.v51; + +import org.sonar.core.persistence.Database; +import org.sonar.server.db.migrations.BaseDataChange; +import org.sonar.server.db.migrations.MassUpdate; +import org.sonar.server.db.migrations.MassUpdate.Handler; +import org.sonar.server.db.migrations.Select.Row; +import org.sonar.server.db.migrations.SqlStatement; + +import java.sql.SQLException; + +public class FeedIssueComponentUuids extends BaseDataChange { + + public FeedIssueComponentUuids(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate update = context.prepareMassUpdate().rowPluralName("issues"); + update.select( + "SELECT c.uuid, c.project_uuid, i.id " + + "FROM issues i " + + "INNER JOIN projects c ON i.component_id=c.id " + + "WHERE i.component_uuid is null"); + update.update("UPDATE issues SET component_uuid=?, project_uuid=? WHERE id=?"); + update.execute(new Handler() { + @Override + public boolean handle(Row row, SqlStatement update) throws SQLException { + update.setString(1, row.getString(1)); + update.setString(2, row.getString(2)); + update.setLong(3, row.getLong(3)); + + return true; + } + }); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest.java new file mode 100644 index 00000000000..e4cb5219d2e --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.db.migrations.v51; + +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.core.persistence.DbTester; + +public class FeedIssueComponentUuidsTest { + @ClassRule + public static DbTester db = new DbTester().schema(FeedIssueComponentUuidsTest.class, "schema.sql"); + + FeedIssueComponentUuids sut; + + @Before + public void setUp() throws Exception { + db.truncateTables(); + + sut = new FeedIssueComponentUuids(db.database()); + } + + @Test + public void migrate_empty_db() throws Exception { + sut.execute(); + } + + @Test + public void migrate() throws Exception { + db.prepareDbUnit(this.getClass(), "before.xml"); + sut.execute(); + db.assertDbUnit(this.getClass(), "after-result.xml", "issues"); + } +} 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 ed157d4de95..0b6c5b2f4fb 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 @@ -41,13 +41,13 @@ import static org.assertj.core.api.Assertions.assertThat; public class IssueDaoTest extends AbstractDaoTestCase { - private IssueDao dao; + private IssueDao sut; private DbSession session; @Before public void before() throws Exception { this.session = getMyBatis().openSession(false); - this.dao = new IssueDao(getMyBatis()); + this.sut = new IssueDao(getMyBatis()); } @After @@ -59,7 +59,7 @@ public class IssueDaoTest extends AbstractDaoTestCase { public void get_by_key() { setupData("shared", "get_by_key"); - IssueDto issue = dao.selectByKey(session, "ABCDE"); + IssueDto issue = sut.selectByKey(session, "ABCDE"); assertThat(issue.getKee()).isEqualTo("ABCDE"); assertThat(issue.getId()).isEqualTo(100L); assertThat(issue.getComponentId()).isEqualTo(401); @@ -93,7 +93,7 @@ public class IssueDaoTest extends AbstractDaoTestCase { public void get_by_keys() { setupData("shared", "get_by_key"); - List issues = dao.selectByKeys(session, Arrays.asList("ABCDE")); + List issues = sut.selectByKeys(session, Arrays.asList("ABCDE")); assertThat(issues).hasSize(1); } @@ -101,7 +101,7 @@ public class IssueDaoTest extends AbstractDaoTestCase { public void find_by_action_plan() { setupData("shared", "find_by_action_plan"); - List issues = dao.findByActionPlan(session, "AP-1"); + List issues = sut.findByActionPlan(session, "AP-1"); assertThat(issues).hasSize(1); IssueDto issue = issues.get(0); @@ -140,12 +140,12 @@ public class IssueDaoTest extends AbstractDaoTestCase { // BCDE is a non-root module, we should find 2 issues from classes and one on itself DefaultResultHandler handler = new DefaultResultHandler(); - dao.selectNonClosedIssuesByModuleUuid(session, "BCDE", handler); + sut.selectNonClosedIssuesByModuleUuid(session, "BCDE", handler); assertThat(handler.getResultList()).extracting("key").containsOnly("100", "101", "103"); // DBCA is a a simple project with a single file handler = new DefaultResultHandler(); - dao.selectNonClosedIssuesByModuleUuid(session, "DBCA", handler); + sut.selectNonClosedIssuesByModuleUuid(session, "DBCA", handler); assertThat(handler.getResultList()).hasSize(1); BatchIssueDto batchIssueDto = (BatchIssueDto) handler.getResultList().get(0); @@ -169,12 +169,12 @@ public class IssueDaoTest extends AbstractDaoTestCase { // ABCD is the root module, we should find all 4 issues DefaultResultHandler handler = new DefaultResultHandler(); - dao.selectNonClosedIssuesByProjectUuid(session, "ABCD", handler); + sut.selectNonClosedIssuesByProjectUuid(session, "ABCD", handler); assertThat(handler.getResultList()).hasSize(4); // DBCA is a a simple project with a single file handler = new DefaultResultHandler(); - dao.selectNonClosedIssuesByProjectUuid(session, "DBCA", handler); + sut.selectNonClosedIssuesByProjectUuid(session, "DBCA", handler); assertThat(handler.getResultList()).hasSize(1); BatchIssueDto batchIssueDto = (BatchIssueDto) handler.getResultList().get(0); @@ -195,8 +195,8 @@ public class IssueDaoTest extends AbstractDaoTestCase { @Test public void insert() throws Exception { IssueDto dto = new IssueDto(); - dto.setComponent(new ComponentDto().setKey("struts:Action").setId(123L)); - dto.setProject(new ComponentDto().setKey("struts").setId(100L)); + dto.setComponent(new ComponentDto().setKey("struts:Action").setId(123L).setUuid("component-uuid")); + dto.setProject(new ComponentDto().setKey("struts").setId(100L).setUuid("project-uuid")); dto.setRule(RuleTesting.newDto(RuleKey.of("squid", "S001")).setId(200)); dto.setKee("ABCDE"); dto.setLine(500); @@ -219,44 +219,9 @@ public class IssueDaoTest extends AbstractDaoTestCase { dto.setCreatedAt(1400000000000L); dto.setUpdatedAt(1450000000000L); - dao.insert(session, dto); + sut.insert(session, dto); session.commit(); checkTables("insert", new String[] {"id"}, "issues"); } - - @Test - public void update() throws Exception { - setupData("update"); - - IssueDto dto = new IssueDto(); - dto.setComponent(new ComponentDto().setKey("struts:Action").setId(123L)); - dto.setProject(new ComponentDto().setKey("struts").setId(101L)); - dto.setRule(RuleTesting.newDto(RuleKey.of("squid", "S001")).setId(200)); - dto.setKee("ABCDE"); - dto.setLine(500); - dto.setEffortToFix(3.14); - dto.setDebt(10L); - dto.setResolution("FIXED"); - dto.setStatus("RESOLVED"); - dto.setSeverity("BLOCKER"); - dto.setReporter("emmerik"); - dto.setAuthorLogin("morgan"); - dto.setAssignee("karadoc"); - dto.setActionPlanKey("current_sprint"); - dto.setIssueAttributes("JIRA=FOO-1234"); - dto.setChecksum("123456789"); - dto.setMessage("the message"); - - dto.setIssueCreationDate(DateUtils.parseDate("2013-05-18")); - dto.setIssueUpdateDate(DateUtils.parseDate("2013-05-19")); - dto.setIssueCloseDate(DateUtils.parseDate("2013-05-20")); - dto.setCreatedAt(1400000000000L); - dto.setUpdatedAt(1450000000000L); - - dao.update(session, dto); - session.commit(); - - checkTables("update", new String[] {"id"}, "issues"); - } } diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/after-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/after-result.xml new file mode 100644 index 00000000000..61626354e1e --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/after-result.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/before.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/before.xml new file mode 100644 index 00000000000..f8b2ed7d1ee --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/before.xml @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/schema.sql b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/schema.sql new file mode 100644 index 00000000000..b7157762feb --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/schema.sql @@ -0,0 +1,52 @@ +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "ROOT_ID" INTEGER, + "UUID" VARCHAR(50), + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(256), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_RESOURCE_ID" INTEGER, + "LONG_NAME" VARCHAR(256), + "PERSON_ID" INTEGER, + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT +); + +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), + "RULE_ID" INTEGER, + "SEVERITY" VARCHAR(10), + "MANUAL_SEVERITY" BOOLEAN NOT NULL, + "MESSAGE" VARCHAR(4000), + "LINE" INTEGER, + "EFFORT_TO_FIX" DOUBLE, + "TECHNICAL_DEBT" INTEGER, + "STATUS" VARCHAR(20), + "RESOLUTION" VARCHAR(20), + "CHECKSUM" VARCHAR(1000), + "REPORTER" VARCHAR(255), + "ASSIGNEE" VARCHAR(255), + "AUTHOR_LOGIN" VARCHAR(255), + "ACTION_PLAN_KEY" VARCHAR(50) NULL, + "ISSUE_ATTRIBUTES" VARCHAR(4000), + "TAGS" VARCHAR(4000), + "ISSUE_CREATION_DATE" TIMESTAMP, + "ISSUE_CLOSE_DATE" TIMESTAMP, + "ISSUE_UPDATE_DATE" TIMESTAMP, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT +); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues-result.xml index dbf2cd99f78..5060b24c26b 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues-result.xml @@ -1,27 +1,30 @@ - + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues-result.xml index 47b4c1ce79a..4015eba96a7 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues-result.xml @@ -13,6 +13,8 @@ message="[null]" line="5000" component_id="100" + component_uuid="[null]" + project_uuid="[null]" root_component_id="10" rule_id="200" created_at="1000000000" @@ -24,10 +26,11 @@ issue_creation_date="2013-05-18 00:00:00.0" issue_update_date="2013-05-18 00:00:00.0" issue_close_date="2013-05-18 00:00:00.0" - /> + /> + change_data="severity=INFO|BLOCKER" created_at="[null]" updated_at="[null]" + issue_change_creation_date="[null]"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml index a655b018921..259a311ea36 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml @@ -20,6 +20,8 @@ message="[null]" line="3000" component_id="100" + component_uuid="[null]" + project_uuid="[null]" root_component_id="10" rule_id="200" created_at="1000000000" diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/insert-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/insert-result.xml index a6ea62afc7e..2a8b878b60e 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/insert-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/insert-result.xml @@ -3,6 +3,8 @@ id="100" kee="ABCDE" component_id="123" + component_uuid="component-uuid" + project_uuid="project-uuid" root_component_id="100" rule_id="200" severity="BLOCKER" diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update-result.xml deleted file mode 100644 index d50a2bc893e..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update-result.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 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 deleted file mode 100644 index e4bf4848927..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/771_add_issue_component_uuids.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/771_add_issue_component_uuids.rb new file mode 100644 index 00000000000..ec2c940231f --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/771_add_issue_component_uuids.rb @@ -0,0 +1,32 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# +# SonarQube 5.1 +# +class AddIssueComponentUuids < ActiveRecord::Migration + + def self.up + add_column 'issues', :component_uuid, :string, :limit => 50, :null => true + add_column 'issues', :project_uuid, :string, :limit => 50, :null => true + add_index 'issues', 'component_uuid', :name => 'issues_component_uuid' + add_index 'issues', 'project_uuid', :name => 'issues_project_uuid' + end +end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/772_feed_issue_component_uuids.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/772_feed_issue_component_uuids.rb new file mode 100644 index 00000000000..173b6a16898 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/772_feed_issue_component_uuids.rb @@ -0,0 +1,29 @@ +# +# 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 FeedIssueComponentUuids < ActiveRecord::Migration + + def self.up + execute_java_migration('org.sonar.server.db.migrations.v51.FeedIssueComponentUuids') + end +end 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 -->