From 7154a2ec6e4b830ac898cfd9e3687ab6586d72e8 Mon Sep 17 00:00:00 2001 From: Filip Hrisafov Date: Sat, 11 May 2024 13:14:33 +0200 Subject: [PATCH] Add internal entity link query --- .../VerifyDatabaseOperationsTest.java | 22 +- .../entitylink/api/EntityLinkService.java | 25 +- .../api/InternalEntityLinkQuery.java | 76 ++++++ .../history/HistoricEntityLinkService.java | 28 +- .../service/impl/EntityLinkServiceImpl.java | 16 +- .../impl/HistoricEntityLinkServiceImpl.java | 16 +- .../impl/InternalEntityLinkQueryImpl.java | 253 ++++++++++++++++++ .../entity/EntityLinkEntityManager.java | 7 +- .../entity/EntityLinkEntityManagerImpl.java | 20 +- .../HistoricEntityLinkEntityManager.java | 7 +- .../HistoricEntityLinkEntityManagerImpl.java | 16 +- .../entity/data/EntityLinkDataManager.java | 11 +- .../data/HistoricEntityLinkDataManager.java | 7 +- .../impl/MybatisEntityLinkDataManager.java | 37 +-- .../MybatisHistoricEntityLinkDataManager.java | 32 +-- ...LinksByReferenceScopeIdAndTypeMatcher.java | 34 --- ...ricEntityLinksByScopeIdAndTypeMatcher.java | 33 --- .../service/db/mapping/entity/EntityLink.xml | 49 +++- .../db/mapping/entity/HistoricEntityLink.xml | 49 +++- 19 files changed, 506 insertions(+), 232 deletions(-) create mode 100644 modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/InternalEntityLinkQuery.java create mode 100644 modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/InternalEntityLinkQueryImpl.java delete mode 100644 modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/cachematcher/EntityLinksByReferenceScopeIdAndTypeMatcher.java delete mode 100644 modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/cachematcher/HistoricEntityLinksByScopeIdAndTypeMatcher.java diff --git a/modules/flowable-engine/src/test/java/org/flowable/engine/test/cfg/executioncount/VerifyDatabaseOperationsTest.java b/modules/flowable-engine/src/test/java/org/flowable/engine/test/cfg/executioncount/VerifyDatabaseOperationsTest.java index 2be015174f0..e8c3e7d92fa 100644 --- a/modules/flowable-engine/src/test/java/org/flowable/engine/test/cfg/executioncount/VerifyDatabaseOperationsTest.java +++ b/modules/flowable-engine/src/test/java/org/flowable/engine/test/cfg/executioncount/VerifyDatabaseOperationsTest.java @@ -147,7 +147,7 @@ public void testStartToEnd() { assertDatabaseSelects("StartProcessInstanceCmd", "selectLatestProcessDefinitionByKey", 1L, "selectVariablesByQuery", 1L, - "selectEntityLinksByRootScopeIdAndRootScopeType", 1L); + "selectEntityLinksByQuery", 1L); assertDatabaseInserts("StartProcessInstanceCmd", "HistoricActivityInstanceEntityImpl-bulk-with-3", 1L, @@ -168,7 +168,7 @@ public void testVariablesAndPassthrough() { assertDatabaseSelects("StartProcessInstanceCmd", "selectLatestProcessDefinitionByKey", 1L, "selectVariablesByQuery", 1L, - "selectEntityLinksByRootScopeIdAndRootScopeType", 1L); + "selectEntityLinksByQuery", 1L); assertDatabaseInserts("StartProcessInstanceCmd", "HistoricVariableInstanceEntityImpl-bulk-with-4", 1L, "HistoricProcessInstanceEntityImpl", 1L, @@ -188,7 +188,7 @@ public void testManyVariablesViaServiceTaskAndPassthroughs() { assertDatabaseSelects("StartProcessInstanceCmd", "selectLatestProcessDefinitionByKey", 1L, "selectVariablesByQuery", 1L, - "selectEntityLinksByRootScopeIdAndRootScopeType", 1L); + "selectEntityLinksByQuery", 1L); assertDatabaseInserts("StartProcessInstanceCmd", "HistoricVariableInstanceEntityImpl-bulk-with-50", 1L, "HistoricProcessInstanceEntityImpl", 1L, @@ -208,7 +208,7 @@ public void testOnlyPassThroughs() { assertDatabaseSelects("StartProcessInstanceCmd", "selectLatestProcessDefinitionByKey", 1L, "selectVariablesByQuery", 1L, - "selectEntityLinksByRootScopeIdAndRootScopeType", 1L); + "selectEntityLinksByQuery", 1L); assertDatabaseInserts("StartProcessInstanceCmd", "HistoricActivityInstanceEntityImpl-bulk-with-17", 1L, "HistoricProcessInstanceEntityImpl", 1L); @@ -227,7 +227,7 @@ public void testParallelForkAndJoin() { assertDatabaseSelects("StartProcessInstanceCmd", "selectLatestProcessDefinitionByKey", 1L, "selectVariablesByQuery", 1L, - "selectEntityLinksByRootScopeIdAndRootScopeType", 1L); + "selectEntityLinksByQuery", 1L); assertDatabaseInserts("StartProcessInstanceCmd", "HistoricActivityInstanceEntityImpl-bulk-with-13", 1L, "HistoricProcessInstanceEntityImpl", 1L); @@ -288,7 +288,7 @@ public void testParallelForkAndJoinWithAsyncJobs() { "selectById org.flowable.job.service.impl.persistence.entity.JobEntityImpl", 1L, // Almost all selectXXXByExecutionId are needed when the process instance is deleted "selectDeadLetterJobsByExecutionId", 1L, - "selectEntityLinksByRootScopeIdAndRootScopeType", 1L, + "selectEntityLinksByQuery", 1L, "selectEventSubscriptionsByExecution", 1L, "selectExecutionsWithSameRootProcessInstanceId", 1L, "selectExternalWorkerJobsByExecutionId", 1L, @@ -327,7 +327,7 @@ public void testNestedParallelForkAndJoin() { assertDatabaseSelects("StartProcessInstanceCmd", "selectLatestProcessDefinitionByKey", 1L, "selectVariablesByQuery", 1L, - "selectEntityLinksByRootScopeIdAndRootScopeType", 1L); + "selectEntityLinksByQuery", 1L); assertDatabaseInserts("StartProcessInstanceCmd", "HistoricActivityInstanceEntityImpl-bulk-with-41", 1L, @@ -347,7 +347,7 @@ public void testExclusiveGateway() { assertDatabaseSelects("StartProcessInstanceCmd", "selectLatestProcessDefinitionByKey", 1L, "selectVariablesByQuery", 1L, - "selectEntityLinksByRootScopeIdAndRootScopeType", 1L); + "selectEntityLinksByQuery", 1L); assertDatabaseInserts("StartProcessInstanceCmd", "HistoricActivityInstanceEntityImpl-bulk-with-9", 1L, "HistoricProcessInstanceEntityImpl", 1L, @@ -407,7 +407,7 @@ public void testOneTaskProcess() { // Start process instance assertDatabaseSelects("StartProcessInstanceCmd", "selectLatestProcessDefinitionByKey", 1L, - "selectEntityLinksByReferenceScopeIdAndType", 1L); + "selectEntityLinksByQuery", 1L); assertDatabaseInserts("StartProcessInstanceCmd", "ExecutionEntityImpl-bulk-with-2", 1L, "TaskEntityImpl", 1L, @@ -439,7 +439,7 @@ public void testOneTaskProcess() { "selectTasksByExecutionId", 2L, "selectVariablesByQuery", 2L, "selectIdentityLinksByProcessInstance", 1L, - "selectEntityLinksByRootScopeIdAndRootScopeType", 1L, + "selectEntityLinksByQuery", 1L, "selectEventSubscriptionsByExecution", 1L, "selectTimerJobsByExecutionId", 1L, "selectSuspendedJobsByExecutionId", 1L, @@ -479,7 +479,7 @@ public void testOneTaskWithBoundaryTimerProcess() { // Start process instance assertDatabaseSelects("StartProcessInstanceCmd", "selectLatestProcessDefinitionByKey", 1L, - "selectEntityLinksByReferenceScopeIdAndType", 1L); + "selectEntityLinksByQuery", 1L); assertDatabaseInserts("StartProcessInstanceCmd", "ExecutionEntityImpl-bulk-with-3", 1L, diff --git a/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/EntityLinkService.java b/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/EntityLinkService.java index 1c23f12c7a3..bb2fece0c0f 100644 --- a/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/EntityLinkService.java +++ b/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/EntityLinkService.java @@ -21,13 +21,32 @@ */ public interface EntityLinkService { - List findEntityLinksByScopeIdAndType(String scopeId, String scopeType, String linkType); + default List findEntityLinksByScopeIdAndType(String scopeId, String scopeType, String linkType) { + return createInternalEntityLinkQuery() + .scopeId(scopeId) + .scopeType(scopeType) + .linkType(linkType) + .list(); + } - List findEntityLinksByRootScopeIdAndRootType(String scopeId, String scopeType); + default List findEntityLinksByRootScopeIdAndRootType(String scopeId, String scopeType) { + return createInternalEntityLinkQuery() + .rootScopeId(scopeId) + .rootScopeType(scopeType) + .list(); + } List findEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType); - List findEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType); + default List findEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType) { + return createInternalEntityLinkQuery() + .referenceScopeId(referenceScopeId) + .referenceScopeType(scopeType) + .linkType(linkType) + .list(); + } + + InternalEntityLinkQuery createInternalEntityLinkQuery(); EntityLink createEntityLink(); diff --git a/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/InternalEntityLinkQuery.java b/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/InternalEntityLinkQuery.java new file mode 100644 index 00000000000..6d236f07705 --- /dev/null +++ b/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/InternalEntityLinkQuery.java @@ -0,0 +1,76 @@ +/* Licensed 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.flowable.entitylink.api; + +import java.util.List; + +/** + * @author Filip Hrisafov + */ +public interface InternalEntityLinkQuery { + + /** + * Query entity links with the given scope id. + */ + InternalEntityLinkQuery scopeId(String scopeId); + + /** + * Query entity links with the given scope definition id. + */ + InternalEntityLinkQuery scopeDefinitionId(String scopeDefinitionId); + + /** + * Query entity links with the given scope type. + */ + InternalEntityLinkQuery scopeType(String scopeType); + + /** + * Query entity links with the given reference scope id. + */ + InternalEntityLinkQuery referenceScopeId(String referenceScopeId); + + /** + * Query entity links with the given reference scope definition id. + */ + InternalEntityLinkQuery referenceScopeDefinitionId(String referenceScopeDefinitionId); + + /** + * Query entity links with the given reference scope type. + */ + InternalEntityLinkQuery referenceScopeType(String referenceScopeType); + + /** + * Query entity links with the given root scope id. + */ + InternalEntityLinkQuery rootScopeId(String rootScopeId); + + /** + * Query entity links with the given root scope type. + */ + InternalEntityLinkQuery rootScopeType(String rootScopeType); + + /** + * Query entity links with the given link type. + */ + InternalEntityLinkQuery linkType(String linkType); + + /** + * Query entity links with the given hierarchy type. + */ + InternalEntityLinkQuery hierarchyType(String hierarchyType); + + List list(); + + E singleResult(); + +} diff --git a/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/history/HistoricEntityLinkService.java b/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/history/HistoricEntityLinkService.java index bf7ea252b37..1f8fd1304da 100644 --- a/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/history/HistoricEntityLinkService.java +++ b/modules/flowable-entitylink-service-api/src/main/java/org/flowable/entitylink/api/history/HistoricEntityLinkService.java @@ -15,6 +15,8 @@ import java.util.Collection; import java.util.List; +import org.flowable.entitylink.api.InternalEntityLinkQuery; + /** * Service which provides access to historic entity links. * @@ -24,15 +26,35 @@ public interface HistoricEntityLinkService { HistoricEntityLink getHistoricEntityLink(String id); - List findHistoricEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType, String linkType); + default List findHistoricEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { + return createInternalHistoricEntityLinkQuery() + .scopeId(scopeId) + .scopeType(scopeType) + .linkType(linkType) + .list(); + } List findHistoricEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType); List findHistoricEntityLinksWithSameRootScopeForScopeIdsAndScopeType(Collection scopeIds, String scopeType, String linkType); - List findHistoricEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType); + default List findHistoricEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType) { + return createInternalHistoricEntityLinkQuery() + .referenceScopeId(referenceScopeId) + .referenceScopeType(scopeType) + .linkType(linkType) + .list(); + } + + default List findHistoricEntityLinksByScopeDefinitionIdAndScopeType(String scopeDefinitionId, String scopeType, String linkType) { + return createInternalHistoricEntityLinkQuery() + .scopeDefinitionId(scopeDefinitionId) + .scopeType(scopeType) + .linkType(linkType) + .list(); + } - List findHistoricEntityLinksByScopeDefinitionIdAndScopeType(String scopeDefinitionId, String scopeType, String linkType); + InternalEntityLinkQuery createInternalHistoricEntityLinkQuery(); HistoricEntityLink createHistoricEntityLink(); diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/EntityLinkServiceImpl.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/EntityLinkServiceImpl.java index 03c77426f09..fa3dfc2f324 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/EntityLinkServiceImpl.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/EntityLinkServiceImpl.java @@ -17,6 +17,7 @@ import org.flowable.common.engine.impl.service.CommonServiceImpl; import org.flowable.entitylink.api.EntityLink; import org.flowable.entitylink.api.EntityLinkService; +import org.flowable.entitylink.api.InternalEntityLinkQuery; import org.flowable.entitylink.service.EntityLinkServiceConfiguration; import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity; import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntityManager; @@ -30,24 +31,15 @@ public EntityLinkServiceImpl(EntityLinkServiceConfiguration entityLinkServiceCon super(entityLinkServiceConfiguration); } - @Override - public List findEntityLinksByScopeIdAndType(String scopeId, String scopeType, String linkType) { - return getEntityLinkEntityManager().findEntityLinksByScopeIdAndType(scopeId, scopeType, linkType); - } - - @Override - public List findEntityLinksByRootScopeIdAndRootType(String scopeId, String scopeType) { - return getEntityLinkEntityManager().findEntityLinksByRootScopeIdAndRootType(scopeId, scopeType); - } - @Override public List findEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { return getEntityLinkEntityManager().findEntityLinksWithSameRootScopeForScopeIdAndScopeType(scopeId, scopeType, linkType); } @Override - public List findEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String referenceScopeType, String linkType) { - return getEntityLinkEntityManager().findEntityLinksByReferenceScopeIdAndType(referenceScopeId, referenceScopeType, linkType); + @SuppressWarnings("unchecked") + public InternalEntityLinkQuery createInternalEntityLinkQuery() { + return (InternalEntityLinkQuery) getEntityLinkEntityManager().createInternalEntityLinkQuery(); } @Override diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/HistoricEntityLinkServiceImpl.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/HistoricEntityLinkServiceImpl.java index ad436c49ee9..6b0fcd9fb5f 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/HistoricEntityLinkServiceImpl.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/HistoricEntityLinkServiceImpl.java @@ -16,6 +16,7 @@ import java.util.List; import org.flowable.common.engine.impl.service.CommonServiceImpl; +import org.flowable.entitylink.api.InternalEntityLinkQuery; import org.flowable.entitylink.api.history.HistoricEntityLink; import org.flowable.entitylink.api.history.HistoricEntityLinkService; import org.flowable.entitylink.service.EntityLinkServiceConfiguration; @@ -36,11 +37,6 @@ public HistoricEntityLink getHistoricEntityLink(String id) { return getHistoricEntityLinkEntityManager().findById(id); } - @Override - public List findHistoricEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { - return getHistoricEntityLinkEntityManager().findHistoricEntityLinksByScopeIdAndScopeType(scopeId, scopeType, linkType); - } - @Override public List findHistoricEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { return getHistoricEntityLinkEntityManager().findHistoricEntityLinksWithSameRootScopeForScopeIdAndScopeType(scopeId, scopeType, linkType); @@ -52,13 +48,9 @@ public List findHistoricEntityLinksWithSameRootScopeForScope } @Override - public List findHistoricEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType) { - return getHistoricEntityLinkEntityManager().findHistoricEntityLinksByReferenceScopeIdAndType(referenceScopeId, scopeType, linkType); - } - - @Override - public List findHistoricEntityLinksByScopeDefinitionIdAndScopeType(String scopeDefinitionId, String scopeType, String linkType) { - return getHistoricEntityLinkEntityManager().findHistoricEntityLinksByScopeDefinitionIdAndScopeType(scopeDefinitionId, scopeType, linkType); + @SuppressWarnings("unchecked") + public InternalEntityLinkQuery createInternalHistoricEntityLinkQuery() { + return (InternalEntityLinkQuery) getHistoricEntityLinkEntityManager().createInternalHistoricEntityLinkQuery(); } @Override diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/InternalEntityLinkQueryImpl.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/InternalEntityLinkQueryImpl.java new file mode 100644 index 00000000000..32f0a5cabf2 --- /dev/null +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/InternalEntityLinkQueryImpl.java @@ -0,0 +1,253 @@ +/* Licensed 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.flowable.entitylink.service.impl; + +import java.util.Collection; +import java.util.List; +import java.util.function.Function; + +import org.apache.commons.lang3.StringUtils; +import org.flowable.common.engine.api.FlowableIllegalArgumentException; +import org.flowable.common.engine.impl.db.SingleCachedEntityMatcher; +import org.flowable.common.engine.impl.persistence.cache.CachedEntity; +import org.flowable.common.engine.impl.persistence.cache.CachedEntityMatcher; +import org.flowable.common.engine.impl.persistence.entity.Entity; +import org.flowable.entitylink.api.EntityLinkInfo; +import org.flowable.entitylink.api.InternalEntityLinkQuery; + +/** + * @author Filip Hrisafov + */ +public class InternalEntityLinkQueryImpl + implements InternalEntityLinkQuery, CachedEntityMatcher, SingleCachedEntityMatcher { + + protected final Function, List> listProvider; + protected final Function, E> singleResultProvider; + + protected String scopeId; + protected String scopeDefinitionId; + protected String scopeType; + protected String referenceScopeId; + protected String referenceScopeDefinitionId; + protected String referenceScopeType; + protected String rootScopeId; + protected String rootScopeType; + protected String linkType; + protected String hierarchyType; + + public InternalEntityLinkQueryImpl(Function, List> listProvider, + Function, E> singleResultProvider) { + this.listProvider = listProvider; + this.singleResultProvider = singleResultProvider; + } + + @Override + public InternalEntityLinkQuery scopeId(String scopeId) { + if (StringUtils.isEmpty(scopeId)) { + throw new FlowableIllegalArgumentException("scopeId is empty"); + } + this.scopeId = scopeId; + return this; + } + + @Override + public InternalEntityLinkQuery scopeDefinitionId(String scopeDefinitionId) { + if (StringUtils.isEmpty(scopeDefinitionId)) { + throw new FlowableIllegalArgumentException("scopeDefinitionId is empty"); + } + this.scopeDefinitionId = scopeDefinitionId; + return this; + } + + @Override + public InternalEntityLinkQuery scopeType(String scopeType) { + if (StringUtils.isEmpty(scopeType)) { + throw new FlowableIllegalArgumentException("scopeType is empty"); + } + this.scopeType = scopeType; + return this; + } + + @Override + public InternalEntityLinkQuery referenceScopeId(String referenceScopeId) { + if (StringUtils.isEmpty(referenceScopeId)) { + throw new FlowableIllegalArgumentException("referenceScopeId is empty"); + } + this.referenceScopeId = referenceScopeId; + return this; + } + + @Override + public InternalEntityLinkQuery referenceScopeDefinitionId(String referenceScopeDefinitionId) { + if (StringUtils.isEmpty(referenceScopeDefinitionId)) { + throw new FlowableIllegalArgumentException("referenceScopeDefinitionId is empty"); + } + this.referenceScopeDefinitionId = referenceScopeDefinitionId; + return this; + } + + @Override + public InternalEntityLinkQuery referenceScopeType(String referenceScopeType) { + if (StringUtils.isEmpty(referenceScopeType)) { + throw new FlowableIllegalArgumentException("referenceScopeType is empty"); + } + this.referenceScopeType = referenceScopeType; + return this; + } + + @Override + public InternalEntityLinkQuery rootScopeId(String rootScopeId) { + if (StringUtils.isEmpty(rootScopeId)) { + throw new FlowableIllegalArgumentException("rootScopeId is empty"); + } + this.rootScopeId = rootScopeId; + return this; + } + + @Override + public InternalEntityLinkQuery rootScopeType(String rootScopeType) { + if (StringUtils.isEmpty(rootScopeType)) { + throw new FlowableIllegalArgumentException("rootScopeType is empty"); + } + this.rootScopeType = rootScopeType; + return this; + } + + @Override + public InternalEntityLinkQuery linkType(String linkType) { + if (StringUtils.isEmpty(linkType)) { + throw new FlowableIllegalArgumentException("linkType is empty"); + } + this.linkType = linkType; + return this; + } + + @Override + public InternalEntityLinkQuery hierarchyType(String hierarchyType) { + if (StringUtils.isEmpty(hierarchyType)) { + throw new FlowableIllegalArgumentException("hierarchyType is empty"); + } + this.hierarchyType = hierarchyType; + return this; + } + + @Override + public List list() { + return listProvider.apply(this); + } + + @Override + public E singleResult() { + return singleResultProvider.apply(this); + } + + public String getScopeId() { + return scopeId; + } + + public String getScopeDefinitionId() { + return scopeDefinitionId; + } + + public String getScopeType() { + return scopeType; + } + + public String getReferenceScopeId() { + return referenceScopeId; + } + + public String getReferenceScopeDefinitionId() { + return referenceScopeDefinitionId; + } + + public String getReferenceScopeType() { + return referenceScopeType; + } + + public String getRootScopeId() { + return rootScopeId; + } + + public String getRootScopeType() { + return rootScopeType; + } + + public String getLinkType() { + return linkType; + } + + public String getHierarchyType() { + return hierarchyType; + } + + // This method is needed because we have a different way of querying list and single objects via MyBatis. + // Querying lists wraps the object in a ListQueryParameterObject + public InternalEntityLinkQueryImpl getParameter() { + return this; + } + + @Override + public boolean isRetained(E entity, Object param) { + return isRetained(entity, (InternalEntityLinkQueryImpl) param); + } + + @Override + public boolean isRetained(Collection databaseEntities, Collection cachedEntities, E entity, Object param) { + return isRetained(entity, (InternalEntityLinkQueryImpl) param); + } + + public boolean isRetained(E entity, InternalEntityLinkQueryImpl param) { + if (param.scopeId != null && !param.scopeId.equals(entity.getScopeId())) { + return false; + } + + if (param.scopeDefinitionId != null && !param.scopeDefinitionId.equals(entity.getScopeDefinitionId())) { + return false; + } + + if (param.scopeType != null && !param.scopeType.equals(entity.getScopeType())) { + return false; + } + + if (param.referenceScopeId != null && !param.referenceScopeId.equals(entity.getReferenceScopeId())) { + return false; + } + + if (param.referenceScopeDefinitionId != null && !param.referenceScopeDefinitionId.equals(entity.getReferenceScopeDefinitionId())) { + return false; + } + + if (param.referenceScopeType != null && !param.referenceScopeType.equals(entity.getReferenceScopeType())) { + return false; + } + + if (param.rootScopeId != null && !param.rootScopeId.equals(entity.getRootScopeId())) { + return false; + } + + if (param.rootScopeType != null && !param.rootScopeType.equals(entity.getRootScopeType())) { + return false; + } + + if (param.linkType != null && !param.linkType.equals(entity.getLinkType())) { + return false; + } + + if (param.hierarchyType != null && !param.hierarchyType.equals(entity.getHierarchyType())) { + return false; + } + + return true; + } +} diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/EntityLinkEntityManager.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/EntityLinkEntityManager.java index d52ae6ae8b3..d4ee13b006c 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/EntityLinkEntityManager.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/EntityLinkEntityManager.java @@ -16,19 +16,16 @@ import org.flowable.common.engine.impl.persistence.entity.EntityManager; import org.flowable.entitylink.api.EntityLink; +import org.flowable.entitylink.api.InternalEntityLinkQuery; /** * @author Tijs Rademakers */ public interface EntityLinkEntityManager extends EntityManager { - List findEntityLinksByScopeIdAndType(String scopeId, String scopeType, String linkType); - - List findEntityLinksByRootScopeIdAndRootType(String scopeId, String scopeType); - List findEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType); - List findEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType); + InternalEntityLinkQuery createInternalEntityLinkQuery(); void deleteEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType); diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/EntityLinkEntityManagerImpl.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/EntityLinkEntityManagerImpl.java index 207d3846cbe..8e8fc5f3d36 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/EntityLinkEntityManagerImpl.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/EntityLinkEntityManagerImpl.java @@ -17,7 +17,9 @@ import org.flowable.common.engine.impl.persistence.entity.AbstractServiceEngineEntityManager; import org.flowable.entitylink.api.EntityLink; +import org.flowable.entitylink.api.InternalEntityLinkQuery; import org.flowable.entitylink.service.EntityLinkServiceConfiguration; +import org.flowable.entitylink.service.impl.InternalEntityLinkQueryImpl; import org.flowable.entitylink.service.impl.persistence.entity.data.EntityLinkDataManager; /** @@ -38,28 +40,14 @@ public EntityLinkEntity create() { return entityLinkEntity; } - @Override - public List findEntityLinksByScopeIdAndType(String scopeId, String scopeType, String linkType) { - return dataManager.findEntityLinksByScopeIdAndType(scopeId, scopeType, linkType); - } - - @Override - public List findEntityLinksByRootScopeIdAndRootType(String scopeId, String scopeType) { - return dataManager.findEntityLinksByRootScopeIdAndRootType(scopeId, scopeType); - } - @Override public List findEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { return dataManager.findEntityLinksWithSameRootScopeForScopeIdAndScopeType(scopeId, scopeType, linkType); } @Override - public List findEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String referenceScopeType, String linkType) { - return dataManager.findEntityLinksByReferenceScopeIdAndType(referenceScopeId, referenceScopeType, linkType); - } - - public void deleteEntityLink(EntityLinkEntity identityLink) { - delete(identityLink); + public InternalEntityLinkQuery createInternalEntityLinkQuery() { + return new InternalEntityLinkQueryImpl<>(dataManager::findEntityLinksByQuery, dataManager::findEntityLinkByQuery); } @Override diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/HistoricEntityLinkEntityManager.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/HistoricEntityLinkEntityManager.java index dae01f1e4ec..fe03cba1e9a 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/HistoricEntityLinkEntityManager.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/HistoricEntityLinkEntityManager.java @@ -16,6 +16,7 @@ import java.util.List; import org.flowable.common.engine.impl.persistence.entity.EntityManager; +import org.flowable.entitylink.api.InternalEntityLinkQuery; import org.flowable.entitylink.api.history.HistoricEntityLink; /** @@ -23,15 +24,11 @@ */ public interface HistoricEntityLinkEntityManager extends EntityManager { - List findHistoricEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType, String linkType); - List findHistoricEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType); List findHistoricEntityLinksWithSameRootScopeForScopeIdsAndScopeType(Collection scopeIds, String scopeType, String linkType); - List findHistoricEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType); - - List findHistoricEntityLinksByScopeDefinitionIdAndScopeType(String scopeDefinitionId, String scopeType, String linkType); + InternalEntityLinkQuery createInternalHistoricEntityLinkQuery(); void deleteHistoricEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType); diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/HistoricEntityLinkEntityManagerImpl.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/HistoricEntityLinkEntityManagerImpl.java index 4c660465258..3f91e3f8791 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/HistoricEntityLinkEntityManagerImpl.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/HistoricEntityLinkEntityManagerImpl.java @@ -17,8 +17,10 @@ import java.util.List; import org.flowable.common.engine.impl.persistence.entity.AbstractServiceEngineEntityManager; +import org.flowable.entitylink.api.InternalEntityLinkQuery; import org.flowable.entitylink.api.history.HistoricEntityLink; import org.flowable.entitylink.service.EntityLinkServiceConfiguration; +import org.flowable.entitylink.service.impl.InternalEntityLinkQueryImpl; import org.flowable.entitylink.service.impl.persistence.entity.data.HistoricEntityLinkDataManager; /** @@ -39,11 +41,6 @@ public HistoricEntityLinkEntity create() { return entityLinkEntity; } - @Override - public List findHistoricEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { - return dataManager.findHistoricEntityLinksByScopeIdAndScopeType(scopeId, scopeType, linkType); - } - @Override public List findHistoricEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { return dataManager.findHistoricEntityLinksWithSameRootScopeForScopeIdAndScopeType(scopeId, scopeType, linkType); @@ -55,13 +52,8 @@ public List findHistoricEntityLinksWithSameRootScopeForScope } @Override - public List findHistoricEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType) { - return dataManager.findHistoricEntityLinksByReferenceScopeIdAndType(referenceScopeId, scopeType, linkType); - } - - @Override - public List findHistoricEntityLinksByScopeDefinitionIdAndScopeType(String scopeDefinitionId, String scopeType, String linkType) { - return dataManager.findHistoricEntityLinksByScopeDefinitionIdAndScopeType(scopeDefinitionId, scopeType, linkType); + public InternalEntityLinkQuery createInternalHistoricEntityLinkQuery() { + return new InternalEntityLinkQueryImpl<>(dataManager::findHistoricEntityLinksByQuery, dataManager::findHistoricEntityLinkByQuery); } @Override diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/EntityLinkDataManager.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/EntityLinkDataManager.java index ce56af6659a..a9bcdfeb9dc 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/EntityLinkDataManager.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/EntityLinkDataManager.java @@ -16,6 +16,7 @@ import org.flowable.common.engine.impl.persistence.entity.data.DataManager; import org.flowable.entitylink.api.EntityLink; +import org.flowable.entitylink.api.InternalEntityLinkQuery; import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity; /** @@ -23,14 +24,12 @@ */ public interface EntityLinkDataManager extends DataManager { - List findEntityLinksByScopeIdAndType(String scopeId, String scopeType, String linkType); + List findEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType); - List findEntityLinksByRootScopeIdAndRootType(String scopeId, String scopeType); + List findEntityLinksByQuery(InternalEntityLinkQuery query); + + EntityLinkEntity findEntityLinkByQuery(InternalEntityLinkQuery query); - List findEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType); - - List findEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType); - void deleteEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType); void deleteEntityLinksByRootScopeIdAndType(String scopeId, String scopeType); diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/HistoricEntityLinkDataManager.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/HistoricEntityLinkDataManager.java index d6c6763754d..fd93303b92d 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/HistoricEntityLinkDataManager.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/HistoricEntityLinkDataManager.java @@ -16,6 +16,7 @@ import java.util.List; import org.flowable.common.engine.impl.persistence.entity.data.DataManager; +import org.flowable.entitylink.api.InternalEntityLinkQuery; import org.flowable.entitylink.api.history.HistoricEntityLink; import org.flowable.entitylink.service.impl.persistence.entity.HistoricEntityLinkEntity; @@ -24,15 +25,13 @@ */ public interface HistoricEntityLinkDataManager extends DataManager { - List findHistoricEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType, String linkType); - List findHistoricEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType); List findHistoricEntityLinksWithSameRootScopeForScopeIdsAndScopeType(Collection scopeIds, String scopeType, String linkType); - List findHistoricEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType); + List findHistoricEntityLinksByQuery(InternalEntityLinkQuery query); - List findHistoricEntityLinksByScopeDefinitionIdAndScopeType(String scopeDefinitionId, String scopeType, String linkType); + HistoricEntityLinkEntity findHistoricEntityLinkByQuery(InternalEntityLinkQuery query); void deleteHistoricEntityLinksByScopeIdAndType(String scopeId, String scopeType); diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/MybatisEntityLinkDataManager.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/MybatisEntityLinkDataManager.java index b996aa0cf7e..4e5556f1e44 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/MybatisEntityLinkDataManager.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/MybatisEntityLinkDataManager.java @@ -18,13 +18,14 @@ import org.flowable.common.engine.impl.cfg.IdGenerator; import org.flowable.common.engine.impl.db.AbstractDataManager; +import org.flowable.common.engine.impl.db.SingleCachedEntityMatcher; import org.flowable.common.engine.impl.persistence.cache.CachedEntityMatcher; import org.flowable.entitylink.api.EntityLink; +import org.flowable.entitylink.api.InternalEntityLinkQuery; import org.flowable.entitylink.service.EntityLinkServiceConfiguration; import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity; import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntityImpl; import org.flowable.entitylink.service.impl.persistence.entity.data.EntityLinkDataManager; -import org.flowable.entitylink.service.impl.persistence.entity.data.impl.cachematcher.EntityLinksByReferenceScopeIdAndTypeMatcher; import org.flowable.entitylink.service.impl.persistence.entity.data.impl.cachematcher.EntityLinksByRootScopeIdAndTypeMatcher; import org.flowable.entitylink.service.impl.persistence.entity.data.impl.cachematcher.EntityLinksByScopeIdAndTypeMatcher; import org.flowable.entitylink.service.impl.persistence.entity.data.impl.cachematcher.EntityLinksWithSameRootScopeForScopeIdAndScopeTypeMatcher; @@ -37,7 +38,6 @@ public class MybatisEntityLinkDataManager extends AbstractDataManager entityLinksByScopeIdAndTypeMatcher = new EntityLinksByScopeIdAndTypeMatcher(); protected CachedEntityMatcher entityLinksByRootScopeIdAndScopeTypeMatcher = new EntityLinksByRootScopeIdAndTypeMatcher(); protected CachedEntityMatcher entityLinksWithSameRootByScopeIdAndTypeMatcher = new EntityLinksWithSameRootScopeForScopeIdAndScopeTypeMatcher<>(); - protected CachedEntityMatcher entityLinksByReferenceScopeIdAndTypeMatcher = new EntityLinksByReferenceScopeIdAndTypeMatcher(); protected EntityLinkServiceConfiguration entityLinkServiceConfiguration; @@ -57,41 +57,24 @@ public EntityLinkEntity create() { @Override @SuppressWarnings({ "unchecked", "rawtypes" }) - public List findEntityLinksByScopeIdAndType(String scopeId, String scopeType, String linkType) { + public List findEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { Map parameters = new HashMap<>(); parameters.put("scopeId", scopeId); parameters.put("scopeType", scopeType); parameters.put("linkType", linkType); - return (List) getList("selectEntityLinksByScopeIdAndType", parameters, entityLinksByScopeIdAndTypeMatcher, true); + return (List) getList("selectEntityLinksWithSameRootScopeByScopeIdAndType", parameters, entityLinksWithSameRootByScopeIdAndTypeMatcher, true); } @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public List findEntityLinksByRootScopeIdAndRootType(String scopeId, String scopeType) { - Map parameters = new HashMap<>(); - parameters.put("rootScopeId", scopeId); - parameters.put("rootScopeType", scopeType); - return (List) getList("selectEntityLinksByRootScopeIdAndRootScopeType", parameters, entityLinksByRootScopeIdAndScopeTypeMatcher, true); + @SuppressWarnings("unchecked") + public List findEntityLinksByQuery(InternalEntityLinkQuery query) { + return getList("selectEntityLinksByQuery", query, (CachedEntityMatcher) query, true); } @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public List findEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { - Map parameters = new HashMap<>(); - parameters.put("scopeId", scopeId); - parameters.put("scopeType", scopeType); - parameters.put("linkType", linkType); - return (List) getList("selectEntityLinksWithSameRootScopeByScopeIdAndType", parameters, entityLinksWithSameRootByScopeIdAndTypeMatcher, true); - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public List findEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String referenceScopeType, String linkType) { - Map parameters = new HashMap<>(); - parameters.put("referenceScopeId", referenceScopeId); - parameters.put("referenceScopeType", referenceScopeType); - parameters.put("linkType", linkType); - return (List) getList("selectEntityLinksByReferenceScopeIdAndType", parameters, entityLinksByReferenceScopeIdAndTypeMatcher, true); + @SuppressWarnings("unchecked") + public EntityLinkEntity findEntityLinkByQuery(InternalEntityLinkQuery query) { + return getEntity("selectEntityLinksByQuery", query, (SingleCachedEntityMatcher) query, true); } @Override diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/MybatisHistoricEntityLinkDataManager.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/MybatisHistoricEntityLinkDataManager.java index afc31ed3c12..bd3a2c71210 100644 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/MybatisHistoricEntityLinkDataManager.java +++ b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/MybatisHistoricEntityLinkDataManager.java @@ -20,21 +20,21 @@ import org.flowable.common.engine.impl.cfg.IdGenerator; import org.flowable.common.engine.impl.db.AbstractDataManager; +import org.flowable.common.engine.impl.db.SingleCachedEntityMatcher; import org.flowable.common.engine.impl.persistence.cache.CachedEntityMatcher; +import org.flowable.entitylink.api.InternalEntityLinkQuery; import org.flowable.entitylink.api.history.HistoricEntityLink; import org.flowable.entitylink.service.EntityLinkServiceConfiguration; import org.flowable.entitylink.service.impl.persistence.entity.HistoricEntityLinkEntity; import org.flowable.entitylink.service.impl.persistence.entity.HistoricEntityLinkEntityImpl; import org.flowable.entitylink.service.impl.persistence.entity.data.HistoricEntityLinkDataManager; import org.flowable.entitylink.service.impl.persistence.entity.data.impl.cachematcher.EntityLinksWithSameRootScopeForScopeIdAndScopeTypeMatcher; -import org.flowable.entitylink.service.impl.persistence.entity.data.impl.cachematcher.HistoricEntityLinksByScopeIdAndTypeMatcher; /** * @author Joram Barrez */ public class MybatisHistoricEntityLinkDataManager extends AbstractDataManager implements HistoricEntityLinkDataManager { - protected CachedEntityMatcher historicEntityLinksByScopeIdAndTypeMatcher = new HistoricEntityLinksByScopeIdAndTypeMatcher(); protected CachedEntityMatcher entityLinksWithSameRootByScopeIdAndTypeMatcher = new EntityLinksWithSameRootScopeForScopeIdAndScopeTypeMatcher<>(); protected EntityLinkServiceConfiguration entityLinkServiceConfiguration; @@ -53,16 +53,6 @@ public HistoricEntityLinkEntity create() { return new HistoricEntityLinkEntityImpl(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public List findHistoricEntityLinksByScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { - Map parameters = new HashMap<>(); - parameters.put("scopeId", scopeId); - parameters.put("scopeType", scopeType); - parameters.put("linkType", linkType); - return (List) getList("selectHistoricEntityLinksByScopeIdAndType", parameters, historicEntityLinksByScopeIdAndTypeMatcher, true); - } - @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public List findHistoricEntityLinksWithSameRootScopeForScopeIdAndScopeType(String scopeId, String scopeType, String linkType) { @@ -94,24 +84,16 @@ public List findHistoricEntityLinksWithSameRootScopeForScope return (List) getList("selectHistoricEntityLinksByRootScopeIdsAndType", parameters); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public List findHistoricEntityLinksByReferenceScopeIdAndType(String referenceScopeId, String scopeType, String linkType) { - Map parameters = new HashMap<>(); - parameters.put("referenceScopeId", referenceScopeId); - parameters.put("referenceScopeType", scopeType); - parameters.put("linkType", linkType); - return (List) getList("selectHistoricEntityLinksByReferenceScopeIdAndType", parameters, historicEntityLinksByScopeIdAndTypeMatcher, true); + @SuppressWarnings("unchecked") + public List findHistoricEntityLinksByQuery(InternalEntityLinkQuery query) { + return getList("selectHistoricEntityLinksByQuery", query, (CachedEntityMatcher) query, true); } @Override @SuppressWarnings("unchecked") - public List findHistoricEntityLinksByScopeDefinitionIdAndScopeType(String scopeDefinitionId, String scopeType, String linkType) { - Map parameters = new HashMap<>(); - parameters.put("scopeDefinitionId", scopeDefinitionId); - parameters.put("scopeType", scopeType); - parameters.put("linkType", linkType); - return getDbSqlSession().selectList("selectHistoricEntityLinksByScopeDefinitionIdAndType", parameters); + public HistoricEntityLinkEntity findHistoricEntityLinkByQuery(InternalEntityLinkQuery query) { + return getEntity("selectHistoricEntityLinksByQuery", query, (SingleCachedEntityMatcher) query, true); } @Override diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/cachematcher/EntityLinksByReferenceScopeIdAndTypeMatcher.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/cachematcher/EntityLinksByReferenceScopeIdAndTypeMatcher.java deleted file mode 100644 index 3e3e8bb75cf..00000000000 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/cachematcher/EntityLinksByReferenceScopeIdAndTypeMatcher.java +++ /dev/null @@ -1,34 +0,0 @@ -/* Licensed 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.flowable.entitylink.service.impl.persistence.entity.data.impl.cachematcher; - -import java.util.Map; - -import org.flowable.common.engine.impl.persistence.cache.CachedEntityMatcherAdapter; -import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity; - -/** - * @author Tijs Rademakers - */ -public class EntityLinksByReferenceScopeIdAndTypeMatcher extends CachedEntityMatcherAdapter { - - @Override - public boolean isRetained(EntityLinkEntity entity, Object parameter) { - @SuppressWarnings("unchecked") - Map parameterMap = (Map) parameter; - return entity.getReferenceScopeId() != null && entity.getReferenceScopeId().equals(parameterMap.get("referenceScopeId")) && - entity.getReferenceScopeType() != null && entity.getReferenceScopeType().equals(parameterMap.get("referenceScopeType")) && - entity.getLinkType() != null && entity.getLinkType().equals(parameterMap.get("linkType")); - } - -} \ No newline at end of file diff --git a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/cachematcher/HistoricEntityLinksByScopeIdAndTypeMatcher.java b/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/cachematcher/HistoricEntityLinksByScopeIdAndTypeMatcher.java deleted file mode 100644 index 557c6b4b34e..00000000000 --- a/modules/flowable-entitylink-service/src/main/java/org/flowable/entitylink/service/impl/persistence/entity/data/impl/cachematcher/HistoricEntityLinksByScopeIdAndTypeMatcher.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Licensed 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.flowable.entitylink.service.impl.persistence.entity.data.impl.cachematcher; - -import java.util.Map; - -import org.flowable.common.engine.impl.persistence.cache.CachedEntityMatcherAdapter; -import org.flowable.entitylink.service.impl.persistence.entity.HistoricEntityLinkEntity; - -/** - * @author Tijs Rademakers - */ -public class HistoricEntityLinksByScopeIdAndTypeMatcher extends CachedEntityMatcherAdapter { - - @Override - public boolean isRetained(HistoricEntityLinkEntity historicIdentityLinkEntity, Object parameter) { - @SuppressWarnings("unchecked") - Map parameterMap = (Map) parameter; - return historicIdentityLinkEntity.getScopeId() != null && historicIdentityLinkEntity.getScopeId().equals(parameterMap.get("scopeId")) && - historicIdentityLinkEntity.getScopeType() != null && historicIdentityLinkEntity.getScopeType().equals(parameterMap.get("scopeType")); - } - -} \ No newline at end of file diff --git a/modules/flowable-entitylink-service/src/main/resources/org/flowable/entitylink/service/db/mapping/entity/EntityLink.xml b/modules/flowable-entitylink-service/src/main/resources/org/flowable/entitylink/service/db/mapping/entity/EntityLink.xml index d34700504cd..e12da0402fa 100644 --- a/modules/flowable-entitylink-service/src/main/resources/org/flowable/entitylink/service/db/mapping/entity/EntityLink.xml +++ b/modules/flowable-entitylink-service/src/main/resources/org/flowable/entitylink/service/db/mapping/entity/EntityLink.xml @@ -117,18 +117,6 @@ select * from ${prefix}ACT_RU_ENTITYLINK where ID_ = #{id, jdbcType=VARCHAR} - - - - - - @@ -171,5 +159,42 @@ ) ROOT_LINK ON RES.ROOT_SCOPE_ID_ = ROOT_LINK.ROOT_SCOPE_ID_ and RES.ROOT_SCOPE_TYPE_ = ROOT_LINK.ROOT_SCOPE_TYPE_ where LINK_TYPE_ = #{parameter.linkType} + + \ No newline at end of file diff --git a/modules/flowable-entitylink-service/src/main/resources/org/flowable/entitylink/service/db/mapping/entity/HistoricEntityLink.xml b/modules/flowable-entitylink-service/src/main/resources/org/flowable/entitylink/service/db/mapping/entity/HistoricEntityLink.xml index 7c4a063b639..a7ef65113fc 100644 --- a/modules/flowable-entitylink-service/src/main/resources/org/flowable/entitylink/service/db/mapping/entity/HistoricEntityLink.xml +++ b/modules/flowable-entitylink-service/src/main/resources/org/flowable/entitylink/service/db/mapping/entity/HistoricEntityLink.xml @@ -137,18 +137,6 @@ select * from ${prefix}ACT_HI_ENTITYLINK where ID_ = #{id, jdbcType=VARCHAR} - - - - - - @@ -224,4 +212,41 @@ and SCOPE_TYPE_ = #{parameter.scopeType} and LINK_TYPE_ = #{parameter.linkType} and ROOT_SCOPE_ID_ is not null + +