|
41 | 41 | import org.flowable.common.engine.impl.persistence.cache.EntityCache; |
42 | 42 | import org.flowable.variable.service.impl.AbstractVariableQueryImpl; |
43 | 43 | import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntity; |
| 44 | +import org.flowable.variable.service.impl.persistence.entity.VariableInitializingList; |
44 | 45 |
|
45 | 46 | /** |
46 | 47 | * @author Joram Barrez |
@@ -114,6 +115,7 @@ public class HistoricCaseInstanceQueryImpl extends AbstractVariableQueryImpl<His |
114 | 115 | protected boolean withoutTenantId; |
115 | 116 | protected boolean includeCaseVariables; |
116 | 117 | protected Collection<String> variableNamesToInclude; |
| 118 | + protected boolean excludeVariableInitialization; |
117 | 119 | protected String activePlanItemDefinitionId; |
118 | 120 | protected Set<String> activePlanItemDefinitionIds; |
119 | 121 | protected String involvedUser; |
@@ -940,11 +942,14 @@ public List<HistoricCaseInstance> executeList(CommandContext commandContext) { |
940 | 942 | results = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager().findIdsByCriteria(this); |
941 | 943 |
|
942 | 944 | } else if (includeCaseVariables) { |
943 | | - results = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager().findWithVariablesByQueryCriteria(this); |
| 945 | + results = VariableInitializingList.executeQueryIncludingVariables(commandContext, excludeVariableInitialization, () -> { |
| 946 | + List<HistoricCaseInstance> caseInstances = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager().findWithVariablesByQueryCriteria(this); |
944 | 947 |
|
945 | | - if (caseInstanceId != null) { |
946 | | - addCachedVariableForQueryById(commandContext, results); |
947 | | - } |
| 948 | + if (caseInstanceId != null) { |
| 949 | + addCachedVariableForQueryById(commandContext, caseInstances); |
| 950 | + } |
| 951 | + return caseInstances; |
| 952 | + }); |
948 | 953 |
|
949 | 954 | } else { |
950 | 955 | results = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager().findByCriteria(this); |
@@ -1050,6 +1055,20 @@ public HistoricCaseInstanceQuery includeCaseVariables(Collection<String> variabl |
1050 | 1055 | return this; |
1051 | 1056 | } |
1052 | 1057 |
|
| 1058 | + @Override |
| 1059 | + public HistoricCaseInstanceQuery includeCaseVariables(boolean excludeVariableInitialization) { |
| 1060 | + includeCaseVariables(); |
| 1061 | + this.excludeVariableInitialization = excludeVariableInitialization; |
| 1062 | + return this; |
| 1063 | + } |
| 1064 | + |
| 1065 | + @Override |
| 1066 | + public HistoricCaseInstanceQuery includeCaseVariables(Collection<String> variableNames, boolean excludeVariableInitialization) { |
| 1067 | + includeCaseVariables(variableNames); |
| 1068 | + this.excludeVariableInitialization = excludeVariableInitialization; |
| 1069 | + return this; |
| 1070 | + } |
| 1071 | + |
1053 | 1072 | @Override |
1054 | 1073 | public HistoricCaseInstanceQuery activePlanItemDefinitionId(String planItemDefinitionId) { |
1055 | 1074 | if (planItemDefinitionId == null) { |
@@ -1555,6 +1574,10 @@ public Collection<String> getVariableNamesToInclude() { |
1555 | 1574 | return variableNamesToInclude; |
1556 | 1575 | } |
1557 | 1576 |
|
| 1577 | + public boolean isExcludeVariableInitialization() { |
| 1578 | + return excludeVariableInitialization; |
| 1579 | + } |
| 1580 | + |
1558 | 1581 | public List<HistoricCaseInstanceQueryImpl> getOrQueryObjects() { |
1559 | 1582 | return orQueryObjects; |
1560 | 1583 | } |
|
0 commit comments