]> source.dussan.org Git - sonarqube.git/commitdiff
issues - add component and project uuids to issues table
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 21 Jan 2015 17:00:21 +0000 (18:00 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 23 Jan 2015 12:22:20 +0000 (13:22 +0100)
40 files changed:
server/sonar-server/src/main/java/org/sonar/server/computation/AnalysisReportService.java
server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistIssuesStep.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrations.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuids.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueDaoTest.java
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/after-result.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/before.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v51/FeedIssueComponentUuidsTest/schema.sql [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_insert_new_issues-result.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues-result.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/ServerIssueStorageTest/should_update_issues.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/insert-result.xml
server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update-result.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/issue/db/IssueDaoTest/update.xml [deleted file]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/771_add_issue_component_uuids.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/772_feed_issue_component_uuids.rb [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java
sonar-core/src/test/java/org/sonar/core/issue/db/IssueStorageTest.java
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/updateBeforeSelectedDate_with_conflict-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/updateBeforeSelectedDate_with_conflict.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_resolve_conflicts_on_updates.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_all_closed_issues.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/should_delete_old_closed_issues.xml

index 98af67b2546067bab81351a93d311e27fba06ba8..ef8391f12ffaf32d88033d91bde74901e7506f01 100644 (file)
@@ -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;
index d081874346a249509d6a20e75ba429ade0a57882..ecfae85a8fcf4dcd6f88b70a5c352de9c7652e81 100644 (file)
@@ -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()) {
index 35482f7072c4e54f5e4c30c137e6e3e9192796c6..f2cb0d801f11a57307fd4b849fe903d3deb0de7c 100644 (file)
@@ -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 (file)
index 0000000..8e07193
--- /dev/null
@@ -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 (file)
index 0000000..e4cb521
--- /dev/null
@@ -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");
+  }
+}
index ed157d4de9570e9e522d1df6593d03ffeaf0e26f..0b6c5b2f4fb3780ec0ead176514aad29ca89b56c 100644 (file)
@@ -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<IssueDto> issues = dao.selectByKeys(session, Arrays.asList("ABCDE"));
+    List<IssueDto> 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<IssueDto> issues = dao.findByActionPlan(session, "AP-1");
+    List<IssueDto> 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 (file)
index 0000000..6162635
--- /dev/null
@@ -0,0 +1,22 @@
+<dataset>
+  <issues id="1" kee="ABC"
+          component_id="100" component_uuid="COMPONENTUUID" root_component_id="10" project_uuid="PROJECTUUID"
+          resolution="OPEN" status="OPEN" severity="BLOCKER" manual_severity="[false]"
+          assignee="[null]" author_login="[null]" checksum="[null]" effort_to_fix="[null]" technical_debt="10"
+          message="[null]" line="5000" rule_id="10" reporter="emmerik" issue_attributes="foo=bar"
+          action_plan_key="[null]" tags="[null]"
+          issue_creation_date="2013-05-18" issue_update_date="2013-05-18" issue_close_date="2013-05-18"
+          created_at="1500000000000" updated_at="1500000000000"
+      />
+
+  <!-- re-entrant migration - ignore the issues that are already fed with uuids -->
+  <issues id="2" kee="DEF"
+          component_id="101" component_uuid="ANOTHERUUID" root_component_id="11" project_uuid="ANOTHER2UUID"
+          resolution="OPEN" status="OPEN" severity="BLOCKER" manual_severity="[false]"
+          assignee="[null]" author_login="[null]" checksum="[null]" effort_to_fix="[null]" technical_debt="10"
+          message="[null]" line="5000" rule_id="10" reporter="emmerik" issue_attributes="foo=bar"
+          action_plan_key="[null]" tags="[null]"
+          issue_creation_date="2013-05-18" issue_update_date="2013-05-18" issue_close_date="2013-05-18"
+          created_at="1500000000000" updated_at="1500000000000"
+      />
+</dataset>
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 (file)
index 0000000..f8b2ed7
--- /dev/null
@@ -0,0 +1,30 @@
+<dataset>
+  <projects long_name="org.struts.RequestContext" id="100" scope="FIL" qualifier="FIL"
+            kee="org.struts:struts-core:src/org/struts/RequestContext.java"
+            uuid="COMPONENTUUID" project_uuid="PROJECTUUID" module_uuid="[null]" module_uuid_path="[null]"
+            name="RequestContext.java" root_id="2"
+            description="[null]" deprecated_kee="[null]"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"
+            path="src/org/struts/RequestContext.java" created_at="2014-06-18"/>
+
+  <issues id="1" kee="ABC"
+          component_id="100" component_uuid="[null]" root_component_id="10" project_uuid="[null]"
+          resolution="OPEN" status="OPEN" severity="BLOCKER" manual_severity="[false]"
+          assignee="[null]" author_login="[null]" checksum="[null]" effort_to_fix="[null]" technical_debt="10"
+          message="[null]" line="5000" rule_id="10" reporter="emmerik" issue_attributes="foo=bar"
+          action_plan_key="[null]" tags="[null]"
+          issue_creation_date="2013-05-18" issue_update_date="2013-05-18" issue_close_date="2013-05-18"
+          created_at="1500000000000" updated_at="1500000000000"
+      />
+
+  <!-- re-entrant migration - ignore the issues that are already fed with uuids -->
+  <issues id="2" kee="DEF"
+          component_id="101" component_uuid="ANOTHERUUID" root_component_id="11" project_uuid="ANOTHER2UUID"
+          resolution="OPEN" status="OPEN" severity="BLOCKER" manual_severity="[false]"
+          assignee="[null]" author_login="[null]" checksum="[null]" effort_to_fix="[null]" technical_debt="10"
+          message="[null]" line="5000" rule_id="10" reporter="emmerik" issue_attributes="foo=bar"
+          action_plan_key="[null]" tags="[null]"
+          issue_creation_date="2013-05-18" issue_update_date="2013-05-18" issue_close_date="2013-05-18"
+          created_at="1500000000000" updated_at="1500000000000"
+      />
+</dataset>
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 (file)
index 0000000..b715776
--- /dev/null
@@ -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
+);
index dbf2cd99f780bdca308c41b1f012900fb13de874..5060b24c26b3838d51da1de46066efa3ae53dd04 100644 (file)
@@ -1,27 +1,30 @@
 <dataset>
   <issues id="1" kee="ABCDE" resolution="OPEN" status="OPEN" severity="BLOCKER" manual_severity="[false]"
