Skip to content

Commit

Permalink
Added support for more than 1000 group items for Oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
tijsrademakers committed Jun 8, 2021
1 parent 70447d2 commit c2493db
Show file tree
Hide file tree
Showing 41 changed files with 998 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class HistoricCaseInstanceQueryImpl extends AbstractVariableQueryImpl<His
protected String involvedUser;
protected IdentityLinkQueryObject involvedUserIdentityLink;
protected Set<String> involvedGroups;
private List<List<String>> safeInvolvedGroups;
protected IdentityLinkQueryObject involvedGroupIdentityLink;
protected List<HistoricCaseInstanceQueryImpl> orQueryObjects = new ArrayList<>();
protected HistoricCaseInstanceQueryImpl currentOrQueryObject;
Expand Down Expand Up @@ -1025,4 +1026,11 @@ public boolean isNeedsCaseDefinitionOuterJoin() {
return hasOrderByForColumn(HistoricCaseInstanceQueryProperty.CASE_DEFINITION_KEY.getName());
}

public List<List<String>> getSafeInvolvedGroups() {
return safeInvolvedGroups;
}

public void setSafeInvolvedGroups(List<List<String>> safeInvolvedGroups) {
this.safeInvolvedGroups = safeInvolvedGroups;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class HistoricPlanItemInstanceQueryImpl extends AbstractQuery<HistoricPla
protected String extraValue;
protected String involvedUser;
protected Collection<String> involvedGroups;
private List<List<String>> safeInvolvedGroups;
protected boolean onlyStages;
protected String tenantId;
protected String tenantIdLike;
Expand Down Expand Up @@ -652,4 +653,12 @@ public String getTenantIdLike() {
public boolean isWithoutTenantId() {
return withoutTenantId;
}

public List<List<String>> getSafeInvolvedGroups() {
return safeInvolvedGroups;
}

public void setSafeInvolvedGroups(List<List<String>> safeInvolvedGroups) {
this.safeInvolvedGroups = safeInvolvedGroups;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,19 @@ public void updateCaseDefinitionTenantIdForDeployment(String deploymentId, Strin
@Override
@SuppressWarnings("unchecked")
public List<CaseDefinition> findCaseDefinitionsByQueryCriteria(CaseDefinitionQueryImpl caseDefinitionQuery) {
setSafeInValueLists(caseDefinitionQuery);
return getDbSqlSession().selectList("selectCaseDefinitionsByQueryCriteria", caseDefinitionQuery);
}

@Override
public long findCaseDefinitionCountByQueryCriteria(CaseDefinitionQueryImpl caseDefinitionQuery) {
setSafeInValueLists(caseDefinitionQuery);
return (Long) getDbSqlSession().selectOne("selectCaseDefinitionCountByQueryCriteria", caseDefinitionQuery);
}

protected void setSafeInValueLists(CaseDefinitionQueryImpl caseDefinitionQuery) {
if (caseDefinitionQuery.getAuthorizationGroups() != null) {
caseDefinitionQuery.setSafeAuthorizationGroups(createSafeInValuesList(caseDefinitionQuery.getAuthorizationGroups()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,20 @@ public List<CaseInstanceEntity> findCaseInstancesByCaseDefinitionId(String caseD
public List<CaseInstance> findByCriteria(CaseInstanceQueryImpl query) {
// Not going through cache as the case instance should always be loaded with all related plan item instances
// when not doing a query call
setSafeInValueLists(query);
return getDbSqlSession().selectListNoCacheLoadAndStore("selectCaseInstancesByQueryCriteria", query, getManagedEntityClass());
}

@SuppressWarnings("unchecked")
@Override
public List<CaseInstance> findWithVariablesByCriteria(CaseInstanceQueryImpl query) {
setSafeInValueLists(query);
return getDbSqlSession().selectListNoCacheLoadAndStore("selectCaseInstanceWithVariablesByQueryCriteria", query, getManagedEntityClass());
}

@Override
public long countByCriteria(CaseInstanceQueryImpl query) {
setSafeInValueLists(query);
return (Long) getDbSqlSession().selectOne("selectCaseInstanceCountByQueryCriteria", query);
}

Expand Down Expand Up @@ -210,4 +213,15 @@ public void clearAllLockTimes(String lockOwner) {
getDbSqlSession().update("clearAllCaseInstanceLockTimes", params);
}

protected void setSafeInValueLists(CaseInstanceQueryImpl caseInstanceQuery) {
if (caseInstanceQuery.getInvolvedGroups() != null) {
caseInstanceQuery.setSafeInvolvedGroups(createSafeInValuesList(caseInstanceQuery.getInvolvedGroups()));
}

if (caseInstanceQuery.getOrQueryObjects() != null && !caseInstanceQuery.getOrQueryObjects().isEmpty()) {
for (CaseInstanceQueryImpl orCaseInstanceQuery : caseInstanceQuery.getOrQueryObjects()) {
setSafeInValueLists(orCaseInstanceQuery);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,20 @@ public List<HistoricCaseInstanceEntity> findHistoricCaseInstancesByCaseDefinitio
@Override
@SuppressWarnings("unchecked")
public List<HistoricCaseInstance> findByCriteria(HistoricCaseInstanceQueryImpl query) {
setSafeInValueLists(query);
return getDbSqlSession().selectList("selectHistoricCaseInstancesByQueryCriteria", query, getManagedEntityClass());
}

@Override
public long countByCriteria(HistoricCaseInstanceQueryImpl query) {
setSafeInValueLists(query);
return (Long) getDbSqlSession().selectOne("selectHistoricCaseInstanceCountByQueryCriteria", query);
}

@Override
@SuppressWarnings("unchecked")
public List<HistoricCaseInstance> findWithVariablesByQueryCriteria(HistoricCaseInstanceQueryImpl historicCaseInstanceQuery) {
setSafeInValueLists(historicCaseInstanceQuery);
return getDbSqlSession().selectList("selectHistoricCaseInstancesWithVariablesByQueryCriteria", historicCaseInstanceQuery, getManagedEntityClass());
}

Expand All @@ -82,4 +85,16 @@ public void deleteByCaseDefinitionId(String caseDefinitionId) {
public void deleteHistoricCaseInstances(HistoricCaseInstanceQueryImpl historicCaseInstanceQuery) {
getDbSqlSession().delete("bulkDeleteHistoricCaseInstances", historicCaseInstanceQuery, getManagedEntityClass());
}

protected void setSafeInValueLists(HistoricCaseInstanceQueryImpl caseInstanceQuery) {
if (caseInstanceQuery.getInvolvedGroups() != null) {
caseInstanceQuery.setSafeInvolvedGroups(createSafeInValuesList(caseInstanceQuery.getInvolvedGroups()));
}

if (caseInstanceQuery.getOrQueryObjects() != null && !caseInstanceQuery.getOrQueryObjects().isEmpty()) {
for (HistoricCaseInstanceQueryImpl orCaseInstanceQuery : caseInstanceQuery.getOrQueryObjects()) {
setSafeInValueLists(orCaseInstanceQuery);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public MybatisHistoricPlanItemInstanceDataManager(CmmnEngineConfiguration cmmnEn
@Override
@SuppressWarnings("unchecked")
public List<HistoricPlanItemInstance> findByCriteria(HistoricPlanItemInstanceQueryImpl query) {
setSafeInValueLists(query);
return getDbSqlSession().selectList("selectHistoricPlanItemInstancesByQueryCriteria", query, getManagedEntityClass());
}

Expand All @@ -55,6 +56,7 @@ public List<HistoricPlanItemInstance> findByCaseDefinitionId(String caseDefiniti

@Override
public long countByCriteria(HistoricPlanItemInstanceQueryImpl query) {
setSafeInValueLists(query);
return (Long) getDbSqlSession().selectOne("selectHistoricPlanItemInstancesCountByQueryCriteria", query);
}

Expand Down Expand Up @@ -82,4 +84,10 @@ public HistoricPlanItemInstanceEntity create() {
public HistoricPlanItemInstanceEntity create(PlanItemInstance planItemInstance) {
return new HistoricPlanItemInstanceEntityImpl(planItemInstance);
}

protected void setSafeInValueLists(HistoricPlanItemInstanceQueryImpl planItemInstanceQuery) {
if (planItemInstanceQuery.getInvolvedGroups() != null) {
planItemInstanceQuery.setSafeInvolvedGroups(createSafeInValuesList(planItemInstanceQuery.getInvolvedGroups()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ public List<PlanItemInstanceEntity> findByStageInstanceIdAndPlanItemId(String st

@Override
public long countByCriteria(PlanItemInstanceQueryImpl planItemInstanceQuery) {
setSafeInValueLists(planItemInstanceQuery);
return (Long) getDbSqlSession().selectOne("selectPlanItemInstanceCountByQueryCriteria", planItemInstanceQuery);
}

@Override
@SuppressWarnings("unchecked")
public List<PlanItemInstance> findByCriteria(PlanItemInstanceQueryImpl planItemInstanceQuery) {
setSafeInValueLists(planItemInstanceQuery);
return getDbSqlSession().selectList("selectPlanItemInstancesByQueryCriteria", planItemInstanceQuery, getManagedEntityClass());
}

Expand Down Expand Up @@ -183,4 +185,9 @@ public boolean isRetained(PlanItemInstanceEntity entity, Object param) {

}

protected void setSafeInValueLists(PlanItemInstanceQueryImpl planItemInstanceQuery) {
if (planItemInstanceQuery.getInvolvedGroups() != null) {
planItemInstanceQuery.setSafeInvolvedGroups(createSafeInValuesList(planItemInstanceQuery.getInvolvedGroups()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class CaseDefinitionQueryImpl extends AbstractQuery<CaseDefinitionQuery,
protected String resourceNameLike;
protected String authorizationUserId;
protected Collection<String> authorizationGroups;
private List<List<String>> safeAuthorizationGroups;
protected boolean authorizationGroupsSet;
protected Integer version;
protected Integer versionGt;
Expand Down Expand Up @@ -440,4 +441,11 @@ public boolean isIncludeAuthorization() {
return authorizationUserId != null || (authorizationGroups != null && !authorizationGroups.isEmpty());
}

public List<List<String>> getSafeAuthorizationGroups() {
return safeAuthorizationGroups;
}

public void setSafeAuthorizationGroups(List<List<String>> safeAuthorizationGroups) {
this.safeAuthorizationGroups = safeAuthorizationGroups;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class CaseInstanceQueryImpl extends AbstractVariableQueryImpl<CaseInstanc
protected String involvedUser;
protected IdentityLinkQueryObject involvedUserIdentityLink;
protected Set<String> involvedGroups;
private List<List<String>> safeInvolvedGroups;
protected IdentityLinkQueryObject involvedGroupIdentityLink;

protected List<CaseInstanceQueryImpl> orQueryObjects = new ArrayList<>();
Expand Down Expand Up @@ -874,4 +875,16 @@ public boolean isNeedsCaseDefinitionOuterJoin() {

return hasOrderByForColumn(CaseInstanceQueryProperty.CASE_DEFINITION_KEY.getName());
}

public List<CaseInstanceQueryImpl> getOrQueryObjects() {
return orQueryObjects;
}

public List<List<String>> getSafeInvolvedGroups() {
return safeInvolvedGroups;
}

public void setSafeInvolvedGroups(List<List<String>> safeInvolvedGroups) {
this.safeInvolvedGroups = safeInvolvedGroups;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class PlanItemInstanceQueryImpl extends AbstractVariableQueryImpl<PlanIte
protected String extraValue;
protected String involvedUser;
protected Collection<String> involvedGroups;
private List<List<String>> safeInvolvedGroups;
protected String tenantId;
protected boolean withoutTenantId;

Expand Down Expand Up @@ -825,4 +826,12 @@ public String getTenantId() {
public boolean isWithoutTenantId() {
return withoutTenantId;
}

public List<List<String>> getSafeInvolvedGroups() {
return safeInvolvedGroups;
}

public void setSafeInvolvedGroups(List<List<String>> safeInvolvedGroups) {
this.safeInvolvedGroups = safeInvolvedGroups;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,19 @@
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})
</if>
<if test="authorizationGroups != null &amp;&amp; authorizationGroups.size() &gt; 0">
OR exists (select ID_ from ${prefix}ACT_RU_IDENTITYLINK IDN where IDN.SCOPE_DEFINITION_ID_ = RES.ID_ and IDN.SCOPE_TYPE_ = 'cmmn' and IDN.GROUP_ID_ IN
<foreach item="group" index="index" collection="authorizationGroups"
open="(" separator="," close=")">
#{group}
</foreach>
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="group" index="index" collection="authorizationGroupListItem"
open="(" separator="," close=")">
#{group}
</foreach>
</foreach>
)
)
</if>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,19 @@
</if>
<if test="involvedGroups != null">
and EXISTS(
select ID_ from ${prefix}ACT_RU_IDENTITYLINK I where I.SCOPE_ID_ = RES.ID_ and I.SCOPE_TYPE_ = 'cmmn' and I.GROUP_ID_ in
<foreach item="involvedGroup" index="index" collection="involvedGroups" open="(" separator="," close=")">
#{involvedGroup}
</foreach>
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="safeInvolvedGroups">
<if test="groupIndex &gt; 0">
or
</if>
I.GROUP_ID_ IN
<foreach item="group" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{group}
</foreach>
</foreach>
)
)
</if>
<if test="involvedGroupIdentityLink != null">
Expand Down Expand Up @@ -651,10 +660,19 @@
</if>
<if test="orQueryObject.involvedGroups != 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_ in
<foreach item="involvedGroup" index="index" collection="orQueryObject.involvedGroups" open="(" separator="," close=")">
#{involvedGroup}
</foreach>
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
</if>
I.GROUP_ID_ IN
<foreach item="group" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{group}
</foreach>
</foreach>
)
)
</if>
<if test="orQueryObject.involvedGroupIdentityLink != null">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,19 @@
</if>
<if test="involvedGroups != null">
and EXISTS(
select ID_ from ${prefix}ACT_HI_IDENTITYLINK I where I.SCOPE_ID_ = ${queryTablePrefix}ID_ and I.SCOPE_TYPE_ = 'cmmn' and I.GROUP_ID_ in
<foreach item="involvedGroup" index="index" collection="involvedGroups" open="(" separator="," close=")">
#{involvedGroup}
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="safeInvolvedGroups">
<if test="groupIndex &gt; 0">
or
</if>
I.GROUP_ID_ IN
<foreach item="group" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{group}
</foreach>
</foreach>
)
)
</if>
<if test="involvedGroupIdentityLink != null">
Expand Down Expand Up @@ -755,10 +764,19 @@
</if>
<if test="orQueryObject.involvedGroups != 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_ in
<foreach item="involvedGroup" index="index" collection="orQueryObject.involvedGroups" open="(" separator="," close=")">
#{involvedGroup}
</foreach>
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
</if>
I.GROUP_ID_ IN
<foreach item="group" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{group}
</foreach>
</foreach>
)
)
</if>
<if test="orQueryObject.involvedGroupIdentityLink != null">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,18 @@
or
</if>
<if test="involvedGroups != null &amp;&amp; involvedGroups.size() &gt; 0">
I.GROUP_ID_ IN
<foreach item="involvedGroup" index="index" collection="involvedGroups"
open="(" separator="," close=")">
#{involvedGroup}
(
<foreach item="involvedGroupListItem" index="groupIndex" collection="safeInvolvedGroups">
<if test="groupIndex &gt; 0">
or
</if>
I.GROUP_ID_ IN
<foreach item="group" index="index" collection="involvedGroupListItem"
open="(" separator="," close=")">
#{group}
</foreach>
</foreach>
)
</if>
)
)
Expand Down
Loading

0 comments on commit c2493db

Please sign in to comment.