You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2018/10/02 14:19:20 UTC

[1/4] syncope git commit: Upgrading Flowable

Repository: syncope
Updated Branches:
  refs/heads/2_1_X 6f6d91569 -> c193001d8
  refs/heads/master fee1317dc -> 5daece32b


http://git-wip-us.apache.org/repos/asf/syncope/blob/c193001d/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml
----------------------------------------------------------------------
diff --git a/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml b/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml
index cc905a3..bf5c06f 100644
--- a/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml
+++ b/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml
@@ -25,118 +25,118 @@ under the License.
   
   <insert id="insertTask" parameterType="org.flowable.task.service.impl.persistence.entity.TaskEntityImpl">
     insert into ${prefix}ACT_RU_TASK (ID_, REV_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_, ASSIGNEE_, DELEGATION_, 
-    EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_,
-    TASK_DEF_KEY_, DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
-    IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_)
+                      EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_,
+                      TASK_DEF_KEY_, DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
+                      IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_)
     values (#{id, jdbcType=VARCHAR},
-    1,
-    #{name, jdbcType=VARCHAR},
-    #{parentTaskId, jdbcType=VARCHAR},
-    #{description, jdbcType=VARCHAR},
-    #{priority, jdbcType=INTEGER},
-    #{createTime, jdbcType=TIMESTAMP},
-    #{owner, jdbcType=VARCHAR},
-    #{assignee, jdbcType=VARCHAR},
-    #{delegationStateString, jdbcType=VARCHAR},
-    #{executionId, jdbcType=VARCHAR},
-    #{processInstanceId, jdbcType=VARCHAR},
-    #{processDefinitionId, jdbcType=VARCHAR},
-    #{taskDefinitionId, jdbcType=VARCHAR},
-    #{scopeId, jdbcType=VARCHAR},
-    #{subScopeId, jdbcType=VARCHAR},
-    #{scopeType, jdbcType=VARCHAR},
-    #{scopeDefinitionId, jdbcType=VARCHAR},
-    #{taskDefinitionKey, jdbcType=VARCHAR},
-    #{dueDate, jdbcType=TIMESTAMP},
-    #{category, jdbcType=VARCHAR},
-    #{suspensionState, jdbcType=INTEGER},
-    #{tenantId, jdbcType=VARCHAR},
-    #{formKey, jdbcType=VARCHAR},
-    #{claimTime, jdbcType=TIMESTAMP},
-    #{isCountEnabled, jdbcType=BOOLEAN},
-    #{variableCount, jdbcType=INTEGER},
-    #{identityLinkCount, jdbcType=INTEGER},
-    #{subTaskCount, jdbcType=INTEGER}
-    )
+            1,
+            #{name, jdbcType=VARCHAR},
+            #{parentTaskId, jdbcType=VARCHAR},
+            #{description, jdbcType=VARCHAR},
+            #{priority, jdbcType=INTEGER},
+            #{createTime, jdbcType=TIMESTAMP},
+            #{owner, jdbcType=VARCHAR},
+            #{assignee, jdbcType=VARCHAR},
+            #{delegationStateString, jdbcType=VARCHAR},
+            #{executionId, jdbcType=VARCHAR},
+            #{processInstanceId, jdbcType=VARCHAR},
+            #{processDefinitionId, jdbcType=VARCHAR},
+            #{taskDefinitionId, jdbcType=VARCHAR},
+            #{scopeId, jdbcType=VARCHAR},
+            #{subScopeId, jdbcType=VARCHAR},
+            #{scopeType, jdbcType=VARCHAR},
+            #{scopeDefinitionId, jdbcType=VARCHAR},
+            #{taskDefinitionKey, jdbcType=VARCHAR},
+            #{dueDate, jdbcType=TIMESTAMP},
+            #{category, jdbcType=VARCHAR},
+            #{suspensionState, jdbcType=INTEGER},
+            #{tenantId, jdbcType=VARCHAR},
+            #{formKey, jdbcType=VARCHAR},
+            #{claimTime, jdbcType=TIMESTAMP},
+            #{isCountEnabled, jdbcType=BOOLEAN},
+            #{variableCount, jdbcType=INTEGER},
+            #{identityLinkCount, jdbcType=INTEGER},
+            #{subTaskCount, jdbcType=INTEGER}
+           )
   </insert>
 
   <insert id="bulkInsertTask" parameterType="java.util.List">
     INSERT INTO ${prefix}ACT_RU_TASK (ID_, REV_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_, ASSIGNEE_, DELEGATION_, 
-    EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_, 
-    TASK_DEF_KEY_, DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
-    IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_)
+        EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_, 
+        TASK_DEF_KEY_, DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
+        IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_)
     VALUES 
-    <foreach collection="list" item="task" index="index" separator=","> 
-      (#{task.id, jdbcType=VARCHAR},
-      1,
-      #{task.name, jdbcType=VARCHAR},
-      #{task.parentTaskId, jdbcType=VARCHAR},
-      #{task.description, jdbcType=VARCHAR},
-      #{task.priority, jdbcType=INTEGER},
-      #{task.createTime, jdbcType=TIMESTAMP},
-      #{task.owner, jdbcType=VARCHAR},
-      #{task.assignee, jdbcType=VARCHAR},
-      #{task.delegationStateString, jdbcType=VARCHAR},
-      #{task.executionId, jdbcType=VARCHAR},
-      #{task.processInstanceId, jdbcType=VARCHAR},
-      #{task.processDefinitionId, jdbcType=VARCHAR},
-      #{task.taskDefinitionId, jdbcType=VARCHAR},
-      #{task.scopeId, jdbcType=VARCHAR},
-      #{task.subScopeId, jdbcType=VARCHAR},
-      #{task.scopeType, jdbcType=VARCHAR},
-      #{task.scopeDefinitionId, jdbcType=VARCHAR},
-      #{task.taskDefinitionKey, jdbcType=VARCHAR},
-      #{task.dueDate, jdbcType=TIMESTAMP},
-      #{task.category, jdbcType=VARCHAR},
-      #{task.suspensionState, jdbcType=INTEGER},
-      #{task.tenantId, jdbcType=VARCHAR},
-      #{task.formKey, jdbcType=VARCHAR},
-      #{task.claimTime, jdbcType=TIMESTAMP},
-      #{task.isCountEnabled, jdbcType=BOOLEAN},
-      #{task.variableCount, jdbcType=INTEGER},
-      #{task.identityLinkCount, jdbcType=INTEGER},
-      #{task.subTaskCount, jdbcType=INTEGER}
-      )
+      <foreach collection="list" item="task" index="index" separator=","> 
+        (#{task.id, jdbcType=VARCHAR},
+         1,
+         #{task.name, jdbcType=VARCHAR},
+         #{task.parentTaskId, jdbcType=VARCHAR},
+         #{task.description, jdbcType=VARCHAR},
+         #{task.priority, jdbcType=INTEGER},
+         #{task.createTime, jdbcType=TIMESTAMP},
+         #{task.owner, jdbcType=VARCHAR},
+         #{task.assignee, jdbcType=VARCHAR},
+         #{task.delegationStateString, jdbcType=VARCHAR},
+         #{task.executionId, jdbcType=VARCHAR},
+         #{task.processInstanceId, jdbcType=VARCHAR},
+         #{task.processDefinitionId, jdbcType=VARCHAR},
+         #{task.taskDefinitionId, jdbcType=VARCHAR},
+         #{task.scopeId, jdbcType=VARCHAR},
+         #{task.subScopeId, jdbcType=VARCHAR},
+         #{task.scopeType, jdbcType=VARCHAR},
+         #{task.scopeDefinitionId, jdbcType=VARCHAR},
+         #{task.taskDefinitionKey, jdbcType=VARCHAR},
+         #{task.dueDate, jdbcType=TIMESTAMP},
+         #{task.category, jdbcType=VARCHAR},
+         #{task.suspensionState, jdbcType=INTEGER},
+         #{task.tenantId, jdbcType=VARCHAR},
+         #{task.formKey, jdbcType=VARCHAR},
+         #{task.claimTime, jdbcType=TIMESTAMP},
+         #{task.isCountEnabled, jdbcType=BOOLEAN},
+         #{task.variableCount, jdbcType=INTEGER},
+         #{task.identityLinkCount, jdbcType=INTEGER},
+         #{task.subTaskCount, jdbcType=INTEGER}
+         )
     </foreach>
   </insert>
 
   <insert id="bulkInsertTask" databaseId="oracle" parameterType="java.util.List">
     INSERT ALL 
-    <foreach collection="list" item="task" index="index">
-      INTO ${prefix}ACT_RU_TASK (ID_, REV_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_, ASSIGNEE_, DELEGATION_, 
-      EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_, TASK_DEF_KEY_, 
-      DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
-      IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_) VALUES
-      (#{task.id, jdbcType=VARCHAR},
-      1,
-      #{task.name, jdbcType=VARCHAR},
-      #{task.parentTaskId, jdbcType=VARCHAR},
-      #{task.description, jdbcType=VARCHAR},
-      #{task.priority, jdbcType=INTEGER},
-      #{task.createTime, jdbcType=TIMESTAMP},
-      #{task.owner, jdbcType=VARCHAR},
-      #{task.assignee, jdbcType=VARCHAR},
-      #{task.delegationStateString, jdbcType=VARCHAR},
-      #{task.executionId, jdbcType=VARCHAR},
-      #{task.processInstanceId, jdbcType=VARCHAR},
-      #{task.processDefinitionId, jdbcType=VARCHAR},
-      #{task.taskDefinitionId, jdbcType=VARCHAR},
-      #{task.scopeId, jdbcType=VARCHAR},
-      #{task.subScopeId, jdbcType=VARCHAR},
-      #{task.scopeType, jdbcType=VARCHAR},
-      #{task.scopeDefinitionId, jdbcType=VARCHAR},
-      #{task.taskDefinitionKey, jdbcType=VARCHAR},
-      #{task.dueDate, jdbcType=TIMESTAMP},
-      #{task.category, jdbcType=VARCHAR},
-      #{task.suspensionState, jdbcType=INTEGER},
-      #{task.tenantId, jdbcType=VARCHAR},
-      #{task.formKey, jdbcType=VARCHAR},
-      #{task.claimTime, jdbcType=TIMESTAMP},
-      #{task.isCountEnabled, jdbcType=BOOLEAN},
-      #{task.variableCount, jdbcType=INTEGER},
-      #{task.identityLinkCount, jdbcType=INTEGER},
-      #{task.subTaskCount, jdbcType=INTEGER}
-      )
+      <foreach collection="list" item="task" index="index">
+        INTO ${prefix}ACT_RU_TASK (ID_, REV_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_, ASSIGNEE_, DELEGATION_, 
+              EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_, TASK_DEF_KEY_, 
+              DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
+              IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_) VALUES
+        (#{task.id, jdbcType=VARCHAR},
+         1,
+         #{task.name, jdbcType=VARCHAR},
+         #{task.parentTaskId, jdbcType=VARCHAR},
+         #{task.description, jdbcType=VARCHAR},
+         #{task.priority, jdbcType=INTEGER},
+         #{task.createTime, jdbcType=TIMESTAMP},
+         #{task.owner, jdbcType=VARCHAR},
+         #{task.assignee, jdbcType=VARCHAR},
+         #{task.delegationStateString, jdbcType=VARCHAR},
+         #{task.executionId, jdbcType=VARCHAR},
+         #{task.processInstanceId, jdbcType=VARCHAR},
+         #{task.processDefinitionId, jdbcType=VARCHAR},
+         #{task.taskDefinitionId, jdbcType=VARCHAR},
+         #{task.scopeId, jdbcType=VARCHAR},
+         #{task.subScopeId, jdbcType=VARCHAR},
+         #{task.scopeType, jdbcType=VARCHAR},
+         #{task.scopeDefinitionId, jdbcType=VARCHAR},
+         #{task.taskDefinitionKey, jdbcType=VARCHAR},
+         #{task.dueDate, jdbcType=TIMESTAMP},
+         #{task.category, jdbcType=VARCHAR},
+         #{task.suspensionState, jdbcType=INTEGER},
+         #{task.tenantId, jdbcType=VARCHAR},
+         #{task.formKey, jdbcType=VARCHAR},
+         #{task.claimTime, jdbcType=TIMESTAMP},
+         #{task.isCountEnabled, jdbcType=BOOLEAN},
+         #{task.variableCount, jdbcType=INTEGER},
+         #{task.identityLinkCount, jdbcType=INTEGER},
+         #{task.subTaskCount, jdbcType=INTEGER}
+         )
     </foreach>
     SELECT * FROM dual
   </insert>
@@ -148,111 +148,114 @@ under the License.
     <set>
       REV_ = #{revisionNext, jdbcType=INTEGER},
       <if test="originalPersistentState.name != name">
-        NAME_ = #{name, jdbcType=VARCHAR},
+          NAME_ = #{name, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.parentTaskId != parentTaskId">
-        PARENT_TASK_ID_ = #{parentTaskId, jdbcType=VARCHAR},
+          PARENT_TASK_ID_ = #{parentTaskId, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.priority != priority">
-        PRIORITY_ = #{priority, jdbcType=INTEGER},
+          PRIORITY_ = #{priority, jdbcType=INTEGER},
       </if>
       <if test="originalPersistentState.createTime != createTime">
-        CREATE_TIME_ = #{createTime, jdbcType=TIMESTAMP},
+          CREATE_TIME_ = #{createTime, jdbcType=TIMESTAMP},
       </if>
       <if test="originalPersistentState.owner != owner">
-        OWNER_ = #{owner, jdbcType=VARCHAR},
+          OWNER_ = #{owner, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.assignee != assignee">
-        ASSIGNEE_ = #{assignee, jdbcType=VARCHAR},
+          ASSIGNEE_ = #{assignee, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.delegationStateString != delegationStateString">
-        DELEGATION_ = #{delegationStateString, jdbcType=VARCHAR},
+          DELEGATION_ = #{delegationStateString, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.executionId != executionId">
-        EXECUTION_ID_ = #{executionId, jdbcType=VARCHAR},
+          EXECUTION_ID_ = #{executionId, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.processDefinitionId != processDefinitionId">
-        PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR},
+          PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.taskDefinitionId != taskDefinitionId">
-        TASK_DEF_ID_ = #{taskDefinitionId, jdbcType=VARCHAR},
+          TASK_DEF_ID_ = #{taskDefinitionId, jdbcType=VARCHAR},
+      </if>
+      <if test="originalPersistentState.taskDefinitionKey != taskDefinitionKey">
+          TASK_DEF_KEY_ = #{taskDefinitionKey, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.scopeId != scopeId">
-        SCOPE_ID_ = #{scopeId, jdbcType=VARCHAR}
+          SCOPE_ID_ = #{scopeId, jdbcType=VARCHAR}
       </if>
       <if test="originalPersistentState.subScopeId != subScopeId">
-        SUB_SCOPE_ID_ = #{subScopeId, jdbcType=VARCHAR}
+          SUB_SCOPE_ID_ = #{subScopeId, jdbcType=VARCHAR}
       </if>
       <if test="originalPersistentState.scopeType != scopeType">
-        SCOPE_TYPE_ = #{scopeType, jdbcType=VARCHAR}
+          SCOPE_TYPE_ = #{scopeType, jdbcType=VARCHAR}
       </if>
-      <if test="originalPersistentState.scopeDefinitionId != scopeDefinitionId">
-        SCOPE_DEFINITION_ID_ = #{scopeDefinitionId, jdbcType=VARCHAR}
+       <if test="originalPersistentState.scopeDefinitionId != scopeDefinitionId">
+          SCOPE_DEFINITION_ID_ = #{scopeDefinitionId, jdbcType=VARCHAR}
       </if>
       <if test="originalPersistentState.description != description">
-        DESCRIPTION_ = #{description, jdbcType=VARCHAR},
+          DESCRIPTION_ = #{description, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.dueDate != dueDate">
-        DUE_DATE_ = #{dueDate, jdbcType=TIMESTAMP},
+          DUE_DATE_ = #{dueDate, jdbcType=TIMESTAMP},
       </if>
       <if test="originalPersistentState.category != category">
-        CATEGORY_ = #{category, jdbcType=VARCHAR},
+          CATEGORY_ = #{category, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.suspensionState != suspensionState">
-        SUSPENSION_STATE_ = #{suspensionState, jdbcType=INTEGER},
+          SUSPENSION_STATE_ = #{suspensionState, jdbcType=INTEGER},
       </if>
       <if test="originalPersistentState.formKey != formKey">
-        FORM_KEY_ = #{formKey, jdbcType=VARCHAR},
+          FORM_KEY_ = #{formKey, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.claimTime != claimTime">
-        CLAIM_TIME_ = #{claimTime, jdbcType=TIMESTAMP},
+          CLAIM_TIME_ = #{claimTime, jdbcType=TIMESTAMP},
       </if>
       <if test="originalPersistentState.isCountEnabled != isCountEnabled">
-        IS_COUNT_ENABLED_ = #{isCountEnabled, jdbcType=BOOLEAN},
+          IS_COUNT_ENABLED_ = #{isCountEnabled, jdbcType=BOOLEAN},
       </if>
       <if test="originalPersistentState.variableCount != variableCount">
-        VAR_COUNT_ = #{variableCount, jdbcType=INTEGER},
+          VAR_COUNT_ = #{variableCount, jdbcType=INTEGER},
       </if>
       <if test="originalPersistentState.identityLinkCount != identityLinkCount">
-        ID_LINK_COUNT_ = #{identityLinkCount, jdbcType=INTEGER},
+          ID_LINK_COUNT_ = #{identityLinkCount, jdbcType=INTEGER},
       </if>
       <if test="originalPersistentState.subTaskCount != subTaskCount">
-        SUB_TASK_COUNT_ = #{subTaskCount, jdbcType=INTEGER}
+          SUB_TASK_COUNT_ = #{subTaskCount, jdbcType=INTEGER}
       </if>
     </set>
     where ID_= #{id, jdbcType=VARCHAR}
-    and REV_ = #{revision, jdbcType=INTEGER}
+      and REV_ = #{revision, jdbcType=INTEGER}
   </update>
   
   <update id="updateTaskTenantIdForDeployment" parameterType="java.util.Map">
     update ${prefix}ACT_RU_TASK set
-    TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
+      TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
     where
-    ID_ in (
-    SELECT T.ID_ from ${prefix}ACT_RU_TASK T
-    inner join ${prefix}ACT_RE_PROCDEF P on T.PROC_DEF_ID_  = P.ID_
-    inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_ 
-    where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
-    ) 
+      ID_ in (
+        SELECT T.ID_ from ${prefix}ACT_RU_TASK T
+        inner join ${prefix}ACT_RE_PROCDEF P on T.PROC_DEF_ID_  = P.ID_
+        inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_ 
+        where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
+      ) 
   </update>
   