-      assignee="[null]"
-      author_login="[null]"
-      checksum="[null]"
-      effort_to_fix="[null]"
-      technical_debt="10"
-      message="[null]"
-      line="5000"
-      component_id="100"
-      root_component_id="10"
-      rule_id="200"
-      created_at="1000000000"
-      updated_at="1000000000"
-      reporter="emmerik"
-      issue_attributes="foo=bar"
-      tags="[null]"
-      action_plan_key="[null]"
-      issue_creation_date="2013-05-18"
-      issue_update_date="2013-05-18"
-      issue_close_date="2013-05-18"
+          assignee="[null]"
+          author_login="[null]"
+          checksum="[null]"
+          effort_to_fix="[null]"
+          technical_debt="10"
+          message="[null]"
+          line="5000"
+          component_id="100"
+          component_uuid="BCDE"
+          project_uuid="ABCD"
+          root_component_id="10"
+          rule_id="200"
+          created_at="1000000000"
+          updated_at="1000000000"
+          reporter="emmerik"
+          issue_attributes="foo=bar"
+          tags="[null]"
+          action_plan_key="[null]"
+          issue_creation_date="2013-05-18"
+          issue_update_date="2013-05-18"
+          issue_close_date="2013-05-18"
       />
 
-  <issue_changes id="1" kee="FGHIJ" issue_key="ABCDE" change_type="comment" user_login="emmerik" change_data="the comment"
-                 created_at="[null]" updated_at="[null]" issue_change_creation_date="[null]" />
+  <issue_changes id="1" kee="FGHIJ" issue_key="ABCDE" change_type="comment" user_login="emmerik"
+                 change_data="the comment"
+                 created_at="[null]" updated_at="[null]" issue_change_creation_date="[null]"/>
 
 </dataset>
