Skip to content

Commit 4def81b

Browse files
Added rootScopeIds and parentScopeIds to process and case instance queries and exist and not exists variable query support in the rest service
1 parent 8dfb3f5 commit 4def81b

55 files changed

Lines changed: 1933 additions & 40 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/flowable-cmmn-api/src/main/java/org/flowable/cmmn/api/history/HistoricCaseInstanceQuery.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,21 @@ public interface HistoricCaseInstanceQuery extends Query<HistoricCaseInstanceQue
7777
*/
7878
HistoricCaseInstanceQuery caseInstanceRootScopeId(String rootScopeId);
7979

80+
/**
81+
* Only select historic case instances with one of the given root scope ids.
82+
*/
83+
HistoricCaseInstanceQuery caseInstanceRootScopeIds(Set<String> rootScopeIds);
84+
8085
/**
8186
* Only select historic case instances with the given case instance parent scope id.
8287
*/
8388
HistoricCaseInstanceQuery caseInstanceParentScopeId(String parentScopeId);
84-
89+
90+
/**
91+
* Only select historic case instances with one of the given parent scope ids.
92+
*/
93+
HistoricCaseInstanceQuery caseInstanceParentScopeIds(Set<String> parentScopeIds);
94+
8595
/**
8696
* Only select historic case instances with the given business status.
8797
*/

modules/flowable-cmmn-api/src/main/java/org/flowable/cmmn/api/runtime/CaseInstanceQuery.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public interface CaseInstanceQuery extends Query<CaseInstanceQuery, CaseInstance
4545
CaseInstanceQuery caseInstanceNameLike(String caseInstanceNameLike);
4646
CaseInstanceQuery caseInstanceNameLikeIgnoreCase(String caseInstanceNameLikeIgnoreCase);
4747
CaseInstanceQuery caseInstanceRootScopeId(String rootScopeId);
48+
CaseInstanceQuery caseInstanceRootScopeIds(Set<String> rootScopeIds);
4849
CaseInstanceQuery caseInstanceParentScopeId(String parentScopeId);
50+
CaseInstanceQuery caseInstanceParentScopeIds(Set<String> parentScopeIds);
4951
CaseInstanceQuery caseInstanceBusinessKey(String caseInstanceBusinessKey);
5052
CaseInstanceQuery caseInstanceBusinessKeyLike(String caseInstanceBusinessKeyLike);
5153
CaseInstanceQuery caseInstanceBusinessKeyLikeIgnoreCase(String caseInstanceBusinessKeyLikeIgnoreCase);

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delete/BatchDeleteCaseConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,15 @@ protected static void populateQuery(JsonNode queryNode, HistoricCaseInstanceQuer
290290
case "caseInstanceRootScopeId":
291291
query.caseInstanceRootScopeId(value.stringValue());
292292
break;
293+
case "caseInstanceRootScopeIds":
294+
query.caseInstanceRootScopeIds(asStringSet(value));
295+
break;
293296
case "caseInstanceParentScopeId":
294297
query.caseInstanceParentScopeId(value.stringValue());
295298
break;
299+
case "caseInstanceParentScopeIds":
300+
query.caseInstanceParentScopeIds(asStringSet(value));
301+
break;
296302
default:
297303
throw new FlowableIllegalArgumentException("Query property " + property + " is not supported");
298304
}

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/delete/DeleteHistoricCaseInstancesUsingBatchesCmd.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ protected void populateQueryNode(ObjectNode queryNode, HistoricCaseInstanceQuery
199199
putIfNotNull(queryNode, "caseInstanceNameLike", query.getCaseInstanceNameLike());
200200
putIfNotNull(queryNode, "caseInstanceNameLikeIgnoreCase", query.getCaseInstanceNameLikeIgnoreCase());
201201
putIfNotNull(queryNode, "caseInstanceRootScopeId", query.getRootScopeId());
202+
putIfNotNullOrEmpty(queryNode, "caseInstanceRootScopeIds", query.getRootScopeIds());
202203
putIfNotNull(queryNode, "caseInstanceParentScopeId", query.getParentScopeId());
204+
putIfNotNullOrEmpty(queryNode, "caseInstanceParentScopeIds", query.getParentScopeIds());
203205
putIfNotNull(queryNode, "businessKey", query.getBusinessKey());
204206
putIfNotNull(queryNode, "businessKeyLike", query.getBusinessKeyLike());
205207
putIfNotNull(queryNode, "businessKeyLikeIgnoreCase", query.getBusinessKeyLikeIgnoreCase());

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/HistoricCaseInstanceQueryImpl.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ public class HistoricCaseInstanceQueryImpl extends AbstractVariableQueryImpl<His
7474
protected String caseInstanceNameLike;
7575
protected String caseInstanceNameLikeIgnoreCase;
7676
protected String rootScopeId;
77+
protected Set<String> rootScopeIds;
78+
private List<List<String>> safeRootScopeIds;
7779
protected String parentScopeId;
80+
protected Set<String> parentScopeIds;
81+
private List<List<String>> safeParentScopeIds;
7882
protected String businessKey;
7983
protected String businessKeyLike;
8084
protected String businessKeyLikeIgnoreCase;
@@ -411,6 +415,19 @@ public HistoricCaseInstanceQueryImpl caseInstanceRootScopeId(String rootScopeId)
411415
return this;
412416
}
413417

