aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMichal Duda <michal.duda@sonarsource.com>2019-02-01 12:51:32 +0100
committerSonarTech <sonartech@sonarsource.com>2019-02-18 20:20:55 +0100
commit2b8cc73a602be586c15754f7d87242dbaa5ccfd7 (patch)
tree9e0a974b045fa96f97fed0ea2620ddccf4545743 /server
parente89a888d560520c69f01e45fc5c9649e76fba30d (diff)
downloadsonarqube-2b8cc73a602be586c15754f7d87242dbaa5ccfd7.tar.gz
sonarqube-2b8cc73a602be586c15754f7d87242dbaa5ccfd7.zip
SONARCLOUD-336: Automatically guess the projectKey/organization
Diffstat (limited to 'server')
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java3
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml11
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmDbTester.java8
5 files changed, 27 insertions, 1 deletions
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
index c42071ea97a..a1b5cb3f75a 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
@@ -123,7 +123,7 @@ public class ComputeEngineContainerImplTest {
+ 26 // level 1
+ 60 // content of DaoModule
+ 3 // content of EsModule
- + 53 // content of CorePropertyDefinitions
+ + 54 // content of CorePropertyDefinitions
+ 1 // StopFlagContainer
);
assertThat(
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
index 9ff0aa9e174..eca30f4dcd1 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
@@ -430,4 +430,8 @@ public class ComponentDao implements Dao {
return mapper(dbSession).selectPrivateProjectsWithNcloc(organizationUuid);
}
+ public Optional<ComponentDto> selectByAlmIdAndAlmRepositoryId(DbSession dbSession, String almId, String almRepositoryId) {
+ return Optional.ofNullable(mapper(dbSession).selectByAlmIdAndAlmRepositoryId(almId, almRepositoryId));
+ }
+
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
index 86cac939a71..fac6f2c06da 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
@@ -45,6 +45,9 @@ public interface ComponentMapper {
@CheckForNull
ComponentDto selectByUuid(String uuid);
+ @CheckForNull
+ ComponentDto selectByAlmIdAndAlmRepositoryId(@Param("almId") String almId, @Param("almRepositoryId") String almRepositoryId);
+
/**
* Return sub project of component keys
*/
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index fc0a1a5cf37..cbe0e28ce31 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -80,6 +80,17 @@
p.uuid=#{uuid,jdbcType=VARCHAR}
</select>
+ <select id="selectByAlmIdAndAlmRepositoryId" resultType="Component">
+ select
+ <include refid="componentColumns"/>
+ from
+ projects p
+ inner join
+ project_alm_bindings pab on pab.project_uuid = p.uuid
+ where
+ pab.alm_id = #{almId,jdbcType=VARCHAR} and pab.repo_id = #{almRepositoryId,jdbcType=VARCHAR}
+ </select>
+
<select id="selectByProjectUuid" parameterType="string" resultType="Component">
select
<include refid="componentColumns"/>
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmDbTester.java b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmDbTester.java
index f18767c6db1..5b015586bf1 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmDbTester.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmDbTester.java
@@ -22,6 +22,7 @@ package org.sonar.db.alm;
import java.util.Arrays;
import java.util.function.Consumer;
import org.sonar.db.DbTester;
+import org.sonar.db.component.ComponentDto;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.user.UserDto;
@@ -44,6 +45,13 @@ public class AlmDbTester {
return db.getDbClient().organizationAlmBindingDao().selectByOrganization(db.getSession(), organization).get();
}
+ public ProjectAlmBindingDto insertProjectAlmBinding(ALM alm, ComponentDto componentDto, String repositoryUuid) {
+ db.getDbClient().projectAlmBindingsDao().insertOrUpdate(db.getSession(), alm, repositoryUuid, componentDto.uuid(),
+ "some_org/some_repo", "http://alm/some_org_some_repo");
+ db.commit();
+ return db.getDbClient().projectAlmBindingsDao().selectByProjectUuid(db.getSession(), componentDto.uuid()).get();
+ }
+
@SafeVarargs
public final AlmAppInstallDto insertAlmAppInstall(Consumer<AlmAppInstallDto>... dtoPopulators) {
AlmAppInstallDto dto = new AlmAppInstallDto()