]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7705 make it more obvious in that project_uuid is uuid of root
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 1 Jul 2016 17:37:18 +0000 (19:37 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 8 Jul 2016 10:42:02 +0000 (12:42 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistComponentsStep.java
server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java

index 5ea98a188dba05f15c2d3850c52db3d955cbd015..ed8592dbd939899f13bfd7d3113550445b5b3e84 100644 (file)
@@ -192,6 +192,7 @@ public class PersistComponentsStep implements ComputationStep {
     res.setName(project.getName());
     res.setLongName(res.name());
     res.setDescription(project.getDescription());
+
     res.setProjectUuid(res.uuid());
     res.setRootUuid(res.uuid());
     res.setUuidPath(ComponentDto.UUID_PATH_OF_ROOT);
@@ -252,6 +253,7 @@ public class PersistComponentsStep implements ComputationStep {
     res.setName(view.getName());
     res.setDescription(view.getDescription());
     res.setLongName(res.name());
+
     res.setProjectUuid(res.uuid());
     res.setRootUuid(res.uuid());
     res.setUuidPath(ComponentDto.UUID_PATH_OF_ROOT);
@@ -305,9 +307,9 @@ public class PersistComponentsStep implements ComputationStep {
    * Applies to a node of type either MODULE, SUBVIEW, PROJECT_VIEW
    */
   private static void setRootAndParentModule(ComponentDto res, PathAwareVisitor.Path<ComponentDtoHolder> path) {
-    ComponentDto projectDto = from(path.getCurrentPath()).last().get().getElement().getDto();
-    res.setRootUuid(projectDto.uuid());
-    res.setProjectUuid(projectDto.uuid());
+    ComponentDto rootDto = path.root().getDto();
+    res.setRootUuid(rootDto.uuid());
+    res.setProjectUuid(rootDto.uuid());
 
     ComponentDto parentModule = path.parent().getDto();
     res.setUuidPath(formatUuidPathFromParent(parentModule));
@@ -319,6 +321,8 @@ public class PersistComponentsStep implements ComputationStep {
    * Applies to a node of type either DIRECTORY or FILE
    */
   private static void setParentModuleProperties(ComponentDto componentDto, PathAwareVisitor.Path<ComponentDtoHolder> path) {
+    componentDto.setProjectUuid(path.root().getDto().uuid());
+
     ComponentDto parentModule = from(path.getCurrentPath())
       .filter(ParentModulePathElement.INSTANCE)
       .first()
@@ -326,9 +330,9 @@ public class PersistComponentsStep implements ComputationStep {
       .getElement().getDto();
     componentDto.setUuidPath(formatUuidPathFromParent(path.parent().getDto()));
     componentDto.setRootUuid(parentModule.uuid());
-    componentDto.setProjectUuid(parentModule.projectUuid());
     componentDto.setModuleUuid(parentModule.uuid());
     componentDto.setModuleUuidPath(parentModule.moduleUuidPath());
+
   }
 
   private static boolean updateExisting(ComponentDto existingComponent, ComponentDto newComponent) {
index 0aa17f31b5c7286851a5e97d4284e1f7bb0362ce..446a24397acf3bfe45413adaa500deeb3c222016 100644 (file)
@@ -332,7 +332,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
     assertThat(projectDto.description()).isEqualTo(VIEW_DESCRIPTION);
     assertThat(projectDto.path()).isNull();
     assertThat(projectDto.uuid()).isEqualTo(VIEW_UUID);
-    assertThat(projectDto.projectUuid()).isEqualTo(projectDto.uuid());
+    assertThat(projectDto.projectUuid()).isEqualTo(VIEW_UUID);
     assertThat(projectDto.getRootUuid()).isEqualTo(VIEW_UUID);
     assertThat(projectDto.moduleUuid()).isNull();
     assertThat(projectDto.moduleUuidPath()).isEqualTo("." + projectDto.uuid() + ".");