-  <!-- See http://stackoverflow.com/questions/4429319/you-cant-specify-target-table-for-update-in-from-clause
-  Tested this on MySQL 5.6: does NOT use a temporary table (so good, performance0 -->
+    <!-- See http://stackoverflow.com/questions/4429319/you-cant-specify-target-table-for-update-in-from-clause
+       Tested this on MySQL 5.6: does NOT use a temporary table (so good, performance0 -->
   <update id="updateTaskTenantIdForDeployment" databaseId="mysql" parameterType="java.util.Map">
     update ${prefix}ACT_RU_TASK set
-    TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
+      TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
     where
-    ID_ in (
+      ID_ in (
 
-    SELECT tempTask.tempId
-    FROM (
-    SELECT T.ID_ as tempId
-    FROM  ${prefix}ACT_RU_TASK T
-    inner join ${prefix}ACT_RE_PROCDEF P on T.PROC_DEF_ID_  = P.ID_
-    inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_ 
-    where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
+          SELECT tempTask.tempId
+          FROM (
+                SELECT T.ID_ as tempId
+                FROM  ${prefix}ACT_RU_TASK T
+                inner join ${prefix}ACT_RE_PROCDEF P on T.PROC_DEF_ID_  = P.ID_
+                inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_ 
+                where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
                 
-    ) AS tempTask 
+        ) AS tempTask 
 
     )
   </update>
@@ -275,7 +278,7 @@ under the License.
   <delete id="bulkDeleteTask" parameterType="java.util.Collection">
     delete from ${prefix}ACT_RU_TASK where 
     <foreach item="task" collection="list" index="index" separator=" or ">
-      ID_ = #{task.id, jdbcType=VARCHAR}
+        ID_ = #{task.id, jdbcType=VARCHAR}
     </foreach>
   </delete>
   
@@ -371,7 +374,7 @@ under the License.
   <!-- TASK SELECT -->  
 
   <select id="selectTask" parameterType="string" resultMap="taskResultMap">
-    select * from ${prefix}ACT_RU_TASK where ID_ = #{id, jdbcType=VARCHAR}
+   select * from ${prefix}ACT_RU_TASK where ID_ = #{id, jdbcType=VARCHAR}
   </select>
   
   <select id="selectTasksByParentTaskId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="taskResultMap">
@@ -403,16 +406,15 @@ under the License.
   </select>
   
   <!-- Using distinct here because a task can appear multiple times in a resultset when -->
-  <select id="selectTaskByQueryCriteria" parameterType="org.apache.syncope.core.flowable.impl.SyncopeTaskQueryImpl" resultMap="taskResultMap">
+  <select id="selectTaskByQueryCriteria" parameterType="org.apache.syncope.core.flowable.support.SyncopeTaskQueryImpl" resultMap="taskResultMap">
     <if test="firstResult != null and firstResult &gt;= 0">${limitBefore}</if>
-    select distinct RES.* <if test="nullHandlingColumn != null">, ${nullHandlingColumn}</if> 
-    <if test="firstResult != null and firstResult &gt;= 0">${limitBetween}</if>
+    select distinct RES.* <if test="nullHandlingColumn != null">, ${nullHandlingColumn}</if> <if test="firstResult != null and firstResult &gt;= 0">${limitBetween}</if>
     <include refid="selectTaskByQueryCriteriaSql"/> 
     ${orderBy}
     <if test="firstResult != null and firstResult &gt;= 0">${limitAfter}</if>
   </select>
 
-  <select id="selectTaskCountByQueryCriteria" parameterType="org.apache.syncope.core.flowable.impl.SyncopeTaskQueryImpl" resultType="long">
+  <select id="selectTaskCountByQueryCriteria" parameterType="org.apache.syncope.core.flowable.support.SyncopeTaskQueryImpl" resultType="long">
     select count(distinct RES.ID_)
     <include refid="selectTaskByQueryCriteriaSql"/>
   </select>
@@ -422,7 +424,7 @@ under the License.
     <include refid="commonSelectTaskByQueryCriteriaSql"/>
   </sql>
   
-  <select id="selectTasksWithRelatedEntitiesByQueryCriteria" parameterType="org.apache.syncope.core.flowable.impl.SyncopeTaskQueryImpl" resultMap="taskAndRelatedEntitiesResultMap">
+  <select id="selectTasksWithRelatedEntitiesByQueryCriteria" parameterType="org.apache.syncope.core.flowable.support.SyncopeTaskQueryImpl" resultMap="taskAndRelatedEntitiesResultMap">
     <include refid="selectTasksWithRelatedEntitiesByQueryCriteriaColumns"/>
     <include refid="selectTasksWithRelatedEntitiesByQueryCriteriaSql"/>
     ${orderBy}
@@ -431,8 +433,8 @@ under the License.
 
   <sql id="selectTasksWithRelatedEntitiesByQueryCriteriaColumns">
     <if test="firstResult != null and firstResult &gt;= 0">${limitBefore}</if>
-    <if test="_databaseId != 'db2' and _databaseId != 'mssql'">
-      select RES.*,
+  	<if test="_databaseId != 'db2' and _databaseId != 'mssql'">
+    select RES.*,
       <if test="includeTaskLocalVariables or includeProcessVariables">
         VAR.ID_ as VAR_ID_, VAR.NAME_ as VAR_NAME_, VAR.TYPE_ as VAR_TYPE_, VAR.REV_ as VAR_REV_,
         VAR.PROC_INST_ID_ as VAR_PROC_INST_ID_, VAR.EXECUTION_ID_ as VAR_EXECUTION_ID_, VAR.TASK_ID_ as VAR_TASK_ID_,
@@ -447,7 +449,7 @@ under the License.
         ILINK.GROUP_ID_ as ILINK_GROUP_ID_, ILINK.TASK_ID_ as ILINK_TASK_ID_,
         ILINK.PROC_INST_ID_ as ILINK_PROC_INST_ID_, ILINK.PROC_DEF_ID_ as ILINK_PROC_DEF_ID_
       </if>
-      <if test="firstResult != null and firstResult &gt;= 0">${limitBetween}</if>
+    <if test="firstResult != null and firstResult &gt;= 0">${limitBetween}</if>
     </if>
     <if test="_databaseId == 'db2' || _databaseId == 'mssql'">
       select distinct TEMPRES_ID_ as ID_, TEMPRES_REV_ as REV_, TEMPRES_NAME_ as NAME_,
@@ -518,43 +520,29 @@ under the License.
     </if>
     <include refid="commonSelectTaskByQueryCriteriaSql"/>
   </sql>
-  
+
   <sql id="commonSelectTaskByQueryCriteriaSql">
-    <if test="candidateUser != null || candidateGroups != null || bothCandidateAndAssigned">
-      <choose>
-        <when test="bothCandidateAndAssigned">left</when>
-        <otherwise>inner</otherwise>
-      </choose>
-      join ${prefix}ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES.ID_
-    </if>
     <foreach collection="queryVariableValues" index="index" item="var">
       <if test="!var.operator.equals('EXISTS') &amp;&amp; !var.operator.equals('NOT_EXISTS')">
-        <choose>
-          <when test="var.local">
-            inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.TASK_ID_ 
-          </when>
-          <otherwise>
-            inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.PROC_INST_ID_ = A${index}.PROC_INST_ID_ 
-          </otherwise>
-        </choose>
+          <choose>
+            <when test="var.local">
+              inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.TASK_ID_ 
+            </when>
+            <otherwise>
+              inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.PROC_INST_ID_ = A${index}.PROC_INST_ID_ 
+            </otherwise>
+          </choose>
       </if>       
     </foreach>
     <foreach collection="orQueryObjects" index="orIndex" item="orQueryObject">
-      <if test="orQueryObject.candidateUser != null || orQueryObject.candidateGroups != null || orQueryObject.bothCandidateAndAssigned">
-        <choose>
-          <when test="orQueryObject.bothCandidateAndAssigned">left</when>
-          <otherwise>inner</otherwise>
-        </choose>
-        join ${prefix}ACT_RU_IDENTITYLINK I_OR${orIndex} on I_OR${orIndex}.TASK_ID_ = RES.ID_
-      </if>
       <if test="orQueryObject.queryVariableValues.size() &gt; 0">
         <if test="orQueryObject.hasValueComparisonQueryVariables()">
-          <if test="orQueryObject.hasLocalQueryVariableValue()">
-            left outer join ${prefix}ACT_RU_VARIABLE A_L_OR${orIndex} on RES.ID_ = A_L_OR${orIndex}.TASK_ID_
-          </if>
-          <if test="orQueryObject.hasNonLocalQueryVariableValue()">
-            left outer join ${prefix}ACT_RU_VARIABLE A_OR${orIndex} on RES.PROC_INST_ID_ = A_OR${orIndex}.PROC_INST_ID_
-          </if>
+            <if test="orQueryObject.hasLocalQueryVariableValue()">
+              left outer join ${prefix}ACT_RU_VARIABLE A_L_OR${orIndex} on RES.ID_ = A_L_OR${orIndex}.TASK_ID_
+            </if>
+            <if test="orQueryObject.hasNonLocalQueryVariableValue()">
+              left outer join ${prefix}ACT_RU_VARIABLE A_OR${orIndex} on RES.PROC_INST_ID_ = A_OR${orIndex}.PROC_INST_ID_
+            </if>
         </if>
       </if>
       
@@ -653,7 +641,7 @@ under the License.
       <if test="ownerLike != null">
         and RES.OWNER_ like #{ownerLike}${wildcardEscapeClause}
       </if>
-      <if test="ownerLikeIgnoreCase != null">
+       <if test="ownerLikeIgnoreCase != null">
         and lower(RES.OWNER_) like #{ownerLikeIgnoreCase}${wildcardEscapeClause}
       </if>
       <if test="unassigned">
@@ -780,15 +768,15 @@ under the License.
       </if>
       <if test="cmmnDeploymentIds != null &amp;&amp; cmmnDeploymentIds.size() &gt; 0 &amp;&amp; deploymentIds != null &amp;&amp; deploymentIds.size() &gt; 0">
         and (
-        DEPLOY_P.DEPLOYMENT_ID_ IN
-        <foreach item="deployment" index="index" collection="deploymentIds" open="(" separator="," close=")">
-          #{deployment}
-        </foreach>
-        or
-        DEPLOY_C.DEPLOYMENT_ID_ IN
-        <foreach item="cmmnDeployment" index="index" collection="cmmnDeploymentIds" open="(" separator="," close=")">
-          #{cmmnDeployment}
-        </foreach>
+            DEPLOY_P.DEPLOYMENT_ID_ IN
+            <foreach item="deployment" index="index" collection="deploymentIds" open="(" separator="," close=")">
+                #{deployment}
+            </foreach>
+            or
+            DEPLOY_C.DEPLOYMENT_ID_ IN
+            <foreach item="cmmnDeployment" index="index" collection="cmmnDeploymentIds" open="(" separator="," close=")">
+                #{cmmnDeployment}
+            </foreach>
         )
       </if>
       <if test="dueDate != null">
@@ -819,137 +807,142 @@ under the License.
       </if>
       <if test="!bothCandidateAndAssigned &amp;&amp; (candidateUser != null || candidateGroups != null)">
         <if test="!ignoreAssigneeValue">
-          and RES.ASSIGNEE_ is null
-        </if>
-        and I.TYPE_ = 'candidate'
-        and 
-        ( 
-        <if test="candidateUser != null">
-          I.USER_ID_ = #{candidateUser}          
-        </if>
-        <if test="candidateUser != null &amp;&amp; candidateGroups != null &amp;&amp; candidateGroups.size() &gt; 0">
-          or
-        </if>
-        <if test="candidateGroups != null &amp;&amp; candidateGroups.size() &gt; 0">
-          I.GROUP_ID_ IN
-          <foreach item="group" index="index" collection="candidateGroups" 
-                     open="(" separator="," close=")">
-            #{group}
-          </foreach>
+            and RES.ASSIGNEE_ is null
         </if>
+        and exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TYPE_ = 'candidate' and LINK.TASK_ID_ = RES.ID_
+            and 
+            ( 
+              <if test="candidateUser != null">
+                LINK.USER_ID_ = #{candidateUser}          
+              </if>
+              <if test="candidateUser != null &amp;&amp; candidateGroups != null &amp;&amp; candidateGroups.size() &gt; 0">
+                or
+              </if>
+              <if test="candidateGroups != null &amp;&amp; candidateGroups.size() &gt; 0">
+                LINK.GROUP_ID_ IN
+                <foreach item="group" index="index" collection="candidateGroups" 
+                         open="(" separator="," close=")">
+                  #{group}
+                </foreach>
+              </if>
+            )
         )
       </if>
       <if test="involvedUser != null">
         and (
-        exists(select LINK.USER_ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where USER_ID_ = #{involvedUser} and LINK.TASK_ID_ = RES.ID_)
-        or RES.ASSIGNEE_ = #{involvedUser}
-        or RES.OWNER_ = #{involvedUser}
+          exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.USER_ID_ = #{involvedUser} and LINK.TASK_ID_ = RES.ID_)
+          or RES.ASSIGNEE_ = #{involvedUser}
+          or RES.OWNER_ = #{involvedUser}
+          )
+      </if>
+      <if test="involvedGroups != null">
+        and EXISTS(
+          select ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_ and LINK.GROUP_ID_ in
+          <foreach item="involvedGroup" index="index" collection="involvedGroups" open="(" separator="," close=")">
+              #{involvedGroup}
+          </foreach>
         )
       </if>
       <foreach item="var" collection="queryVariableValues" index="index">
         <choose>
-          <when test="var.operator.equals('EXISTS')">
-            and EXISTS (
-            select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
-            <if test="!var.local">
-              and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
-            </if>
-            <if test="var.local">
-              and RES.ID_ = TASK_ID_ 
-            </if>
-            )
-          </when>
-          <when test="var.operator.equals('NOT_EXISTS')">
-            and NOT EXISTS (
-            select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
-            <if test="!var.local">
-              and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
-            </if>
-            <if test="var.local">
-              and RES.ID_ = TASK_ID_ 
-            </if>
-            )
-          </when>
-          <otherwise>
-            <if test="!var.local">
-              <!-- When process instance variable is queried for, taskId should be null -->
-              and A${index}.TASK_ID_ is null
-            </if>
-            <if test="var.name != null">
-              <!-- Match-all variable-names when name is null -->
-              and A${index}.NAME_= #{var.name}
-            </if>
-            <if test="var.name == null">
-              and A${index}.NAME_ is not null
-            </if>
-            <if test="!var.type.equals('null')">
-              and A${index}.TYPE_ = #{var.type}
-            </if>
+            <when test="var.operator.equals('EXISTS')">
+              and EXISTS (
+                select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
+                <if test="!var.local">
+                    and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
+                </if>
+                <if test="var.local">
+                    and RES.ID_ = TASK_ID_ 
+                </if>
+              )
+            </when>
+            <when test="var.operator.equals('NOT_EXISTS')">
+              and NOT EXISTS (
+                select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
+                <if test="!var.local">
+                    and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
+                </if>
+                <if test="var.local">
+                    and RES.ID_ = TASK_ID_ 
+                </if>
+              )
+            </when>
+            <otherwise>
+                <if test="!var.local">
+                  <!-- When process instance variable is queried for, taskId should be null -->
+                  and A${index}.TASK_ID_ is null
+                </if>
+                <if test="var.name != null">
+                  <!-- Match-all variable-names when name is null -->
+                  and A${index}.NAME_= #{var.name}
+                </if>
+                <if test="var.name == null">
+                  and A${index}.NAME_ is not null
+                </if>
+                <if test="!var.type.equals('null')">
+                  and A${index}.TYPE_ = #{var.type}
+                </if>
                 
-            <!-- Variable value -->
-            <if test="var.textValue != null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
-              <choose>
-                <when test="var.operator.equals('EQUALS_IGNORE_CASE') || var.operator.equals('NOT_EQUALS_IGNORE_CASE') || var.operator.equals('LIKE_IGNORE_CASE')">
-                  and lower(A${index}.TEXT_)
-                </when>
-                <otherwise>
-                  and A${index}.TEXT_
-                </otherwise>
-              </choose> 
-              <choose>
-                <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
-                <otherwise>
+                <!-- Variable value -->
+                <if test="var.textValue != null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
+                  <choose>
+                    <when test="var.operator.equals('EQUALS_IGNORE_CASE') || var.operator.equals('NOT_EQUALS_IGNORE_CASE') || var.operator.equals('LIKE_IGNORE_CASE')">
+                      and lower(A${index}.TEXT_)
+                    </when>
+                    <otherwise>
+                      and A${index}.TEXT_
+                    </otherwise>
+                  </choose> 
+                  <choose>
+                      <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
+                      <otherwise><include refid="executionVariableOperator" /></otherwise>
+                  </choose>          
+                  #{var.textValue}
+                  <choose>
+        			<when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
+        		  </choose>
+                </if>
+                <if test="var.textValue2 != null">
+                  and A${index}.TEXT2_ 
+                  <choose>
+                    <when test="var.operator.equals('LIKE')">LIKE</when>
+                    <otherwise><include refid="executionVariableOperator" /></otherwise>
+                  </choose>          
+                  #{var.textValue2}
+                  <choose>
+        			<when test="var.operator.equals('LIKE')">${wildcardEscapeClause}</when>
+        		  </choose>
+                </if>
+                <if test="var.longValue != null">
+                  and A${index}.LONG_
                   <include refid="executionVariableOperator" />
-                </otherwise>
-              </choose>          
-              #{var.textValue}
-              <choose>
-                <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
-              </choose>
-            </if>
-            <if test="var.textValue2 != null">
-              and A${index}.TEXT2_ 
-              <choose>
-                <when test="var.operator.equals('LIKE')">LIKE</when>
-                <otherwise>
+                  #{var.longValue}
+                </if>
+                <if test="var.doubleValue != null">
+                  and A${index}.DOUBLE_ 
                   <include refid="executionVariableOperator" />
-                </otherwise>
-              </choose>          
-              #{var.textValue2}
-              <choose>
-                <when test="var.operator.equals('LIKE')">${wildcardEscapeClause}</when>
-              </choose>
-            </if>
-            <if test="var.longValue != null">
-              and A${index}.LONG_
-              <include refid="executionVariableOperator" />
-              #{var.longValue}
-            </if>
-            <if test="var.doubleValue != null">
-              and A${index}.DOUBLE_ 
-              <include refid="executionVariableOperator" />
-              #{var.doubleValue}
-            </if>
-            <!-- Null variable type -->
-            <if test="var.textValue == null &amp;&amp; var.textValue2 == null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
-              <choose>
-                <when test="var.operator.equals('NOT_EQUALS')">
-                  and (A${index}.TEXT_ is not null or A${index}.TEXT2_ is not null or A${index}.LONG_ is not null or A${index}.DOUBLE_ is not null or A${index}.BYTEARRAY_ID_ is not null)
-                </when>
-                <otherwise>
-                  and A${index}.TEXT_ is null and A${index}.TEXT2_ is null and A${index}.LONG_ is null and A${index}.DOUBLE_ is null and A${index}.BYTEARRAY_ID_ is null
-                </otherwise>
-              </choose>          
-            </if>
-          </otherwise>
+                  #{var.doubleValue}
+                </if>
+                <!-- Null variable type -->
+                <if test="var.textValue == null &amp;&amp; var.textValue2 == null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
+                  <choose>
+                    <when test="var.operator.equals('NOT_EQUALS')">
+                      and (A${index}.TEXT_ is not null or A${index}.TEXT2_ is not null or A${index}.LONG_ is not null or A${index}.DOUBLE_ is not null or A${index}.BYTEARRAY_ID_ is not null)
+                    </when>
+                    <otherwise>
+                      and A${index}.TEXT_ is null and A${index}.TEXT2_ is null and A${index}.LONG_ is null and A${index}.DOUBLE_ is null and A${index}.BYTEARRAY_ID_ is null
+                    </otherwise>
+                  </choose>          
+                </if>
+            </otherwise>
         </choose>
       </foreach>
       <if test="suspensionState != null">
         <if test="suspensionState.stateCode == 1">
-          and RES.SUSPENSION_STATE_ = 1
+            and RES.SUSPENSION_STATE_ = 1
         </if>
         <if test="suspensionState.stateCode == 2">
-          and RES.SUSPENSION_STATE_ = 2
+            and RES.SUSPENSION_STATE_ = 2
         </if>
       </if>
       <if test="tenantId != null">
@@ -967,431 +960,441 @@ under the License.
           <if test="userIdForCandidateAndAssignee != null">
             <if test="candidateGroups == null">
               and (RES.ASSIGNEE_ = #{userIdForCandidateAndAssignee}
-              or (
-              <if test="!ignoreAssigneeValue">
-                RES.ASSIGNEE_ is null
-              </if>
-              and (I.USER_ID_ = #{userIdForCandidateAndAssignee}
-              or I.GROUP_ID_ IN (select g.GROUP_ID_ from ${prefix}ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{userIdForCandidateAndAssignee} ) ) ) )
+                or (
+                <if test="!ignoreAssigneeValue">
+                    RES.ASSIGNEE_ is null and
+                </if>
+                exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_
+                and (LINK.USER_ID_ = #{userIdForCandidateAndAssignee}
+                or LINK.GROUP_ID_ IN (select g.GROUP_ID_ from ${prefix}ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{userIdForCandidateAndAssignee} )))))
             </if>
           </if>
           <!-- if dbIdentityUsed set false in process engine configuration of using custom session factory of GroupIdentityManager -->
           <if test="candidateGroups != null">
             and (RES.ASSIGNEE_ = #{userIdForCandidateAndAssignee}
-            
-            or (
-            <if test="!ignoreAssigneeValue">
-              RES.ASSIGNEE_ is null and
-            </if>
-            I.TYPE_ = 'candidate' and (I.USER_ID_ = #{userIdForCandidateAndAssignee}
-            <if test="candidateGroups.size() &gt; 0">
-              or I.GROUP_ID_ IN
-              <foreach item="group" index="index" collection="candidateGroups" open="(" separator="," close=")">
-                #{group}
-              </foreach>
-            </if>
-            )))
+              or (
+              <if test="!ignoreAssigneeValue">
+                RES.ASSIGNEE_ is null and
+              </if>
+                exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_
+                and LINK.TYPE_ = 'candidate' and (LINK.USER_ID_ = #{userIdForCandidateAndAssignee}
+                <if test="candidateGroups.size() &gt; 0">
+                    or LINK.GROUP_ID_ IN
+                    <foreach item="group" index="index" collection="candidateGroups" open="(" separator="," close=")">
+                        #{group}
+                    </foreach>
+                </if>
+                ))))
           </if>
         </when>
       </choose>
       <foreach item="orQueryObject" index="orIndex" collection="orQueryObjects">
         and 
         <trim prefix="(" prefixOverrides="OR" suffix=")">