index 47b4c1ce79ad00a544df261254893a00ae68509c..4015eba96a7d7f98e3606fc00b835faab808d810 100644 (file)
@@ -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"
           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"
-    />
+      />
 
   <issue_changes id="1" kee="FGHIJ" issue_key="ABCDE" change_type="comment" user_login="emmerik"
                  change_data="the comment" created_at="[null]" updated_at="[null]" issue_change_creation_date="[null]"/>
   <issue_changes id="2" kee="[null]" issue_key="ABCDE" change_type="diff" user_login="emmerik"
-                 change_data="severity=INFO|BLOCKER" created_at="[null]" updated_at="[null]" issue_change_creation_date="[null]"/>
+                 change_data="severity=INFO|BLOCKER" created_at="[null]" updated_at="[null]"
+                 issue_change_creation_date="[null]"/>
 </dataset>
index a655b0189219c05222d4fc6d9d0f34ec5b1c407d..259a311ea36312a064081c4ebb48fb5635bc398c 100644 (file)
@@ -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"
index a6ea62afc7edf340c464a856bb902ece5a380b51..2a8b878b60ee6ef4666330348f5f5339db037bd5 100644 (file)
@@ -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 (file)
index d50a2bc..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<dataset>
-  <issues
-      id="100"
-      kee="ABCDE"
-      component_id="123"
-      root_component_id="101"
-      rule_id="200"
-      severity="BLOCKER"
-      manual_severity="[false]"
-      message="the message"
-      line="500"
-      effort_to_fix="3.14"
-      technical_debt="10"
-      status="RESOLVED"
-      resolution="FIXED"
-      checksum="123456789"
-      reporter="emmerik"
-      author_login="morgan"
-      assignee="karadoc"
-      issue_attributes="JIRA=FOO-1234"
-      tags="[null]"
-      issue_creation_date="2013-05-18"
-      issue_update_date="2013-05-19"
-      issue_close_date="2013-05-20"
-      created_at="1400000000000"
-      updated_at="1450000000000"
-      action_plan_key="current_sprint"
-      />
-</dataset>
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 (file)
index e4bf484..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<dataset>
-  <issues
-      id="100"
-      kee="ABCDE"
-      component_id="123"
-      root_component_id="100"
-      rule_id="200"
-      severity="INFO"
-      manual_severity="[false]"
-      message="old"
-      line="[null]"
-      effort_to_fix="[null]"
-      technical_debt="[null]"
-      status="OPEN"
-      resolution="[null]"
-      checksum="[null]"
-      reporter="[null]"
-      author_login="[null]"
-      assignee="[null]"
-      issue_attributes="[null]"
-      issue_creation_date="[null]"
-      issue_update_date="[null]"
-      issue_close_date="[null]"
-      created_at="1400000000000"
-      updated_at="1400000000000"
-      action_plan_key="[null]"
-      />
-</dataset>
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 (file)
index 0000000..ec2c940
--- /dev/null
@@ -0,0 +1,32 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# SonarQube 5.1
+#
+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 (file)
index 0000000..173b6a1
--- /dev/null
@@ -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
index 5c6c46ed641d10aac5f636e4fa3c2462d15f35dd..4b0b0db2ba665ac92f0961e122279f603751c317 100644 (file)
@@ -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);
   }
index d45867e74e0cf70698ffa3aa37948a2c8ab440ae..f51fae850ba887c7cfa4c8ca6fad8ace85e66590 100644 (file)
@@ -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
index bd1a61b84d7493cf8ef752d33f3235ee2537d195..fd487317b1f8e6371d61ddd83a3b6094fdf4db57 100644 (file)
     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})
   </insert>
 
   <!--
     author_login=#{authorLogin},
     tags=#{tagsString},
     root_component_id=#{projectId},
+    project_uuid=#{projectUuid},
     issue_attributes=#{issueAttributes},
     issue_creation_date=#{issueCreationDate},
     issue_update_date=#{issueUpdateDate},
     author_login=#{authorLogin},
     tags=#{tagsString},
     root_component_id=#{projectId},
