Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"resolved": false,
"removalTime": null,
"rootProcessInstanceId": "aRootProcessInstanceId",
"annotation": "an annotation"
"annotation": "an annotation",
"rootCauseIncidentMessage": "aRootCauseIncidentMessage"
},
{
"id": "anIncidentId",
Expand All @@ -81,7 +82,8 @@
"resolved": true,
"removalTime": "2018-02-10T14:33:19.000+0200",
"rootProcessInstanceId": "aRootProcessInstanceId",
"annotation": "another annotation"
"annotation": "another annotation",
"rootCauseIncidentMessage": "anotherRootCauseIncidentMessage"
}
]
}']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class HistoricIncidentDto {
protected Boolean deleted;
protected Boolean resolved;
protected String annotation;
protected String rootCauseIncidentMessage;

public String getId() {
return id;
Expand Down Expand Up @@ -142,6 +143,10 @@ public String getAnnotation() {
return annotation;
}

public String getRootCauseIncidentMessage() {
return rootCauseIncidentMessage;
}

public static HistoricIncidentDto fromHistoricIncident(HistoricIncident historicIncident) {
HistoricIncidentDto dto = new HistoricIncidentDto();

Expand All @@ -168,6 +173,7 @@ public static HistoricIncidentDto fromHistoricIncident(HistoricIncident historic
dto.removalTime = historicIncident.getRemovalTime();
dto.rootProcessInstanceId = historicIncident.getRootProcessInstanceId();
dto.annotation = historicIncident.getAnnotation();
dto.rootCauseIncidentMessage = historicIncident.getRootCauseIncidentMessage();

return dto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ public abstract class MockProvider {
public static final String EXAMPLE_HIST_INCIDENT_PROC_DEF_KEY = "aProcDefKey";
public static final String EXAMPLE_HIST_INCIDENT_ROOT_PROC_INST_ID = "aRootProcInstId";
public static final String EXAMPLE_HIST_INCIDENT_CAUSE_INCIDENT_ID = "aCauseIncidentId";
public static final String EXAMPLE_HIST_ROOT_CAUSE_INCIDENT_MSG = "aRootCauseIncidentMessage";
public static final String EXAMPLE_HIST_INCIDENT_ROOT_CAUSE_INCIDENT_ID = "aRootCauseIncidentId";
public static final String EXAMPLE_HIST_INCIDENT_CONFIGURATION = "aConfiguration";
public static final String EXAMPLE_HIST_INCIDENT_HISTORY_CONFIGURATION = "aHistoryConfiguration";
Expand Down Expand Up @@ -2644,6 +2645,19 @@ public static HistoricIncident createMockHistoricIncident() {
return createMockHistoricIncident(EXAMPLE_TENANT_ID);
}

public static HistoricIncident createMockHistoricIncidentWithoutRootCauseIncidentMessage() {
HistoricIncident incident = createMockHistoricIncident(EXAMPLE_TENANT_ID);
when(incident.getRootCauseIncidentMessage()).thenReturn(null);
return incident;
}

public static List<HistoricIncident> createMockHistoricIncidentsWithoutRootCauseIncidentMessage() {
List<HistoricIncident> entries = new ArrayList<>();
entries.add(createMockHistoricIncidentWithoutRootCauseIncidentMessage());
return entries;
}


public static HistoricIncident createMockHistoricIncident(String tenantId) {
HistoricIncident incident = mock(HistoricIncident.class);

Expand All @@ -2669,6 +2683,7 @@ public static HistoricIncident createMockHistoricIncident(String tenantId) {
when(incident.getRemovalTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HIST_INCIDENT_REMOVAL_TIME));
when(incident.getRootProcessInstanceId()).thenReturn(EXAMPLE_HIST_INCIDENT_ROOT_PROC_INST_ID);
when(incident.getAnnotation()).thenReturn(EXAMPLE_USER_OPERATION_ANNOTATION);
when(incident.getRootCauseIncidentMessage()).thenReturn(EXAMPLE_HIST_ROOT_CAUSE_INCIDENT_MSG);

return incident;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ public void testSimpleHistoricTaskInstanceQuery() {
Date returnedRemovalTime = DateTimeUtil.parseDate(from(content).getString("[0].removalTime"));
String returnedRootProcessInstanceId = from(content).getString("[0].rootProcessInstanceId");
String returnedAnnotation = from(content).getString("[0].annotation");
String returnedRootCauseIncidentMessage = from(content).getString("[0].rootCauseIncidentMessage");

Assert.assertEquals(MockProvider.EXAMPLE_HIST_INCIDENT_ID, returnedId);
Assert.assertEquals(MockProvider.EXAMPLE_HIST_INCIDENT_PROC_INST_ID, returnedProcessInstanceId);
Expand All @@ -413,6 +414,7 @@ public void testSimpleHistoricTaskInstanceQuery() {
Assert.assertEquals(DateTimeUtil.parseDate(MockProvider.EXAMPLE_HIST_INCIDENT_REMOVAL_TIME), returnedRemovalTime);
Assert.assertEquals(MockProvider.EXAMPLE_HIST_INCIDENT_ROOT_PROC_INST_ID, returnedRootProcessInstanceId);
Assert.assertEquals(MockProvider.EXAMPLE_USER_OPERATION_ANNOTATION, returnedAnnotation);
Assert.assertEquals(MockProvider.EXAMPLE_HIST_ROOT_CAUSE_INCIDENT_MSG, returnedRootCauseIncidentMessage);

}

Expand Down Expand Up @@ -723,4 +725,39 @@ public void testQueryByJobDefinitionIds() {
verify(mockedQuery).list();
}

@Test
public void testIncidentWithRootCauseIncidentMessage() {
Response response = given()
.then().expect()
.statusCode(Status.OK.getStatusCode())
.when()
.get(HISTORY_INCIDENT_QUERY_URL);

verify(mockedQuery).list();

String content = response.asString();
List<String> incidents = from(content).getList("");
assertThat(incidents).hasSize(1);

assertThat(from(content).getString("[0].rootCauseIncidentMessage")).isEqualTo(MockProvider.EXAMPLE_HIST_ROOT_CAUSE_INCIDENT_MSG);
}

@Test
public void testIncidentWithoutRootCauseIncidentMessage() {
mockedQuery = setUpMockHistoricIncidentQuery(MockProvider.createMockHistoricIncidentsWithoutRootCauseIncidentMessage());
Response response = given()
.then().expect()
.statusCode(Status.OK.getStatusCode())
.when()
.get(HISTORY_INCIDENT_QUERY_URL);

verify(mockedQuery).list();

String content = response.asString();
List<String> incidents = from(content).getList("");
assertThat(incidents).hasSize(1);

assertThat(from(content).getString("[0].rootCauseIncidentMessage")).isNull();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,9 @@ public interface HistoricIncident {
* Returns the annotation of this incident
*/
String getAnnotation();

/**
* Returns the incident message of the root incident
*/
String getRootCauseIncidentMessage();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class HistoricIncidentEventEntity extends HistoryEvent {
protected String historyConfiguration;
protected String failedActivityId;
protected String annotation;
protected String rootCauseIncidentMessage;

public Date getCreateTime() {
return createTime;
Expand Down Expand Up @@ -171,4 +172,12 @@ public void setAnnotation(String annotation) {
this.annotation = annotation;
}

public String getRootCauseIncidentMessage() {
return rootCauseIncidentMessage;
}

public void setRootCauseIncidentMessage(String rootCauseIncidentMessage) {
this.rootCauseIncidentMessage = rootCauseIncidentMessage;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -388,23 +388,29 @@
<result property="removalTime" column="REMOVAL_TIME_" jdbcType="TIMESTAMP"/>
</resultMap>

<resultMap id="historicIncidentResultWithRootCauseIncidentMessageMap" type="org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity" extends="historicIncidentResultMap">
<result property="rootCauseIncidentMessage" column="ROOT_CAUSE_INCIDENT_MESSAGE_" jdbcType="VARCHAR"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick:
to keep consistent and short lets also abbreviate message here like in the other message field:

Suggested change
<result property="rootCauseIncidentMessage" column="ROOT_CAUSE_INCIDENT_MESSAGE_" jdbcType="VARCHAR"/>
<result property="rootCauseIncidentMessage" column="ROOT_CAUSE_INCIDENT_MSG_" jdbcType="VARCHAR"/>

</resultMap>

<!-- HISTORIC INCIDENT SELECT -->

<select id="selectHistoricIncidentById" resultMap="historicIncidentResultMap">
select RES.* from ${prefix}ACT_HI_INCIDENT RES where RES.ID_ = #{id}
</select>

<select id="selectHistoricIncidentByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.HistoricIncidentQueryImpl" resultMap="historicIncidentResultMap">
<select id="selectHistoricIncidentByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.HistoricIncidentQueryImpl" resultMap="historicIncidentResultWithRootCauseIncidentMessageMap">
<bind name="includeRootCauseIncidentMessage" value="'Y'"/>
<include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.bindOrderBy"/>
${limitBefore}
select ${distinct} RES.*
select ${distinct} RES.*, ROOT_INCIDENT.INCIDENT_MSG_ as ROOT_CAUSE_INCIDENT_MESSAGE_
${limitBetween}
<include refid="selectHistoricIncidentByQueryCriteriaSql"/>
${orderBy}
${limitAfter}
</select>

<select id="selectHistoricIncidentCountByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.HistoricIncidentQueryImpl" resultType="long">
<bind name="includeRootCauseIncidentMessage" value="'N'"/>
${countDistinctBeforeStart} RES.ID_ ${countDistinctBeforeEnd}
<include refid="selectHistoricIncidentByQueryCriteriaSql"/>
${countDistinctAfterEnd}
Expand All @@ -429,6 +435,11 @@
)
</if>

<if test="includeRootCauseIncidentMessage == 'Y'">
left join ${prefix}ACT_HI_INCIDENT ROOT_INCIDENT
on ROOT_INCIDENT.ID_ = RES.ROOT_CAUSE_INCIDENT_ID_
</if>

<where>
<if test="id != null">
RES.ID_ = #{id}
Expand Down