aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorGuillaume Jambet <guillaume.jambet@sonarsource.com>2018-04-10 14:01:46 +0200
committerSonarTech <sonartech@sonarsource.com>2018-04-26 20:20:50 +0200
commita4f510d4548b71357412fcd0b6cac70ca1ec4277 (patch)
tree412db6f1aec4ea3799a472be9804fddce0e569af /server/sonar-db-dao
parent99044b2859e0867684a6f5bb72129fdbd341cc4a (diff)
downloadsonarqube-a4f510d4548b71357412fcd0b6cac70ca1ec4277.tar.gz
sonarqube-a4f510d4548b71357412fcd0b6cac70ca1ec4277.zip
SONAR-10544 save externally defined Rules if needed
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java6
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDefinitionDto.java3
2 files changed, 8 insertions, 1 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java
index 65f78d58d9f..ebf033b8316 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDao.java
@@ -25,6 +25,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import javax.annotation.Nullable;
+
import org.apache.ibatis.session.ResultHandler;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleQuery;
@@ -49,6 +50,11 @@ public class RuleDao implements Dao {
return ofNullable(res);
}
+ public RuleDto selectOrFailByKey(DbSession session, RuleKey key) {
+ RuleDefinitionDto ruleDefinitionDto = selectOrFailDefinitionByKey(session, key);
+ return new RuleDto(ruleDefinitionDto, new RuleMetadataDto());
+ }
+
public Optional<RuleDefinitionDto> selectDefinitionByKey(DbSession session, RuleKey key) {
return ofNullable(mapper(session).selectDefinitionByKey(key));
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDefinitionDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDefinitionDto.java
index 1b072c46594..c4180028480 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDefinitionDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDefinitionDto.java
@@ -122,11 +122,12 @@ public class RuleDefinitionDto {
return this;
}
+ @CheckForNull
public String getDescriptionURL() {
return descriptionURL;
}
- public RuleDefinitionDto setDescriptionURL(String descriptionURL) {
+ public RuleDefinitionDto setDescriptionURL(@Nullable String descriptionURL) {
this.descriptionURL = descriptionURL;
return this;
}