Skip to content

Commit

Permalink
fix(engine): allow querying for hist pis by async activities
Browse files Browse the repository at this point in the history
related to #4757
  • Loading branch information
tasso94 committed Nov 5, 2024
1 parent ab78ff5 commit cc93482
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 241 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
"activityIdIn": {
"type": "array",
"itemType": "string",
"desc": "Restrict to instances with an active activity with one of the given ids. This filter behaves differently as `activeActivityIdIn` since it also yields results when filtering for activities with an incident. ${listTypeDescription}"
"desc": "Restrict to instances with an active activity with one of the given ids. In contrast to the `activeActivityIdIn` filter, it can query for async and incident activities. ${listTypeDescription}"
},

"executedActivityIdIn": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ public interface HistoricProcessInstanceQuery extends Query<HistoricProcessInsta
HistoricProcessInstanceQuery activeActivityIdIn(String... ids);

/**
* Only select historic process instances with an active activity with one of the given ids. This filter behaves differently as `activeActivityIdIn` since it also yields results when filtering for activities with an incident.
* Only select historic process instances with an active activity with one of the given ids.
* In contrast to the `activeActivityIdIn` filter, it can query for async and incident activities.
*/
HistoricProcessInstanceQuery activityIdIn(String... ids);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@

<bind name="INC_JOIN" value="false" />
<bind name="HAI_JOIN" value="false" />
<bind name="INCACT_JOIN" value="false" />
<bind name="RU_EXE_JOIN" value="false" />
<bind name="JOIN_TYPE" value="'inner join'" />

<foreach collection="queries" item="query">
Expand All @@ -414,12 +414,12 @@
<bind name="INC_JOIN" value="true" />
</if>

<if test="query != null &amp;&amp; (query.executedActivityIds != null and query.executedActivityIds.length > 0) || (query.activeActivityIds != null and query.activeActivityIds.length > 0) || (query.activityIds != null and query.activityIds.length > 0)">
<if test="query != null &amp;&amp; (query.executedActivityIds != null and query.executedActivityIds.length > 0) || (query.activeActivityIds != null and query.activeActivityIds.length > 0)">
<bind name="HAI_JOIN" value="true" />
</if>

<if test="query != null &amp;&amp; (query.activityIds != null and query.activityIds.length > 0)">
<bind name="INCACT_JOIN" value="true" />
<bind name="RU_EXE_JOIN" value="true" />
</if>
</foreach>

Expand All @@ -430,9 +430,8 @@
LEFT JOIN ${prefix}ACT_HI_ACTINST HAI
ON HAI.PROC_INST_ID_ = SELF.ID_
</if>

<if test="INCACT_JOIN">
LEFT JOIN ${prefix}ACT_HI_INCIDENT INCACT on SELF.PROC_INST_ID_ = INCACT.PROC_INST_ID_
<if test="RU_EXE_JOIN">
LEFT JOIN ${prefix}ACT_RU_EXECUTION EXE on SELF.PROC_INST_ID_ = EXE.PROC_INST_ID_
</if>

<!-- actual value conditions are checked in the WHERE part;
Expand Down Expand Up @@ -643,19 +642,14 @@
)
</if>

<if test="query.activityIds != null and query.activityIds.length > 0">
${queryType} (
(
HAI.END_TIME_ IS NULL
AND HAI.ACT_ID_ IN
<foreach item="activityId" index="index" collection="query.activityIds" open="(" separator="," close=")">
#{activityId}
</foreach>
) OR INCACT.ACTIVITY_ID_ IN
<foreach item="activityId" index="index" collection="query.activityIds" open="(" separator="," close=")">
#{activityId}
</foreach>
)
<if test="query.activityIds != null &amp;&amp; query.activityIds.length > 0">
${queryType} (EXE.IS_EVENT_SCOPE_ = ${falseConstant}
and EXE.ACT_ID_ in
<foreach item="activityId" index="index" collection="query.activityIds"
open="(" separator="," close=")">
#{activityId}
</foreach>
)
</if>

<if test="query.executedActivityIds != null and query.executedActivityIds.length > 0">
Expand Down
Loading

0 comments on commit cc93482

Please sign in to comment.