-          <if test="orQueryObject.taskId != null">
-            RES.ID_ = #{orQueryObject.taskId}
-          </if>
-          <if test="orQueryObject.name != null">
-            or RES.NAME_ = #{orQueryObject.name}
-          </if>
-          <if test="orQueryObject.nameLike != null">
-            or RES.NAME_ like #{orQueryObject.nameLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.nameLikeIgnoreCase != null">
-            or lower(RES.NAME_) like #{orQueryObject.nameLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.nameList != null &amp;&amp; orQueryObject.nameList.size() &gt; 0">
-            or RES.NAME_ IN
-            <foreach item="name" index="index" collection="orQueryObject.nameList"
-                       open="(" separator="," close=")">
-              #{name}
-            </foreach>
-          </if>
-          <if test="orQueryObject.nameListIgnoreCase != null &amp;&amp; orQueryObject.nameListIgnoreCase.size() &gt; 0">
-            or lower(RES.NAME_) IN
-            <foreach item="name" index="index" collection="orQueryObject.nameListIgnoreCase"
-                       open="(" separator="," close=")">
-              #{name}
-            </foreach>
-          </if>
-          <if test="orQueryObject.description != null">
-            or RES.DESCRIPTION_ = #{orQueryObject.description}
-          </if>
-          <if test="orQueryObject.descriptionLike != null">
-            or RES.DESCRIPTION_ like #{orQueryObject.descriptionLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.descriptionLikeIgnoreCase != null">
-            or lower(RES.DESCRIPTION_) like #{orQueryObject.descriptionLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.priority != null">
-            or RES.PRIORITY_ = #{orQueryObject.priority}
-          </if> 
-          <if test="orQueryObject.minPriority != null">
-            or RES.PRIORITY_ &gt;= #{orQueryObject.minPriority}
-          </if> 
-          <if test="orQueryObject.maxPriority != null">
-            or RES.PRIORITY_ &lt;= #{orQueryObject.maxPriority}
-          </if> 
-          <if test="orQueryObject.assignee != null">
-            or RES.ASSIGNEE_ = #{orQueryObject.assignee}
-          </if>
-          <if test="orQueryObject.assigneeLike != null">
-            or RES.ASSIGNEE_ like #{orQueryObject.assigneeLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.assigneeLikeIgnoreCase != null">
-            or lower(RES.ASSIGNEE_) like #{orQueryObject.assigneeLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.assigneeIds != null &amp;&amp; orQueryObject.assigneeIds.size() &gt; 0">
-            or RES.ASSIGNEE_ IN
-            <foreach item="assigneeId" index="index" collection="orQueryObject.assigneeIds" 
+            <if test="orQueryObject.taskId != null">
+              RES.ID_ = #{orQueryObject.taskId}
+            </if>
+            <if test="orQueryObject.name != null">
+              or RES.NAME_ = #{orQueryObject.name}
+            </if>
+            <if test="orQueryObject.nameLike != null">
+              or RES.NAME_ like #{orQueryObject.nameLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.nameLikeIgnoreCase != null">
+              or lower(RES.NAME_) like #{orQueryObject.nameLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.nameList != null &amp;&amp; orQueryObject.nameList.size() &gt; 0">
+              or RES.NAME_ IN
+              <foreach item="name" index="index" collection="orQueryObject.nameList"
+                      open="(" separator="," close=")">
+                #{name}
+              </foreach>
+            </if>
+            <if test="orQueryObject.nameListIgnoreCase != null &amp;&amp; orQueryObject.nameListIgnoreCase.size() &gt; 0">
+              or lower(RES.NAME_) IN
+              <foreach item="name" index="index" collection="orQueryObject.nameListIgnoreCase"
                        open="(" separator="," close=")">
-              #{assigneeId}
-            </foreach>
-          </if>
-          <if test="orQueryObject.owner != null">
-            or RES.OWNER_ = #{orQueryObject.owner}
-          </if>
-          <if test="orQueryObject.ownerLike != null">
-            or RES.OWNER_ like #{orQueryObject.ownerLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.ownerLikeIgnoreCase != null">
-            or RES.OWNER_ like #{orQueryObject.ownerLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.unassigned">
-            or RES.ASSIGNEE_ IS NULL
-          </if>
-          <if test="orQueryObject.noDelegationState">
-            or RES.DELEGATION_ IS NULL
-          </if>
-          <if test="orQueryObject.delegationState != null">
-            or RES.DELEGATION_ = #{orQueryObject.delegationStateString}
-          </if>
-          <if test="orQueryObject.processInstanceId != null">
-            or RES.PROC_INST_ID_ = #{orQueryObject.processInstanceId}
-          </if>
-          <if test="orQueryObject.processInstanceIds != null &amp;&amp; orQueryObject.processInstanceIds.size() &gt; 0">
-            or RES.PROC_INST_ID_ IN
-            <foreach item="processInstance" index="index" collection="orQueryObject.processInstanceIds" 
+                #{name}
+              </foreach>
+            </if>
+            <if test="orQueryObject.description != null">
+              or RES.DESCRIPTION_ = #{orQueryObject.description}
+            </if>
+            <if test="orQueryObject.descriptionLike != null">
+              or RES.DESCRIPTION_ like #{orQueryObject.descriptionLike}${wildcardEscapeClause}
+            </if>
+             <if test="orQueryObject.descriptionLikeIgnoreCase != null">
+              or lower(RES.DESCRIPTION_) like #{orQueryObject.descriptionLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.priority != null">
+              or RES.PRIORITY_ = #{orQueryObject.priority}
+            </if> 
+            <if test="orQueryObject.minPriority != null">
+              or RES.PRIORITY_ &gt;= #{orQueryObject.minPriority}
+            </if> 
+            <if test="orQueryObject.maxPriority != null">
+              or RES.PRIORITY_ &lt;= #{orQueryObject.maxPriority}
+            </if> 
+            <if test="orQueryObject.assignee != null">
+              or RES.ASSIGNEE_ = #{orQueryObject.assignee}
+            </if>
+            <if test="orQueryObject.assigneeLike != null">
+              or RES.ASSIGNEE_ like #{orQueryObject.assigneeLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.assigneeLikeIgnoreCase != null">
+              or lower(RES.ASSIGNEE_) like #{orQueryObject.assigneeLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.assigneeIds != null &amp;&amp; orQueryObject.assigneeIds.size() &gt; 0">
+		      or RES.ASSIGNEE_ IN
+		      <foreach item="assigneeId" index="index" collection="orQueryObject.assigneeIds" 
+		               open="(" separator="," close=")">
+		        #{assigneeId}
+		      </foreach>
+		    </if>
+            <if test="orQueryObject.owner != null">
+              or RES.OWNER_ = #{orQueryObject.owner}
+            </if>
+            <if test="orQueryObject.ownerLike != null">
+              or RES.OWNER_ like #{orQueryObject.ownerLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.ownerLikeIgnoreCase != null">
+              or RES.OWNER_ like #{orQueryObject.ownerLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.unassigned">
+              or RES.ASSIGNEE_ IS NULL
+            </if>
+            <if test="orQueryObject.noDelegationState">
+              or RES.DELEGATION_ IS NULL
+            </if>
+            <if test="orQueryObject.delegationState != null">
+              or RES.DELEGATION_ = #{orQueryObject.delegationStateString}
+            </if>
+            <if test="orQueryObject.processInstanceId != null">
+              or RES.PROC_INST_ID_ = #{orQueryObject.processInstanceId}
+            </if>
+            <if test="orQueryObject.processInstanceIds != null &amp;&amp; orQueryObject.processInstanceIds.size() &gt; 0">
+              or RES.PROC_INST_ID_ IN
+              <foreach item="processInstance" index="index" collection="orQueryObject.processInstanceIds" 
                        open="(" separator="," close=")">
-              #{processInstance}
-            </foreach>
-          </if>
-          <if test="orQueryObject.processInstanceBusinessKey != null">
-            or E_OR${orIndex}.BUSINESS_KEY_ = #{orQueryObject.processInstanceBusinessKey}
-          </if>
-          <if test="orQueryObject.processInstanceBusinessKeyLike != null">
-            or E_OR${orIndex}.BUSINESS_KEY_ like #{orQueryObject.processInstanceBusinessKeyLike}${wildcardEscapeClause}
-          </if>      
-          <if test="orQueryObject.processInstanceBusinessKeyLikeIgnoreCase != null">
-            or lower(E.BUSINESS_KEY_) like #{orQueryObject.processInstanceBusinessKeyLikeIgnoreCase}${wildcardEscapeClause}
-          </if>         
-          <if test="orQueryObject.executionId != null">
-            or RES.EXECUTION_ID_ = #{orQueryObject.executionId}
-          </if>
-          <if test="orQueryObject.scopeId != null">
-            and RES.SCOPE_ID_ = #{orQueryObject.scopeId}
-          </if>
-          <if test="orQueryObject.subScopeId != null">
-            and RES.SUB_SCOPE_ID_ = #{orQueryObject.subScopeId}
-          </if>
-          <if test="orQueryObject.scopeType != null">
-            and RES.SCOPE_TYPE_ = #{orQueryObject.scopeType}
-          </if>
-          <if test="orQueryObject.scopeDefinitionId != null">
-            and RES.SCOPE_DEFINITION_ID_ = #{orQueryObject.scopeDefinitionId}
-          </if>
-          <if test="orQueryObject.createTime != null">
-            or RES.CREATE_TIME_ = #{orQueryObject.createTime}
-          </if>
-          <if test="orQueryObject.createTimeBefore != null">
-            or RES.CREATE_TIME_ &lt; #{orQueryObject.createTimeBefore}
-          </if>
-          <if test="orQueryObject.createTimeAfter != null">
-            or RES.CREATE_TIME_ &gt; #{orQueryObject.createTimeAfter}
-          </if>
-          <if test="orQueryObject.key != null">
-            or RES.TASK_DEF_KEY_ = #{orQueryObject.key}
-          </if>
-          <if test="orQueryObject.keyLike != null">
-            or RES.TASK_DEF_KEY_ like #{orQueryObject.keyLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.processDefinitionId != null">
-            or RES.PROC_DEF_ID_ = #{orQueryObject.processDefinitionId}
-          </if>
-          <if test="orQueryObject.taskDefinitionId != null">
-            or RES.TASK_DEF_ID_ = #{orQueryObject.taskDefinitionId}
-          </if>
-          <if test="orQueryObject.processDefinitionKey != null">
-            or D_OR${orIndex}.KEY_ = #{orQueryObject.processDefinitionKey}
-          </if>
-          <if test="orQueryObject.processDefinitionKeyLike != null">
-            or D_OR${orIndex}.KEY_ like #{orQueryObject.processDefinitionKeyLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.processDefinitionKeyLikeIgnoreCase != null">
-            or lower(D_OR${orIndex}.KEY_) like #{orQueryObject.processDefinitionKeyLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.processDefinitionKeys != null &amp;&amp; orQueryObject.processDefinitionKeys.size() &gt; 0">
-            or D_OR${orIndex}.KEY_ in
-            <foreach item="item" index="index" collection="orQueryObject.processDefinitionKeys" open="(" separator="," close=")">
-              #{item}
-            </foreach>
-          </if>
-          <if test="orQueryObject.processDefinitionName != null">
-            or D_OR${orIndex}.NAME_ = #{orQueryObject.processDefinitionName}
-          </if>
-          <if test="orQueryObject.processDefinitionNameLike != null">
-            or D_OR${orIndex}.NAME_ like #{orQueryObject.processDefinitionNameLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.processCategoryInList != null &amp;&amp; orQueryObject.processCategoryInList.size() &gt; 0">
-            or D_OR${orIndex}.CATEGORY_ IN
-            <foreach item="processCategory" index="index" collection="orQueryObject.processCategoryInList"
+                #{processInstance}
+              </foreach>
+            </if>
+            <if test="orQueryObject.processInstanceBusinessKey != null">
+              or E_OR${orIndex}.BUSINESS_KEY_ = #{orQueryObject.processInstanceBusinessKey}
+            </if>
+            <if test="orQueryObject.processInstanceBusinessKeyLike != null">
+              or E_OR${orIndex}.BUSINESS_KEY_ like #{orQueryObject.processInstanceBusinessKeyLike}${wildcardEscapeClause}
+            </if>      
+            <if test="orQueryObject.processInstanceBusinessKeyLikeIgnoreCase != null">
+              or lower(E.BUSINESS_KEY_) like #{orQueryObject.processInstanceBusinessKeyLikeIgnoreCase}${wildcardEscapeClause}
+            </if>         
+            <if test="orQueryObject.executionId != null">
+              or RES.EXECUTION_ID_ = #{orQueryObject.executionId}
+            </if>
+            <if test="orQueryObject.scopeId != null">
+              and RES.SCOPE_ID_ = #{orQueryObject.scopeId}
+            </if>
+            <if test="orQueryObject.subScopeId != null">
+              and RES.SUB_SCOPE_ID_ = #{orQueryObject.subScopeId}
+            </if>
+            <if test="orQueryObject.scopeType != null">
+              and RES.SCOPE_TYPE_ = #{orQueryObject.scopeType}
+            </if>
+            <if test="orQueryObject.scopeDefinitionId != null">
+              and RES.SCOPE_DEFINITION_ID_ = #{orQueryObject.scopeDefinitionId}
+            </if>
+            <if test="orQueryObject.createTime != null">
+              or RES.CREATE_TIME_ = #{orQueryObject.createTime}
+            </if>
+            <if test="orQueryObject.createTimeBefore != null">
+              or RES.CREATE_TIME_ &lt; #{orQueryObject.createTimeBefore}
+            </if>
+            <if test="orQueryObject.createTimeAfter != null">
+              or RES.CREATE_TIME_ &gt; #{orQueryObject.createTimeAfter}
+            </if>
+            <if test="orQueryObject.key != null">
+              or RES.TASK_DEF_KEY_ = #{orQueryObject.key}
+            </if>
+            <if test="orQueryObject.keyLike != null">
+              or RES.TASK_DEF_KEY_ like #{orQueryObject.keyLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.processDefinitionId != null">
+              or RES.PROC_DEF_ID_ = #{orQueryObject.processDefinitionId}
+            </if>
+            <if test="orQueryObject.taskDefinitionId != null">
+              or RES.TASK_DEF_ID_ = #{orQueryObject.taskDefinitionId}
+            </if>
+            <if test="orQueryObject.processDefinitionKey != null">
+              or D_OR${orIndex}.KEY_ = #{orQueryObject.processDefinitionKey}
+            </if>
+            <if test="orQueryObject.processDefinitionKeyLike != null">
+              or D_OR${orIndex}.KEY_ like #{orQueryObject.processDefinitionKeyLike}${wildcardEscapeClause}
+            </if>
+             <if test="orQueryObject.processDefinitionKeyLikeIgnoreCase != null">
+              or lower(D_OR${orIndex}.KEY_) like #{orQueryObject.processDefinitionKeyLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.processDefinitionKeys != null &amp;&amp; orQueryObject.processDefinitionKeys.size() &gt; 0">
+              or D_OR${orIndex}.KEY_ in
+              <foreach item="item" index="index" collection="orQueryObject.processDefinitionKeys" open="(" separator="," close=")">
+                #{item}
+              </foreach>
+            </if>
+            <if test="orQueryObject.processDefinitionName != null">
+              or D_OR${orIndex}.NAME_ = #{orQueryObject.processDefinitionName}
+            </if>
+            <if test="orQueryObject.processDefinitionNameLike != null">
+              or D_OR${orIndex}.NAME_ like #{orQueryObject.processDefinitionNameLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.processCategoryInList != null &amp;&amp; orQueryObject.processCategoryInList.size() &gt; 0">
+              or D_OR${orIndex}.CATEGORY_ IN
+              <foreach item="processCategory" index="index" collection="orQueryObject.processCategoryInList"
                        open="(" separator="," close=")">
-              #{processCategory}
-            </foreach>
-          </if>
-          <if test="orQueryObject.processCategoryNotInList != null &amp;&amp; orQueryObject.processCategoryNotInList.size() &gt; 0">
-            or D_OR${orIndex}.CATEGORY_ NOT IN
-            <foreach item="processCategory" index="index" collection="orQueryObject.processCategoryNotInList"
+                #{processCategory}
+              </foreach>
+            </if>
+            <if test="orQueryObject.processCategoryNotInList != null &amp;&amp; orQueryObject.processCategoryNotInList.size() &gt; 0">
+              or D_OR${orIndex}.CATEGORY_ NOT IN
+              <foreach item="processCategory" index="index" collection="orQueryObject.processCategoryNotInList"
                        open="(" separator="," close=")">
-              #{processCategory}
-            </foreach>
-          </if>
-          <if test="orQueryObject.deploymentId != null">
-            or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ = #{orQueryObject.deploymentId}
-          </if>
-          <if test="orQueryObject.deploymentIds != null &amp;&amp; orQueryObject.deploymentIds.size() &gt; 0">
-            or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ IN
-            <foreach item="deployment" index="index" collection="orQueryObject.deploymentIds" 
+                #{processCategory}
+              </foreach>
+            </if>
+            <if test="orQueryObject.deploymentId != null">
+              or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ = #{orQueryObject.deploymentId}
+            </if>
+            <if test="orQueryObject.deploymentIds != null &amp;&amp; orQueryObject.deploymentIds.size() &gt; 0">
+              or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ IN
+              <foreach item="deployment" index="index" collection="orQueryObject.deploymentIds" 
                        open="(" separator="," close=")">
-              #{deployment}
-            </foreach>
-          </if>
-          <if test="orQueryObject.cmmnDeploymentId != null">
-            or DEPLOY_C_OR${orIndex}.DEPLOYMENT_ID_ = #{orQueryObject.cmmnDeploymentId}
-          </if>
-          <if test="orQueryObject.cmmnDeploymentIds != null &amp;&amp; orQueryObject.cmmnDeploymentIds.size() &gt; 0">
-            or DEPLOY_C_OR${orIndex}.DEPLOYMENT_ID_ IN
-            <foreach item="deployment" index="index" collection="orQueryObject.cmmnDeploymentIds" 
+                #{deployment}
+              </foreach>
+            </if>
+            <if test="orQueryObject.cmmnDeploymentId != null">
+              or DEPLOY_C_OR${orIndex}.DEPLOYMENT_ID_ = #{orQueryObject.cmmnDeploymentId}
+            </if>
+            <if test="orQueryObject.cmmnDeploymentIds != null &amp;&amp; orQueryObject.cmmnDeploymentIds.size() &gt; 0">
+              or DEPLOY_C_OR${orIndex}.DEPLOYMENT_ID_ IN
+              <foreach item="deployment" index="index" collection="orQueryObject.cmmnDeploymentIds" 
                        open="(" separator="," close=")">
