import org.sonar.batch.protocol.input.ProjectReferentials;
import org.sonar.core.UtcDateUtils;
import org.sonar.core.component.ComponentDto;
-import org.sonar.core.component.ProjectRefentialsComponentDto;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
}
List<PropertyDto> moduleSettings = dbClient.propertiesDao().selectProjectProperties(query.getModuleKey(), session);
- List<ProjectRefentialsComponentDto> moduleChildren = dbClient.componentDao().findChildrenModulesFromModule(session, query.getModuleKey());
+ List<ComponentDto> moduleChildren = dbClient.componentDao().findChildrenModulesFromModule(session, query.getModuleKey());
List<PropertyDto> moduleChildrenSettings = newArrayList();
if (!moduleChildren.isEmpty()) {
moduleChildrenSettings = dbClient.propertiesDao().findChildrenModuleProperties(query.getModuleKey(), session);
}
}
- private Map<String, String> getPropertiesMap(List<? extends PropertyDto> propertyDtos, boolean hasScanPerm) {
+ private Map<String, String> getPropertiesMap(List<PropertyDto> propertyDtos, boolean hasScanPerm) {
Map<String, String> properties = newHashMap();
for (PropertyDto propertyDto : propertyDtos) {
String key = propertyDto.getKey();
private static class TreeModuleSettings {
private Map<String, Long> moduleIdsByKey;
+ private Map<String, String> moduleUuidsByKey;
private Multimap<Long, PropertyDto> propertiesByModuleId;
- private Multimap<String, ProjectRefentialsComponentDto> moduleChildrenByModuleKey;
+ private Multimap<String, ComponentDto> moduleChildrenByModuleUuid;
- private TreeModuleSettings(List<ProjectRefentialsComponentDto> moduleChildren, List<PropertyDto> moduleChildrenSettings, ComponentDto module, List<PropertyDto> moduleSettings) {
+ private TreeModuleSettings(List<ComponentDto> moduleChildren, List<PropertyDto> moduleChildrenSettings, ComponentDto module, List<PropertyDto> moduleSettings) {
propertiesByModuleId = ArrayListMultimap.create();
+ moduleIdsByKey = newHashMap();
+ moduleUuidsByKey = newHashMap();
+ moduleChildrenByModuleUuid = ArrayListMultimap.create();
+
for (PropertyDto settings : moduleChildrenSettings) {
propertiesByModuleId.put(settings.getResourceId(), settings);
}
propertiesByModuleId.putAll(module.getId(), moduleSettings);
- moduleIdsByKey = newHashMap();
- for (ProjectRefentialsComponentDto componentDto : moduleChildren) {
- moduleIdsByKey.put(componentDto.key(), componentDto.getId());
- }
+
moduleIdsByKey.put(module.key(), module.getId());
- moduleChildrenByModuleKey = ArrayListMultimap.create();
- for (ProjectRefentialsComponentDto componentDto : moduleChildren) {
- String parentModuleKey = componentDto.getParentModuleKey();
- if (parentModuleKey != null) {
- moduleChildrenByModuleKey.put(parentModuleKey, componentDto);
+ moduleUuidsByKey.put(module.key(), module.uuid());
+ for (ComponentDto componentDto : moduleChildren) {
+ moduleIdsByKey.put(componentDto.key(), componentDto.getId());
+ moduleUuidsByKey.put(componentDto.key(), componentDto.uuid());
+ String moduleUuid = componentDto.moduleUuid();
+ if (moduleUuid != null) {
+ moduleChildrenByModuleUuid.put(moduleUuid, componentDto);
} else {
- moduleChildrenByModuleKey.put(module.key(), componentDto);
+ moduleChildrenByModuleUuid.put(module.uuid(), componentDto);
}
}
}
return newArrayList(propertiesByModuleId.get(moduleId));
}
- private List<? extends ComponentDto> findChildrenModule(String moduleKey) {
- return newArrayList(moduleChildrenByModuleKey.get(moduleKey));
+ private List<ComponentDto> findChildrenModule(String moduleKey) {
+ String moduleUuid = moduleUuidsByKey.get(moduleKey);
+ return newArrayList(moduleChildrenByModuleUuid.get(moduleUuid));
}
-
}
}
import org.sonar.api.ServerComponent;
import org.sonar.api.utils.System2;
import org.sonar.core.component.ComponentDto;
-import org.sonar.core.component.ProjectRefentialsComponentDto;
import org.sonar.core.component.db.ComponentMapper;
import org.sonar.core.persistence.DaoComponent;
import org.sonar.core.persistence.DbSession;
return mapper(session).findSubProjectsByComponentUuids(keys);
}
- public List<ProjectRefentialsComponentDto> findChildrenModulesFromModule(DbSession session, String moduleKey) {
+ public List<ComponentDto> findChildrenModulesFromModule(DbSession session, String moduleKey) {
return mapper(session).findChildrenModulesFromModule(moduleKey);
}
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
import org.sonar.core.component.ComponentDto;
-import org.sonar.core.component.ProjectRefentialsComponentDto;
import org.sonar.core.persistence.AbstractDaoTestCase;
import org.sonar.core.persistence.DbSession;
import org.sonar.server.exceptions.NotFoundException;
setupData("multi-modules");
// From root project
- List<ProjectRefentialsComponentDto> modules = dao.findChildrenModulesFromModule(session, "org.struts:struts");
+ List<ComponentDto> modules = dao.findChildrenModulesFromModule(session, "org.struts:struts");
assertThat(modules).hasSize(2);
assertThat(modules).onProperty("id").containsOnly(2L, 3L);
- assertThat(modules).onProperty("parentModuleKey").containsOnly("org.struts:struts", "org.struts:struts-core");
// From module
modules = dao.findChildrenModulesFromModule(session, "org.struts:struts-core");
assertThat(modules).hasSize(1);
assertThat(modules).onProperty("id").containsOnly(3L);
- assertThat(modules).onProperty("parentModuleKey").containsOnly("org.struts:struts-core");
// From sub module
modules = dao.findChildrenModulesFromModule(session, "org.struts:struts-data");
+++ /dev/null
-/*
- * 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.core.component;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-public class ProjectRefentialsComponentDto extends ComponentDto {
-
- private String parentModuleKey;
-
- @CheckForNull
- public String getParentModuleKey() {
- return parentModuleKey;
- }
-
- public void setParentModuleKey(@Nullable String parentModuleKey) {
- this.parentModuleKey = parentModuleKey;
- }
-}
import org.apache.ibatis.annotations.Param;
import org.sonar.core.component.ComponentDto;
-import org.sonar.core.component.ProjectRefentialsComponentDto;
import javax.annotation.CheckForNull;
/**
* Return all modules children (not returning itself) from a module key
*/
- List<ProjectRefentialsComponentDto> findChildrenModulesFromModule(@Param("moduleKey") String moduleKey);
+ List<ComponentDto> findChildrenModulesFromModule(@Param("moduleKey") String moduleKey);
long countById(long id);
import org.sonar.core.activity.db.ActivityMapper;
import org.sonar.core.cluster.WorkQueue;
import org.sonar.core.component.ComponentDto;
-import org.sonar.core.component.ProjectRefentialsComponentDto;
import org.sonar.core.component.SnapshotDto;
import org.sonar.core.component.db.ComponentMapper;
import org.sonar.core.component.db.SnapshotMapper;
loadAlias(conf, "ActiveDashboard", ActiveDashboardDto.class);
loadAlias(conf, "Author", AuthorDto.class);
loadAlias(conf, "Component", ComponentDto.class);
- loadAlias(conf, "ProjectRefentialsComponent", ProjectRefentialsComponentDto.class);
loadAlias(conf, "Dashboard", DashboardDto.class);
loadAlias(conf, "Dependency", DependencyDto.class);
loadAlias(conf, "DuplicationUnit", DuplicationUnitDto.class);
</where>
</select>
- <select id="findChildrenModulesFromModule" parameterType="String" resultType="ProjectRefentialsComponent">
- SELECT <include refid="componentColumns"/>, parent.kee as parentModuleKey
+ <select id="findChildrenModulesFromModule" parameterType="String" resultType="Component">
+ SELECT <include refid="componentColumns"/>
FROM projects p
INNER JOIN (<include refid="org.sonar.core.component.db.SnapshotMapper.selectChildrenModulesFromModuleQuery" />) snapshotModules on snapshotModules.resourceId=p.id
- LEFT OUTER JOIN snapshots parent_snapshot on parent_snapshot.id = snapshotModules.parentId
- LEFT OUTER JOIN projects parent on parent.id = parent_snapshot.project_id
</select>
<select id="findProjectUuids" resultType="String">