syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [syncope] 02/02: Small cleanup after Flowable upgrade
Date Wed, 16 Jan 2019 07:11:58 GMT
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 7616b9ef8326c676ea2e522669ecc4a342b94e7b
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
AuthorDate: Wed Jan 16 08:11:23 2019 +0100

    Small cleanup after Flowable upgrade
---
 .../syncope/core/flowable/impl/FlowableRuntimeUtils.java   | 14 +++-----------
 .../core/flowable/impl/FlowableUserRequestHandler.java     | 14 +++++++-------
 .../core/flowable/impl/FlowableUserWorkflowAdapter.java    |  5 ++---
 3 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java
b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java
index c46b728..e88e25f 100644
--- a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java
+++ b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java
@@ -36,7 +36,6 @@ import org.flowable.engine.history.HistoricActivityInstance;
 import org.flowable.engine.repository.ProcessDefinition;
 import org.flowable.engine.runtime.ProcessInstance;
 import org.flowable.task.api.Task;
-import org.flowable.task.api.TaskQuery;
 import org.identityconnectors.common.security.EncryptorFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -129,7 +128,7 @@ public final class FlowableRuntimeUtils {
     }
 
     public static void updateStatus(final DomainProcessEngine engine, final String procInstId,
final User user) {
-        List<Task> tasks = createTaskQuery(engine, false).processInstanceId(procInstId).list();
+        List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(procInstId).list();
         if (tasks.isEmpty() || tasks.size() > 1) {
             LOG.warn("While setting user status: unexpected task number ({})", tasks.size());
         } else {
@@ -137,18 +136,11 @@ public final class FlowableRuntimeUtils {
         }
     }
 
-    public static TaskQuery createTaskQuery(final DomainProcessEngine engine, final boolean
onlyFormTasks) {
-        TaskQuery taskQuery = engine.getTaskService().createTaskQuery();
-        if (onlyFormTasks) {
-            taskQuery.taskWithFormKey();
-        }
-        return taskQuery;
-    }
-
     public static String getFormTask(final DomainProcessEngine engine, final String procInstId)
{
         String result = null;
 
-        List<Task> tasks = createTaskQuery(engine, true).processInstanceId(procInstId).list();
+        List<Task> tasks = engine.getTaskService().createTaskQuery().
+                taskWithFormKey().processInstanceId(procInstId).list();
         if (tasks.isEmpty() || tasks.size() > 1) {
             LOG.debug("While checking if form task: unexpected task number ({})", tasks.size());
         } else {
diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserRequestHandler.java
b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserRequestHandler.java
index 1f539fb..22bd357 100644
--- a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserRequestHandler.java
+++ b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserRequestHandler.java
@@ -128,7 +128,7 @@ public class FlowableUserRequestHandler implements UserRequestHandler
{
         userRequest.setStartTime(procInst.getStartTime());
         userRequest.setUsername(userDAO.find(split.getRight()).getUsername());
         userRequest.setExecutionId(procInst.getId());
-        userRequest.setActivityId(FlowableRuntimeUtils.createTaskQuery(engine, false).
+        userRequest.setActivityId(engine.getTaskService().createTaskQuery().
                 processInstanceId(procInst.getProcessInstanceId()).singleResult().getTaskDefinitionKey());
         return userRequest;
     }
@@ -461,7 +461,7 @@ public class FlowableUserRequestHandler implements UserRequestHandler
{
 
         Pair<Integer, List<UserRequestForm>> forms;
 
-        TaskQuery query = FlowableRuntimeUtils.createTaskQuery(engine, true);
+        TaskQuery query = engine.getTaskService().createTaskQuery().taskWithFormKey();
         if (userKey != null) {
             query.processInstanceBusinessKeyLike(FlowableRuntimeUtils.getProcBusinessKey("%",
userKey));
         }
@@ -539,7 +539,7 @@ public class FlowableUserRequestHandler implements UserRequestHandler
{
     protected Pair<Task, TaskFormData> parseTask(final String taskId) {
         Task task;
         try {
-            task = FlowableRuntimeUtils.createTaskQuery(engine, true).taskId(taskId).singleResult();
+            task = engine.getTaskService().createTaskQuery().taskWithFormKey().taskId(taskId).singleResult();
             if (task == null) {
                 throw new FlowableException("NULL result");
             }
@@ -563,8 +563,8 @@ public class FlowableUserRequestHandler implements UserRequestHandler
{
 
         String authUser = AuthContextUtils.getUsername();
         if (!adminUser.equals(authUser)) {
-            List<Task> tasksForUser = FlowableRuntimeUtils.createTaskQuery(engine,
true).
-                    taskId(taskId).taskCandidateOrAssigned(authUser).list();
+            List<Task> tasksForUser = engine.getTaskService().createTaskQuery().
+                    taskWithFormKey().taskId(taskId).taskCandidateOrAssigned(authUser).list();
             if (tasksForUser.isEmpty()) {
                 throw new WorkflowException(
                         new IllegalArgumentException(authUser + " is not candidate nor assignee
of task " + taskId));
@@ -586,7 +586,7 @@ public class FlowableUserRequestHandler implements UserRequestHandler
{
         Task task;
         try {
             engine.getTaskService().claim(taskId, authUser);
-            task = FlowableRuntimeUtils.createTaskQuery(engine, true).taskId(taskId).singleResult();
+            task = engine.getTaskService().createTaskQuery().taskWithFormKey().taskId(taskId).singleResult();
         } catch (FlowableException e) {
             throw new WorkflowException("While reading task " + taskId, e);
         }
@@ -601,7 +601,7 @@ public class FlowableUserRequestHandler implements UserRequestHandler
{
         Task task;
         try {
             engine.getTaskService().unclaim(taskId);
-            task = FlowableRuntimeUtils.createTaskQuery(engine, true).taskId(taskId).singleResult();
+            task = engine.getTaskService().createTaskQuery().taskWithFormKey().taskId(taskId).singleResult();
         } catch (FlowableException e) {
             throw new WorkflowException("While unclaiming task " + taskId, e);
         }
diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserWorkflowAdapter.java
b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserWorkflowAdapter.java
index 24e765d..e5734eb 100644
--- a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserWorkflowAdapter.java
+++ b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableUserWorkflowAdapter.java
@@ -173,7 +173,7 @@ public class FlowableUserWorkflowAdapter extends AbstractUserWorkflowAdapter
imp
             variables.putAll(moreVariables);
         }
 
-        List<Task> tasks = FlowableRuntimeUtils.createTaskQuery(engine, false).processInstanceId(procInstID).list();
+        List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(procInstID).list();
         String task = null;
         if (tasks.size() == 1) {
             try {
@@ -461,8 +461,7 @@ public class FlowableUserWorkflowAdapter extends AbstractUserWorkflowAdapter
imp
 
         List<String> availableTasks = new ArrayList<>();
         try {
-            Task currentTask = FlowableRuntimeUtils.createTaskQuery(engine, false).
-                    processInstanceId(procInstID).singleResult();
+            Task currentTask = engine.getTaskService().createTaskQuery().processInstanceId(procInstID).singleResult();
 
             Process process = engine.getRepositoryService().
                     getBpmnModel(FlowableRuntimeUtils.getLatestProcDefByKey(


Mime
View raw message