-              #{deployment}
-            </foreach>
-          </if>
-          <if test="orQueryObject.dueDate != null">
-            or RES.DUE_DATE_ = #{orQueryObject.dueDate}
-          </if>
-          <if test="orQueryObject.dueBefore != null">
-            or (RES.DUE_DATE_ &lt; #{orQueryObject.dueBefore} and RES.DUE_DATE_ is not null)
-          </if>
-          <if test="orQueryObject.dueAfter != null">
-            or (RES.DUE_DATE_ &gt; #{orQueryObject.dueAfter} and RES.DUE_DATE_ is not null)
-          </if>
-          <if test="orQueryObject.withoutDueDate">
-            or RES.DUE_DATE_ is null
-          </if>
-          <if test="orQueryObject.category != null">
-            or RES.CATEGORY_ = #{orQueryObject.category}
-          </if>
-          <if test="orQueryObject.excludeSubtasks">
-            or RES.PARENT_TASK_ID_ IS NULL
-          </if>
-            
-          <if test="!orQueryObject.bothCandidateAndAssigned &amp;&amp; (orQueryObject.candidateUser != null || orQueryObject.candidateGroups != null)">
-            or (
-            <if test="!orQueryObject.ignoreAssigneeValue">
-              RES.ASSIGNEE_ is null and
+                #{deployment}
+              </foreach>
             </if>
-            I_OR${orIndex}.TYPE_ = 'candidate'
-            and 
-            ( 
-            <if test="orQueryObject.candidateUser != null">
-              I_OR${orIndex}.USER_ID_ = #{orQueryObject.candidateUser}          
+            <if test="orQueryObject.dueDate != null">
+              or RES.DUE_DATE_ = #{orQueryObject.dueDate}
             </if>
-            <if test="orQueryObject.candidateUser != null &amp;&amp; orQueryObject.candidateGroups != null &amp;&amp; orQueryObject.candidateGroups.size() &gt; 0">
-              or
+            <if test="orQueryObject.dueBefore != null">
+              or (RES.DUE_DATE_ &lt; #{orQueryObject.dueBefore} and RES.DUE_DATE_ is not null)
             </if>
-            <if test="orQueryObject.candidateGroups != null &amp;&amp; orQueryObject.candidateGroups.size() &gt; 0">
-              I_OR${orIndex}.GROUP_ID_ IN
-              <foreach item="group" index="index" collection="orQueryObject.candidateGroups" 
-                           open="(" separator="," close=")">
-                #{group}
-              </foreach>
+            <if test="orQueryObject.dueAfter != null">
+              or (RES.DUE_DATE_ &gt; #{orQueryObject.dueAfter} and RES.DUE_DATE_ is not null)
             </if>
-            ))
-          </if>
-          <if test="orQueryObject.involvedUser != null">
-            or (
-            exists(select LINK.USER_ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where USER_ID_ = #{orQueryObject.involvedUser} and LINK.TASK_ID_ = RES.ID_)
-            or RES.ASSIGNEE_ = #{orQueryObject.involvedUser}
-            or RES.OWNER_ = #{orQueryObject.involvedUser}
-            )
-          </if>
-          <foreach item="var" collection="orQueryObject.queryVariableValues" index="index">
-            or 
-            <trim prefix="(" prefixOverrides="AND" suffix=")">
-              <choose>
-                <when test="var.operator.equals('EXISTS')">
-                  and EXISTS (
-                  select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
-                  <if test="!var.local">
-                    and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
-                  </if>
-                  <if test="var.local">
-                    and RES.ID_ = TASK_ID_ 
-                  </if>
-                  )
-                </when>
-                <when test="var.operator.equals('NOT_EXISTS')">
-                  and NOT EXISTS (
-                  select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
-                  <if test="!var.local">
-                    and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
-                  </if>
-                  <if test="var.local">
-                    and RES.ID_ = TASK_ID_ 
-                  </if>
-                  )
-                </when>
-                <otherwise>
-                  <choose>
-                    <when test="!var.local">
-                      <bind name="orLocal" value="''" />
-                      <!-- When process instance variable is queried for, taskId should be null -->
-                      and A_OR${orIndex}.TASK_ID_ is null
+            <if test="orQueryObject.withoutDueDate">
+              or RES.DUE_DATE_ is null
+            </if>
+            <if test="orQueryObject.category != null">
+              or RES.CATEGORY_ = #{orQueryObject.category}
+            </if>
+            <if test="orQueryObject.excludeSubtasks">
+              or RES.PARENT_TASK_ID_ IS NULL
+            </if>
+            
+            <if test="!orQueryObject.bothCandidateAndAssigned &amp;&amp; (orQueryObject.candidateUser != null || orQueryObject.candidateGroups != null)">
+              or (
+                <if test="!orQueryObject.ignoreAssigneeValue">
+                    RES.ASSIGNEE_ is null and
+                </if>
+                exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TYPE_ = 'candidate' and LINK.TASK_ID_ = RES.ID_
+                    and 
+                    ( 
+                    <if test="orQueryObject.candidateUser != null">
+                      LINK.USER_ID_ = #{orQueryObject.candidateUser}          
+                    </if>
+                    <if test="orQueryObject.candidateUser != null &amp;&amp; orQueryObject.candidateGroups != null &amp;&amp; orQueryObject.candidateGroups.size() &gt; 0">
+                      or
+                    </if>
+                    <if test="orQueryObject.candidateGroups != null &amp;&amp; orQueryObject.candidateGroups.size() &gt; 0">
+                      LINK.GROUP_ID_ IN
+                      <foreach item="group" index="index" collection="orQueryObject.candidateGroups" 
+                               open="(" separator="," close=")">
+                        #{group}
+                      </foreach>
+                    </if>
+                    )
+                )
+              )
+            </if>
+            <if test="orQueryObject.involvedUser != null">
+              or (
+                exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.USER_ID_ = #{orQueryObject.involvedUser} and LINK.TASK_ID_ = RES.ID_)
+                or RES.ASSIGNEE_ = #{orQueryObject.involvedUser}
+                or RES.OWNER_ = #{orQueryObject.involvedUser}
+                )
+            </if>
+            <if test="orQueryObject.involvedGroups != null">
+              or (
+                EXISTS(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_ and LINK.GROUP_ID_ in
+                <foreach item="involvedGroup" index="index" collection="orQueryObject.involvedGroups" open="(" separator="," close=")">
+                    #{involvedGroup}
+                </foreach>
+                )
+              )
+            </if>
+            <foreach item="var" collection="orQueryObject.queryVariableValues" index="index">
+              or 
+              <trim prefix="(" prefixOverrides="AND" suffix=")">
+                <choose>
+                    <when test="var.operator.equals('EXISTS')">
+                        and EXISTS (
+                            select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
+                        <if test="!var.local">
+                            and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
+                        </if>
+                        <if test="var.local">
+                            and RES.ID_ = TASK_ID_ 
+                        </if>
+                        )
+                    </when>
+                    <when test="var.operator.equals('NOT_EXISTS')">
+                        and NOT EXISTS (
+                            select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
+                        <if test="!var.local">
+                            and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
+                        </if>
+                        <if test="var.local">
+                            and RES.ID_ = TASK_ID_ 
+                        </if>
+                        )
                     </when>
                     <otherwise>
-                      <bind name="orLocal" value="'L_'" />
-                    </otherwise>
-                  </choose>
-                  <if test="var.name != null">
-                    <!-- Match-all variable-names when name is null -->
-                    and A_${orLocal}OR${orIndex}.NAME_= #{var.name}
-                  </if>
-                  <if test="var.name == null">
-                    and A_${orLocal}OR${orIndex}.NAME_ is not null
-                  </if>
-                  <if test="!var.type.equals('null')">
-                    and A_${orLocal}OR${orIndex}.TYPE_ = #{var.type}
-                  </if>
-                  <!-- Variable value -->
-                  <if test="var.textValue != null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
-                    <choose>
-                      <when test="var.operator.equals('EQUALS_IGNORE_CASE') || var.operator.equals('NOT_EQUALS_IGNORE_CASE') || var.operator.equals('LIKE_IGNORE_CASE')">
-                        and lower(A_${orLocal}OR${orIndex}.TEXT_)
-                      </when>
-                      <otherwise>
-                        and A_${orLocal}OR${orIndex}.TEXT_
-                      </otherwise>
-                    </choose> 
-                    <choose>
-                      <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
-                      <otherwise>
+                      <choose>
+                        <when test="!var.local">
+                          <bind name="orLocal" value="''" />
+                          <!-- When process instance variable is queried for, taskId should be null -->
+                          and A_OR${orIndex}.TASK_ID_ is null
+                        </when>
+                        <otherwise>
+                          <bind name="orLocal" value="'L_'" />
+                        </otherwise>
+                      </choose>
+                      <if test="var.name != null">
+                        <!-- Match-all variable-names when name is null -->
+                        and A_${orLocal}OR${orIndex}.NAME_= #{var.name}
+                      </if>
+                      <if test="var.name == null">
+                        and A_${orLocal}OR${orIndex}.NAME_ is not null
+                      </if>
+                      <if test="!var.type.equals('null')">
+                        and A_${orLocal}OR${orIndex}.TYPE_ = #{var.type}
+                      </if>
+                      <!-- Variable value -->
+                      <if test="var.textValue != null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
+                        <choose>
+                          <when test="var.operator.equals('EQUALS_IGNORE_CASE') || var.operator.equals('NOT_EQUALS_IGNORE_CASE') || var.operator.equals('LIKE_IGNORE_CASE')">
+                            and lower(A_${orLocal}OR${orIndex}.TEXT_)
+                          </when>
+                          <otherwise>
+                            and A_${orLocal}OR${orIndex}.TEXT_
+                          </otherwise>
+                        </choose> 
+                        <choose>
+                            <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
+                            <otherwise><include refid="executionVariableOperator" /></otherwise>
+                        </choose>          
+                        #{var.textValue}
+                        <choose>
+                            <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
+                        </choose>
+                      </if>
+                      <if test="var.textValue2 != null">
+                        and A_${orLocal}OR${orIndex}.TEXT2_
+                        <choose>
+                          <when test="var.operator.equals('LIKE')">LIKE</when>
+                          <otherwise><include refid="executionVariableOperator" /></otherwise>
+                        </choose>          
+                        #{var.textValue2}
+                        <choose>
+                          <when test="var.operator.equals('LIKE')">${wildcardEscapeClause}</when>
+                        </choose>
+                      </if>
+                      <if test="var.longValue != null">
+                        and A_${orLocal}OR${orIndex}.LONG_
                         <include refid="executionVariableOperator" />
-                      </otherwise>
-                    </choose>          
-                    #{var.textValue}
-                    <choose>
-                      <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
-                    </choose>
-                  </if>
-                  <if test="var.textValue2 != null">
-                    and A_${orLocal}OR${orIndex}.TEXT2_
-                    <choose>
-                      <when test="var.operator.equals('LIKE')">LIKE</when>
-                      <otherwise>
+                        #{var.longValue}
+                      </if>
+                      <if test="var.doubleValue != null">
+                        and A_${orLocal}OR${orIndex}.DOUBLE_
                         <include refid="executionVariableOperator" />
-                      </otherwise>
-                    </choose>          
-                    #{var.textValue2}
-                    <choose>
-                      <when test="var.operator.equals('LIKE')">${wildcardEscapeClause}</when>
-                    </choose>
-                  </if>
-                  <if test="var.longValue != null">
-                    and A_${orLocal}OR${orIndex}.LONG_
-                    <include refid="executionVariableOperator" />
-                    #{var.longValue}
-                  </if>
-                  <if test="var.doubleValue != null">
-                    and A_${orLocal}OR${orIndex}.DOUBLE_
-                    <include refid="executionVariableOperator" />
-                    #{var.doubleValue}
-                  </if>
-                  <!-- Null variable type -->
-                  <if test="var.textValue == null &amp;&amp; var.textValue2 == null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
-                    <choose>
-                      <when test="var.operator.equals('NOT_EQUALS')">
-                        and (A_${orLocal}OR${orIndex}.TEXT_ is not null or A_${orLocal}OR${orIndex}.TEXT2_ is not null or A_${orLocal}OR${orIndex}.LONG_ is not null or A_${orLocal}OR${orIndex}.DOUBLE_ is not null or A_${orLocal}OR${orIndex}.BYTEARRAY_ID_ is not null)
-                      </when>
-                      <otherwise>
-                        and A_${orLocal}OR${orIndex}.TEXT_ is null and A_${orLocal}OR${orIndex}.TEXT2_ is null and A_${orLocal}OR${orIndex}.LONG_ is null and A_${orLocal}OR${orIndex}.DOUBLE_ is null and A_${orLocal}OR${orIndex}.BYTEARRAY_ID_ is null
-                      </otherwise>
-                    </choose>          
-                  </if>
-                </otherwise>
-              </choose>
-            </trim>
-          </foreach>
-          <if test="orQueryObject.suspensionState != null">
-            <if test="orQueryObject.suspensionState.stateCode == 1">
-              or RES.SUSPENSION_STATE_ = 1
+                        #{var.doubleValue}
+                      </if>
+                      <!-- Null variable type -->
+                      <if test="var.textValue == null &amp;&amp; var.textValue2 == null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
+                        <choose>
+                          <when test="var.operator.equals('NOT_EQUALS')">
+                            and (A_${orLocal}OR${orIndex}.TEXT_ is not null or A_${orLocal}OR${orIndex}.TEXT2_ is not null or A_${orLocal}OR${orIndex}.LONG_ is not null or A_${orLocal}OR${orIndex}.DOUBLE_ is not null or A_${orLocal}OR${orIndex}.BYTEARRAY_ID_ is not null)
+                          </when>
+                          <otherwise>
+                            and A_${orLocal}OR${orIndex}.TEXT_ is null and A_${orLocal}OR${orIndex}.TEXT2_ is null and A_${orLocal}OR${orIndex}.LONG_ is null and A_${orLocal}OR${orIndex}.DOUBLE_ is null and A_${orLocal}OR${orIndex}.BYTEARRAY_ID_ is null
+                          </otherwise>
+                        </choose>          
+                      </if>
+                    </otherwise>
+                </choose>
+              </trim>
+            </foreach>
+            <if test="orQueryObject.suspensionState != null">
+              <if test="orQueryObject.suspensionState.stateCode == 1">
+                  or RES.SUSPENSION_STATE_ = 1
+              </if>
+              <if test="orQueryObject.suspensionState.stateCode == 2">
+                  or RES.SUSPENSION_STATE_ = 2
+              </if>
             </if>
-            <if test="orQueryObject.suspensionState.stateCode == 2">
-              or RES.SUSPENSION_STATE_ = 2
+            <if test="orQueryObject.tenantId != null">
+              or RES.TENANT_ID_ = #{orQueryObject.tenantId}
             </if>
-          </if>
-          <if test="orQueryObject.tenantId != null">
-            or RES.TENANT_ID_ = #{orQueryObject.tenantId}
-          </if>
-          <if test="orQueryObject.tenantIdLike != null">
-            or RES.TENANT_ID_ like #{orQueryObject.tenantIdLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.withoutTenantId">
-            or (RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null)
-          </if>
-          <choose>
-            <when test="orQueryObject.bothCandidateAndAssigned">
-              <!-- if dbIdentityUsed set true in process engine configuration -->
-              <if test="orQueryObject.userIdForCandidateAndAssignee != null">
-                <if test="orQueryObject.candidateGroups == null">
-                  or (RES.ASSIGNEE_ = #{orQueryObject.userIdForCandidateAndAssignee}
-                  or (
-                  <if test="!orQueryObject.ignoreAssigneeValue">
-                    RES.ASSIGNEE_ is null and
+            <if test="orQueryObject.tenantIdLike != null">
+              or RES.TENANT_ID_ like #{orQueryObject.tenantIdLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.withoutTenantId">
+              or (RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null)
+            </if>
+            <choose>
+              <when test="orQueryObject.bothCandidateAndAssigned">
+                <!-- if dbIdentityUsed set true in process engine configuration -->
+                <if test="orQueryObject.userIdForCandidateAndAssignee != null">
+                  <if test="orQueryObject.candidateGroups == null">
+                    or (RES.ASSIGNEE_ = #{orQueryObject.userIdForCandidateAndAssignee}
+                        or (
+                        <if test="!orQueryObject.ignoreAssigneeValue">
+                            RES.ASSIGNEE_ is null and
+                        </if>
+                        exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_
+                        and (LINK.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee}
+                        or LINK.GROUP_ID_ IN (select g.GROUP_ID_ from ${prefix}ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee} )))))
                   </if>
-                  (I_OR${orIndex}.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee}
-                  or I_OR${orIndex}.GROUP_ID_ IN (select g.GROUP_ID_ from ${prefix}ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee} ) ) ) )
-                </if>
-              </if>
-              <!-- if dbIdentityUsed set false in process engine configuration of using custom session factory of GroupIdentityManager -->
-              <if test="orQueryObject.candidateGroups != null">
-                or (RES.ASSIGNEE_ = #{orQueryObject.userIdForCandidateAndAssignee}
-                or (
-                <if test="!orQueryObject.ignoreAssigneeValue">
-                  RES.ASSIGNEE_ is null and
                 </if>
-                I_OR${orIndex}.TYPE_ = 'candidate' and (I_OR${orIndex}.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee}
-                <if test="orQueryObject.candidateGroups.size() &gt; 0">
-                  or I_OR${orIndex}.GROUP_ID_ IN
-                  <foreach item="group" index="index" collection="orQueryObject.candidateGroups" open="(" separator="," close=")">
-                    #{group}
-                  </foreach>
+                <!-- if dbIdentityUsed set false in process engine configuration of using custom session factory of GroupIdentityManager -->
+                <if test="orQueryObject.candidateGroups != null">
+                  or (RES.ASSIGNEE_ = #{orQueryObject.userIdForCandidateAndAssignee}
+                  or (
+                    <if test="!orQueryObject.ignoreAssigneeValue">
+                        RES.ASSIGNEE_ is null and
+                    </if>
+                    exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_
+                    and LINK.TYPE_ = 'candidate' and (LINK.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee}
+                    <if test="orQueryObject.candidateGroups.size() &gt; 0">
+                        or LINK.GROUP_ID_ IN
+                        <foreach item="group" index="index" collection="orQueryObject.candidateGroups" open="(" separator="," close=")">
+                            #{group}
+                        </foreach>
+                    </if>
+                  ))))
                 </if>
-                )))
-              </if>
-            </when>
-          </choose>
-        </trim>
-      </foreach>
-    </where>
+              </when>
+            </choose>
+          </trim>
+        </foreach>
+     </where>
   </sql>
   
   <sql id="executionVariableOperator">
@@ -1404,15 +1407,15 @@ under the License.
       <when test="var.operator.equals('GREATER_THAN_OR_EQUAL')">&gt;=</when>
       <when test="var.operator.equals('LESS_THAN')">&lt;</when>
       <when test="var.operator.equals('LESS_THAN_OR_EQUAL')">&lt;=</when>
-    </choose>
+   </choose>
   </sql>  
 
   <select id="selectTaskByNativeQuery" parameterType="java.util.Map" resultMap="taskResultMap">
-    <include refid="org.flowable.task.service.db.common.selectByNativeQuery"/>
+  	<include refid="org.flowable.task.service.db.common.selectByNativeQuery"/>
   </select>
   
   <select id="selectTaskCountByNativeQuery" parameterType="java.util.Map" resultType="long">
-    ${sql}
+     ${sql}
   </select>
 
 </mapper>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/syncope/blob/c193001d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index db39a89..db72c35 100644
--- a/pom.xml
+++ b/pom.xml
@@ -408,7 +408,7 @@ under the License.
 
     <groovy.version>3.0.0-alpha-3</groovy.version>
 
-    <flowable.version>6.3.1</flowable.version>
+    <flowable.version>6.4.0</flowable.version>
 
     <camel.version>2.22.1</camel.version>	
 
@@ -1150,6 +1150,11 @@ under the License.
       </dependency>
       <dependency>
         <groupId>org.flowable</groupId>
+        <artifactId>flowable-idm-spring-configurator</artifactId>
+        <version>${flowable.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.flowable</groupId>
         <artifactId>flowable-json-converter</artifactId>
         <version>${flowable.version}</version>
       </dependency>


[3/4] syncope git commit: Upgrading Flowable

Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/syncope/blob/5daece32/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml
----------------------------------------------------------------------
diff --git a/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml b/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml
index cc905a3..bf5c06f 100644
--- a/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml
+++ b/ext/flowable/flowable-bpmn/src/main/resources/org/apache/syncope/ext/flowable/Task.xml
@@ -25,118 +25,118 @@ under the License.
   
   <insert id="insertTask" parameterType="org.flowable.task.service.impl.persistence.entity.TaskEntityImpl">
     insert into ${prefix}ACT_RU_TASK (ID_, REV_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_, ASSIGNEE_, DELEGATION_, 
-    EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_,
-    TASK_DEF_KEY_, DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
-    IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_)
+                      EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_,
+                      TASK_DEF_KEY_, DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
+                      IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_)
     values (#{id, jdbcType=VARCHAR},
-    1,
-    #{name, jdbcType=VARCHAR},
-    #{parentTaskId, jdbcType=VARCHAR},
-    #{description, jdbcType=VARCHAR},
-    #{priority, jdbcType=INTEGER},
-    #{createTime, jdbcType=TIMESTAMP},
-    #{owner, jdbcType=VARCHAR},
-    #{assignee, jdbcType=VARCHAR},
-    #{delegationStateString, jdbcType=VARCHAR},
-    #{executionId, jdbcType=VARCHAR},
-    #{processInstanceId, jdbcType=VARCHAR},
-    #{processDefinitionId, jdbcType=VARCHAR},
-    #{taskDefinitionId, jdbcType=VARCHAR},
-    #{scopeId, jdbcType=VARCHAR},
-    #{subScopeId, jdbcType=VARCHAR},
-    #{scopeType, jdbcType=VARCHAR},
-    #{scopeDefinitionId, jdbcType=VARCHAR},
-    #{taskDefinitionKey, jdbcType=VARCHAR},
-    #{dueDate, jdbcType=TIMESTAMP},
-    #{category, jdbcType=VARCHAR},
-    #{suspensionState, jdbcType=INTEGER},
-    #{tenantId, jdbcType=VARCHAR},
-    #{formKey, jdbcType=VARCHAR},
-    #{claimTime, jdbcType=TIMESTAMP},
-    #{isCountEnabled, jdbcType=BOOLEAN},
-    #{variableCount, jdbcType=INTEGER},
-    #{identityLinkCount, jdbcType=INTEGER},
-    #{subTaskCount, jdbcType=INTEGER}
-    )
+            1,
+            #{name, jdbcType=VARCHAR},
+            #{parentTaskId, jdbcType=VARCHAR},
+            #{description, jdbcType=VARCHAR},
+            #{priority, jdbcType=INTEGER},
+            #{createTime, jdbcType=TIMESTAMP},
+            #{owner, jdbcType=VARCHAR},
+            #{assignee, jdbcType=VARCHAR},
+            #{delegationStateString, jdbcType=VARCHAR},
+            #{executionId, jdbcType=VARCHAR},
+            #{processInstanceId, jdbcType=VARCHAR},
+            #{processDefinitionId, jdbcType=VARCHAR},
+            #{taskDefinitionId, jdbcType=VARCHAR},
+            #{scopeId, jdbcType=VARCHAR},
+            #{subScopeId, jdbcType=VARCHAR},
+            #{scopeType, jdbcType=VARCHAR},
+            #{scopeDefinitionId, jdbcType=VARCHAR},
+            #{taskDefinitionKey, jdbcType=VARCHAR},
+            #{dueDate, jdbcType=TIMESTAMP},
+            #{category, jdbcType=VARCHAR},
+            #{suspensionState, jdbcType=INTEGER},
+            #{tenantId, jdbcType=VARCHAR},
+            #{formKey, jdbcType=VARCHAR},
+            #{claimTime, jdbcType=TIMESTAMP},
+            #{isCountEnabled, jdbcType=BOOLEAN},
+            #{variableCount, jdbcType=INTEGER},
+            #{identityLinkCount, jdbcType=INTEGER},
+            #{subTaskCount, jdbcType=INTEGER}
+           )
   </insert>
 
   <insert id="bulkInsertTask" parameterType="java.util.List">
     INSERT INTO ${prefix}ACT_RU_TASK (ID_, REV_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_, ASSIGNEE_, DELEGATION_, 
-    EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_, 
-    TASK_DEF_KEY_, DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
-    IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_)
+        EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_, 
+        TASK_DEF_KEY_, DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
+        IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_)
     VALUES 
