You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "GopikaReghunath (via GitHub)" <gi...@apache.org> on 2026/05/04 05:19:43 UTC
[PR] Improve usertask endpoint [incubator-kie-kogito-runtimes]
GopikaReghunath opened a new pull request, #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273
closes: https://github.com/apache/incubator-kie-kogito-runtimes/issues/4269
- A new endpoint /usertasks is introduced
Lightweight data transfer object for user task list operations
Only essential task information without inputs, outputs, or metadata
Supports filtering (processId, processInstanceId, status, taskName)
Testing of the new endpoint:
Create usertasks and try to return the details (Atleast one identity parameter is required group/user)
Apply different filters and verify the responses
- New View Classes for Inputs/Outputs
UserTaskInputsView: Returns only task ID and inputs map
UserTaskOutputsView: Returns only task ID and outputs map
Purpose: Optimized responses for PUT endpoints that modify inputs/outputs
Testing:
Call the PUT endpoints with the required request
A lightweight response with only id and inputs/outputs is obtined
- Schema Endpoints Enhancement
GET /usertasks/{taskName}/schema: Get schema by task name
Uses static registry populated at build time for unauthenticated access
Falls back to authenticated lookup for backward compatibility
GET /usertasks/instance/{taskId}/schema: Get schema by task instance ID
Includes runtime transition information
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "martinweiler (via GitHub)" <gi...@apache.org>.
martinweiler commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3205003486
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -86,20 +102,54 @@ public void init() {
}
@GET
+ @Path("/instance")
@Produces(MediaType.APPLICATION_JSON)
- public List<UserTaskView> list(@QueryParam("user") String user, @QueryParam("group") List<String> groups) {
- return userTaskService.list(identityProviderFactory.getOrImpersonateIdentity(user, groups));
+ public Object list(
+ @QueryParam("user") String user,
+ @QueryParam("group") List<String> groups,
+ @QueryParam("format") String format,
+ @QueryParam("processId") String processId,
+ @QueryParam("processInstanceId") String processInstanceId,
+ @QueryParam("status") String status,
Review Comment:
Should we support a list of `status` elements?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "pefernan (via GitHub)" <gi...@apache.org>.
pefernan commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3335587901
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java:
##########
@@ -61,6 +62,15 @@ public List<UserTaskInstance> findByIdentity(IdentityProvider identityProvider)
.toList();
}
+ @Override
+ public List<UserTaskInstance> findByIdentity(IdentityProvider identityProvider, UserTaskFilter filter) {
Review Comment:
+1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "jstastny-cz (via GitHub)" <gi...@apache.org>.
jstastny-cz commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3315993957
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/view/UserTaskInputsView.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.usertask.view;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * Lightweight view for user task inputs.
+ * Used by PUT /usertasks/instance/{id}/inputs endpoint to return only input data.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class UserTaskInputsView {
Review Comment:
This was an explicit ask during reviews, resolving.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3389014621
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -87,8 +84,49 @@ public void init() {
@GET
@Produces(MediaType.APPLICATION_JSON)
- public List<UserTaskView> list(@QueryParam("user") String user, @QueryParam("group") List<String> groups) {
- return userTaskService.list(identityProviderFactory.getOrImpersonateIdentity(user, groups));
+ public Object list(
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "pefernan (via GitHub)" <gi...@apache.org>.
pefernan commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3335605838
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
import jakarta.persistence.*;
@Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
- query = "select userTask from UserTaskInstanceEntity userTask " +
- "left join userTask.adminGroups adminGroup " +
- "left join userTask.potentialGroups potentialGroup " +
- "where :userId member of userTask.adminUsers " +
- "or adminGroup in (:roles) " +
- "or userTask.actualOwner = :userId " +
- "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
- "and :userId not member of userTask.excludedUsers " +
- "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)" +
- "))")
@NamedNativeQuery(
name = UserTaskInstanceEntity.DELETE_BY_ID,
query = "delete from jbpm_user_tasks where id = :taskId")
@Table(name = "jbpm_user_tasks")
public class UserTaskInstanceEntity {
- public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity";
public static final String DELETE_BY_ID = "UserTaskInstanceEntity.DeleteById";
+ // Base query for finding instances by identity (without status filter)
+ public static final String BASE_IDENTITY_QUERY =
+ "select userTask from UserTaskInstanceEntity userTask " +
+ "left join userTask.adminGroups adminGroup " +
+ "left join userTask.potentialGroups potentialGroup " +
+ "where (:userId member of userTask.adminUsers " +
+ "or adminGroup in (:roles) " +
+ "or userTask.actualOwner = :userId " +
+ "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
+ "and :userId not member of userTask.excludedUsers " +
+ "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)))) " +
+ "and (cast(:processId as string) is null or userTask.processInfo.processId = :processId) " +
+ "and (cast(:processInstanceId as string) is null or userTask.processInfo.processInstanceId = :processInstanceId)";
+
+ // TaskName filter clause - case-insensitive (conditional to avoid bytea issues)
+ public static final String TASKNAME_FILTER_CLAUSE = " and lower(userTask.taskName) like lower(concat('%', :taskName, '%'))";
Review Comment:
maybe we should add more indexes to our schema with this new feature
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3207919586
##########
class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -0,0 +1,276 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.myspace.demo;
+
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import java.util.Collection;
+
+import jakarta.inject.Inject;
+
+import jakarta.ws.rs.NotFoundException;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.UriInfo;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.PUT;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.Consumes;
+
+import org.kie.kogito.auth.IdentityProviderFactory;
+import org.kie.kogito.usertask.UserTaskInstanceNotFoundException;
+import org.kie.kogito.usertask.UserTaskService;
+import org.kie.kogito.usertask.impl.json.SimpleDeserializationProblemHandler;
+import org.kie.kogito.usertask.impl.json.SimplePolymorphicTypeValidator;
+import org.kie.kogito.usertask.view.UserTaskView;
+import org.kie.kogito.usertask.view.UserTaskTransitionView;
+
+import org.kie.kogito.usertask.model.*;
+
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
+import com.fasterxml.jackson.databind.cfg.MapperConfig;
+import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
+import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
+import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
+import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator.Validity;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+@Path("/usertasks/instance")
+public class UserTasksResource {
Review Comment:
removed the unwanted file
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "martinweiler (via GitHub)" <gi...@apache.org>.
martinweiler commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3204995894
##########
class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -0,0 +1,276 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.myspace.demo;
+
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import java.util.Collection;
+
+import jakarta.inject.Inject;
+
+import jakarta.ws.rs.NotFoundException;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.UriInfo;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.PUT;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.Consumes;
+
+import org.kie.kogito.auth.IdentityProviderFactory;
+import org.kie.kogito.usertask.UserTaskInstanceNotFoundException;
+import org.kie.kogito.usertask.UserTaskService;
+import org.kie.kogito.usertask.impl.json.SimpleDeserializationProblemHandler;
+import org.kie.kogito.usertask.impl.json.SimplePolymorphicTypeValidator;
+import org.kie.kogito.usertask.view.UserTaskView;
+import org.kie.kogito.usertask.view.UserTaskTransitionView;
+
+import org.kie.kogito.usertask.model.*;
+
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
+import com.fasterxml.jackson.databind.cfg.MapperConfig;
+import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
+import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
+import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
+import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator.Validity;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+@Path("/usertasks/instance")
+public class UserTasksResource {
Review Comment:
Is this file required here? Aren't the templates already in `kogito-codegen-modules`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3246338402
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -273,4 +333,65 @@ public Attachment getAttachment(
.orElseThrow(() -> new UserTaskInstanceNotFoundException("Attachment " + attachmentId + " not found"));
}
+ @GET
+ @Path("/{taskName}/schema")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Map<String, Object> getSchemaByTaskName(
+ @PathParam("taskName") String taskName,
+ @QueryParam("user") String user,
+ @QueryParam("group") List<String> groups) {
Review Comment:
We tried the scenarios as mentioned by @josedee and below observations were made example used is process-user-tasks-subsystem (hiring.bpmn is the process)
Two different processes with same task name and different schema
created a test process (test.bpmn) with taskName hr_interview input: interview_in output: interview_out, while hitting schema endpoint with taskName as hr_interview only the schema details from hiring.bpmn process is returned and the test process is ignored
Same process with two tasks with same task name
To test this we renamed it_interview to hr_interview in hiring.bpmn (The input/output of both these tasks are different the original hr_interview has hr_approval while it_interview which is renamed to hr_interview has it_approval) and hit the schema endpoint. The response had both it_approval and hr_approval, Attaching a sample response for second scenario
`URL : http://localhost:8080/usertasks/hr_interview/schema`
`{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$defs": {
"Candidate": {
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"position": {
"type": "string"
}
}
}
},
"type": "object",
"properties": {
"candidate": {
"$ref": "#/$defs/Candidate",
"input": true
},
"it_approval": {
"type": "boolean",
"input": true,
"output": true
},
"hr_approval": {
"type": "boolean",
"input": true,
"output": true
}
}
}`
cc: @martinweiler @pefernan
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "josedee (via GitHub)" <gi...@apache.org>.
josedee commented on PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#issuecomment-4437266580
@GopikaReghunath Please create the issue in https://github.com/apache/incubator-kie-issues/issues
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "jstastny-cz (via GitHub)" <gi...@apache.org>.
jstastny-cz commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3271458623
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskFilter.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.usertask;
+
+import java.util.List;
+
+import org.kie.kogito.usertask.lifecycle.UserTaskState;
+
+/**
+ * Filter criteria for querying user tasks.
+ * All filters are combined using AND logic.
+ * Null filters are ignored (no filtering applied for that criterion).
+ */
+public class UserTaskFilter {
Review Comment:
This can be a record instead of class + builder. It does not have any additional behavior, just getters and instance creation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "jstastny-cz (via GitHub)" <gi...@apache.org>.
jstastny-cz commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3316154726
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskSpringTemplate.java:
##########
@@ -92,15 +99,54 @@ public void init() {
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.ALL_VALUE)
- public List<UserTaskView> list(
- @RequestParam(value = "user", required = false) String user,
- @RequestParam(value = "group", required = false) List<String> groups) {
- return userTaskService.list(identityProviderFactory.getOrImpersonateIdentity(user, groups));
+ public Object list(
+ @RequestParam(value = "user", required = false) String user,
+ @RequestParam(value = "group", required = false) List<String> groups,
+ @RequestParam(value = "format", required = false) String format,
+ @RequestParam(value = "processId", required = false) String processId,
+ @RequestParam(value = "processInstanceId", required = false) String processInstanceId,
+ @RequestParam(value = "status", required = false) List<String> status,
+ @RequestParam(value = "taskName", required = false) String taskName) {
Review Comment:
What is the rationale behind using task name (free form text) as the filtering parameter for a task? Why not use user task id instead?
With this choice and allowing partial match, IMHO you're beating the "selling" point calling this performance optimization.
When checking jbpm_user_tasks table I can see index only on id column and user_task_id:
```
"jbpm_user_tasks_pkey" PRIMARY KEY, btree (id)
"idx_usertasks_tid" btree (user_task_id)
```
So those are IMHO the only ones to be queried in performant and optimized way.
Even if the task name column was indexed - the partial match and concat SQL functions might prevent the query from hitting the index at all.
Problem with user_task_id is that the KIE editor might allow only generated values - but that's IMHO a room for improvement on that front, I don't think it needs to be restricted to that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#issuecomment-4437413547
> @GopikaReghunath Please create the issue in https://github.com/apache/incubator-kie-issues/issues
Issue created https://github.com/apache/incubator-kie-issues/issues/2308
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "martinweiler (via GitHub)" <gi...@apache.org>.
martinweiler commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3363923895
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskService.java:
##########
@@ -34,13 +37,15 @@ public interface UserTaskService {
List<UserTaskView> list(IdentityProvider identity);
+ List<UserTaskInfoView> listTasks(IdentityProvider identity, UserTaskFilter filter);
+
Optional<UserTaskView> transition(String taskId, String transitionId, Map<String, Object> data, IdentityProvider identity);
List<UserTaskTransitionView> allowedTransitions(String taskId, IdentityProvider identity);
- Optional<UserTaskView> setOutputs(String taskId, Map<String, Object> data, IdentityProvider identity);
+ Optional<UserTaskOutputsView> setOutputs(String taskId, Map<String, Object> data, IdentityProvider identity);
- Optional<UserTaskView> setInputs(String taskId, Map<String, Object> data, IdentityProvider identity);
+ Optional<UserTaskInputsView> setInputs(String taskId, Map<String, Object> data, IdentityProvider identity);
Review Comment:
@cimbalek thanks for highlighting this! I agree that this is a breaking change, but one that has been done intentionally. There are other endpoints available which return the full UserTaskView that users can call if needed. Returning the new `UserTaskInputsView` / `UserTaskOutputsView` streamlines the response for the input/output related endpoints.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3310741342
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstances.java:
##########
@@ -32,6 +32,8 @@ public interface UserTaskInstances {
List<UserTaskInstance> findByIdentity(IdentityProvider identityProvider);
+ List<UserTaskInstance> findByIdentityAndFilter(IdentityProvider identityProvider, UserTaskFilter filter);
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "pefernan (via GitHub)" <gi...@apache.org>.
pefernan commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3335609528
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskSpringTemplate.java:
##########
@@ -92,15 +99,54 @@ public void init() {
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.ALL_VALUE)
- public List<UserTaskView> list(
- @RequestParam(value = "user", required = false) String user,
- @RequestParam(value = "group", required = false) List<String> groups) {
- return userTaskService.list(identityProviderFactory.getOrImpersonateIdentity(user, groups));
+ public Object list(
+ @RequestParam(value = "user", required = false) String user,
+ @RequestParam(value = "group", required = false) List<String> groups,
+ @RequestParam(value = "format", required = false) String format,
+ @RequestParam(value = "processId", required = false) String processId,
+ @RequestParam(value = "processInstanceId", required = false) String processInstanceId,
+ @RequestParam(value = "status", required = false) List<String> status,
+ @RequestParam(value = "taskName", required = false) String taskName) {
Review Comment:
Task Name is a business name that the user gives to a task (or tasks), I think it is good to have it here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3342131036
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
import jakarta.persistence.*;
@Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
- query = "select userTask from UserTaskInstanceEntity userTask " +
- "left join userTask.adminGroups adminGroup " +
- "left join userTask.potentialGroups potentialGroup " +
- "where :userId member of userTask.adminUsers " +
- "or adminGroup in (:roles) " +
- "or userTask.actualOwner = :userId " +
- "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
- "and :userId not member of userTask.excludedUsers " +
- "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)" +
- "))")
@NamedNativeQuery(
name = UserTaskInstanceEntity.DELETE_BY_ID,
query = "delete from jbpm_user_tasks where id = :taskId")
@Table(name = "jbpm_user_tasks")
public class UserTaskInstanceEntity {
- public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity";
public static final String DELETE_BY_ID = "UserTaskInstanceEntity.DeleteById";
+ // Base query for finding instances by identity (without status filter)
+ public static final String BASE_IDENTITY_QUERY =
+ "select userTask from UserTaskInstanceEntity userTask " +
+ "left join userTask.adminGroups adminGroup " +
+ "left join userTask.potentialGroups potentialGroup " +
+ "where (:userId member of userTask.adminUsers " +
+ "or adminGroup in (:roles) " +
+ "or userTask.actualOwner = :userId " +
+ "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
+ "and :userId not member of userTask.excludedUsers " +
+ "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)))) " +
+ "and (cast(:processId as string) is null or userTask.processInfo.processId = :processId) " +
+ "and (cast(:processInstanceId as string) is null or userTask.processInfo.processInstanceId = :processInstanceId)";
+
+ // TaskName filter clause - case-insensitive (conditional to avoid bytea issues)
+ public static final String TASKNAME_FILTER_CLAUSE = " and lower(userTask.taskName) like lower(concat('%', :taskName, '%'))";
Review Comment:
Made taskname filter case sensitive and exact match
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "martinweiler (via GitHub)" <gi...@apache.org>.
martinweiler commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3335472147
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
import jakarta.persistence.*;
@Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
- query = "select userTask from UserTaskInstanceEntity userTask " +
- "left join userTask.adminGroups adminGroup " +
- "left join userTask.potentialGroups potentialGroup " +
- "where :userId member of userTask.adminUsers " +
- "or adminGroup in (:roles) " +
- "or userTask.actualOwner = :userId " +
- "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
- "and :userId not member of userTask.excludedUsers " +
- "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)" +
- "))")
@NamedNativeQuery(
name = UserTaskInstanceEntity.DELETE_BY_ID,
query = "delete from jbpm_user_tasks where id = :taskId")
@Table(name = "jbpm_user_tasks")
public class UserTaskInstanceEntity {
- public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity";
public static final String DELETE_BY_ID = "UserTaskInstanceEntity.DeleteById";
+ // Base query for finding instances by identity (without status filter)
+ public static final String BASE_IDENTITY_QUERY =
+ "select userTask from UserTaskInstanceEntity userTask " +
+ "left join userTask.adminGroups adminGroup " +
+ "left join userTask.potentialGroups potentialGroup " +
+ "where (:userId member of userTask.adminUsers " +
+ "or adminGroup in (:roles) " +
+ "or userTask.actualOwner = :userId " +
+ "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
+ "and :userId not member of userTask.excludedUsers " +
+ "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)))) " +
+ "and (cast(:processId as string) is null or userTask.processInfo.processId = :processId) " +
+ "and (cast(:processInstanceId as string) is null or userTask.processInfo.processInstanceId = :processInstanceId)";
+
+ // TaskName filter clause - case-insensitive (conditional to avoid bytea issues)
+ public static final String TASKNAME_FILTER_CLAUSE = " and lower(userTask.taskName) like lower(concat('%', :taskName, '%'))";
Review Comment:
You are raising some valid concerns about potential performance issues. We also don't have an actual request to support `like` queries.
@GopikaReghunath please adjust the code accordingly. Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3342149676
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskSpringTemplate.java:
##########
@@ -92,15 +99,54 @@ public void init() {
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.ALL_VALUE)
- public List<UserTaskView> list(
- @RequestParam(value = "user", required = false) String user,
- @RequestParam(value = "group", required = false) List<String> groups) {
- return userTaskService.list(identityProviderFactory.getOrImpersonateIdentity(user, groups));
+ public Object list(
+ @RequestParam(value = "user", required = false) String user,
+ @RequestParam(value = "group", required = false) List<String> groups,
+ @RequestParam(value = "format", required = false) String format,
+ @RequestParam(value = "processId", required = false) String processId,
+ @RequestParam(value = "processInstanceId", required = false) String processInstanceId,
+ @RequestParam(value = "status", required = false) List<String> status,
+ @RequestParam(value = "taskName", required = false) String taskName) {
Review Comment:
Have made taskname exact match and case sensitive
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "cimbalek (via GitHub)" <gi...@apache.org>.
cimbalek commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3362380213
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskService.java:
##########
@@ -34,13 +37,15 @@ public interface UserTaskService {
List<UserTaskView> list(IdentityProvider identity);
+ List<UserTaskInfoView> listTasks(IdentityProvider identity, UserTaskFilter filter);
+
Optional<UserTaskView> transition(String taskId, String transitionId, Map<String, Object> data, IdentityProvider identity);
List<UserTaskTransitionView> allowedTransitions(String taskId, IdentityProvider identity);
- Optional<UserTaskView> setOutputs(String taskId, Map<String, Object> data, IdentityProvider identity);
+ Optional<UserTaskOutputsView> setOutputs(String taskId, Map<String, Object> data, IdentityProvider identity);
- Optional<UserTaskView> setInputs(String taskId, Map<String, Object> data, IdentityProvider identity);
+ Optional<UserTaskInputsView> setInputs(String taskId, Map<String, Object> data, IdentityProvider identity);
Review Comment:
Seems that it was part of assignment, but the question about breaking backwards compatibility stays.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3207924132
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java:
##########
@@ -42,6 +48,56 @@ public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProv
return query.getResultList();
}
+ public List<UserTaskInstanceEntity> findByIdentityAndFilter(IdentityProvider identityProvider, UserTaskFilter filter) {
+ // Start with identity-based query
+ List<UserTaskInstanceEntity> identityFiltered = findByIdentity(identityProvider);
+
+ // If no filter, return identity-filtered results
+ if (filter == null) {
+ return identityFiltered;
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3257414002
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -273,4 +333,65 @@ public Attachment getAttachment(
.orElseThrow(() -> new UserTaskInstanceNotFoundException("Attachment " + attachmentId + " not found"));
}
+ @GET
+ @Path("/{taskName}/schema")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Map<String, Object> getSchemaByTaskName(
+ @PathParam("taskName") String taskName,
+ @QueryParam("user") String user,
+ @QueryParam("group") List<String> groups) {
Review Comment:
The schema endpoints has been removed as discussed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3380891174
##########
springboot/addons/jbpm-usertask-storage-jpa/pom.xml:
##########
@@ -53,5 +53,48 @@
<groupId>org.kie</groupId>
<artifactId>kie-addons-springboot-flyway</artifactId>
</dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3342131036
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
import jakarta.persistence.*;
@Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
- query = "select userTask from UserTaskInstanceEntity userTask " +
- "left join userTask.adminGroups adminGroup " +
- "left join userTask.potentialGroups potentialGroup " +
- "where :userId member of userTask.adminUsers " +
- "or adminGroup in (:roles) " +
- "or userTask.actualOwner = :userId " +
- "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
- "and :userId not member of userTask.excludedUsers " +
- "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)" +
- "))")
@NamedNativeQuery(
name = UserTaskInstanceEntity.DELETE_BY_ID,
query = "delete from jbpm_user_tasks where id = :taskId")
@Table(name = "jbpm_user_tasks")
public class UserTaskInstanceEntity {
- public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity";
public static final String DELETE_BY_ID = "UserTaskInstanceEntity.DeleteById";
+ // Base query for finding instances by identity (without status filter)
+ public static final String BASE_IDENTITY_QUERY =
+ "select userTask from UserTaskInstanceEntity userTask " +
+ "left join userTask.adminGroups adminGroup " +
+ "left join userTask.potentialGroups potentialGroup " +
+ "where (:userId member of userTask.adminUsers " +
+ "or adminGroup in (:roles) " +
+ "or userTask.actualOwner = :userId " +
+ "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
+ "and :userId not member of userTask.excludedUsers " +
+ "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)))) " +
+ "and (cast(:processId as string) is null or userTask.processInfo.processId = :processId) " +
+ "and (cast(:processInstanceId as string) is null or userTask.processInfo.processInstanceId = :processInstanceId)";
+
+ // TaskName filter clause - case-insensitive (conditional to avoid bytea issues)
+ public static final String TASKNAME_FILTER_CLAUSE = " and lower(userTask.taskName) like lower(concat('%', :taskName, '%'))";
Review Comment:
Made taskname filter casensensitive and exact match
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "jstastny-cz (via GitHub)" <gi...@apache.org>.
jstastny-cz commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3311434064
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
import jakarta.persistence.*;
@Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
- query = "select userTask from UserTaskInstanceEntity userTask " +
- "left join userTask.adminGroups adminGroup " +
- "left join userTask.potentialGroups potentialGroup " +
- "where :userId member of userTask.adminUsers " +
- "or adminGroup in (:roles) " +
- "or userTask.actualOwner = :userId " +
- "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
- "and :userId not member of userTask.excludedUsers " +
- "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)" +
- "))")
@NamedNativeQuery(
name = UserTaskInstanceEntity.DELETE_BY_ID,
query = "delete from jbpm_user_tasks where id = :taskId")
@Table(name = "jbpm_user_tasks")
public class UserTaskInstanceEntity {
- public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity";
public static final String DELETE_BY_ID = "UserTaskInstanceEntity.DeleteById";
+ // Base query for finding instances by identity (without status filter)
+ public static final String BASE_IDENTITY_QUERY =
+ "select userTask from UserTaskInstanceEntity userTask " +
+ "left join userTask.adminGroups adminGroup " +
+ "left join userTask.potentialGroups potentialGroup " +
+ "where (:userId member of userTask.adminUsers " +
+ "or adminGroup in (:roles) " +
+ "or userTask.actualOwner = :userId " +
+ "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
+ "and :userId not member of userTask.excludedUsers " +
+ "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)))) " +
+ "and (cast(:processId as string) is null or userTask.processInfo.processId = :processId) " +
+ "and (cast(:processInstanceId as string) is null or userTask.processInfo.processInstanceId = :processInstanceId)";
+
+ // TaskName filter clause - case-insensitive (conditional to avoid bytea issues)
+ public static final String TASKNAME_FILTER_CLAUSE = " and lower(userTask.taskName) like lower(concat('%', :taskName, '%'))";
Review Comment:
do these TASKNAME and STATUS filters hit DB index or resorts in skipping them (concat is always a problem) ?
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInfo.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.usertask;
+
+import java.util.Objects;
+
+import org.kie.kogito.usertask.lifecycle.UserTaskState;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * Lightweight data transfer object for user task list operations.
+ * Contains only essential task information without inputs, outputs, or metadata.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class UserTaskInfo {
Review Comment:
why isn't existing UserTaskView enough? Seems like we're creating new view/dto for each case, this might come out of hands soon.
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java:
##########
@@ -61,6 +62,15 @@ public List<UserTaskInstance> findByIdentity(IdentityProvider identityProvider)
.toList();
}
+ @Override
+ public List<UserTaskInstance> findByIdentity(IdentityProvider identityProvider, UserTaskFilter filter) {
Review Comment:
shouldn't `findByIdentity(IdentityProvider identityProvider)` call this overload with null filter parameter?
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/view/UserTaskInputsView.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.usertask.view;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * Lightweight view for user task inputs.
+ * Used by PUT /usertasks/instance/{id}/inputs endpoint to return only input data.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class UserTaskInputsView {
Review Comment:
UserTaskView has both inputs and outputs values, why new view/dto? Isn't it possible to used the existing one?
##########
springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,668 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.it.KogitoSpringbootApplication;
+import org.kie.kogito.testcontainers.springboot.PostgreSqlSpringBootTestResource;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class)
+@ContextConfiguration(initializers = PostgreSqlSpringBootTestResource.class)
+public class UserTaskFilterIT extends BaseUserTaskIT {
Review Comment:
Please add tests also to quarkus and springboot modules under addons/jbpm-usertask-storage-jpa testing the storage, not only these rest level tests. They are complementary.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "josedee (via GitHub)" <gi...@apache.org>.
josedee commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3233535231
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
What do you think about `status` filter being case insensitive. Would it make more sense. Just a thought
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3207922816
##########
addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesFilterTest.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file to
+ * you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.usertask.jpa;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper;
+import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity;
+import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.kie.kogito.auth.IdentityProvider;
+import org.kie.kogito.usertask.UserTaskFilter;
+import org.kie.kogito.usertask.UserTaskInstance;
+import org.kie.kogito.usertask.lifecycle.UserTaskState;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test class for JPAUserTaskInstances.findByIdentityAndFilter() method.
+ * This test verifies that the method correctly delegates to the repository
+ * and maps the results using the entity mapper.
+ */
+@ExtendWith(MockitoExtension.class)
+public class JPAUserTaskInstancesFilterTest {
Review Comment:
integration tests added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3374850223
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -466,98 +466,7 @@ public void testFilterByStatusCaseInsensitive() {
.get(USER_TASKS_ENDPOINT)
.then()
.statusCode(200)
- .body("$.size()", is(1))
- .body("[0].status.name", is("Reserved"));
- }
-
- @Test
- public void testFilterByStatusUpperCase() {
- // Given - Start a process instance (creates task in Reserved status)
- Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
- new Address("main street", "Boston", "10005", "US"));
- startProcessInstance(traveller);
-
- // When - Query with uppercase status (should match case-insensitively)
- given().contentType(ContentType.JSON)
- .queryParam("user", "manager")
- .queryParam("group", "department-managers")
- .queryParam("status", "RESERVED")
- .when()
- .get(USER_TASKS_ENDPOINT)
- .then()
- .statusCode(200)
- .body("$.size()", is(1))
- .body("[0].status.name", is("Reserved"));
- }
-
- @Test
- public void testFilterByStatusMixedCase() {
- // Given - Start a process instance (creates task in Reserved status)
- Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
- new Address("main street", "Boston", "10005", "US"));
- startProcessInstance(traveller);
-
- // When - Query with mixed case status (should match case-insensitively)
- given().contentType(ContentType.JSON)
- .queryParam("user", "manager")
- .queryParam("group", "department-managers")
- .queryParam("status", "ReSeRvEd")
- .when()
- .get(USER_TASKS_ENDPOINT)
- .then()
- .statusCode(200)
- .body("$.size()", is(1))
- .body("[0].status.name", is("Reserved"));
+ .body("$.size()", is(0));
Review Comment:
comment addressed
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
import jakarta.persistence.*;
@Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
- query = "select userTask from UserTaskInstanceEntity userTask " +
- "left join userTask.adminGroups adminGroup " +
- "left join userTask.potentialGroups potentialGroup " +
- "where :userId member of userTask.adminUsers " +
- "or adminGroup in (:roles) " +
- "or userTask.actualOwner = :userId " +
- "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
- "and :userId not member of userTask.excludedUsers " +
- "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)" +
- "))")
@NamedNativeQuery(
name = UserTaskInstanceEntity.DELETE_BY_ID,
query = "delete from jbpm_user_tasks where id = :taskId")
@Table(name = "jbpm_user_tasks")
public class UserTaskInstanceEntity {
- public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity";
public static final String DELETE_BY_ID = "UserTaskInstanceEntity.DeleteById";
+ // Base query for finding instances by identity (without status filter)
+ public static final String BASE_IDENTITY_QUERY =
+ "select userTask from UserTaskInstanceEntity userTask " +
+ "left join userTask.adminGroups adminGroup " +
+ "left join userTask.potentialGroups potentialGroup " +
+ "where (:userId member of userTask.adminUsers " +
+ "or adminGroup in (:roles) " +
+ "or userTask.actualOwner = :userId " +
+ "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
+ "and :userId not member of userTask.excludedUsers " +
+ "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)))) " +
+ "and (cast(:processId as string) is null or userTask.processInfo.processId = :processId) " +
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3374852304
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java:
##########
@@ -36,9 +42,61 @@ public UserTaskInstanceRepository(UserTaskJPAContext context) {
}
public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProvider) {
- TypedQuery<UserTaskInstanceEntity> query = getEntityManager().createNamedQuery(GET_INSTANCES_BY_IDENTITY, UserTaskInstanceEntity.class);
- query.setParameter("userId", identityProvider.getName());
- query.setParameter("roles", identityProvider.getRoles());
+ return findByIdentity(identityProvider, null);
+ }
+
+ public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProvider, UserTaskFilter filter) {
+ String userId = identityProvider.getName();
+ Collection<String> roles = identityProvider.getRoles();
+
+ // Build query dynamically - start with base query
+ String jpql = BASE_IDENTITY_QUERY;
+
+ boolean hasTaskNameFilter = filter != null
+ && filter.taskName() != null
+ && !filter.taskName().isEmpty();
+
+ boolean hasStatusFilter = filter != null
+ && filter.statuses() != null
+ && !filter.statuses().isEmpty();
+
+ // Conditionally append filter clauses
+ if (hasTaskNameFilter) {
+ jpql = jpql.concat(TASKNAME_FILTER_CLAUSE);
+ }
+
+ if (hasStatusFilter) {
+ jpql = jpql.concat(STATUS_FILTER_CLAUSE);
+ }
+
+ // Create typed query with the final JPQL
+ TypedQuery<UserTaskInstanceEntity> query = getEntityManager()
+ .createQuery(jpql, UserTaskInstanceEntity.class)
+ .setParameter("userId", userId)
+ .setParameter("roles", roles);
+
+ if (filter != null) {
+ query.setParameter("processId", filter.processId());
+ query.setParameter("processInstanceId", filter.processInstanceId());
+
+ // Only set taskName if we added it to the query
+ if (hasTaskNameFilter) {
+ query.setParameter("taskName", filter.taskName());
+ }
+
+ // Only set statusFilter if we added it to the query
+ if (hasStatusFilter) {
+ List<String> statusFilter = filter.statuses().stream()
+ .map(UserTaskState::getName)
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3234408068
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
Since status is having predefined values I kept it as case sensitive to match those predefined values. Let me know if this needs to be changed. @martinweiler Let me know your thoughts as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3234408068
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
From my understanding taskname is something set in BPMN files (via tns:taskName attribute) and it can be any string value chosen by the user hence kept it case insensitive and partial match. Let me know if any of these needs to be changed. @martinweiler Let me know your thoughts as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "josedee (via GitHub)" <gi...@apache.org>.
josedee commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3241249849
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -273,4 +333,65 @@ public Attachment getAttachment(
.orElseThrow(() -> new UserTaskInstanceNotFoundException("Attachment " + attachmentId + " not found"));
}
+ @GET
+ @Path("/{taskName}/schema")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Map<String, Object> getSchemaByTaskName(
+ @PathParam("taskName") String taskName,
+ @QueryParam("user") String user,
+ @QueryParam("group") List<String> groups) {
Review Comment:
@GopikaReghunath I have my doubts over this implementation. What happens if we have
- Two different processes with same task name and different schema
- Same process with two tasks with same task name
Aren't these scenarios possible. Shouldn't we use something unique like task definition id
cc: @martinweiler @pefernan Would like to hear your thoughts
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "jstastny-cz (via GitHub)" <gi...@apache.org>.
jstastny-cz commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3373769980
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -466,98 +466,7 @@ public void testFilterByStatusCaseInsensitive() {
.get(USER_TASKS_ENDPOINT)
.then()
.statusCode(200)
- .body("$.size()", is(1))
- .body("[0].status.name", is("Reserved"));
- }
-
- @Test
- public void testFilterByStatusUpperCase() {
- // Given - Start a process instance (creates task in Reserved status)
- Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
- new Address("main street", "Boston", "10005", "US"));
- startProcessInstance(traveller);
-
- // When - Query with uppercase status (should match case-insensitively)
- given().contentType(ContentType.JSON)
- .queryParam("user", "manager")
- .queryParam("group", "department-managers")
- .queryParam("status", "RESERVED")
- .when()
- .get(USER_TASKS_ENDPOINT)
- .then()
- .statusCode(200)
- .body("$.size()", is(1))
- .body("[0].status.name", is("Reserved"));
- }
-
- @Test
- public void testFilterByStatusMixedCase() {
- // Given - Start a process instance (creates task in Reserved status)
- Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
- new Address("main street", "Boston", "10005", "US"));
- startProcessInstance(traveller);
-
- // When - Query with mixed case status (should match case-insensitively)
- given().contentType(ContentType.JSON)
- .queryParam("user", "manager")
- .queryParam("group", "department-managers")
- .queryParam("status", "ReSeRvEd")
- .when()
- .get(USER_TASKS_ENDPOINT)
- .then()
- .statusCode(200)
- .body("$.size()", is(1))
- .body("[0].status.name", is("Reserved"));
+ .body("$.size()", is(0));
Review Comment:
I think this test case either needs renaming or remove? `testFilterByStatusCaseInsensitive` - also based on body contents - now it is case sensitive.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3207917700
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -86,20 +102,54 @@ public void init() {
}
@GET
+ @Path("/instance")
@Produces(MediaType.APPLICATION_JSON)
- public List<UserTaskView> list(@QueryParam("user") String user, @QueryParam("group") List<String> groups) {
- return userTaskService.list(identityProviderFactory.getOrImpersonateIdentity(user, groups));
+ public Object list(
+ @QueryParam("user") String user,
+ @QueryParam("group") List<String> groups,
+ @QueryParam("format") String format,
+ @QueryParam("processId") String processId,
+ @QueryParam("processInstanceId") String processInstanceId,
+ @QueryParam("status") String status,
Review Comment:
changes done, supports a list of statuses for filtering
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "jstastny-cz (via GitHub)" <gi...@apache.org>.
jstastny-cz commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3271440610
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java:
##########
@@ -42,6 +52,73 @@ public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProv
return query.getResultList();
}
+ public List<UserTaskInstanceEntity> findByIdentityAndFilter(IdentityProvider identityProvider, UserTaskFilter filter) {
+ // If no filter, use the optimized named query
+ if (filter == null) {
+ return findByIdentity(identityProvider);
+ }
+
+ // Build single query combining identity and filter predicates using Criteria API
+ CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
+ CriteriaQuery<UserTaskInstanceEntity> cq = cb.createQuery(UserTaskInstanceEntity.class);
Review Comment:
I would advice not mixing approaches JPQL and Criteria query. Enough that we have such differentiation between components, but bringing it into a single class basically means we have to manage duplicate implementations.
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskFilter.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.usertask;
+
+import java.util.List;
+
+import org.kie.kogito.usertask.lifecycle.UserTaskState;
+
+/**
+ * Filter criteria for querying user tasks.
+ * All filters are combined using AND logic.
+ * Null filters are ignored (no filtering applied for that criterion).
+ */
+public class UserTaskFilter {
Review Comment:
This can be a record instead class + builder. It does not have any additional behavior, just getters and instance creation.
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstances.java:
##########
@@ -32,6 +32,8 @@ public interface UserTaskInstances {
List<UserTaskInstance> findByIdentity(IdentityProvider identityProvider);
+ List<UserTaskInstance> findByIdentityAndFilter(IdentityProvider identityProvider, UserTaskFilter filter);
Review Comment:
As apparent from implementation, isn't this rather overload of findByIdentity? As it falls back to call that when filter is not provided.
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInfo.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.usertask;
+
+import org.kie.kogito.usertask.lifecycle.UserTaskState;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * Lightweight data transfer object for user task list operations.
+ * Contains only essential task information without inputs, outputs, or metadata.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class UserTaskInfo {
Review Comment:
Don't we need equals and hashcode for DTOs?
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java:
##########
@@ -42,6 +52,73 @@ public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProv
return query.getResultList();
}
+ public List<UserTaskInstanceEntity> findByIdentityAndFilter(IdentityProvider identityProvider, UserTaskFilter filter) {
+ // If no filter, use the optimized named query
+ if (filter == null) {
+ return findByIdentity(identityProvider);
Review Comment:
This seems as if this method should be overload of findByIdentity in the first place.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3216659258
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
Yes, The task name match is partial and case-insensitive.
For task names with spaces, I verified this behavior by temporarily modifying the BPMN file to use task names with spaces ("First Line Approval" instead of "firstLineApproval") and running the integration tests, which confirmed that all matching scenarios work correctly including:
Test Scenarios Verified:
Partial match from start: Search "First" → Matches "First Line Approval" ✅
Partial match from middle: Search "Line" → Matches "First Line Approval" ✅
Partial match from end: Search "Approval" → Matches "First Line Approval" ✅
Exact match: Search "First Line Approval" → Matches "First Line Approval" ✅
Partial match with space: Search "Line App" → Matches "First Line Approval" ✅
Case-insensitive match: Search "first LINE approval" → Matches "First Line Approval" ✅
Empty string: Search "" → Matches all tasks ✅
Non-existent: Search "nonExistentTask" → Returns no results ✅
All tests passed successfully, confirming that task names with spaces are handled correctly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "martinweiler (via GitHub)" <gi...@apache.org>.
martinweiler commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3234478519
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
I don't have a strong opinion on making `status` filter case insensitive, although I can see that this could be a small improvement in the usability of the query.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3234408068
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
Since status is having predefined values I kept it as case sensitive. Let me know if this needs to be changed. @martinweiler Let me know your thoughts as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "cimbalek (via GitHub)" <gi...@apache.org>.
cimbalek commented on PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#issuecomment-4631238196
LGTM. Thanks.
However, I have one question in the code - questioning change with the views that is imo breaking backward compatibility. Is that desirable? @martinweiler WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "pefernan (via GitHub)" <gi...@apache.org>.
pefernan commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3378895701
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -87,8 +84,49 @@ public void init() {
@GET
@Produces(MediaType.APPLICATION_JSON)
- public List<UserTaskView> list(@QueryParam("user") String user, @QueryParam("group") List<String> groups) {
- return userTaskService.list(identityProviderFactory.getOrImpersonateIdentity(user, groups));
+ public Object list(
Review Comment:
I understand the change, but I still think it should return a List<UserTaskView> instead of object, why not using [jackson views](https://www.baeldung.com/jackson-json-view-annotation) on top of `UserTaskView` to somehow switch between both task presentations.
Maybe with this approach we can also simplify [this fragment](https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273/changes#diff-3efefca73563302797ac35ae81f359f53ab353d6a23b27d90670e23c60bb35b6R113-R129) in both templates.
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -87,8 +84,49 @@ public void init() {
@GET
@Produces(MediaType.APPLICATION_JSON)
- public List<UserTaskView> list(@QueryParam("user") String user, @QueryParam("group") List<String> groups) {
- return userTaskService.list(identityProviderFactory.getOrImpersonateIdentity(user, groups));
+ public Object list(
+ @QueryParam("user") String user,
+ @QueryParam("group") List<String> groups,
+ @QueryParam("format") String format,
+ @QueryParam("processId") String processId,
+ @QueryParam("processInstanceId") String processInstanceId,
+ @QueryParam("status") List<String> status,
+ @QueryParam("taskName") String taskName) {
+
+ // Build filter from query parameters
+ UserTaskFilter.Builder filterBuilder = UserTaskFilter.builder()
+ .processId(processId)
+ .processInstanceId(processInstanceId)
+ .taskName(taskName);
+
+ // Handle multiple status values
+ if (status != null && !status.isEmpty()) {
Review Comment:
@GopikaReghunath Considering that you use the UserTaskState name to build the query [here](https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273/changes#diff-f5872faada1b3bc1899550b79afbd939226b3c39e778fa51ccb370e54195251cR107) I think this conversion is not necessary.
You can directly pass the states collection to the `filterBuilder`, so we simplify this and both REST templates are simpler.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "pefernan (via GitHub)" <gi...@apache.org>.
pefernan merged PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3389013551
##########
kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/usertask/RestResourceUserTaskQuarkusTemplate.java:
##########
@@ -87,8 +84,49 @@ public void init() {
@GET
@Produces(MediaType.APPLICATION_JSON)
- public List<UserTaskView> list(@QueryParam("user") String user, @QueryParam("group") List<String> groups) {
- return userTaskService.list(identityProviderFactory.getOrImpersonateIdentity(user, groups));
+ public Object list(
+ @QueryParam("user") String user,
+ @QueryParam("group") List<String> groups,
+ @QueryParam("format") String format,
+ @QueryParam("processId") String processId,
+ @QueryParam("processInstanceId") String processInstanceId,
+ @QueryParam("status") List<String> status,
+ @QueryParam("taskName") String taskName) {
+
+ // Build filter from query parameters
+ UserTaskFilter.Builder filterBuilder = UserTaskFilter.builder()
+ .processId(processId)
+ .processInstanceId(processInstanceId)
+ .taskName(taskName);
+
+ // Handle multiple status values
+ if (status != null && !status.isEmpty()) {
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3216659258
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
Yes, The task name match is partial and case-insensitive.
Task names with spaces are treated as below
Stored: "HR Interview" + Search: "HR Interview" → ✅ Exact match
Stored: "HR Interview" + Search: "Interview" → ✅ Partial match
Stored: "HR Interview" + Search: "HR Int" → ✅ Partial match with space
Stored: "HR Interview" + Search: "hr interview" → ✅ Case-insensitive exact match
I have added more test cases on this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "cimbalek (via GitHub)" <gi...@apache.org>.
cimbalek commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3361773938
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskService.java:
##########
@@ -34,13 +37,15 @@ public interface UserTaskService {
List<UserTaskView> list(IdentityProvider identity);
+ List<UserTaskInfoView> listTasks(IdentityProvider identity, UserTaskFilter filter);
+
Optional<UserTaskView> transition(String taskId, String transitionId, Map<String, Object> data, IdentityProvider identity);
List<UserTaskTransitionView> allowedTransitions(String taskId, IdentityProvider identity);
- Optional<UserTaskView> setOutputs(String taskId, Map<String, Object> data, IdentityProvider identity);
+ Optional<UserTaskOutputsView> setOutputs(String taskId, Map<String, Object> data, IdentityProvider identity);
- Optional<UserTaskView> setInputs(String taskId, Map<String, Object> data, IdentityProvider identity);
+ Optional<UserTaskInputsView> setInputs(String taskId, Map<String, Object> data, IdentityProvider identity);
Review Comment:
Aren't these chages breaking backward compatibility? And do we need all those new views?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "jstastny-cz (via GitHub)" <gi...@apache.org>.
jstastny-cz commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3371569196
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java:
##########
@@ -36,9 +42,61 @@ public UserTaskInstanceRepository(UserTaskJPAContext context) {
}
public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProvider) {
- TypedQuery<UserTaskInstanceEntity> query = getEntityManager().createNamedQuery(GET_INSTANCES_BY_IDENTITY, UserTaskInstanceEntity.class);
- query.setParameter("userId", identityProvider.getName());
- query.setParameter("roles", identityProvider.getRoles());
+ return findByIdentity(identityProvider, null);
+ }
+
+ public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProvider, UserTaskFilter filter) {
+ String userId = identityProvider.getName();
+ Collection<String> roles = identityProvider.getRoles();
+
+ // Build query dynamically - start with base query
+ String jpql = BASE_IDENTITY_QUERY;
+
+ boolean hasTaskNameFilter = filter != null
+ && filter.taskName() != null
+ && !filter.taskName().isEmpty();
+
+ boolean hasStatusFilter = filter != null
+ && filter.statuses() != null
+ && !filter.statuses().isEmpty();
+
+ // Conditionally append filter clauses
+ if (hasTaskNameFilter) {
+ jpql = jpql.concat(TASKNAME_FILTER_CLAUSE);
+ }
+
+ if (hasStatusFilter) {
+ jpql = jpql.concat(STATUS_FILTER_CLAUSE);
+ }
+
+ // Create typed query with the final JPQL
+ TypedQuery<UserTaskInstanceEntity> query = getEntityManager()
+ .createQuery(jpql, UserTaskInstanceEntity.class)
+ .setParameter("userId", userId)
+ .setParameter("roles", roles);
+
+ if (filter != null) {
+ query.setParameter("processId", filter.processId());
+ query.setParameter("processInstanceId", filter.processInstanceId());
+
+ // Only set taskName if we added it to the query
+ if (hasTaskNameFilter) {
+ query.setParameter("taskName", filter.taskName());
+ }
+
+ // Only set statusFilter if we added it to the query
+ if (hasStatusFilter) {
+ List<String> statusFilter = filter.statuses().stream()
+ .map(UserTaskState::getName)
Review Comment:
entity.setStatus(userTaskInstance.getStatus().getName());
Check the mapper - we have full control over the format of the state value - it's being persisted via getName() of the enum. We should drop any lower-case transformation, especially from the SQL query, and just make sure we pass the correctly formatted values.
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
import jakarta.persistence.*;
@Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
- query = "select userTask from UserTaskInstanceEntity userTask " +
- "left join userTask.adminGroups adminGroup " +
- "left join userTask.potentialGroups potentialGroup " +
- "where :userId member of userTask.adminUsers " +
- "or adminGroup in (:roles) " +
- "or userTask.actualOwner = :userId " +
- "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
- "and :userId not member of userTask.excludedUsers " +
- "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)" +
- "))")
@NamedNativeQuery(
name = UserTaskInstanceEntity.DELETE_BY_ID,
query = "delete from jbpm_user_tasks where id = :taskId")
@Table(name = "jbpm_user_tasks")
public class UserTaskInstanceEntity {
- public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity";
public static final String DELETE_BY_ID = "UserTaskInstanceEntity.DeleteById";
+ // Base query for finding instances by identity (without status filter)
+ public static final String BASE_IDENTITY_QUERY =
+ "select userTask from UserTaskInstanceEntity userTask " +
+ "left join userTask.adminGroups adminGroup " +
+ "left join userTask.potentialGroups potentialGroup " +
+ "where (:userId member of userTask.adminUsers " +
+ "or adminGroup in (:roles) " +
+ "or userTask.actualOwner = :userId " +
+ "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
+ "and :userId not member of userTask.excludedUsers " +
+ "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)))) " +
+ "and (cast(:processId as string) is null or userTask.processInfo.processId = :processId) " +
Review Comment:
Do we need such casts for a NULL check?
Why don't we append the query similarly to how we handle taskName and status fields? That's IMHO cleaner approach, also you have such logic already applied for taskName and status, why not also processId and processInstanceId?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3310738015
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java:
##########
@@ -42,6 +52,73 @@ public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProv
return query.getResultList();
}
+ public List<UserTaskInstanceEntity> findByIdentityAndFilter(IdentityProvider identityProvider, UserTaskFilter filter) {
+ // If no filter, use the optimized named query
+ if (filter == null) {
+ return findByIdentity(identityProvider);
+ }
+
+ // Build single query combining identity and filter predicates using Criteria API
+ CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
+ CriteriaQuery<UserTaskInstanceEntity> cq = cb.createQuery(UserTaskInstanceEntity.class);
Review Comment:
comment addressed
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java:
##########
@@ -42,6 +52,73 @@ public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProv
return query.getResultList();
}
+ public List<UserTaskInstanceEntity> findByIdentityAndFilter(IdentityProvider identityProvider, UserTaskFilter filter) {
+ // If no filter, use the optimized named query
+ if (filter == null) {
+ return findByIdentity(identityProvider);
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3310740352
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskFilter.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.usertask;
+
+import java.util.List;
+
+import org.kie.kogito.usertask.lifecycle.UserTaskState;
+
+/**
+ * Filter criteria for querying user tasks.
+ * All filters are combined using AND logic.
+ * Null filters are ignored (no filtering applied for that criterion).
+ */
+public class UserTaskFilter {
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "martinweiler (via GitHub)" <gi...@apache.org>.
martinweiler commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3211403851
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
So the task name match is a partial, case-insensitive match, correct? How about task names with spaces, are these treated correctly (both exact match as well as partial match)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3216659258
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
Yes, The task name match is partial and case-insensitive.
Task names with spaces are treated as below
Stored: "HR Interview" + Search: "HR Interview" → ✅ Exact match
Stored: "HR Interview" + Search: "Interview" → ✅ Partial match
Stored: "HR Interview" + Search: "HR Int" → ✅ Partial match with space
Stored: "HR Interview" + Search: "hr interview" → ✅ Case-insensitive exact match
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "pefernan (via GitHub)" <gi...@apache.org>.
pefernan commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3335450529
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
import jakarta.persistence.*;
@Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
- query = "select userTask from UserTaskInstanceEntity userTask " +
- "left join userTask.adminGroups adminGroup " +
- "left join userTask.potentialGroups potentialGroup " +
- "where :userId member of userTask.adminUsers " +
- "or adminGroup in (:roles) " +
- "or userTask.actualOwner = :userId " +
- "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
- "and :userId not member of userTask.excludedUsers " +
- "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)" +
- "))")
@NamedNativeQuery(
name = UserTaskInstanceEntity.DELETE_BY_ID,
query = "delete from jbpm_user_tasks where id = :taskId")
@Table(name = "jbpm_user_tasks")
public class UserTaskInstanceEntity {
- public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity";
public static final String DELETE_BY_ID = "UserTaskInstanceEntity.DeleteById";
+ // Base query for finding instances by identity (without status filter)
+ public static final String BASE_IDENTITY_QUERY =
+ "select userTask from UserTaskInstanceEntity userTask " +
+ "left join userTask.adminGroups adminGroup " +
+ "left join userTask.potentialGroups potentialGroup " +
+ "where (:userId member of userTask.adminUsers " +
+ "or adminGroup in (:roles) " +
+ "or userTask.actualOwner = :userId " +
+ "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
+ "and :userId not member of userTask.excludedUsers " +
+ "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)))) " +
+ "and (cast(:processId as string) is null or userTask.processInfo.processId = :processId) " +
+ "and (cast(:processInstanceId as string) is null or userTask.processInfo.processInstanceId = :processInstanceId)";
+
+ // TaskName filter clause - case-insensitive (conditional to avoid bytea issues)
+ public static final String TASKNAME_FILTER_CLAUSE = " and lower(userTask.taskName) like lower(concat('%', :taskName, '%'))";
Review Comment:
I have some feelings about this too, I'm afraid this will perform very bad with a large amount of tasks in DB. I'd prefer use not use partial and lowercase here. I think that it's better to go for equality in a first iteration and we can see if we need to evolve later if we get feedback on this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "pefernan (via GitHub)" <gi...@apache.org>.
pefernan commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3335585316
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
import jakarta.persistence.*;
@Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
- query = "select userTask from UserTaskInstanceEntity userTask " +
- "left join userTask.adminGroups adminGroup " +
- "left join userTask.potentialGroups potentialGroup " +
- "where :userId member of userTask.adminUsers " +
- "or adminGroup in (:roles) " +
- "or userTask.actualOwner = :userId " +
- "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
- "and :userId not member of userTask.excludedUsers " +
- "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)" +
- "))")
@NamedNativeQuery(
name = UserTaskInstanceEntity.DELETE_BY_ID,
query = "delete from jbpm_user_tasks where id = :taskId")
@Table(name = "jbpm_user_tasks")
public class UserTaskInstanceEntity {
- public static final String GET_INSTANCES_BY_IDENTITY = "UserTaskInstanceEntity.GetInstanceByIdentity";
public static final String DELETE_BY_ID = "UserTaskInstanceEntity.DeleteById";
+ // Base query for finding instances by identity (without status filter)
+ public static final String BASE_IDENTITY_QUERY =
+ "select userTask from UserTaskInstanceEntity userTask " +
+ "left join userTask.adminGroups adminGroup " +
+ "left join userTask.potentialGroups potentialGroup " +
+ "where (:userId member of userTask.adminUsers " +
+ "or adminGroup in (:roles) " +
+ "or userTask.actualOwner = :userId " +
+ "or (userTask.actualOwner is null " + // checking if task is not reserved, we cannot check by status since lifecycle can be customized
+ "and :userId not member of userTask.excludedUsers " +
+ "and (:userId member of userTask.potentialUsers or potentialGroup in (:roles)))) " +
+ "and (cast(:processId as string) is null or userTask.processInfo.processId = :processId) " +
+ "and (cast(:processInstanceId as string) is null or userTask.processInfo.processInstanceId = :processInstanceId)";
+
+ // TaskName filter clause - case-insensitive (conditional to avoid bytea issues)
+ public static final String TASKNAME_FILTER_CLAUSE = " and lower(userTask.taskName) like lower(concat('%', :taskName, '%'))";
Review Comment:
To be clear, I'd go with exact matches and would try to rely in DB indexes as much as possible
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "jstastny-cz (via GitHub)" <gi...@apache.org>.
jstastny-cz commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3378575288
##########
springboot/addons/jbpm-usertask-storage-jpa/pom.xml:
##########
@@ -53,5 +53,48 @@
<groupId>org.kie</groupId>
<artifactId>kie-addons-springboot-flyway</artifactId>
</dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
Review Comment:
We should rather use
```
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-spring-boot-test-utils</artifactId>
<scope>test</scope>
</dependency>
```
instead of direct testcontainers dependencies, or why do we not use it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "pefernan (via GitHub)" <gi...@apache.org>.
pefernan commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3335592605
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInfo.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.usertask;
+
+import java.util.Objects;
+
+import org.kie.kogito.usertask.lifecycle.UserTaskState;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * Lightweight data transfer object for user task list operations.
+ * Contains only essential task information without inputs, outputs, or metadata.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class UserTaskInfo {
Review Comment:
I think the idea is have a reduced view of the usertask to not return all task information unless it is required (metadata, inputs, outputs...)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3239068604
##########
quarkus/integration-tests/integration-tests-quarkus-usertasks/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,395 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@QuarkusIntegrationTest
+@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true)
+public class UserTaskFilterIT extends BaseUserTaskIT {
+
+ @AfterEach
+ public void cleanUp() {
+ // Get all process instances and delete them to ensure test isolation
+ List<String> processInstanceIds = given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/{processId}", PROCESS_ID)
+ .then()
+ .extract()
+ .jsonPath()
+ .getList("id", String.class);
+
+ processInstanceIds.forEach(processInstanceId -> {
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("/{processId}/{processInstanceId}", PROCESS_ID, processInstanceId)
+ .then()
+ .statusCode(200);
+ });
+ }
+
+ @Test
+ public void testFilterByProcessId() {
+ // Given - Start two process instances
+ Traveller traveller1 = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ Traveller traveller2 = new Traveller("Jane", "Smith", "jane.smith@example.com", "Canadian",
+ new Address("second street", "Toronto", "20005", "CA"));
+
+ startProcessInstance(traveller1);
+ startProcessInstance(traveller2);
+
+ // When - Query with processId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(2))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[1].processInfo.processId", is(PROCESS_ID));
+ }
+
+ @Test
+ public void testFilterByProcessInstanceId() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with processInstanceId filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processInstanceId", pid)
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processInstanceId", is(pid));
+ }
+
+ @Test
+ public void testFilterByStatus() {
+ // Given - Start a process instance (creates task in Reserved status)
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with status filter
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("status", "Reserved")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].status.name", is("Reserved"));
+ }
+
+ @Test
+ public void testFilterByTaskName() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with taskName filter (case-insensitive partial match)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "approval")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testCombinedFilters() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ String pid = startProcessInstance(traveller);
+
+ // When - Query with multiple filters
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", PROCESS_ID)
+ .queryParam("processInstanceId", pid)
+ .queryParam("status", "Reserved")
+ .queryParam("taskName", "firstLine")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(1))
+ .body("[0].processInfo.processId", is(PROCESS_ID))
+ .body("[0].processInfo.processInstanceId", is(pid))
+ .body("[0].status.name", is("Reserved"))
+ .body("[0].taskName", is("firstLineApproval"));
+ }
+
+ @Test
+ public void testFilterWithNoMatches() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with filter that doesn't match
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("processId", "nonexistent")
+ .when()
+ .get(USER_TASKS_ENDPOINT)
+ .then()
+ .statusCode(200)
+ .body("$.size()", is(0));
+ }
+
+ @Test
+ public void testFilterByTaskNameCaseInsensitive() {
+ // Given - Start a process instance
+ Traveller traveller = new Traveller("John", "Doe", "john.doe@example.com", "American",
+ new Address("main street", "Boston", "10005", "US"));
+ startProcessInstance(traveller);
+
+ // When - Query with uppercase taskName (should match case-insensitively)
+ given().contentType(ContentType.JSON)
+ .queryParam("user", "manager")
+ .queryParam("group", "department-managers")
+ .queryParam("taskName", "APPROVAL")
Review Comment:
PR comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "martinweiler (via GitHub)" <gi...@apache.org>.
martinweiler commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3204988839
##########
addons/common/jbpm-usertask-storage-jpa/src/test/java/org/jbpm/usertask/jpa/JPAUserTaskInstancesFilterTest.java:
##########
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file to
+ * you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.usertask.jpa;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jbpm.usertask.jpa.mapper.UserTaskInstanceEntityMapper;
+import org.jbpm.usertask.jpa.model.UserTaskInstanceEntity;
+import org.jbpm.usertask.jpa.repository.UserTaskInstanceRepository;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.kie.kogito.auth.IdentityProvider;
+import org.kie.kogito.usertask.UserTaskFilter;
+import org.kie.kogito.usertask.UserTaskInstance;
+import org.kie.kogito.usertask.lifecycle.UserTaskState;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test class for JPAUserTaskInstances.findByIdentityAndFilter() method.
+ * This test verifies that the method correctly delegates to the repository
+ * and maps the results using the entity mapper.
+ */
+@ExtendWith(MockitoExtension.class)
+public class JPAUserTaskInstancesFilterTest {
Review Comment:
I only see mocked tests in this PR, but no actual integration-tests that verify the correctness of the filter queries. Can you add those @GopikaReghunath ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issue#4269] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "martinweiler (via GitHub)" <gi...@apache.org>.
martinweiler commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3204905667
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/repository/UserTaskInstanceRepository.java:
##########
@@ -42,6 +48,56 @@ public List<UserTaskInstanceEntity> findByIdentity(IdentityProvider identityProv
return query.getResultList();
}
+ public List<UserTaskInstanceEntity> findByIdentityAndFilter(IdentityProvider identityProvider, UserTaskFilter filter) {
+ // Start with identity-based query
+ List<UserTaskInstanceEntity> identityFiltered = findByIdentity(identityProvider);
+
+ // If no filter, return identity-filtered results
+ if (filter == null) {
+ return identityFiltered;
Review Comment:
Isn't this kind of inefficient to create this first query, and in case of further filters, execute another query to apply the additional filters? Could we do something like the following instead?
```
if(filter == null) {
return findByIdentity(identityProvider);
}
// ... create single query combining identity and filter predicates
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3342135001
##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/JPAUserTaskInstances.java:
##########
@@ -61,6 +62,15 @@ public List<UserTaskInstance> findByIdentity(IdentityProvider identityProvider)
.toList();
}
+ @Override
+ public List<UserTaskInstance> findByIdentity(IdentityProvider identityProvider, UserTaskFilter filter) {
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3342144861
##########
springboot/integration-tests/integration-tests-springboot-usertasks-it/src/test/java/org/jbpm/userTask/jpa/it/UserTaskFilterIT.java:
##########
@@ -0,0 +1,668 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.jbpm.userTask.jpa.it;
+
+import java.util.List;
+
+import org.acme.travels.Address;
+import org.acme.travels.Traveller;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.it.KogitoSpringbootApplication;
+import org.kie.kogito.testcontainers.springboot.PostgreSqlSpringBootTestResource;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.hasItem;
+
+/**
+ * Integration test for user task filtering functionality.
+ * Tests the filter query parameters on the /usertasks/instance endpoint.
+ */
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class)
+@ContextConfiguration(initializers = PostgreSqlSpringBootTestResource.class)
+public class UserTaskFilterIT extends BaseUserTaskIT {
Review Comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-issues#2308] Improve usertask endpoint [incubator-kie-kogito-runtimes]
Posted by "GopikaReghunath (via GitHub)" <gi...@apache.org>.
GopikaReghunath commented on code in PR #4273:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3342142423
##########
api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInfo.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.kogito.usertask;
+
+import java.util.Objects;
+
+import org.kie.kogito.usertask.lifecycle.UserTaskState;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * Lightweight data transfer object for user task list operations.
+ * Contains only essential task information without inputs, outputs, or metadata.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class UserTaskInfo {
Review Comment:
I have moved this class to view package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org