package org.sonar.server.issue.db;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
import org.sonar.api.utils.System2;
import org.sonar.core.issue.db.IssueDto;
import org.sonar.core.issue.db.IssueMapper;
import org.sonar.core.persistence.DbSession;
import org.sonar.server.db.BaseDao;
+import java.sql.Timestamp;
+import java.util.Date;
+
public class IssueDao extends BaseDao<IssueMapper, IssueDto, String> implements DaoComponent {
public IssueDao() {
protected IssueDto doGetNullableByKey(DbSession session, String key) {
return mapper(session).selectByKey(key);
}
+
+ @Override
+ protected IssueDto doUpdate(DbSession session, IssueDto issue) {
+ mapper(session).update(issue);
+ return issue;
+ }
+
+ @Override
+ protected IssueDto doInsert(DbSession session, IssueDto issue) {
+ Preconditions.checkNotNull(issue.getKey(), "Cannot insert Issue with empty key!");
+ Preconditions.checkNotNull(issue.getComponentId(), "Cannot insert Issue with no Component!");
+ mapper(session).insert(issue);
+ return issue;
+ }
+
+ @Override
+ protected Iterable<IssueDto> findAfterDate(DbSession session, Date date) {
+ return mapper(session).selectAfterDate(new Timestamp(date.getTime()));
+ }
}
--- /dev/null
+package org.sonar.server.issue.db;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.utils.DateUtils;
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.AbstractDaoTestCase;
+import org.sonar.core.persistence.DbSession;
+
+import java.util.Date;
+
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class IssueDaoTest extends AbstractDaoTestCase {
+
+ private IssueDao dao;
+ private DbSession session;
+ private System2 system2;
+
+ @Before
+ public void before() throws Exception {
+ this.session = getMyBatis().openSession(false);
+ this.system2 = mock(System2.class);
+ this.dao = new IssueDao(system2);
+ }
+
+ @After
+ public void after() {
+ this.session.close();
+ }
+
+ @Test
+ public void find_after_dates() throws Exception {
+ setupData("shared", "should_select_all");
+
+ Date t0 = new Date(0);
+ assertThat(dao.findAfterDate(session, t0)).hasSize(3);
+
+ Date t2014 = DateUtils.parseDate("2014-01-01");
+ assertThat(dao.findAfterDate(session, t2014)).hasSize(1);
+ }
+}
--- /dev/null
+<dataset>
+
+ <group_roles id="1" group_id="[null]" resource_id="399" role="user"/>
+
+ <projects id="399" kee="struts" root_id="[null]" qualifier="TRK" scope="PRJ"/>
+ <projects id="400" kee="struts-core" root_id="399" qualifier="BRC" scope="PRJ"/>
+ <projects id="401" kee="Action.java" root_id="400" qualifier="CLA" scope="PRJ"/>
+ <projects id="402" kee="Filter.java" root_id="400" qualifier="CLA" scope="PRJ"/>
+
+ <snapshots id="100" project_id="399" root_snapshot_id="[null]" parent_snapshot_id="[null]" root_project_id="399"
+ path="" islast="[true]"/>
+ <snapshots id="101" project_id="400" root_snapshot_id="100" parent_snapshot_id="100" root_project_id="399" path="100."
+ islast="[true]"/>
+ <snapshots id="102" project_id="401" root_snapshot_id="100" parent_snapshot_id="101" root_project_id="399"
+ path="100.101." islast="[true]"/>
+ <snapshots id="103" project_id="402" root_snapshot_id="100" parent_snapshot_id="101" root_project_id="399"
+ path="100.101." islast="[true]"/>
+
+ <rules id="500" tags="[null]" system_tags="[null]" plugin_rule_key="AvoidCycle" plugin_name="squid" language="java"/>
+ <rules id="501" tags="[null]" system_tags="[null]" plugin_rule_key="NullRef" plugin_name="squid" language="xoo"/>
+
+</dataset>
--- /dev/null
+<dataset>
+
+ <!-- rule 500 -->
+ <issues
+ id="100"
+ kee="ABCDE-1"
+ component_id="401"
+ root_component_id="399"
+ rule_id="500"
+ severity="BLOCKER"
+ manual_severity="[false]"
+ message="[null]"
+ line="200"
+ effort_to_fix="4.2"
+ status="OPEN"
+ resolution="FIXED"
+ checksum="XXX"
+ reporter="arthur"
+ assignee="perceval"
+ author_login="[null]"
+ issue_attributes="JIRA=FOO-1234"
+ issue_creation_date="2013-04-16"
+ issue_update_date="2013-04-16"
+ issue_close_date="2013-04-16"
+ created_at="2013-04-16"
+ updated_at="2013-04-16"
+ />
+
+ <issues
+ id="101"
+ kee="ABCDE-2"
+ component_id="401"
+ root_component_id="399"
+ rule_id="500"
+ severity="BLOCKER"
+ manual_severity="[false]"
+ message="[null]"
+ line="200"
+ effort_to_fix="4.2"
+ status="OPEN"
+ resolution="FIXED"
+ checksum="XXX"
+ reporter="arthur"
+ assignee="perceval"
+ author_login="[null]"
+ issue_attributes="JIRA=FOO-1234"
+ issue_creation_date="2013-04-16"
+ issue_update_date="2013-04-16"
+ issue_close_date="2013-04-16"
+ created_at="2013-04-16"
+ updated_at="2013-04-16"
+ />
+
+
+ <!-- rule 501 -->
+ <issues
+ id="102"
+ kee="ABCDE-3"
+ component_id="401"
+ root_component_id="399"
+ rule_id="501"
+ severity="BLOCKER"
+ manual_severity="[false]"
+ message="[null]"
+ line="200"
+ effort_to_fix="4.2"
+ status="OPEN"
+ resolution="FIXED"
+ checksum="XXX"
+ reporter="arthur"
+ assignee="perceval"
+ author_login="[null]"
+ issue_attributes="JIRA=FOO-1234"
+ issue_creation_date="2014-04-16"
+ issue_update_date="2014-04-16"
+ issue_close_date="2014-04-16"
+ created_at="2014-04-16"
+ updated_at="2014-04-16"
+ />
+</dataset>
import javax.annotation.Nullable;
+import java.sql.Timestamp;
import java.util.Collection;
import java.util.Date;
import java.util.List;
* If the role is null, then the authorisation check is disabled.
*/
List<IssueDto> selectIssueIds(@Param("query") IssueQuery query, @Param("componentRootKeys") Collection<String> componentRootKeys,
- @Nullable @Param("userId") Integer userId, @Nullable @Param("role") String role,
- @Param("maxResults") Integer maxResult);
+ @Nullable @Param("userId") Integer userId, @Nullable @Param("role") String role,
+ @Param("maxResults") Integer maxResult);
/**
* Return a none paginated list of authorized issues for a user.
* If the role is null, then the authorisation check is disabled.
*/
List<IssueDto> selectIssues(@Param("query") IssueQuery query, @Param("componentRootKeys") Collection<String> componentRootKeys,
- @Nullable @Param("userId") Integer userId, @Nullable @Param("role") String role);
-
+ @Nullable @Param("userId") Integer userId, @Nullable @Param("role") String role);
List<RuleDto> findRulesByComponent(@Param("componentKey") String componentKey, @Nullable @Param("createdAt") Date createdAtOrAfter);
int update(IssueDto issue);
int updateIfBeforeSelectedDate(IssueDto issue);
+
+ List<IssueDto> selectAfterDate(Timestamp timestamp);
}
*/
package org.sonar.core.rule;
-import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Result;
-import org.apache.ibatis.annotations.Select;
import org.sonar.api.rule.RuleKey;
import java.sql.Timestamp;
void deleteParameter(Integer paramId);
- final String SELECT_FIELDS="r.id,\n" +
- " r.plugin_rule_key as \"ruleKey\",\n" +
- " r.plugin_name as \"repositoryKey\",\n" +
- " r.description,\n" +
- " r.description_format as \"descriptionFormat\",\n" +
- " r.status,\n" +
- " r.name,\n" +
- " r.plugin_config_key as \"configKey\",\n" +
- " r.priority as \"severity\",\n" +
- " r.is_template as \"isTemplate\",\n" +
- " r.language as \"language\",\n" +
- " r.template_id as \"templateId\",\n" +
- " r.note_data as \"noteData\",\n" +
- " r.note_user_login as \"noteUserLogin\",\n" +
- " r.note_created_at as \"noteCreatedAt\",\n" +
- " r.note_updated_at as \"noteUpdatedAt\",\n" +
- " r.characteristic_id as \"subCharacteristicId\",\n" +
- " r.default_characteristic_id as \"defaultSubCharacteristicId\",\n" +
- " r.remediation_function as \"remediationFunction\",\n" +
- " r.default_remediation_function as \"defaultRemediationFunction\",\n" +
- " r.remediation_coeff as \"remediationCoefficient\",\n" +
- " r.default_remediation_coeff as \"defaultRemediationCoefficient\",\n" +
- " r.remediation_offset as \"remediationOffset\",\n" +
- " r.default_remediation_offset as \"defaultRemediationOffset\",\n" +
- " r.effort_to_fix_description as \"effortToFixDescription\",\n" +
- " r.tags as \"tagsField\",\n" +
- " r.system_tags as \"systemTagsField\",\n" +
- " r.created_at as \"createdAt\",\n" +
- " r.updated_at as \"updatedAt\"";
-
- @Select("SELECT " + SELECT_FIELDS + " FROM rules r WHERE r.updated_at IS NULL or r.updated_at >= #{date} ")
- @Options(fetchSize = 200, useCache = false, flushCache = true)
- @Result(javaType = RuleDto.class)
List<RuleDto> selectAfterDate(@Param("date") Timestamp timestamp);
}
</if>
</sql>
- <insert id="insert" parameterType="Issue" useGeneratedKeys="false" keyProperty="id" >
+ <insert id="insert" parameterType="Issue" useGeneratedKeys="false" keyProperty="id">
INSERT INTO issues (kee, component_id, root_component_id, rule_id, action_plan_key, severity, manual_severity,
message, line, effort_to_fix, technical_debt, status,
resolution, checksum, reporter, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
<!--
IMPORTANT - invariant columns can't be updated. See IssueDto#toDtoForUpdate()
-->
- <update id="update" parameterType="Issue" >
+ <update id="update" parameterType="Issue">
update issues set
action_plan_key=#{actionPlanKey},
severity=#{severity},
<!--
IMPORTANT - invariant columns can't be updated. See IssueDto#toDtoForUpdate()
-->
- <update id="updateIfBeforeSelectedDate" parameterType="Issue" >
+ <update id="updateIfBeforeSelectedDate" parameterType="Issue">
update issues set
action_plan_key=#{actionPlanKey},
severity=#{severity},
where i.kee=#{kee}
</select>
- <select id="selectNonClosedIssuesByModule" parameterType="int" resultType="Issue" >
+ <select id="selectAfterDate" resultType="Issue" resultSetType="FORWARD_ONLY" fetchSize="200">
select
- i.id,
- i.kee as kee,
- i.component_id as componentId,
- i.root_component_id as rootComponentId,
- i.rule_id as ruleId,
- i.action_plan_key as actionPlanKey,
- i.severity as severity,
- i.manual_severity as manualSeverity,
- i.message as message,
- i.line as line,
- i.effort_to_fix as effortToFix,
- i.technical_debt as debt,
- i.status as status,
- i.resolution as resolution,
- i.checksum as checksum,
- i.reporter as reporter,
- i.assignee as assignee,
- i.author_login as authorLogin,
- i.issue_attributes as issueAttributes,
- i.issue_creation_date as issueCreationDate,
- i.issue_update_date as issueUpdateDate,
- i.issue_close_date as issueCloseDate,
- i.created_at as createdAt,
- i.updated_at as updatedAt,
- r.plugin_rule_key as ruleKey,
- r.plugin_name as ruleRepo,
- p.kee as componentKey,
- root.kee as rootComponentKey
+ <include refid="issueColumns"/>
from issues i
- inner join (select p.id,p.kee from projects p where (p.root_id=#{id} and p.qualifier <> 'BRC') or (p.id=#{id})) p on p.id=i.component_id
+ inner join rules r on r.id=i.rule_id
+ inner join projects p on p.id=i.component_id
+ inner join projects root on root.id=i.root_component_id
+ where i.updated_at IS NULL or i.updated_at >= #{date}
+ </select>
+
+ <select id="selectNonClosedIssuesByModule" parameterType="int" resultType="Issue">
+ select
+ i.id,
+ i.kee as kee,
+ i.component_id as componentId,
+ i.root_component_id as rootComponentId,
+ i.rule_id as ruleId,
+ i.action_plan_key as actionPlanKey,
+ i.severity as severity,
+ i.manual_severity as manualSeverity,
+ i.message as message,
+ i.line as line,
+ i.effort_to_fix as effortToFix,
+ i.technical_debt as debt,
+ i.status as status,
+ i.resolution as resolution,
+ i.checksum as checksum,
+ i.reporter as reporter,
+ i.assignee as assignee,
+ i.author_login as authorLogin,
+ i.issue_attributes as issueAttributes,
+ i.issue_creation_date as issueCreationDate,
+ i.issue_update_date as issueUpdateDate,
+ i.issue_close_date as issueCloseDate,
+ i.created_at as createdAt,
+ i.updated_at as updatedAt,
+ r.plugin_rule_key as ruleKey,
+ r.plugin_name as ruleRepo,
+ p.kee as componentKey,
+ root.kee as rootComponentKey
+ from issues i
+ inner join (select p.id,p.kee from projects p where (p.root_id=#{id} and p.qualifier <> 'BRC') or
+ (p.id=#{id})) p on p.id=i.component_id
inner join rules r on r.id=i.rule_id
left outer join projects root on root.id=i.root_component_id
where i.status <> 'CLOSED'
inner join projects p on p.id=i.component_id
inner join projects root on root.id=i.root_component_id
where i.id in
- <foreach collection="list" open="(" close=")" item="id" separator=",">
- #{id}
- </foreach>
+ <foreach collection="list" open="(" close=")" item="id" separator=",">
+ #{id}
+ </foreach>
</select>
<select id="selectIssues" parameterType="map" resultType="Issue">
- select <include refid="issueColumns"/>
+ select
+ <include refid="issueColumns"/>
from issues i
inner join rules r on r.id=i.rule_id
inner join projects p on p.id=i.component_id
</select>
<select id="selectIssueIds" parameterType="map" resultType="Issue">
- select i.id <include refid="sortColumn"/>
+ select i.id
+ <include refid="sortColumn"/>
from issues i
<include refid="selectQueryConditions"/>
limit #{maxResults}
<!-- SQL Server -->
<select id="selectIssueIds" parameterType="map" resultType="Issue" databaseId="mssql">
- select top (#{maxResults}) i.id <include refid="sortColumn"/>
+ select top (#{maxResults}) i.id
+ <include refid="sortColumn"/>
from issues i
<include refid="selectQueryConditions"/>
</select>
<!-- Oracle -->
<select id="selectIssueIds" parameterType="map" resultType="Issue" databaseId="oracle">
select * from (select
- i.id <include refid="sortColumn"/>
- from issues i
- <include refid="selectQueryConditions"/>
+ i.id
+ <include refid="sortColumn"/>
+ from issues i
+ <include refid="selectQueryConditions"/>
)
where rownum <= #{maxResults}
</select>
<sql id="selectQueryConditions">
<if test="componentRootKeys.size() == 0 and role != null">
- inner join (<include refid="org.sonar.core.user.AuthorizationMapper.selectAuthorizedRootProjectIdsQuery" />) authorizedProjects on authorizedProjects.root_project_id=i.root_component_id
+ inner join (<include refid="org.sonar.core.user.AuthorizationMapper.selectAuthorizedRootProjectIdsQuery"/>)
+ authorizedProjects on authorizedProjects.root_project_id=i.root_component_id
</if>
<if test="componentRootKeys.size() > 0">
- inner join (<include refid="org.sonar.core.resource.ResourceMapper.selectAuthorizedChildrenComponentIdsQuery" />) authorizedComponents on authorizedComponents.project_id=i.component_id
+ inner join (<include refid="org.sonar.core.resource.ResourceMapper.selectAuthorizedChildrenComponentIdsQuery"/>)
+ authorizedComponents on authorizedComponents.project_id=i.component_id
</if>
<if test="query.components().size() > 0">
- inner join projects project_component on project_component.id=i.component_id and project_component.enabled=${_true} and
- <foreach item="component" index="index" collection="query.components()" open="(" separator=" or " close=")">project_component.kee=#{component}
+ inner join projects project_component on project_component.id=i.component_id and
+ project_component.enabled=${_true} and
+ <foreach item="component" index="index" collection="query.components()" open="(" separator=" or " close=")">
+ project_component.kee=#{component}
</foreach>
</if>
<if test="query.rules().size()>0 or query.languages().size()>0">
</if>
<where>
<if test="query.issueKeys().size()>0">
- and <foreach item="key" index="index" collection="query.issueKeys()" open="(" separator=" or " close=")">i.kee=#{key}
+ and
+ <foreach item="key" index="index" collection="query.issueKeys()" open="(" separator=" or " close=")">
+ i.kee=#{key}
</foreach>
</if>
<if test="query.severities().size()>0">
- and <foreach item="severity" index="index" collection="query.severities()" open="(" separator=" or " close=")">i.severity=#{severity}
+ and
+ <foreach item="severity" index="index" collection="query.severities()" open="(" separator=" or " close=")">
+ i.severity=#{severity}
</foreach>
</if>
<if test="query.statuses().size()>0">
- and <foreach item="status" index="index" collection="query.statuses()" open="(" separator=" or " close=")">i.status=#{status}
+ and
+ <foreach item="status" index="index" collection="query.statuses()" open="(" separator=" or " close=")">
+ i.status=#{status}
</foreach>
</if>
<if test="query.resolutions().size()>0">
- and <foreach item="resolution" index="index" collection="query.resolutions()" open="(" separator=" or " close=")">i.resolution=#{resolution}
+ and
+ <foreach item="resolution" index="index" collection="query.resolutions()" open="(" separator=" or " close=")">
+ i.resolution=#{resolution}
</foreach>
</if>
<if test="query.resolved() != null">
</if>
</if>
<if test="query.reporters().size()>0">
- and <foreach item="reporter" index="index" collection="query.reporters()" open="(" separator=" or " close=")">i.reporter=#{reporter}
+ and
+ <foreach item="reporter" index="index" collection="query.reporters()" open="(" separator=" or " close=")">
+ i.reporter=#{reporter}
</foreach>
</if>
<if test="query.assignees().size()>0">
- and <foreach item="assignee" index="index" collection="query.assignees()" open="(" separator=" or " close=")">i.assignee=#{assignee}
+ and
+ <foreach item="assignee" index="index" collection="query.assignees()" open="(" separator=" or " close=")">
+ i.assignee=#{assignee}
</foreach>
</if>
<if test="query.assigned() != null">
</sql>
<select id="findRulesByComponent" parameterType="String" resultType="Rule">
- SELECT <include refid="org.sonar.core.rule.RuleMapper.selectColumns" />
+ SELECT
+ <include refid="org.sonar.core.rule.RuleMapper.selectColumns"/>
FROM issues i
INNER JOIN projects p on p.id=i.component_id
INNER JOIN rules r on r.id=i.rule_id
WHERE
- p.kee=#{componentKey}
- AND i.resolution IS NULL
- <if test="createdAt != null">
- AND i.issue_creation_date >= #{createdAt}
- </if>
+ p.kee=#{componentKey}
+ AND i.resolution IS NULL
+ <if test="createdAt != null">
+ AND i.issue_creation_date >= #{createdAt}
+ </if>
</select>
<select id="findSeveritiesByComponent" parameterType="String" resultType="String">
INNER JOIN projects on projects.id=i.component_id
INNER JOIN rules on rules.id=i.rule_id
WHERE
- projects.kee=#{componentKey}
- AND i.resolution IS NULL
- <if test="createdAt != null">
- AND i.issue_creation_date >= #{createdAt}
- </if>
+ projects.kee=#{componentKey}
+ AND i.resolution IS NULL
+ <if test="createdAt != null">
+ AND i.issue_creation_date >= #{createdAt}
+ </if>
</select>
</mapper>
</sql>
<select id="selectAll" resultType="Rule">
- select <include refid="selectColumns"/> from rules r
+ select
+ <include refid="selectColumns"/>
+ from rules r
+ </select>
+
+ <select id="selectAfterDate" resultType="Rule" resultSetType="FORWARD_ONLY" fetchSize="200">
+ select
+ <include refid="selectColumns"/>
+ from rules r
+ where r.updated_at IS NULL or r.updated_at >= #{date}
</select>
<select id="selectEnablesAndNonManual" resultType="Rule">
- select <include refid="selectColumns"/> from rules r
+ select
+ <include refid="selectColumns"/>
+ from rules r
where r.status != 'REMOVED' and r.plugin_name != 'manual'
</select>
<select id="selectById" parameterType="Integer" resultType="Rule">
- select <include refid="selectColumns"/> from rules r WHERE r.id=#{id}
+ select
+ <include refid="selectColumns"/>
+ from rules r WHERE r.id=#{id}
</select>
<select id="selectByKey" parameterType="map" resultType="Rule">
- SELECT <include refid="selectColumns"/> FROM rules r WHERE r.plugin_name=#{repository} AND r.plugin_rule_key=#{rule}
+ SELECT
+ <include refid="selectColumns"/>
+ FROM rules r WHERE r.plugin_name=#{repository} AND r.plugin_rule_key=#{rule}
</select>
<select id="selectByName" parameterType="String" resultType="Rule">
- select <include refid="selectColumns"/> from rules r WHERE r.name=#{name}
+ select
+ <include refid="selectColumns"/>
+ from rules r WHERE r.name=#{name}
</select>
<select id="selectNonManual" resultType="Rule">
- select <include refid="selectColumns"/> from rules r
+ select
+ <include refid="selectColumns"/>
+ from rules r
where r.plugin_name != 'manual'
</select>
<select id="selectBySubCharacteristicId" resultType="Rule">
- select <include refid="selectColumns"/> from rules r
+ select
+ <include refid="selectColumns"/>
+ from rules r
where (r.characteristic_id=#{subCharacteristicId} or r.default_characteristic_id=#{subCharacteristicId})
</select>
</update>
<sql id="insertColumns">
- (plugin_rule_key, plugin_name, description, description_format, status, name, plugin_config_key, priority, is_template, language, template_id,
+ (plugin_rule_key, plugin_name, description, description_format, status, name, plugin_config_key, priority,
+ is_template, language, template_id,
characteristic_id, default_characteristic_id, remediation_function, default_remediation_function,
remediation_coeff, default_remediation_coeff, remediation_offset, default_remediation_offset,
effort_to_fix_description, tags, system_tags, note_data, note_user_login, note_created_at, note_updated_at,
</sql>
<insert id="insert" parameterType="Rule" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- insert into rules <include refid="insertColumns"/>
+ insert into rules
+ <include refid="insertColumns"/>
values (#{ruleKey}, #{repositoryKey}, #{description}, #{descriptionFormat}, #{status}, #{name}, #{configKey},
- #{severity}, #{isTemplate}, #{language}, #{templateId},
- #{subCharacteristicId}, #{defaultSubCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction},
- #{remediationCoefficient}, #{defaultRemediationCoefficient}, #{remediationOffset}, #{defaultRemediationOffset},
- #{effortToFixDescription}, #{tagsField}, #{systemTagsField}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt},
- #{noteUpdatedAt}, #{createdAt}, #{updatedAt})
+ #{severity}, #{isTemplate}, #{language}, #{templateId},
+ #{subCharacteristicId}, #{defaultSubCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction},
+ #{remediationCoefficient}, #{defaultRemediationCoefficient}, #{remediationOffset}, #{defaultRemediationOffset},
+ #{effortToFixDescription}, #{tagsField}, #{systemTagsField}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt},
+ #{noteUpdatedAt}, #{createdAt}, #{updatedAt})
</insert>
<insert id="batchInsert" parameterType="Rule" useGeneratedKeys="false">
- insert into rules <include refid="insertColumns"/>
+ insert into rules
+ <include refid="insertColumns"/>
values (#{ruleKey}, #{repositoryKey}, #{description}, #{descriptionFormat}, #{status}, #{name}, #{configKey},
#{severity}, #{isTemplate}, #{language}, #{templateId},
#{subCharacteristicId}, #{defaultSubCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction},
#{noteUpdatedAt}, #{createdAt}, #{updatedAt})
</insert>
- <delete id="deleteParams" parameterType="Integer" >
+ <delete id="deleteParams" parameterType="Integer">
delete from active_rule_parameters where rules_parameter_id=#{id}
</delete>
</sql>
<select id="selectAllParams" resultType="RuleParam">
- select <include refid="paramColumns"/>
+ select
+ <include refid="paramColumns"/>
from rules_parameters p
</select>
<select id="selectParamsByRuleIds" resultType="RuleParam">
- SELECT <include refid="paramColumns"/>
+ SELECT
+ <include refid="paramColumns"/>
FROM rules_parameters p
<where>
- AND (<foreach item="id" index="index" collection="ruleIds" open="(" separator=" or " close=")">p.rule_id=#{id}</foreach>)
+ AND (<foreach item="id" index="index" collection="ruleIds" open="(" separator=" or " close=")">
+ p.rule_id=#{id}</foreach>)
</where>
</select>
<select id="selectParamsByRuleKey" resultType="RuleParam" parameterType="org.sonar.api.rule.RuleKey">
- SELECT <include refid="paramColumns"/>
+ SELECT
+ <include refid="paramColumns"/>
FROM rules_parameters p, rules r
WHERE p.rule_id=r.id
AND r.plugin_name=#{repository} AND r.plugin_rule_key=#{rule}
</select>
<select id="selectParamByRuleAndKey" resultType="RuleParam">
- SELECT <include refid="paramColumns"/>
+ SELECT
+ <include refid="paramColumns"/>
FROM rules_parameters p
WHERE p.rule_id=#{ruleId} AND p.name=#{key}
</select>
- <delete id="deleteParameter" parameterType="Integer" >
+ <delete id="deleteParameter" parameterType="Integer">
delete from rules_parameters where id=#{id}
</delete>
- <insert id="insertParameter" parameterType="RuleParam" keyColumn="id" useGeneratedKeys="true" keyProperty="id" >
+ <insert id="insertParameter" parameterType="RuleParam" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO rules_parameters (rule_id, name, param_type, default_value, description)
VALUES (#{ruleId}, #{name}, #{type}, #{defaultValue}, #{description})
</insert>
- <update id="updateParameter" parameterType="RuleParam" >
+ <update id="updateParameter" parameterType="RuleParam">
UPDATE rules_parameters SET
- param_type=#{type},
- default_value=#{defaultValue},
- description=#{description}
+ param_type=#{type},
+ default_value=#{defaultValue},
+ description=#{description}
WHERE id=#{id}
</update>
</mapper>