-    <foreach collection="list" item="task" index="index" separator=","> 
-      (#{task.id, jdbcType=VARCHAR},
-      1,
-      #{task.name, jdbcType=VARCHAR},
-      #{task.parentTaskId, jdbcType=VARCHAR},
-      #{task.description, jdbcType=VARCHAR},
-      #{task.priority, jdbcType=INTEGER},
-      #{task.createTime, jdbcType=TIMESTAMP},
-      #{task.owner, jdbcType=VARCHAR},
-      #{task.assignee, jdbcType=VARCHAR},
-      #{task.delegationStateString, jdbcType=VARCHAR},
-      #{task.executionId, jdbcType=VARCHAR},
-      #{task.processInstanceId, jdbcType=VARCHAR},
-      #{task.processDefinitionId, jdbcType=VARCHAR},
-      #{task.taskDefinitionId, jdbcType=VARCHAR},
-      #{task.scopeId, jdbcType=VARCHAR},
-      #{task.subScopeId, jdbcType=VARCHAR},
-      #{task.scopeType, jdbcType=VARCHAR},
-      #{task.scopeDefinitionId, jdbcType=VARCHAR},
-      #{task.taskDefinitionKey, jdbcType=VARCHAR},
-      #{task.dueDate, jdbcType=TIMESTAMP},
-      #{task.category, jdbcType=VARCHAR},
-      #{task.suspensionState, jdbcType=INTEGER},
-      #{task.tenantId, jdbcType=VARCHAR},
-      #{task.formKey, jdbcType=VARCHAR},
-      #{task.claimTime, jdbcType=TIMESTAMP},
-      #{task.isCountEnabled, jdbcType=BOOLEAN},
-      #{task.variableCount, jdbcType=INTEGER},
-      #{task.identityLinkCount, jdbcType=INTEGER},
-      #{task.subTaskCount, jdbcType=INTEGER}
-      )
+      <foreach collection="list" item="task" index="index" separator=","> 
+        (#{task.id, jdbcType=VARCHAR},
+         1,
+         #{task.name, jdbcType=VARCHAR},
+         #{task.parentTaskId, jdbcType=VARCHAR},
+         #{task.description, jdbcType=VARCHAR},
+         #{task.priority, jdbcType=INTEGER},
+         #{task.createTime, jdbcType=TIMESTAMP},
+         #{task.owner, jdbcType=VARCHAR},
+         #{task.assignee, jdbcType=VARCHAR},
+         #{task.delegationStateString, jdbcType=VARCHAR},
+         #{task.executionId, jdbcType=VARCHAR},
+         #{task.processInstanceId, jdbcType=VARCHAR},
+         #{task.processDefinitionId, jdbcType=VARCHAR},
+         #{task.taskDefinitionId, jdbcType=VARCHAR},
+         #{task.scopeId, jdbcType=VARCHAR},
+         #{task.subScopeId, jdbcType=VARCHAR},
+         #{task.scopeType, jdbcType=VARCHAR},
+         #{task.scopeDefinitionId, jdbcType=VARCHAR},
+         #{task.taskDefinitionKey, jdbcType=VARCHAR},
+         #{task.dueDate, jdbcType=TIMESTAMP},
+         #{task.category, jdbcType=VARCHAR},
+         #{task.suspensionState, jdbcType=INTEGER},
+         #{task.tenantId, jdbcType=VARCHAR},
+         #{task.formKey, jdbcType=VARCHAR},
+         #{task.claimTime, jdbcType=TIMESTAMP},
+         #{task.isCountEnabled, jdbcType=BOOLEAN},
+         #{task.variableCount, jdbcType=INTEGER},
+         #{task.identityLinkCount, jdbcType=INTEGER},
+         #{task.subTaskCount, jdbcType=INTEGER}
+         )
     </foreach>
   </insert>
 
   <insert id="bulkInsertTask" databaseId="oracle" parameterType="java.util.List">
     INSERT ALL 
-    <foreach collection="list" item="task" index="index">
-      INTO ${prefix}ACT_RU_TASK (ID_, REV_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_, ASSIGNEE_, DELEGATION_, 
-      EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_, TASK_DEF_KEY_, 
-      DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
-      IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_) VALUES
-      (#{task.id, jdbcType=VARCHAR},
-      1,
-      #{task.name, jdbcType=VARCHAR},
-      #{task.parentTaskId, jdbcType=VARCHAR},
-      #{task.description, jdbcType=VARCHAR},
-      #{task.priority, jdbcType=INTEGER},
-      #{task.createTime, jdbcType=TIMESTAMP},
-      #{task.owner, jdbcType=VARCHAR},
-      #{task.assignee, jdbcType=VARCHAR},
-      #{task.delegationStateString, jdbcType=VARCHAR},
-      #{task.executionId, jdbcType=VARCHAR},
-      #{task.processInstanceId, jdbcType=VARCHAR},
-      #{task.processDefinitionId, jdbcType=VARCHAR},
-      #{task.taskDefinitionId, jdbcType=VARCHAR},
-      #{task.scopeId, jdbcType=VARCHAR},
-      #{task.subScopeId, jdbcType=VARCHAR},
-      #{task.scopeType, jdbcType=VARCHAR},
-      #{task.scopeDefinitionId, jdbcType=VARCHAR},
-      #{task.taskDefinitionKey, jdbcType=VARCHAR},
-      #{task.dueDate, jdbcType=TIMESTAMP},
-      #{task.category, jdbcType=VARCHAR},
-      #{task.suspensionState, jdbcType=INTEGER},
-      #{task.tenantId, jdbcType=VARCHAR},
-      #{task.formKey, jdbcType=VARCHAR},
-      #{task.claimTime, jdbcType=TIMESTAMP},
-      #{task.isCountEnabled, jdbcType=BOOLEAN},
-      #{task.variableCount, jdbcType=INTEGER},
-      #{task.identityLinkCount, jdbcType=INTEGER},
-      #{task.subTaskCount, jdbcType=INTEGER}
-      )
+      <foreach collection="list" item="task" index="index">
+        INTO ${prefix}ACT_RU_TASK (ID_, REV_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_, ASSIGNEE_, DELEGATION_, 
+              EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_ID_, SCOPE_ID_, SUB_SCOPE_ID_, SCOPE_TYPE_, SCOPE_DEFINITION_ID_, TASK_DEF_KEY_, 
+              DUE_DATE_, CATEGORY_, SUSPENSION_STATE_, TENANT_ID_, FORM_KEY_, CLAIM_TIME_, 
+              IS_COUNT_ENABLED_, VAR_COUNT_, ID_LINK_COUNT_, SUB_TASK_COUNT_) VALUES
+        (#{task.id, jdbcType=VARCHAR},
+         1,
+         #{task.name, jdbcType=VARCHAR},
+         #{task.parentTaskId, jdbcType=VARCHAR},
+         #{task.description, jdbcType=VARCHAR},
+         #{task.priority, jdbcType=INTEGER},
+         #{task.createTime, jdbcType=TIMESTAMP},
+         #{task.owner, jdbcType=VARCHAR},
+         #{task.assignee, jdbcType=VARCHAR},
+         #{task.delegationStateString, jdbcType=VARCHAR},
+         #{task.executionId, jdbcType=VARCHAR},
+         #{task.processInstanceId, jdbcType=VARCHAR},
+         #{task.processDefinitionId, jdbcType=VARCHAR},
+         #{task.taskDefinitionId, jdbcType=VARCHAR},
+         #{task.scopeId, jdbcType=VARCHAR},
+         #{task.subScopeId, jdbcType=VARCHAR},
+         #{task.scopeType, jdbcType=VARCHAR},
+         #{task.scopeDefinitionId, jdbcType=VARCHAR},
+         #{task.taskDefinitionKey, jdbcType=VARCHAR},
+         #{task.dueDate, jdbcType=TIMESTAMP},
+         #{task.category, jdbcType=VARCHAR},
+         #{task.suspensionState, jdbcType=INTEGER},
+         #{task.tenantId, jdbcType=VARCHAR},
+         #{task.formKey, jdbcType=VARCHAR},
+         #{task.claimTime, jdbcType=TIMESTAMP},
+         #{task.isCountEnabled, jdbcType=BOOLEAN},
+         #{task.variableCount, jdbcType=INTEGER},
+         #{task.identityLinkCount, jdbcType=INTEGER},
+         #{task.subTaskCount, jdbcType=INTEGER}
+         )
     </foreach>
     SELECT * FROM dual
   </insert>
@@ -148,111 +148,114 @@ under the License.
     <set>
       REV_ = #{revisionNext, jdbcType=INTEGER},
       <if test="originalPersistentState.name != name">
-        NAME_ = #{name, jdbcType=VARCHAR},
+          NAME_ = #{name, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.parentTaskId != parentTaskId">
-        PARENT_TASK_ID_ = #{parentTaskId, jdbcType=VARCHAR},
+          PARENT_TASK_ID_ = #{parentTaskId, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.priority != priority">
-        PRIORITY_ = #{priority, jdbcType=INTEGER},
+          PRIORITY_ = #{priority, jdbcType=INTEGER},
       </if>
       <if test="originalPersistentState.createTime != createTime">
-        CREATE_TIME_ = #{createTime, jdbcType=TIMESTAMP},
+          CREATE_TIME_ = #{createTime, jdbcType=TIMESTAMP},
       </if>
       <if test="originalPersistentState.owner != owner">
-        OWNER_ = #{owner, jdbcType=VARCHAR},
+          OWNER_ = #{owner, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.assignee != assignee">
-        ASSIGNEE_ = #{assignee, jdbcType=VARCHAR},
+          ASSIGNEE_ = #{assignee, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.delegationStateString != delegationStateString">
-        DELEGATION_ = #{delegationStateString, jdbcType=VARCHAR},
+          DELEGATION_ = #{delegationStateString, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.executionId != executionId">
-        EXECUTION_ID_ = #{executionId, jdbcType=VARCHAR},
+          EXECUTION_ID_ = #{executionId, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.processDefinitionId != processDefinitionId">
-        PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR},
+          PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.taskDefinitionId != taskDefinitionId">
-        TASK_DEF_ID_ = #{taskDefinitionId, jdbcType=VARCHAR},
+          TASK_DEF_ID_ = #{taskDefinitionId, jdbcType=VARCHAR},
+      </if>
+      <if test="originalPersistentState.taskDefinitionKey != taskDefinitionKey">
+          TASK_DEF_KEY_ = #{taskDefinitionKey, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.scopeId != scopeId">
-        SCOPE_ID_ = #{scopeId, jdbcType=VARCHAR}
+          SCOPE_ID_ = #{scopeId, jdbcType=VARCHAR}
       </if>
       <if test="originalPersistentState.subScopeId != subScopeId">
-        SUB_SCOPE_ID_ = #{subScopeId, jdbcType=VARCHAR}
+          SUB_SCOPE_ID_ = #{subScopeId, jdbcType=VARCHAR}
       </if>
       <if test="originalPersistentState.scopeType != scopeType">
-        SCOPE_TYPE_ = #{scopeType, jdbcType=VARCHAR}
+          SCOPE_TYPE_ = #{scopeType, jdbcType=VARCHAR}
       </if>
-      <if test="originalPersistentState.scopeDefinitionId != scopeDefinitionId">
-        SCOPE_DEFINITION_ID_ = #{scopeDefinitionId, jdbcType=VARCHAR}
+       <if test="originalPersistentState.scopeDefinitionId != scopeDefinitionId">
+          SCOPE_DEFINITION_ID_ = #{scopeDefinitionId, jdbcType=VARCHAR}
       </if>
       <if test="originalPersistentState.description != description">
-        DESCRIPTION_ = #{description, jdbcType=VARCHAR},
+          DESCRIPTION_ = #{description, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.dueDate != dueDate">
-        DUE_DATE_ = #{dueDate, jdbcType=TIMESTAMP},
+          DUE_DATE_ = #{dueDate, jdbcType=TIMESTAMP},
       </if>
       <if test="originalPersistentState.category != category">
-        CATEGORY_ = #{category, jdbcType=VARCHAR},
+          CATEGORY_ = #{category, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.suspensionState != suspensionState">
-        SUSPENSION_STATE_ = #{suspensionState, jdbcType=INTEGER},
+          SUSPENSION_STATE_ = #{suspensionState, jdbcType=INTEGER},
       </if>
       <if test="originalPersistentState.formKey != formKey">
-        FORM_KEY_ = #{formKey, jdbcType=VARCHAR},
+          FORM_KEY_ = #{formKey, jdbcType=VARCHAR},
       </if>
       <if test="originalPersistentState.claimTime != claimTime">
-        CLAIM_TIME_ = #{claimTime, jdbcType=TIMESTAMP},
+          CLAIM_TIME_ = #{claimTime, jdbcType=TIMESTAMP},
       </if>
       <if test="originalPersistentState.isCountEnabled != isCountEnabled">
-        IS_COUNT_ENABLED_ = #{isCountEnabled, jdbcType=BOOLEAN},
+          IS_COUNT_ENABLED_ = #{isCountEnabled, jdbcType=BOOLEAN},
       </if>
       <if test="originalPersistentState.variableCount != variableCount">
-        VAR_COUNT_ = #{variableCount, jdbcType=INTEGER},
+          VAR_COUNT_ = #{variableCount, jdbcType=INTEGER},
       </if>
       <if test="originalPersistentState.identityLinkCount != identityLinkCount">
-        ID_LINK_COUNT_ = #{identityLinkCount, jdbcType=INTEGER},
+          ID_LINK_COUNT_ = #{identityLinkCount, jdbcType=INTEGER},
       </if>
       <if test="originalPersistentState.subTaskCount != subTaskCount">
-        SUB_TASK_COUNT_ = #{subTaskCount, jdbcType=INTEGER}
+          SUB_TASK_COUNT_ = #{subTaskCount, jdbcType=INTEGER}
       </if>
     </set>
     where ID_= #{id, jdbcType=VARCHAR}
-    and REV_ = #{revision, jdbcType=INTEGER}
+      and REV_ = #{revision, jdbcType=INTEGER}
   </update>
   
   <update id="updateTaskTenantIdForDeployment" parameterType="java.util.Map">
     update ${prefix}ACT_RU_TASK set
-    TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
+      TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
     where
-    ID_ in (
-    SELECT T.ID_ from ${prefix}ACT_RU_TASK T
-    inner join ${prefix}ACT_RE_PROCDEF P on T.PROC_DEF_ID_  = P.ID_
-    inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_ 
-    where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
-    ) 
+      ID_ in (
+        SELECT T.ID_ from ${prefix}ACT_RU_TASK T
+        inner join ${prefix}ACT_RE_PROCDEF P on T.PROC_DEF_ID_  = P.ID_
+        inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_ 
+        where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
+      ) 
   </update>
   
