diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-01-08 09:40:02 +0100 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-01-09 11:22:55 +0100 |
commit | 67d004788b04f297ecbea105c0b55be10ba77812 (patch) | |
tree | 733d9373e3fcec849f087bf9ddf33459feebf523 /sonar-core | |
parent | d0b736937c9e4e7affbe173e71ad72256f2e5a57 (diff) | |
download | sonarqube-67d004788b04f297ecbea105c0b55be10ba77812.tar.gz sonarqube-67d004788b04f297ecbea105c0b55be10ba77812.zip |
SONAR-4326 Start work on rule tags DAO
Diffstat (limited to 'sonar-core')
5 files changed, 73 insertions, 0 deletions
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 55e112bee13..f5cf9a16a6d 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 @@ -19,6 +19,8 @@ */ package org.sonar.core.persistence; +import org.sonar.core.rule.RuleTagDto; + import ch.qos.logback.classic.Level; import com.google.common.io.Closeables; import org.apache.ibatis.builder.xml.XMLMapperBuilder; @@ -117,6 +119,7 @@ public class MyBatis implements BatchComponent, ServerComponent { loadAlias(conf, "ResourceSnapshot", ResourceSnapshotDto.class); loadAlias(conf, "Rule", RuleDto.class); loadAlias(conf, "RuleParam", RuleParamDto.class); + loadAlias(conf, "RuleTag", RuleTagDto.class); loadAlias(conf, "Snapshot", SnapshotDto.class); loadAlias(conf, "Semaphore", SemaphoreDto.class); loadAlias(conf, "SchemaMigration", SchemaMigrationDto.class); diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java index 922efb2c782..a941792ba11 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java @@ -25,6 +25,7 @@ import org.sonar.api.ServerComponent; import org.sonar.core.persistence.MyBatis; import javax.annotation.CheckForNull; + import java.util.Collection; import java.util.List; @@ -170,4 +171,17 @@ public class RuleDao implements BatchComponent, ServerComponent { private RuleMapper getMapper(SqlSession session) { return session.getMapper(RuleMapper.class); } + + public List<RuleTagDto> selectTags(SqlSession session) { + return getMapper(session).selectAllTags(); + } + + public List<RuleTagDto> selectTags() { + SqlSession session = mybatis.openSession(); + try { + return selectTags(session); + } finally { + MyBatis.closeQuietly(session); + } + } } diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleMapper.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleMapper.java index 8c340b33569..3223d8db5af 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleMapper.java @@ -47,4 +47,6 @@ public interface RuleMapper { void insertParameter(RuleParamDto param); void updateParameter(RuleParamDto param); + + List<RuleTagDto> selectAllTags(); } diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleTagDto.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleTagDto.java new file mode 100644 index 00000000000..5ad3b7dd56b --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleTagDto.java @@ -0,0 +1,45 @@ +package org.sonar.core.rule; + +public class RuleTagDto { + + private Long id; + private Integer ruleId; + private String tag; + private String type; + + public Long getId() { + return id; + } + + public RuleTagDto setId(Long id) { + this.id = id; + return this; + } + + public Integer getRuleId() { + return ruleId; + } + + public RuleTagDto setRuleId(Integer ruleId) { + this.ruleId = ruleId; + return this; + } + + public String getTag() { + return tag; + } + + public RuleTagDto setTag(String tag) { + this.tag = tag; + return this; + } + + public String getType() { + return type; + } + + public RuleTagDto setType(String type) { + this.type = type; + return this; + } +} diff --git a/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml index 95063093b9a..c1d76bdc2c6 100644 --- a/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml @@ -119,5 +119,14 @@ WHERE id=#{id} </update> + <sql id="tagColumns"> + id, rule_id as "ruleId", tag, tag_type as "type" + </sql> + + <select id="selectAllTags" resultType="RuleTag"> + SELECT <include refid="tagColumns"/> + FROM rule_tags + </select> + </mapper> |