Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ CREATE INDEX ACT_IDX_APP_DEF_DPLY ON ACT_APP_APPDEF(DEPLOYMENT_ID_);
CREATE UNIQUE INDEX ACT_IDX_APP_DEF_UNIQ ON ACT_APP_APPDEF(KEY_, VERSION_, TENANT_ID_);

insert into ACT_GE_PROPERTY
values ('app.schema.version', '8.1.0.2', 1);
values ('app.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ CREATE INDEX ACT_IDX_APP_DEF_DPLY ON ACT_APP_APPDEF(DEPLOYMENT_ID_);
CREATE UNIQUE INDEX ACT_IDX_APP_DEF_UNIQ ON ACT_APP_APPDEF(KEY_, VERSION_, TENANT_ID_);

insert into ACT_GE_PROPERTY
values ('app.schema.version', '8.1.0.2', 1);
values ('app.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ CREATE NONCLUSTERED INDEX ACT_IDX_APP_DEF_DPLY ON ACT_APP_APPDEF(DEPLOYMENT_ID_)
CREATE UNIQUE NONCLUSTERED INDEX ACT_IDX_APP_DEF_UNIQ ON ACT_APP_APPDEF(KEY_, VERSION_, TENANT_ID_);

insert into ACT_GE_PROPERTY
values ('app.schema.version', '8.1.0.2', 1);
values ('app.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ ALTER TABLE ACT_APP_DEPLOYMENT MODIFY DEPLOY_TIME_ datetime(3);
CREATE UNIQUE INDEX ACT_IDX_APP_DEF_UNIQ ON ACT_APP_APPDEF(KEY_, VERSION_, TENANT_ID_);

insert into ACT_GE_PROPERTY
values ('app.schema.version', '8.1.0.2', 1);
values ('app.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ CREATE INDEX ACT_IDX_APP_DEF_DPLY ON ACT_APP_APPDEF(DEPLOYMENT_ID_);
CREATE UNIQUE INDEX ACT_IDX_APP_DEF_UNIQ ON ACT_APP_APPDEF(KEY_, VERSION_, TENANT_ID_);

insert into ACT_GE_PROPERTY
values ('app.schema.version', '8.1.0.2', 1);
values ('app.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ CREATE INDEX ACT_IDX_APP_DEF_DPLY ON ACT_APP_APPDEF(DEPLOYMENT_ID_);
CREATE UNIQUE INDEX ACT_IDX_APP_DEF_UNIQ ON ACT_APP_APPDEF(KEY_, VERSION_, TENANT_ID_);

insert into ACT_GE_PROPERTY
values ('app.schema.version', '8.1.0.2', 1);
values ('app.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update ACT_GE_PROPERTY set VALUE_ = '8.1.0.3' where NAME_ = 'app.schema.version';
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class SqlUpgradeValidationTest {
"7.1.0.2",
"7.2.0.1",
"7.2.0.2",
"8.1.0.2"
"8.1.0.2",
"8.1.0.3"
);

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ CREATE TABLE ACT_CMMN_HI_PLAN_ITEM_INST
CREATE INDEX ACT_IDX_HI_PLAN_ITEM_INST_CASE ON ACT_CMMN_HI_PLAN_ITEM_INST (CASE_INST_ID_);

insert into ACT_GE_PROPERTY
values ('cmmn.schema.version', '8.1.0.2', 1);
values ('cmmn.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ CREATE TABLE ACT_CMMN_HI_PLAN_ITEM_INST
CREATE INDEX ACT_IDX_HI_PLAN_ITEM_INST_CASE ON ACT_CMMN_HI_PLAN_ITEM_INST (CASE_INST_ID_);

insert into ACT_GE_PROPERTY
values ('cmmn.schema.version', '8.1.0.2', 1);
values ('cmmn.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ CREATE TABLE ACT_CMMN_HI_PLAN_ITEM_INST
CREATE INDEX ACT_IDX_HI_PLAN_ITEM_INST_CASE ON ACT_CMMN_HI_PLAN_ITEM_INST (CASE_INST_ID_);

insert into ACT_GE_PROPERTY
values ('cmmn.schema.version', '8.1.0.2', 1);
values ('cmmn.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ CREATE TABLE ACT_CMMN_HI_PLAN_ITEM_INST
CREATE NONCLUSTERED INDEX ACT_IDX_HI_PLAN_ITEM_INST_CASE ON ACT_CMMN_HI_PLAN_ITEM_INST(CASE_INST_ID_);

insert into ACT_GE_PROPERTY
values ('cmmn.schema.version', '8.1.0.2', 1);
values ('cmmn.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ CREATE TABLE ACT_CMMN_HI_PLAN_ITEM_INST
CREATE INDEX ACT_IDX_HI_PLAN_ITEM_INST_CASE ON ACT_CMMN_HI_PLAN_ITEM_INST (CASE_INST_ID_);

insert into ACT_GE_PROPERTY
values ('cmmn.schema.version', '8.1.0.2', 1);
values ('cmmn.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ CREATE TABLE ACT_CMMN_HI_PLAN_ITEM_INST
CREATE INDEX ACT_IDX_HI_PLAN_ITEM_INST_CASE ON ACT_CMMN_HI_PLAN_ITEM_INST (CASE_INST_ID_);

insert into ACT_GE_PROPERTY
values ('cmmn.schema.version', '8.1.0.2', 1);
values ('cmmn.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ CREATE TABLE ACT_CMMN_HI_PLAN_ITEM_INST
CREATE INDEX ACT_IDX_HI_PLAN_ITEM_INST_CASE ON ACT_CMMN_HI_PLAN_ITEM_INST (CASE_INST_ID_);

insert into ACT_GE_PROPERTY
values ('cmmn.schema.version', '8.1.0.2', 1);
values ('cmmn.schema.version', '8.1.0.3', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -276,29 +276,27 @@
and (RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null)
</if>
<if test="includeAuthorization">
AND
<!-- The user and groups are combined in a single EXISTS, so databases can turn it into a semi-join -->
AND exists (select ID_ from ${prefix}ACT_RU_IDENTITYLINK IDN where IDN.SCOPE_DEFINITION_ID_ = RES.ID_ and IDN.SCOPE_TYPE_ = 'cmmn' and
<trim prefix="(" prefixOverrides="OR" suffix=")">
<if test="authorizationUserId != null">
exists (select ID_ from ${prefix}ACT_RU_IDENTITYLINK IDN where IDN.SCOPE_DEFINITION_ID_ = RES.ID_ and IDN.SCOPE_TYPE_ = 'cmmn' and IDN.USER_ID_ = #{authorizationUserId, jdbcType=NVARCHAR})
</if>
<if test="authorizationGroups != null &amp;&amp; !authorizationGroups.empty">
OR exists (select ID_ from ${prefix}ACT_RU_IDENTITYLINK IDN where IDN.SCOPE_DEFINITION_ID_ = RES.ID_ and IDN.SCOPE_TYPE_ = 'cmmn' and
(
<foreach item="authorizationGroupListItem" index="groupIndex" collection="safeAuthorizationGroups">
<if test="groupIndex &gt; 0">
or
</if>
IDN.GROUP_ID_ IN
<foreach item="authorizationGroup" index="index" collection="authorizationGroupListItem"
open="(" separator="," close=")">
#{authorizationGroup, jdbcType=NVARCHAR}
</foreach>
</foreach>
)
)
<if test="authorizationUserId != null">
IDN.USER_ID_ = #{authorizationUserId, jdbcType=NVARCHAR}
</if>
<if test="safeAuthorizationGroups != null &amp;&amp; !safeAuthorizationGroups.empty">
OR
<foreach item="authorizationGroupListItem" index="groupIndex" collection="safeAuthorizationGroups">
<if test="groupIndex &gt; 0">
or
</if>
IDN.GROUP_ID_ IN
<foreach item="authorizationGroup" index="index" collection="authorizationGroupListItem"
open="(" separator="," close=")">
#{authorizationGroup, jdbcType=NVARCHAR}
</foreach>
</foreach>
</if>

</trim>
)
</if>
</where>
</sql>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,35 +909,32 @@
</foreach>
and P.STATE_ = 'active')
</if>
<if test="orQueryObject.involvedUser != null">
or EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.SCOPE_ID_ = RES.ID_ and I.SCOPE_TYPE_ = 'cmmn' and I.USER_ID_ =
#{orQueryObject.involvedUser, jdbcType=NVARCHAR})
</if>
<if test="orQueryObject.involvedUserIdentityLink != null">
or EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.SCOPE_ID_ = RES.ID_ and I.SCOPE_TYPE_ = 'cmmn' and
I.USER_ID_ = #{orQueryObject.involvedUserIdentityLink.userId, jdbcType=NVARCHAR} and I.TYPE_ = #{orQueryObject.involvedUserIdentityLink.type, jdbcType=NVARCHAR})
</if>
<if test="orQueryObject.involvedGroups != null">
<!-- The involvement checks are combined in a single EXISTS, so databases can turn it into a semi-join when the OR has no other criteria -->
<if test="orQueryObject.involvedUser != null || orQueryObject.involvedUserIdentityLink != null || orQueryObject.involvedGroups != null || orQueryObject.involvedGroupIdentityLink != null">
or EXISTS(
select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.SCOPE_ID_ = RES.ID_ and I.SCOPE_TYPE_ = 'cmmn' and
(
<foreach item="involvedGroupListItem" index="groupIndex" collection="orQueryObject.safeInvolvedGroups">
<if test="groupIndex &gt; 0">
or
<trim prefix="(" prefixOverrides="OR" suffix=")">
<if test="orQueryObject.involvedUser != null">
or I.USER_ID_ = #{orQueryObject.involvedUser, jdbcType=NVARCHAR}
</if>
I.GROUP_ID_ IN
<foreach item="involvedGroup" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{involvedGroup, jdbcType=NVARCHAR}
</foreach>
</foreach>
)
<if test="orQueryObject.involvedUserIdentityLink != null">
or (I.USER_ID_ = #{orQueryObject.involvedUserIdentityLink.userId, jdbcType=NVARCHAR} and I.TYPE_ = #{orQueryObject.involvedUserIdentityLink.type, jdbcType=NVARCHAR})
</if>
<if test="orQueryObject.involvedGroups != null">
<foreach item="involvedGroupListItem" index="groupIndex" collection="orQueryObject.safeInvolvedGroups">
or I.GROUP_ID_ IN
<foreach item="involvedGroup" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{involvedGroup, jdbcType=NVARCHAR}
</foreach>
</foreach>
</if>
<if test="orQueryObject.involvedGroupIdentityLink != null">
or (I.GROUP_ID_ = #{orQueryObject.involvedGroupIdentityLink.groupId, jdbcType=NVARCHAR} and I.TYPE_ = #{orQueryObject.involvedGroupIdentityLink.type, jdbcType=NVARCHAR})
</if>
</trim>
)
</if>
<if test="orQueryObject.involvedGroupIdentityLink != null">
or EXISTS(select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.SCOPE_ID_ = RES.ID_ and I.SCOPE_TYPE_ = 'cmmn' and
I.GROUP_ID_ = #{orQueryObject.involvedGroupIdentityLink.groupId, jdbcType=NVARCHAR} and I.TYPE_ = #{orQueryObject.involvedGroupIdentityLink.type, jdbcType=NVARCHAR})
</if>
<if test="orQueryObject.parentScopeId != null">
or EXISTS(select 1 from ${prefix}ACT_RU_ENTITYLINK LINK where
LINK.SCOPE_ID_ = #{orQueryObject.parentScopeId, jdbcType=NVARCHAR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1056,35 +1056,32 @@
</foreach>
and P.STATE_ = 'active')
</if>
<if test="orQueryObject.involvedUser != null">
or EXISTS(select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.SCOPE_ID_ = ${queryTablePrefix}ID_ and I.SCOPE_TYPE_ = 'cmmn' and I.USER_ID_ =
#{orQueryObject.involvedUser, jdbcType=NVARCHAR})
</if>
<if test="orQueryObject.involvedUserIdentityLink != null">
or EXISTS(select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.SCOPE_ID_ = ${queryTablePrefix}ID_ and I.SCOPE_TYPE_ = 'cmmn' and
I.USER_ID_ = #{orQueryObject.involvedUserIdentityLink.userId, jdbcType=NVARCHAR} and I.TYPE_ = #{orQueryObject.involvedUserIdentityLink.type, jdbcType=NVARCHAR})
</if>
<if test="orQueryObject.involvedGroups != null">
<!-- The involvement checks are combined in a single EXISTS, so databases can turn it into a semi-join when the OR has no other criteria -->
<if test="orQueryObject.involvedUser != null || orQueryObject.involvedUserIdentityLink != null || orQueryObject.involvedGroups != null || orQueryObject.involvedGroupIdentityLink != null">
or EXISTS(
select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.SCOPE_ID_ = ${queryTablePrefix}ID_ and I.SCOPE_TYPE_ = 'cmmn' and
(
<foreach item="involvedGroupListItem" index="groupIndex" collection="orQueryObject.safeInvolvedGroups">
<if test="groupIndex &gt; 0">
or
select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.SCOPE_ID_ = ${queryTablePrefix}ID_ and I.SCOPE_TYPE_ = 'cmmn' and
<trim prefix="(" prefixOverrides="OR" suffix=")">
<if test="orQueryObject.involvedUser != null">
or I.USER_ID_ = #{orQueryObject.involvedUser, jdbcType=NVARCHAR}
</if>
I.GROUP_ID_ IN
<foreach item="involvedGroup" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{involvedGroup, jdbcType=NVARCHAR}
</foreach>
</foreach>
)
<if test="orQueryObject.involvedUserIdentityLink != null">
or (I.USER_ID_ = #{orQueryObject.involvedUserIdentityLink.userId, jdbcType=NVARCHAR} and I.TYPE_ = #{orQueryObject.involvedUserIdentityLink.type, jdbcType=NVARCHAR})
</if>
<if test="orQueryObject.involvedGroups != null">
<foreach item="involvedGroupListItem" index="groupIndex" collection="orQueryObject.safeInvolvedGroups">
or I.GROUP_ID_ IN
<foreach item="involvedGroup" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{involvedGroup, jdbcType=NVARCHAR}
</foreach>
</foreach>
</if>
<if test="orQueryObject.involvedGroupIdentityLink != null">
or (I.GROUP_ID_ = #{orQueryObject.involvedGroupIdentityLink.groupId, jdbcType=NVARCHAR} and I.TYPE_ = #{orQueryObject.involvedGroupIdentityLink.type, jdbcType=NVARCHAR})
</if>
</trim>
)
</if>
<if test="orQueryObject.involvedGroupIdentityLink != null">
or EXISTS(select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.SCOPE_ID_ = ${queryTablePrefix}ID_ and I.SCOPE_TYPE_ = 'cmmn' and
I.GROUP_ID_ = #{orQueryObject.involvedGroupIdentityLink.groupId, jdbcType=NVARCHAR} and I.TYPE_ = #{orQueryObject.involvedGroupIdentityLink.type, jdbcType=NVARCHAR})
</if>
<if test="orQueryObject.parentScopeId != null">
or EXISTS(select 1 from ${prefix}ACT_HI_ENTITYLINK LINK where
LINK.SCOPE_ID_ = #{orQueryObject.parentScopeId, jdbcType=NVARCHAR}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update ACT_GE_PROPERTY set VALUE_ = '8.1.0.3' where NAME_ = 'cmmn.schema.version';
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,61 @@ public void getCaseInstanceByInvolvedGroupIdentityLink() {
}
}

@Test
public void getCaseInstanceByOrInvolvedUsersAndGroupsWithIdentityLinkTypes() {
CaseInstance userTypeInstance = startOneTaskCase();
cmmnRuntimeService.addUserIdentityLink(userTypeInstance.getId(), "kermit", "specialLink");
CaseInstance userOtherTypeInstance = startOneTaskCase();
cmmnRuntimeService.addUserIdentityLink(userOtherTypeInstance.getId(), "kermit", "otherLink");
CaseInstance groupTypeInstance = startOneTaskCase();
cmmnRuntimeService.addGroupIdentityLink(groupTypeInstance.getId(), "sales", "specialLink");
CaseInstance groupOtherTypeInstance = startOneTaskCase();
cmmnRuntimeService.addGroupIdentityLink(groupOtherTypeInstance.getId(), "sales", "otherLink");
CaseInstance groupsInstance = startOneTaskCase();
cmmnRuntimeService.addGroupIdentityLink(groupsInstance.getId(), "testGroup", "otherLink");

if (CmmnHistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, cmmnEngineConfiguration)) {
assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery()
.or().involvedUser("kermit", "specialLink").involvedGroup("sales", "specialLink").endOr()
.list())
.extracting(HistoricCaseInstance::getId)
.containsExactlyInAnyOrder(userTypeInstance.getId(), groupTypeInstance.getId());

assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery()
.or().involvedUser("kermit", "specialLink").involvedGroups(Set.of("testGroup")).endOr()
.list())
.extracting(HistoricCaseInstance::getId)
.containsExactlyInAnyOrder(userTypeInstance.getId(), groupsInstance.getId());

assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery()
.or().involvedUser("kermit").involvedGroup("sales", "specialLink").involvedGroups(Set.of("testGroup")).endOr()
.list())
.extracting(HistoricCaseInstance::getId)
.containsExactlyInAnyOrder(userTypeInstance.getId(), userOtherTypeInstance.getId(), groupTypeInstance.getId(), groupsInstance.getId());

assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery()
.or()
.involvedUser("kermit", "specialLink")
.involvedGroup("sales", "specialLink")
.involvedGroups(Set.of("testGroup"))
.caseInstanceId(groupOtherTypeInstance.getId())
.endOr()
.count())
.isEqualTo(4);

assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery()
.or().involvedUser("kermit", "wrongType").involvedGroup("sales", "wrongType").endOr()
.count())
.isZero();
}
}

protected CaseInstance startOneTaskCase() {
return cmmnRuntimeService.createCaseInstanceBuilder()
.caseDefinitionKey("oneTaskCase")
.start();
}

@Test
public void getCaseInstanceByInvolvedGroupOrUser() {
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder()
Expand Down
Loading
Loading