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