From 5e1d6321ce3e614982fcdf31f2f329e346fe6621 Mon Sep 17 00:00:00 2001 From: Tommaso D'Alessandro Date: Wed, 11 Dec 2024 17:55:55 +0100 Subject: [PATCH] AAE-28084 Add new fields to task filters and process instance filters (#1642) * AAE-28084 add required fields and tests * AAE-28084 remove blank line --- ...a => CloudRuntimeEntityFilterRequest.java} | 5 +- .../payload/ProcessInstanceSearchRequest.java | 4 +- .../query/rest/payload/TaskSearchRequest.java | 5 +- .../ProcessInstanceSpecification.java | 8 + .../specification/SpecificationSupport.java | 10 +- .../rest/specification/TaskSpecification.java | 15 ++ ...ocessInstanceEntitySearchControllerIT.java | 47 +++++- .../query/rest/AbstractTaskControllerIT.java | 98 ++++++++++++ .../ProcessInstanceControllerHelperTest.java | 10 +- .../query/util/ProcessInstanceBuilder.java | 5 + .../ProcessInstanceSearchRequestBuilder.java | 14 ++ .../query/util/ProcessInstanceTestUtils.java | 22 --- .../query/util/TaskSearchRequestBuilder.java | 21 +++ .../src/test/resources/swagger-expected.json | 141 +++++++++++------- 14 files changed, 319 insertions(+), 86 deletions(-) rename activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/{ProcessVariableFilterRequest.java => CloudRuntimeEntityFilterRequest.java} (89%) diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessVariableFilterRequest.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/CloudRuntimeEntityFilterRequest.java similarity index 89% rename from activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessVariableFilterRequest.java rename to activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/CloudRuntimeEntityFilterRequest.java index 662282a5fe..fecc1684d8 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessVariableFilterRequest.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/CloudRuntimeEntityFilterRequest.java @@ -18,8 +18,9 @@ import java.util.Set; import org.activiti.cloud.services.query.rest.filter.VariableFilter; -public interface ProcessVariableFilterRequest { +public interface CloudRuntimeEntityFilterRequest { + Set id(); + Set parentId(); Set processVariableFilters(); - CloudRuntimeEntitySort sort(); } diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessInstanceSearchRequest.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessInstanceSearchRequest.java index 98acefe4b2..742b4b4726 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessInstanceSearchRequest.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/ProcessInstanceSearchRequest.java @@ -23,6 +23,8 @@ //prettier-ignore public record ProcessInstanceSearchRequest( + Set id, + Set parentId, Set name, Set processDefinitionName, Set initiator, @@ -39,4 +41,4 @@ public record ProcessInstanceSearchRequest( Set processVariableFilters, Set processVariableKeys, CloudRuntimeEntitySort sort -) implements ProcessVariableFilterRequest{} +) implements CloudRuntimeEntityFilterRequest {} diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/TaskSearchRequest.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/TaskSearchRequest.java index cfcd52deb2..c8e8b51442 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/TaskSearchRequest.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/payload/TaskSearchRequest.java @@ -25,6 +25,9 @@ public record TaskSearchRequest ( boolean onlyStandalone, boolean onlyRoot, + Set id, + Set parentId, + Set processInstanceId, Set name, Set description, Set processDefinitionName, @@ -48,4 +51,4 @@ public record TaskSearchRequest ( Set processVariableFilters, Set processVariableKeys, CloudRuntimeEntitySort sort -) implements ProcessVariableFilterRequest {} +) implements CloudRuntimeEntityFilterRequest {} diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/ProcessInstanceSpecification.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/ProcessInstanceSpecification.java index 1e80225666..43f1b97f63 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/ProcessInstanceSpecification.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/ProcessInstanceSpecification.java @@ -58,6 +58,8 @@ public Predicate toPredicate( ) { reset(); applyUserRestrictionFilter(root, criteriaBuilder); + applyIdFilter(root); + applyParentIdFilter(root); applyNameFilter(root, criteriaBuilder); applyProcessDefinitionNameFilter(root); applyInitiatorFilter(root); @@ -80,6 +82,12 @@ protected SetAttribute getProcessV return ProcessInstanceEntity_.variables; } + private void applyParentIdFilter(Root root) { + if (!CollectionUtils.isEmpty(searchRequest.parentId())) { + predicates.add(root.get(ProcessInstanceEntity_.parentId).in(searchRequest.parentId())); + } + } + private void applyNameFilter(Root root, CriteriaBuilder criteriaBuilder) { if (!CollectionUtils.isEmpty(searchRequest.name())) { addLikeFilters(predicates, searchRequest.name(), root, criteriaBuilder, ProcessInstanceEntity_.name); diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/SpecificationSupport.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/SpecificationSupport.java index 61b34f31cf..25d894a3fd 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/SpecificationSupport.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/SpecificationSupport.java @@ -38,14 +38,14 @@ import org.activiti.cloud.services.query.model.ProcessVariableEntity; import org.activiti.cloud.services.query.model.ProcessVariableEntity_; import org.activiti.cloud.services.query.rest.filter.VariableType; +import org.activiti.cloud.services.query.rest.payload.CloudRuntimeEntityFilterRequest; import org.activiti.cloud.services.query.rest.payload.CloudRuntimeEntitySort; -import org.activiti.cloud.services.query.rest.payload.ProcessVariableFilterRequest; import org.springframework.data.jpa.domain.Specification; import org.springframework.http.HttpStatus; import org.springframework.util.CollectionUtils; import org.springframework.web.server.ResponseStatusException; -public abstract class SpecificationSupport implements Specification { +public abstract class SpecificationSupport implements Specification { protected final R searchRequest; protected List predicates; @@ -132,6 +132,12 @@ protected void applyProcessVariableFilters( } } + protected void applyIdFilter(Root root) { + if (!CollectionUtils.isEmpty(searchRequest.id())) { + predicates.add(root.get(getIdAttribute()).in(searchRequest.id())); + } + } + protected void addLikeFilters( Collection predicates, Set valuesToFilter, diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/TaskSpecification.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/TaskSpecification.java index 5bcaf94590..77fd739f18 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/TaskSpecification.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/main/java/org/activiti/cloud/services/query/rest/specification/TaskSpecification.java @@ -86,6 +86,9 @@ public Predicate toPredicate(Root root, CriteriaQuery query, Crit reset(); applyUserRestrictionFilter(root, criteriaBuilder); applyRootTasksFilter(root, criteriaBuilder); + applyIdFilter(root); + applyParentIdFilter(root); + applyProcessInstanceIdFilter(root); applyStandaloneFilter(root, criteriaBuilder); applyNameFilter(root, criteriaBuilder); applyDescriptionFilter(root, criteriaBuilder); @@ -132,6 +135,18 @@ protected SetAttribute getProcessVariablesAtt return TaskEntity_.processVariables; } + private void applyParentIdFilter(Root root) { + if (!CollectionUtils.isEmpty(searchRequest.parentId())) { + predicates.add(root.get(TaskEntity_.parentTaskId).in(searchRequest.parentId())); + } + } + + private void applyProcessInstanceIdFilter(Root root) { + if (!CollectionUtils.isEmpty(searchRequest.processInstanceId())) { + predicates.add(root.get(TaskEntity_.processInstanceId).in(searchRequest.processInstanceId())); + } + } + private void applyProcessDefinitionNameFilter(Root root, CriteriaBuilder criteriaBuilder) { if (!CollectionUtils.isEmpty(searchRequest.processDefinitionName())) { addLikeFilters( diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractProcessInstanceEntitySearchControllerIT.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractProcessInstanceEntitySearchControllerIT.java index d933e5be1d..e6478ce430 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractProcessInstanceEntitySearchControllerIT.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractProcessInstanceEntitySearchControllerIT.java @@ -30,6 +30,7 @@ import java.math.BigDecimal; import java.util.Date; +import java.util.stream.IntStream; import org.activiti.QueryRestTestApplication; import org.activiti.api.process.model.ProcessInstance; import org.activiti.cloud.alfresco.config.AlfrescoWebAutoConfiguration; @@ -82,6 +83,50 @@ void cleanUp() { protected abstract String getSearchEndpoint(); + @Test + void should_returnProcessInstances_filteredById() { + IntStream + .range(0, 3) + .forEach(i -> queryTestUtils.buildProcessInstance().withId("id" + i).withInitiator(USER).buildAndSave()); + + ProcessInstanceSearchRequest request = new ProcessInstanceSearchRequestBuilder().withIds("id0", "id2").build(); + + given() + .contentType(MediaType.APPLICATION_JSON) + .body(request) + .when() + .post(getSearchEndpoint()) + .then() + .statusCode(200) + .body(PROCESS_INSTANCES_JSON_PATH, hasSize(2)) + .body(PROCESS_INSTANCE_IDS_JSON_PATH, contains("id0", "id2")); + } + + @Test + void should_returnProcessInstances_filteredByParentId() { + queryTestUtils.buildProcessInstance().withId("id1").withInitiator(USER).withParentId("parent1").buildAndSave(); + + queryTestUtils.buildProcessInstance().withId("id2").withInitiator(USER).withParentId("parent2").buildAndSave(); + + queryTestUtils.buildProcessInstance().withId("id3").withInitiator(USER).withParentId("parent3").buildAndSave(); + + queryTestUtils.buildProcessInstance().withId("id4").withInitiator(USER).buildAndSave(); + + ProcessInstanceSearchRequest request = new ProcessInstanceSearchRequestBuilder() + .withParentIds("parent1", "parent3") + .build(); + + given() + .contentType(MediaType.APPLICATION_JSON) + .body(request) + .when() + .post(getSearchEndpoint()) + .then() + .statusCode(200) + .body(PROCESS_INSTANCES_JSON_PATH, hasSize(2)) + .body(PROCESS_INSTANCE_IDS_JSON_PATH, contains("id1", "id3")); + } + @Test void should_returnProcessInstances_filteredByNameLike() { ProcessInstanceEntity processInstance1 = queryTestUtils @@ -2514,7 +2559,7 @@ void should_returnProcessInstances_sortedBy_BooleanProcessVariable() { } /** - * From Postgres documentation: https://www.postgresql.org/docs/current/queries-order.html + * From Postgres documentation: Postgres sorting * By default, null values sort as if larger than any non-null value; * that is, NULLS FIRST is the default for DESC order, and NULLS LAST otherwise. */ diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractTaskControllerIT.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractTaskControllerIT.java index aef660e628..f381f373b2 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractTaskControllerIT.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/AbstractTaskControllerIT.java @@ -211,6 +211,104 @@ void should_returnTasks_withOnlyRequestedProcessVariables() { .body(TASKS_JSON_PATH + "[0].processVariables[0].name", is(VAR_NAME)); } + @Test + void should_returnTasks_filteredById() { + IntStream + .range(0, 3) + .forEach(i -> queryTestUtils.buildTask().withId("id" + i).withAssignee(CURRENT_USER).buildAndSave()); + + TaskSearchRequest request = new TaskSearchRequestBuilder().withId("id0", "id2").build(); + + given() + .contentType(MediaType.APPLICATION_JSON) + .body(request) + .when() + .post(getSearchEndpointHttpPost()) + .then() + .statusCode(200) + .body(TASKS_JSON_PATH, hasSize(2)) + .body(TASK_IDS_JSON_PATH, contains("id0", "id2")); + } + + @Test + void should_returnTasks_filteredByParentId() { + TaskEntity parent1 = queryTestUtils.buildTask().withAssignee(CURRENT_USER).buildAndSave(); + TaskEntity parent2 = queryTestUtils.buildTask().withAssignee(CURRENT_USER).buildAndSave(); + + queryTestUtils.buildTask().withId(TASK_ID_1).withAssignee(CURRENT_USER).withParentTask(parent1).buildAndSave(); + + queryTestUtils + .buildTask() + .withAssignee(CURRENT_USER) + .withParentTask(queryTestUtils.buildTask().buildAndSave()) + .buildAndSave(); + + queryTestUtils.buildTask().withId(TASK_ID_3).withAssignee(CURRENT_USER).withParentTask(parent2).buildAndSave(); + + TaskSearchRequest request = new TaskSearchRequestBuilder() + .withParentId(parent1.getId(), parent2.getId()) + .build(); + + given() + .contentType(MediaType.APPLICATION_JSON) + .body(request) + .when() + .post(getSearchEndpointHttpPost()) + .then() + .statusCode(200) + .body(TASKS_JSON_PATH, hasSize(2)) + .body(TASK_IDS_JSON_PATH, containsInAnyOrder(TASK_ID_1, TASK_ID_3)); + } + + @Test + void should_returnTasks_filteredByProcessInstanceId() { + ProcessInstanceEntity processInstance1 = queryTestUtils + .buildProcessInstance() + .withInitiator(CURRENT_USER) + .withProcessDefinitionKey(PROCESS_DEFINITION_KEY) + .buildAndSave(); + + ProcessInstanceEntity processInstance2 = queryTestUtils + .buildProcessInstance() + .withInitiator(CURRENT_USER) + .withProcessDefinitionKey(UUID.randomUUID().toString()) + .buildAndSave(); + + queryTestUtils + .buildTask() + .withId(TASK_ID_1) + .withAssignee(CURRENT_USER) + .withParentProcess(processInstance1) + .buildAndSave(); + + queryTestUtils + .buildTask() + .withAssignee(CURRENT_USER) + .withParentProcess(queryTestUtils.buildProcessInstance().buildAndSave()) + .buildAndSave(); + + queryTestUtils + .buildTask() + .withId(TASK_ID_3) + .withAssignee(CURRENT_USER) + .withParentProcess(processInstance2) + .buildAndSave(); + + TaskSearchRequest request = new TaskSearchRequestBuilder() + .withProcessInstanceId(processInstance1.getId(), processInstance2.getId()) + .build(); + + given() + .contentType(MediaType.APPLICATION_JSON) + .body(request) + .when() + .post(getSearchEndpointHttpPost()) + .then() + .statusCode(200) + .body(TASKS_JSON_PATH, hasSize(2)) + .body(TASK_IDS_JSON_PATH, containsInAnyOrder(TASK_ID_1, TASK_ID_3)); + } + @Test void should_returnTasks_filteredByProcessVariable_withOnlyRequestedProcessVariables() { queryTestUtils diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/ProcessInstanceControllerHelperTest.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/ProcessInstanceControllerHelperTest.java index 3c6e25477f..df213013eb 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/ProcessInstanceControllerHelperTest.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/rest/ProcessInstanceControllerHelperTest.java @@ -15,8 +15,9 @@ */ package org.activiti.cloud.services.query.rest; -import static org.activiti.cloud.services.query.util.ProcessInstanceTestUtils.createProcessInstanceSearchRequest; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -27,6 +28,7 @@ import org.activiti.cloud.services.query.model.ProcessInstanceEntity; import org.activiti.cloud.services.query.rest.helper.ProcessInstanceControllerHelper; import org.activiti.cloud.services.query.rest.payload.ProcessInstanceSearchRequest; +import org.activiti.cloud.services.query.util.ProcessInstanceSearchRequestBuilder; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -107,15 +109,15 @@ void findById_shouldReturnProcessInstance() { @Test void searchProcessInstances_shouldReturnProcessInstances() { //given - ProcessInstanceSearchRequest searchRequest = createProcessInstanceSearchRequest(); Pageable pageable = PageRequest.of(0, 10); Page pageResult = new PageImpl<>(Collections.singletonList(new ProcessInstanceEntity())); - given(processInstanceService.search(searchRequest, pageable)).willReturn(pageResult); + given(processInstanceService.search(any(ProcessInstanceSearchRequest.class), eq(pageable))) + .willReturn(pageResult); given(processInstanceRepository.mapSubprocesses(pageResult, pageable)).willReturn(pageResult); //when Page result = processInstanceControllerHelper.searchProcessInstances( - searchRequest, + new ProcessInstanceSearchRequestBuilder().build(), pageable ); diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceBuilder.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceBuilder.java index 14e2c92f93..393db482f6 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceBuilder.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceBuilder.java @@ -56,6 +56,11 @@ public ProcessInstanceBuilder withId(String id) { return this; } + public ProcessInstanceBuilder withParentId(String parentId) { + process.setParentId(parentId); + return this; + } + public ProcessInstanceBuilder withName(String name) { process.setName(name); return this; diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceSearchRequestBuilder.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceSearchRequestBuilder.java index d13bae9324..98eb420623 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceSearchRequestBuilder.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceSearchRequestBuilder.java @@ -31,6 +31,8 @@ public class ProcessInstanceSearchRequestBuilder { + private Set ids; + private Set parentIds; private Set names; private Set processDefinitionNames; private Set initiators; @@ -48,6 +50,16 @@ public class ProcessInstanceSearchRequestBuilder { private Set processVariableKeys; private CloudRuntimeEntitySort sort; + public ProcessInstanceSearchRequestBuilder withIds(String... ids) { + this.ids = Set.of(ids); + return this; + } + + public ProcessInstanceSearchRequestBuilder withParentIds(String... parentIds) { + this.parentIds = Set.of(parentIds); + return this; + } + public ProcessInstanceSearchRequestBuilder withNames(String... names) { this.names = Set.of(names); return this; @@ -157,6 +169,8 @@ public ProcessInstanceSearchRequest build() { } } return new ProcessInstanceSearchRequest( + ids, + parentIds, names, processDefinitionNames, initiators, diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceTestUtils.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceTestUtils.java index a26e4f2f9e..23c86bb8de 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceTestUtils.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/ProcessInstanceTestUtils.java @@ -22,7 +22,6 @@ import org.activiti.api.process.model.ProcessInstance; import org.activiti.cloud.services.query.model.ProcessInstanceEntity; import org.activiti.cloud.services.query.model.ProcessVariableEntity; -import org.activiti.cloud.services.query.rest.payload.ProcessInstanceSearchRequest; public class ProcessInstanceTestUtils { @@ -59,25 +58,4 @@ public static Set createProcessVariables( } return variables; } - - public static ProcessInstanceSearchRequest createProcessInstanceSearchRequest() { - return new ProcessInstanceSearchRequest( - Set.of("My-app"), // processDefinitionKeys - Set.of("initiator"), // initiators - Set.of("1.0"), // appVersions - Set.of("My-app"), // appNames - Set.of(ProcessInstance.ProcessInstanceStatus.RUNNING), // statuses - null, // lastModifiedFrom - null, // lastModifiedTo - null, // startFrom - null, // startTo - null, // completedFrom - null, // completedTo - null, // suspendedFrom - null, // suspendedTo - null, // processVariableFilters - null, // processVariableKeys - null // sort - ); - } } diff --git a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/TaskSearchRequestBuilder.java b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/TaskSearchRequestBuilder.java index 8abdcfe430..7f80fde5a8 100644 --- a/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/TaskSearchRequestBuilder.java +++ b/activiti-cloud-query-service/activiti-cloud-services-query/activiti-cloud-services-query-rest/src/test/java/org/activiti/cloud/services/query/util/TaskSearchRequestBuilder.java @@ -33,6 +33,9 @@ public class TaskSearchRequestBuilder { private boolean onlyStandalone; private boolean onlyRoot; + private Set id; + private Set parentId; + private Set processInstanceId; private Set name; private Set description; private Set processDefinitionName; @@ -67,6 +70,21 @@ public TaskSearchRequestBuilder onlyRoot() { return this; } + public TaskSearchRequestBuilder withId(String... ids) { + this.id = Set.of(ids); + return this; + } + + public TaskSearchRequestBuilder withParentId(String... parentIds) { + this.parentId = Set.of(parentIds); + return this; + } + + public TaskSearchRequestBuilder withProcessInstanceId(String... processInstanceIds) { + this.processInstanceId = Set.of(processInstanceIds); + return this; + } + public TaskSearchRequestBuilder withName(String... names) { this.name = Set.of(names); return this; @@ -214,6 +232,9 @@ public TaskSearchRequest build() { return new TaskSearchRequest( onlyStandalone, onlyRoot, + id, + parentId, + processInstanceId, name, description, processDefinitionName, diff --git a/activiti-cloud-query-service/activiti-cloud-starter-query/src/test/resources/swagger-expected.json b/activiti-cloud-query-service/activiti-cloud-starter-query/src/test/resources/swagger-expected.json index f77a30590d..c57807ef7f 100644 --- a/activiti-cloud-query-service/activiti-cloud-starter-query/src/test/resources/swagger-expected.json +++ b/activiti-cloud-query-service/activiti-cloud-starter-query/src/test/resources/swagger-expected.json @@ -6412,6 +6412,27 @@ "onlyRoot": { "type": "boolean" }, + "id": { + "uniqueItems": true, + "type": "array", + "items": { + "type": "string" + } + }, + "parentId": { + "uniqueItems": true, + "type": "array", + "items": { + "type": "string" + } + }, + "processInstanceId": { + "uniqueItems": true, + "type": "array", + "items": { + "type": "string" + } + }, "name": { "uniqueItems": true, "type": "array", @@ -6752,16 +6773,9 @@ "standalone": { "type": "boolean" }, - "completedDate": { - "type": "string", - "format": "date-time" - }, "processDefinitionId": { "type": "string" }, - "processInstanceId": { - "type": "string" - }, "candidateUsers": { "type": "array", "items": { @@ -6774,16 +6788,23 @@ "type": "string" } }, + "processInstanceId": { + "type": "string" + }, + "completedDate": { + "type": "string", + "format": "date-time" + }, "parentTaskId": { "type": "string" }, "taskDefinitionKey": { "type": "string" }, - "assignee": { + "formKey": { "type": "string" }, - "formKey": { + "assignee": { "type": "string" }, "businessKey": { @@ -6804,6 +6825,9 @@ "completedBy": { "type": "string" }, + "description": { + "type": "string" + }, "status": { "type": "string", "enum": [ @@ -6815,9 +6839,6 @@ "DELETED" ] }, - "description": { - "type": "string" - }, "processDefinitionVersion": { "type": "integer", "format": "int32" @@ -6828,6 +6849,20 @@ "title": "ProcessInstanceSearchRequest_ProcessVariables", "type": "object", "properties": { + "id": { + "uniqueItems": true, + "type": "array", + "items": { + "type": "string" + } + }, + "parentId": { + "uniqueItems": true, + "type": "array", + "items": { + "type": "string" + } + }, "name": { "uniqueItems": true, "type": "array", @@ -6989,21 +7024,24 @@ "id": { "type": "string" }, + "processDefinitionId": { + "type": "string" + }, "completedDate": { "type": "string", "format": "date-time" }, - "processDefinitionId": { + "businessKey": { "type": "string" }, "startDate": { "type": "string", "format": "date-time" }, - "businessKey": { + "initiator": { "type": "string" }, - "initiator": { + "parentId": { "type": "string" }, "status": { @@ -7016,18 +7054,15 @@ "COMPLETED" ] }, - "parentId": { - "type": "string" - }, - "processDefinitionName": { - "type": "string" - }, "processDefinitionKey": { "type": "string" }, "processDefinitionVersion": { "type": "integer", "format": "int32" + }, + "processDefinitionName": { + "type": "string" } } }, @@ -7304,16 +7339,9 @@ "standalone": { "type": "boolean" }, - "completedDate": { - "type": "string", - "format": "date-time" - }, "processDefinitionId": { "type": "string" }, - "processInstanceId": { - "type": "string" - }, "candidateUsers": { "type": "array", "items": { @@ -7326,16 +7354,23 @@ "type": "string" } }, + "processInstanceId": { + "type": "string" + }, + "completedDate": { + "type": "string", + "format": "date-time" + }, "parentTaskId": { "type": "string" }, "taskDefinitionKey": { "type": "string" }, - "assignee": { + "formKey": { "type": "string" }, - "formKey": { + "assignee": { "type": "string" }, "businessKey": { @@ -7356,6 +7391,9 @@ "completedBy": { "type": "string" }, + "description": { + "type": "string" + }, "status": { "type": "string", "enum": [ @@ -7367,9 +7405,6 @@ "DELETED" ] }, - "description": { - "type": "string" - }, "processDefinitionVersion": { "type": "integer", "format": "int32" @@ -7420,21 +7455,24 @@ "id": { "type": "string" }, + "processDefinitionId": { + "type": "string" + }, "completedDate": { "type": "string", "format": "date-time" }, - "processDefinitionId": { + "businessKey": { "type": "string" }, "startDate": { "type": "string", "format": "date-time" }, - "businessKey": { + "initiator": { "type": "string" }, - "initiator": { + "parentId": { "type": "string" }, "status": { @@ -7447,18 +7485,15 @@ "COMPLETED" ] }, - "parentId": { - "type": "string" - }, - "processDefinitionName": { - "type": "string" - }, "processDefinitionKey": { "type": "string" }, "processDefinitionVersion": { "type": "integer", "format": "int32" + }, + "processDefinitionName": { + "type": "string" } } }, @@ -7657,21 +7692,21 @@ "id": { "type": "string" }, - "completedDate": { - "type": "string", - "format": "date-time" - }, "cancelledDate": { "type": "string", "format": "date-time" }, - "startedDate": { + "completedDate": { "type": "string", "format": "date-time" }, "businessKey": { "type": "string" }, + "startedDate": { + "type": "string", + "format": "date-time" + }, "status": { "type": "string", "enum": [ @@ -7849,13 +7884,10 @@ "type": "object" } }, - "clientId": { - "type": "string" - }, - "clientName": { + "appVersion": { "type": "string" }, - "appVersion": { + "businessKey": { "type": "string" }, "executionId": { @@ -7864,7 +7896,10 @@ "clientType": { "type": "string" }, - "businessKey": { + "clientId": { + "type": "string" + }, + "clientName": { "type": "string" }, "processDefinitionKey": {