diff --git a/engine-rest/engine-rest-openapi/src/main/templates/lib/commons/history-process-instance.ftl b/engine-rest/engine-rest-openapi/src/main/templates/lib/commons/history-process-instance.ftl index 086b3aacceb..d5532b1cf92 100644 --- a/engine-rest/engine-rest-openapi/src/main/templates/lib/commons/history-process-instance.ftl +++ b/engine-rest/engine-rest-openapi/src/main/templates/lib/commons/history-process-instance.ftl @@ -237,6 +237,12 @@ "desc": "Only include historic process instances which belong to no tenant. Value may only be `true`, as `false` is the default behavior." }, + "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}" + }, + "executedActivityIdIn": { "type": "array", "itemType": "string", diff --git a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricProcessInstanceQueryDto.java b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricProcessInstanceQueryDto.java index da4e861a544..c944c2288ed 100644 --- a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricProcessInstanceQueryDto.java +++ b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricProcessInstanceQueryDto.java @@ -109,6 +109,7 @@ public class HistoricProcessInstanceQueryDto extends AbstractQueryDto executedActivityIdIn; private List activeActivityIdIn; + private List activityIdIn; private Boolean active; private Boolean suspended; private Boolean completed; @@ -342,6 +343,11 @@ public void setActiveActivityIdIn(List activeActivityIdIn) { this.activeActivityIdIn = activeActivityIdIn; } + @CamundaQueryParam(value = "activityIdIn", converter = StringListConverter.class) + public void setActivityIdIn(List activityIdIn) { + this.activityIdIn = activityIdIn; + } + @CamundaQueryParam(value = "executedJobAfter", converter = DateConverter.class) public void setExecutedJobAfter(Date executedJobAfter) { this.executedJobAfter = executedJobAfter; @@ -548,6 +554,10 @@ protected void applyFilters(HistoricProcessInstanceQuery query) { query.activeActivityIdIn(activeActivityIdIn.toArray(new String[0])); } + if(activityIdIn!= null && !activityIdIn.isEmpty()) { + query.activityIdIn(activityIdIn.toArray(new String[0])); + } + if (executedJobAfter != null) { query.executedJobAfter(executedJobAfter); } diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricProcessInstanceRestServiceQueryTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricProcessInstanceRestServiceQueryTest.java index b5734cc32f0..7ed79ed567b 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricProcessInstanceRestServiceQueryTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricProcessInstanceRestServiceQueryTest.java @@ -74,6 +74,7 @@ public class HistoricProcessInstanceRestServiceQueryTest extends AbstractRestSer protected static final String QUERY_PARAM_EXECUTED_ACTIVITY_IDS = "executedActivityIdIn"; protected static final String QUERY_PARAM_ACTIVE_ACTIVITY_IDS = "activeActivityIdIn"; protected static final String QUERY_PARAM_INCIDENT_IDS = "incidentIdIn"; + protected static final String QUERY_PARAM_ACTIVE_OR_FAILING_ACTIVITY_IDS = "activityIdIn"; @ClassRule public static TestContainerRule rule = new TestContainerRule(); @@ -2346,4 +2347,32 @@ public void testQueryByIncidentIdInAsPost() { verify(mockedQuery).incidentIdIn("1", "2"); } + @Test + public void testQueryByActivityIdIn() { + given() + .queryParam(QUERY_PARAM_ACTIVE_OR_FAILING_ACTIVITY_IDS, "1,2") + .then().expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).activityIdIn("1", "2"); + } + + @Test + public void testQueryByActivityIdInAsPost() { + Map> parameters = new HashMap>(); + parameters.put(QUERY_PARAM_ACTIVE_OR_FAILING_ACTIVITY_IDS, Arrays.asList("1", "2")); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(parameters) + .then().expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).activityIdIn("1", "2"); + } + } diff --git a/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceQuery.java b/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceQuery.java index e8034aa7df9..46fa51c951c 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceQuery.java +++ b/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceQuery.java @@ -440,6 +440,11 @@ public interface HistoricProcessInstanceQuery extends Query - update + update ${limitBeforeWithoutOffset} @@ -317,7 +317,7 @@ - + @@ -366,7 +366,7 @@ ${countDistinctAfterEnd} - +