static _buildTree()

in src/app/teamcity/teamcity-service.js [58:92]


  static _buildTree(projects, projectMap, buildTypes) {
    // Build a forest of projects
    const roots = [];
    projects.forEach(project => {
      const parent = projectMap[project.parentProjectId];
      if (parent) {
        const children = parent.children || [];
        children.push(project);
        parent.children = children;
        project.parent = parent;
      } else {
        roots.push(project);
      }
    });

    buildTypes.forEach(buildType => {
      const parent = projectMap[buildType.projectId];
      if (parent) {
        const childBuildTypes = parent.buildTypes || [];
        childBuildTypes.push(buildType);
        parent.buildTypes = childBuildTypes;
        buildType.parent = parent;
        buildType.isBuildType = true;
      }
    });

    projects.forEach(project => {
      project.path = TeamcityService._getPath(project);
    });
    buildTypes.forEach(buildType => {
      buildType.path = TeamcityService._getPath(buildType);
    });

    return roots;
  }