+    project_uuid=#{projectUuid},
     issue_attributes=#{issueAttributes},
     issue_creation_date=#{issueCreationDate},
     issue_update_date=#{issueUpdateDate},
     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,
     i.action_plan_key as actionPlanKey,
     i.severity as severity,
     i.manual_severity as manualSeverity,
     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 &lt;&gt; 'BRC') or (p.id=#{id})) p on p.id=i.component_id
+    inner join (select p.id,p.kee from projects p where (p.root_id=#{id} and p.qualifier &lt;&gt; 'BRC') or
+    (p.id=#{id})) p on p.id=i.component_id
     inner join rules r on r.id=i.rule_id
     left outer join projects root on root.id=i.root_component_id
     where i.status &lt;&gt; 'CLOSED'
     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.kee FROM projects p WHERE p.module_uuid=#{uuid} OR p.uuid=#{uuid}) component ON
+    component.id=i.component_id
     INNER JOIN rules r ON r.id=i.rule_id
     WHERE i.status &lt;&gt; 'CLOSED'
   </select>
index 5d5fbca06b6a471f933dde8151ff7d37e7ca91fa..206704d1de61389cc5cbad6bbeedc9321fcd3a61 100644 (file)
@@ -285,6 +285,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('753');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('754');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('755');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('756');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('757');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('758');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('759');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('760');
@@ -298,6 +299,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('767');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('768');
 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 USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index 68a4c96b538d94d757e7209b40cddaaa65b9d4bc..5e1b3a7521a1d416892e4846272672361e26d774 100644 (file)
@@ -443,7 +443,9 @@ 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,
@@ -660,8 +662,12 @@ 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");
 
 CREATE INDEX "ISSUES_SEVERITY" ON "ISSUES" ("SEVERITY");
index a26c27e8dde4370806139c48f1a11dc053a4ee50..86004c2bec921ae4e2144693d82799551e9d06e2 100644 (file)
@@ -46,10 +46,12 @@ public class IssueMapperTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void testInsert() throws Exception {
+  public void insert() throws Exception {
     IssueDto dto = new IssueDto();
     dto.setComponentId(123l);
+    dto.setComponentUuid("component-uuid");
     dto.setProjectId(100l);
+    dto.setProjectUuid("project-uuid");
     dto.setRuleId(200);
     dto.setKee("ABCDE");
     dto.setLine(500);
@@ -75,16 +77,17 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     mapper.insert(dto);
     session.commit();
 
-    checkTables("testInsert", new String[]{"id"}, "issues");
+    checkTables("testInsert", new String[] {"id"}, "issues");
   }
 
   @Test
-  public void testUpdate() throws Exception {
+  public void update() throws Exception {
     setupData("testUpdate");
 
     IssueDto dto = new IssueDto();
     dto.setComponentId(123l);
     dto.setProjectId(101l);
+    dto.setProjectUuid("project-uuid-2");
     dto.setRuleId(200);
     dto.setKee("ABCDE");
     dto.setLine(500);
@@ -110,7 +113,7 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     mapper.update(dto);
     session.commit();
 
-    checkTables("testUpdate", new String[]{"id"}, "issues");
+    checkTables("testUpdate", new String[] {"id"}, "issues");
   }
 
   @Test
@@ -120,6 +123,7 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     IssueDto dto = new IssueDto();
     dto.setComponentId(123l);
     dto.setProjectId(101l);
+    dto.setProjectUuid("project-uuid-2");
     dto.setRuleId(200);
     dto.setKee("ABCDE");
     dto.setLine(500);
@@ -148,7 +152,7 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     assertThat(count).isEqualTo(1);
     session.commit();
 
-    checkTables("testUpdate", new String[]{"id"}, "issues");
+    checkTables("testUpdate", new String[] {"id"}, "issues");
   }
 
   @Test
@@ -158,6 +162,7 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     IssueDto dto = new IssueDto();
     dto.setComponentId(123l);
     dto.setProjectId(101l);
+    dto.setProjectUuid("project-uuid-2");
     dto.setRuleId(200);
     dto.setKee("ABCDE");
     dto.setLine(500);
@@ -186,6 +191,6 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     assertThat(count).isEqualTo(0);
     session.commit();
 
-    checkTables("updateBeforeSelectedDate_with_conflict", new String[]{"id"}, "issues");
+    checkTables("updateBeforeSelectedDate_with_conflict", new String[] {"id"}, "issues");
   }
 }
index 4cab4dfdda2539ede476fc85ca7a65a22482aeff..240aa0e8596b4ffa66ef77e55ab8d03140177240 100644 (file)
@@ -81,6 +81,8 @@ public class IssueStorageTest extends AbstractDaoTestCase {
       .setUpdateDate(date)
       .setCloseDate(date)
 
+      .setComponentUuid("component-uuid")
+      .setProjectUuid("project-uuid")
       .setComponentKey("struts:Action");
 
     saver.save(issue);
@@ -114,6 +116,8 @@ public class IssueStorageTest extends AbstractDaoTestCase {
       .setUpdateDate(date)
       .setCloseDate(date)
 
+      .setComponentUuid("component-uuid")
+      .setProjectUuid("project-uuid")
       .setComponentKey("struts:Action");
 
     saver.save(session, issue);
@@ -124,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);
-    ComponentDto component = new ComponentDto().setId(100L);
+    ComponentDto project = new ComponentDto().setId(10L).setUuid("project-uuid");
+    ComponentDto component = new ComponentDto().setId(100L).setUuid("component-uuid");
     FakeServerSaver saver = new FakeServerSaver(getMyBatis(), new FakeRuleFinder(), component, project);
 
     DefaultIssueComment comment = DefaultIssueComment.create("ABCDE", "emmerik", "the comment");
@@ -150,7 +154,9 @@ public class IssueStorageTest extends AbstractDaoTestCase {
       .setUpdateDate(date)
       .setCloseDate(date)
 
-      .setComponentKey("struts:Action");
+      .setComponentKey("struts:Action")
+      .setComponentUuid("component-uuid")
+      .setProjectUuid("project-uuid");
 
     saver.save(session, issue);
     session.commit();
@@ -253,7 +259,7 @@ public class IssueStorageTest extends AbstractDaoTestCase {
     @Override
     protected void doInsert(DbSession session, long now, DefaultIssue issue) {
       int ruleId = rule(issue).getId();
-      IssueDto dto = IssueDto.toDtoForBatchInsert(issue, 100l, 10l, ruleId, now);
+      IssueDto dto = IssueDto.toDtoForComputationInsert(issue, 100l, 10l, ruleId, now);
 
       session.getMapper(IssueMapper.class).insert(dto);
     }
index de4d58f480874f7ee118acc150e954c5d63d0b02..4e42661eff2b251a86018169167e37c572889aa0 100644 (file)
@@ -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"
index ea66b875954b34e407ece89dc588b641cd4ca130..e786cee7859ba5888b527ae45d67cc64e823a975 100644 (file)
@@ -3,6 +3,8 @@
       id="100"
       kee="ABCDE"
       component_id="123"
+      component_uuid="component-uuid"
+      project_uuid="project-uuid-2"
       root_component_id="101"
       rule_id="200"
       severity="BLOCKER"
index e4bf4848927c830d339aa67dc9dabd941e5a9eb1..3990d9ae5a21cab109324bd30498f729d6591a97 100644 (file)
@@ -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="INFO"
index 1cd6e6c18b4fd83f508305043533840cef6f1cc9..7035788c73991a705ab09805c6a8fe78c90a0ae1 100644 (file)
@@ -4,6 +4,8 @@
       id="100"
       kee="ABCDE"
       component_id="123"
+      component_uuid="component-uuid"
+      project_uuid="project-uuid"
       root_component_id="100"
       rule_id="200"
       severity="INFO"
index 6de2cc7d038a912929c8c21f87d1096831063a71..8af4d4cbfc9e7198bc8b88fbd244129936b85c70 100644 (file)
@@ -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="INFO"
index 458ce2553c26c00361bc95f3a79878d1cc2196fa..b30fd9374dda326e4ef8ecb23ba609b6971c5419 100644 (file)
@@ -1,27 +1,30 @@
 <dataset>
   <issues id="1" kee="ABCDE" resolution="OPEN" status="OPEN" severity="BLOCKER" manual_severity="[false]"
-      assignee="[null]"
-      author_login="[null]"
-      checksum="[null]"
-      effort_to_fix="[null]"
-      technical_debt="10"
-      message="[null]"
-      line="5000"
-      component_id="100"
-      root_component_id="10"
-      rule_id="200"
-      created_at="[null]"
-      updated_at="[null]"
-      reporter="emmerik"
-      issue_attributes="foo=bar"
-      tags="[null]"
-      action_plan_key="[null]"
-      issue_creation_date="2013-05-18"
-      issue_update_date="2013-05-18"
-      issue_close_date="2013-05-18"
+          assignee="[null]"
+          author_login="[null]"
+          checksum="[null]"
+          effort_to_fix="[null]"
+          technical_debt="10"
+          message="[null]"
+          line="5000"
+          component_id="100"
+          root_component_id="10"
+          component_uuid="component-uuid"
+          project_uuid="project-uuid"
+          rule_id="200"
+          created_at="[null]"
+          updated_at="[null]"
+          reporter="emmerik"
+          issue_attributes="foo=bar"
+          tags="[null]"
+          action_plan_key="[null]"
+          issue_creation_date="2013-05-18"
+          issue_update_date="2013-05-18"
+          issue_close_date="2013-05-18"
       />
 
-  <issue_changes id="1" kee="FGHIJ" issue_key="ABCDE" change_type="comment" user_login="emmerik" change_data="the comment"
-                 created_at="[null]" updated_at="[null]" issue_change_creation_date="[null]" />
+  <issue_changes id="1" kee="FGHIJ" issue_key="ABCDE" change_type="comment" user_login="emmerik"
+                 change_data="the comment"
+                 created_at="[null]" updated_at="[null]" issue_change_creation_date="[null]"/>
 
 </dataset>
index 26b0dd5f351275d78fa7096e0059eba134e477f3..e3397e3d142d6395173ea10b1c4b82a23e6a531d 100644 (file)
@@ -19,6 +19,8 @@
           message="[null]"
           line="444"
           component_id="100"
+          component_uuid="component-uuid"
+          project_uuid="project-uuid"
           root_component_id="10"
           rule_id="200"
           reporter="[null]"
@@ -29,5 +31,5 @@
           issue_creation_date="2005-05-12 00:00:00.0"
           issue_update_date="2013-05-18 00:00:00.0"
           issue_close_date="[null]"
-    />
+      />
 </dataset>
index b2422b190af5d60b945cc244e0492f48812fbae3..c2cd5033e0bb170a257d2914bfccb77d4bcf1c12 100644 (file)
@@ -1,7 +1,7 @@
 <dataset>
 
   <rules tags="[null]" system_tags="[null]" id="200" name="Avoid Cycles" plugin_rule_key="AvoidCycles"
-         plugin_config_key="[null]" plugin_name="squid" />
+         plugin_config_key="[null]" plugin_name="squid"/>
 
   <projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts"/>
   <projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action"/>
@@ -21,6 +21,8 @@
           message="[null]"
           line="1"
           component_id="100"
+          component_uuid="component-uuid"
+          project_uuid="project-uuid"
           root_component_id="10"
           rule_id="200"
           reporter="[null]"
@@ -31,5 +33,5 @@
           issue_creation_date="2005-05-12 00:00:00.0"
           issue_update_date="2013-05-18 00:00:00.0"
           issue_close_date="[null]"
-    />
+      />
 </dataset>
index 9127db20d63179bbc4679c10bb0d3cbaa8fdbffc..2cf53b1e763a0934d017ef8eb745c51f443da8f7 100644 (file)
@@ -13,6 +13,8 @@
           message="[null]"
           line="5000"
           component_id="100"
+          component_uuid="component-uuid"
+          project_uuid="[null]"
           root_component_id="10"
           rule_id="200"
           created_at="2013-05-18"
           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"
-    />
+      />
 
   <issue_changes id="1" kee="FGHIJ" issue_key="ABCDE" change_type="comment" user_login="emmerik"
                  change_data="the comment" created_at="[null]" updated_at="[null]" issue_change_creation_date="[null]"/>
   <issue_changes id="2" kee="[null]" issue_key="ABCDE" change_type="diff" user_login="emmerik"
-                 change_data="severity=INFO|BLOCKER" created_at="[null]" updated_at="[null]" issue_change_creation_date="[null]"/>
+                 change_data="severity=INFO|BLOCKER" created_at="[null]" updated_at="[null]"
+                 issue_change_creation_date="[null]"/>
 </dataset>
index 58b3f183dc42709412ba64d76be4172062bb4b5a..751373bb9be288c393783f92cc1bd546571bd18b 100644 (file)
@@ -13,6 +13,8 @@
           message="[null]"
           line="3000"
           component_id="100"
+          component_uuid="component-uuid"
+          project_uuid="[null]"
           root_component_id="10"
           rule_id="200"
           created_at="1400000000000"
@@ -24,5 +26,5 @@
           issue_creation_date="2010-01-01"
           issue_update_date="2010-02-02"
           issue_close_date="[null]"
-    />
+      />
 </dataset>
index 0404cd9fffd162ba3a1289f9a9fff24c17d015d1..cf7f9a41062fa9d039702e3187bc5a97e00d30fc 100644 (file)
@@ -57,6 +57,8 @@ What has been changed :
   <!-- Open issue on file -->
   <issues id="1" kee="ISSUE-1"
           component_id="3"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2014-04-09"
@@ -67,6 +69,8 @@ What has been changed :
   <!-- Open issue on directory -->
   <issues id="2" kee="ISSUE-2"
           component_id="2"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2014-04-09"
@@ -77,6 +81,8 @@ What has been changed :
   <!-- Open issue on project -->
   <issues id="3" kee="ISSUE-3"
           component_id="1"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2014-04-09"
@@ -87,6 +93,8 @@ What has been changed :
   <!-- Resolved issue on file -> not to be updated -->
   <issues id="4" kee="ISSUE-4"
           component_id="3"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2015-12-08"
index b629de0324ff5ccc1e686eec948eb6c99dc2e4cd..121c1148321e305c453535d904d9c94696bb77b5 100644 (file)
@@ -49,6 +49,8 @@
   <!-- Open issue on file -->
   <issues id="1" kee="ISSUE-1"
           component_id="3"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="OPEN"
           issue_close_date="[null]"
@@ -59,6 +61,8 @@
   <!-- Open issue on directory -->
   <issues id="2" kee="ISSUE-2"
           component_id="2"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="OPEN"
           issue_close_date="[null]"
@@ -69,6 +73,8 @@
   <!-- Open issue on project -->
   <issues id="3" kee="ISSUE-3"
           component_id="1"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CONFIRM"
           issue_close_date="[null]"
@@ -79,6 +85,8 @@
   <!-- Resolved issue on file -> not to be updated -->
   <issues id="4" kee="ISSUE-4"
           component_id="3"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2015-12-08"
index 4b3e552e028d01bd778d16cffe766c2c934707ec..23d072cc1ffb09b790d56bf3621d546fc84e2cdc 100644 (file)
@@ -46,6 +46,8 @@
   <!-- old open issues -->
   <issues id="3" kee="ISSUE-3"
           component_id="1"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="OPEN"
           issue_close_date="[null]"
@@ -57,6 +59,8 @@
   <!-- recent open and closed issues -->
   <issues id="4" kee="ISSUE-4"
           component_id="100"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="OPEN"
           issue_close_date="[null]"
index c9e3e76b6f39b14b6a07825f3a32ddcd2c33f5ea..401591c1b6a71240438cc161e9e57f8b3d07928c 100644 (file)
@@ -2,7 +2,8 @@
 
   <projects id="1" enabled="[true]" root_id="[null]" created_at="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" authorization_updated_at="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]"
+            authorization_updated_at="[null]"/>
 
   <snapshots id="1"
              project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
              period3_mode="[null]" period3_param="[null]" period3_date="[null]"
              period4_mode="[null]" period4_param="[null]" period4_date="[null]"
              period5_mode="[null]" period5_param="[null]" period5_date="[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]"/>
 
 
   <!-- old closed issues on file and project -->
   <issues id="1" kee="ISSUE-1"
           component_id="100"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2010-01-01"
-          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"/>
-  <issue_changes id="1" kee="[null]" issue_key="ISSUE-1" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[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"/>
+  <issue_changes id="1" kee="[null]" issue_key="ISSUE-1" created_at="[null]" updated_at="[null]" user_login="admin"
+                 change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
 
   <issues id="2" kee="ISSUE-2"
           component_id="1"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2010-01-01"
-          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"/>
-  <issue_changes id="2" kee="[null]" issue_key="ISSUE-2" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[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"/>
+  <issue_changes id="2" kee="[null]" issue_key="ISSUE-2" created_at="[null]" updated_at="[null]" user_login="admin"
+                 change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
 
 
   <!-- old open issues -->
   <issues id="3" kee="ISSUE-3"
           component_id="1"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="OPEN"
           issue_close_date="[null]"
-          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"/>
-  <issue_changes id="3" kee="[null]" issue_key="ISSUE-3" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
+          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"/>
+  <issue_changes id="3" kee="[null]" issue_key="ISSUE-3" created_at="[null]" updated_at="[null]" user_login="admin"
+                 change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
 
   <!-- recent open and closed issues -->
   <issues id="4" kee="ISSUE-4"
           component_id="100"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="OPEN"
           issue_close_date="[null]"
-          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"/>
-  <issue_changes id="4" kee="[null]" issue_key="ISSUE-4" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
+          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"/>
+  <issue_changes id="4" kee="[null]" issue_key="ISSUE-4" created_at="[null]" updated_at="[null]" user_login="admin"
+                 change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
 
   <issues id="5" kee="ISSUE-5"
           component_id="100"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2025-01-01"
-          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"/>
-  <issue_changes id="5" kee="[null]" issue_key="ISSUE-5" created_at="[null]" updated_at="[null]" user_login="admin" change_type="comment" change_data="abc" issue_change_creation_date="[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"/>
+  <issue_changes id="5" kee="[null]" issue_key="ISSUE-5" created_at="[null]" updated_at="[null]" user_login="admin"
+                 change_type="comment" change_data="abc" issue_change_creation_date="[null]"/>
 
 </dataset>
index 7d2e4cd652eaa48246592939efc9bc6301d49d0a..95d93990575b42954a290bfeb45bb34a6f4c8813 100644 (file)
@@ -40,6 +40,8 @@
   <!-- old open issues -> do not purge -->
   <issues id="3" kee="ISSUE-3"
           component_id="1"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="OPEN"
           issue_close_date="[null]"
@@ -51,6 +53,8 @@
   <!-- recent open and closed issues -> do not purge -->
   <issues id="4" kee="ISSUE-4"
           component_id="100"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="OPEN"
           issue_close_date="[null]"
@@ -61,6 +65,8 @@
 
   <issues id="5" kee="ISSUE-5"
           component_id="100"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2025-01-01"
index 0a70926c003b268878510a1e71cf037174f67b99..353e75358a3a66a650839b5331e50778cf4f3b45 100644 (file)
@@ -17,6 +17,8 @@
   <!-- old closed issues on file and project -> to be purged -->
   <issues id="1" kee="ISSUE-1"
           component_id="100"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2010-01-01"
@@ -27,6 +29,8 @@
 
   <issues id="2" kee="ISSUE-2"
           component_id="1"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2010-01-01"
@@ -50,6 +54,8 @@
   <!-- recent open and closed issues -> do not purge -->
   <issues id="4" kee="ISSUE-4"
           component_id="100"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="OPEN"
           issue_close_date="[null]"
@@ -60,6 +66,8 @@
 
   <issues id="5" kee="ISSUE-5"
           component_id="100"
+          component_uuid="[null]"
+          project_uuid="[null]"
           root_component_id="1"
           status="CLOSED"
           issue_close_date="2025-01-01"