-  <!-- See http://stackoverflow.com/questions/4429319/you-cant-specify-target-table-for-update-in-from-clause
-  Tested this on MySQL 5.6: does NOT use a temporary table (so good, performance0 -->
+    <!-- See http://stackoverflow.com/questions/4429319/you-cant-specify-target-table-for-update-in-from-clause
+       Tested this on MySQL 5.6: does NOT use a temporary table (so good, performance0 -->
   <update id="updateTaskTenantIdForDeployment" databaseId="mysql" parameterType="java.util.Map">
     update ${prefix}ACT_RU_TASK set
-    TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
+      TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
     where
-    ID_ in (
+      ID_ in (
 
-    SELECT tempTask.tempId
-    FROM (
-    SELECT T.ID_ as tempId
-    FROM  ${prefix}ACT_RU_TASK T
-    inner join ${prefix}ACT_RE_PROCDEF P on T.PROC_DEF_ID_  = P.ID_
-    inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_ 
-    where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
+          SELECT tempTask.tempId
+          FROM (
+                SELECT T.ID_ as tempId
+                FROM  ${prefix}ACT_RU_TASK T
+                inner join ${prefix}ACT_RE_PROCDEF P on T.PROC_DEF_ID_  = P.ID_
+                inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_ 
+                where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
                 
-    ) AS tempTask 
+        ) AS tempTask 
 
     )
   </update>
@@ -275,7 +278,7 @@ under the License.
   <delete id="bulkDeleteTask" parameterType="java.util.Collection">
     delete from ${prefix}ACT_RU_TASK where 
     <foreach item="task" collection="list" index="index" separator=" or ">
-      ID_ = #{task.id, jdbcType=VARCHAR}
+        ID_ = #{task.id, jdbcType=VARCHAR}
     </foreach>
   </delete>
   
@@ -371,7 +374,7 @@ under the License.
   <!-- TASK SELECT -->  
 
   <select id="selectTask" parameterType="string" resultMap="taskResultMap">
-    select * from ${prefix}ACT_RU_TASK where ID_ = #{id, jdbcType=VARCHAR}
+   select * from ${prefix}ACT_RU_TASK where ID_ = #{id, jdbcType=VARCHAR}
   </select>
   
   <select id="selectTasksByParentTaskId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="taskResultMap">
@@ -403,16 +406,15 @@ under the License.
   </select>
   
   <!-- Using distinct here because a task can appear multiple times in a resultset when -->
-  <select id="selectTaskByQueryCriteria" parameterType="org.apache.syncope.core.flowable.impl.SyncopeTaskQueryImpl" resultMap="taskResultMap">
+  <select id="selectTaskByQueryCriteria" parameterType="org.apache.syncope.core.flowable.support.SyncopeTaskQueryImpl" resultMap="taskResultMap">
     <if test="firstResult != null and firstResult &gt;= 0">${limitBefore}</if>
-    select distinct RES.* <if test="nullHandlingColumn != null">, ${nullHandlingColumn}</if> 
-    <if test="firstResult != null and firstResult &gt;= 0">${limitBetween}</if>
+    select distinct RES.* <if test="nullHandlingColumn != null">, ${nullHandlingColumn}</if> <if test="firstResult != null and firstResult &gt;= 0">${limitBetween}</if>
     <include refid="selectTaskByQueryCriteriaSql"/> 
     ${orderBy}
     <if test="firstResult != null and firstResult &gt;= 0">${limitAfter}</if>
   </select>
 
-  <select id="selectTaskCountByQueryCriteria" parameterType="org.apache.syncope.core.flowable.impl.SyncopeTaskQueryImpl" resultType="long">
+  <select id="selectTaskCountByQueryCriteria" parameterType="org.apache.syncope.core.flowable.support.SyncopeTaskQueryImpl" resultType="long">
     select count(distinct RES.ID_)
     <include refid="selectTaskByQueryCriteriaSql"/>
   </select>
@@ -422,7 +424,7 @@ under the License.
     <include refid="commonSelectTaskByQueryCriteriaSql"/>
   </sql>
   
-  <select id="selectTasksWithRelatedEntitiesByQueryCriteria" parameterType="org.apache.syncope.core.flowable.impl.SyncopeTaskQueryImpl" resultMap="taskAndRelatedEntitiesResultMap">
+  <select id="selectTasksWithRelatedEntitiesByQueryCriteria" parameterType="org.apache.syncope.core.flowable.support.SyncopeTaskQueryImpl" resultMap="taskAndRelatedEntitiesResultMap">
     <include refid="selectTasksWithRelatedEntitiesByQueryCriteriaColumns"/>
     <include refid="selectTasksWithRelatedEntitiesByQueryCriteriaSql"/>
     ${orderBy}
@@ -431,8 +433,8 @@ under the License.
 
   <sql id="selectTasksWithRelatedEntitiesByQueryCriteriaColumns">
     <if test="firstResult != null and firstResult &gt;= 0">${limitBefore}</if>
-    <if test="_databaseId != 'db2' and _databaseId != 'mssql'">
-      select RES.*,
+  	<if test="_databaseId != 'db2' and _databaseId != 'mssql'">
+    select RES.*,
       <if test="includeTaskLocalVariables or includeProcessVariables">
         VAR.ID_ as VAR_ID_, VAR.NAME_ as VAR_NAME_, VAR.TYPE_ as VAR_TYPE_, VAR.REV_ as VAR_REV_,
         VAR.PROC_INST_ID_ as VAR_PROC_INST_ID_, VAR.EXECUTION_ID_ as VAR_EXECUTION_ID_, VAR.TASK_ID_ as VAR_TASK_ID_,
@@ -447,7 +449,7 @@ under the License.
         ILINK.GROUP_ID_ as ILINK_GROUP_ID_, ILINK.TASK_ID_ as ILINK_TASK_ID_,
         ILINK.PROC_INST_ID_ as ILINK_PROC_INST_ID_, ILINK.PROC_DEF_ID_ as ILINK_PROC_DEF_ID_
       </if>
-      <if test="firstResult != null and firstResult &gt;= 0">${limitBetween}</if>
+    <if test="firstResult != null and firstResult &gt;= 0">${limitBetween}</if>
     </if>
     <if test="_databaseId == 'db2' || _databaseId == 'mssql'">
       select distinct TEMPRES_ID_ as ID_, TEMPRES_REV_ as REV_, TEMPRES_NAME_ as NAME_,
@@ -518,43 +520,29 @@ under the License.
     </if>
     <include refid="commonSelectTaskByQueryCriteriaSql"/>
   </sql>
-  
+
   <sql id="commonSelectTaskByQueryCriteriaSql">
-    <if test="candidateUser != null || candidateGroups != null || bothCandidateAndAssigned">
-      <choose>
-        <when test="bothCandidateAndAssigned">left</when>
-        <otherwise>inner</otherwise>
-      </choose>
-      join ${prefix}ACT_RU_IDENTITYLINK I on I.TASK_ID_ = RES.ID_
-    </if>
     <foreach collection="queryVariableValues" index="index" item="var">
       <if test="!var.operator.equals('EXISTS') &amp;&amp; !var.operator.equals('NOT_EXISTS')">
-        <choose>
-          <when test="var.local">
-            inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.TASK_ID_ 
-          </when>
-          <otherwise>
-            inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.PROC_INST_ID_ = A${index}.PROC_INST_ID_ 
-          </otherwise>
-        </choose>
+          <choose>
+            <when test="var.local">
+              inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.TASK_ID_ 
+            </when>
+            <otherwise>
+              inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.PROC_INST_ID_ = A${index}.PROC_INST_ID_ 
+            </otherwise>
+          </choose>
       </if>       
     </foreach>
     <foreach collection="orQueryObjects" index="orIndex" item="orQueryObject">
-      <if test="orQueryObject.candidateUser != null || orQueryObject.candidateGroups != null || orQueryObject.bothCandidateAndAssigned">
-        <choose>
-          <when test="orQueryObject.bothCandidateAndAssigned">left</when>
-          <otherwise>inner</otherwise>
-        </choose>
-        join ${prefix}ACT_RU_IDENTITYLINK I_OR${orIndex} on I_OR${orIndex}.TASK_ID_ = RES.ID_
-      </if>
       <if test="orQueryObject.queryVariableValues.size() &gt; 0">
         <if test="orQueryObject.hasValueComparisonQueryVariables()">
-          <if test="orQueryObject.hasLocalQueryVariableValue()">
-            left outer join ${prefix}ACT_RU_VARIABLE A_L_OR${orIndex} on RES.ID_ = A_L_OR${orIndex}.TASK_ID_
-          </if>
-          <if test="orQueryObject.hasNonLocalQueryVariableValue()">
-            left outer join ${prefix}ACT_RU_VARIABLE A_OR${orIndex} on RES.PROC_INST_ID_ = A_OR${orIndex}.PROC_INST_ID_
-          </if>
+            <if test="orQueryObject.hasLocalQueryVariableValue()">
+              left outer join ${prefix}ACT_RU_VARIABLE A_L_OR${orIndex} on RES.ID_ = A_L_OR${orIndex}.TASK_ID_
+            </if>
+            <if test="orQueryObject.hasNonLocalQueryVariableValue()">
+              left outer join ${prefix}ACT_RU_VARIABLE A_OR${orIndex} on RES.PROC_INST_ID_ = A_OR${orIndex}.PROC_INST_ID_
+            </if>
         </if>
       </if>
       
@@ -653,7 +641,7 @@ under the License.
       <if test="ownerLike != null">
         and RES.OWNER_ like #{ownerLike}${wildcardEscapeClause}
       </if>
-      <if test="ownerLikeIgnoreCase != null">
+       <if test="ownerLikeIgnoreCase != null">
         and lower(RES.OWNER_) like #{ownerLikeIgnoreCase}${wildcardEscapeClause}
       </if>
       <if test="unassigned">
@@ -780,15 +768,15 @@ under the License.
       </if>
       <if test="cmmnDeploymentIds != null &amp;&amp; cmmnDeploymentIds.size() &gt; 0 &amp;&amp; deploymentIds != null &amp;&amp; deploymentIds.size() &gt; 0">
         and (
-        DEPLOY_P.DEPLOYMENT_ID_ IN
-        <foreach item="deployment" index="index" collection="deploymentIds" open="(" separator="," close=")">
-          #{deployment}
-        </foreach>
-        or
-        DEPLOY_C.DEPLOYMENT_ID_ IN
-        <foreach item="cmmnDeployment" index="index" collection="cmmnDeploymentIds" open="(" separator="," close=")">
-          #{cmmnDeployment}
-        </foreach>
+            DEPLOY_P.DEPLOYMENT_ID_ IN
+            <foreach item="deployment" index="index" collection="deploymentIds" open="(" separator="," close=")">
+                #{deployment}
+            </foreach>
+            or
+            DEPLOY_C.DEPLOYMENT_ID_ IN
+            <foreach item="cmmnDeployment" index="index" collection="cmmnDeploymentIds" open="(" separator="," close=")">
+                #{cmmnDeployment}
+            </foreach>
         )
       </if>
       <if test="dueDate != null">
@@ -819,137 +807,142 @@ under the License.
       </if>
       <if test="!bothCandidateAndAssigned &amp;&amp; (candidateUser != null || candidateGroups != null)">
         <if test="!ignoreAssigneeValue">
-          and RES.ASSIGNEE_ is null
-        </if>
-        and I.TYPE_ = 'candidate'
-        and 
-        ( 
-        <if test="candidateUser != null">
-          I.USER_ID_ = #{candidateUser}          
-        </if>
-        <if test="candidateUser != null &amp;&amp; candidateGroups != null &amp;&amp; candidateGroups.size() &gt; 0">
-          or
-        </if>
-        <if test="candidateGroups != null &amp;&amp; candidateGroups.size() &gt; 0">
-          I.GROUP_ID_ IN
-          <foreach item="group" index="index" collection="candidateGroups" 
-                     open="(" separator="," close=")">
-            #{group}
-          </foreach>
+            and RES.ASSIGNEE_ is null
         </if>
+        and exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TYPE_ = 'candidate' and LINK.TASK_ID_ = RES.ID_
+            and 
+            ( 
+              <if test="candidateUser != null">
+                LINK.USER_ID_ = #{candidateUser}          
+              </if>
+              <if test="candidateUser != null &amp;&amp; candidateGroups != null &amp;&amp; candidateGroups.size() &gt; 0">
+                or
+              </if>
+              <if test="candidateGroups != null &amp;&amp; candidateGroups.size() &gt; 0">
+                LINK.GROUP_ID_ IN
+                <foreach item="group" index="index" collection="candidateGroups" 
+                         open="(" separator="," close=")">
+                  #{group}
+                </foreach>
+              </if>
+            )
         )
       </if>
       <if test="involvedUser != null">
         and (
-        exists(select LINK.USER_ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where USER_ID_ = #{involvedUser} and LINK.TASK_ID_ = RES.ID_)
-        or RES.ASSIGNEE_ = #{involvedUser}
-        or RES.OWNER_ = #{involvedUser}
+          exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.USER_ID_ = #{involvedUser} and LINK.TASK_ID_ = RES.ID_)
+          or RES.ASSIGNEE_ = #{involvedUser}
+          or RES.OWNER_ = #{involvedUser}
+          )
+      </if>
+      <if test="involvedGroups != null">
+        and EXISTS(
+          select ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_ and LINK.GROUP_ID_ in
+          <foreach item="involvedGroup" index="index" collection="involvedGroups" open="(" separator="," close=")">
+              #{involvedGroup}
+          </foreach>
         )
       </if>
       <foreach item="var" collection="queryVariableValues" index="index">
         <choose>
-          <when test="var.operator.equals('EXISTS')">
-            and EXISTS (
-            select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
-            <if test="!var.local">
-              and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
-            </if>
-            <if test="var.local">
-              and RES.ID_ = TASK_ID_ 
-            </if>
-            )
-          </when>
-          <when test="var.operator.equals('NOT_EXISTS')">
-            and NOT EXISTS (
-            select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
-            <if test="!var.local">
-              and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
-            </if>
-            <if test="var.local">
-              and RES.ID_ = TASK_ID_ 
-            </if>
-            )
-          </when>
-          <otherwise>
-            <if test="!var.local">
-              <!-- When process instance variable is queried for, taskId should be null -->
-              and A${index}.TASK_ID_ is null
-            </if>
-            <if test="var.name != null">
-              <!-- Match-all variable-names when name is null -->
-              and A${index}.NAME_= #{var.name}
-            </if>
-            <if test="var.name == null">
-              and A${index}.NAME_ is not null
-            </if>
-            <if test="!var.type.equals('null')">
-              and A${index}.TYPE_ = #{var.type}
-            </if>
+            <when test="var.operator.equals('EXISTS')">
+              and EXISTS (
+                select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
+                <if test="!var.local">
+                    and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
+                </if>
+                <if test="var.local">
+                    and RES.ID_ = TASK_ID_ 
+                </if>
+              )
+            </when>
+            <when test="var.operator.equals('NOT_EXISTS')">
+              and NOT EXISTS (
+                select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
+                <if test="!var.local">
+                    and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
+                </if>
+                <if test="var.local">
+                    and RES.ID_ = TASK_ID_ 
+                </if>
+              )
+            </when>
+            <otherwise>
+                <if test="!var.local">
+                  <!-- When process instance variable is queried for, taskId should be null -->
+                  and A${index}.TASK_ID_ is null
+                </if>
+                <if test="var.name != null">
+                  <!-- Match-all variable-names when name is null -->
+                  and A${index}.NAME_= #{var.name}
+                </if>
+                <if test="var.name == null">
+                  and A${index}.NAME_ is not null
+                </if>
+                <if test="!var.type.equals('null')">
+                  and A${index}.TYPE_ = #{var.type}
+                </if>
                 
-            <!-- Variable value -->
-            <if test="var.textValue != null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
-              <choose>
-                <when test="var.operator.equals('EQUALS_IGNORE_CASE') || var.operator.equals('NOT_EQUALS_IGNORE_CASE') || var.operator.equals('LIKE_IGNORE_CASE')">
-                  and lower(A${index}.TEXT_)
-                </when>
-                <otherwise>
-                  and A${index}.TEXT_
-                </otherwise>
-              </choose> 
-              <choose>
-                <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
-                <otherwise>
+                <!-- Variable value -->
+                <if test="var.textValue != null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
+                  <choose>
+                    <when test="var.operator.equals('EQUALS_IGNORE_CASE') || var.operator.equals('NOT_EQUALS_IGNORE_CASE') || var.operator.equals('LIKE_IGNORE_CASE')">
+                      and lower(A${index}.TEXT_)
+                    </when>
+                    <otherwise>
+                      and A${index}.TEXT_
+                    </otherwise>
+                  </choose> 
+                  <choose>
+                      <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
+                      <otherwise><include refid="executionVariableOperator" /></otherwise>
+                  </choose>          
+                  #{var.textValue}
+                  <choose>
+        			<when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
+        		  </choose>
+                </if>
+                <if test="var.textValue2 != null">
+                  and A${index}.TEXT2_ 
+                  <choose>
+                    <when test="var.operator.equals('LIKE')">LIKE</when>
+                    <otherwise><include refid="executionVariableOperator" /></otherwise>
+                  </choose>          
+                  #{var.textValue2}
+                  <choose>
+        			<when test="var.operator.equals('LIKE')">${wildcardEscapeClause}</when>
+        		  </choose>
+                </if>
+                <if test="var.longValue != null">
+                  and A${index}.LONG_
                   <include refid="executionVariableOperator" />
-                </otherwise>
-              </choose>          
-              #{var.textValue}
-              <choose>
-                <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
-              </choose>
-            </if>
-            <if test="var.textValue2 != null">
-              and A${index}.TEXT2_ 
-              <choose>
-                <when test="var.operator.equals('LIKE')">LIKE</when>
-                <otherwise>
+                  #{var.longValue}
+                </if>
+                <if test="var.doubleValue != null">
+                  and A${index}.DOUBLE_ 
                   <include refid="executionVariableOperator" />
-                </otherwise>
-              </choose>          
-              #{var.textValue2}
-              <choose>
-                <when test="var.operator.equals('LIKE')">${wildcardEscapeClause}</when>
-              </choose>
-            </if>
-            <if test="var.longValue != null">
-              and A${index}.LONG_
-              <include refid="executionVariableOperator" />
-              #{var.longValue}
-            </if>
-            <if test="var.doubleValue != null">
-              and A${index}.DOUBLE_ 
-              <include refid="executionVariableOperator" />
-              #{var.doubleValue}
-            </if>
-            <!-- Null variable type -->
-            <if test="var.textValue == null &amp;&amp; var.textValue2 == null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
-              <choose>
-                <when test="var.operator.equals('NOT_EQUALS')">
-                  and (A${index}.TEXT_ is not null or A${index}.TEXT2_ is not null or A${index}.LONG_ is not null or A${index}.DOUBLE_ is not null or A${index}.BYTEARRAY_ID_ is not null)
-                </when>
-                <otherwise>
-                  and A${index}.TEXT_ is null and A${index}.TEXT2_ is null and A${index}.LONG_ is null and A${index}.DOUBLE_ is null and A${index}.BYTEARRAY_ID_ is null
-                </otherwise>
-              </choose>          
-            </if>
-          </otherwise>
+                  #{var.doubleValue}
+                </if>
+                <!-- Null variable type -->
+                <if test="var.textValue == null &amp;&amp; var.textValue2 == null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
+                  <choose>
+                    <when test="var.operator.equals('NOT_EQUALS')">
+                      and (A${index}.TEXT_ is not null or A${index}.TEXT2_ is not null or A${index}.LONG_ is not null or A${index}.DOUBLE_ is not null or A${index}.BYTEARRAY_ID_ is not null)
+                    </when>
+                    <otherwise>
+                      and A${index}.TEXT_ is null and A${index}.TEXT2_ is null and A${index}.LONG_ is null and A${index}.DOUBLE_ is null and A${index}.BYTEARRAY_ID_ is null
+                    </otherwise>
+                  </choose>          
+                </if>
+            </otherwise>
         </choose>
       </foreach>
       <if test="suspensionState != null">
         <if test="suspensionState.stateCode == 1">
-          and RES.SUSPENSION_STATE_ = 1
+            and RES.SUSPENSION_STATE_ = 1
         </if>
         <if test="suspensionState.stateCode == 2">
-          and RES.SUSPENSION_STATE_ = 2
+            and RES.SUSPENSION_STATE_ = 2
         </if>
       </if>
       <if test="tenantId != null">
@@ -967,431 +960,441 @@ under the License.
           <if test="userIdForCandidateAndAssignee != null">
             <if test="candidateGroups == null">
               and (RES.ASSIGNEE_ = #{userIdForCandidateAndAssignee}
-              or (
-              <if test="!ignoreAssigneeValue">
-                RES.ASSIGNEE_ is null
-              </if>
-              and (I.USER_ID_ = #{userIdForCandidateAndAssignee}
-              or I.GROUP_ID_ IN (select g.GROUP_ID_ from ${prefix}ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{userIdForCandidateAndAssignee} ) ) ) )
+                or (
+                <if test="!ignoreAssigneeValue">
+                    RES.ASSIGNEE_ is null and
+                </if>
+                exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_
+                and (LINK.USER_ID_ = #{userIdForCandidateAndAssignee}
+                or LINK.GROUP_ID_ IN (select g.GROUP_ID_ from ${prefix}ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{userIdForCandidateAndAssignee} )))))
             </if>
           </if>
           <!-- if dbIdentityUsed set false in process engine configuration of using custom session factory of GroupIdentityManager -->
           <if test="candidateGroups != null">
             and (RES.ASSIGNEE_ = #{userIdForCandidateAndAssignee}
-            
-            or (
-            <if test="!ignoreAssigneeValue">
-              RES.ASSIGNEE_ is null and
-            </if>
-            I.TYPE_ = 'candidate' and (I.USER_ID_ = #{userIdForCandidateAndAssignee}
-            <if test="candidateGroups.size() &gt; 0">
-              or I.GROUP_ID_ IN
-              <foreach item="group" index="index" collection="candidateGroups" open="(" separator="," close=")">
-                #{group}
-              </foreach>
-            </if>
-            )))
+              or (
+              <if test="!ignoreAssigneeValue">
+                RES.ASSIGNEE_ is null and
+              </if>
+                exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_
+                and LINK.TYPE_ = 'candidate' and (LINK.USER_ID_ = #{userIdForCandidateAndAssignee}
+                <if test="candidateGroups.size() &gt; 0">
+                    or LINK.GROUP_ID_ IN
+                    <foreach item="group" index="index" collection="candidateGroups" open="(" separator="," close=")">
+                        #{group}
+                    </foreach>
+                </if>
+                ))))
           </if>
         </when>
       </choose>
       <foreach item="orQueryObject" index="orIndex" collection="orQueryObjects">
         and 
         <trim prefix="(" prefixOverrides="OR" suffix=")">
-          <if test="orQueryObject.taskId != null">
-            RES.ID_ = #{orQueryObject.taskId}
-          </if>
-          <if test="orQueryObject.name != null">
-            or RES.NAME_ = #{orQueryObject.name}
-          </if>
-          <if test="orQueryObject.nameLike != null">
-            or RES.NAME_ like #{orQueryObject.nameLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.nameLikeIgnoreCase != null">
-            or lower(RES.NAME_) like #{orQueryObject.nameLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.nameList != null &amp;&amp; orQueryObject.nameList.size() &gt; 0">
-            or RES.NAME_ IN
-            <foreach item="name" index="index" collection="orQueryObject.nameList"
-                       open="(" separator="," close=")">
-              #{name}
-            </foreach>
-          </if>
-          <if test="orQueryObject.nameListIgnoreCase != null &amp;&amp; orQueryObject.nameListIgnoreCase.size() &gt; 0">
-            or lower(RES.NAME_) IN
-            <foreach item="name" index="index" collection="orQueryObject.nameListIgnoreCase"
-                       open="(" separator="," close=")">
-              #{name}
-            </foreach>
-          </if>
-          <if test="orQueryObject.description != null">
-            or RES.DESCRIPTION_ = #{orQueryObject.description}
-          </if>
-          <if test="orQueryObject.descriptionLike != null">
-            or RES.DESCRIPTION_ like #{orQueryObject.descriptionLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.descriptionLikeIgnoreCase != null">
-            or lower(RES.DESCRIPTION_) like #{orQueryObject.descriptionLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.priority != null">
-            or RES.PRIORITY_ = #{orQueryObject.priority}
-          </if> 
-          <if test="orQueryObject.minPriority != null">
-            or RES.PRIORITY_ &gt;= #{orQueryObject.minPriority}
-          </if> 
-          <if test="orQueryObject.maxPriority != null">
-            or RES.PRIORITY_ &lt;= #{orQueryObject.maxPriority}
-          </if> 
-          <if test="orQueryObject.assignee != null">
-            or RES.ASSIGNEE_ = #{orQueryObject.assignee}
-          </if>
-          <if test="orQueryObject.assigneeLike != null">
-            or RES.ASSIGNEE_ like #{orQueryObject.assigneeLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.assigneeLikeIgnoreCase != null">
-            or lower(RES.ASSIGNEE_) like #{orQueryObject.assigneeLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.assigneeIds != null &amp;&amp; orQueryObject.assigneeIds.size() &gt; 0">
-            or RES.ASSIGNEE_ IN
-            <foreach item="assigneeId" index="index" collection="orQueryObject.assigneeIds" 
+            <if test="orQueryObject.taskId != null">
+              RES.ID_ = #{orQueryObject.taskId}
+            </if>
+            <if test="orQueryObject.name != null">
+              or RES.NAME_ = #{orQueryObject.name}
+            </if>
+            <if test="orQueryObject.nameLike != null">
+              or RES.NAME_ like #{orQueryObject.nameLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.nameLikeIgnoreCase != null">
+              or lower(RES.NAME_) like #{orQueryObject.nameLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.nameList != null &amp;&amp; orQueryObject.nameList.size() &gt; 0">
+              or RES.NAME_ IN
+              <foreach item="name" index="index" collection="orQueryObject.nameList"
+                      open="(" separator="," close=")">
+                #{name}
+              </foreach>
+            </if>
+            <if test="orQueryObject.nameListIgnoreCase != null &amp;&amp; orQueryObject.nameListIgnoreCase.size() &gt; 0">
+              or lower(RES.NAME_) IN
+              <foreach item="name" index="index" collection="orQueryObject.nameListIgnoreCase"
                        open="(" separator="," close=")">
-              #{assigneeId}
-            </foreach>
-          </if>
-          <if test="orQueryObject.owner != null">
-            or RES.OWNER_ = #{orQueryObject.owner}
-          </if>
-          <if test="orQueryObject.ownerLike != null">
-            or RES.OWNER_ like #{orQueryObject.ownerLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.ownerLikeIgnoreCase != null">
-            or RES.OWNER_ like #{orQueryObject.ownerLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.unassigned">
-            or RES.ASSIGNEE_ IS NULL
-          </if>
-          <if test="orQueryObject.noDelegationState">
-            or RES.DELEGATION_ IS NULL
-          </if>
-          <if test="orQueryObject.delegationState != null">
-            or RES.DELEGATION_ = #{orQueryObject.delegationStateString}
-          </if>
-          <if test="orQueryObject.processInstanceId != null">
-            or RES.PROC_INST_ID_ = #{orQueryObject.processInstanceId}
-          </if>
-          <if test="orQueryObject.processInstanceIds != null &amp;&amp; orQueryObject.processInstanceIds.size() &gt; 0">
-            or RES.PROC_INST_ID_ IN
-            <foreach item="processInstance" index="index" collection="orQueryObject.processInstanceIds" 
+                #{name}
+              </foreach>
+            </if>
+            <if test="orQueryObject.description != null">
+              or RES.DESCRIPTION_ = #{orQueryObject.description}
+            </if>
+            <if test="orQueryObject.descriptionLike != null">
+              or RES.DESCRIPTION_ like #{orQueryObject.descriptionLike}${wildcardEscapeClause}
+            </if>
+             <if test="orQueryObject.descriptionLikeIgnoreCase != null">
+              or lower(RES.DESCRIPTION_) like #{orQueryObject.descriptionLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.priority != null">
+              or RES.PRIORITY_ = #{orQueryObject.priority}
+            </if> 
+            <if test="orQueryObject.minPriority != null">
+              or RES.PRIORITY_ &gt;= #{orQueryObject.minPriority}
+            </if> 
+            <if test="orQueryObject.maxPriority != null">
+              or RES.PRIORITY_ &lt;= #{orQueryObject.maxPriority}
+            </if> 
+            <if test="orQueryObject.assignee != null">
+              or RES.ASSIGNEE_ = #{orQueryObject.assignee}
+            </if>
+            <if test="orQueryObject.assigneeLike != null">
+              or RES.ASSIGNEE_ like #{orQueryObject.assigneeLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.assigneeLikeIgnoreCase != null">
+              or lower(RES.ASSIGNEE_) like #{orQueryObject.assigneeLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.assigneeIds != null &amp;&amp; orQueryObject.assigneeIds.size() &gt; 0">
+		      or RES.ASSIGNEE_ IN
+		      <foreach item="assigneeId" index="index" collection="orQueryObject.assigneeIds" 
+		               open="(" separator="," close=")">
+		        #{assigneeId}
+		      </foreach>
+		    </if>
+            <if test="orQueryObject.owner != null">
+              or RES.OWNER_ = #{orQueryObject.owner}
+            </if>
+            <if test="orQueryObject.ownerLike != null">
+              or RES.OWNER_ like #{orQueryObject.ownerLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.ownerLikeIgnoreCase != null">
+              or RES.OWNER_ like #{orQueryObject.ownerLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.unassigned">
+              or RES.ASSIGNEE_ IS NULL
+            </if>
+            <if test="orQueryObject.noDelegationState">
+              or RES.DELEGATION_ IS NULL
+            </if>
+            <if test="orQueryObject.delegationState != null">
+              or RES.DELEGATION_ = #{orQueryObject.delegationStateString}
+            </if>
+            <if test="orQueryObject.processInstanceId != null">
+              or RES.PROC_INST_ID_ = #{orQueryObject.processInstanceId}
+            </if>
+            <if test="orQueryObject.processInstanceIds != null &amp;&amp; orQueryObject.processInstanceIds.size() &gt; 0">
+              or RES.PROC_INST_ID_ IN
+              <foreach item="processInstance" index="index" collection="orQueryObject.processInstanceIds" 
                        open="(" separator="," close=")">
