]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5755 Improve migration re-entrance
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 28 Oct 2014 09:24:00 +0000 (10:24 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 28 Oct 2014 09:36:42 +0000 (10:36 +0100)
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_components.xml [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_projects.xml [deleted file]
sonar-core/src/main/java/org/sonar/core/persistence/migration/v50/Migration50Mapper.java

index 9619825745cde1e3be1e3ab294ea2a56f75bb072..098b4a6ace7a4c9cc0f5686b3862f6246b016a92 100644 (file)
@@ -36,6 +36,7 @@ import java.util.Timer;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicLong;
 
+import static com.google.common.collect.Lists.newArrayList;
 import static com.google.common.collect.Maps.newHashMap;
 
 /**
@@ -85,14 +86,19 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration {
 
     List<Component> components = mapper.selectComponentChildrenForProjects(project.getId());
     components.add(project);
+    List<Component> componentsToMigrate = newArrayList();
     for (Component component : components) {
       componentsBySnapshotId.put(component.getSnapshotId(), component);
 
-      component.setUuid(getOrCreateUuid(component, uuidByComponentId));
-      component.setProjectUuid(getOrCreateUuid(project, uuidByComponentId));
+      // Not migrate components already having an UUID
+      if (component.getUuid() == null) {
+        component.setUuid(getOrCreateUuid(component, uuidByComponentId));
+        component.setProjectUuid(getOrCreateUuid(project, uuidByComponentId));
+        componentsToMigrate.add(component);
+      }
     }
 
-    for (Component component : components) {
+    for (Component component : componentsToMigrate) {
       updateComponent(component, project, componentsBySnapshotId, uuidByComponentId);
       mapper.updateComponentUuids(component);
       counter.getAndIncrement();
@@ -115,7 +121,7 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration {
     }
     if (moduleUuidPath.length() > 0) {
       // Remove last '.'
-      moduleUuidPath.deleteCharAt(moduleUuidPath.length()-1);
+      moduleUuidPath.deleteCharAt(moduleUuidPath.length() - 1);
       component.setModuleUuidPath(moduleUuidPath.toString());
     }
 
@@ -126,9 +132,17 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration {
   }
 
   private void migrateDisabledComponents(DbSession session, Migration50Mapper mapper, Component project, Map<Long, String> uuidByComponentId) {
-    for (Component component : mapper.selectDisabledComponentChildrenForProjects(project.getId())) {
+    String projectUuid = getOrCreateUuid(project, uuidByComponentId);
+    for (Component component : mapper.selectDisabledDirectComponentChildrenForProjects(project.getId())) {
+      component.setUuid(getOrCreateUuid(component, uuidByComponentId));
+      component.setProjectUuid(projectUuid);
+
+      mapper.updateComponentUuids(component);
+      counter.getAndIncrement();
+    }
+    for (Component component : mapper.selectDisabledNoneDirectComponentChildrenForProjects(project.getId())) {
       component.setUuid(getOrCreateUuid(component, uuidByComponentId));
-      component.setProjectUuid(getOrCreateUuid(project, uuidByComponentId));
+      component.setProjectUuid(projectUuid);
 
       mapper.updateComponentUuids(component);
       counter.getAndIncrement();
index fe4b669c3200cfcf494f41721b2608e3a7f3935e..53250c0b56139a298b4d190899d5ee2558f7f4f1 100644 (file)
@@ -104,26 +104,47 @@ public class PopulateProjectsUuidColumnsMigrationTest {
   }
 
   @Test
-  public void not_migrate_already_migrated_projects() throws Exception {
-    db.prepareDbUnit(getClass(), "not_migrate_already_migrated_projects.xml");
+  public void not_migrate_already_migrated_components() throws Exception {
+    db.prepareDbUnit(getClass(), "not_migrate_already_migrated_components.xml");
+
+    migration.execute();
     session.commit();
 
     Component root = mapper.selectComponentByKey("org.struts:struts");
+    assertThat(root.getUuid()).isEqualTo("ABCD");
+    assertThat(root.getProjectUuid()).isEqualTo("ABCD");
+    assertThat(root.getModuleUuid()).isNull();
+    assertThat(root.getModuleUuidPath()).isNull();
+
     Component module = mapper.selectComponentByKey("org.struts:struts-core");
+    assertThat(module.getUuid()).isEqualTo("BCDE");
+    assertThat(module.getProjectUuid()).isEqualTo("ABCD");
+    assertThat(module.getModuleUuid()).isEqualTo("ABCD");
+    assertThat(module.getModuleUuidPath()).isEqualTo("ABCD");
+
     Component subModule = mapper.selectComponentByKey("org.struts:struts-db");
+    assertThat(subModule.getUuid()).isNotNull();
+    assertThat(subModule.getProjectUuid()).isEqualTo("ABCD");
+    assertThat(subModule.getModuleUuid()).isEqualTo("BCDE");
+    assertThat(subModule.getModuleUuidPath()).isEqualTo("ABCD.BCDE");
+
     Component directory = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts");
-    Component file = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext.java");
-    Component removedFile = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext2.java");
+    assertThat(directory.getUuid()).isNotNull();
+    assertThat(directory.getProjectUuid()).isEqualTo("ABCD");
+    assertThat(directory.getModuleUuid()).isEqualTo(subModule.getUuid());
+    assertThat(directory.getModuleUuidPath()).isEqualTo("ABCD.BCDE." + subModule.getUuid());
 
-    migration.execute();
-    session.commit();
+    Component file = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext.java");
+    assertThat(file.getUuid()).isNotNull();
+    assertThat(file.getProjectUuid()).isEqualTo("ABCD");
+    assertThat(file.getModuleUuid()).isEqualTo(subModule.getUuid());
+    assertThat(file.getModuleUuidPath()).isEqualTo("ABCD.BCDE." + subModule.getUuid());
 
-    assertThat(mapper.selectComponentByKey("org.struts:struts").getUuid()).isEqualTo(root.getUuid());
-    assertThat(mapper.selectComponentByKey("org.struts:struts-core").getUuid()).isEqualTo(module.getUuid());
-    assertThat(mapper.selectComponentByKey("org.struts:struts-db").getUuid()).isEqualTo(subModule.getUuid());
-    assertThat(mapper.selectComponentByKey("org.struts:struts-core:src/org/struts").getUuid()).isEqualTo(directory.getUuid());
-    assertThat(mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext.java").getUuid()).isEqualTo(file.getUuid());
-    assertThat(mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext2.java").getUuid()).isEqualTo(removedFile.getUuid());
+    Component removedFile = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext2.java");
+    assertThat(removedFile.getUuid()).isEqualTo("DCBA");
+    assertThat(removedFile.getProjectUuid()).isEqualTo("ABCD");
+    assertThat(removedFile.getModuleUuid()).isEqualTo("BCDE");
+    assertThat(removedFile.getModuleUuidPath()).isEqualTo("ABCD.BCDE");
   }
 
   @Test
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_components.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_components.xml
new file mode 100644 (file)
index 0000000..c558f41
--- /dev/null
@@ -0,0 +1,99 @@
+<dataset>
+
+  <!-- root project migrated -->
+  <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
+            uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="[null]"
+            description="the description" long_name="Apache Struts"
+            enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]"
+            created_at="2014-06-18" authorization_updated_at="2014-06-18" />
+  <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
+             status="P" islast="[true]" purge_status="[null]"
+             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+             period2_mode="[null]" period2_param="[null]" period2_date="[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=""/>
+
+  <!-- module migrated -->
+  <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core"
+            uuid="BCDE" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path="ABCD"
+            scope="PRJ" qualifier="BRC" long_name="Struts Core" deprecated_kee="[null]"
+            description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" authorization_updated_at="[null]" />
+  <snapshots id="2" project_id="2" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1"
+             status="P" islast="[true]" purge_status="[null]"
+             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+             period2_mode="[null]" period2_param="[null]" period2_date="[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="BRC" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
+             version="[null]" path="1."/>
+
+  <!-- sub module not migrated -->
+  <projects id="3" root_id="2" kee="org.struts:struts-db" name="Struts Db"
+            uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]"
+            scope="PRJ" qualifier="BRC" long_name="Struts Db" deprecated_kee="[null]"
+            description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" authorization_updated_at="[null]" />
+  <snapshots id="3" project_id="3" parent_snapshot_id="2" root_project_id="1" root_snapshot_id="1"
+             status="P" islast="[true]" purge_status="[null]"
+             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+             period2_mode="[null]" period2_param="[null]" period2_date="[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="BRC" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
+             version="[null]" path="1.2."/>
+
+  <!-- directory not migrated -->
+  <projects long_name="org.struts" id="4" scope="DIR" qualifier="DIR" kee="org.struts:struts-core:src/org/struts"
+            uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]"
+            name="src/org/struts" root_id="2"
+            description="[null]" deprecated_kee="[null]"
+            enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="src/org/struts" created_at="2014-06-18" authorization_updated_at="[null]" />
+  <snapshots id="4" project_id="4" parent_snapshot_id="3" root_project_id="1" root_snapshot_id="1"
+             status="P" islast="[true]" purge_status="[null]"
+             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+             period2_mode="[null]" period2_param="[null]" period2_date="[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="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
+             version="[null]" path="1.2.3."/>
+
+  <!-- file not migrated -->
+  <projects long_name="org.struts.RequestContext" id="5" scope="FIL" qualifier="FIL" kee="org.struts:struts-core:src/org/struts/RequestContext.java"
+            uuid="[null]" project_uuid="[null]" 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" authorization_updated_at="[null]" />
+
+  <snapshots id="5" project_id="5" parent_snapshot_id="4" root_project_id="1" root_snapshot_id="1"
+             status="P" islast="[true]" purge_status="[null]"
+             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+             period2_mode="[null]" period2_param="[null]" period2_date="[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="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
+             version="[null]" path="1.2.3.4."/>
+
+  <!-- removed file linked on module, migrated -->
+  <projects long_name="org.struts.RequestContext2" id="6" scope="FIL" qualifier="FIL" kee="org.struts:struts-core:src/org/struts/RequestContext2.java"
+            uuid="DCBA" project_uuid="ABCD" module_uuid="BCDE" module_uuid_path="ABCD.BCDE"
+            name="RequestContext.java" root_id="2"
+            description="[null]" deprecated_kee="[null]"
+            enabled="[false]" language="java" copy_resource_id="[null]" person_id="[null]" path="src/org/struts/RequestContext.java" created_at="2014-06-18" authorization_updated_at="[null]" />
+
+  <snapshots id="6" project_id="6" parent_snapshot_id="4" root_project_id="1" root_snapshot_id="1"
+             status="P" islast="[false]" purge_status="[null]"
+             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
+             period2_mode="[null]" period2_param="[null]" period2_date="[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="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
+             version="[null]" path="1.2.3.4."/>
+
+</dataset>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_projects.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_projects.xml
deleted file mode 100644 (file)
index 6a9087f..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-<dataset>
-
-  <!-- root project -->
-  <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
-            uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="[null]"
-            description="the description" long_name="Apache Struts"
-            enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]"
-            created_at="2014-06-18" authorization_updated_at="2014-06-18" />
-  <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
-             status="P" islast="[true]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[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=""/>
-
-  <!-- module -->
-  <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core"
-            uuid="BCDE" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="ABCD"
-            scope="PRJ" qualifier="BRC" long_name="Struts Core" deprecated_kee="[null]"
-            description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" authorization_updated_at="[null]" />
-  <snapshots id="2" project_id="2" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1"
-             status="P" islast="[true]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[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="BRC" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
-             version="[null]" path="1."/>
-
-  <!-- sub module -->
-  <projects id="3" root_id="2" kee="org.struts:struts-db" name="Struts Db"
-            uuid="CDEF" project_uuid="ABCD" module_uuid="BCDE" module_uuid_path="ABCD.BCDE."
-            scope="PRJ" qualifier="BRC" long_name="Struts Db" deprecated_kee="[null]"
-            description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" authorization_updated_at="[null]" />
-  <snapshots id="3" project_id="3" parent_snapshot_id="2" root_project_id="1" root_snapshot_id="1"
-             status="P" islast="[true]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[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="BRC" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
-             version="[null]" path="1.2."/>
-
-  <!-- directory -->
-  <projects long_name="org.struts" id="4" scope="DIR" qualifier="DIR" kee="org.struts:struts-core:src/org/struts"
-            uuid="DEFG" project_uuid="ABCD" module_uuid="CDEF" module_uuid_path="ABCD.BCDE.CDEF."
-            name="src/org/struts" root_id="2"
-            description="[null]" deprecated_kee="[null]"
-            enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="src/org/struts" created_at="2014-06-18" authorization_updated_at="[null]" />
-  <snapshots id="4" project_id="4" parent_snapshot_id="3" root_project_id="1" root_snapshot_id="1"
-             status="P" islast="[true]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[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="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
-             version="[null]" path="1.2.3."/>
-
-  <!-- file -->
-  <projects long_name="org.struts.RequestContext" id="5" scope="FIL" qualifier="FIL" kee="org.struts:struts-core:src/org/struts/RequestContext.java"
-            uuid="EFGH" project_uuid="ABCD" module_uuid="CDEF" module_uuid_path="ABCD.BCDE.CDEF."
-            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" authorization_updated_at="[null]" />
-
-  <snapshots id="5" project_id="5" parent_snapshot_id="4" root_project_id="1" root_snapshot_id="1"
-             status="P" islast="[true]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[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="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
-             version="[null]" path="1.2.3.4."/>
-
-  <!-- removed file -->
-  <projects long_name="org.struts.RequestContext2" id="6" scope="FIL" qualifier="FIL" kee="org.struts:struts-core:src/org/struts/RequestContext2.java"
-            uuid="GHIJ" project_uuid="ABCD" module_uuid="CDEF" module_uuid_path="ABCD.BCDE.CDEF."
-            name="RequestContext.java" root_id="2"
-            description="[null]" deprecated_kee="[null]"
-            enabled="[false]" language="java" copy_resource_id="[null]" person_id="[null]" path="src/org/struts/RequestContext.java" created_at="2014-06-18" authorization_updated_at="[null]" />
-
-  <snapshots id="6" project_id="6" parent_snapshot_id="4" root_project_id="1" root_snapshot_id="1"
-             status="P" islast="[false]" purge_status="[null]"
-             period1_mode="[null]" period1_param="[null]" period1_date="[null]"
-             period2_mode="[null]" period2_param="[null]" period2_date="[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="FIL" qualifier="CLA" created_at="2008-12-02 13:58:00.00" build_date="2008-12-02 13:58:00.00"
-             version="[null]" path="1.2.3.4."/>
-
-</dataset>
index 1a914314fdf23004a2376d970eae83da048d70a1..61c1c43fb91c9171319239b3f02a5353453dd3e2 100644 (file)
@@ -34,6 +34,7 @@ public interface Migration50Mapper {
   @Select("SELECT " +
     "  p.id AS \"id\", " +
     "  p.uuid AS \"uuid\", " +
+    "  p.project_uuid AS \"projectUuid\", " +
     "  s.root_project_id AS \"projectId\", " +
     "  s.id AS \"snapshotId\", " +
     "  s.path AS \"snapshotPath\", " +
@@ -50,6 +51,9 @@ public interface Migration50Mapper {
   @Select("SELECT " +
     "  p.id AS \"id\", " +
     "  p.uuid AS \"uuid\", " +
+    "  p.project_uuid AS \"projectUuid\", " +
+    "  p.module_uuid AS \"moduleUuid\", " +
+    "  p.module_uuid_path AS \"moduleUuidPath\", " +
     "  s.root_project_id AS \"projectId\", " +
     "  s.id AS \"snapshotId\", " +
     "  s.path AS \"snapshotPath\", " +
@@ -58,25 +62,40 @@ public interface Migration50Mapper {
     "  INNER JOIN snapshots root_snapshot ON root_snapshot.project_id = root.id AND root_snapshot.islast = ${_true} " +
     "  INNER JOIN snapshots s ON s.root_snapshot_id = root_snapshot.id AND s.islast = ${_true} " +
     "  INNER JOIN projects p ON p.id = s.project_id " +
-    "  WHERE root.id = #{id} " +
-    "   AND p.uuid IS NULL ")
+    "  WHERE root.id = #{id} ")
   @Result(javaType = Component.class)
   List<Component> selectComponentChildrenForProjects(@Param("id") Long projectId);
 
   /**
-   * Return disabled children
+   * Return disabled direct children from a project (1st level modules, files on single module project)
+   * For migration re-entrance, ignore components already having UUID
+   */
+  @Select("SELECT " +
+    "  p.id AS \"id\", " +
+    "  p.uuid AS \"uuid\" " +
+    "FROM projects p " +
+    "  INNER JOIN projects root ON root.id = p.root_id " +
+    "  WHERE root.id = #{id} " +
+    "   AND p.uuid IS NULL " +
+    "   AND p.enabled=${_false} ")
+  @Result(javaType = Component.class)
+  List<Component> selectDisabledDirectComponentChildrenForProjects(@Param("id") Long projectId);
+
+  /**
+   * Return disabled none direct children (2nd level modules and more, files on modules, etc.)
+   * For migration re-entrance, ignore components already having UUID
    */
   @Select("SELECT " +
     "  p.id AS \"id\", " +
     "  p.uuid AS \"uuid\" " +
     "FROM projects p " +
-    "  LEFT OUTER JOIN projects root_one ON root_one.id = p.root_id " +
-    "  LEFT OUTER JOIN projects root_two ON root_two.id = root_one.root_id " +
-    "  WHERE (root_one.id = #{id} OR root_two.id=#{id}) " +
+    "  INNER JOIN projects root_one ON root_one.id = p.root_id " +
+    "  INNER JOIN projects root_two ON root_two.id = root_one.root_id " +
+    "  WHERE root_two.id=#{id} " +
     "   AND p.uuid IS NULL " +
     "   AND p.enabled=${_false} ")
   @Result(javaType = Component.class)
-  List<Component> selectDisabledComponentChildrenForProjects(@Param("id") Long projectId);
+  List<Component> selectDisabledNoneDirectComponentChildrenForProjects(@Param("id") Long projectId);
 
   /**
    * Return not migrated components