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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to