-              #{processInstance}
-            </foreach>
-          </if>
-          <if test="orQueryObject.processInstanceBusinessKey != null">
-            or E_OR${orIndex}.BUSINESS_KEY_ = #{orQueryObject.processInstanceBusinessKey}
-          </if>
-          <if test="orQueryObject.processInstanceBusinessKeyLike != null">
-            or E_OR${orIndex}.BUSINESS_KEY_ like #{orQueryObject.processInstanceBusinessKeyLike}${wildcardEscapeClause}
-          </if>      
-          <if test="orQueryObject.processInstanceBusinessKeyLikeIgnoreCase != null">
-            or lower(E.BUSINESS_KEY_) like #{orQueryObject.processInstanceBusinessKeyLikeIgnoreCase}${wildcardEscapeClause}
-          </if>         
-          <if test="orQueryObject.executionId != null">
-            or RES.EXECUTION_ID_ = #{orQueryObject.executionId}
-          </if>
-          <if test="orQueryObject.scopeId != null">
-            and RES.SCOPE_ID_ = #{orQueryObject.scopeId}
-          </if>
-          <if test="orQueryObject.subScopeId != null">
-            and RES.SUB_SCOPE_ID_ = #{orQueryObject.subScopeId}
-          </if>
-          <if test="orQueryObject.scopeType != null">
-            and RES.SCOPE_TYPE_ = #{orQueryObject.scopeType}
-          </if>
-          <if test="orQueryObject.scopeDefinitionId != null">
-            and RES.SCOPE_DEFINITION_ID_ = #{orQueryObject.scopeDefinitionId}
-          </if>
-          <if test="orQueryObject.createTime != null">
-            or RES.CREATE_TIME_ = #{orQueryObject.createTime}
-          </if>
-          <if test="orQueryObject.createTimeBefore != null">
-            or RES.CREATE_TIME_ &lt; #{orQueryObject.createTimeBefore}
-          </if>
-          <if test="orQueryObject.createTimeAfter != null">
-            or RES.CREATE_TIME_ &gt; #{orQueryObject.createTimeAfter}
-          </if>
-          <if test="orQueryObject.key != null">
-            or RES.TASK_DEF_KEY_ = #{orQueryObject.key}
-          </if>
-          <if test="orQueryObject.keyLike != null">
-            or RES.TASK_DEF_KEY_ like #{orQueryObject.keyLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.processDefinitionId != null">
-            or RES.PROC_DEF_ID_ = #{orQueryObject.processDefinitionId}
-          </if>
-          <if test="orQueryObject.taskDefinitionId != null">
-            or RES.TASK_DEF_ID_ = #{orQueryObject.taskDefinitionId}
-          </if>
-          <if test="orQueryObject.processDefinitionKey != null">
-            or D_OR${orIndex}.KEY_ = #{orQueryObject.processDefinitionKey}
-          </if>
-          <if test="orQueryObject.processDefinitionKeyLike != null">
-            or D_OR${orIndex}.KEY_ like #{orQueryObject.processDefinitionKeyLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.processDefinitionKeyLikeIgnoreCase != null">
-            or lower(D_OR${orIndex}.KEY_) like #{orQueryObject.processDefinitionKeyLikeIgnoreCase}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.processDefinitionKeys != null &amp;&amp; orQueryObject.processDefinitionKeys.size() &gt; 0">
-            or D_OR${orIndex}.KEY_ in
-            <foreach item="item" index="index" collection="orQueryObject.processDefinitionKeys" open="(" separator="," close=")">
-              #{item}
-            </foreach>
-          </if>
-          <if test="orQueryObject.processDefinitionName != null">
-            or D_OR${orIndex}.NAME_ = #{orQueryObject.processDefinitionName}
-          </if>
-          <if test="orQueryObject.processDefinitionNameLike != null">
-            or D_OR${orIndex}.NAME_ like #{orQueryObject.processDefinitionNameLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.processCategoryInList != null &amp;&amp; orQueryObject.processCategoryInList.size() &gt; 0">
-            or D_OR${orIndex}.CATEGORY_ IN
-            <foreach item="processCategory" index="index" collection="orQueryObject.processCategoryInList"
+                #{processInstance}
+              </foreach>
+            </if>
+            <if test="orQueryObject.processInstanceBusinessKey != null">
+              or E_OR${orIndex}.BUSINESS_KEY_ = #{orQueryObject.processInstanceBusinessKey}
+            </if>
+            <if test="orQueryObject.processInstanceBusinessKeyLike != null">
+              or E_OR${orIndex}.BUSINESS_KEY_ like #{orQueryObject.processInstanceBusinessKeyLike}${wildcardEscapeClause}
+            </if>      
+            <if test="orQueryObject.processInstanceBusinessKeyLikeIgnoreCase != null">
+              or lower(E.BUSINESS_KEY_) like #{orQueryObject.processInstanceBusinessKeyLikeIgnoreCase}${wildcardEscapeClause}
+            </if>         
+            <if test="orQueryObject.executionId != null">
+              or RES.EXECUTION_ID_ = #{orQueryObject.executionId}
+            </if>
+            <if test="orQueryObject.scopeId != null">
+              and RES.SCOPE_ID_ = #{orQueryObject.scopeId}
+            </if>
+            <if test="orQueryObject.subScopeId != null">
+              and RES.SUB_SCOPE_ID_ = #{orQueryObject.subScopeId}
+            </if>
+            <if test="orQueryObject.scopeType != null">
+              and RES.SCOPE_TYPE_ = #{orQueryObject.scopeType}
+            </if>
+            <if test="orQueryObject.scopeDefinitionId != null">
+              and RES.SCOPE_DEFINITION_ID_ = #{orQueryObject.scopeDefinitionId}
+            </if>
+            <if test="orQueryObject.createTime != null">
+              or RES.CREATE_TIME_ = #{orQueryObject.createTime}
+            </if>
+            <if test="orQueryObject.createTimeBefore != null">
+              or RES.CREATE_TIME_ &lt; #{orQueryObject.createTimeBefore}
+            </if>
+            <if test="orQueryObject.createTimeAfter != null">
+              or RES.CREATE_TIME_ &gt; #{orQueryObject.createTimeAfter}
+            </if>
+            <if test="orQueryObject.key != null">
+              or RES.TASK_DEF_KEY_ = #{orQueryObject.key}
+            </if>
+            <if test="orQueryObject.keyLike != null">
+              or RES.TASK_DEF_KEY_ like #{orQueryObject.keyLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.processDefinitionId != null">
+              or RES.PROC_DEF_ID_ = #{orQueryObject.processDefinitionId}
+            </if>
+            <if test="orQueryObject.taskDefinitionId != null">
+              or RES.TASK_DEF_ID_ = #{orQueryObject.taskDefinitionId}
+            </if>
+            <if test="orQueryObject.processDefinitionKey != null">
+              or D_OR${orIndex}.KEY_ = #{orQueryObject.processDefinitionKey}
+            </if>
+            <if test="orQueryObject.processDefinitionKeyLike != null">
+              or D_OR${orIndex}.KEY_ like #{orQueryObject.processDefinitionKeyLike}${wildcardEscapeClause}
+            </if>
+             <if test="orQueryObject.processDefinitionKeyLikeIgnoreCase != null">
+              or lower(D_OR${orIndex}.KEY_) like #{orQueryObject.processDefinitionKeyLikeIgnoreCase}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.processDefinitionKeys != null &amp;&amp; orQueryObject.processDefinitionKeys.size() &gt; 0">
+              or D_OR${orIndex}.KEY_ in
+              <foreach item="item" index="index" collection="orQueryObject.processDefinitionKeys" open="(" separator="," close=")">
+                #{item}
+              </foreach>
+            </if>
+            <if test="orQueryObject.processDefinitionName != null">
+              or D_OR${orIndex}.NAME_ = #{orQueryObject.processDefinitionName}
+            </if>
+            <if test="orQueryObject.processDefinitionNameLike != null">
+              or D_OR${orIndex}.NAME_ like #{orQueryObject.processDefinitionNameLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.processCategoryInList != null &amp;&amp; orQueryObject.processCategoryInList.size() &gt; 0">
+              or D_OR${orIndex}.CATEGORY_ IN
+              <foreach item="processCategory" index="index" collection="orQueryObject.processCategoryInList"
                        open="(" separator="," close=")">
-              #{processCategory}
-            </foreach>
-          </if>
-          <if test="orQueryObject.processCategoryNotInList != null &amp;&amp; orQueryObject.processCategoryNotInList.size() &gt; 0">
-            or D_OR${orIndex}.CATEGORY_ NOT IN
-            <foreach item="processCategory" index="index" collection="orQueryObject.processCategoryNotInList"
+                #{processCategory}
+              </foreach>
+            </if>
+            <if test="orQueryObject.processCategoryNotInList != null &amp;&amp; orQueryObject.processCategoryNotInList.size() &gt; 0">
+              or D_OR${orIndex}.CATEGORY_ NOT IN
+              <foreach item="processCategory" index="index" collection="orQueryObject.processCategoryNotInList"
                        open="(" separator="," close=")">
-              #{processCategory}
-            </foreach>
-          </if>
-          <if test="orQueryObject.deploymentId != null">
-            or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ = #{orQueryObject.deploymentId}
-          </if>
-          <if test="orQueryObject.deploymentIds != null &amp;&amp; orQueryObject.deploymentIds.size() &gt; 0">
-            or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ IN
-            <foreach item="deployment" index="index" collection="orQueryObject.deploymentIds" 
+                #{processCategory}
+              </foreach>
+            </if>
+            <if test="orQueryObject.deploymentId != null">
+              or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ = #{orQueryObject.deploymentId}
+            </if>
+            <if test="orQueryObject.deploymentIds != null &amp;&amp; orQueryObject.deploymentIds.size() &gt; 0">
+              or DEPLOY_P_OR${orIndex}.DEPLOYMENT_ID_ IN
+              <foreach item="deployment" index="index" collection="orQueryObject.deploymentIds" 
                        open="(" separator="," close=")">
-              #{deployment}
-            </foreach>
-          </if>
-          <if test="orQueryObject.cmmnDeploymentId != null">
-            or DEPLOY_C_OR${orIndex}.DEPLOYMENT_ID_ = #{orQueryObject.cmmnDeploymentId}
-          </if>
-          <if test="orQueryObject.cmmnDeploymentIds != null &amp;&amp; orQueryObject.cmmnDeploymentIds.size() &gt; 0">
-            or DEPLOY_C_OR${orIndex}.DEPLOYMENT_ID_ IN
-            <foreach item="deployment" index="index" collection="orQueryObject.cmmnDeploymentIds" 
+                #{deployment}
+              </foreach>
+            </if>
+            <if test="orQueryObject.cmmnDeploymentId != null">
+              or DEPLOY_C_OR${orIndex}.DEPLOYMENT_ID_ = #{orQueryObject.cmmnDeploymentId}
+            </if>
+            <if test="orQueryObject.cmmnDeploymentIds != null &amp;&amp; orQueryObject.cmmnDeploymentIds.size() &gt; 0">
+              or DEPLOY_C_OR${orIndex}.DEPLOYMENT_ID_ IN
+              <foreach item="deployment" index="index" collection="orQueryObject.cmmnDeploymentIds" 
                        open="(" separator="," close=")">
