From: Julien Lancelot Date: Tue, 30 Dec 2014 14:34:49 +0000 (+0100) Subject: SONAR-5849 Performance issue of Project Referentials WS for project with many modules X-Git-Tag: 5.0-RC4~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5fdff45fc6e56b5240e619d296d9975a317b94ea;p=sonarqube.git SONAR-5849 Performance issue of Project Referentials WS for project with many modules --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsLoader.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsLoader.java index 4fcbf411aea..dbff7696929 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectReferentialsLoader.java @@ -20,13 +20,16 @@ package org.sonar.server.batch; +import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; import org.sonar.api.ServerComponent; import org.sonar.api.resources.Language; import org.sonar.api.resources.Languages; 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; @@ -74,22 +77,31 @@ public class ProjectReferentialsLoader implements ServerComponent { DbSession session = dbClient.openSession(false); try { ProjectReferentials ref = new ProjectReferentials(); - String projectKey = null; + String projectKey = query.getModuleKey(); ComponentDto module = dbClient.componentDao().getNullableByKey(session, query.getModuleKey()); // Current project/module can be null when analysing a new project if (module != null) { ComponentDto project = dbClient.componentDao().getNullableRootProjectByKey(query.getModuleKey(), session); + // Can be null if the given project is a provisioned one if (project != null) { if (!project.key().equals(module.key())) { addSettings(ref, module.getKey(), getSettingsFromParents(module.key(), hasScanPerm, session)); + projectKey = project.key(); + } + + List moduleSettings = dbClient.propertiesDao().selectProjectProperties(query.getModuleKey(), session); + List moduleChildren = dbClient.componentDao().findChildrenModulesFromModule(session, query.getModuleKey()); + List moduleChildrenSettings = newArrayList(); + if (!moduleChildren.isEmpty()) { + moduleChildrenSettings = dbClient.propertiesDao().findChildrenModuleProperties(query.getModuleKey(), session); } - projectKey = project.key(); - addSettingsToChildrenModules(ref, query.getModuleKey(), Maps.newHashMap(), hasScanPerm, session); + TreeModuleSettings treeModuleSettings = new TreeModuleSettings(moduleChildren, moduleChildrenSettings, module, moduleSettings); + + addSettingsToChildrenModules(ref, query.getModuleKey(), Maps.newHashMap(), treeModuleSettings, hasScanPerm, session); } else { // Add settings of the provisioned project addSettings(ref, query.getModuleKey(), getPropertiesMap(dbClient.propertiesDao().selectProjectProperties(query.getModuleKey(), session), hasScanPerm)); - projectKey = query.getModuleKey(); } } @@ -121,15 +133,16 @@ public class ProjectReferentialsLoader implements ServerComponent { } } - private void addSettingsToChildrenModules(ProjectReferentials ref, String projectKey, Map parentProperties, boolean hasScanPerm, DbSession session) { + private void addSettingsToChildrenModules(ProjectReferentials ref, String moduleKey, Map parentProperties, TreeModuleSettings treeModuleSettings, + boolean hasScanPerm, DbSession session) { Map currentParentProperties = newHashMap(); currentParentProperties.putAll(parentProperties); - currentParentProperties.putAll(getPropertiesMap(dbClient.propertiesDao().selectProjectProperties(projectKey, session), hasScanPerm)); - addSettings(ref, projectKey, currentParentProperties); + currentParentProperties.putAll(getPropertiesMap(treeModuleSettings.findModuleSettings(moduleKey), hasScanPerm)); + addSettings(ref, moduleKey, currentParentProperties); - for (ComponentDto module : dbClient.componentDao().findModulesByProject(projectKey, session)) { - addSettings(ref, module.key(), currentParentProperties); - addSettingsToChildrenModules(ref, module.key(), currentParentProperties, hasScanPerm, session); + for (ComponentDto childModule : treeModuleSettings.findChildrenModule(moduleKey)) { + addSettings(ref, childModule.getKey(), currentParentProperties); + addSettingsToChildrenModules(ref, childModule.getKey(), currentParentProperties, treeModuleSettings, hasScanPerm, session); } } @@ -139,7 +152,7 @@ public class ProjectReferentialsLoader implements ServerComponent { } } - private Map getPropertiesMap(List propertyDtos, boolean hasScanPerm) { + private Map getPropertiesMap(List propertyDtos, boolean hasScanPerm) { Map properties = newHashMap(); for (PropertyDto propertyDto : propertyDtos) { String key = propertyDto.getKey(); @@ -218,4 +231,43 @@ public class ProjectReferentialsLoader implements ServerComponent { "Please contact your SonarQube administrator."); } } + + private static class TreeModuleSettings { + + private Map moduleIdsByKey; + private Multimap propertiesByModuleId; + private Multimap moduleChildrenByModuleKey; + + private TreeModuleSettings(List moduleChildren, List moduleChildrenSettings, ComponentDto module, List moduleSettings) { + propertiesByModuleId = 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); + } else { + moduleChildrenByModuleKey.put(module.key(), componentDto); + } + } + } + + private List findModuleSettings(String moduleKey) { + Long moduleId = moduleIdsByKey.get(moduleKey); + return newArrayList(propertiesByModuleId.get(moduleId)); + } + + private List findChildrenModule(String moduleKey) { + return newArrayList(moduleChildrenByModuleKey.get(moduleKey)); + } + + } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/db/ComponentDao.java b/server/sonar-server/src/main/java/org/sonar/server/component/db/ComponentDao.java index c9e7f27e771..69e3ec3dfa8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/db/ComponentDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/db/ComponentDao.java @@ -17,12 +17,14 @@ * 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.component.db; import com.google.common.collect.Lists; 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; @@ -113,6 +115,10 @@ public class ComponentDao extends BaseDao return mapper(session).findSubProjectsByComponentUuids(keys); } + public List findChildrenModulesFromModule(DbSession session, String moduleKey) { + return mapper(session).findChildrenModulesFromModule(moduleKey); + } + public List getByUuids(DbSession session, Collection uuids) { if (uuids.isEmpty()) { return Collections.emptyList(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/db/SnapshotDao.java b/server/sonar-server/src/main/java/org/sonar/server/component/db/SnapshotDao.java index 5379396bcae..213467f8903 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/db/SnapshotDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/db/SnapshotDao.java @@ -66,6 +66,13 @@ public class SnapshotDao extends BaseDao impl return mapper(session).selectSnapshotAndChildrenOfScope(snapshot.getId(), Scopes.PROJECT); } + /** + * Return all snapshots children (not returning itself) from a module key + */ + public List findChildrenModulesFromModule(DbSession session, String moduleKey) { + return mapper(session).selectChildrenModulesFromModule(moduleKey); + } + public int updateSnapshotAndChildrenLastFlagAndStatus(DbSession session, SnapshotDto snapshot, boolean isLast, String status) { Long rootId = snapshot.getId(); String path = snapshot.getPath() + snapshot.getId() + ".%"; diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java index cdc017e5aad..3376773d2a4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java @@ -67,7 +67,7 @@ public class ComponentTesting { .setUuid(Uuids.create()) .setProjectUuid(subProjectOrProject.projectUuid()) .setModuleUuid(subProjectOrProject.uuid()) - .setModuleUuidPath(subProjectOrProject.moduleUuidPath() == null ? subProjectOrProject.uuid() : subProjectOrProject.moduleUuidPath() + "." + subProjectOrProject.uuid()) + .setModuleUuidPath(subProjectOrProject.moduleUuidPath() == null ? subProjectOrProject.uuid() + "." : subProjectOrProject.moduleUuidPath() + subProjectOrProject.uuid() + ".") .setKey("KEY_" + uuid) .setName("NAME_" + uuid) .setLongName("LONG_NAME_" + uuid) diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/SnapshotTesting.java b/server/sonar-server/src/test/java/org/sonar/server/component/SnapshotTesting.java index 8785d3db8b8..1b174c9a11f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/SnapshotTesting.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/SnapshotTesting.java @@ -24,6 +24,8 @@ import org.sonar.api.utils.DateUtils; import org.sonar.core.component.ComponentDto; import org.sonar.core.component.SnapshotDto; +import java.util.Date; + public class SnapshotTesting { /** @@ -39,7 +41,9 @@ public class SnapshotTesting { .setQualifier(component.qualifier()) .setScope(component.scope()) .setParentId(parentSnapshot.getId()) - .setLast(true); + .setPath(parentSnapshot.getPath() == null ? Long.toString(parentSnapshot.getId()) + "." : parentSnapshot.getPath() + Long.toString(parentSnapshot.getId()) + ".") + .setLast(true) + .setBuildDate(new Date()); } public static SnapshotDto createForProject(ComponentDto project) { @@ -49,7 +53,9 @@ public class SnapshotTesting { .setStatus(SnapshotDto.STATUS_PROCESSED) .setQualifier(project.qualifier()) .setScope(project.scope()) - .setLast(true); + .setPath("") + .setLast(true) + .setBuildDate(new Date()); } public static SnapshotDto defaultSnapshot() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/db/ComponentDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/db/ComponentDaoTest.java index ca50790fe13..b49a2009645 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/db/ComponentDaoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/db/ComponentDaoTest.java @@ -17,6 +17,7 @@ * 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.component.db; import org.apache.ibatis.exceptions.PersistenceException; @@ -26,6 +27,7 @@ import org.junit.Test; 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; @@ -329,6 +331,27 @@ public class ComponentDaoTest extends AbstractDaoTestCase { assertThat(dao.findSubProjectsByComponentUuids(session, Collections.emptyList())).isEmpty(); } + @Test + public void find_children_modules_from_module() throws Exception { + setupData("multi-modules"); + + // From root project + List 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"); + assertThat(modules).isEmpty(); + } + @Test public void insert() { when(system2.now()).thenReturn(DateUtils.parseDate("2014-06-18").getTime()); @@ -391,9 +414,9 @@ public class ComponentDaoTest extends AbstractDaoTestCase { @Test(expected = IllegalStateException.class) public void update() { dao.update(session, new ComponentDto() - .setId(1L) - .setKey("org.struts:struts-core:src/org/struts/RequestContext.java") - ); + .setId(1L) + .setKey("org.struts:struts-core:src/org/struts/RequestContext.java") + ); } @Test @@ -401,9 +424,9 @@ public class ComponentDaoTest extends AbstractDaoTestCase { setupData("shared"); dao.delete(session, new ComponentDto() - .setId(1L) - .setKey("org.struts:struts-core:src/org/struts/RequestContext.java") - ); + .setId(1L) + .setKey("org.struts:struts-core:src/org/struts/RequestContext.java") + ); session.commit(); checkTable("delete", "projects"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/db/SnapshotDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/db/SnapshotDaoTest.java index f799082745f..3308afc1515 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/db/SnapshotDaoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/db/SnapshotDaoTest.java @@ -185,6 +185,26 @@ public class SnapshotDaoTest extends AbstractDaoTestCase { assertThat(snapshots).onProperty("id").containsOnly(1L, 6L); } + @Test + public void find_children_modules() { + setupData("modules"); + + // From root project + List snapshots = sut.findChildrenModulesFromModule(session, "org.struts:struts"); + assertThat(snapshots).hasSize(2); + assertThat(snapshots).onProperty("id").containsOnly(2L, 3L); + assertThat(snapshots).onProperty("last").containsOnly(true); + + // From module + snapshots = sut.findChildrenModulesFromModule(session, "org.struts:struts-core"); + assertThat(snapshots).hasSize(1); + assertThat(snapshots).onProperty("id").containsOnly(3L); + + // From sub module + snapshots = sut.findChildrenModulesFromModule(session, "org.struts:struts-data"); + assertThat(snapshots).isEmpty(); + } + @Test public void set_snapshot_and_children_to_false_and_status_processed() { setupData("snapshots"); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/component/db/SnapshotDaoTest/modules.xml b/server/sonar-server/src/test/resources/org/sonar/server/component/db/SnapshotDaoTest/modules.xml new file mode 100644 index 00000000000..8bc9decea38 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/component/db/SnapshotDaoTest/modules.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sonar-core/src/main/java/org/sonar/core/component/ProjectRefentialsComponentDto.java b/sonar-core/src/main/java/org/sonar/core/component/ProjectRefentialsComponentDto.java new file mode 100644 index 00000000000..e531993ce5d --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/component/ProjectRefentialsComponentDto.java @@ -0,0 +1,37 @@ +/* + * 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; + } +} diff --git a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java index 37c0a894ae8..789af967e65 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentMapper.java @@ -17,10 +17,12 @@ * 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.db; import org.apache.ibatis.annotations.Param; import org.sonar.core.component.ComponentDto; +import org.sonar.core.component.ProjectRefentialsComponentDto; import javax.annotation.CheckForNull; @@ -72,12 +74,16 @@ public interface ComponentMapper { * Warning, projectId are always null */ List findByUuids(@Param("uuids") Collection uuids); - /** * Return all project (PRJ/TRK) uuids */ List findProjectUuids(); + /** + * Return all modules children (not returning itself) from a module key + */ + List findChildrenModulesFromModule(@Param("moduleKey") String moduleKey); + long countById(long id); void insert(ComponentDto rule); diff --git a/sonar-core/src/main/java/org/sonar/core/component/db/SnapshotMapper.java b/sonar-core/src/main/java/org/sonar/core/component/db/SnapshotMapper.java index fd9d1c1188b..31f1167a686 100644 --- a/sonar-core/src/main/java/org/sonar/core/component/db/SnapshotMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/component/db/SnapshotMapper.java @@ -43,6 +43,8 @@ public interface SnapshotMapper { List selectSnapshotAndChildrenOfScope(@Param(value = "snapshot") Long resourceId, @Param(value = "scope") String scope); + List selectChildrenModulesFromModule(@Param(value = "moduleKey") String moduleKey); + int updateSnapshotAndChildrenLastFlagAndStatus(@Param(value = "root") Long rootId, @Param(value = "pathRootId") Long pathRootId, @Param(value = "path") String path, @Param(value = "isLast") boolean isLast, @Param(value = "status") String status); diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java index 7785eba83c8..a06112e2597 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java @@ -17,6 +17,7 @@ * 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.persistence; import ch.qos.logback.classic.Level; @@ -35,6 +36,7 @@ import org.sonar.core.activity.db.ActivityDto; 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; @@ -129,6 +131,7 @@ public class MyBatis implements BatchComponent, ServerComponent { 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); diff --git a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java index 9ba8f2468fa..4fa7f90797e 100644 --- a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java +++ b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java @@ -17,6 +17,7 @@ * 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.properties; import com.google.common.base.Preconditions; @@ -121,6 +122,10 @@ public class PropertiesDao implements BatchComponent, ServerComponent, DaoCompon } } + public List findChildrenModuleProperties(String moduleKey, SqlSession session) { + return session.getMapper(PropertiesMapper.class).selectChildrenModuleProperties(moduleKey); + } + public PropertyDto selectProjectProperty(long resourceId, String propertyKey) { SqlSession session = mybatis.openSession(false); PropertiesMapper mapper = session.getMapper(PropertiesMapper.class); diff --git a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesMapper.java b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesMapper.java index 10f298b53c3..3fc4311c509 100644 --- a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesMapper.java @@ -17,6 +17,7 @@ * 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.properties; import org.apache.ibatis.annotations.Param; @@ -43,6 +44,8 @@ public interface PropertiesMapper { List selectByQuery(@Param("query") PropertyQuery query); + List selectChildrenModuleProperties(@Param("moduleKey") String moduleKey); + void update(PropertyDto property); void insert(PropertyDto property); diff --git a/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml index 685f8e42d40..2af4bfc0438 100644 --- a/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/component/db/ComponentMapper.xml @@ -132,6 +132,14 @@ + + + + + + SELECT + FROM snapshots s + INNER JOIN snapshots root_snapshot ON root_snapshot.id = s.root_snapshot_id AND root_snapshot.islast = ${_true} + INNER JOIN snapshots current_snapshot ON current_snapshot.root_project_id = root_snapshot.project_id AND s.islast = ${_true} + INNER JOIN projects module ON module.id = current_snapshot.project_id AND module.enabled = ${_true} AND module.kee = #{moduleKey} + + AND s.islast = ${_true} + AND s.scope = 'PRJ' + AND + + s.path LIKE current_snapshot.path + CAST(current_snapshot.id AS varchar(15)) + '.%' + + + s.path LIKE concat(current_snapshot.path, current_snapshot.id, '.%') + + + s.path LIKE current_snapshot.path || current_snapshot.id || '.%' + + + + + (parent_snapshot_id, root_snapshot_id, root_project_id, project_id, created_at, build_date, status, purge_status, islast, scope, qualifier, version, path, depth, diff --git a/sonar-core/src/main/resources/org/sonar/core/properties/PropertiesMapper.xml b/sonar-core/src/main/resources/org/sonar/core/properties/PropertiesMapper.xml index dedc3d19362..d86d22e817c 100644 --- a/sonar-core/src/main/resources/org/sonar/core/properties/PropertiesMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/properties/PropertiesMapper.xml @@ -45,6 +45,14 @@ where p.resource_id=#{resourceId} and p.user_id is null + +