<mapper namespace="org.sonar.db.report.RegulatoryReportMapper">
<resultMap id="issueResultMap" type="org.sonar.db.report.IssueFindingDto" autoMapping="true">
<id property="kee" column="kee"/>
- <collection property="comments" ofType="string">
- <result column="change_data"/>
+ <result property="severity" column="severity"/>
+ <result property="isManualSeverity" column="isManualSeverity"/>
+ <result property="message" column="message"/>
+ <result property="line" column="line"/>
+ <result property="status" column="status"/>
+ <result property="resolution" column="resolution"/>
+ <result property="fileName" column="fileName"/>
+ <result property="type" column="type"/>
+ <result property="ruleRepository" column="ruleRepository"/>
+ <result property="ruleKey" column="ruleKey"/>
+ <result property="securityStandards" column="securityStandards"/>
+ <result property="ruleName" column="ruleName"/>
+ <result property="creationDate" column="creationDate"/>
+ <result property="isNewCodeReferenceIssue" column="isNewCodeReferenceIssue"/>
+ <!--Usage of notNullColumn allows to skip creating objects which are not matching discriminator-->
+ <collection property="comments" ofType="string" notNullColumn="issue_change_kee">
+ <discriminator javaType="string" column="change_type" >
+ <case value="comment">
+ <result column="change_data"/>
+ </case>
+ </discriminator>
</collection>
</resultMap>
i.line as line,
i.status as status,
i.resolution as resolution,
- p.kee as componentKey,
p.path as fileName,
i.issue_type as type,
r.plugin_name as ruleRepository,
<include refid="org.sonar.db.issue.IssueMapper.isNewCodeReferenceIssue"/>
</sql>
- <select id="scrollIssues" parameterType="String" resultMap="issueResultMap" resultOrdered="true" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
+ <select id="scrollIssues" parameterType="String" resultMap="issueResultMap" resultOrdered="true"
+ fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
select
<include refid="issueColumns"/>,
+ ic.kee as issue_change_kee,
ic.change_data,
- ic.issue_change_creation_date
+ ic.change_type
from issues i
inner join rules r on r.uuid=i.rule_uuid
inner join components p on p.uuid=i.component_uuid
left join issue_changes ic on ic.issue_key = i.kee
left join new_code_reference_issues n on i.kee = n.issue_key
where i.project_uuid=#{branchUuid,jdbcType=VARCHAR}
- and (ic.change_type = 'comment' or ic.change_type is null)
and i.status !='CLOSED'
order by i.kee, ic.issue_change_creation_date
</select>
IssueDto issue3 = db.issues().insertIssue(rule, project, file, i -> i.setStatus("RESOLVED").setResolution(RESOLUTION_WONT_FIX));
// comments
- db.issues().insertChange(issue1, ic -> ic.setChangeData("c2").setIssueChangeCreationDate(2000L).setChangeType("comment"));
db.issues().insertChange(issue1, ic -> ic.setChangeData("c1").setIssueChangeCreationDate(1000L).setChangeType("comment"));
+ db.issues().insertChange(issue1, ic -> ic.setChangeData("c2").setIssueChangeCreationDate(2000L).setChangeType("comment"));
+ db.issues().insertChange(issue1, ic -> ic.setChangeData("c3").setIssueChangeCreationDate(3000L).setChangeType("diff").setKey(null));
+
+ db.issues().insertChange(issue2, ic -> ic.setChangeData("c4").setIssueChangeCreationDate(4000L).setChangeType("diff").setKey(null));
// not returned
IssueDto issue4 = db.issues().insertIssue(rule, project, file, i -> i.setStatus("CLOSED").setResolution(null));
assertThat(issue.getType().getDbConstant()).isEqualTo(issue1.getType());
assertThat(issue.getSecurityStandards()).isEqualTo(rule.getSecurityStandards());
assertThat(issue.isManualSeverity()).isEqualTo(issue1.isManualSeverity());
+ assertThat(issue.getCreationDate()).isEqualTo(issue1.getIssueCreationTime());
+ assertThat(issue.isNewCodeReferenceIssue()).isEqualTo(issue1.isNewCodeReferenceIssue());
+ assertThat(issue.getResolution()).isEqualTo(issue1.getResolution());
+ assertThat(issue.getStatus()).isEqualTo(issue1.getStatus());
assertThat(issue.getComments()).containsExactly("c1", "c2");
}
}