-              #{deployment}
-            </foreach>
-          </if>
-          <if test="orQueryObject.dueDate != null">
-            or RES.DUE_DATE_ = #{orQueryObject.dueDate}
-          </if>
-          <if test="orQueryObject.dueBefore != null">
-            or (RES.DUE_DATE_ &lt; #{orQueryObject.dueBefore} and RES.DUE_DATE_ is not null)
-          </if>
-          <if test="orQueryObject.dueAfter != null">
-            or (RES.DUE_DATE_ &gt; #{orQueryObject.dueAfter} and RES.DUE_DATE_ is not null)
-          </if>
-          <if test="orQueryObject.withoutDueDate">
-            or RES.DUE_DATE_ is null
-          </if>
-          <if test="orQueryObject.category != null">
-            or RES.CATEGORY_ = #{orQueryObject.category}
-          </if>
-          <if test="orQueryObject.excludeSubtasks">
-            or RES.PARENT_TASK_ID_ IS NULL
-          </if>
-            
-          <if test="!orQueryObject.bothCandidateAndAssigned &amp;&amp; (orQueryObject.candidateUser != null || orQueryObject.candidateGroups != null)">
-            or (
-            <if test="!orQueryObject.ignoreAssigneeValue">
-              RES.ASSIGNEE_ is null and
+                #{deployment}
+              </foreach>
             </if>
-            I_OR${orIndex}.TYPE_ = 'candidate'
-            and 
-            ( 
-            <if test="orQueryObject.candidateUser != null">
-              I_OR${orIndex}.USER_ID_ = #{orQueryObject.candidateUser}          
+            <if test="orQueryObject.dueDate != null">
+              or RES.DUE_DATE_ = #{orQueryObject.dueDate}
             </if>
-            <if test="orQueryObject.candidateUser != null &amp;&amp; orQueryObject.candidateGroups != null &amp;&amp; orQueryObject.candidateGroups.size() &gt; 0">
-              or
+            <if test="orQueryObject.dueBefore != null">
+              or (RES.DUE_DATE_ &lt; #{orQueryObject.dueBefore} and RES.DUE_DATE_ is not null)
             </if>
-            <if test="orQueryObject.candidateGroups != null &amp;&amp; orQueryObject.candidateGroups.size() &gt; 0">
-              I_OR${orIndex}.GROUP_ID_ IN
-              <foreach item="group" index="index" collection="orQueryObject.candidateGroups" 
-                           open="(" separator="," close=")">
-                #{group}
-              </foreach>
+            <if test="orQueryObject.dueAfter != null">
+              or (RES.DUE_DATE_ &gt; #{orQueryObject.dueAfter} and RES.DUE_DATE_ is not null)
             </if>
-            ))
-          </if>
-          <if test="orQueryObject.involvedUser != null">
-            or (
-            exists(select LINK.USER_ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where USER_ID_ = #{orQueryObject.involvedUser} and LINK.TASK_ID_ = RES.ID_)
-            or RES.ASSIGNEE_ = #{orQueryObject.involvedUser}
-            or RES.OWNER_ = #{orQueryObject.involvedUser}
-            )
-          </if>
-          <foreach item="var" collection="orQueryObject.queryVariableValues" index="index">
-            or 
-            <trim prefix="(" prefixOverrides="AND" suffix=")">
-              <choose>
-                <when test="var.operator.equals('EXISTS')">
-                  and EXISTS (
-                  select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
-                  <if test="!var.local">
-                    and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
-                  </if>
-                  <if test="var.local">
-                    and RES.ID_ = TASK_ID_ 
-                  </if>
-                  )
-                </when>
-                <when test="var.operator.equals('NOT_EXISTS')">
-                  and NOT EXISTS (
-                  select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
-                  <if test="!var.local">
-                    and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
-                  </if>
-                  <if test="var.local">
-                    and RES.ID_ = TASK_ID_ 
-                  </if>
-                  )
-                </when>
-                <otherwise>
-                  <choose>
-                    <when test="!var.local">
-                      <bind name="orLocal" value="''" />
-                      <!-- When process instance variable is queried for, taskId should be null -->
-                      and A_OR${orIndex}.TASK_ID_ is null
+            <if test="orQueryObject.withoutDueDate">
+              or RES.DUE_DATE_ is null
+            </if>
+            <if test="orQueryObject.category != null">
+              or RES.CATEGORY_ = #{orQueryObject.category}
+            </if>
+            <if test="orQueryObject.excludeSubtasks">
+              or RES.PARENT_TASK_ID_ IS NULL
+            </if>
+            
+            <if test="!orQueryObject.bothCandidateAndAssigned &amp;&amp; (orQueryObject.candidateUser != null || orQueryObject.candidateGroups != null)">
+              or (
+                <if test="!orQueryObject.ignoreAssigneeValue">
+                    RES.ASSIGNEE_ is null and
+                </if>
+                exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TYPE_ = 'candidate' and LINK.TASK_ID_ = RES.ID_
+                    and 
+                    ( 
+                    <if test="orQueryObject.candidateUser != null">
+                      LINK.USER_ID_ = #{orQueryObject.candidateUser}          
+                    </if>
+                    <if test="orQueryObject.candidateUser != null &amp;&amp; orQueryObject.candidateGroups != null &amp;&amp; orQueryObject.candidateGroups.size() &gt; 0">
+                      or
+                    </if>
+                    <if test="orQueryObject.candidateGroups != null &amp;&amp; orQueryObject.candidateGroups.size() &gt; 0">
+                      LINK.GROUP_ID_ IN
+                      <foreach item="group" index="index" collection="orQueryObject.candidateGroups" 
+                               open="(" separator="," close=")">
+                        #{group}
+                      </foreach>
+                    </if>
+                    )
+                )
+              )
+            </if>
+            <if test="orQueryObject.involvedUser != null">
+              or (
+                exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.USER_ID_ = #{orQueryObject.involvedUser} and LINK.TASK_ID_ = RES.ID_)
+                or RES.ASSIGNEE_ = #{orQueryObject.involvedUser}
+                or RES.OWNER_ = #{orQueryObject.involvedUser}
+                )
+            </if>
+            <if test="orQueryObject.involvedGroups != null">
+              or (
+                EXISTS(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_ and LINK.GROUP_ID_ in
+                <foreach item="involvedGroup" index="index" collection="orQueryObject.involvedGroups" open="(" separator="," close=")">
+                    #{involvedGroup}
+                </foreach>
+                )
+              )
+            </if>
+            <foreach item="var" collection="orQueryObject.queryVariableValues" index="index">
+              or 
+              <trim prefix="(" prefixOverrides="AND" suffix=")">
+                <choose>
+                    <when test="var.operator.equals('EXISTS')">
+                        and EXISTS (
+                            select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
+                        <if test="!var.local">
+                            and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
+                        </if>
+                        <if test="var.local">
+                            and RES.ID_ = TASK_ID_ 
+                        </if>
+                        )
+                    </when>
+                    <when test="var.operator.equals('NOT_EXISTS')">
+                        and NOT EXISTS (
+                            select ID_ from ${prefix}ACT_RU_VARIABLE where NAME_ = #{var.name}
+                        <if test="!var.local">
+                            and RES.PROC_INST_ID_ = PROC_INST_ID_ and TASK_ID_ is null
+                        </if>
+                        <if test="var.local">
+                            and RES.ID_ = TASK_ID_ 
+                        </if>
+                        )
                     </when>
                     <otherwise>
-                      <bind name="orLocal" value="'L_'" />
-                    </otherwise>
-                  </choose>
-                  <if test="var.name != null">
-                    <!-- Match-all variable-names when name is null -->
-                    and A_${orLocal}OR${orIndex}.NAME_= #{var.name}
-                  </if>
-                  <if test="var.name == null">
-                    and A_${orLocal}OR${orIndex}.NAME_ is not null
-                  </if>
-                  <if test="!var.type.equals('null')">
-                    and A_${orLocal}OR${orIndex}.TYPE_ = #{var.type}
-                  </if>
-                  <!-- Variable value -->
-                  <if test="var.textValue != null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
-                    <choose>
-                      <when test="var.operator.equals('EQUALS_IGNORE_CASE') || var.operator.equals('NOT_EQUALS_IGNORE_CASE') || var.operator.equals('LIKE_IGNORE_CASE')">
-                        and lower(A_${orLocal}OR${orIndex}.TEXT_)
-                      </when>
-                      <otherwise>
-                        and A_${orLocal}OR${orIndex}.TEXT_
-                      </otherwise>
-                    </choose> 
-                    <choose>
-                      <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
-                      <otherwise>
+                      <choose>
+                        <when test="!var.local">
+                          <bind name="orLocal" value="''" />
+                          <!-- When process instance variable is queried for, taskId should be null -->
+                          and A_OR${orIndex}.TASK_ID_ is null
+                        </when>
+                        <otherwise>
+                          <bind name="orLocal" value="'L_'" />
+                        </otherwise>
+                      </choose>
+                      <if test="var.name != null">
+                        <!-- Match-all variable-names when name is null -->
+                        and A_${orLocal}OR${orIndex}.NAME_= #{var.name}
+                      </if>
+                      <if test="var.name == null">
+                        and A_${orLocal}OR${orIndex}.NAME_ is not null
+                      </if>
+                      <if test="!var.type.equals('null')">
+                        and A_${orLocal}OR${orIndex}.TYPE_ = #{var.type}
+                      </if>
+                      <!-- Variable value -->
+                      <if test="var.textValue != null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
+                        <choose>
+                          <when test="var.operator.equals('EQUALS_IGNORE_CASE') || var.operator.equals('NOT_EQUALS_IGNORE_CASE') || var.operator.equals('LIKE_IGNORE_CASE')">
+                            and lower(A_${orLocal}OR${orIndex}.TEXT_)
+                          </when>
+                          <otherwise>
+                            and A_${orLocal}OR${orIndex}.TEXT_
+                          </otherwise>
+                        </choose> 
+                        <choose>
+                            <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">LIKE</when>
+                            <otherwise><include refid="executionVariableOperator" /></otherwise>
+                        </choose>          
+                        #{var.textValue}
+                        <choose>
+                            <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
+                        </choose>
+                      </if>
+                      <if test="var.textValue2 != null">
+                        and A_${orLocal}OR${orIndex}.TEXT2_
+                        <choose>
+                          <when test="var.operator.equals('LIKE')">LIKE</when>
+                          <otherwise><include refid="executionVariableOperator" /></otherwise>
+                        </choose>          
+                        #{var.textValue2}
+                        <choose>
+                          <when test="var.operator.equals('LIKE')">${wildcardEscapeClause}</when>
+                        </choose>
+                      </if>
+                      <if test="var.longValue != null">
+                        and A_${orLocal}OR${orIndex}.LONG_
                         <include refid="executionVariableOperator" />
-                      </otherwise>
-                    </choose>          
-                    #{var.textValue}
-                    <choose>
-                      <when test="var.operator.equals('LIKE') || var.operator.equals('LIKE_IGNORE_CASE')">${wildcardEscapeClause}</when>
-                    </choose>
-                  </if>
-                  <if test="var.textValue2 != null">
-                    and A_${orLocal}OR${orIndex}.TEXT2_
-                    <choose>
-                      <when test="var.operator.equals('LIKE')">LIKE</when>
-                      <otherwise>
+                        #{var.longValue}
+                      </if>
+                      <if test="var.doubleValue != null">
+                        and A_${orLocal}OR${orIndex}.DOUBLE_
                         <include refid="executionVariableOperator" />
-                      </otherwise>
-                    </choose>          
-                    #{var.textValue2}
-                    <choose>
-                      <when test="var.operator.equals('LIKE')">${wildcardEscapeClause}</when>
-                    </choose>
-                  </if>
-                  <if test="var.longValue != null">
-                    and A_${orLocal}OR${orIndex}.LONG_
-                    <include refid="executionVariableOperator" />
-                    #{var.longValue}
-                  </if>
-                  <if test="var.doubleValue != null">
-                    and A_${orLocal}OR${orIndex}.DOUBLE_
-                    <include refid="executionVariableOperator" />
-                    #{var.doubleValue}
-                  </if>
-                  <!-- Null variable type -->
-                  <if test="var.textValue == null &amp;&amp; var.textValue2 == null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
-                    <choose>
-                      <when test="var.operator.equals('NOT_EQUALS')">
-                        and (A_${orLocal}OR${orIndex}.TEXT_ is not null or A_${orLocal}OR${orIndex}.TEXT2_ is not null or A_${orLocal}OR${orIndex}.LONG_ is not null or A_${orLocal}OR${orIndex}.DOUBLE_ is not null or A_${orLocal}OR${orIndex}.BYTEARRAY_ID_ is not null)
-                      </when>
-                      <otherwise>
-                        and A_${orLocal}OR${orIndex}.TEXT_ is null and A_${orLocal}OR${orIndex}.TEXT2_ is null and A_${orLocal}OR${orIndex}.LONG_ is null and A_${orLocal}OR${orIndex}.DOUBLE_ is null and A_${orLocal}OR${orIndex}.BYTEARRAY_ID_ is null
-                      </otherwise>
-                    </choose>          
-                  </if>
-                </otherwise>
-              </choose>
-            </trim>
-          </foreach>
-          <if test="orQueryObject.suspensionState != null">
-            <if test="orQueryObject.suspensionState.stateCode == 1">
-              or RES.SUSPENSION_STATE_ = 1
+                        #{var.doubleValue}
+                      </if>
+                      <!-- Null variable type -->
+                      <if test="var.textValue == null &amp;&amp; var.textValue2 == null &amp;&amp; var.longValue == null &amp;&amp; var.doubleValue == null">
+                        <choose>
+                          <when test="var.operator.equals('NOT_EQUALS')">
+                            and (A_${orLocal}OR${orIndex}.TEXT_ is not null or A_${orLocal}OR${orIndex}.TEXT2_ is not null or A_${orLocal}OR${orIndex}.LONG_ is not null or A_${orLocal}OR${orIndex}.DOUBLE_ is not null or A_${orLocal}OR${orIndex}.BYTEARRAY_ID_ is not null)
+                          </when>
+                          <otherwise>
+                            and A_${orLocal}OR${orIndex}.TEXT_ is null and A_${orLocal}OR${orIndex}.TEXT2_ is null and A_${orLocal}OR${orIndex}.LONG_ is null and A_${orLocal}OR${orIndex}.DOUBLE_ is null and A_${orLocal}OR${orIndex}.BYTEARRAY_ID_ is null
+                          </otherwise>
+                        </choose>          
+                      </if>
+                    </otherwise>
+                </choose>
+              </trim>
+            </foreach>
+            <if test="orQueryObject.suspensionState != null">
+              <if test="orQueryObject.suspensionState.stateCode == 1">
+                  or RES.SUSPENSION_STATE_ = 1
+              </if>
+              <if test="orQueryObject.suspensionState.stateCode == 2">
+                  or RES.SUSPENSION_STATE_ = 2
+              </if>
             </if>
-            <if test="orQueryObject.suspensionState.stateCode == 2">
-              or RES.SUSPENSION_STATE_ = 2
+            <if test="orQueryObject.tenantId != null">
+              or RES.TENANT_ID_ = #{orQueryObject.tenantId}
             </if>
-          </if>
-          <if test="orQueryObject.tenantId != null">
-            or RES.TENANT_ID_ = #{orQueryObject.tenantId}
-          </if>
-          <if test="orQueryObject.tenantIdLike != null">
-            or RES.TENANT_ID_ like #{orQueryObject.tenantIdLike}${wildcardEscapeClause}
-          </if>
-          <if test="orQueryObject.withoutTenantId">
-            or (RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null)
-          </if>
-          <choose>
-            <when test="orQueryObject.bothCandidateAndAssigned">
-              <!-- if dbIdentityUsed set true in process engine configuration -->
-              <if test="orQueryObject.userIdForCandidateAndAssignee != null">
-                <if test="orQueryObject.candidateGroups == null">
-                  or (RES.ASSIGNEE_ = #{orQueryObject.userIdForCandidateAndAssignee}
-                  or (
-                  <if test="!orQueryObject.ignoreAssigneeValue">
-                    RES.ASSIGNEE_ is null and
+            <if test="orQueryObject.tenantIdLike != null">
+              or RES.TENANT_ID_ like #{orQueryObject.tenantIdLike}${wildcardEscapeClause}
+            </if>
+            <if test="orQueryObject.withoutTenantId">
+              or (RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null)
+            </if>
+            <choose>
+              <when test="orQueryObject.bothCandidateAndAssigned">
+                <!-- if dbIdentityUsed set true in process engine configuration -->
+                <if test="orQueryObject.userIdForCandidateAndAssignee != null">
+                  <if test="orQueryObject.candidateGroups == null">
+                    or (RES.ASSIGNEE_ = #{orQueryObject.userIdForCandidateAndAssignee}
+                        or (
+                        <if test="!orQueryObject.ignoreAssigneeValue">
+                            RES.ASSIGNEE_ is null and
+                        </if>
+                        exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_
+                        and (LINK.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee}
+                        or LINK.GROUP_ID_ IN (select g.GROUP_ID_ from ${prefix}ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee} )))))
                   </if>
-                  (I_OR${orIndex}.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee}
-                  or I_OR${orIndex}.GROUP_ID_ IN (select g.GROUP_ID_ from ${prefix}ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee} ) ) ) )
-                </if>
-              </if>
-              <!-- if dbIdentityUsed set false in process engine configuration of using custom session factory of GroupIdentityManager -->
-              <if test="orQueryObject.candidateGroups != null">
-                or (RES.ASSIGNEE_ = #{orQueryObject.userIdForCandidateAndAssignee}
-                or (
-                <if test="!orQueryObject.ignoreAssigneeValue">
-                  RES.ASSIGNEE_ is null and
                 </if>
-                I_OR${orIndex}.TYPE_ = 'candidate' and (I_OR${orIndex}.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee}
-                <if test="orQueryObject.candidateGroups.size() &gt; 0">
-                  or I_OR${orIndex}.GROUP_ID_ IN
-                  <foreach item="group" index="index" collection="orQueryObject.candidateGroups" open="(" separator="," close=")">
-                    #{group}
-                  </foreach>
+                <!-- if dbIdentityUsed set false in process engine configuration of using custom session factory of GroupIdentityManager -->
+                <if test="orQueryObject.candidateGroups != null">
+                  or (RES.ASSIGNEE_ = #{orQueryObject.userIdForCandidateAndAssignee}
+                  or (
+                    <if test="!orQueryObject.ignoreAssigneeValue">
+                        RES.ASSIGNEE_ is null and
+                    </if>
+                    exists(select LINK.ID_ from ${prefix}ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = RES.ID_
+                    and LINK.TYPE_ = 'candidate' and (LINK.USER_ID_ = #{orQueryObject.userIdForCandidateAndAssignee}
+                    <if test="orQueryObject.candidateGroups.size() &gt; 0">
+                        or LINK.GROUP_ID_ IN
+                        <foreach item="group" index="index" collection="orQueryObject.candidateGroups" open="(" separator="," close=")">
+                            #{group}
+                        </foreach>
+                    </if>
+                  ))))
                 </if>
-                )))
-              </if>
-            </when>
-          </choose>
-        </trim>
-      </foreach>
-    </where>
+              </when>
+            </choose>
+          </trim>
+        </foreach>
+     </where>
   </sql>
   
   <sql id="executionVariableOperator">
@@ -1404,15 +1407,15 @@ under the License.
       <when test="var.operator.equals('GREATER_THAN_OR_EQUAL')">&gt;=</when>
       <when test="var.operator.equals('LESS_THAN')">&lt;</when>
       <when test="var.operator.equals('LESS_THAN_OR_EQUAL')">&lt;=</when>
-    </choose>
+   </choose>
   </sql>  
 
   <select id="selectTaskByNativeQuery" parameterType="java.util.Map" resultMap="taskResultMap">
-    <include refid="org.flowable.task.service.db.common.selectByNativeQuery"/>
+  	<include refid="org.flowable.task.service.db.common.selectByNativeQuery"/>
   </select>
   
   <select id="selectTaskCountByNativeQuery" parameterType="java.util.Map" resultType="long">
-    ${sql}
+     ${sql}
   </select>
 
 </mapper>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/syncope/blob/5daece32/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a04a9e5..2014447 100644
--- a/pom.xml
+++ b/pom.xml
@@ -408,7 +408,7 @@ under the License.
 
     <groovy.version>3.0.0-alpha-3</groovy.version>
 
-    <flowable.version>6.3.1</flowable.version>
+    <flowable.version>6.4.0</flowable.version>
 
     <camel.version>2.22.1</camel.version>	
 
@@ -1150,6 +1150,11 @@ under the License.
       </dependency>
       <dependency>
         <groupId>org.flowable</groupId>
+        <artifactId>flowable-idm-spring-configurator</artifactId>
+        <version>${flowable.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.flowable</groupId>
         <artifactId>flowable-json-converter</artifactId>
         <version>${flowable.version}</version>
       </dependency>


[2/4] syncope git commit: Upgrading Flowable

Posted by il...@apache.org.
Upgrading Flowable


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/c193001d
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/c193001d
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/c193001d

Branch: refs/heads/2_1_X
Commit: c193001d8336e8eb7d1e78072af458a39668bebd
Parents: 6f6d915
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Tue Oct 2 16:19:04 2018 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Tue Oct 2 16:19:04 2018 +0200

----------------------------------------------------------------------
 ext/flowable/flowable-bpmn/pom.xml              |    4 +
 .../flowable/impl/FlowableRuntimeUtils.java     |    1 +
 .../flowable/impl/SyncopeTaskQueryImpl.java     |   49 -
 .../flowable/support/SyncopeTaskQueryImpl.java  |   49 +
 .../org/apache/syncope/ext/flowable/Task.xml    | 1415 +++++++++---------
 pom.xml                                         |    7 +-
 6 files changed, 769 insertions(+), 756 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/c193001d/ext/flowable/flowable-bpmn/pom.xml
----------------------------------------------------------------------
diff --git a/ext/flowable/flowable-bpmn/pom.xml b/ext/flowable/flowable-bpmn/pom.xml
index a236d20..0cdbee6 100644
--- a/ext/flowable/flowable-bpmn/pom.xml
+++ b/ext/flowable/flowable-bpmn/pom.xml
@@ -61,6 +61,10 @@ under the License.
     </dependency>
     <dependency>
       <groupId>org.flowable</groupId>
+      <artifactId>flowable-idm-spring-configurator</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.flowable</groupId>
       <artifactId>flowable-json-converter</artifactId>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/c193001d/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java
----------------------------------------------------------------------
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 cdf035d..15fd7a4 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
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.core.flowable.impl;
 
+import org.apache.syncope.core.flowable.support.SyncopeTaskQueryImpl;
 import java.util.Base64;
 import java.util.List;
 import java.util.Set;

http://git-wip-us.apache.org/repos/asf/syncope/blob/c193001d/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/SyncopeTaskQueryImpl.java
----------------------------------------------------------------------
diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/SyncopeTaskQueryImpl.java b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/SyncopeTaskQueryImpl.java
deleted file mode 100644
index eb36838..0000000
--- a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/SyncopeTaskQueryImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.apache.syncope.core.flowable.impl;
-
-import org.flowable.common.engine.impl.interceptor.CommandExecutor;
-import org.flowable.task.api.TaskQuery;
-import org.flowable.task.service.impl.TaskQueryImpl;
-
-public class SyncopeTaskQueryImpl extends TaskQueryImpl {
-
-    private static final long serialVersionUID = 734215641378485689L;
-
-    protected boolean withFormKey;
-
-    protected SyncopeTaskQueryImpl currentOrQueryObject;
-
-    public SyncopeTaskQueryImpl(final CommandExecutor commandExecutor) {
-        super(commandExecutor);
-    }
-
-    public TaskQuery taskWithFormKey() {
-        if (orActive) {
-            currentOrQueryObject.withFormKey = true;
-        } else {
-            this.withFormKey = true;
-        }
-        return this;
-    }
-
-    public boolean isWithFormKey() {
-        return withFormKey;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/c193001d/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/SyncopeTaskQueryImpl.java
----------------------------------------------------------------------
diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/SyncopeTaskQueryImpl.java b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/SyncopeTaskQueryImpl.java
new file mode 100644
index 0000000..833fe6b
--- /dev/null
+++ b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/SyncopeTaskQueryImpl.java
@@ -0,0 +1,49 @@
+/*
+ * 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.apache.syncope.core.flowable.support;
+
+import org.flowable.common.engine.impl.interceptor.CommandExecutor;
+import org.flowable.task.api.TaskQuery;
+import org.flowable.task.service.impl.TaskQueryImpl;
+
+public class SyncopeTaskQueryImpl extends TaskQueryImpl {
+
+    private static final long serialVersionUID = 734215641378485689L;
+
+    protected boolean withFormKey;
+
+    protected SyncopeTaskQueryImpl currentOrQueryObject;
+
+    public SyncopeTaskQueryImpl(final CommandExecutor commandExecutor) {
+        super(commandExecutor);
+    }
+
+    public TaskQuery taskWithFormKey() {
+        if (orActive) {
+            currentOrQueryObject.withFormKey = true;
+        } else {
+            this.withFormKey = true;
+        }
+        return this;
+    }
+
+    public boolean isWithFormKey() {
+        return withFormKey;
+    }
+}


[4/4] syncope git commit: Upgrading Flowable

Posted by il...@apache.org.
Upgrading Flowable


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/5daece32
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/5daece32
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/5daece32

Branch: refs/heads/master
Commit: 5daece32b19b2a00d5627d41c67e939fc2eac9f7
Parents: fee1317
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Tue Oct 2 16:19:04 2018 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Tue Oct 2 16:19:12 2018 +0200

----------------------------------------------------------------------
 ext/flowable/flowable-bpmn/pom.xml              |    4 +
 .../flowable/impl/FlowableRuntimeUtils.java     |    1 +
 .../flowable/impl/SyncopeTaskQueryImpl.java     |   49 -
 .../flowable/support/SyncopeTaskQueryImpl.java  |   49 +
 .../org/apache/syncope/ext/flowable/Task.xml    | 1415 +++++++++---------
 pom.xml                                         |    7 +-
 6 files changed, 769 insertions(+), 756 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/5daece32/ext/flowable/flowable-bpmn/pom.xml
----------------------------------------------------------------------
diff --git a/ext/flowable/flowable-bpmn/pom.xml b/ext/flowable/flowable-bpmn/pom.xml
index 9d13066..7218034 100644
--- a/ext/flowable/flowable-bpmn/pom.xml
+++ b/ext/flowable/flowable-bpmn/pom.xml
@@ -61,6 +61,10 @@ under the License.
     </dependency>
     <dependency>
       <groupId>org.flowable</groupId>
+      <artifactId>flowable-idm-spring-configurator</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.flowable</groupId>
       <artifactId>flowable-json-converter</artifactId>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/5daece32/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java
----------------------------------------------------------------------
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 cdf035d..15fd7a4 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
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.core.flowable.impl;
 
+import org.apache.syncope.core.flowable.support.SyncopeTaskQueryImpl;
 import java.util.Base64;
 import java.util.List;
 import java.util.Set;

http://git-wip-us.apache.org/repos/asf/syncope/blob/5daece32/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/SyncopeTaskQueryImpl.java
----------------------------------------------------------------------
diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/SyncopeTaskQueryImpl.java b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/SyncopeTaskQueryImpl.java
deleted file mode 100644
index eb36838..0000000
--- a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/SyncopeTaskQueryImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.apache.syncope.core.flowable.impl;
-
-import org.flowable.common.engine.impl.interceptor.CommandExecutor;
-import org.flowable.task.api.TaskQuery;
-import org.flowable.task.service.impl.TaskQueryImpl;
-
-public class SyncopeTaskQueryImpl extends TaskQueryImpl {
-
-    private static final long serialVersionUID = 734215641378485689L;
-
-    protected boolean withFormKey;
-
-    protected SyncopeTaskQueryImpl currentOrQueryObject;
-
-    public SyncopeTaskQueryImpl(final CommandExecutor commandExecutor) {
-        super(commandExecutor);
-    }
-
-    public TaskQuery taskWithFormKey() {
-        if (orActive) {
-            currentOrQueryObject.withFormKey = true;
-        } else {
-            this.withFormKey = true;
-        }
-        return this;
-    }
-
-    public boolean isWithFormKey() {
-        return withFormKey;
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/5daece32/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/SyncopeTaskQueryImpl.java
----------------------------------------------------------------------
diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/SyncopeTaskQueryImpl.java b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/SyncopeTaskQueryImpl.java
new file mode 100644
index 0000000..833fe6b
--- /dev/null
+++ b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/support/SyncopeTaskQueryImpl.java
@@ -0,0 +1,49 @@
+/*
+ * 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.apache.syncope.core.flowable.support;
+
+import org.flowable.common.engine.impl.interceptor.CommandExecutor;
+import org.flowable.task.api.TaskQuery;
+import org.flowable.task.service.impl.TaskQueryImpl;
+
+public class SyncopeTaskQueryImpl extends TaskQueryImpl {
+
+    private static final long serialVersionUID = 734215641378485689L;
+
+    protected boolean withFormKey;
+
+    protected SyncopeTaskQueryImpl currentOrQueryObject;
+
+    public SyncopeTaskQueryImpl(final CommandExecutor commandExecutor) {
+        super(commandExecutor);
+    }
+
+    public TaskQuery taskWithFormKey() {
+        if (orActive) {
+            currentOrQueryObject.withFormKey = true;
+        } else {
+            this.withFormKey = true;
+        }
+        return this;
+    }
+
+    public boolean isWithFormKey() {
+        return withFormKey;
+    }
+}