diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-05 14:48:10 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-05 14:48:19 +0200 |
commit | 738c12ac2aeadb0e7abc2e4f92fc169186e6aa58 (patch) | |
tree | 79322c9a3a5a5e1dc237f1fd2e6b6c91bc42b814 /sonar-core | |
parent | 6cdc8d925b22dcc9a6b92313e7e458197334ae4c (diff) | |
download | sonarqube-738c12ac2aeadb0e7abc2e4f92fc169186e6aa58.tar.gz sonarqube-738c12ac2aeadb0e7abc2e4f92fc169186e6aa58.zip |
SONAR-5007 improve restore, copy and reset of Q profiles
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java | 18 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDto.java | 2 |
2 files changed, 14 insertions, 6 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java index 9e0943936b0..2f81053f2e4 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java @@ -39,10 +39,18 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { } @CheckForNull - public QualityProfileDto getByKey(QualityProfileKey key, DbSession session) { + public QualityProfileDto getByKey(DbSession session, QualityProfileKey key) { return session.getMapper(QualityProfileMapper.class).selectByNameAndLanguage(key.name(), key.lang()); } + public QualityProfileDto getNonNullByKey(DbSession session, QualityProfileKey key) { + QualityProfileDto dto = getByKey(session, key); + if (dto == null) { + throw new IllegalArgumentException("Quality profile not found: " + key); + } + return dto; + } + public List<QualityProfileDto> findAll(DbSession session) { return session.getMapper(QualityProfileMapper.class).selectAll(); } @@ -185,7 +193,7 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { /** * @deprecated Replaced by - * {@link #getByKey(QualityProfileKey, DbSession)} + * {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)} */ @Deprecated @CheckForNull @@ -195,7 +203,7 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { /** * @deprecated Replaced by - * {@link #getByKey(QualityProfileKey, DbSession)} + * {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)} */ @Deprecated @CheckForNull @@ -265,7 +273,7 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { /** * @deprecated Replaced by - * {@link #getByKey(QualityProfileKey, DbSession)} + * {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)} */ @Deprecated public QualityProfileDto selectByNameAndLanguage(String name, String language, DbSession session) { @@ -274,7 +282,7 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { /** * @deprecated Replaced by - * {@link #getByKey(QualityProfileKey, DbSession)} + * {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)} */ @Deprecated public QualityProfileDto selectByNameAndLanguage(String name, String language) { diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDto.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDto.java index ed8cec9002f..56262219af3 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDto.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDto.java @@ -116,7 +116,7 @@ public class QualityProfileDto extends Dto<QualityProfileKey> { return new QualityProfileDto() .setName(name) .setLanguage(language) - .setUsed(true) + .setUsed(false) .setVersion(1); } |