418+
@Override
419+
public HistoricCaseInstanceQuery caseInstanceRootScopeIds(Set<String> rootScopeIds) {
420+
if (rootScopeIds == null || rootScopeIds.isEmpty()) {
421+
throw new FlowableIllegalArgumentException("rootScopeIds is null or empty");
422+
}
423+
if (inOrStatement) {
424+
this.currentOrQueryObject.rootScopeIds = rootScopeIds;
425+
} else {
426+
this.rootScopeIds = rootScopeIds;
427+
}
428+
return this;
429+
}
430+
414431
@Override
415432
public HistoricCaseInstanceQueryImpl caseInstanceParentScopeId(String parentScopeId) {
416433
if (parentScopeId == null) {
@@ -424,6 +441,18 @@ public HistoricCaseInstanceQueryImpl caseInstanceParentScopeId(String parentScop
424441
return this;
425442
}
426443

444+
@Override
445+
public HistoricCaseInstanceQuery caseInstanceParentScopeIds(Set<String> parentScopeIds) {
446+
if (parentScopeIds == null || parentScopeIds.isEmpty()) {
447+
throw new FlowableIllegalArgumentException("parentScopeIds is null or empty");
448+
}
449+
if (inOrStatement) {
450+
this.currentOrQueryObject.parentScopeIds = parentScopeIds;
451+
} else {
452+
this.parentScopeIds = parentScopeIds;
453+
}
454+
return this;
455+
}
427456

428457
@Override
429458
public HistoricCaseInstanceQueryImpl caseInstanceBusinessStatus(String businessStatus) {
@@ -1558,8 +1587,32 @@ public String getRootScopeId() {
15581587
return rootScopeId;
15591588
}
15601589

1590+
public Set<String> getRootScopeIds() {
1591+
return rootScopeIds;
1592+
}
1593+
15611594
public String getParentScopeId() {
15621595
return parentScopeId;
15631596
}
15641597

1598+
public Set<String> getParentScopeIds() {
1599+
return parentScopeIds;
1600+
}
1601+
1602+
public List<List<String>> getSafeRootScopeIds() {
1603+
return safeRootScopeIds;
1604+
}
1605+
1606+
public void setSafeRootScopeIds(List<List<String>> safeRootScopeIds) {
1607+
this.safeRootScopeIds = safeRootScopeIds;
1608+
}
1609+
1610+
public List<List<String>> getSafeParentScopeIds() {
1611+
return safeParentScopeIds;
1612+
}
1613+
1614+
public void setSafeParentScopeIds(List<List<String>> safeParentScopeIds) {
1615+
this.safeParentScopeIds = safeParentScopeIds;
1616+
}
1617+
15651618
}

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/persistence/entity/data/impl/MybatisCaseInstanceDataManagerImpl.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,19 @@ protected void setSafeInValueLists(CaseInstanceQueryImpl caseInstanceQuery) {
217217
if (caseInstanceQuery.getCaseInstanceIds() != null) {
218218
caseInstanceQuery.setSafeCaseInstanceIds(createSafeInValuesList(caseInstanceQuery.getCaseInstanceIds()));
219219
}
220-
220+
221221
if (caseInstanceQuery.getInvolvedGroups() != null) {
222222
caseInstanceQuery.setSafeInvolvedGroups(createSafeInValuesList(caseInstanceQuery.getInvolvedGroups()));
223223
}
224-
224+
225+
if (caseInstanceQuery.getRootScopeIds() != null) {
226+
caseInstanceQuery.setSafeRootScopeIds(createSafeInValuesList(caseInstanceQuery.getRootScopeIds()));
227+
}
228+
229+
if (caseInstanceQuery.getParentScopeIds() != null) {
230+
caseInstanceQuery.setSafeParentScopeIds(createSafeInValuesList(caseInstanceQuery.getParentScopeIds()));
231+
}
232+
225233
if (caseInstanceQuery.getOrQueryObjects() != null && !caseInstanceQuery.getOrQueryObjects().isEmpty()) {
226234
for (CaseInstanceQueryImpl orCaseInstanceQuery : caseInstanceQuery.getOrQueryObjects()) {
227235
setSafeInValueLists(orCaseInstanceQuery);

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/persistence/entity/data/impl/MybatisHistoricCaseInstanceDataManagerImpl.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,19 @@ protected void setSafeInValueLists(HistoricCaseInstanceQueryImpl caseInstanceQue
108108
if (caseInstanceQuery.getCaseInstanceIds() != null) {
109109
caseInstanceQuery.setSafeCaseInstanceIds(createSafeInValuesList(caseInstanceQuery.getCaseInstanceIds()));
110110
}
111-
111+
112112
if (caseInstanceQuery.getInvolvedGroups() != null) {
113113
caseInstanceQuery.setSafeInvolvedGroups(createSafeInValuesList(caseInstanceQuery.getInvolvedGroups()));
114114
}
115-
115+
116+
if (caseInstanceQuery.getRootScopeIds() != null) {
117+
caseInstanceQuery.setSafeRootScopeIds(createSafeInValuesList(caseInstanceQuery.getRootScopeIds()));
118+
}
119+
120+
if (caseInstanceQuery.getParentScopeIds() != null) {
121+
caseInstanceQuery.setSafeParentScopeIds(createSafeInValuesList(caseInstanceQuery.getParentScopeIds()));
122+
}
123+
116124
if (caseInstanceQuery.getOrQueryObjects() != null && !caseInstanceQuery.getOrQueryObjects().isEmpty()) {
117125
for (HistoricCaseInstanceQueryImpl orCaseInstanceQuery : caseInstanceQuery.getOrQueryObjects()) {
118126
setSafeInValueLists(orCaseInstanceQuery);

modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/CaseInstanceQueryImpl.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ public class CaseInstanceQueryImpl extends AbstractVariableQueryImpl<CaseInstanc
6262
protected String nameLike;
6363
protected String nameLikeIgnoreCase;
6464
protected String rootScopeId;
65+
protected Set<String> rootScopeIds;
66+
private List<List<String>> safeRootScopeIds;
6567
protected String parentScopeId;
68+
protected Set<String> parentScopeIds;
69+
private List<List<String>> safeParentScopeIds;
6670
protected String businessKey;
6771
protected String businessKeyLike;
6872
protected String businessKeyLikeIgnoreCase;
@@ -375,6 +379,19 @@ public CaseInstanceQuery caseInstanceRootScopeId(String rootScopeId) {
375379
return this;
376380
}
377381

382+
@Override
383+
public CaseInstanceQuery caseInstanceRootScopeIds(Set<String> rootScopeIds) {
384+
if (rootScopeIds == null || rootScopeIds.isEmpty()) {
385+
throw new FlowableIllegalArgumentException("rootScopeIds is null or empty");
386+
}
387+
if (inOrStatement) {
388+
this.currentOrQueryObject.rootScopeIds = rootScopeIds;
389+
} else {
390+
this.rootScopeIds = rootScopeIds;
391+
}
392+
return this;
393+
}
394+
378395
@Override
379396
public CaseInstanceQuery caseInstanceParentScopeId(String parentScopeId) {
380397
if (parentScopeId == null) {
@@ -388,6 +405,19 @@ public CaseInstanceQuery caseInstanceParentScopeId(String parentScopeId) {
388405
return this;
389406
}
390407

408+
@Override
409+
public CaseInstanceQuery caseInstanceParentScopeIds(Set<String> parentScopeIds) {
410+
if (parentScopeIds == null || parentScopeIds.isEmpty()) {
411+
throw new FlowableIllegalArgumentException("parentScopeIds is null or empty");
412+
}
413+
if (inOrStatement) {
414+
this.currentOrQueryObject.parentScopeIds = parentScopeIds;
415+
} else {
416+
this.parentScopeIds = parentScopeIds;
417+
}
418+
return this;
419+
}
420+
391421
@Override
392422
public CaseInstanceQueryImpl caseInstanceBusinessKey(String businessKey) {
393423
if (businessKey == null) {
@@ -1249,10 +1279,18 @@ public String getRootScopeId() {
12491279
return rootScopeId;
12501280
}
12511281

1282+
public Set<String> getRootScopeIds() {
1283+
return rootScopeIds;
1284+
}
1285+
12521286
public String getParentScopeId() {
12531287
return parentScopeId;
12541288
}
12551289

1290+
public Set<String> getParentScopeIds() {
1291+
return parentScopeIds;
1292+
}
1293+
12561294
public String getParentCaseInstanceId() {
12571295
return parentCaseInstanceId;
12581296
}
@@ -1350,4 +1388,20 @@ public List<List<String>> getSafeInvolvedGroups() {
13501388
public void setSafeInvolvedGroups(List<List<String>> safeInvolvedGroups) {
13511389
this.safeInvolvedGroups = safeInvolvedGroups;
13521390
}
1391+
1392+
public List<List<String>> getSafeRootScopeIds() {
1393+
return safeRootScopeIds;
1394+
}
1395+
1396+
public void setSafeRootScopeIds(List<List<String>> safeRootScopeIds) {
1397+
this.safeRootScopeIds = safeRootScopeIds;
1398+
}
1399+
1400+
public List<List<String>> getSafeParentScopeIds() {
1401+
return safeParentScopeIds;
1402+
}
1403+
1404+
public void setSafeParentScopeIds(List<List<String>> safeParentScopeIds) {
1405+
this.safeParentScopeIds = safeParentScopeIds;
1406+
}
13531407
}

modules/flowable-cmmn-engine/src/main/resources/org/flowable/cmmn/db/mapping/entity/CaseInstance.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,45 @@
462462
and LINK.HIERARCHY_TYPE_ = 'parent'
463463
)
464464
</if>
465+
<if test="parentScopeIds != null">
466+
and EXISTS(select 1 from ${prefix}ACT_RU_ENTITYLINK LINK where
467+
(
468+
<foreach item="parentScopeIdListItem" index="groupIndex" collection="safeParentScopeIds">
469+
<if test="groupIndex &gt; 0">
470+
or
471+
</if>
472+
LINK.SCOPE_ID_ in
473+
<foreach item="parentScopeIdItem" index="index" collection="parentScopeIdListItem" open="(" separator="," close=")">
474+
#{parentScopeIdItem, jdbcType=NVARCHAR}
475+
</foreach>
476+
</foreach>
477+
)
478+
and LINK.REF_SCOPE_ID_ = RES.ID_
479+
and LINK.HIERARCHY_TYPE_ = 'parent'
480+
)
481+
</if>
465482
<if test="rootScopeId != null">
466483
and exists(select 1 from ${prefix}ACT_RU_ENTITYLINK LINK where
467484
LINK.REF_SCOPE_ID_ = RES.ID_
468485
and LINK.ROOT_SCOPE_ID_ = #{rootScopeId, jdbcType=NVARCHAR}
469486
)
470487
</if>
488+
<if test="rootScopeIds != null">
489+
and exists(select 1 from ${prefix}ACT_RU_ENTITYLINK LINK where
490+
LINK.REF_SCOPE_ID_ = RES.ID_
491+
and (
492+
<foreach item="rootScopeIdListItem" index="groupIndex" collection="safeRootScopeIds">
493+
<if test="groupIndex &gt; 0">
494+
or
495+
</if>
496+
LINK.ROOT_SCOPE_ID_ in
497+
<foreach item="rootScopeIdItem" index="index" collection="rootScopeIdListItem" open="(" separator="," close=")">
498+
#{rootScopeIdItem, jdbcType=NVARCHAR}
499+
</foreach>
500+
</foreach>
501+
)
502+
)
503+
</if>
471504
<if test="businessKey != null">
472505
and RES.BUSINESS_KEY_ = #{businessKey, jdbcType=NVARCHAR}
473506
</if>
@@ -882,12 +915,45 @@
882915
and LINK.HIERARCHY_TYPE_ = 'parent'
883916
)
884917
</if>
918+
<if test="orQueryObject.parentScopeIds != null">
919+
or EXISTS(select 1 from ${prefix}ACT_RU_ENTITYLINK LINK where
920+
(
921+
<foreach item="parentScopeIdListItem" index="groupIndex" collection="orQueryObject.safeParentScopeIds">
922+
<if test="groupIndex &gt; 0">
923+
or
924+
</if>
925+
LINK.SCOPE_ID_ in
926+
<foreach item="parentScopeIdItem" index="index" collection="parentScopeIdListItem" open="(" separator="," close=")">
927+
#{parentScopeIdItem, jdbcType=NVARCHAR}
928+
</foreach>
929+
</foreach>
930+
)
931+
and LINK.REF_SCOPE_ID_ = RES.ID_
932+
and LINK.HIERARCHY_TYPE_ = 'parent'
933+
)
934+
</if>
885935
<if test="orQueryObject.rootScopeId != null">
886936
or exists(select 1 from ${prefix}ACT_RU_ENTITYLINK LINK where
887937
LINK.REF_SCOPE_ID_ = RES.ID_
888938
and LINK.ROOT_SCOPE_ID_ = #{orQueryObject.rootScopeId, jdbcType=NVARCHAR}
889939
)
890940
</if>
941+
<if test="orQueryObject.rootScopeIds != null">
942+
or exists(select 1 from ${prefix}ACT_RU_ENTITYLINK LINK where
943+
LINK.REF_SCOPE_ID_ = RES.ID_
944+
and (
945+
<foreach item="rootScopeIdListItem" index="groupIndex" collection="orQueryObject.safeRootScopeIds">
946+
<if test="groupIndex &gt; 0">
947+
or
948+
</if>
949+
LINK.ROOT_SCOPE_ID_ in
950+
<foreach item="rootScopeIdItem" index="index" collection="rootScopeIdListItem" open="(" separator="," close=")">
951+
#{rootScopeIdItem, jdbcType=NVARCHAR}
952+
</foreach>
953+
</foreach>
954+
)
955+
)
956+
</if>
891957
<foreach collection="orQueryObject.queryVariableValues" index="index" item="queryVariableValue">
892958
or
893959
<trim prefix="(" prefixOverrides="AND" suffix=")">

0 commit comments

Comments
 (0)