From be5dc018778b18a153aa366ccdd76166ec8cb026 Mon Sep 17 00:00:00 2001 From: Filip Hrisafov Date: Tue, 15 Aug 2023 14:07:19 +0200 Subject: [PATCH] Remove async history support --- .../configurator/CmmnEngineConfigurator.java | 3 - ...mmnEngineConfiguratorAsyncHistoryTest.java | 102 +- .../cmmn/test/TestHistoryJobHandler.java} | 33 +- .../resources/flowable.async.history.cfg.xml | 26 +- .../cmmn/engine/CmmnEngineConfiguration.java | 199 +- .../history/CmmnHistoryVariableManager.java | 12 - .../AbstractAsyncCmmnHistoryManager.java | 341 ---- .../async/AsyncCmmnHistoryManager.java | 436 ----- .../async/CmmnAsyncHistoryConstants.java | 212 --- .../AbstractHistoryJsonTransformer.java | 28 - ...dsHistoricCaseInstanceJsonTransformer.java | 46 - ...lanItemInstanceHistoryJsonTransformer.java | 58 - ...lanItemInstanceHistoryJsonTransformer.java | 56 - .../AbstractTaskHistoryJsonTransformer.java | 67 - ...CaseInstanceEndHistoryJsonTransformer.java | 77 - ...tanceReactivateHistoryJsonTransformer.java | 59 - ...seInstanceStartHistoryJsonTransformer.java | 78 - ...dateBusinessKeyHistoryJsonTransformer.java | 54 - ...eBusinessStatusHistoryJsonTransformer.java | 54 - ...tanceUpdateNameHistoryJsonTransformer.java | 54 - ...tityLinkCreatedHistoryJsonTransformer.java | 71 - ...tityLinkDeletedHistoryJsonTransformer.java | 62 - ...InstanceDeletedHistoryJsonTransformer.java | 47 - ...toricUserTaskLogDeleteJsonTransformer.java | 53 - ...toricUserTaskLogRecordJsonTransformer.java | 65 - ...tityLinkCreatedHistoryJsonTransformer.java | 65 - ...tityLinkDeletedHistoryJsonTransformer.java | 62 - ...ilestoneReachedHistoryJsonTransformer.java | 63 - ...stanceAvailableHistoryJsonTransformer.java | 56 - ...stanceCompletedHistoryJsonTransformer.java | 51 - ...InstanceCreatedHistoryJsonTransformer.java | 56 - ...nstanceDisabledHistoryJsonTransformer.java | 56 - ...InstanceEnabledHistoryJsonTransformer.java | 56 - ...temInstanceExitHistoryJsonTransformer.java | 51 - ...temInstanceFullHistoryJsonTransformer.java | 99 - ...nstanceOccurredHistoryJsonTransformer.java | 51 - ...InstanceStartedHistoryJsonTransformer.java | 56 - ...stanceSuspendedHistoryJsonTransformer.java | 56 - ...tanceTerminatedHistoryJsonTransformer.java | 51 - .../TaskCreatedHistoryJsonTransformer.java | 54 - .../TaskDeletedHistoryJsonTransformer.java | 51 - .../TaskEndedHistoryJsonTransformer.java | 80 - .../TaskUpdatedHistoryJsonTransformer.java | 72 - ...finitionCascadeHistoryJsonTransformer.java | 84 - ...VariableCreatedHistoryJsonTransformer.java | 94 - ...VariableRemovedHistoryJsonTransformer.java | 60 - ...VariableUpdatedHistoryJsonTransformer.java | 90 - .../cmmn/test/async/AsyncCmmnHistoryTest.java | 1653 ----------------- ...cCmmnHistoryTest.createRootEntityLink.cmmn | 19 - .../AsyncCmmnHistoryTest.testBusinessKey.cmmn | 19 - ...storyTest.testCaseInstanceStartAndEnd.cmmn | 19 - ...AsyncCmmnHistoryTest.testCasePageTask.cmmn | 18 - ...testCriterionStoredOnPlanItemInstance.cmmn | 91 - ...yTest.testHistoricCaseInstanceDeleted.cmmn | 19 - ...CmmnHistoryTest.testHistoryJobFailure.cmmn | 19 - .../AsyncCmmnHistoryTest.testHumanTask.cmmn | 19 - ...tHumanTaskWithCandidateUsersAndGroups.cmmn | 19 - ...syncCmmnHistoryTest.testIdentityLinks.cmmn | 14 - ...cCmmnHistoryTest.testMilestoneReached.cmmn | 14 - ...CmmnHistoryTest.testPlanItemInstances.cmmn | 37 - ...temInstancesStateChangesWithFixedTime.cmmn | 91 - .../AsyncCmmnHistoryTest.testVariables.cmmn | 19 - .../cfg/ProcessEngineConfigurationImpl.java | 190 +- .../DefaultHistoryVariableManager.java | 13 - .../async/AbstractAsyncHistoryManager.java | 200 -- .../history/async/AsyncHistoryManager.java | 554 ------ .../history/async/HistoryJsonConstants.java | 244 --- .../AbstractHistoryJsonTransformer.java | 164 -- ...istoricActivityHistoryJsonTransformer.java | 31 - ...ProcessInstanceHistoryJsonTransformer.java | 37 - ...stractNeedsTaskHistoryJsonTransformer.java | 35 - ...istoricActivityHistoryJsonTransformer.java | 31 - ...ocessInstanceDeleteHistoryTransformer.java | 56 - .../ActivityEndHistoryJsonTransformer.java | 79 - .../ActivityFullHistoryJsonTransformer.java | 83 - .../ActivityStartHistoryJsonTransformer.java | 72 - .../ActivityUpdateHistoryJsonTransformer.java | 84 - ...tityLinkCreatedHistoryJsonTransformer.java | 67 - ...tityLinkDeletedHistoryJsonTransformer.java | 50 - ...ertiesSubmittedHistoryJsonTransformer.java | 93 - ...lVariableUpdateHistoryJsonTransformer.java | 120 -- ...toricUserTaskLogDeleteJsonTransformer.java | 53 - ...toricUserTaskLogRecordJsonTransformer.java | 68 - ...tityLinkCreatedHistoryJsonTransformer.java | 61 - ...tityLinkDeletedHistoryJsonTransformer.java | 50 - ...yByProcessDefinitionIdJsonTransformer.java | 51 - ...sInstanceDeleteHistoryJsonTransformer.java | 51 - ...cessInstanceEndHistoryJsonTransformer.java | 107 -- ...PropertyChangedHistoryJsonTransformer.java | 63 - ...ssInstanceStartHistoryJsonTransformer.java | 88 - ...ocessDefinitionHistoryJsonTransformer.java | 47 - ...ssInstanceStartHistoryJsonTransformer.java | 105 -- ...AssigneeChangedHistoryJsonTransformer.java | 102 - .../TaskCreatedHistoryJsonTransformer.java | 100 - .../TaskDeletedHistoryJsonTransformer.java | 45 - .../TaskEndedHistoryJsonTransformer.java | 139 -- ...askOwnerChangedHistoryJsonTransformer.java | 56 - ...PropertyChangedHistoryJsonTransformer.java | 78 - ...finitionCascadeHistoryJsonTransformer.java | 83 - ...VariableCreatedHistoryJsonTransformer.java | 92 - ...VariableRemovedHistoryJsonTransformer.java | 56 - ...VariableUpdatedHistoryJsonTransformer.java | 89 - .../history/async/AsyncHistoryTest.java | 1172 ------------ .../async/AsyncHistoryUpgradeTest.java | 401 ---- .../history/async/TestUpCounterDelegate.java | 26 - ...ryTest.testInclusiveGatewayEndTimeSet.bpmn | 158 -- ...yEventOnCallActivityWithOldData.bpmn20.xml | 22 - ...Test.testSimpleStraightThroughProcess.bpmn | 49 - .../async/testProcessWithTaskLevel.bpmn | 26 - .../async/testSTPWithCustomHistoryLevel.bpmn | 33 - .../async/testSTPWithInstanceLevel.bpmn | 29 - .../job/service/JobServiceConfiguration.java | 89 - .../async/AbstractAsyncHistoryJobHandler.java | 151 -- ...ncHistoryCommittedTransactionListener.java | 47 - .../history/async/AsyncHistoryJobHandler.java | 112 -- ...AsyncHistoryJobNotApplicableException.java | 30 - .../async/AsyncHistoryJobZippedHandler.java | 48 - .../history/async/AsyncHistoryListener.java | 27 - .../history/async/AsyncHistorySession.java | 159 -- ...orySessionCommandContextCloseListener.java | 166 -- .../async/AsyncHistorySessionFactory.java | 56 - .../async/DefaultAsyncHistoryJobProducer.java | 126 -- .../SpringAsyncHistoryExecutorTest.java | 75 - ...ingAsyncHistoryJobExecutorTest-context.xml | 77 - .../InternalHistoryVariableManager.java | 3 +- .../variable/service/impl/types/JsonType.java | 1 - .../service/impl/types/SerializableType.java | 1 - 127 files changed, 90 insertions(+), 12558 deletions(-) rename modules/{flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/transformer/HistoryJsonTransformer.java => flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/TestHistoryJobHandler.java} (53%) delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/AbstractAsyncCmmnHistoryManager.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/AsyncCmmnHistoryManager.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/CmmnAsyncHistoryConstants.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractNeedsHistoricCaseInstanceJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractPlanItemInstanceHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractTaskHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceEndHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceReactivateHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceStartHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateBusinessKeyHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateBusinessStatusHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateNameHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/EntityLinkCreatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/EntityLinkDeletedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricCaseInstanceDeletedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricUserTaskLogDeleteJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricUserTaskLogRecordJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/IdentityLinkCreatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/IdentityLinkDeletedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/MilestoneReachedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceAvailableHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceCompletedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceCreatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceDisabledHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceEnabledHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceExitHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceFullHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceOccurredHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceStartedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceSuspendedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceTerminatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskCreatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskDeletedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskEndedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskUpdatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/UpdateCaseDefinitionCascadeHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableCreatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableRemovedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableUpdatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.java delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.createRootEntityLink.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testBusinessKey.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCaseInstanceStartAndEnd.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCasePageTask.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCriterionStoredOnPlanItemInstance.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoricCaseInstanceDeleted.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoryJobFailure.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTask.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTaskWithCandidateUsersAndGroups.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testIdentityLinks.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testMilestoneReached.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testPlanItemInstances.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testPlanItemInstancesStateChangesWithFixedTime.cmmn delete mode 100644 modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testVariables.cmmn delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/AbstractAsyncHistoryManager.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/AsyncHistoryManager.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/HistoryJsonConstants.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsHistoricActivityHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsProcessInstanceHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsTaskHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsUnfinishedHistoricActivityHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractProcessInstanceDeleteHistoryTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityEndHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityFullHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityStartHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityUpdateHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/EntityLinkCreatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/EntityLinkDeletedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/FormPropertiesSubmittedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricDetailVariableUpdateHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricUserTaskLogDeleteJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricUserTaskLogRecordJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/IdentityLinkCreatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/IdentityLinkDeletedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceDeleteHistoryByProcessDefinitionIdJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceDeleteHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceEndHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstancePropertyChangedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceStartHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/SetProcessDefinitionHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/SubProcessInstanceStartHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskAssigneeChangedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskCreatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskDeletedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskEndedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskOwnerChangedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskPropertyChangedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/UpdateProcessDefinitionCascadeHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableCreatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableRemovedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableUpdatedHistoryJsonTransformer.java delete mode 100644 modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/AsyncHistoryTest.java delete mode 100644 modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/AsyncHistoryUpgradeTest.java delete mode 100644 modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/TestUpCounterDelegate.java delete mode 100644 modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testInclusiveGatewayEndTimeSet.bpmn delete mode 100644 modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testNonInterruptingTimerBoundaryEventOnCallActivityWithOldData.bpmn20.xml delete mode 100644 modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testSimpleStraightThroughProcess.bpmn delete mode 100644 modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testProcessWithTaskLevel.bpmn delete mode 100644 modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testSTPWithCustomHistoryLevel.bpmn delete mode 100644 modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testSTPWithInstanceLevel.bpmn delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AbstractAsyncHistoryJobHandler.java delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryCommittedTransactionListener.java delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobHandler.java delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobNotApplicableException.java delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobZippedHandler.java delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryListener.java delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySession.java delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySessionCommandContextCloseListener.java delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySessionFactory.java delete mode 100644 modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/DefaultAsyncHistoryJobProducer.java delete mode 100644 modules/flowable-spring/src/test/java/org/flowable/spring/test/jobexecutor/SpringAsyncHistoryExecutorTest.java delete mode 100644 modules/flowable-spring/src/test/resources/org/flowable/spring/test/components/SpringAsyncHistoryJobExecutorTest-context.xml diff --git a/modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/CmmnEngineConfigurator.java b/modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/CmmnEngineConfigurator.java index 0deb357f362..d20cebafa4c 100644 --- a/modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/CmmnEngineConfigurator.java +++ b/modules/flowable-cmmn-engine-configurator/src/main/java/org/flowable/cmmn/engine/configurator/CmmnEngineConfigurator.java @@ -125,9 +125,6 @@ protected void copyProcessEngineProperties(ProcessEngineConfigurationImpl proces // The job handlers will be added in the CmmnEngineConfiguration itself cmmnEngineConfiguration.setAsyncHistoryEnabled(true); cmmnEngineConfiguration.setAsyncHistoryExecutor(asyncHistoryExecutor); - cmmnEngineConfiguration.setAsyncHistoryJsonGroupingEnabled(processEngineConfiguration.isAsyncHistoryJsonGroupingEnabled()); - cmmnEngineConfiguration.setAsyncHistoryJsonGroupingThreshold(processEngineConfiguration.getAsyncHistoryJsonGroupingThreshold()); - cmmnEngineConfiguration.setAsyncHistoryJsonGzipCompressionEnabled(processEngineConfiguration.isAsyncHistoryJsonGzipCompressionEnabled()); cmmnEngineConfiguration.setAsyncHistoryTaskExecutor(processEngineConfiguration.getAsyncHistoryTaskExecutor()); diff --git a/modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/CmmnEngineConfiguratorAsyncHistoryTest.java b/modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/CmmnEngineConfiguratorAsyncHistoryTest.java index c8101b23b82..cddc348f5cd 100644 --- a/modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/CmmnEngineConfiguratorAsyncHistoryTest.java +++ b/modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/CmmnEngineConfiguratorAsyncHistoryTest.java @@ -14,18 +14,17 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.flowable.cmmn.api.runtime.PlanItemInstanceState; import org.flowable.cmmn.engine.CmmnEngine; import org.flowable.cmmn.engine.CmmnEngines; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; import org.flowable.cmmn.engine.test.impl.CmmnJobTestHelper; import org.flowable.common.engine.api.async.AsyncTaskExecutor; import org.flowable.engine.ProcessEngine; import org.flowable.engine.ProcessEngineConfiguration; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.job.api.HistoryJob; +import org.flowable.engine.impl.util.CommandContextUtil; +import org.flowable.job.service.HistoryJobService; import org.flowable.job.service.JobServiceConfiguration; import org.flowable.job.service.impl.asyncexecutor.AsyncExecutor; +import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -54,9 +53,6 @@ public void cleanup() { .createDeploymentQuery() .list() .forEach(deployment -> cmmnEngine.getCmmnRepositoryService().deleteDeployment(deployment.getId(), true)); - // Execute history jobs for the delete deployments - processEngine.getManagementService().createHistoryJobQuery().list() - .forEach(historyJob -> processEngine.getManagementService().executeHistoryJob(historyJob.getId())); cmmnEngine.close(); processEngine.close(); @@ -79,66 +75,48 @@ public void testSharedAsyncHistoryExecutor() { assertThat(processEngine.getProcessEngineConfiguration().getAsyncHistoryExecutor().getJobServiceConfiguration().getHistoryJobExecutionScope()) .isEqualTo(JobServiceConfiguration.JOB_EXECUTION_SCOPE_ALL); - // 2 job handlers / engine - assertThat(processEngineAsyncExecutor.getJobServiceConfiguration().getHistoryJobHandlers()).hasSize(4); - - // Deploy and start test processes/cases - // Trigger one plan item instance to start the process - processEngine.getRepositoryService().createDeployment().addClasspathResource("org/flowable/cmmn/test/oneTaskProcess.bpmn20.xml").deploy(); - cmmnEngine.getCmmnRepositoryService().createDeployment() - .addClasspathResource("org/flowable/cmmn/test/ProcessTaskTest.testOneTaskProcessNonBlocking.cmmn").deploy(); - cmmnEngine.getCmmnRuntimeService().createCaseInstanceBuilder().caseDefinitionKey("myCase").start(); - cmmnEngine.getCmmnRuntimeService().triggerPlanItemInstance( - cmmnEngine.getCmmnRuntimeService().createPlanItemInstanceQuery().planItemInstanceState(PlanItemInstanceState.ACTIVE).singleResult().getId()); - - // As async history is enabled, there should be no historical entries yet, but there should be history jobs - assertThat(cmmnEngine.getCmmnHistoryService().createHistoricCaseInstanceQuery().count()).isZero(); - assertThat(processEngine.getHistoryService().createHistoricProcessInstanceQuery().count()).isZero(); - - // 3 history jobs expected: - // - one for the case instance start - // - one for the plan item instance trigger - // - one for the process instance start - assertThat(cmmnEngine.getCmmnManagementService().createHistoryJobQuery().count()).isEqualTo(3); - assertThat(processEngine.getManagementService().createHistoryJobQuery().count()).isEqualTo(3); - - // Expected 2 jobs originating from the cmmn engine and 1 for the process engine - int cmmnHistoryJobs = 0; - int bpmnHistoryJobs = 0; - for (HistoryJob historyJob : cmmnEngine.getCmmnManagementService().createHistoryJobQuery().list()) { - if (historyJob.getJobHandlerType().equals(CmmnAsyncHistoryConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY) - || historyJob.getJobHandlerType().equals(CmmnAsyncHistoryConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED)) { - cmmnHistoryJobs++; - } else if (historyJob.getJobHandlerType().equals(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY) - || historyJob.getJobHandlerType().equals(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED)) { - bpmnHistoryJobs++; - } - - // Execution scope should be all (see the CmmnEngineConfigurator) - assertThat(historyJob.getScopeType()).isEqualTo(JobServiceConfiguration.JOB_EXECUTION_SCOPE_ALL); - } - assertThat(bpmnHistoryJobs).isEqualTo(1); - assertThat(cmmnHistoryJobs).isEqualTo(2); + // 1 job handlers / engine + assertThat(processEngineAsyncExecutor.getJobServiceConfiguration().getHistoryJobHandlers()) + .containsOnlyKeys("bpmn-test-history-job-handler", "cmmn-test-history-job-handler"); + + processEngine.getManagementService() + .executeCommand(commandContext -> { + HistoryJobService historyJobService = CommandContextUtil.getProcessEngineConfiguration(commandContext) + .getJobServiceConfiguration() + .getHistoryJobService(); + + HistoryJobEntity historyJob = historyJobService.createHistoryJob(); + historyJob.setScopeType(JobServiceConfiguration.JOB_EXECUTION_SCOPE_ALL); + historyJob.setJobHandlerType("bpmn-test-history-job-handler"); + historyJob.setRetries(3); + historyJob.setCreateTime(commandContext.getClock().getCurrentTime()); + historyJobService.scheduleHistoryJob(historyJob); + return null; + }); + + cmmnEngine.getCmmnEngineConfiguration() + .getCommandExecutor() + .execute(commandContext -> { + HistoryJobService historyJobService = org.flowable.cmmn.engine.impl.util.CommandContextUtil.getCmmnEngineConfiguration(commandContext) + .getJobServiceConfiguration() + .getHistoryJobService(); + + HistoryJobEntity historyJob = historyJobService.createHistoryJob(); + historyJob.setScopeType(JobServiceConfiguration.JOB_EXECUTION_SCOPE_ALL); + historyJob.setJobHandlerType("cmmn-test-history-job-handler"); + historyJob.setRetries(3); + historyJob.setCreateTime(commandContext.getClock().getCurrentTime()); + historyJobService.scheduleHistoryJob(historyJob); + return null; + }); + + assertThat(cmmnEngine.getCmmnManagementService().createHistoryJobQuery().count()).isEqualTo(2); + assertThat(processEngine.getManagementService().createHistoryJobQuery().count()).isEqualTo(2); // Starting the async history executor should process all of these CmmnJobTestHelper.waitForAsyncHistoryExecutorToProcessAllJobs(cmmnEngine.getCmmnEngineConfiguration(), 10000L, 200L, true); - assertThat(cmmnEngine.getCmmnHistoryService().createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(processEngine.getHistoryService().createHistoricProcessInstanceQuery().count()).isEqualTo(1); assertThat(cmmnEngine.getCmmnManagementService().createHistoryJobQuery().count()).isZero(); assertThat(processEngine.getManagementService().createHistoryJobQuery().count()).isZero(); } - - @Test - public void testProcessAsyncHistoryNotChanged() { - // This test validates that the shared async history executor does not intervene when running a process regularly - processEngine.getRepositoryService().createDeployment().addClasspathResource("org/flowable/cmmn/test/oneTaskProcess.bpmn20.xml").deploy(); - processEngine.getRuntimeService().startProcessInstanceByKey("oneTask"); - assertThat(processEngine.getManagementService().createHistoryJobQuery().count()).isEqualTo(1); - - HistoryJob historyJob = processEngine.getManagementService().createHistoryJobQuery().singleResult(); - assertThat(historyJob.getJobHandlerType()).isEqualTo(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY); - processEngine.getManagementService().executeHistoryJob(historyJob.getId()); - } - } diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/transformer/HistoryJsonTransformer.java b/modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/TestHistoryJobHandler.java similarity index 53% rename from modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/transformer/HistoryJsonTransformer.java rename to modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/TestHistoryJobHandler.java index ce8546e4a42..94b52747e57 100644 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/transformer/HistoryJsonTransformer.java +++ b/modules/flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/TestHistoryJobHandler.java @@ -1,33 +1,40 @@ /* 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.job.service.impl.history.async.transformer; - -import java.util.List; +package org.flowable.cmmn.test; import org.flowable.common.engine.impl.interceptor.CommandContext; +import org.flowable.job.service.HistoryJobHandler; +import org.flowable.job.service.JobServiceConfiguration; import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import com.fasterxml.jackson.databind.node.ObjectNode; +/** + * @author Filip Hrisafov + */ +public class TestHistoryJobHandler implements HistoryJobHandler { -public interface HistoryJsonTransformer { - - String FIELD_NAME_TYPE = "type"; - String FIELD_NAME_DATA = "data"; + protected final String type; - List getTypes(); + public TestHistoryJobHandler(String type) { + this.type = type; + } - boolean isApplicable(ObjectNode historicalData, CommandContext commandContext); + @Override + public String getType() { + return type; + } - void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext); + @Override + public void execute(HistoryJobEntity job, String configuration, CommandContext commandContext, JobServiceConfiguration jobServiceConfiguration) { + } } diff --git a/modules/flowable-cmmn-engine-configurator/src/test/resources/flowable.async.history.cfg.xml b/modules/flowable-cmmn-engine-configurator/src/test/resources/flowable.async.history.cfg.xml index cf938e13685..7ed63308120 100644 --- a/modules/flowable-cmmn-engine-configurator/src/test/resources/flowable.async.history.cfg.xml +++ b/modules/flowable-cmmn-engine-configurator/src/test/resources/flowable.async.history.cfg.xml @@ -20,6 +20,20 @@ + + + + + + + + + + + + + + @@ -34,8 +48,6 @@ - - @@ -43,7 +55,15 @@ - + + + + + + + + + diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/CmmnEngineConfiguration.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/CmmnEngineConfiguration.java index 10e91884c57..214085deb13 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/CmmnEngineConfiguration.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/CmmnEngineConfiguration.java @@ -94,41 +94,6 @@ import org.flowable.cmmn.engine.impl.history.CmmnHistoryVariableManager; import org.flowable.cmmn.engine.impl.history.DefaultCmmnHistoryConfigurationSettings; import org.flowable.cmmn.engine.impl.history.DefaultCmmnHistoryManager; -import org.flowable.cmmn.engine.impl.history.async.AsyncCmmnHistoryManager; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.CaseInstanceEndHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.CaseInstanceReactivateHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.CaseInstanceStartHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.CaseInstanceUpdateBusinessKeyHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.CaseInstanceUpdateBusinessStatusHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.CaseInstanceUpdateNameHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.EntityLinkCreatedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.EntityLinkDeletedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.HistoricCaseInstanceDeletedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.HistoricUserTaskLogDeleteJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.HistoricUserTaskLogRecordJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.IdentityLinkCreatedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.IdentityLinkDeletedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.MilestoneReachedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceAvailableHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceCompletedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceCreatedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceDisabledHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceEnabledHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceExitHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceFullHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceOccurredHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceStartedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceSuspendedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.PlanItemInstanceTerminatedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.TaskCreatedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.TaskDeletedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.TaskEndedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.TaskUpdatedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.UpdateCaseDefinitionCascadeHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.VariableCreatedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.VariableRemovedHistoryJsonTransformer; -import org.flowable.cmmn.engine.impl.history.async.json.transformer.VariableUpdatedHistoryJsonTransformer; import org.flowable.cmmn.engine.impl.idm.DefaultCandidateManager; import org.flowable.cmmn.engine.impl.interceptor.CmmnCommandInvoker; import org.flowable.cmmn.engine.impl.interceptor.DefaultCmmnIdentityLinkInterceptor; @@ -321,13 +286,6 @@ import org.flowable.job.service.impl.asyncexecutor.FailedJobCommandFactory; import org.flowable.job.service.impl.asyncexecutor.JobManager; import org.flowable.job.service.impl.db.JobDbSchemaManager; -import org.flowable.job.service.impl.history.async.AsyncHistoryJobHandler; -import org.flowable.job.service.impl.history.async.AsyncHistoryJobZippedHandler; -import org.flowable.job.service.impl.history.async.AsyncHistoryListener; -import org.flowable.job.service.impl.history.async.AsyncHistorySession; -import org.flowable.job.service.impl.history.async.AsyncHistorySessionFactory; -import org.flowable.job.service.impl.history.async.DefaultAsyncHistoryJobProducer; -import org.flowable.job.service.impl.history.async.transformer.HistoryJsonTransformer; import org.flowable.mail.common.api.client.FlowableMailClient; import org.flowable.task.service.InternalTaskAssignmentManager; import org.flowable.task.service.InternalTaskVariableScopeResolver; @@ -652,10 +610,6 @@ public class CmmnEngineConfiguration extends AbstractEngineConfiguration impleme protected boolean shutdownAsyncHistoryTaskExecutor; protected boolean isAsyncHistoryEnabled; protected boolean asyncHistoryExecutorActivate; - protected boolean isAsyncHistoryJsonGzipCompressionEnabled; - protected boolean isAsyncHistoryJsonGroupingEnabled; - protected int asyncHistoryJsonGroupingThreshold = 10; - protected AsyncHistoryListener asyncHistoryListener; // More info: see similar async executor properties. protected int asyncHistoryExecutorNumberOfRetries = 10; @@ -672,7 +626,6 @@ public class CmmnEngineConfiguration extends AbstractEngineConfiguration impleme protected Map historyJobHandlers; protected List customHistoryJobHandlers; - protected List customHistoryJsonTransformers; protected FormFieldHandler formFieldHandler; protected boolean isFormFieldValidationEnabled; @@ -1058,34 +1011,12 @@ public void initCommandInvoker() { public void initSessionFactories() { super.initSessionFactories(); addSessionFactory(new CmmnEngineAgendaSessionFactory(cmmnEngineAgendaFactory)); - - if (isAsyncHistoryEnabled) { - initAsyncHistorySessionFactory(); - } if (!sessionFactories.containsKey(VariableListenerSession.class)) { VariableListenerSessionFactory variableListenerSessionFactory = new VariableListenerSessionFactory(); sessionFactories.put(VariableListenerSession.class, variableListenerSessionFactory); } } - - public void initAsyncHistorySessionFactory() { - // If another engine has set the asyncHistorySessionFactory already, there's no need to do it again. - if (!sessionFactories.containsKey(AsyncHistorySession.class)) { - AsyncHistorySessionFactory asyncHistorySessionFactory = new AsyncHistorySessionFactory(); - if (asyncHistoryListener == null) { - initDefaultAsyncHistoryListener(); - } - asyncHistorySessionFactory.setAsyncHistoryListener(asyncHistoryListener); - sessionFactories.put(AsyncHistorySession.class, asyncHistorySessionFactory); - } - - ((AsyncHistorySessionFactory) sessionFactories.get(AsyncHistorySession.class)).registerJobDataTypes(CmmnAsyncHistoryConstants.ORDERED_TYPES); - } - - protected void initDefaultAsyncHistoryListener() { - asyncHistoryListener = new DefaultAsyncHistoryJobProducer(); - } protected void initServices() { initService(cmmnRuntimeService); @@ -1365,11 +1296,7 @@ public void initHistoryConfigurationSettings() { public void initHistoryManager() { if (cmmnHistoryManager == null) { - if (isAsyncHistoryEnabled) { - cmmnHistoryManager = new AsyncCmmnHistoryManager(this); - } else { - cmmnHistoryManager = new DefaultCmmnHistoryManager(this); - } + cmmnHistoryManager = new DefaultCmmnHistoryManager(this); } } @@ -1735,21 +1662,6 @@ public void initJobHandlers() { protected void initHistoryJobHandlers() { if (isAsyncHistoryEnabled) { historyJobHandlers = new HashMap<>(); - - List allHistoryJsonTransformers = new ArrayList<>(initDefaultHistoryJsonTransformers()); - if (customHistoryJsonTransformers != null) { - allHistoryJsonTransformers.addAll(customHistoryJsonTransformers); - } - - AsyncHistoryJobHandler asyncHistoryJobHandler = new AsyncHistoryJobHandler(CmmnAsyncHistoryConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY); - allHistoryJsonTransformers.forEach(asyncHistoryJobHandler::addHistoryJsonTransformer); - asyncHistoryJobHandler.setAsyncHistoryJsonGroupingEnabled(isAsyncHistoryJsonGroupingEnabled); - historyJobHandlers.put(asyncHistoryJobHandler.getType(), asyncHistoryJobHandler); - - AsyncHistoryJobZippedHandler asyncHistoryJobZippedHandler = new AsyncHistoryJobZippedHandler(CmmnAsyncHistoryConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED); - allHistoryJsonTransformers.forEach(asyncHistoryJobZippedHandler::addHistoryJsonTransformer); - asyncHistoryJobZippedHandler.setAsyncHistoryJsonGroupingEnabled(isAsyncHistoryJsonGroupingEnabled); - historyJobHandlers.put(asyncHistoryJobZippedHandler.getType(), asyncHistoryJobZippedHandler); if (getCustomHistoryJobHandlers() != null) { for (HistoryJobHandler customJobHandler : getCustomHistoryJobHandlers()) { @@ -1758,54 +1670,6 @@ protected void initHistoryJobHandlers() { } } } - - protected List initDefaultHistoryJsonTransformers() { - List historyJsonTransformers = new ArrayList<>(); - - historyJsonTransformers.add(new CaseInstanceStartHistoryJsonTransformer(this)); - historyJsonTransformers.add(new CaseInstanceEndHistoryJsonTransformer(this)); - historyJsonTransformers.add(new CaseInstanceReactivateHistoryJsonTransformer(this)); - historyJsonTransformers.add(new CaseInstanceUpdateNameHistoryJsonTransformer(this)); - historyJsonTransformers.add(new CaseInstanceUpdateBusinessKeyHistoryJsonTransformer(this)); - historyJsonTransformers.add(new CaseInstanceUpdateBusinessStatusHistoryJsonTransformer(this)); - historyJsonTransformers.add(new HistoricCaseInstanceDeletedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new MilestoneReachedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new IdentityLinkCreatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new IdentityLinkDeletedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new EntityLinkCreatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new EntityLinkDeletedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new VariableCreatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new VariableUpdatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new VariableRemovedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new TaskCreatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new TaskUpdatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new TaskEndedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new TaskDeletedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new PlanItemInstanceFullHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceAvailableHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceCompletedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceCreatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceDisabledHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceEnabledHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceExitHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceOccurredHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceStartedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceSuspendedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new PlanItemInstanceTerminatedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new UpdateCaseDefinitionCascadeHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new HistoricUserTaskLogRecordJsonTransformer(this)); - historyJsonTransformers.add(new HistoricUserTaskLogDeleteJsonTransformer(this)); - - return historyJsonTransformers; - } public void initFailedJobCommandFactory() { if (this.failedJobCommandFactory == null) { @@ -1856,14 +1720,7 @@ public void configureJobServiceConfiguration() { } else { this.jobServiceConfiguration.setInternalJobManager(new DefaultInternalCmmnJobManager(this)); } - - // Async history job config - jobServiceConfiguration.setJobTypeAsyncHistory(CmmnAsyncHistoryConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY); - jobServiceConfiguration.setJobTypeAsyncHistoryZipped(CmmnAsyncHistoryConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED); - jobServiceConfiguration.setAsyncHistoryJsonGzipCompressionEnabled(isAsyncHistoryJsonGzipCompressionEnabled); - jobServiceConfiguration.setAsyncHistoryJsonGroupingEnabled(isAsyncHistoryJsonGroupingEnabled); - jobServiceConfiguration.setAsyncHistoryJsonGroupingThreshold(asyncHistoryJsonGroupingThreshold); - + this.jobServiceConfiguration.setJobExecutionScope(this.jobExecutionScope); this.jobServiceConfiguration.setHistoryJobExecutionScope(this.historyJobExecutionScope); @@ -1993,7 +1850,7 @@ public void initAsyncHistoryExecutor() { if (asyncHistoryExecutor == null) { DefaultAsyncHistoryJobExecutor defaultAsyncHistoryExecutor = new DefaultAsyncHistoryJobExecutor(getOrCreateAsyncHistoryExecutorConfiguration()); - + asyncHistoryExecutor = defaultAsyncHistoryExecutor; if (asyncHistoryExecutor.getJobServiceConfiguration() == null) { @@ -2007,7 +1864,7 @@ public void initAsyncHistoryExecutor() { if (asyncHistoryExecutor.getJobServiceConfiguration() == null) { asyncHistoryExecutor.setJobServiceConfiguration(jobServiceConfiguration); } - historyJobHandlers.forEach((type, handler) -> { asyncHistoryExecutor.getJobServiceConfiguration().mergeHistoryJobHandler(handler); }); + historyJobHandlers.forEach((type, handler) -> asyncHistoryExecutor.getJobServiceConfiguration().addHistoryJobHandler(type, handler)); } } @@ -3769,45 +3626,6 @@ public CmmnEngineConfiguration setAsyncHistoryExecutorActivate(boolean asyncHist return this; } - public boolean isAsyncHistoryJsonGzipCompressionEnabled() { - return isAsyncHistoryJsonGzipCompressionEnabled; - } - - public CmmnEngineConfiguration setAsyncHistoryJsonGzipCompressionEnabled(boolean isAsyncHistoryJsonGzipCompressionEnabled) { - this.isAsyncHistoryJsonGzipCompressionEnabled = isAsyncHistoryJsonGzipCompressionEnabled; - return this; - } - - public boolean isAsyncHistoryJsonGroupingEnabled() { - return isAsyncHistoryJsonGroupingEnabled; - } - - public CmmnEngineConfiguration setAsyncHistoryJsonGroupingEnabled(boolean isAsyncHistoryJsonGroupingEnabled) { - this.isAsyncHistoryJsonGroupingEnabled = isAsyncHistoryJsonGroupingEnabled; - return this; - } - - public int getAsyncHistoryJsonGroupingThreshold() { - return asyncHistoryJsonGroupingThreshold; - } - - public CmmnEngineConfiguration setAsyncHistoryJsonGroupingThreshold(int asyncHistoryJsonGroupingThreshold) { - this.asyncHistoryJsonGroupingThreshold = asyncHistoryJsonGroupingThreshold; - return this; - } - - public AsyncHistoryListener getAsyncHistoryListener() { - if (asyncHistoryListener == null) { - asyncHistoryListener = new DefaultAsyncHistoryJobProducer(); - } - return asyncHistoryListener; - } - - public CmmnEngineConfiguration setAsyncHistoryListener(AsyncHistoryListener asyncHistoryListener) { - this.asyncHistoryListener = asyncHistoryListener; - return this; - } - public int getAsyncHistoryExecutorNumberOfRetries() { return asyncHistoryExecutorNumberOfRetries; } @@ -4128,15 +3946,6 @@ public CmmnEngineConfiguration setCustomHistoryJobHandlers(List getCustomHistoryJsonTransformers() { - return customHistoryJsonTransformers; - } - - public CmmnEngineConfiguration setCustomHistoryJsonTransformers(List customHistoryJsonTransformers) { - this.customHistoryJsonTransformers = customHistoryJsonTransformers; - return this; - } - public List getEnabledJobCategories() { return enabledJobCategories; } diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/CmmnHistoryVariableManager.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/CmmnHistoryVariableManager.java index 4527e505dc5..8a5802be799 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/CmmnHistoryVariableManager.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/CmmnHistoryVariableManager.java @@ -15,10 +15,6 @@ import java.util.Date; import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.util.CommandContextUtil; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.history.async.AsyncHistorySession; -import org.flowable.job.service.impl.history.async.AsyncHistorySessionCommandContextCloseListener; import org.flowable.variable.service.history.InternalHistoryVariableManager; import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity; @@ -49,12 +45,4 @@ public void recordVariableRemoved(VariableInstanceEntity variable, Date removeTi cmmnEngineConfiguration.getCmmnHistoryManager().recordVariableRemoved(variable); } - @Override - public void initAsyncHistoryCommandContextCloseListener() { - if (cmmnEngineConfiguration.isAsyncHistoryEnabled()) { - CommandContext commandContext = CommandContextUtil.getCommandContext(); - commandContext.addCloseListener(new AsyncHistorySessionCommandContextCloseListener( - commandContext.getSession(AsyncHistorySession.class), cmmnEngineConfiguration.getAsyncHistoryListener())); - } - } } diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/AbstractAsyncCmmnHistoryManager.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/AbstractAsyncCmmnHistoryManager.java deleted file mode 100644 index 163ee71831e..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/AbstractAsyncCmmnHistoryManager.java +++ /dev/null @@ -1,341 +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.cmmn.engine.impl.history.async; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.convertToBase64; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.putIfNotNull; - -import java.util.Date; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.cmmn.api.repository.CaseDefinition; -import org.flowable.cmmn.api.runtime.CaseInstance; -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.CmmnHistoryConfigurationSettings; -import org.flowable.cmmn.engine.impl.history.CmmnHistoryManager; -import org.flowable.cmmn.engine.impl.persistence.entity.CaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.MilestoneInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.PlanItemInstanceEntity; -import org.flowable.cmmn.engine.impl.repository.CaseDefinitionUtil; -import org.flowable.cmmn.model.Milestone; -import org.flowable.cmmn.model.PlanItemDefinition; -import org.flowable.cmmn.model.Stage; -import org.flowable.common.engine.api.FlowableException; -import org.flowable.common.engine.api.delegate.Expression; -import org.flowable.common.engine.api.scope.ScopeTypes; -import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity; -import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity; -import org.flowable.task.api.history.HistoricTaskLogEntryBuilder; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Filip Hrisafov - */ -public abstract class AbstractAsyncCmmnHistoryManager implements CmmnHistoryManager { - - protected CmmnEngineConfiguration cmmnEngineConfiguration; - - public AbstractAsyncCmmnHistoryManager(CmmnEngineConfiguration cmmnEngineConfiguration) { - this.cmmnEngineConfiguration = cmmnEngineConfiguration; - } - - protected CmmnHistoryConfigurationSettings getHistoryConfigurationSettings() { - return cmmnEngineConfiguration.getCmmnHistoryConfigurationSettings(); - } - - protected void addCommonCaseInstanceFields(CaseInstanceEntity caseInstanceEntity, ObjectNode data) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, caseInstanceEntity.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, caseInstanceEntity.getRevision()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_NAME, caseInstanceEntity.getName()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_STATE, caseInstanceEntity.getState()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_BUSINESS_KEY, caseInstanceEntity.getBusinessKey()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_BUSINESS_STATUS, caseInstanceEntity.getBusinessStatus()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PARENT_ID, caseInstanceEntity.getParentId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID, caseInstanceEntity.getCaseDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_START_USER_ID, caseInstanceEntity.getStartUserId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_START_TIME, caseInstanceEntity.getStartTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CALLBACK_ID, caseInstanceEntity.getCallbackId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CALLBACK_TYPE, caseInstanceEntity.getCallbackType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REFERENCE_ID, caseInstanceEntity.getReferenceId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REFERENCE_TYPE, caseInstanceEntity.getReferenceType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TENANT_ID, caseInstanceEntity.getTenantId()); - - if (caseInstanceEntity.getCaseDefinitionId() != null) { - CaseDefinition caseDefinition = CaseDefinitionUtil.getCaseDefinition(caseInstanceEntity.getCaseDefinitionId()); - addCaseDefinitionFields(data, caseDefinition); - } - } - - protected void addCommonHistoricCaseInstanceFields(HistoricCaseInstanceEntity historicCaseInstanceEntity, ObjectNode data) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, historicCaseInstanceEntity.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, historicCaseInstanceEntity.getRevision()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_NAME, historicCaseInstanceEntity.getName()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_STATE, historicCaseInstanceEntity.getState()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_BUSINESS_KEY, historicCaseInstanceEntity.getBusinessKey()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_BUSINESS_STATUS, historicCaseInstanceEntity.getBusinessStatus()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PARENT_ID, historicCaseInstanceEntity.getParentId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID, historicCaseInstanceEntity.getCaseDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_START_USER_ID, historicCaseInstanceEntity.getStartUserId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_START_TIME, historicCaseInstanceEntity.getStartTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TENANT_ID, historicCaseInstanceEntity.getTenantId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CALLBACK_ID, historicCaseInstanceEntity.getCallbackId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CALLBACK_TYPE, historicCaseInstanceEntity.getCallbackType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REFERENCE_ID, historicCaseInstanceEntity.getReferenceId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REFERENCE_TYPE, historicCaseInstanceEntity.getReferenceType()); - - if (historicCaseInstanceEntity.getCaseDefinitionId() != null) { - addCaseDefinitionFields(data, CaseDefinitionUtil.getCaseDefinition(historicCaseInstanceEntity.getCaseDefinitionId())); - } - } - - protected void addCaseDefinitionFields(ObjectNode data, CaseDefinition caseDefinition) { - if (caseDefinition != null) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID, caseDefinition.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_CATEGORY, caseDefinition.getCategory()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_DEPLOYMENT_ID, caseDefinition.getDeploymentId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_DESCRIPTION, caseDefinition.getDescription()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_KEY, caseDefinition.getKey()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_NAME, caseDefinition.getName()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_VERSION, caseDefinition.getVersion()); - } - } - - protected void addCommonIdentityLinkFields(IdentityLinkEntity identityLink, ObjectNode data) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, identityLink.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_GROUP_ID, identityLink.getGroupId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_DEFINITION_ID, identityLink.getScopeDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID, identityLink.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID, identityLink.getSubScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID, identityLink.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE, identityLink.getScopeType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID, identityLink.getScopeDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TASK_ID, identityLink.getTaskId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PROCESS_INSTANCE_ID, identityLink.getProcessInstanceId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_IDENTITY_LINK_TYPE, identityLink.getType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_USER_ID, identityLink.getUserId()); - } - - protected void addCommonEntityLinkFields(EntityLinkEntity entityLink, ObjectNode data) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, entityLink.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ENTITY_LINK_TYPE, entityLink.getLinkType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME, entityLink.getCreateTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID, entityLink.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID, entityLink.getSubScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE, entityLink.getScopeType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_DEFINITION_ID, entityLink.getScopeDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PARENT_ELEMENT_ID, entityLink.getParentElementId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REF_SCOPE_ID, entityLink.getReferenceScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REF_SCOPE_TYPE, entityLink.getReferenceScopeType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REF_SCOPE_DEFINITION_ID, entityLink.getReferenceScopeDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ROOT_SCOPE_ID, entityLink.getRootScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ROOT_SCOPE_TYPE, entityLink.getRootScopeType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_HIERARCHY_TYPE, entityLink.getHierarchyType()); - } - - protected void addCommonTaskFields(TaskEntity task, ObjectNode data) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, task.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, task.getRevision()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_NAME, task.getName()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PARENT_TASK_ID, task.getParentTaskId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_DESCRIPTION, task.getDescription()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_OWNER, task.getOwner()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ASSIGNEE, task.getAssignee()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME, task.getCreateTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TASK_DEFINITION_KEY, task.getTaskDefinitionKey()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TASK_DEFINITION_ID, task.getTaskDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PRIORITY, task.getPriority()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_DUE_DATE, task.getDueDate()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CATEGORY, task.getCategory()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_FORM_KEY, task.getFormKey()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TENANT_ID, task.getTenantId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CLAIM_TIME, task.getClaimTime()); - - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID, task.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID, task.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID, task.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID, task.getSubScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PLAN_ITEM_INSTANCE_ID, task.getSubScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE, task.getScopeType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_DEFINITION_ID, task.getScopeDefinitionId()); - - if (task.getScopeDefinitionId() != null) { - addCaseDefinitionFields(data, CaseDefinitionUtil.getCaseDefinition(task.getScopeDefinitionId())); - } - } - - protected void addCommonPlanItemInstanceFields(PlanItemInstanceEntity planItemInstanceEntity, ObjectNode data) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, planItemInstanceEntity.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, planItemInstanceEntity.getRevision()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_NAME, planItemInstanceEntity.getName()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_STATE, planItemInstanceEntity.getState()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID, planItemInstanceEntity.getCaseDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID, planItemInstanceEntity.getCaseInstanceId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_STAGE_INSTANCE_ID, planItemInstanceEntity.getStageInstanceId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_IS_STAGE, planItemInstanceEntity.isStage()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ELEMENT_ID, planItemInstanceEntity.getElementId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PLAN_ITEM_DEFINITION_ID, planItemInstanceEntity.getPlanItemDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PLAN_ITEM_DEFINITION_TYPE, planItemInstanceEntity.getPlanItemDefinitionType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_START_USER_ID, planItemInstanceEntity.getStartUserId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME, planItemInstanceEntity.getCreateTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REFERENCE_ID, planItemInstanceEntity.getReferenceId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REFERENCE_TYPE, planItemInstanceEntity.getReferenceType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ENTRY_CRITERION_ID, planItemInstanceEntity.getEntryCriterionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_EXIT_CRITERION_ID, planItemInstanceEntity.getExitCriterionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_EXTRA_VALUE, planItemInstanceEntity.getExtraValue()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TENANT_ID, planItemInstanceEntity.getTenantId()); - - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_AVAILABLE_TIME, planItemInstanceEntity.getLastAvailableTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_UNAVAILABLE_TIME, planItemInstanceEntity.getLastUnavailableTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_ENABLED_TIME, planItemInstanceEntity.getLastEnabledTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_DISABLED_TIME, planItemInstanceEntity.getLastDisabledTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_STARTED_TIME, planItemInstanceEntity.getLastStartedTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_SUSPENDED_TIME, planItemInstanceEntity.getLastSuspendedTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_COMPLETED_TIME, planItemInstanceEntity.getCompletedTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_OCCURRED_TIME, planItemInstanceEntity.getOccurredTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TERMINATED_TIME, planItemInstanceEntity.getTerminatedTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_EXIT_TIME, planItemInstanceEntity.getExitTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_END_TIME, planItemInstanceEntity.getEndedTime()); - - if (planItemInstanceEntity.getCaseDefinitionId() != null) { - addCaseDefinitionFields(data, CaseDefinitionUtil.getCaseDefinition(planItemInstanceEntity.getCaseDefinitionId())); - } - } - - protected void addCommonMilestoneInstanceFields(MilestoneInstanceEntity milestoneInstanceEntity, ObjectNode data) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, milestoneInstanceEntity.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, milestoneInstanceEntity.getRevision()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_NAME, milestoneInstanceEntity.getName()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID, milestoneInstanceEntity.getCaseInstanceId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID, milestoneInstanceEntity.getCaseDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ELEMENT_ID, milestoneInstanceEntity.getElementId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME, milestoneInstanceEntity.getTimeStamp()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TENANT_ID, milestoneInstanceEntity.getTenantId()); - - if (milestoneInstanceEntity.getCaseDefinitionId() != null) { - addCaseDefinitionFields(data, CaseDefinitionUtil.getCaseDefinition(milestoneInstanceEntity.getCaseDefinitionId())); - } - } - - protected void addCommonVariableFields(VariableInstanceEntity variable, ObjectNode data, Date time) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, variable.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TASK_ID, variable.getTaskId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, variable.getRevision()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_NAME, variable.getName()); - - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_EXECUTION_ID, variable.getExecutionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PROCESS_INSTANCE_ID, variable.getProcessInstanceId()); - - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID, variable.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID, variable.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID, variable.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID, variable.getSubScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_PLAN_ITEM_INSTANCE_ID, variable.getSubScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE, variable.getScopeType()); - - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME, time); - - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_VARIABLE_TYPE, variable.getType().getTypeName()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_VARIABLE_TEXT_VALUE, variable.getTextValue()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_VARIABLE_TEXT_VALUE2, variable.getTextValue2()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_VARIABLE_DOUBLE_VALUE, variable.getDoubleValue()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_VARIABLE_LONG_VALUE, variable.getLongValue()); - if (variable.getByteArrayRef() != null) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_VARIABLE_BYTES_VALUE, convertToBase64(variable)); - } - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_META_INFO, variable.getMetaInfo()); - - if (variable.getScopeId() != null && ScopeTypes.CMMN.equals(variable.getScopeType())) { - CaseInstance caseInstance = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(variable.getScopeId()); - addCaseDefinitionFields(data, CaseDefinitionUtil.getCaseDefinition(caseInstance.getCaseDefinitionId())); - } - } - - protected void addCommonHistoricTaskLogEntryFields(HistoricTaskLogEntryBuilder taskLogEntryBuilder, ObjectNode data) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LOG_ENTRY_DATA, taskLogEntryBuilder.getData()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID, taskLogEntryBuilder.getScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE, taskLogEntryBuilder.getScopeType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID, taskLogEntryBuilder.getSubScopeId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_SCOPE_DEFINITION_ID, taskLogEntryBuilder.getScopeDefinitionId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TASK_ID, taskLogEntryBuilder.getTaskId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_TENANT_ID, taskLogEntryBuilder.getTenantId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME, taskLogEntryBuilder.getTimeStamp()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LOG_ENTRY_TYPE, taskLogEntryBuilder.getType()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_USER_ID, taskLogEntryBuilder.getUserId()); - } - - protected CaseDefinition getCaseDefinition(IdentityLinkEntity identityLink) { - String caseDefinitionId = null; - if (ScopeTypes.CMMN.equals(identityLink.getScopeType()) && identityLink.getScopeId() != null) { - CaseInstance caseInstance = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(identityLink.getScopeId()); - if (caseInstance != null) { - caseDefinitionId = caseInstance.getCaseDefinitionId(); - } - - } else if (identityLink.getTaskId() != null) { - TaskEntity task = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(identityLink.getTaskId()); - if (task != null && ScopeTypes.CMMN.equals(task.getScopeType())) { - caseDefinitionId = task.getScopeDefinitionId(); - } - - } else if (ScopeTypes.PLAN_ITEM.equals(identityLink.getScopeType()) && identityLink.getSubScopeId() != null) { - PlanItemInstanceEntity planItemInstance = cmmnEngineConfiguration.getPlanItemInstanceEntityManager().findById(identityLink.getSubScopeId()); - if (planItemInstance != null) { - caseDefinitionId = planItemInstance.getCaseDefinitionId(); - } - } - - return CaseDefinitionUtil.getCaseDefinition(caseDefinitionId); - } - - protected Boolean evaluateShowInOverview(PlanItemInstanceEntity planItemInstanceEntity) { - Boolean showInOverview = null; - - PlanItemDefinition planItemDefinition = planItemInstanceEntity.getPlanItemDefinition(); - String includeInStageOverviewValue = null; - if (planItemInstanceEntity.isStage()) { - if (planItemDefinition instanceof Stage) { - Stage stage = (Stage) planItemDefinition; - includeInStageOverviewValue = stage.getIncludeInStageOverview(); - } - - } else if (planItemDefinition instanceof Milestone) { - Milestone milestone = (Milestone) planItemDefinition; - includeInStageOverviewValue = milestone.getIncludeInStageOverview(); - } - - if (StringUtils.isNotEmpty(includeInStageOverviewValue)) { - if ("true".equalsIgnoreCase(includeInStageOverviewValue)) { - showInOverview = true; - - } else if ("false".equalsIgnoreCase(includeInStageOverviewValue)) { - showInOverview = false; - - } else { - Expression stageExpression = cmmnEngineConfiguration.getExpressionManager().createExpression(includeInStageOverviewValue); - Object stageValueObject = stageExpression.getValue(planItemInstanceEntity); - if (!(stageValueObject instanceof Boolean)) { - throw new FlowableException("Include in stage overview expression does not resolve to a boolean value " + - includeInStageOverviewValue + ": " + stageValueObject); - } - - showInOverview = (Boolean) stageValueObject; - } - } - - return showInOverview; - } -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/AsyncCmmnHistoryManager.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/AsyncCmmnHistoryManager.java deleted file mode 100644 index 46d36955547..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/AsyncCmmnHistoryManager.java +++ /dev/null @@ -1,436 +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.cmmn.engine.impl.history.async; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.putIfNotNull; - -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.flowable.cmmn.api.repository.CaseDefinition; -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.CmmnHistoryHelper; -import org.flowable.cmmn.engine.impl.persistence.entity.CaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntityManager; -import org.flowable.cmmn.engine.impl.persistence.entity.MilestoneInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.PlanItemInstanceEntity; -import org.flowable.common.engine.impl.context.Context; -import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity; -import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity; -import org.flowable.job.service.JobServiceConfiguration; -import org.flowable.job.service.impl.history.async.AsyncHistorySession; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.api.history.HistoricTaskLogEntryBuilder; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class AsyncCmmnHistoryManager extends AbstractAsyncCmmnHistoryManager { - - public AsyncCmmnHistoryManager(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - protected AsyncHistorySession getAsyncHistorySession() { - return Context.getCommandContext().getSession(AsyncHistorySession.class); - } - - @Override - public void recordCaseInstanceStart(CaseInstanceEntity caseInstanceEntity) { - if (getHistoryConfigurationSettings().isHistoryEnabledForCaseInstance(caseInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonCaseInstanceFields(caseInstanceEntity, data); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_CASE_INSTANCE_START, data, caseInstanceEntity.getTenantId()); - } - } - - @Override - public void recordCaseInstanceEnd(CaseInstanceEntity caseInstanceEntity, String state, Date endTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForCaseInstance(caseInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonCaseInstanceFields(caseInstanceEntity, data); - - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_END_TIME, endTime); - - if (caseInstanceEntity.getStartTime() != null) { - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_DURATION, endTime.getTime() - caseInstanceEntity.getStartTime().getTime()); - } - - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_STATE, state); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_CASE_INSTANCE_END, data, caseInstanceEntity.getTenantId()); - } - } - - @Override - public void recordHistoricCaseInstanceReactivated(CaseInstanceEntity caseInstanceEntity) { - if (getHistoryConfigurationSettings().isHistoryEnabledForCaseInstance(caseInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, caseInstanceEntity.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_STATE, caseInstanceEntity.getState()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_REACTIVATION_TIME, caseInstanceEntity.getLastReactivationTime()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_REACTIVATION_USER_ID, caseInstanceEntity.getLastReactivationUserId()); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_CASE_INSTANCE_REACTIVATE, data, caseInstanceEntity.getTenantId()); - } - } - - @Override - public void recordUpdateCaseInstanceName(CaseInstanceEntity caseInstanceEntity, String name) { - if (getHistoryConfigurationSettings().isHistoryEnabledForCaseInstance(caseInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, caseInstanceEntity.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_NAME, caseInstanceEntity.getName()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, caseInstanceEntity.getRevision()); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_UPDATE_CASE_INSTANCE_NAME, data, caseInstanceEntity.getTenantId()); - } - } - - @Override - public void recordUpdateBusinessKey(CaseInstanceEntity caseInstanceEntity, String businessKey) { - if (getHistoryConfigurationSettings().isHistoryEnabledForCaseInstance(caseInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, caseInstanceEntity.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_BUSINESS_KEY, caseInstanceEntity.getBusinessKey()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, caseInstanceEntity.getRevision()); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_UPDATE_CASE_INSTANCE_BUSINESS_KEY, data, - caseInstanceEntity.getTenantId()); - } - } - - @Override - public void recordUpdateBusinessStatus(CaseInstanceEntity caseInstanceEntity, String businessKey) { - if (caseInstanceEntity != null) { - if (getHistoryConfigurationSettings().isHistoryEnabledForCaseInstance(caseInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, caseInstanceEntity.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_BUSINESS_STATUS, caseInstanceEntity.getBusinessStatus()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, caseInstanceEntity.getRevision()); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_UPDATE_CASE_INSTANCE_BUSINESS_STATUS, - data, - caseInstanceEntity.getTenantId()); - } - } - } - - @Override - public void recordHistoricCaseInstanceDeleted(String caseInstanceId, String tenantId) { - // Can only be done after the case instance has been fully ended (see DeleteHistoricCaseInstanceCmd) - if (getHistoryConfigurationSettings().isHistoryEnabled()) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, caseInstanceId); - - HistoricCaseInstanceEntityManager historicCaseInstanceEntityManager = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager(); - HistoricCaseInstanceEntity historicCaseInstanceEntity = historicCaseInstanceEntityManager.findById(caseInstanceId); - if (historicCaseInstanceEntity != null) { - addCommonHistoricCaseInstanceFields(historicCaseInstanceEntity, data); - } - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_HISTORIC_CASE_INSTANCE_DELETED, data, - historicCaseInstanceEntity != null ? historicCaseInstanceEntity.getTenantId() : null); - } - } - - @Override - public void recordBulkDeleteHistoricCaseInstances(Collection caseInstanceIds) { - if (getHistoryConfigurationSettings().isHistoryEnabled()) { - CmmnHistoryHelper.bulkDeleteHistoricCaseInstances(caseInstanceIds, cmmnEngineConfiguration); - } - } - - @Override - public void recordMilestoneReached(MilestoneInstanceEntity milestoneInstanceEntity) { - if (getHistoryConfigurationSettings().isHistoryEnabledForMilestone(milestoneInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonMilestoneInstanceFields(milestoneInstanceEntity, data); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_MILESTONE_REACHED, data, milestoneInstanceEntity.getTenantId()); - } - } - - @Override - public void recordIdentityLinkCreated(IdentityLinkEntity identityLink) { - if (getHistoryConfigurationSettings().isHistoryEnabledForIdentityLink(identityLink) - && (identityLink.getScopeId() != null || identityLink.getTaskId() != null)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonIdentityLinkFields(identityLink, data); - - CaseDefinition caseDefinition = getCaseDefinition(identityLink); - if (caseDefinition != null) { - addCaseDefinitionFields(data, caseDefinition); - } - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_IDENTITY_LINK_CREATED, data, - caseDefinition != null ? caseDefinition.getTenantId() : null); - } - } - - @Override - public void recordIdentityLinkDeleted(IdentityLinkEntity identityLink) { - if (getHistoryConfigurationSettings().isHistoryEnabledForIdentityLink(identityLink)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonIdentityLinkFields(identityLink, data); - - CaseDefinition caseDefinition = getCaseDefinition(identityLink); - if (caseDefinition != null) { - addCaseDefinitionFields(data, caseDefinition); - } - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_IDENTITY_LINK_DELETED, data, - caseDefinition != null ? caseDefinition.getTenantId() : null); - } - } - - @Override - public void recordEntityLinkCreated(EntityLinkEntity entityLink) { - if (getHistoryConfigurationSettings().isHistoryEnabledForEntityLink(entityLink) && entityLink.getScopeId() != null) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonEntityLinkFields(entityLink, data); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_ENTITY_LINK_CREATED, data, null); - } - } - - @Override - public void recordEntityLinkDeleted(EntityLinkEntity entityLink) { - if (getHistoryConfigurationSettings().isHistoryEnabledForEntityLink(entityLink)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonEntityLinkFields(entityLink, data); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_ENTITY_LINK_DELETED, data, null); - } - } - - @Override - public void recordVariableCreate(VariableInstanceEntity variableInstanceEntity, Date createTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForVariableInstance(variableInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME, createTime); - addCommonVariableFields(variableInstanceEntity, data, createTime); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_VARIABLE_CREATED, data); - } - } - - @Override - public void recordVariableUpdate(VariableInstanceEntity variableInstanceEntity, Date updateTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForVariableInstance(variableInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonVariableFields(variableInstanceEntity, data, updateTime); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_VARIABLE_UPDATED, data); - } - } - - @Override - public void recordVariableRemoved(VariableInstanceEntity variableInstanceEntity) { - if (getHistoryConfigurationSettings().isHistoryEnabledForVariableInstance(variableInstanceEntity)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, variableInstanceEntity.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_REVISION, variableInstanceEntity.getRevision()); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_VARIABLE_REMOVED, data); - } - } - - @Override - public void recordTaskCreated(TaskEntity task) { - if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(task)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonTaskFields(task, data); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_TASK_CREATED, data, task.getTenantId()); - } - } - - @Override - public void recordTaskInfoChange(TaskEntity task, Date changeTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(task)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonTaskFields(task, data); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME, changeTime); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_TASK_UPDATED, data, task.getTenantId()); - } - } - - @Override - public void recordTaskEnd(TaskEntity task, String deleteReason, Date endTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(task)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonTaskFields(task, data); - - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_DELETE_REASON, deleteReason); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_END_TIME, endTime); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME, endTime); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_TASK_REMOVED, data, task.getTenantId()); - } - } - - @Override - public void recordHistoricTaskDeleted(HistoricTaskInstance task) { - if (task != null && getHistoryConfigurationSettings().isHistoryEnabledForUserTask(task)) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, task.getId()); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_TASK_DELETED, data); - } - } - - @Override - public void recordPlanItemInstanceCreated(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, null); - } - - @Override - public void recordPlanItemInstanceReactivated(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, null); - // TODO: do we need a specific reactivation flag to mark this item being created because of a reactivation? - } - - @Override - public void recordPlanItemInstanceUpdated(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, null); - } - - @Override - public void recordPlanItemInstanceAvailable(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getLastAvailableTime()); - } - - @Override - public void recordPlanItemInstanceUnavailable(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getLastUnavailableTime()); - } - - @Override - public void recordPlanItemInstanceEnabled(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getLastEnabledTime()); - } - - @Override - public void recordPlanItemInstanceDisabled(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getLastDisabledTime()); - } - - @Override - public void recordPlanItemInstanceStarted(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getLastStartedTime()); - } - - @Override - public void recordPlanItemInstanceSuspended(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getLastSuspendedTime()); - } - - @Override - public void recordPlanItemInstanceCompleted(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getCompletedTime()); - } - - @Override - public void recordPlanItemInstanceOccurred(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getOccurredTime()); - } - - @Override - public void recordPlanItemInstanceTerminated(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getTerminatedTime()); - } - - @Override - public void recordPlanItemInstanceExit(PlanItemInstanceEntity planItemInstanceEntity) { - recordPlanItemInstanceFull(planItemInstanceEntity, planItemInstanceEntity.getExitTime()); - } - - @Override - public void updateCaseDefinitionIdInHistory(CaseDefinition caseDefinition, CaseInstanceEntity caseInstance) { - if (getHistoryConfigurationSettings().isHistoryEnabled(caseDefinition.getId())) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_ID, caseInstance.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID, caseDefinition.getId()); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID, caseInstance.getId()); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_UPDATE_CASE_DEFINITION_CASCADE, data); - } - } - - @Override - public void recordHistoricUserTaskLogEntry(HistoricTaskLogEntryBuilder taskLogEntryBuilder) { - if (cmmnEngineConfiguration.getTaskServiceConfiguration().isEnableHistoricTaskLogging()) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonHistoricTaskLogEntryFields(taskLogEntryBuilder, data); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_HISTORIC_USER_TASK_LOG_RECORD, data, taskLogEntryBuilder.getTenantId()); - } - } - - @Override - public void deleteHistoricUserTaskLogEntry(long logNumber) { - if (cmmnEngineConfiguration.getTaskServiceConfiguration().isEnableHistoricTaskLogging()) { - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LOG_ENTRY_LOGNUMBER, logNumber); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_HISTORIC_USER_TASK_LOG_DELETE, data); - } - } - - protected void recordPlanItemInstanceFull(PlanItemInstanceEntity planItemInstanceEntity, Date lastUpdateTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForPlanItemInstance(planItemInstanceEntity)) { - // When there are multiple changes on a PlanItemInstance within the same transaction - // we need to use only the last one (that one will contain the latest data) - removePlanItemInstanceFull(planItemInstanceEntity.getId()); - - ObjectNode data = cmmnEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonPlanItemInstanceFields(planItemInstanceEntity, data); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME, lastUpdateTime); - putIfNotNull(data, CmmnAsyncHistoryConstants.FIELD_IS_SHOW_IN_OVERVIEW, evaluateShowInOverview(planItemInstanceEntity)); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_FULL, data); - } - } - - /* Helper methods */ - - protected void removePlanItemInstanceFull(String planItemInstanceId) { - Map sessionData = getAsyncHistorySession().getSessionData(); - if (sessionData != null) { - AsyncHistorySession.AsyncHistorySessionData asyncHistorySessionData = sessionData.get(getJobServiceConfiguration()); - if (asyncHistorySessionData != null) { - Map> jobData = asyncHistorySessionData.getJobData(); - if (jobData != null && jobData.containsKey(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_FULL)) { - List planItemInstanceDataList = jobData.get(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_FULL); - Iterator planItemInstanceDataIterator = planItemInstanceDataList.listIterator(); - while (planItemInstanceDataIterator.hasNext()) { - ObjectNode planItemInstanceData = planItemInstanceDataIterator.next(); - if (planItemInstanceId.equals(getStringFromJson(planItemInstanceData, CmmnAsyncHistoryConstants.FIELD_ID))) { - planItemInstanceDataIterator.remove(); - } - } - } - } - } - } - - protected JobServiceConfiguration getJobServiceConfiguration() { - return cmmnEngineConfiguration.getJobServiceConfiguration(); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/CmmnAsyncHistoryConstants.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/CmmnAsyncHistoryConstants.java deleted file mode 100644 index 1606041dbc0..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/CmmnAsyncHistoryConstants.java +++ /dev/null @@ -1,212 +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.cmmn.engine.impl.history.async; - -import java.util.Arrays; -import java.util.List; - -/** - * @author Joram Barrez - */ -public interface CmmnAsyncHistoryConstants { - - String JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY = "cmmn-async-history"; - String JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED = "cmmn-async-history-zipped"; - - String TYPE_CASE_INSTANCE_END = "cmmn-case-instance-end"; - String TYPE_CASE_INSTANCE_START = "cmmn-case-instance-start"; - String TYPE_CASE_INSTANCE_REACTIVATE = "cmmn-case-instance-reactivate"; - String TYPE_UPDATE_CASE_INSTANCE_NAME = "cmmn-update-case-instance-name"; - String TYPE_UPDATE_CASE_INSTANCE_BUSINESS_KEY = "cmmn-update-case-business-key"; - String TYPE_UPDATE_CASE_INSTANCE_BUSINESS_STATUS = "cmmn-update-case-business-status"; - String TYPE_HISTORIC_CASE_INSTANCE_DELETED = "cmmn-historic-case-instance-deleted"; - String TYPE_IDENTITY_LINK_CREATED = "cmmn-identity-link-created"; - String TYPE_IDENTITY_LINK_DELETED = "cmmn-identity-link-deleted"; - String TYPE_ENTITY_LINK_CREATED = "cmmn-entity-link-created"; - String TYPE_ENTITY_LINK_DELETED = "cmmn-entity-link-deleted"; - String TYPE_MILESTONE_REACHED = "cmmn-milestone-reached"; - String TYPE_PLAN_ITEM_INSTANCE_FULL = "cmmn-plan-item-instance-full"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_AVAILABLE = "cmmn-plan-item-instance-available"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_COMPLETED = "cmmn-plan-item-instance-completed"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_CREATED = "cmmn-plan-item-instance-created"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_DISABLED = "cmmn-plan-item-instance-disabled"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_ENABLED = "cmmn-plan-item-instance-enabled"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_EXIT = "cmmn-plan-item-instance-exit"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_OCCURRED = "cmmn-plan-item-instance-occurred"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_SUSPENDED = "cmmn-plan-item-instance-suspended"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_STARTED = "cmmn-plan-item-instance-started"; - /** - * @deprecated - */ - @Deprecated - String TYPE_PLAN_ITEM_INSTANCE_TERMINATED = "cmmn-plan-item-instance-terminated"; - String TYPE_TASK_CREATED = "cmmn-task-created"; - String TYPE_TASK_REMOVED = "cmmn-task-removed"; - String TYPE_TASK_UPDATED = "cmmn-task-updated"; - String TYPE_TASK_DELETED = "cmmn-task-deleted"; - String TYPE_VARIABLE_CREATED = "cmmn-variable-created"; - String TYPE_VARIABLE_REMOVED = "cmmn-variable-removed"; - String TYPE_VARIABLE_UPDATED = "cmmn-variable-updated"; - String TYPE_UPDATE_CASE_DEFINITION_CASCADE = "cmmn-update-case-definition-cascade"; - String TYPE_HISTORIC_USER_TASK_LOG_RECORD = "cmmn-historic-user-task-log-record"; - String TYPE_HISTORIC_USER_TASK_LOG_DELETE = "cmmn-historic-user-task-log-delete"; - - List ORDERED_TYPES = Arrays.asList( - TYPE_CASE_INSTANCE_START, - TYPE_UPDATE_CASE_INSTANCE_NAME, - TYPE_ENTITY_LINK_CREATED, - TYPE_ENTITY_LINK_DELETED, - TYPE_IDENTITY_LINK_CREATED, - TYPE_IDENTITY_LINK_DELETED, - TYPE_MILESTONE_REACHED, - TYPE_PLAN_ITEM_INSTANCE_FULL, - TYPE_TASK_CREATED, - TYPE_TASK_REMOVED, - TYPE_TASK_UPDATED, - TYPE_TASK_DELETED, - TYPE_VARIABLE_CREATED, - TYPE_VARIABLE_REMOVED, - TYPE_VARIABLE_UPDATED, - TYPE_HISTORIC_CASE_INSTANCE_DELETED, - TYPE_CASE_INSTANCE_END - ); - - String FIELD_ASSIGNEE = "assignee"; - String FIELD_BUSINESS_KEY = "businessKey"; - String FIELD_BUSINESS_STATUS = "businessStatus"; - String FIELD_CASE_DEFINITION_CATEGORY = "caseDefinitionCategory"; - String FIELD_CASE_DEFINITION_DEPLOYMENT_ID = "caseDefinitionDeploymentId"; - String FIELD_CASE_DEFINITION_DESCRIPTION = "caseDefinitionDescription"; - String FIELD_CASE_DEFINITION_ID = "caseDefinitionId"; - String FIELD_DERIVED_CASE_DEFINITION_ID = "derivedCaseDefinitionId"; - String FIELD_CASE_DEFINITION_KEY = "caseDefinitionKey"; - String FIELD_CASE_DEFINITION_NAME = "caseDefinitionName"; - String FIELD_CASE_DEFINITION_VERSION = "caseDefinitionVersion"; - String FIELD_CASE_INSTANCE_ID = "caseInstanceId"; - String FIELD_CATEGORY = "category"; - String FIELD_CLAIM_TIME = "claimTime"; - String FIELD_COMPLETED_TIME = "completedTime"; - String FIELD_CREATE_TIME = "createTime"; - String FIELD_DELETE_REASON = "deleteReason"; - String FIELD_DESCRIPTION = "description"; - String FIELD_DUE_DATE = "dueDate"; - String FIELD_DURATION = "duration"; - String FIELD_ELEMENT_ID = "elementId"; - String FIELD_END_TIME = "endTime"; - String FIELD_EXIT_TIME = "exitTime"; - String FIELD_FORM_KEY = "formKey"; - String FIELD_GROUP_ID = "groupId"; - String FIELD_ID = "id"; - String FIELD_IS_STAGE = "isStage"; - String FIELD_IS_SHOW_IN_OVERVIEW = "isShowInOverview"; - String FIELD_IDENTITY_LINK_TYPE = "identityLinkType"; - String FIELD_ENTITY_LINK_TYPE = "entityLinkType"; - String FIELD_LAST_AVAILABLE_TIME = "lastAvailableTime"; - String FIELD_LAST_UNAVAILABLE_TIME = "lastUnavailableTime"; - String FIELD_LAST_DISABLED_TIME = "lastDisabledTime"; - String FIELD_LAST_ENABLED_TIME = "lastEnabledTime"; - String FIELD_LAST_STARTED_TIME = "lastStartedTime"; - String FIELD_LAST_SUSPENDED_TIME = "lastSuspendedTime"; - String FIELD_LAST_UPDATE_TIME = "lastUpdateTime"; - String FIELD_NAME = "name"; - String FIELD_OCCURRED_TIME = "occurredTime"; - String FIELD_OWNER = "owner"; - String FIELD_PARENT_ID = "parentId"; - String FIELD_PARENT_TASK_ID = "parentTaskId"; - String FIELD_PLAN_ITEM_DEFINITION_ID = "planItemDefinitionId"; - String FIELD_PLAN_ITEM_DEFINITION_TYPE = "planItemDefinitionType"; - String FIELD_PLAN_ITEM_INSTANCE_ID = "planItemInstanceId"; - String FIELD_PRIORITY = "priority"; - String FIELD_REFERENCE_ID = "referenceId"; - String FIELD_REFERENCE_TYPE = "referenceType"; - String FIELD_ENTRY_CRITERION_ID = "entryCriterionId"; - String FIELD_EXIT_CRITERION_ID = "exitCriterionId"; - String FIELD_EXTRA_VALUE = "extraValue"; - String FIELD_REVISION = "revision"; - String FIELD_SCOPE_ID = "scopeId"; - String FIELD_SCOPE_DEFINITION_ID = "scopeDefinitionId"; - String FIELD_SCOPE_TYPE = "scopeType"; - String FIELD_SUB_SCOPE_ID = "subScopeId"; - String FIELD_PARENT_ELEMENT_ID = "parentElementId"; - String FIELD_REF_SCOPE_ID = "refScopeId"; - String FIELD_REF_SCOPE_DEFINITION_ID = "refScopeDefinitionId"; - String FIELD_REF_SCOPE_TYPE = "refScopeType"; - String FIELD_ROOT_SCOPE_ID = "rootScopeId"; - String FIELD_ROOT_SCOPE_TYPE = "rootScopeType"; - String FIELD_HIERARCHY_TYPE = "hierarchyType"; - String FIELD_STAGE_INSTANCE_ID = "stageInstanceId"; - String FIELD_START_TIME = "startTime"; - String FIELD_START_USER_ID = "startUserId"; - String FIELD_LAST_REACTIVATION_TIME = "lastReactivationTime"; - String FIELD_LAST_REACTIVATION_USER_ID = "lastReactivationUserId"; - String FIELD_STATE = "state"; - String FIELD_TASK_ID = "taskId"; - String FIELD_TASK_DEFINITION_ID = "taskDefinitionId"; - String FIELD_TASK_DEFINITION_KEY = "taskDefinitionKey"; - String FIELD_TERMINATED_TIME = "terminatedTime"; - String FIELD_CALLBACK_ID = "callbackId"; - String FIELD_CALLBACK_TYPE = "callbackType"; - String FIELD_TENANT_ID = "tenantId"; - String FIELD_USER_ID = "userId"; - String FIELD_VARIABLE_BYTES_VALUE = "variableBytesValue"; - String FIELD_VARIABLE_DOUBLE_VALUE = "variableDoubleValue"; - String FIELD_VARIABLE_LONG_VALUE = "variableLongValue"; - String FIELD_VARIABLE_TEXT_VALUE = "variableTextValue"; - String FIELD_VARIABLE_TEXT_VALUE2 = "variableTextValue2"; - String FIELD_VARIABLE_TYPE = "variableType"; - String FIELD_LOG_ENTRY_TYPE = "logEntryType"; - String FIELD_LOG_ENTRY_DATA = "logEntryData"; - String FIELD_LOG_ENTRY_LOGNUMBER = "logNumber"; - String FIELD_META_INFO = "metaInfo"; - - String FIELD_EXECUTION_ID = "executionId"; - String FIELD_PROCESS_INSTANCE_ID = "processInstanceId"; - String FIELD_PROCESS_DEFINITION_ID = "processDefinitionId"; - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractHistoryJsonTransformer.java deleted file mode 100644 index cc7858af18f..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractHistoryJsonTransformer.java +++ /dev/null @@ -1,28 +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.cmmn.engine.impl.history.async.json.transformer; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.job.service.impl.history.async.transformer.HistoryJsonTransformer; - -/** - * @author Joram Barrez - */ -public abstract class AbstractHistoryJsonTransformer implements HistoryJsonTransformer { - - protected CmmnEngineConfiguration cmmnEngineConfiguration; - - public AbstractHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - this.cmmnEngineConfiguration = cmmnEngineConfiguration; - } -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractNeedsHistoricCaseInstanceJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractNeedsHistoricCaseInstanceJsonTransformer.java deleted file mode 100644 index 5e3e29fa011..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractNeedsHistoricCaseInstanceJsonTransformer.java +++ /dev/null @@ -1,46 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.util.CommandContextUtil; -import org.flowable.common.engine.impl.interceptor.CommandContext; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public abstract class AbstractNeedsHistoricCaseInstanceJsonTransformer extends AbstractHistoryJsonTransformer { - - public AbstractNeedsHistoricCaseInstanceJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - HistoricCaseInstanceEntity historicCaseInstanceEntity = getHistoricCaseInstanceEntity(historicalData, commandContext); - return historicCaseInstanceEntity != null; - } - - protected HistoricCaseInstanceEntity getHistoricCaseInstanceEntity(ObjectNode historicalData, CommandContext commandContext) { - String id = getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID); - HistoricCaseInstanceEntity historicCaseInstanceEntity = CommandContextUtil.getHistoricCaseInstanceEntityManager(commandContext).findById(id); - return historicCaseInstanceEntity; - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer.java deleted file mode 100644 index 7c21d03c31d..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer.java +++ /dev/null @@ -1,58 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Date; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public abstract class AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer extends AbstractPlanItemInstanceHistoryJsonTransformer { - - public AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return getHistoricPlanItemInstanceEntity(historicalData, commandContext) != null; - } - - protected HistoricPlanItemInstanceEntity getHistoricPlanItemInstanceEntity(ObjectNode historicalData, CommandContext commandContext) { - return cmmnEngineConfiguration.getHistoricPlanItemInstanceEntityManager() - .findById(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - } - - public HistoricPlanItemInstanceEntity updateCommonProperties(ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = getHistoricPlanItemInstanceEntity(historicalData, commandContext); - Date lastUpdatedTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME); - if (lastUpdatedTime != null - && (historicPlanItemInstanceEntity.getLastUpdatedTime() == null || lastUpdatedTime.after(historicPlanItemInstanceEntity.getLastUpdatedTime()))) { - copyCommonPlanItemInstanceProperties(historicPlanItemInstanceEntity, historicalData); - } - return historicPlanItemInstanceEntity; - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractPlanItemInstanceHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractPlanItemInstanceHistoryJsonTransformer.java deleted file mode 100644 index bfb16062a33..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractPlanItemInstanceHistoryJsonTransformer.java +++ /dev/null @@ -1,56 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getBooleanFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public abstract class AbstractPlanItemInstanceHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public AbstractPlanItemInstanceHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - protected void copyCommonPlanItemInstanceProperties(HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity, ObjectNode historicalData) { - historicPlanItemInstanceEntity.setId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - historicPlanItemInstanceEntity.setName(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_NAME)); - historicPlanItemInstanceEntity.setState(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_STATE)); - historicPlanItemInstanceEntity.setCaseDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID)); - historicPlanItemInstanceEntity.setDerivedCaseDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_DERIVED_CASE_DEFINITION_ID)); - historicPlanItemInstanceEntity.setCaseInstanceId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID)); - historicPlanItemInstanceEntity.setStageInstanceId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_STAGE_INSTANCE_ID)); - historicPlanItemInstanceEntity.setStage(getBooleanFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_IS_STAGE)); - historicPlanItemInstanceEntity.setElementId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ELEMENT_ID)); - historicPlanItemInstanceEntity.setPlanItemDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_PLAN_ITEM_DEFINITION_ID)); - historicPlanItemInstanceEntity.setPlanItemDefinitionType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_PLAN_ITEM_DEFINITION_TYPE)); - historicPlanItemInstanceEntity.setStartUserId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_START_USER_ID)); - historicPlanItemInstanceEntity.setCreateTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME)); - historicPlanItemInstanceEntity.setReferenceId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REFERENCE_ID)); - historicPlanItemInstanceEntity.setReferenceType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REFERENCE_TYPE)); - historicPlanItemInstanceEntity.setEntryCriterionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ENTRY_CRITERION_ID)); - historicPlanItemInstanceEntity.setExitCriterionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_EXIT_CRITERION_ID)); - historicPlanItemInstanceEntity.setTenantId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TENANT_ID)); - historicPlanItemInstanceEntity.setLastUpdatedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME)); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractTaskHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractTaskHistoryJsonTransformer.java deleted file mode 100644 index 4301e3be6bd..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/AbstractTaskHistoryJsonTransformer.java +++ /dev/null @@ -1,67 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getIntegerFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public abstract class AbstractTaskHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public AbstractTaskHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - protected HistoricTaskInstanceEntity getHistoricTaskEntity(ObjectNode historicalData, CommandContext commandContext) { - return cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService() - .getHistoricTask(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - } - - protected void copyCommonHistoricTaskInstanceFields(ObjectNode historicalData,HistoricTaskInstanceEntity historicTaskInstanceEntity) { - historicTaskInstanceEntity.setId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - historicTaskInstanceEntity.setTaskDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TASK_DEFINITION_ID)); - historicTaskInstanceEntity.setTaskDefinitionKey(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TASK_DEFINITION_KEY)); - historicTaskInstanceEntity.setScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID)); - historicTaskInstanceEntity.setSubScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID)); - historicTaskInstanceEntity.setScopeType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE)); - historicTaskInstanceEntity.setScopeDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_DEFINITION_ID)); - historicTaskInstanceEntity.setName(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_NAME)); - historicTaskInstanceEntity.setParentTaskId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_PARENT_TASK_ID)); - historicTaskInstanceEntity.setDescription(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_DESCRIPTION)); - historicTaskInstanceEntity.setOwner(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_OWNER)); - historicTaskInstanceEntity.setAssignee(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ASSIGNEE)); - if (historicalData.has(CmmnAsyncHistoryConstants.FIELD_CREATE_TIME)) { - historicTaskInstanceEntity.setCreateTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME)); - } else { - // For backwards compatibility. New async data uses the FIELD_CREATE_TIME. This should be removed eventually - historicTaskInstanceEntity.setCreateTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_START_TIME)); - } - historicTaskInstanceEntity.setFormKey(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_FORM_KEY)); - historicTaskInstanceEntity.setPriority(getIntegerFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_PRIORITY)); - historicTaskInstanceEntity.setDueDate(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_DUE_DATE)); - historicTaskInstanceEntity.setCategory(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CATEGORY)); - historicTaskInstanceEntity.setTenantId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TENANT_ID)); - historicTaskInstanceEntity.setLastUpdateTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME)); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceEndHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceEndHistoryJsonTransformer.java deleted file mode 100644 index ede90e71057..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceEndHistoryJsonTransformer.java +++ /dev/null @@ -1,77 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class CaseInstanceEndHistoryJsonTransformer extends AbstractNeedsHistoricCaseInstanceJsonTransformer { - - public CaseInstanceEndHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_CASE_INSTANCE_END); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricCaseInstanceEntityManager historicCaseInstanceEntityManager = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager(); - HistoricCaseInstanceEntity historicCaseInstanceEntity = getHistoricCaseInstanceEntity(historicalData, commandContext); - - if (historicCaseInstanceEntity == null) { - historicCaseInstanceEntity = historicCaseInstanceEntityManager.create(); - historicCaseInstanceEntity.setId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - historicCaseInstanceEntity.setName(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_NAME)); - historicCaseInstanceEntity.setBusinessKey(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_BUSINESS_KEY)); - historicCaseInstanceEntity.setBusinessStatus(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_BUSINESS_STATUS)); - historicCaseInstanceEntity.setParentId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_PARENT_ID)); - historicCaseInstanceEntity.setCaseDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID)); - historicCaseInstanceEntity.setState(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_STATE)); - historicCaseInstanceEntity.setStartUserId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_START_USER_ID)); - historicCaseInstanceEntity.setStartTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_START_TIME)); - historicCaseInstanceEntity.setCallbackId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CALLBACK_ID)); - historicCaseInstanceEntity.setCallbackType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CALLBACK_TYPE)); - historicCaseInstanceEntity.setReferenceId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REFERENCE_ID)); - historicCaseInstanceEntity.setReferenceType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REFERENCE_TYPE)); - historicCaseInstanceEntity.setTenantId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TENANT_ID)); - historicCaseInstanceEntityManager.insert(historicCaseInstanceEntity); - - } else { - Date endTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_END_TIME); - historicCaseInstanceEntity.setEndTime(endTime); - historicCaseInstanceEntity.setState(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_STATE)); - historicCaseInstanceEntityManager.update(historicCaseInstanceEntity); - - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceReactivateHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceReactivateHistoryJsonTransformer.java deleted file mode 100644 index d1101dec37d..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceReactivateHistoryJsonTransformer.java +++ /dev/null @@ -1,59 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Resets the end time and reactivates the historic case instance by changing its state. - * - * @author Micha Kiener - */ -public class CaseInstanceReactivateHistoryJsonTransformer extends AbstractNeedsHistoricCaseInstanceJsonTransformer { - - public CaseInstanceReactivateHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_CASE_INSTANCE_REACTIVATE); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricCaseInstanceEntityManager historicCaseInstanceEntityManager = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager(); - HistoricCaseInstanceEntity historicCaseInstanceEntity = getHistoricCaseInstanceEntity(historicalData, commandContext); - - if (historicCaseInstanceEntity != null) { - historicCaseInstanceEntity.setState(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_STATE)); - historicCaseInstanceEntity.setLastReactivationTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_REACTIVATION_TIME)); - historicCaseInstanceEntity.setLastReactivationUserId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_REACTIVATION_USER_ID)); - historicCaseInstanceEntity.setEndTime(null); - historicCaseInstanceEntityManager.update(historicCaseInstanceEntity); - } - } -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceStartHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceStartHistoryJsonTransformer.java deleted file mode 100644 index b322df9c697..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceStartHistoryJsonTransformer.java +++ /dev/null @@ -1,78 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class CaseInstanceStartHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public CaseInstanceStartHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_CASE_INSTANCE_START); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricCaseInstanceEntityManager historicCaseInstanceEntityManager = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager(); - - String id = getStringFromJson(historicalData, "id"); - HistoricCaseInstanceEntity historicCaseInstanceEntity = historicCaseInstanceEntityManager.findById(id); - - // If the entity is already persisted, no need to do anything. - // The end event already has inserted the latest state and there is no new data in the json here. - if (historicCaseInstanceEntity == null) { - historicCaseInstanceEntity = historicCaseInstanceEntityManager.create(); - historicCaseInstanceEntity.setId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - historicCaseInstanceEntity.setName(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_NAME)); - historicCaseInstanceEntity.setBusinessKey(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_BUSINESS_KEY)); - historicCaseInstanceEntity.setBusinessStatus(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_BUSINESS_STATUS)); - historicCaseInstanceEntity.setParentId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_PARENT_ID)); - historicCaseInstanceEntity.setCaseDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID)); - historicCaseInstanceEntity.setState(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_STATE)); - historicCaseInstanceEntity.setStartUserId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_START_USER_ID)); - historicCaseInstanceEntity.setStartTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_START_TIME)); - historicCaseInstanceEntity.setCallbackId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CALLBACK_ID)); - historicCaseInstanceEntity.setCallbackType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CALLBACK_TYPE)); - historicCaseInstanceEntity.setReferenceId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REFERENCE_ID)); - historicCaseInstanceEntity.setReferenceType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REFERENCE_TYPE)); - historicCaseInstanceEntity.setTenantId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TENANT_ID)); - historicCaseInstanceEntityManager.insert(historicCaseInstanceEntity); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateBusinessKeyHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateBusinessKeyHistoryJsonTransformer.java deleted file mode 100644 index 2ef6a2d888e..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateBusinessKeyHistoryJsonTransformer.java +++ /dev/null @@ -1,54 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Tijs Rademakers - */ -public class CaseInstanceUpdateBusinessKeyHistoryJsonTransformer extends AbstractNeedsHistoricCaseInstanceJsonTransformer { - - public CaseInstanceUpdateBusinessKeyHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_UPDATE_CASE_INSTANCE_BUSINESS_KEY); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricCaseInstanceEntityManager historicCaseInstanceEntityManager = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager(); - HistoricCaseInstanceEntity historicCaseInstanceEntity = getHistoricCaseInstanceEntity(historicalData, commandContext); - - if (historicCaseInstanceEntity != null) { - historicCaseInstanceEntity.setBusinessKey(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_BUSINESS_KEY)); - historicCaseInstanceEntityManager.update(historicCaseInstanceEntity); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateBusinessStatusHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateBusinessStatusHistoryJsonTransformer.java deleted file mode 100644 index f222c7901d8..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateBusinessStatusHistoryJsonTransformer.java +++ /dev/null @@ -1,54 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Tijs Rademakers - */ -public class CaseInstanceUpdateBusinessStatusHistoryJsonTransformer extends AbstractNeedsHistoricCaseInstanceJsonTransformer { - - public CaseInstanceUpdateBusinessStatusHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_UPDATE_CASE_INSTANCE_BUSINESS_STATUS); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricCaseInstanceEntityManager historicCaseInstanceEntityManager = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager(); - HistoricCaseInstanceEntity historicCaseInstanceEntity = getHistoricCaseInstanceEntity(historicalData, commandContext); - - if (historicCaseInstanceEntity != null) { - historicCaseInstanceEntity.setBusinessStatus(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_BUSINESS_STATUS)); - historicCaseInstanceEntityManager.update(historicCaseInstanceEntity); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateNameHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateNameHistoryJsonTransformer.java deleted file mode 100644 index ba7e2d4b712..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/CaseInstanceUpdateNameHistoryJsonTransformer.java +++ /dev/null @@ -1,54 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Tijs Rademakers - */ -public class CaseInstanceUpdateNameHistoryJsonTransformer extends AbstractNeedsHistoricCaseInstanceJsonTransformer { - - public CaseInstanceUpdateNameHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_UPDATE_CASE_INSTANCE_NAME); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricCaseInstanceEntityManager historicCaseInstanceEntityManager = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager(); - HistoricCaseInstanceEntity historicCaseInstanceEntity = getHistoricCaseInstanceEntity(historicalData, commandContext); - - if (historicCaseInstanceEntity != null) { - historicCaseInstanceEntity.setName(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_NAME)); - historicCaseInstanceEntityManager.update(historicCaseInstanceEntity); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/EntityLinkCreatedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/EntityLinkCreatedHistoryJsonTransformer.java deleted file mode 100644 index 55391c2653f..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/EntityLinkCreatedHistoryJsonTransformer.java +++ /dev/null @@ -1,71 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.entitylink.api.history.HistoricEntityLinkService; -import org.flowable.entitylink.service.impl.persistence.entity.HistoricEntityLinkEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Tijs Rademakers - */ -public class EntityLinkCreatedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public EntityLinkCreatedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_ENTITY_LINK_CREATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricEntityLinkService historicEntityLinkService = cmmnEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService(); - HistoricEntityLinkEntity historicEntityLinkEntity = (HistoricEntityLinkEntity) historicEntityLinkService.createHistoricEntityLink(); - historicEntityLinkEntity.setId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - historicEntityLinkEntity.setLinkType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ENTITY_LINK_TYPE)); - historicEntityLinkEntity.setCreateTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME)); - historicEntityLinkEntity.setScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID)); - historicEntityLinkEntity.setSubScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID)); - historicEntityLinkEntity.setScopeType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE)); - historicEntityLinkEntity.setScopeDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_DEFINITION_ID)); - historicEntityLinkEntity.setParentElementId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_PARENT_ELEMENT_ID)); - historicEntityLinkEntity.setReferenceScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REF_SCOPE_ID)); - historicEntityLinkEntity.setReferenceScopeType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REF_SCOPE_TYPE)); - historicEntityLinkEntity.setReferenceScopeDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REF_SCOPE_DEFINITION_ID)); - historicEntityLinkEntity.setRootScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ROOT_SCOPE_ID)); - historicEntityLinkEntity.setRootScopeType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ROOT_SCOPE_TYPE)); - historicEntityLinkEntity.setHierarchyType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_HIERARCHY_TYPE)); - - historicEntityLinkService.insertHistoricEntityLink(historicEntityLinkEntity, false); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/EntityLinkDeletedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/EntityLinkDeletedHistoryJsonTransformer.java deleted file mode 100644 index a3a1726b31a..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/EntityLinkDeletedHistoryJsonTransformer.java +++ /dev/null @@ -1,62 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.entitylink.api.history.HistoricEntityLink; -import org.flowable.entitylink.api.history.HistoricEntityLinkService; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Tijs Rademakers - */ -public class EntityLinkDeletedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public EntityLinkDeletedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_ENTITY_LINK_DELETED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return getHistoricEntityLink(historicalData, commandContext) != null; - } - - protected HistoricEntityLink getHistoricEntityLink(ObjectNode historicalData, CommandContext commandContext) { - return cmmnEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService() - .getHistoricEntityLink(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricEntityLinkService historicEntityLinkService = cmmnEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService(); - HistoricEntityLink historicEntityLink = getHistoricEntityLink(historicalData, commandContext); - if (historicEntityLink != null) { - historicEntityLinkService.deleteHistoricEntityLink(historicEntityLink); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricCaseInstanceDeletedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricCaseInstanceDeletedHistoryJsonTransformer.java deleted file mode 100644 index cf20e2a0a3c..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricCaseInstanceDeletedHistoryJsonTransformer.java +++ /dev/null @@ -1,47 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.CmmnHistoryHelper; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class HistoricCaseInstanceDeletedHistoryJsonTransformer extends AbstractNeedsHistoricCaseInstanceJsonTransformer { - - public HistoricCaseInstanceDeletedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_HISTORIC_CASE_INSTANCE_DELETED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - CmmnHistoryHelper.deleteHistoricCaseInstance(cmmnEngineConfiguration, getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricUserTaskLogDeleteJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricUserTaskLogDeleteJsonTransformer.java deleted file mode 100644 index 1fbd90375a5..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricUserTaskLogDeleteJsonTransformer.java +++ /dev/null @@ -1,53 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getLongFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author martin.grofcik - */ -public class HistoricUserTaskLogDeleteJsonTransformer extends AbstractHistoryJsonTransformer { - - public HistoricUserTaskLogDeleteJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_HISTORIC_USER_TASK_LOG_DELETE); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - Long logNumber = getLongFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LOG_ENTRY_LOGNUMBER); - if (logNumber != null) { - cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().deleteHistoricTaskLogEntry(logNumber); - } - } -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricUserTaskLogRecordJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricUserTaskLogRecordJsonTransformer.java deleted file mode 100644 index 31e1d85dfc0..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/HistoricUserTaskLogRecordJsonTransformer.java +++ /dev/null @@ -1,65 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.service.impl.BaseHistoricTaskLogEntryBuilderImpl; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author martin.grofcik - */ -public class HistoricUserTaskLogRecordJsonTransformer extends AbstractHistoryJsonTransformer { - - public HistoricUserTaskLogRecordJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_HISTORIC_USER_TASK_LOG_RECORD); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - BaseHistoricTaskLogEntryBuilderImpl taskLogEntryBuilder = new BaseHistoricTaskLogEntryBuilderImpl(); - - taskLogEntryBuilder.data(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LOG_ENTRY_DATA)); - taskLogEntryBuilder.scopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID)); - taskLogEntryBuilder.scopeType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE)); - taskLogEntryBuilder.subScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID)); - taskLogEntryBuilder.scopeDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_DEFINITION_ID)); - taskLogEntryBuilder.taskId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TASK_ID)); - taskLogEntryBuilder.tenantId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TENANT_ID)); - taskLogEntryBuilder.timeStamp(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME)); - taskLogEntryBuilder.type(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LOG_ENTRY_TYPE)); - taskLogEntryBuilder.userId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_USER_ID)); - - cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().createHistoricTaskLogEntry(taskLogEntryBuilder); - } -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/IdentityLinkCreatedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/IdentityLinkCreatedHistoryJsonTransformer.java deleted file mode 100644 index 442205fcbc3..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/IdentityLinkCreatedHistoryJsonTransformer.java +++ /dev/null @@ -1,65 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.identitylink.service.HistoricIdentityLinkService; -import org.flowable.identitylink.service.impl.persistence.entity.HistoricIdentityLinkEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class IdentityLinkCreatedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public IdentityLinkCreatedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_IDENTITY_LINK_CREATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricIdentityLinkService historicIdentityLinkService = cmmnEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService(); - HistoricIdentityLinkEntity historicIdentityLinkEntity = historicIdentityLinkService.createHistoricIdentityLink(); - historicIdentityLinkEntity.setId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - historicIdentityLinkEntity.setGroupId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_GROUP_ID)); - historicIdentityLinkEntity.setScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID)); - historicIdentityLinkEntity.setSubScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID)); - historicIdentityLinkEntity.setScopeType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE)); - historicIdentityLinkEntity.setScopeDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_DEFINITION_ID)); - historicIdentityLinkEntity.setTaskId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TASK_ID)); - historicIdentityLinkEntity.setProcessInstanceId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_PROCESS_INSTANCE_ID)); - historicIdentityLinkEntity.setType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_IDENTITY_LINK_TYPE)); - historicIdentityLinkEntity.setUserId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_USER_ID)); - historicIdentityLinkService.insertHistoricIdentityLink(historicIdentityLinkEntity, false); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/IdentityLinkDeletedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/IdentityLinkDeletedHistoryJsonTransformer.java deleted file mode 100644 index dfca3f7147e..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/IdentityLinkDeletedHistoryJsonTransformer.java +++ /dev/null @@ -1,62 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.identitylink.service.HistoricIdentityLinkService; -import org.flowable.identitylink.service.impl.persistence.entity.HistoricIdentityLinkEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class IdentityLinkDeletedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public IdentityLinkDeletedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_IDENTITY_LINK_DELETED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return getHistoricIdentityLinkEntity(historicalData, commandContext) != null; - } - - protected HistoricIdentityLinkEntity getHistoricIdentityLinkEntity(ObjectNode historicalData, CommandContext commandContext) { - return cmmnEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService() - .getHistoricIdentityLink(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricIdentityLinkService historicIdentityLinkService = cmmnEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService(); - HistoricIdentityLinkEntity historicIdentityLinkEntity = getHistoricIdentityLinkEntity(historicalData, commandContext); - if (historicIdentityLinkEntity != null) { - historicIdentityLinkService.deleteHistoricIdentityLink(historicIdentityLinkEntity); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/MilestoneReachedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/MilestoneReachedHistoryJsonTransformer.java deleted file mode 100644 index 8254a4740dc..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/MilestoneReachedHistoryJsonTransformer.java +++ /dev/null @@ -1,63 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricMilestoneInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricMilestoneInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class MilestoneReachedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public MilestoneReachedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_MILESTONE_REACHED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricMilestoneInstanceEntityManager historicMilestoneInstanceEntityManager = cmmnEngineConfiguration.getHistoricMilestoneInstanceEntityManager(); - HistoricMilestoneInstanceEntity historicMilestoneInstanceEntity = historicMilestoneInstanceEntityManager.create(); - historicMilestoneInstanceEntity.setId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - historicMilestoneInstanceEntity.setName(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_NAME)); - historicMilestoneInstanceEntity.setCaseInstanceId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID)); - historicMilestoneInstanceEntity.setCaseDefinitionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID)); - historicMilestoneInstanceEntity.setElementId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ELEMENT_ID)); - historicMilestoneInstanceEntity.setTimeStamp(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME)); - historicMilestoneInstanceEntity.setTenantId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TENANT_ID)); - historicMilestoneInstanceEntityManager.insert(historicMilestoneInstanceEntity); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceAvailableHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceAvailableHistoryJsonTransformer.java deleted file mode 100644 index 9aea9a6dc94..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceAvailableHistoryJsonTransformer.java +++ /dev/null @@ -1,56 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceAvailableHistoryJsonTransformer extends AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceAvailableHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_AVAILABLE); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = updateCommonProperties(historicalData, commandContext); - - Date lastAvailableTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_AVAILABLE_TIME); - if (historicPlanItemInstanceEntity.getLastAvailableTime() == null - || historicPlanItemInstanceEntity.getLastAvailableTime().before(lastAvailableTime)) { - historicPlanItemInstanceEntity.setLastAvailableTime(lastAvailableTime); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceCompletedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceCompletedHistoryJsonTransformer.java deleted file mode 100644 index c8a511536cc..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceCompletedHistoryJsonTransformer.java +++ /dev/null @@ -1,51 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceCompletedHistoryJsonTransformer extends AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceCompletedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_COMPLETED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = updateCommonProperties(historicalData, commandContext); - historicPlanItemInstanceEntity.setCompletedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_COMPLETED_TIME)); - historicPlanItemInstanceEntity.setEndedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_END_TIME)); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceCreatedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceCreatedHistoryJsonTransformer.java deleted file mode 100644 index 46f35103d8a..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceCreatedHistoryJsonTransformer.java +++ /dev/null @@ -1,56 +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.cmmn.engine.impl.history.async.json.transformer; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceCreatedHistoryJsonTransformer extends AbstractPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceCreatedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_CREATED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntityManager historicPlanItemInstanceEntityManager = cmmnEngineConfiguration.getHistoricPlanItemInstanceEntityManager(); - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = historicPlanItemInstanceEntityManager.create(); - copyCommonPlanItemInstanceProperties(historicPlanItemInstanceEntity, historicalData); - historicPlanItemInstanceEntityManager.insert(historicPlanItemInstanceEntity); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceDisabledHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceDisabledHistoryJsonTransformer.java deleted file mode 100644 index 3b3afefd79c..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceDisabledHistoryJsonTransformer.java +++ /dev/null @@ -1,56 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceDisabledHistoryJsonTransformer extends AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceDisabledHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_DISABLED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = updateCommonProperties(historicalData, commandContext); - - Date lastDisabledTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_DISABLED_TIME); - if (historicPlanItemInstanceEntity.getLastDisabledTime() == null - || historicPlanItemInstanceEntity.getLastDisabledTime().before(lastDisabledTime)) { - historicPlanItemInstanceEntity.setLastDisabledTime(lastDisabledTime); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceEnabledHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceEnabledHistoryJsonTransformer.java deleted file mode 100644 index 4fce1bdb3b6..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceEnabledHistoryJsonTransformer.java +++ /dev/null @@ -1,56 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceEnabledHistoryJsonTransformer extends AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceEnabledHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_ENABLED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = updateCommonProperties(historicalData, commandContext); - - Date lastEnabledTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_ENABLED_TIME); - if (historicPlanItemInstanceEntity.getLastEnabledTime() == null - || historicPlanItemInstanceEntity.getLastEnabledTime().before(lastEnabledTime)) { - historicPlanItemInstanceEntity.setLastEnabledTime(lastEnabledTime); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceExitHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceExitHistoryJsonTransformer.java deleted file mode 100644 index a2fae02dece..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceExitHistoryJsonTransformer.java +++ /dev/null @@ -1,51 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceExitHistoryJsonTransformer extends AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceExitHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_EXIT); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = updateCommonProperties(historicalData, commandContext); - historicPlanItemInstanceEntity.setExitTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_EXIT_TIME)); - historicPlanItemInstanceEntity.setEndedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_END_TIME)); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceFullHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceFullHistoryJsonTransformer.java deleted file mode 100644 index a670f85989e..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceFullHistoryJsonTransformer.java +++ /dev/null @@ -1,99 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getBooleanFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Filip Hrisafov - */ -public class PlanItemInstanceFullHistoryJsonTransformer extends AbstractPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceFullHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_FULL); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = getHistoricPlanItemInstanceEntity(historicalData, commandContext); - if (historicPlanItemInstanceEntity == null) { - HistoricPlanItemInstanceEntityManager historicPlanItemInstanceEntityManager = cmmnEngineConfiguration.getHistoricPlanItemInstanceEntityManager(); - historicPlanItemInstanceEntity = historicPlanItemInstanceEntityManager.create(); - copyCommonPlanItemInstanceProperties(historicPlanItemInstanceEntity, historicalData); - historicPlanItemInstanceEntityManager.insert(historicPlanItemInstanceEntity); - - } else { - // If there is already a historic plan item instance it means that the last update time must not be null - Date lastUpdateTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME); - if (lastUpdateTime != null && (historicPlanItemInstanceEntity.getLastUpdatedTime() == null - || lastUpdateTime.after(historicPlanItemInstanceEntity.getLastUpdatedTime()) - || lastUpdateTime.equals(historicPlanItemInstanceEntity.getLastUpdatedTime()))) { // last in wins in case of ties - - copyCommonPlanItemInstanceProperties(historicPlanItemInstanceEntity, historicalData); - cmmnEngineConfiguration.getHistoricPlanItemInstanceEntityManager().update(historicPlanItemInstanceEntity); - } - } - } - - @Override - protected void copyCommonPlanItemInstanceProperties(HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity, ObjectNode historicalData) { - super.copyCommonPlanItemInstanceProperties(historicPlanItemInstanceEntity, historicalData); - - historicPlanItemInstanceEntity.setLastAvailableTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_AVAILABLE_TIME)); - historicPlanItemInstanceEntity.setLastUnavailableTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_UNAVAILABLE_TIME)); - historicPlanItemInstanceEntity.setLastEnabledTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_ENABLED_TIME)); - historicPlanItemInstanceEntity.setLastDisabledTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_DISABLED_TIME)); - historicPlanItemInstanceEntity.setLastStartedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_STARTED_TIME)); - historicPlanItemInstanceEntity.setLastSuspendedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_SUSPENDED_TIME)); - historicPlanItemInstanceEntity.setCompletedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_COMPLETED_TIME)); - historicPlanItemInstanceEntity.setOccurredTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_OCCURRED_TIME)); - historicPlanItemInstanceEntity.setTerminatedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TERMINATED_TIME)); - historicPlanItemInstanceEntity.setExitTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_EXIT_TIME)); - historicPlanItemInstanceEntity.setEndedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_END_TIME)); - historicPlanItemInstanceEntity.setExtraValue(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_EXTRA_VALUE)); - - if (historicalData.has(CmmnAsyncHistoryConstants.FIELD_IS_SHOW_IN_OVERVIEW)) { - historicPlanItemInstanceEntity.setShowInOverview(getBooleanFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_IS_SHOW_IN_OVERVIEW)); - } - } - - protected HistoricPlanItemInstanceEntity getHistoricPlanItemInstanceEntity(ObjectNode historicalData, CommandContext commandContext) { - return cmmnEngineConfiguration.getHistoricPlanItemInstanceEntityManager() - .findById(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - } -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceOccurredHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceOccurredHistoryJsonTransformer.java deleted file mode 100644 index 4f7faed305b..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceOccurredHistoryJsonTransformer.java +++ /dev/null @@ -1,51 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceOccurredHistoryJsonTransformer extends AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceOccurredHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_OCCURRED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = updateCommonProperties(historicalData, commandContext); - historicPlanItemInstanceEntity.setOccurredTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_OCCURRED_TIME)); - historicPlanItemInstanceEntity.setEndedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_END_TIME)); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceStartedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceStartedHistoryJsonTransformer.java deleted file mode 100644 index 2b16411e6c2..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceStartedHistoryJsonTransformer.java +++ /dev/null @@ -1,56 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceStartedHistoryJsonTransformer extends AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceStartedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_STARTED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = updateCommonProperties(historicalData, commandContext); - - Date lastStartedTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_STARTED_TIME); - if (historicPlanItemInstanceEntity.getLastStartedTime() == null - || historicPlanItemInstanceEntity.getLastStartedTime().before(lastStartedTime)) { - historicPlanItemInstanceEntity.setLastStartedTime(lastStartedTime); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceSuspendedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceSuspendedHistoryJsonTransformer.java deleted file mode 100644 index edbcd2b73ef..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceSuspendedHistoryJsonTransformer.java +++ /dev/null @@ -1,56 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceSuspendedHistoryJsonTransformer extends AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceSuspendedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_SUSPENDED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = updateCommonProperties(historicalData, commandContext); - - Date lastSuspendedTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_SUSPENDED_TIME); - if (historicPlanItemInstanceEntity.getLastSuspendedTime() == null - || historicPlanItemInstanceEntity.getLastSuspendedTime().before(lastSuspendedTime)) { - historicPlanItemInstanceEntity.setLastSuspendedTime(lastSuspendedTime); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceTerminatedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceTerminatedHistoryJsonTransformer.java deleted file mode 100644 index 9b9e6a8f99f..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/PlanItemInstanceTerminatedHistoryJsonTransformer.java +++ /dev/null @@ -1,51 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @deprecated - */ -@Deprecated -public class PlanItemInstanceTerminatedHistoryJsonTransformer extends AbstractNeedsHistoricPlanItemInstanceHistoryJsonTransformer { - - public PlanItemInstanceTerminatedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_PLAN_ITEM_INSTANCE_TERMINATED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricPlanItemInstanceEntity historicPlanItemInstanceEntity = updateCommonProperties(historicalData, commandContext); - historicPlanItemInstanceEntity.setTerminatedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TERMINATED_TIME)); - historicPlanItemInstanceEntity.setEndedTime(getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_END_TIME)); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskCreatedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskCreatedHistoryJsonTransformer.java deleted file mode 100644 index 8b63f2c0dd5..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskCreatedHistoryJsonTransformer.java +++ /dev/null @@ -1,54 +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.cmmn.engine.impl.history.async.json.transformer; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.service.HistoricTaskService; -import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class TaskCreatedHistoryJsonTransformer extends AbstractTaskHistoryJsonTransformer { - - public TaskCreatedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_TASK_CREATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricTaskService historicTaskService = cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService(); - HistoricTaskInstanceEntity historicTaskInstanceEntity = historicTaskService.createHistoricTask(); - copyCommonHistoricTaskInstanceFields(historicalData, historicTaskInstanceEntity); - historicTaskService.insertHistoricTask(historicTaskInstanceEntity, false); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskDeletedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskDeletedHistoryJsonTransformer.java deleted file mode 100644 index 8cc2b2dc141..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskDeletedHistoryJsonTransformer.java +++ /dev/null @@ -1,51 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.task.TaskHelper; -import org.flowable.cmmn.engine.impl.util.CommandContextUtil; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class TaskDeletedHistoryJsonTransformer extends AbstractTaskHistoryJsonTransformer { - - public TaskDeletedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_TASK_DELETED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return getHistoricTaskEntity(historicalData, commandContext) != null; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String taskId = getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID); - TaskHelper.deleteHistoricTask(taskId, CommandContextUtil.getCmmnEngineConfiguration(commandContext)); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskEndedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskEndedHistoryJsonTransformer.java deleted file mode 100644 index 5c69df7df66..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskEndedHistoryJsonTransformer.java +++ /dev/null @@ -1,80 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.service.HistoricTaskService; -import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class TaskEndedHistoryJsonTransformer extends AbstractTaskHistoryJsonTransformer { - - public TaskEndedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_TASK_REMOVED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return getHistoricTaskEntity(historicalData, commandContext) != null; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricTaskInstanceEntity historicTaskInstance = getHistoricTaskEntity(historicalData, commandContext); - - if (historicTaskInstance != null) { - // The end time is the last update time - Date lastUpdateTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_END_TIME); - if (historicTaskInstance.getLastUpdateTime() == null || !historicTaskInstance.getLastUpdateTime().after(lastUpdateTime)) { - historicTaskInstance.setLastUpdateTime(lastUpdateTime); - copyCommonHistoricTaskInstanceFields(historicalData, historicTaskInstance); - } - setEndProperties(historicalData, historicTaskInstance); - - } else { - HistoricTaskService historicTaskService = cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService(); - HistoricTaskInstanceEntity historicTaskInstanceEntity = historicTaskService.createHistoricTask(); - copyCommonHistoricTaskInstanceFields(historicalData, historicTaskInstanceEntity); - setEndProperties(historicalData, historicTaskInstanceEntity); - historicTaskService.insertHistoricTask(historicTaskInstanceEntity, false); - } - } - - protected void setEndProperties(ObjectNode historicalData, HistoricTaskInstanceEntity historicTaskInstance) { - Date endTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_END_TIME); - historicTaskInstance.setEndTime(endTime); - historicTaskInstance.setDeleteReason(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_DELETE_REASON)); - - Date startTime = historicTaskInstance.getStartTime(); - if (startTime != null && endTime != null) { - historicTaskInstance.setDurationInMillis(endTime.getTime() - startTime.getTime()); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskUpdatedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskUpdatedHistoryJsonTransformer.java deleted file mode 100644 index 181f4efc8a1..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/TaskUpdatedHistoryJsonTransformer.java +++ /dev/null @@ -1,72 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.history.async.AsyncHistorySession; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class TaskUpdatedHistoryJsonTransformer extends AbstractTaskHistoryJsonTransformer { - - private static final Logger LOGGER = LoggerFactory.getLogger(TaskUpdatedHistoryJsonTransformer.class); - - public TaskUpdatedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_TASK_UPDATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return getHistoricTaskEntity(historicalData, commandContext) != null; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricTaskInstanceEntity historicTaskInstance = getHistoricTaskEntity(historicalData, commandContext); - - Date lastUpdateTime = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME); - if (lastUpdateTime == null) { - // this is for backwards compatibility for jobs that don't have the last update time set - lastUpdateTime = getDateFromJson(historicalData, AsyncHistorySession.TIMESTAMP); - } - if (historicTaskInstance.getLastUpdateTime() == null || !historicTaskInstance.getLastUpdateTime().after(lastUpdateTime)) { - copyCommonHistoricTaskInstanceFields(historicalData, historicTaskInstance); - - } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("History job (id={}) has expired and will be ignored.", job.getId()); - } - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/UpdateCaseDefinitionCascadeHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/UpdateCaseDefinitionCascadeHistoryJsonTransformer.java deleted file mode 100644 index 2902ef1a64a..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/UpdateCaseDefinitionCascadeHistoryJsonTransformer.java +++ /dev/null @@ -1,84 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.api.history.HistoricPlanItemInstance; -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.HistoricPlanItemInstanceQueryImpl; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricCaseInstanceEntityManager; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntity; -import org.flowable.cmmn.engine.impl.persistence.entity.HistoricPlanItemInstanceEntityManager; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.service.HistoricTaskService; -import org.flowable.task.service.impl.HistoricTaskInstanceQueryImpl; -import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class UpdateCaseDefinitionCascadeHistoryJsonTransformer extends AbstractNeedsHistoricCaseInstanceJsonTransformer { - - public UpdateCaseDefinitionCascadeHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_UPDATE_CASE_DEFINITION_CASCADE); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String caseDefinitionId = getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CASE_DEFINITION_ID); - String caseInstanceId = getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CASE_INSTANCE_ID); - - HistoricCaseInstanceEntityManager historicCaseInstanceEntityManager = cmmnEngineConfiguration.getHistoricCaseInstanceEntityManager(); - HistoricCaseInstanceEntity historicCaseInstance = historicCaseInstanceEntityManager.findById(caseInstanceId); - historicCaseInstance.setCaseDefinitionId(caseDefinitionId); - historicCaseInstanceEntityManager.update(historicCaseInstance); - - HistoricTaskService historicTaskService = cmmnEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService(); - HistoricTaskInstanceQueryImpl taskQuery = new HistoricTaskInstanceQueryImpl(); - taskQuery.caseInstanceId(caseInstanceId); - List historicTasks = historicTaskService.findHistoricTaskInstancesByQueryCriteria(taskQuery); - if (historicTasks != null) { - for (HistoricTaskInstance historicTaskInstance : historicTasks) { - HistoricTaskInstanceEntity taskEntity = (HistoricTaskInstanceEntity) historicTaskInstance; - taskEntity.setScopeDefinitionId(caseDefinitionId); - historicTaskService.updateHistoricTask(taskEntity, true); - } - } - - // because of upgrade runtimeActivity instances can be only subset of historicActivity instances - HistoricPlanItemInstanceQueryImpl historicPlanItemQuery = new HistoricPlanItemInstanceQueryImpl(); - historicPlanItemQuery.planItemInstanceCaseInstanceId(caseInstanceId); - HistoricPlanItemInstanceEntityManager historicPlanItemInstanceEntityManager = cmmnEngineConfiguration.getHistoricPlanItemInstanceEntityManager(); - List historicPlanItems = historicPlanItemInstanceEntityManager.findByCriteria(historicPlanItemQuery); - if (historicPlanItems != null) { - for (HistoricPlanItemInstance historicPlanItemInstance : historicPlanItems) { - HistoricPlanItemInstanceEntity planItemEntity = (HistoricPlanItemInstanceEntity) historicPlanItemInstance; - planItemEntity.setCaseDefinitionId(caseDefinitionId); - historicPlanItemInstanceEntityManager.update(planItemEntity); - } - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableCreatedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableCreatedHistoryJsonTransformer.java deleted file mode 100644 index dc656fce070..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableCreatedHistoryJsonTransformer.java +++ /dev/null @@ -1,94 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDoubleFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getIntegerFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getLongFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Base64; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.variable.api.types.VariableType; -import org.flowable.variable.api.types.VariableTypes; -import org.flowable.variable.service.HistoricVariableService; -import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class VariableCreatedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public VariableCreatedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_VARIABLE_CREATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricVariableService historicVariableService = cmmnEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService(); - HistoricVariableInstanceEntity historicVariableInstanceEntity = historicVariableService.createHistoricVariableInstance(); - historicVariableInstanceEntity.setId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - historicVariableInstanceEntity.setScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_ID)); - historicVariableInstanceEntity.setSubScopeId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SUB_SCOPE_ID)); - historicVariableInstanceEntity.setScopeType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_SCOPE_TYPE)); - historicVariableInstanceEntity.setTaskId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_TASK_ID)); - historicVariableInstanceEntity.setExecutionId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_EXECUTION_ID)); - historicVariableInstanceEntity.setProcessInstanceId(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_PROCESS_INSTANCE_ID)); - historicVariableInstanceEntity.setRevision(getIntegerFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_REVISION)); - historicVariableInstanceEntity.setName(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_NAME)); - - VariableTypes variableTypes = cmmnEngineConfiguration.getVariableTypes(); - VariableType variableType = variableTypes.getVariableType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_TYPE)); - - historicVariableInstanceEntity.setVariableType(variableType); - - historicVariableInstanceEntity.setTextValue(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_TEXT_VALUE)); - historicVariableInstanceEntity.setTextValue2(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_TEXT_VALUE2)); - historicVariableInstanceEntity.setDoubleValue(getDoubleFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_DOUBLE_VALUE)); - historicVariableInstanceEntity.setLongValue(getLongFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_LONG_VALUE)); - historicVariableInstanceEntity.setMetaInfo(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_META_INFO)); - - String variableBytes = getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_BYTES_VALUE); - if (StringUtils.isNotEmpty(variableBytes)) { - historicVariableInstanceEntity.setBytes(Base64.getDecoder().decode(variableBytes)); - } - - Date time = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_CREATE_TIME); - historicVariableInstanceEntity.setCreateTime(time); - historicVariableInstanceEntity.setLastUpdatedTime(time); - - historicVariableService.insertHistoricVariableInstance(historicVariableInstanceEntity); - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableRemovedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableRemovedHistoryJsonTransformer.java deleted file mode 100644 index 695e60c77ae..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableRemovedHistoryJsonTransformer.java +++ /dev/null @@ -1,60 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class VariableRemovedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public VariableRemovedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_VARIABLE_REMOVED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return getHistoricVariableInstanceEntity(historicalData, commandContext) != null; - } - - protected HistoricVariableInstanceEntity getHistoricVariableInstanceEntity(ObjectNode historicalData, CommandContext commandContext) { - return cmmnEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService() - .getHistoricVariableInstance(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricVariableInstanceEntity historicVariable = getHistoricVariableInstanceEntity(historicalData, commandContext); - if (historicVariable != null) { - cmmnEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService().deleteHistoricVariableInstance(historicVariable); - } - } - -} diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableUpdatedHistoryJsonTransformer.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableUpdatedHistoryJsonTransformer.java deleted file mode 100644 index d6c6fc6135e..00000000000 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/history/async/json/transformer/VariableUpdatedHistoryJsonTransformer.java +++ /dev/null @@ -1,90 +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.cmmn.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDoubleFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getLongFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Base64; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.history.async.CmmnAsyncHistoryConstants; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.variable.api.types.VariableType; -import org.flowable.variable.api.types.VariableTypes; -import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - */ -public class VariableUpdatedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public VariableUpdatedHistoryJsonTransformer(CmmnEngineConfiguration cmmnEngineConfiguration) { - super(cmmnEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(CmmnAsyncHistoryConstants.TYPE_VARIABLE_UPDATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return getHistoricVariableInstanceEntity(historicalData, commandContext) != null; - } - - protected HistoricVariableInstanceEntity getHistoricVariableInstanceEntity(ObjectNode historicalData, CommandContext commandContext) { - return cmmnEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService() - .getHistoricVariableInstance(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_ID)); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricVariableInstanceEntity historicVariable = getHistoricVariableInstanceEntity(historicalData, commandContext); - - Date time = getDateFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_LAST_UPDATE_TIME); - if (historicVariable.getLastUpdatedTime().after(time)) { - // If the historic variable already has a later time, we don't need to change its details - // to something that is already superseded by later data. - return; - } - - VariableTypes variableTypes = cmmnEngineConfiguration.getVariableTypes(); - VariableType variableType = variableTypes.getVariableType(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_TYPE)); - historicVariable.setVariableType(variableType); - - historicVariable.setTextValue(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_TEXT_VALUE)); - historicVariable.setTextValue2(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_TEXT_VALUE2)); - historicVariable.setDoubleValue(getDoubleFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_DOUBLE_VALUE)); - historicVariable.setLongValue(getLongFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_LONG_VALUE)); - - String variableBytes = getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_VARIABLE_BYTES_VALUE); - if (StringUtils.isNotEmpty(variableBytes)) { - historicVariable.setBytes(Base64.getDecoder().decode(variableBytes)); - } - - historicVariable.setMetaInfo(getStringFromJson(historicalData, CmmnAsyncHistoryConstants.FIELD_META_INFO)); - - historicVariable.setLastUpdatedTime(time); - } - -} diff --git a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.java b/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.java deleted file mode 100644 index c7ac0230333..00000000000 --- a/modules/flowable-cmmn-engine/src/test/java/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.java +++ /dev/null @@ -1,1653 +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.cmmn.test.async; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.assertj.core.api.Assertions.extractProperty; -import static org.assertj.core.api.Assertions.tuple; - -import java.time.Instant; -import java.time.temporal.ChronoField; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.flowable.cmmn.api.history.HistoricCaseInstance; -import org.flowable.cmmn.api.history.HistoricMilestoneInstance; -import org.flowable.cmmn.api.history.HistoricPlanItemInstance; -import org.flowable.cmmn.api.runtime.CaseInstance; -import org.flowable.cmmn.api.runtime.CaseInstanceState; -import org.flowable.cmmn.api.runtime.PlanItemDefinitionType; -import org.flowable.cmmn.api.runtime.PlanItemInstance; -import org.flowable.cmmn.api.runtime.PlanItemInstanceState; -import org.flowable.cmmn.api.runtime.UserEventListenerInstance; -import org.flowable.cmmn.engine.CmmnEngineConfiguration; -import org.flowable.cmmn.engine.impl.CmmnManagementServiceImpl; -import org.flowable.cmmn.engine.impl.util.CommandContextUtil; -import org.flowable.cmmn.engine.test.CmmnDeployment; -import org.flowable.cmmn.engine.test.impl.CmmnHistoryTestHelper; -import org.flowable.cmmn.test.impl.CustomCmmnConfigurationFlowableTestCase; -import org.flowable.common.engine.api.FlowableIllegalArgumentException; -import org.flowable.common.engine.api.FlowableObjectNotFoundException; -import org.flowable.common.engine.api.scope.ScopeTypes; -import org.flowable.common.engine.impl.interceptor.Command; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.common.engine.impl.interceptor.CommandExecutor; -import org.flowable.entitylink.api.EntityLinkType; -import org.flowable.entitylink.api.history.HistoricEntityLink; -import org.flowable.entitylink.api.history.HistoricEntityLinkService; -import org.flowable.identitylink.api.IdentityLink; -import org.flowable.identitylink.api.IdentityLinkType; -import org.flowable.identitylink.api.history.HistoricIdentityLink; -import org.flowable.job.api.HistoryJob; -import org.flowable.job.api.Job; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.api.history.HistoricTaskLogEntry; -import org.flowable.task.api.history.HistoricTaskLogEntryBuilder; -import org.flowable.task.api.history.HistoricTaskLogEntryType; -import org.flowable.variable.api.history.HistoricVariableInstance; -import org.flowable.variable.service.VariableServiceConfiguration; -import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity; -import org.junit.Assert; -import org.junit.Test; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Joram Barrez - * @author Filip Hrisafov - */ -public class AsyncCmmnHistoryTest extends CustomCmmnConfigurationFlowableTestCase { - - @Override - protected String getEngineName() { - return "AsyncCmmnHistoryTest"; - } - - @Override - protected void configureConfiguration(CmmnEngineConfiguration cmmnEngineConfiguration) { - cmmnEngineConfiguration.setAsyncHistoryEnabled(true); - cmmnEngineConfiguration.setAsyncExecutorActivate(false); - cmmnEngineConfiguration.setAsyncHistoryExecutorActivate(false); - cmmnEngineConfiguration.setAsyncHistoryJsonGroupingEnabled(true); - cmmnEngineConfiguration.setAsyncHistoryJsonGroupingThreshold(1); - cmmnEngineConfiguration.setAsyncFailedJobWaitTime(100); - cmmnEngineConfiguration.setDefaultFailedJobWaitTime(100); - cmmnEngineConfiguration.setAsyncHistoryExecutorNumberOfRetries(10); - cmmnEngineConfiguration.setAsyncHistoryExecutorDefaultAsyncJobAcquireWaitTime(1000); - } - - @Test - @CmmnDeployment - public void testCaseInstanceStartAndEnd() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .name("someName") - .businessKey("someBusinessKey") - .callbackId("someCallbackId") - .callbackType("someCallbackType") - .referenceId("someReferenceId") - .referenceType("someReferenceType") - .start(); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isZero(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - - HistoricCaseInstance historicCaseInstance = cmmnHistoryService.createHistoricCaseInstanceQuery().singleResult(); - assertThat(historicCaseInstance.getId()).isEqualTo(caseInstance.getId()); - assertThat(historicCaseInstance.getName()).isEqualTo("someName"); - assertThat(historicCaseInstance.getParentId()).isNull(); - assertThat(historicCaseInstance.getBusinessKey()).isEqualTo("someBusinessKey"); - assertThat(historicCaseInstance.getCaseDefinitionId()).isEqualTo(caseInstance.getCaseDefinitionId()); - assertThat(historicCaseInstance.getCaseDefinitionKey()).isEqualTo("oneHumanTaskCase"); - assertThat(historicCaseInstance.getCaseDefinitionName()).isEqualTo("oneHumanTaskCaseName"); - assertThat(historicCaseInstance.getCaseDefinitionVersion()).isEqualTo(1); - assertThat(historicCaseInstance.getCaseDefinitionDeploymentId()).isEqualTo(caseInstance.getCaseDefinitionDeploymentId()); - assertThat(historicCaseInstance.getState()).isEqualTo(CaseInstanceState.ACTIVE); - assertThat(historicCaseInstance.getCallbackId()).isEqualTo("someCallbackId"); - assertThat(historicCaseInstance.getCallbackType()).isEqualTo("someCallbackType"); - assertThat(historicCaseInstance.getReferenceId()).isEqualTo("someReferenceId"); - assertThat(historicCaseInstance.getReferenceType()).isEqualTo("someReferenceType"); - assertThat(historicCaseInstance.getStartTime()).isNotNull(); - assertThat(historicCaseInstance.getEndTime()).isNull(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertCaseInstanceEnded(caseInstance); - historicCaseInstance = cmmnHistoryService.createHistoricCaseInstanceQuery().singleResult(); - assertThat(historicCaseInstance.getId()).isEqualTo(caseInstance.getId()); - assertThat(historicCaseInstance.getName()).isEqualTo("someName"); - assertThat(historicCaseInstance.getParentId()).isNull(); - assertThat(historicCaseInstance.getBusinessKey()).isEqualTo("someBusinessKey"); - assertThat(historicCaseInstance.getCaseDefinitionId()).isEqualTo(caseInstance.getCaseDefinitionId()); - assertThat(historicCaseInstance.getState()).isEqualTo(CaseInstanceState.COMPLETED); - assertThat(historicCaseInstance.getCallbackId()).isEqualTo("someCallbackId"); - assertThat(historicCaseInstance.getCallbackType()).isEqualTo("someCallbackType"); - assertThat(historicCaseInstance.getReferenceId()).isEqualTo("someReferenceId"); - assertThat(historicCaseInstance.getReferenceType()).isEqualTo("someReferenceType"); - assertThat(historicCaseInstance.getStartTime()).isNotNull(); - assertThat(historicCaseInstance.getEndTime()).isNotNull(); - } - - @Test - @CmmnDeployment - public void testHistoricCaseInstanceDeleted() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .name("someName") - .businessKey("someBusinessKey") - .variable("test", "test") - .start(); - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - cmmnHistoryService.deleteHistoricCaseInstance(caseInstance.getId()); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isZero(); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoricCaseInstanceDeleted.cmmn") - public void testHistoricCaseInstanceBulkDeleted() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .name("someName") - .businessKey("someBusinessKey") - .variable("test", "test") - .start(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - CaseInstance caseInstance2 = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .name("someName") - .businessKey("someBusinessKey") - .variable("test", "test") - .start(); - - Task task2 = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance2.getId()).singleResult(); - cmmnTaskService.complete(task2.getId()); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - CaseInstance caseInstance3 = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .name("someName") - .businessKey("someBusinessKey") - .variable("test", "test") - .start(); - - Task task3 = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance3.getId()).singleResult(); - cmmnTaskService.complete(task3.getId()); - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().count()).isEqualTo(0); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(3); - List instanceIdList = new ArrayList<>(); - instanceIdList.add(caseInstance.getId()); - instanceIdList.add(caseInstance2.getId()); - cmmnHistoryService.bulkDeleteHistoricCaseInstances(instanceIdList); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoricCaseInstanceDeleted.cmmn") - public void testInvalidHistoricCaseInstanceBulkDeleted() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .name("someName") - .businessKey("someBusinessKey") - .variable("test", "test") - .start(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - CaseInstance caseInstance2 = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .name("someName") - .businessKey("someBusinessKey") - .variable("test", "test") - .start(); - - Task task2 = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance2.getId()).singleResult(); - cmmnTaskService.complete(task2.getId()); - - CaseInstance caseInstance3 = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .name("someName") - .businessKey("someBusinessKey") - .variable("test", "test") - .start(); - - Task task3 = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance3.getId()).singleResult(); - cmmnTaskService.complete(task3.getId()); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - Set caseInstanceIdList = new HashSet<>(); - caseInstanceIdList.add(caseInstance.getId()); - caseInstanceIdList.add(caseInstance2.getId()); - caseInstanceIdList.add("inValidId"); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(3); - - cmmnHistoryService.bulkDeleteHistoricCaseInstances(caseInstanceIdList); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - - assertThatThrownBy(() -> cmmnHistoryService.bulkDeleteHistoricCaseInstances(null)) - .isInstanceOf(FlowableIllegalArgumentException.class).hasMessage("historic case instanceIds are null"); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/history/testStartSimplePassthroughCaseInstanceLevel.cmmn") - public void testInstanceLevelSTP() { - cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("myCase") - .variable("var1", "test") - .variable("var2", 10) - .start(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/history/testStartSimplePassthroughCaseCustomLevelPlanItems.cmmn") - public void testCustomLevelPlanItemsSTP() { - cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("myCase") - .variable("var1", "test") - .variable("var2", 10) - .start(); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isEqualTo(2); - - List planItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery().list(); - assertThat(planItemInstances) - .extracting(HistoricPlanItemInstance::getPlanItemDefinitionId, - HistoricPlanItemInstance::getPlanItemDefinitionType) - .containsOnly( - tuple("taskA", "task"), - tuple("mileStoneTwo", "milestone") - ); - - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().singleResult().getElementId()).isEqualTo("planItemMileStoneTwo"); - - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/history/testTwoTaskCase.cmmn") - public void testDefaultHistoryLevelTwoTasks() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("myCase") - .variable("var1", "test") - .variable("var2", 10) - .start(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isEqualTo(2); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isEqualTo(3); - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isEqualTo(2); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/history/testTwoTaskCaseInstanceLevel.cmmn") - public void testInstanceLevelTwoTasks() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("myCase") - .variable("var1", "test") - .variable("var2", 10) - .start(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/history/testTwoTaskCaseInstanceLevelPlanItems.cmmn") - public void testInstanceLevelTwoTasksWithCustomPlanItems() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("myCase") - .variable("var1", "test") - .variable("var2", 10) - .start(); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isEqualTo(2); - - List planItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery().list(); - assertThat(planItemInstances) - .extracting(HistoricPlanItemInstance::getPlanItemDefinitionId, - HistoricPlanItemInstance::getPlanItemDefinitionType, - HistoricPlanItemInstance::getState) - .containsOnly( - tuple("taskB", "humantask", PlanItemInstanceState.AVAILABLE), - tuple("mileStoneOne", "milestone", PlanItemInstanceState.AVAILABLE) - ); - - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isEqualTo(2); - - planItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery().list(); - assertThat(planItemInstances) - .extracting(HistoricPlanItemInstance::getPlanItemDefinitionId, - HistoricPlanItemInstance::getPlanItemDefinitionType, - HistoricPlanItemInstance::getState) - .containsOnly( - tuple("taskB", "humantask", PlanItemInstanceState.ACTIVE), - tuple("mileStoneOne", "milestone", PlanItemInstanceState.AVAILABLE) - ); - - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - - task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isEqualTo(2); - - planItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery().list(); - assertThat(planItemInstances) - .extracting(HistoricPlanItemInstance::getPlanItemDefinitionId, - HistoricPlanItemInstance::getPlanItemDefinitionType, - HistoricPlanItemInstance::getState) - .containsOnly( - tuple("taskB", "humantask", PlanItemInstanceState.COMPLETED), - tuple("mileStoneOne", "milestone", PlanItemInstanceState.COMPLETED) - ); - - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/history/testTwoTaskCaseTaskLevel.cmmn") - public void testTaskLevelTwoTasks() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("myCase") - .variable("var1", "test") - .variable("var2", 10) - .start(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isEqualTo(2); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/history/testTwoTaskCaseTaskLevelPlanItems.cmmn") - public void testTaskLevelTwoTasksWithCustomPlanItems() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("myCase") - .variable("var1", "test") - .variable("var2", 10) - .start(); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isEqualTo(2); - - List planItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery().list(); - assertThat(planItemInstances) - .extracting(HistoricPlanItemInstance::getPlanItemDefinitionId, - HistoricPlanItemInstance::getPlanItemDefinitionType, - HistoricPlanItemInstance::getState) - .containsOnly( - tuple("taskB", "humantask", PlanItemInstanceState.AVAILABLE), - tuple("mileStoneOne", "milestone", PlanItemInstanceState.AVAILABLE) - ); - - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isEqualTo(2); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isEqualTo(2); - - planItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery().list(); - assertThat(planItemInstances) - .extracting(HistoricPlanItemInstance::getPlanItemDefinitionId, - HistoricPlanItemInstance::getPlanItemDefinitionType, - HistoricPlanItemInstance::getState) - .containsOnly( - tuple("taskB", "humantask", PlanItemInstanceState.ACTIVE), - tuple("mileStoneOne", "milestone", PlanItemInstanceState.AVAILABLE) - ); - - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isZero(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - - task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().count()).isEqualTo(2); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().count()).isEqualTo(2); - - planItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery().list(); - assertThat(planItemInstances) - .extracting(HistoricPlanItemInstance::getPlanItemDefinitionId, - HistoricPlanItemInstance::getPlanItemDefinitionType, - HistoricPlanItemInstance::getState) - .containsOnly( - tuple("taskB", "humantask", PlanItemInstanceState.COMPLETED), - tuple("mileStoneOne", "milestone", PlanItemInstanceState.COMPLETED) - ); - - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().count()).isZero(); - } - - @Test - public void testCreateTaskHistory() { - Task task = cmmnTaskService.createTaskBuilder().id("task1").create(); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult()).isNull(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult()).isNotNull(); - assertThat(task.getId()).isEqualTo("task1"); - - cmmnTaskService.deleteTask(task.getId(), true); - } - - @Test - public void testDeleteHistoricTask() { - Task task = cmmnTaskService.createTaskBuilder().id("task1").create(); - cmmnTaskService.complete(task.getId()); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().taskId("task1").singleResult()).isNotNull(); - cmmnHistoryService.deleteHistoricTaskInstance("task1"); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().taskId("task1").singleResult()).isNull(); - } - - @Test - @CmmnDeployment - public void testMilestoneReached() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("caseWithOneMilestone").start(); - assertThat(cmmnRuntimeService.createMilestoneInstanceQuery().milestoneInstanceCaseInstanceId(caseInstance.getId()).count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().milestoneInstanceCaseInstanceId(caseInstance.getId()).count()).isZero(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnHistoryService.createHistoricMilestoneInstanceQuery().milestoneInstanceCaseInstanceId(caseInstance.getId()).count()).isEqualTo(1); - HistoricMilestoneInstance historicMilestoneInstance = cmmnHistoryService.createHistoricMilestoneInstanceQuery() - .milestoneInstanceCaseInstanceId(caseInstance.getId()) - .singleResult(); - assertThat(historicMilestoneInstance.getName()).isEqualTo("xyzMilestone"); - assertThat(historicMilestoneInstance.getElementId()).isEqualTo("milestonePlanItem1"); - assertThat(historicMilestoneInstance.getCaseInstanceId()).isEqualTo(caseInstance.getId()); - assertThat(historicMilestoneInstance.getCaseDefinitionId()).isEqualTo(caseInstance.getCaseDefinitionId()); - assertThat(historicMilestoneInstance.getTimeStamp()).isNotNull(); - } - - @Test - @CmmnDeployment - public void testIdentityLinks() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("caseWithOneMilestone").start(); - cmmnRuntimeService.addUserIdentityLink(caseInstance.getId(), "someUser", IdentityLinkType.PARTICIPANT); - assertThat(cmmnHistoryService.getHistoricIdentityLinksForCaseInstance(caseInstance.getId())).isEmpty(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.getHistoricIdentityLinksForCaseInstance(caseInstance.getId())).hasSize(1); - - cmmnRuntimeService.deleteUserIdentityLink(caseInstance.getId(), "someUser", IdentityLinkType.PARTICIPANT); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.getHistoricIdentityLinksForCaseInstance(caseInstance.getId())).isEmpty(); - } - - @Test - @CmmnDeployment - public void testVariables() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").start(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().caseInstanceId(caseInstance.getId()).count()).isZero(); - - cmmnRuntimeService.setVariable(caseInstance.getId(), "test", "hello world"); - cmmnRuntimeService.setVariable(caseInstance.getId(), "test2", 2); - - // Create - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().caseInstanceId(caseInstance.getId()).count()).isEqualTo(2); - - HistoricVariableInstance historicVariableInstance = cmmnHistoryService.createHistoricVariableInstanceQuery().caseInstanceId(caseInstance.getId()) - .variableName("test").singleResult(); - assertThat(historicVariableInstance.getVariableName()).isEqualTo("test"); - assertThat(historicVariableInstance.getScopeId()).isEqualTo(caseInstance.getId()); - assertThat(historicVariableInstance.getScopeType()).isEqualTo(ScopeTypes.CMMN); - assertThat(historicVariableInstance.getValue()).isEqualTo("hello world"); - assertThat(historicVariableInstance.getCreateTime()).isNotNull(); - assertThat(historicVariableInstance.getLastUpdatedTime()).isNotNull(); - - historicVariableInstance = cmmnHistoryService.createHistoricVariableInstanceQuery().caseInstanceId(caseInstance.getId()).variableName("test2") - .singleResult(); - assertThat(historicVariableInstance.getVariableName()).isEqualTo("test2"); - assertThat(historicVariableInstance.getScopeId()).isEqualTo(caseInstance.getId()); - assertThat(historicVariableInstance.getSubScopeId()).isNull(); - assertThat(historicVariableInstance.getScopeType()).isEqualTo(ScopeTypes.CMMN); - assertThat(historicVariableInstance.getValue()).isEqualTo(2); - assertThat(historicVariableInstance.getCreateTime()).isNotNull(); - assertThat(historicVariableInstance.getLastUpdatedTime()).isNotNull(); - - // Update - try { - Thread.sleep(16); // wait time for diff in last updated time - } catch (InterruptedException e) { - e.printStackTrace(); - } - cmmnRuntimeService.setVariable(caseInstance.getId(), "test", "hello test"); - waitForAsyncHistoryExecutorToProcessAllJobs(); - - HistoricVariableInstance updatedHistoricVariable = cmmnHistoryService.createHistoricVariableInstanceQuery().caseInstanceId(caseInstance.getId()) - .variableName("test").singleResult(); - assertThat(updatedHistoricVariable.getVariableName()).isEqualTo("test"); - assertThat(updatedHistoricVariable.getScopeId()).isEqualTo(caseInstance.getId()); - assertThat(updatedHistoricVariable.getSubScopeId()).isNull(); - assertThat(updatedHistoricVariable.getScopeType()).isEqualTo(ScopeTypes.CMMN); - assertThat(updatedHistoricVariable.getValue()).isEqualTo("hello test"); - assertThat(updatedHistoricVariable.getCreateTime()).isNotNull(); - assertThat(updatedHistoricVariable.getLastUpdatedTime()).isNotNull(); - assertThat(historicVariableInstance.getLastUpdatedTime()).isNotEqualTo(updatedHistoricVariable.getLastUpdatedTime()); - - // Delete - cmmnRuntimeService.removeVariable(caseInstance.getId(), "test"); - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().caseInstanceId(caseInstance.getId()).variableName("test").singleResult()).isNull(); - } - - @Test - @CmmnDeployment - public void testHumanTask() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").start(); - assertThat(cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).count()).isZero(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).count()).isEqualTo(1); - - // Create - HistoricTaskInstance historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getName()).isEqualTo("The Task"); - assertThat(historicTaskInstance.getAssignee()).isEqualTo("johnDoe"); - assertThat(historicTaskInstance.getScopeId()).isEqualTo(caseInstance.getId()); - assertThat(historicTaskInstance.getScopeDefinitionId()).isEqualTo(caseInstance.getCaseDefinitionId()); - assertThat(historicTaskInstance.getScopeType()).isEqualTo(ScopeTypes.CMMN); - assertThat(historicTaskInstance.getCreateTime()).isNotNull(); - - // Update - cmmnTaskService.setAssignee(historicTaskInstance.getId(), "janeDoe"); - waitForAsyncHistoryExecutorToProcessAllJobs(); - - historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getName()).isEqualTo("The Task"); - assertThat(historicTaskInstance.getAssignee()).isEqualTo("janeDoe"); - - cmmnTaskService.setPriority(historicTaskInstance.getId(), 99); - waitForAsyncHistoryExecutorToProcessAllJobs(); - historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getPriority()).isEqualTo(99); - assertThat(historicTaskInstance.getEndTime()).isNull(); - - List planItemInstances = cmmnRuntimeService.createPlanItemInstanceQuery() - .planItemDefinitionType(PlanItemDefinitionType.HUMAN_TASK) - .orderByName().asc() - .list(); - assertThat(planItemInstances).extracting(PlanItemInstance::getName).containsExactly("The Task"); - assertThat(planItemInstances).extracting(PlanItemInstance::getCreateTime).isNotNull(); - - // Complete - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - assertThat(cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).count()).isZero(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getEndTime()).isNotNull(); - - List historicPlanItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery() - .planItemInstanceDefinitionType(PlanItemDefinitionType.HUMAN_TASK) - .list(); - assertThat(historicPlanItemInstances).extracting(HistoricPlanItemInstance::getName).containsExactly("The Task"); - assertThat(historicPlanItemInstances).extracting(HistoricPlanItemInstance::getCreateTime).isNotNull(); - } - - @Test - @CmmnDeployment - public void testHumanTaskWithCandidateUsersAndGroups() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").start(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(task).isNotNull(); - assertThat(cmmnTaskService.getIdentityLinksForTask(task.getId())) - .extracting(IdentityLink::getType, IdentityLink::getUserId, IdentityLink::getGroupId) - .containsExactlyInAnyOrder( - tuple("assignee", "johnDoe", null), - tuple("candidate", "user1", null), - tuple("candidate", null, "group1"), - tuple("candidate", null, "group2") - ); - - assertThatThrownBy(() -> cmmnHistoryService.getHistoricIdentityLinksForTask(task.getId())) - .isInstanceOf(FlowableObjectNotFoundException.class) - .hasMessageContaining("No historic task exists"); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnHistoryService.getHistoricIdentityLinksForTask(task.getId())) - .extracting(HistoricIdentityLink::getType, HistoricIdentityLink::getUserId, HistoricIdentityLink::getGroupId) - .containsExactlyInAnyOrder( - tuple("assignee", "johnDoe", null), - tuple("candidate", "user1", null), - tuple("candidate", null, "group1"), - tuple("candidate", null, "group2") - ); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTask.cmmn") - public void testHumanTaskWithNameDueDateAndDescription() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("oneHumanTaskCase").start(); - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(task).isNotNull(); - task.setName("Test name"); - task.setDescription("Test description"); - cmmnTaskService.saveTask(task); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - // Create - HistoricTaskInstance historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance).isNotNull(); - assertThat(historicTaskInstance.getName()).isEqualTo("Test name"); - assertThat(historicTaskInstance.getDescription()).isEqualTo("Test description"); - assertThat(historicTaskInstance.getDueDate()).isNull(); - - // Set due date - Date dueDate = Date.from(Instant.now().with(ChronoField.MILLI_OF_SECOND, 0)); - cmmnTaskService.setDueDate(task.getId(), dueDate); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getDueDate()).isEqualTo(dueDate); - - // Update name and description to null - task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - task.setName(null); - task.setDescription(null); - cmmnTaskService.saveTask(task); - - // Before the history jobs it has the old data - historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getName()).isEqualTo("Test name"); - assertThat(historicTaskInstance.getDescription()).isEqualTo("Test description"); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - // After the history jobs it has the new data - historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getName()).isNull(); - assertThat(historicTaskInstance.getDescription()).isNull(); - - // Update dueDate to null - cmmnTaskService.setDueDate(task.getId(), null); - - // Before the history jobs it has the old data - historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getDueDate()).isEqualTo(dueDate); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - // After the history jobs it has the new data - historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getDueDate()).isNull(); - } - - @Test - @CmmnDeployment - public void testCasePageTask() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("oneCasePageTask").start(); - assertThat(cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).count()).isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstance.getId()).count()).isZero(); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).count()).isZero(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstance.getId()).count()).isEqualTo(2); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).count()).isEqualTo(1); - - HistoricPlanItemInstance historicPlanItemInstance = cmmnHistoryService.createHistoricPlanItemInstanceQuery() - .planItemInstanceFormKey("testKey") - .planItemInstanceCaseInstanceId(caseInstance.getId()) - .singleResult(); - assertThat(historicPlanItemInstance.getName()).isEqualTo("The Case Page Task"); - assertThat(historicPlanItemInstance.getFormKey()).isEqualTo("testKey"); - assertThat(historicPlanItemInstance.getExtraValue()).isEqualTo("testKey"); - assertThat(historicPlanItemInstance.getEndedTime()).isNull(); - - List historicIdentityLinks = cmmnHistoryService.getHistoricIdentityLinksForPlanItemInstance(historicPlanItemInstance.getId()); - assertThat(historicIdentityLinks).hasSize(5); - - List historicAssigneeLink = historicIdentityLinks.stream() - .filter(identityLink -> identityLink.getType().equals(IdentityLinkType.ASSIGNEE)).collect(Collectors.toList()); - assertThat(historicAssigneeLink) - .extracting(HistoricIdentityLink::getUserId) - .containsExactly("johnDoe"); - - List historicOwnerLink = historicIdentityLinks.stream() - .filter(identityLink -> identityLink.getType().equals(IdentityLinkType.OWNER)).collect(Collectors.toList()); - assertThat(historicOwnerLink) - .extracting(HistoricIdentityLink::getUserId) - .containsExactly("janeDoe"); - - List historicCandidateUserLinks = historicIdentityLinks.stream() - .filter(identityLink -> identityLink.getType().equals(IdentityLinkType.CANDIDATE) && - identityLink.getUserId() != null).collect(Collectors.toList()); - - assertThat(extractProperty("userId").from(historicCandidateUserLinks)) - .containsExactlyInAnyOrder("johnDoe", "janeDoe"); - - List historicGroupLink = historicIdentityLinks.stream() - .filter(identityLink -> identityLink.getType().equals(IdentityLinkType.CANDIDATE) && - identityLink.getGroupId() != null).collect(Collectors.toList()); - assertThat(historicGroupLink) - .extracting(HistoricIdentityLink::getGroupId) - .containsExactly("sales"); - - // Complete - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - assertThat(cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).count()).isZero(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - HistoricTaskInstance historicTaskInstance = cmmnHistoryService.createHistoricTaskInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getEndTime()).isNotNull(); - - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstance.getId()).count()).isEqualTo(2); - historicPlanItemInstance = cmmnHistoryService.createHistoricPlanItemInstanceQuery() - .planItemInstanceFormKey("testKey") - .planItemInstanceCaseInstanceId(caseInstance.getId()) - .singleResult(); - assertThat(historicPlanItemInstance.getEndedTime()).isNotNull(); - } - - @Test - @CmmnDeployment - public void testPlanItemInstances() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("testSimpleCaseFlow").start(); - List currentPlanItemInstances = cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()).list(); - assertThat(currentPlanItemInstances).hasSize(3); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstance.getId()).count()).isZero(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstance.getId()).count()).isEqualTo(3); - - List historicPlanItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery() - .planItemInstanceCaseInstanceId(caseInstance.getId()).list(); - assertThat(historicPlanItemInstances.stream().map(HistoricPlanItemInstance::getPlanItemDefinitionType) - .anyMatch(PlanItemDefinitionType.STAGE::equalsIgnoreCase)).isTrue(); - assertThat(historicPlanItemInstances.stream().map(HistoricPlanItemInstance::getPlanItemDefinitionType) - .anyMatch(PlanItemDefinitionType.MILESTONE::equalsIgnoreCase)).isTrue(); - assertThat(historicPlanItemInstances.stream() - .anyMatch(h -> "task".equalsIgnoreCase(h.getPlanItemDefinitionType()) && "planItemTaskA".equalsIgnoreCase(h.getElementId()))).isTrue(); - - boolean showInOverviewMilestone = false; - Date lastEnabledTimeTaskA = null; - for (HistoricPlanItemInstance historicPlanItemInstance : historicPlanItemInstances) { - assertThat(historicPlanItemInstance.getCaseInstanceId()).isEqualTo(caseInstance.getId()); - assertThat(historicPlanItemInstance.getCaseDefinitionId()).isEqualTo(caseInstance.getCaseDefinitionId()); - - assertThat(historicPlanItemInstance) - .extracting( - HistoricPlanItemInstance::getElementId, - HistoricPlanItemInstance::getCreateTime, - HistoricPlanItemInstance::getLastAvailableTime) - .doesNotContainNull(); - assertThat(historicPlanItemInstance) - .extracting( - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastSuspendedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getTerminatedTime, - HistoricPlanItemInstance::getEntryCriterionId, - HistoricPlanItemInstance::getExitCriterionId) - .containsOnlyNulls(); - - if ("planItemTaskA".equals(historicPlanItemInstance.getElementId())) { - lastEnabledTimeTaskA = historicPlanItemInstance.getLastEnabledTime(); - } else if ("planItemMilestoneOne".equals(historicPlanItemInstance.getElementId())) { - showInOverviewMilestone = historicPlanItemInstance.isShowInOverview(); - } else { - assertThat(historicPlanItemInstance.getLastEnabledTime()).isNull(); - } - } - - assertThat(lastEnabledTimeTaskA).isNotNull(); - assertThat(showInOverviewMilestone).isTrue(); - - // Disable task - PlanItemInstance task = cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceElementId("planItemTaskA").singleResult(); - assertThat(task).isNotNull(); - - cmmnRuntimeService.disablePlanItemInstance(task.getId()); - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnManagementService.createHistoryJobQuery().scopeType(ScopeTypes.CMMN).count()).isZero(); - assertThat(cmmnManagementService.createDeadLetterJobQuery().scopeType(ScopeTypes.CMMN).count()).isZero(); - - HistoricPlanItemInstance historicPlanItemInstance = cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceId(task.getId()) - .singleResult(); - assertThat(historicPlanItemInstance.getState()).isEqualTo(PlanItemInstanceState.DISABLED); - assertThat(historicPlanItemInstance) - .extracting( - HistoricPlanItemInstance::getLastEnabledTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastAvailableTime, - HistoricPlanItemInstance::getLastUpdatedTime) - .doesNotContainNull(); - assertThat(historicPlanItemInstance) - .extracting( - HistoricPlanItemInstance::getLastStartedTime, - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getLastSuspendedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getTerminatedTime) - .containsOnlyNulls(); - - // Enable task - cmmnRuntimeService.enablePlanItemInstance(task.getId()); - waitForAsyncHistoryExecutorToProcessAllJobs(); - historicPlanItemInstance = cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceId(task.getId()).singleResult(); - assertThat(historicPlanItemInstance.getState()).isEqualTo(PlanItemInstanceState.ENABLED); - - assertThat(historicPlanItemInstance) - .extracting( - HistoricPlanItemInstance::getLastEnabledTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastAvailableTime, - HistoricPlanItemInstance::getLastUpdatedTime) - .doesNotContainNull(); - assertThat(historicPlanItemInstance) - .extracting( - HistoricPlanItemInstance::getLastStartedTime, - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getLastSuspendedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getTerminatedTime) - .containsOnlyNulls(); - - // Manually enable - cmmnRuntimeService.startPlanItemInstance(task.getId()); - waitForAsyncHistoryExecutorToProcessAllJobs(); - - historicPlanItemInstance = cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceId(task.getId()).singleResult(); - assertThat(historicPlanItemInstance.getLastStartedTime()).isNotNull(); - assertThat(historicPlanItemInstance.getEndedTime()).isNull(); - - // Complete task - Calendar clockCal = cmmnEngineConfiguration.getClock().getCurrentCalendar(); - clockCal.add(Calendar.HOUR, 1); - setClockTo(clockCal.getTime()); - cmmnRuntimeService.triggerPlanItemInstance(task.getId()); - waitForAsyncHistoryExecutorToProcessAllJobs(); - - HistoricPlanItemInstance completedHistoricPlanItemInstance = cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceId(task.getId()) - .singleResult(); - assertThat(completedHistoricPlanItemInstance) - .extracting( - HistoricPlanItemInstance::getLastEnabledTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastAvailableTime, - HistoricPlanItemInstance::getLastStartedTime, - HistoricPlanItemInstance::getLastUpdatedTime) - .doesNotContainNull(); - assertThat(historicPlanItemInstance) - .extracting( - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getLastSuspendedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getTerminatedTime) - .containsOnlyNulls(); - - assertThat(historicPlanItemInstance.getLastUpdatedTime()).isBefore(completedHistoricPlanItemInstance.getLastUpdatedTime()); - - HistoricPlanItemInstance completedMilestoneInstance = cmmnHistoryService.createHistoricPlanItemInstanceQuery() - .planItemInstanceElementId("planItemMilestoneOne").singleResult(); - assertThat(completedMilestoneInstance.getEndedTime()).isNotNull(); - assertThat(completedMilestoneInstance.isShowInOverview()).isTrue(); - - cmmnEngineConfiguration.getClock().reset(); - } - - @Test - @CmmnDeployment - public void testCriterionStoredOnPlanItemInstance() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder().caseDefinitionKey("testCriterions").start(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - // Executing the tasks triggers the entry criterion - Task taskB = cmmnTaskService.createTaskQuery().taskName("B").singleResult(); - cmmnTaskService.complete(taskB.getId()); - - assertThat(cmmnRuntimeService.createPlanItemInstanceQuery().planItemInstanceName("C").singleResult().getEntryCriterionId()).isEqualTo("entryA2"); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - HistoricPlanItemInstance planItemInstanceC = cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceName("C").singleResult(); - assertThat(planItemInstanceC.getEntryCriterionId()).isEqualTo("entryA2"); - assertThat(planItemInstanceC.getExitCriterionId()).isNull(); - - // Completing will set the exit criterion - UserEventListenerInstance userEventListenerInstance = cmmnRuntimeService.createUserEventListenerInstanceQuery().caseInstanceId(caseInstance.getId()) - .singleResult(); - cmmnRuntimeService.completeUserEventListenerInstance(userEventListenerInstance.getId()); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - planItemInstanceC = cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceName("C").singleResult(); - assertThat(planItemInstanceC.getEntryCriterionId()).isEqualTo("entryA2"); - assertThat(planItemInstanceC.getExitCriterionId()).isEqualTo("stop"); - } - - @Test - public void createUserTaskLogEntity() { - HistoricTaskLogEntryBuilder historicTaskLogEntryBuilder = cmmnHistoryService.createHistoricTaskLogEntryBuilder(); - - Date todayDate = new Date(); - historicTaskLogEntryBuilder.taskId("1"); - historicTaskLogEntryBuilder.type("testType"); - historicTaskLogEntryBuilder.userId("testUserId"); - historicTaskLogEntryBuilder.data("testData"); - historicTaskLogEntryBuilder.scopeId("testScopeId"); - historicTaskLogEntryBuilder.scopeType("testScopeType"); - historicTaskLogEntryBuilder.scopeDefinitionId("testDefinitionId"); - historicTaskLogEntryBuilder.subScopeId("testSubScopeId"); - historicTaskLogEntryBuilder.timeStamp(todayDate); - historicTaskLogEntryBuilder.tenantId("testTenant"); - - historicTaskLogEntryBuilder.create(); - - HistoricTaskLogEntry historicTaskLogEntry = null; - try { - assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId("1").count()).isZero(); - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId("1").count()).isEqualTo(1); - - historicTaskLogEntry = cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId("1").singleResult(); - assertThat(historicTaskLogEntry.getLogNumber()).isPositive(); - assertThat(historicTaskLogEntry.getTaskId()).isEqualTo("1"); - assertThat(historicTaskLogEntry.getType()).isEqualTo("testType"); - assertThat(historicTaskLogEntry.getUserId()).isEqualTo("testUserId"); - assertThat(historicTaskLogEntry.getScopeId()).isEqualTo("testScopeId"); - assertThat(historicTaskLogEntry.getScopeType()).isEqualTo("testScopeType"); - assertThat(historicTaskLogEntry.getScopeDefinitionId()).isEqualTo("testDefinitionId"); - assertThat(historicTaskLogEntry.getSubScopeId()).isEqualTo("testSubScopeId"); - assertThat(historicTaskLogEntry.getData()).isEqualTo("testData"); - assertThat(historicTaskLogEntry.getLogNumber()).isPositive(); - assertThat(historicTaskLogEntry.getTimeStamp()).isNotNull(); - assertThat(historicTaskLogEntry.getTenantId()).isEqualTo("testTenant"); - } finally { - if (historicTaskLogEntry != null) { - cmmnHistoryService.deleteHistoricTaskLogEntry(historicTaskLogEntry.getLogNumber()); - waitForAsyncHistoryExecutorToProcessAllJobs(); - } - } - } - - @Test - public void createCmmnAsynchUserTaskLogEntries() { - CaseInstance caseInstance = deployAndStartOneHumanTaskCaseModel(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - task.setName("newName"); - task.setPriority(0); - cmmnTaskService.saveTask(task); - cmmnTaskService.setAssignee(task.getId(), "newAssignee"); - cmmnTaskService.setOwner(task.getId(), "newOwner"); - cmmnTaskService.setDueDate(task.getId(), new Date()); - cmmnTaskService.addUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT); - cmmnTaskService.addGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT); - cmmnTaskService.deleteUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT); - cmmnTaskService.deleteGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT); - cmmnTaskService.complete(task.getId()); - - assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().count()).isZero(); - assertThat(cmmnManagementService.createHistoryJobQuery().count()).isEqualTo(10); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).count()).isEqualTo(11); - assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_CREATED.name()).count()) - .isEqualTo(1); - assertThat( - cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_NAME_CHANGED.name()).count()) - .isEqualTo(1); - assertThat( - cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_PRIORITY_CHANGED.name()) - .count()) - .isEqualTo(1); - assertThat( - cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_ASSIGNEE_CHANGED.name()) - .count()) - .isEqualTo(1); - assertThat( - cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_OWNER_CHANGED.name()).count()) - .isEqualTo(1); - assertThat( - cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_DUEDATE_CHANGED.name()) - .count()) - .isEqualTo(1); - assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_ADDED.name()) - .count()).isEqualTo(2); - assertThat( - cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_REMOVED.name()) - .count()).isEqualTo(2); - assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_COMPLETED.name()).count()) - .isEqualTo(1); - } - - @Test - public void deleteAsynchUserTaskLogEntries() { - CaseInstance caseInstance = deployAndStartOneHumanTaskCaseModel(); - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().count()).isZero(); - assertThat(cmmnManagementService.createHistoryJobQuery().count()).isEqualTo(1); - waitForAsyncHistoryExecutorToProcessAllJobs(); - List historicTaskLogEntries = cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); - assertThat(historicTaskLogEntries).hasSize(1); - - cmmnHistoryService.deleteHistoricTaskLogEntry(historicTaskLogEntries.get(0).getLogNumber()); - - assertThat(cmmnManagementService.createHistoryJobQuery().count()).isEqualTo(1); - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricTaskLogEntryQuery().taskId(task.getId()).count()).isZero(); - } - - @Test - @CmmnDeployment - public void createRootEntityLink() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .name("someName") - .businessKey("someBusinessKey") - .start(); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isZero(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().count()).isEqualTo(1); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - cmmnTaskService.complete(task.getId()); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - assertCaseInstanceEnded(caseInstance); - - CommandExecutor commandExecutor = cmmnEngine.getCmmnEngineConfiguration().getCommandExecutor(); - - List entityLinksByScopeIdAndType = commandExecutor.execute(commandContext -> { - HistoricEntityLinkService historicEntityLinkService = cmmnEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService(); - - return historicEntityLinkService.findHistoricEntityLinksByReferenceScopeIdAndType(task.getId(), ScopeTypes.TASK, EntityLinkType.CHILD); - }); - - assertThat(entityLinksByScopeIdAndType) - .extracting(HistoricEntityLink::getHierarchyType) - .containsExactly("root"); - } - - @Test - @CmmnDeployment - public void testPlanItemInstancesStateChangesWithFixedTime() { - // We need to make sure the time ends on .000, .003 or .007 due to SQL Server rounding to that - Date fixTime = Date.from(Instant.now().truncatedTo(ChronoUnit.SECONDS).plusMillis(823)); - cmmnEngineConfiguration.getClock().setCurrentTime(fixTime); - - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("allStates") - .start(); - - List runtimePlanItemInstances = cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(caseInstance.getId()).list(); - assertThat(runtimePlanItemInstances) - .extracting(PlanItemInstance::getPlanItemDefinitionId, PlanItemInstance::getState) - .as("planItemDefinitionId, state") - .containsExactlyInAnyOrder( - tuple("eventListenerAvailable", PlanItemInstanceState.AVAILABLE), - tuple("eventListenerUnavailable", PlanItemInstanceState.UNAVAILABLE), - tuple("serviceTaskAvailableEnabled", PlanItemInstanceState.ENABLED), - tuple("serviceTaskAvailableAsyncActive", PlanItemInstanceState.ASYNC_ACTIVE) - ); - - Map runtimePlanItemInstancesByDefinitionId = runtimePlanItemInstances.stream() - .collect(Collectors.toMap(PlanItemInstance::getPlanItemDefinitionId, Function.identity())); - - PlanItemInstance eventListenerAvailable = runtimePlanItemInstancesByDefinitionId.get("eventListenerAvailable"); - - assertThat(eventListenerAvailable).extracting( - PlanItemInstance::getCompletedTime, - PlanItemInstance::getEndedTime, - PlanItemInstance::getOccurredTime, - PlanItemInstance::getTerminatedTime, - PlanItemInstance::getExitTime, - PlanItemInstance::getLastEnabledTime, - PlanItemInstance::getLastDisabledTime, - PlanItemInstance::getLastStartedTime, - PlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(eventListenerAvailable).extracting( - PlanItemInstance::getCreateTime, - PlanItemInstance::getLastAvailableTime - ).containsOnly(fixTime); - - PlanItemInstance eventListenerUnavailable = runtimePlanItemInstancesByDefinitionId.get("eventListenerUnavailable"); - - assertThat(eventListenerUnavailable).extracting( - PlanItemInstance::getCompletedTime, - PlanItemInstance::getEndedTime, - PlanItemInstance::getOccurredTime, - PlanItemInstance::getTerminatedTime, - PlanItemInstance::getExitTime, - PlanItemInstance::getLastEnabledTime, - PlanItemInstance::getLastAvailableTime, - PlanItemInstance::getLastDisabledTime, - PlanItemInstance::getLastStartedTime, - PlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(eventListenerUnavailable).extracting( - PlanItemInstance::getCreateTime - ).isEqualTo(fixTime); - - PlanItemInstance serviceTaskAvailableEnabled = runtimePlanItemInstancesByDefinitionId.get("serviceTaskAvailableEnabled"); - - assertThat(serviceTaskAvailableEnabled).extracting( - PlanItemInstance::getCompletedTime, - PlanItemInstance::getEndedTime, - PlanItemInstance::getOccurredTime, - PlanItemInstance::getTerminatedTime, - PlanItemInstance::getExitTime, - PlanItemInstance::getLastDisabledTime, - PlanItemInstance::getLastStartedTime, - PlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(serviceTaskAvailableEnabled).extracting( - PlanItemInstance::getCreateTime, - PlanItemInstance::getLastEnabledTime, - PlanItemInstance::getLastAvailableTime - ).containsOnly(fixTime); - - PlanItemInstance serviceTaskAvailableAsyncActive = runtimePlanItemInstancesByDefinitionId.get("serviceTaskAvailableAsyncActive"); - - assertThat(serviceTaskAvailableAsyncActive).extracting( - PlanItemInstance::getCompletedTime, - PlanItemInstance::getEndedTime, - PlanItemInstance::getOccurredTime, - PlanItemInstance::getTerminatedTime, - PlanItemInstance::getExitTime, - PlanItemInstance::getLastEnabledTime, - PlanItemInstance::getLastDisabledTime, - PlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(serviceTaskAvailableAsyncActive).extracting( - PlanItemInstance::getCreateTime, - PlanItemInstance::getLastAvailableTime, - PlanItemInstance::getLastStartedTime - ).containsOnly(fixTime); - - assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstance.getId()).list()) - .extracting(HistoricPlanItemInstance::getPlanItemDefinitionId, HistoricPlanItemInstance::getState) - .isEmpty(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - List historicPlanItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery() - .planItemInstanceCaseInstanceId(caseInstance.getId()) - .list(); - - assertThat(historicPlanItemInstances) - .extracting(HistoricPlanItemInstance::getPlanItemDefinitionId, HistoricPlanItemInstance::getState) - .containsExactlyInAnyOrder( - tuple("serviceTaskAvailableActiveCompleted", PlanItemInstanceState.COMPLETED), - tuple("stageAvailableActiveTerminated", PlanItemInstanceState.TERMINATED), - tuple("humanTaskAvailableActiveTerminatedAndWaitingForRepetition", PlanItemInstanceState.TERMINATED), - tuple("eventListenerAvailable", PlanItemInstanceState.AVAILABLE), - tuple("eventListenerUnavailable", PlanItemInstanceState.UNAVAILABLE), - tuple("serviceTaskAvailableEnabled", PlanItemInstanceState.ENABLED), - tuple("serviceTaskAvailableAsyncActive", PlanItemInstanceState.ASYNC_ACTIVE) - ); - - Map historicPlanItemInstancesByDefinitionId = historicPlanItemInstances.stream() - .collect(Collectors.toMap(HistoricPlanItemInstance::getPlanItemDefinitionId, Function.identity())); - - HistoricPlanItemInstance historicEventListenerAvailable = historicPlanItemInstancesByDefinitionId.get("eventListenerAvailable"); - - assertThat(historicEventListenerAvailable).extracting( - HistoricPlanItemInstance::getCompletedTime, - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getOccurredTime, - HistoricPlanItemInstance::getTerminatedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getLastEnabledTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastStartedTime, - HistoricPlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(historicEventListenerAvailable).extracting( - HistoricPlanItemInstance::getCreateTime, - HistoricPlanItemInstance::getLastAvailableTime - ).containsOnly(fixTime); - - HistoricPlanItemInstance historicEventListenerUnavailable = historicPlanItemInstancesByDefinitionId.get("eventListenerUnavailable"); - - assertThat(historicEventListenerUnavailable).extracting( - HistoricPlanItemInstance::getCompletedTime, - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getOccurredTime, - HistoricPlanItemInstance::getTerminatedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getLastEnabledTime, - HistoricPlanItemInstance::getLastAvailableTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastStartedTime, - HistoricPlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(historicEventListenerUnavailable).extracting( - HistoricPlanItemInstance::getCreateTime - ).isEqualTo(fixTime); - - HistoricPlanItemInstance historicServiceTaskAvailableEnabled = historicPlanItemInstancesByDefinitionId.get("serviceTaskAvailableEnabled"); - - assertThat(historicServiceTaskAvailableEnabled).extracting( - HistoricPlanItemInstance::getCompletedTime, - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getOccurredTime, - HistoricPlanItemInstance::getTerminatedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastStartedTime, - HistoricPlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(historicServiceTaskAvailableEnabled).extracting( - HistoricPlanItemInstance::getCreateTime, - HistoricPlanItemInstance::getLastEnabledTime, - HistoricPlanItemInstance::getLastAvailableTime - ).containsOnly(fixTime); - - HistoricPlanItemInstance historicServiceTaskAvailableActiveCompleted = historicPlanItemInstancesByDefinitionId - .get("serviceTaskAvailableActiveCompleted"); - - assertThat(historicServiceTaskAvailableActiveCompleted).extracting( - HistoricPlanItemInstance::getOccurredTime, - HistoricPlanItemInstance::getTerminatedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getLastEnabledTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(historicServiceTaskAvailableActiveCompleted).extracting( - HistoricPlanItemInstance::getCreateTime, - HistoricPlanItemInstance::getCompletedTime, - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getLastAvailableTime, - HistoricPlanItemInstance::getLastStartedTime - ).containsOnly(fixTime); - - HistoricPlanItemInstance historicStageAvailableActiveTerminated = historicPlanItemInstancesByDefinitionId.get("stageAvailableActiveTerminated"); - - assertThat(historicStageAvailableActiveTerminated).extracting( - HistoricPlanItemInstance::getCompletedTime, - HistoricPlanItemInstance::getOccurredTime, - HistoricPlanItemInstance::getTerminatedTime, - HistoricPlanItemInstance::getLastEnabledTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(historicStageAvailableActiveTerminated).extracting( - HistoricPlanItemInstance::getCreateTime, - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getLastAvailableTime, - HistoricPlanItemInstance::getLastStartedTime - ).containsOnly(fixTime); - - HistoricPlanItemInstance historicHumanTaskAvailableActiveTerminatedAndWaitingForRepetition = historicPlanItemInstancesByDefinitionId - .get("humanTaskAvailableActiveTerminatedAndWaitingForRepetition"); - - assertThat(historicHumanTaskAvailableActiveTerminatedAndWaitingForRepetition).extracting( - HistoricPlanItemInstance::getCompletedTime, - HistoricPlanItemInstance::getOccurredTime, - HistoricPlanItemInstance::getTerminatedTime, - HistoricPlanItemInstance::getLastEnabledTime, - HistoricPlanItemInstance::getLastDisabledTime, - HistoricPlanItemInstance::getLastSuspendedTime - ).containsOnlyNulls(); - - assertThat(historicHumanTaskAvailableActiveTerminatedAndWaitingForRepetition).extracting( - HistoricPlanItemInstance::getCreateTime, - HistoricPlanItemInstance::getEndedTime, - HistoricPlanItemInstance::getExitTime, - HistoricPlanItemInstance::getLastAvailableTime, - HistoricPlanItemInstance::getLastStartedTime - ).containsOnly(fixTime); - } - - @Test - @CmmnDeployment - public void testBusinessKey() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("businessKeyCase") - .businessKey("someBusinessKey") - .start(); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult().getBusinessKey()) - .isEqualTo("someBusinessKey"); - cmmnRuntimeService.updateBusinessKey(caseInstance.getId(), "newBusinessKey"); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().caseInstanceId(caseInstance.getId()).singleResult().getBusinessKey()) - .isEqualTo("newBusinessKey"); - } - - @Test - @CmmnDeployment - public void testHistoryJobFailure() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .start(); - - // Fetch the first history job, and programmatically change the handler type, such that it will guaranteed fail. - HistoryJob historyJob = cmmnManagementService.createHistoryJobQuery().singleResult(); - changeHistoryJsonToBeInvalid((HistoryJobEntity) historyJob); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().list()).isEmpty(); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().list()).isEmpty(); - assertThat(cmmnManagementService.createDeadLetterJobQuery().count()).isEqualTo(0); - waitForAsyncHistoryExecutorToProcessAllJobs(); - assertThat(cmmnManagementService.createHistoryJobQuery().count()).isEqualTo(0); - // There is no historic case instance because the job data for it was invalid - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().list()).isEmpty(); - // There is a historic task because the job data for it was valid - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().list()).hasSize(1); - - Job deadLetterJob = cmmnManagementService.createDeadLetterJobQuery().singleResult(); - assertThat(deadLetterJob.getJobType()).isEqualTo(HistoryJobEntity.HISTORY_JOB_TYPE); - assertThat(deadLetterJob.getExceptionMessage()).isNotEmpty(); - - String deadLetterJobExceptionStacktrace = cmmnManagementService.getDeadLetterJobExceptionStacktrace(deadLetterJob.getId()); - assertThat(deadLetterJobExceptionStacktrace).isNotEmpty(); - - cmmnManagementService.moveDeadLetterJobToHistoryJob(deadLetterJob.getId(), 3); - assertThat(cmmnManagementService.createHistoryJobQuery().count()).isEqualTo(1); - historyJob = cmmnManagementService.createHistoryJobQuery().singleResult(); - - changeHistoryJsonToBeValid((HistoryJobEntity) historyJob); - waitForAsyncHistoryExecutorToProcessAllJobs(); - // Once the history job is valid there will be a historic case instance - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().list()).hasSize(1); - - // The history jobs in the deadletter table have no link to the case instance, hence why a manual cleanup is needed. - cmmnRuntimeService.terminateCaseInstance(caseInstance.getId()); - cmmnManagementService.createHistoryJobQuery().list().forEach(j -> cmmnManagementService.deleteHistoryJob(j.getId())); - cmmnManagementService.createDeadLetterJobQuery().list().forEach(j -> cmmnManagementService.deleteDeadLetterJob(j.getId())); - - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoryJobFailure.cmmn") - public void testMoveDeadLetterJobBackToHistoryJob() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("oneHumanTaskCase") - .start(); - - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().list()).isEmpty(); - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().list()).isEmpty(); - - // Fetch the first history job, and programmatically change the handler type, such that it will guaranteed fail. - HistoryJob historyJob = cmmnManagementService.createHistoryJobQuery().singleResult(); - changeHistoryJsonToBeInvalid((HistoryJobEntity) historyJob); - - waitForAsyncHistoryExecutorToProcessAllJobs(); - - // There is no historic case instance because the job data for it was invalid - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().list()).isEmpty(); - // There is a historic task because the job data for it was valid - assertThat(cmmnHistoryService.createHistoricTaskInstanceQuery().list()).hasSize(1); - - assertThat(cmmnManagementService.createHistoryJobQuery().count()).isEqualTo(0); - Job deadLetterJob = cmmnManagementService.createDeadLetterJobQuery().singleResult(); - - cmmnManagementService.moveDeadLetterJobToHistoryJob(deadLetterJob.getId(), 3); - assertThat(cmmnManagementService.createHistoryJobQuery().count()).isEqualTo(1); - historyJob = cmmnManagementService.createHistoryJobQuery().singleResult(); - - assertThat(historyJob.getCreateTime()).isNotNull(); - assertThat(historyJob.getRetries()).isEqualTo(3); - assertThat(historyJob.getExceptionMessage()).isNotNull(); // this is consistent with regular jobs - assertThat(historyJob.getJobHandlerConfiguration()).isNull(); // needs to have been reset - - changeHistoryJsonToBeValid((HistoryJobEntity) historyJob); - waitForAsyncHistoryExecutorToProcessAllJobs(); - // Once the history job is valid there will be a historic case instance - assertThat(cmmnHistoryService.createHistoricCaseInstanceQuery().list()).hasSize(1); - - // The history jobs in the deadletter table have no link to the case instance, hence why a manual cleanup is needed. - cmmnRuntimeService.terminateCaseInstance(caseInstance.getId()); - cmmnManagementService.createHistoryJobQuery().list().forEach(j -> cmmnManagementService.deleteHistoryJob(j.getId())); - cmmnManagementService.createDeadLetterJobQuery().list().forEach(j -> cmmnManagementService.deleteDeadLetterJob(j.getId())); - } - - @Test - @CmmnDeployment(resources = "org/flowable/cmmn/test/history/testTwoTaskCase.cmmn") - public void testVariableChanges() { - CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() - .caseDefinitionKey("myCase") - .variable("var1", "test") - .start(); - - Task task = cmmnTaskService.createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult(); - Map variables = new HashMap<>(); - variables.put("var1", "updated"); - cmmnTaskService.complete(task.getId(), variables); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().caseInstanceId(caseInstance.getId()) - .variableName("var1").singleResult().getValue()).isEqualTo("updated"); - - ((CmmnManagementServiceImpl) cmmnManagementService).executeCommand(commandContext -> { - List variablesInstances = CommandContextUtil.getVariableService(commandContext) - .findVariableInstanceByScopeIdAndScopeType(caseInstance.getId(), ScopeTypes.CMMN); - - VariableInstanceEntity variableInstanceEntity = variablesInstances.get(0); - variableInstanceEntity.setMetaInfo("test meta info"); - VariableServiceConfiguration variableServiceConfiguration = cmmnEngineConfiguration.getVariableServiceConfiguration(); - variableServiceConfiguration.getVariableInstanceEntityManager().update(variableInstanceEntity); - if (variableServiceConfiguration.getInternalHistoryVariableManager() != null) { - variableServiceConfiguration.getInternalHistoryVariableManager() - .recordVariableUpdate(variableInstanceEntity, commandContext.getClock().getCurrentTime()); - } - return null; - }); - - CmmnHistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(cmmnEngineConfiguration, cmmnManagementService, 10000, 200); - - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().caseInstanceId(caseInstance.getId()) - .variableName("var1").singleResult().getValue()).isEqualTo("updated"); - assertThat(cmmnHistoryService.createHistoricVariableInstanceQuery().caseInstanceId(caseInstance.getId()) - .variableName("var1").singleResult().getMetaInfo()).isEqualTo("test meta info"); - } - - - protected void changeHistoryJsonToBeInvalid(HistoryJobEntity historyJob) { - cmmnEngineConfiguration.getCommandExecutor().execute(new Command() { - - @Override - public Void execute(CommandContext commandContext) { - try { - HistoryJobEntity historyJobEntity = historyJob; - - ObjectMapper objectMapper = cmmnEngineConfiguration.getObjectMapper(); - JsonNode historyJsonNode = objectMapper.readTree(historyJobEntity.getAdvancedJobHandlerConfiguration()); - - for (JsonNode jsonNode : historyJsonNode) { - if (jsonNode.has("type") && "cmmn-case-instance-start".equals(jsonNode.get("type").asText())) { - ((ObjectNode) jsonNode).put("type", "invalidType"); - } - } - - historyJobEntity.setAdvancedJobHandlerConfiguration(objectMapper.writeValueAsString(historyJsonNode)); - } catch (JsonProcessingException e) { - Assert.fail(); - } - return null; - } - }); - } - - protected void changeHistoryJsonToBeValid(HistoryJobEntity historyJob) { - cmmnEngineConfiguration.getCommandExecutor().execute(new Command() { - - @Override - public Void execute(CommandContext commandContext) { - try { - HistoryJobEntity historyJobEntity = historyJob; - - ObjectMapper objectMapper = cmmnEngineConfiguration.getObjectMapper(); - JsonNode historyJsonNode = objectMapper.readTree(historyJobEntity.getAdvancedJobHandlerConfiguration()); - - for (JsonNode jsonNode : historyJsonNode) { - if (jsonNode.has("type") && "invalidType".equals(jsonNode.get("type").asText())) { - ((ObjectNode) jsonNode).put("type", "cmmn-case-instance-start"); - } - } - - historyJobEntity.setAdvancedJobHandlerConfiguration(objectMapper.writeValueAsString(historyJsonNode)); - } catch (JsonProcessingException e) { - Assert.fail(); - } - return null; - } - }); - } - -} diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.createRootEntityLink.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.createRootEntityLink.cmmn deleted file mode 100644 index d0d8213dc59..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.createRootEntityLink.cmmn +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - This is a test documentation - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testBusinessKey.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testBusinessKey.cmmn deleted file mode 100644 index 731431c6d28..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testBusinessKey.cmmn +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - This is a test documentation - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCaseInstanceStartAndEnd.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCaseInstanceStartAndEnd.cmmn deleted file mode 100644 index 255dff6ee30..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCaseInstanceStartAndEnd.cmmn +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - This is a test documentation - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCasePageTask.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCasePageTask.cmmn deleted file mode 100644 index a2f86905027..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCasePageTask.cmmn +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - This is a test documentation - - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCriterionStoredOnPlanItemInstance.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCriterionStoredOnPlanItemInstance.cmmn deleted file mode 100644 index 7159dd0a198..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testCriterionStoredOnPlanItemInstance.cmmn +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - complete - - - - - complete - - - - - occur - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoricCaseInstanceDeleted.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoricCaseInstanceDeleted.cmmn deleted file mode 100644 index d0d8213dc59..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoricCaseInstanceDeleted.cmmn +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - This is a test documentation - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoryJobFailure.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoryJobFailure.cmmn deleted file mode 100644 index 255dff6ee30..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHistoryJobFailure.cmmn +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - This is a test documentation - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTask.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTask.cmmn deleted file mode 100644 index d0d8213dc59..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTask.cmmn +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - This is a test documentation - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTaskWithCandidateUsersAndGroups.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTaskWithCandidateUsersAndGroups.cmmn deleted file mode 100644 index 468da18f9f6..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testHumanTaskWithCandidateUsersAndGroups.cmmn +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - This is a test documentation - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testIdentityLinks.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testIdentityLinks.cmmn deleted file mode 100644 index 89a4a73b96c..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testIdentityLinks.cmmn +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testMilestoneReached.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testMilestoneReached.cmmn deleted file mode 100644 index 89a4a73b96c..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testMilestoneReached.cmmn +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testPlanItemInstances.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testPlanItemInstances.cmmn deleted file mode 100644 index 7b6fae09c61..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testPlanItemInstances.cmmn +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - complete - - - - - occur - - - - - - - - - - - diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testPlanItemInstancesStateChangesWithFixedTime.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testPlanItemInstancesStateChangesWithFixedTime.cmmn deleted file mode 100644 index cb091e56ab2..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testPlanItemInstancesStateChangesWithFixedTime.cmmn +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - complete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testVariables.cmmn b/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testVariables.cmmn deleted file mode 100644 index d0d8213dc59..00000000000 --- a/modules/flowable-cmmn-engine/src/test/resources/org/flowable/cmmn/test/async/AsyncCmmnHistoryTest.testVariables.cmmn +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - This is a test documentation - - - - - diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java index f004985f3cb..3afeee0fd2f 100755 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java @@ -254,37 +254,6 @@ import org.flowable.engine.impl.history.DefaultHistoryVariableManager; import org.flowable.engine.impl.history.HistoryConfigurationSettings; import org.flowable.engine.impl.history.HistoryManager; -import org.flowable.engine.impl.history.async.AsyncHistoryManager; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.history.async.json.transformer.ActivityEndHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.ActivityFullHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.ActivityStartHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.ActivityUpdateHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.EntityLinkCreatedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.EntityLinkDeletedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.FormPropertiesSubmittedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.HistoricDetailVariableUpdateHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.HistoricUserTaskLogDeleteJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.HistoricUserTaskLogRecordJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.IdentityLinkCreatedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.IdentityLinkDeletedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.ProcessInstanceDeleteHistoryByProcessDefinitionIdJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.ProcessInstanceDeleteHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.ProcessInstanceEndHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.ProcessInstancePropertyChangedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.ProcessInstanceStartHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.SetProcessDefinitionHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.SubProcessInstanceStartHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.TaskAssigneeChangedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.TaskCreatedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.TaskDeletedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.TaskEndedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.TaskOwnerChangedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.TaskPropertyChangedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.UpdateProcessDefinitionCascadeHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.VariableCreatedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.VariableRemovedHistoryJsonTransformer; -import org.flowable.engine.impl.history.async.json.transformer.VariableUpdatedHistoryJsonTransformer; import org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor; import org.flowable.engine.impl.interceptor.CommandInvoker; import org.flowable.engine.impl.interceptor.DefaultIdentityLinkInterceptor; @@ -414,13 +383,6 @@ import org.flowable.job.service.impl.asyncexecutor.FailedJobCommandFactory; import org.flowable.job.service.impl.asyncexecutor.JobManager; import org.flowable.job.service.impl.db.JobDbSchemaManager; -import org.flowable.job.service.impl.history.async.AsyncHistoryJobHandler; -import org.flowable.job.service.impl.history.async.AsyncHistoryJobZippedHandler; -import org.flowable.job.service.impl.history.async.AsyncHistoryListener; -import org.flowable.job.service.impl.history.async.AsyncHistorySession; -import org.flowable.job.service.impl.history.async.AsyncHistorySessionFactory; -import org.flowable.job.service.impl.history.async.DefaultAsyncHistoryJobProducer; -import org.flowable.job.service.impl.history.async.transformer.HistoryJsonTransformer; import org.flowable.task.api.TaskQueryInterceptor; import org.flowable.task.api.history.HistoricTaskQueryInterceptor; import org.flowable.task.service.InternalTaskAssignmentManager; @@ -541,10 +503,6 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig protected HistoryConfigurationSettings historyConfigurationSettings; protected boolean isAsyncHistoryEnabled; - protected boolean isAsyncHistoryJsonGzipCompressionEnabled; - protected boolean isAsyncHistoryJsonGroupingEnabled; - protected int asyncHistoryJsonGroupingThreshold = 10; - protected AsyncHistoryListener asyncHistoryListener; // Change Tenant ID Manager @@ -618,7 +576,6 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig protected Map historyJobHandlers; protected List customHistoryJobHandlers; - protected List customHistoryJsonTransformers; // HELPERS ////////////////////////////////////////////////////////////////// protected ProcessInstanceHelper processInstanceHelper; @@ -1324,11 +1281,7 @@ public void initHistoryConfigurationSettings() { public void initHistoryManager() { if (historyManager == null) { - if (isAsyncHistoryEnabled) { - historyManager = new AsyncHistoryManager(this); - } else { - historyManager = new DefaultHistoryManager(this); - } + historyManager = new DefaultHistoryManager(this); } } @@ -1381,10 +1334,6 @@ public void initSessionFactories() { initDbSqlSessionFactory(); } - if (isAsyncHistoryEnabled) { - initAsyncHistorySessionFactory(); - } - if (agendaFactory != null) { addSessionFactory(new AgendaSessionFactory(agendaFactory)); } @@ -1398,12 +1347,6 @@ public void initSessionFactories() { initDbSqlSessionFactoryEntitySettings(); } - if (isAsyncHistoryEnabled) { - if (!sessionFactories.containsKey(AsyncHistorySession.class)) { - initAsyncHistorySessionFactory(); - } - } - if (!sessionFactories.containsKey(FlowableEngineAgenda.class)) { if (agendaFactory != null) { addSessionFactory(new AgendaSessionFactory(agendaFactory)); @@ -1444,23 +1387,6 @@ protected void initDbSqlSessionFactoryEntitySettings() { } } - public void initAsyncHistorySessionFactory() { - if (!sessionFactories.containsKey(AsyncHistorySession.class)) { - AsyncHistorySessionFactory asyncHistorySessionFactory = new AsyncHistorySessionFactory(); - if (asyncHistoryListener == null) { - initDefaultAsyncHistoryListener(); - } - asyncHistorySessionFactory.setAsyncHistoryListener(asyncHistoryListener); - sessionFactories.put(AsyncHistorySession.class, asyncHistorySessionFactory); - } - - ((AsyncHistorySessionFactory) sessionFactories.get(AsyncHistorySession.class)).registerJobDataTypes(HistoryJsonConstants.ORDERED_TYPES); - } - - protected void initDefaultAsyncHistoryListener() { - asyncHistoryListener = new DefaultAsyncHistoryJobProducer(); - } - public void configureVariableServiceConfiguration() { this.variableServiceConfiguration = instantiateVariableServiceConfiguration(); this.variableServiceConfiguration.setHistoryLevel(this.historyLevel); @@ -1649,13 +1575,6 @@ public void configureJobServiceConfiguration() { this.jobServiceConfiguration.setInternalJobCompatibilityManager(new DefaultInternalJobCompatibilityManager(this)); } - // Async history job config - jobServiceConfiguration.setJobTypeAsyncHistory(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY); - jobServiceConfiguration.setJobTypeAsyncHistoryZipped(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED); - jobServiceConfiguration.setAsyncHistoryJsonGzipCompressionEnabled(isAsyncHistoryJsonGzipCompressionEnabled); - jobServiceConfiguration.setAsyncHistoryJsonGroupingEnabled(isAsyncHistoryJsonGroupingEnabled); - jobServiceConfiguration.setAsyncHistoryJsonGroupingThreshold(asyncHistoryJsonGroupingThreshold); - // set the job processors this.jobServiceConfiguration.setJobProcessors(this.jobProcessors); this.jobServiceConfiguration.setHistoryJobProcessors(this.historyJobProcessors); @@ -2117,21 +2036,6 @@ protected void initHistoryJobHandlers() { if (isAsyncHistoryEnabled) { historyJobHandlers = new HashMap<>(); - List allHistoryJsonTransformers = new ArrayList<>(initDefaultHistoryJsonTransformers()); - if (customHistoryJsonTransformers != null) { - allHistoryJsonTransformers.addAll(customHistoryJsonTransformers); - } - - AsyncHistoryJobHandler asyncHistoryJobHandler = new AsyncHistoryJobHandler(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY); - allHistoryJsonTransformers.forEach(asyncHistoryJobHandler::addHistoryJsonTransformer); - asyncHistoryJobHandler.setAsyncHistoryJsonGroupingEnabled(isAsyncHistoryJsonGroupingEnabled); - historyJobHandlers.put(asyncHistoryJobHandler.getType(), asyncHistoryJobHandler); - - AsyncHistoryJobZippedHandler asyncHistoryJobZippedHandler = new AsyncHistoryJobZippedHandler(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED); - allHistoryJsonTransformers.forEach(asyncHistoryJobZippedHandler::addHistoryJsonTransformer); - asyncHistoryJobZippedHandler.setAsyncHistoryJsonGroupingEnabled(isAsyncHistoryJsonGroupingEnabled); - historyJobHandlers.put(asyncHistoryJobZippedHandler.getType(), asyncHistoryJobZippedHandler); - if (getCustomHistoryJobHandlers() != null) { for (HistoryJobHandler customJobHandler : getCustomHistoryJobHandlers()) { historyJobHandlers.put(customJobHandler.getType(), customJobHandler); @@ -2140,47 +2044,6 @@ protected void initHistoryJobHandlers() { } } - protected List initDefaultHistoryJsonTransformers() { - List historyJsonTransformers = new ArrayList<>(); - historyJsonTransformers.add(new ProcessInstanceStartHistoryJsonTransformer(this)); - historyJsonTransformers.add(new ProcessInstanceEndHistoryJsonTransformer(this)); - historyJsonTransformers.add(new ProcessInstanceDeleteHistoryJsonTransformer(this)); - historyJsonTransformers.add(new ProcessInstanceDeleteHistoryByProcessDefinitionIdJsonTransformer(this)); - historyJsonTransformers.add(new ProcessInstancePropertyChangedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new SubProcessInstanceStartHistoryJsonTransformer(this)); - historyJsonTransformers.add(new SetProcessDefinitionHistoryJsonTransformer(this)); - historyJsonTransformers.add(new UpdateProcessDefinitionCascadeHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new ActivityStartHistoryJsonTransformer(this)); - historyJsonTransformers.add(new ActivityEndHistoryJsonTransformer(this)); - historyJsonTransformers.add(new ActivityFullHistoryJsonTransformer(this)); - historyJsonTransformers.add(new ActivityUpdateHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new TaskCreatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new TaskEndedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new TaskDeletedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new TaskPropertyChangedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new TaskAssigneeChangedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new TaskOwnerChangedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new IdentityLinkCreatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new IdentityLinkDeletedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new EntityLinkCreatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new EntityLinkDeletedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new VariableCreatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new VariableUpdatedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new VariableRemovedHistoryJsonTransformer(this)); - historyJsonTransformers.add(new HistoricDetailVariableUpdateHistoryJsonTransformer(this)); - historyJsonTransformers.add(new FormPropertiesSubmittedHistoryJsonTransformer(this)); - - historyJsonTransformers.add(new HistoricUserTaskLogRecordJsonTransformer(this)); - historyJsonTransformers.add(new HistoricUserTaskLogDeleteJsonTransformer(this)); - return historyJsonTransformers; - } - // async executor // ///////////////////////////////////////////////////////////// @@ -2275,9 +2138,7 @@ public void initAsyncHistoryExecutor() { if (asyncHistoryExecutor.getJobServiceConfiguration() == null) { asyncHistoryExecutor.setJobServiceConfiguration(jobServiceConfiguration); } - historyJobHandlers.forEach((type, handler) -> { - asyncHistoryExecutor.getJobServiceConfiguration().mergeHistoryJobHandler(handler); - }); + historyJobHandlers.forEach((type, handler) -> asyncHistoryExecutor.getJobServiceConfiguration().addHistoryJobHandler(type, handler)); } } @@ -3621,15 +3482,6 @@ public ProcessEngineConfigurationImpl setCustomHistoryJobHandlers(List getCustomHistoryJsonTransformers() { - return customHistoryJsonTransformers; - } - - public ProcessEngineConfigurationImpl setCustomHistoryJsonTransformers(List customHistoryJsonTransformers) { - this.customHistoryJsonTransformers = customHistoryJsonTransformers; - return this; - } - public List getCustomFormEngines() { return customFormEngines; } @@ -4435,44 +4287,6 @@ public ProcessEngineConfigurationImpl setAsyncHistoryEnabled(boolean isAsyncHist return this; } - public boolean isAsyncHistoryJsonGzipCompressionEnabled() { - return isAsyncHistoryJsonGzipCompressionEnabled; - } - - public ProcessEngineConfigurationImpl setAsyncHistoryJsonGzipCompressionEnabled(boolean isAsyncHistoryJsonGzipCompressionEnabled) { - this.isAsyncHistoryJsonGzipCompressionEnabled = isAsyncHistoryJsonGzipCompressionEnabled; - return this; - } - - public boolean isAsyncHistoryJsonGroupingEnabled() { - return isAsyncHistoryJsonGroupingEnabled; - } - - public ProcessEngineConfigurationImpl setAsyncHistoryJsonGroupingEnabled(boolean isAsyncHistoryJsonGroupingEnabled) { - this.isAsyncHistoryJsonGroupingEnabled = isAsyncHistoryJsonGroupingEnabled; - return this; - } - - public int getAsyncHistoryJsonGroupingThreshold() { - return asyncHistoryJsonGroupingThreshold; - } - - public void setAsyncHistoryJsonGroupingThreshold(int asyncHistoryJsonGroupingThreshold) { - this.asyncHistoryJsonGroupingThreshold = asyncHistoryJsonGroupingThreshold; - } - - public AsyncHistoryListener getAsyncHistoryListener() { - if (asyncHistoryListener == null) { - asyncHistoryListener = new DefaultAsyncHistoryJobProducer(); - } - return asyncHistoryListener; - } - - public ProcessEngineConfigurationImpl setAsyncHistoryListener(AsyncHistoryListener asyncHistoryListener) { - this.asyncHistoryListener = asyncHistoryListener; - return this; - } - public JobManager getJobManager() { return jobManager; } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/DefaultHistoryVariableManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/DefaultHistoryVariableManager.java index beb71499156..0802d97230e 100644 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/DefaultHistoryVariableManager.java +++ b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/DefaultHistoryVariableManager.java @@ -15,11 +15,7 @@ import java.util.Date; -import org.flowable.common.engine.impl.interceptor.CommandContext; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.util.CommandContextUtil; -import org.flowable.job.service.impl.history.async.AsyncHistorySession; -import org.flowable.job.service.impl.history.async.AsyncHistorySessionCommandContextCloseListener; import org.flowable.variable.service.history.InternalHistoryVariableManager; import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity; @@ -55,15 +51,6 @@ public void recordVariableRemoved(VariableInstanceEntity variable, Date removeTi } } - @Override - public void initAsyncHistoryCommandContextCloseListener() { - if (processEngineConfiguration.isAsyncHistoryEnabled()) { - CommandContext commandContext = CommandContextUtil.getCommandContext(); - commandContext.addCloseListener(new AsyncHistorySessionCommandContextCloseListener( - commandContext.getSession(AsyncHistorySession.class), processEngineConfiguration.getAsyncHistoryListener())); - } - } - protected HistoryManager getHistoryManager() { return processEngineConfiguration.getHistoryManager(); } diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/AbstractAsyncHistoryManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/AbstractAsyncHistoryManager.java deleted file mode 100644 index ac1726c3c49..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/AbstractAsyncHistoryManager.java +++ /dev/null @@ -1,200 +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.engine.impl.history.async; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.convertToBase64; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.putIfNotNull; - -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.AbstractHistoryManager; -import org.flowable.engine.impl.persistence.entity.ExecutionEntity; -import org.flowable.engine.repository.ProcessDefinition; -import org.flowable.engine.runtime.ActivityInstance; -import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity; -import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity; -import org.flowable.task.api.history.HistoricTaskLogEntryBuilder; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author Filip Hrisafov - */ -public abstract class AbstractAsyncHistoryManager extends AbstractHistoryManager { - - public AbstractAsyncHistoryManager(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - protected void addCommonProcessInstanceFields(ExecutionEntity processInstance, ObjectNode data) { - putIfNotNull(data, HistoryJsonConstants.ID, processInstance.getId()); - putIfNotNull(data, HistoryJsonConstants.REVISION, processInstance.getRevision()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, processInstance.getProcessInstanceId()); - putIfNotNull(data, HistoryJsonConstants.NAME, processInstance.getName()); - putIfNotNull(data, HistoryJsonConstants.BUSINESS_KEY, processInstance.getBusinessKey()); - putIfNotNull(data, HistoryJsonConstants.BUSINESS_STATUS, processInstance.getBusinessStatus()); - putIfNotNull(data, HistoryJsonConstants.DEPLOYMENT_ID, processInstance.getDeploymentId()); - putIfNotNull(data, HistoryJsonConstants.START_TIME, processInstance.getStartTime()); - putIfNotNull(data, HistoryJsonConstants.START_USER_ID, processInstance.getStartUserId()); - putIfNotNull(data, HistoryJsonConstants.START_ACTIVITY_ID, processInstance.getStartActivityId()); - putIfNotNull(data, HistoryJsonConstants.SUPER_PROCESS_INSTANCE_ID, processInstance.getSuperExecution() != null ? processInstance.getSuperExecution().getProcessInstanceId() : null); - putIfNotNull(data, HistoryJsonConstants.CALLBACK_ID, processInstance.getCallbackId()); - putIfNotNull(data, HistoryJsonConstants.CALLBACK_TYPE, processInstance.getCallbackType()); - putIfNotNull(data, HistoryJsonConstants.REFERENCE_ID, processInstance.getReferenceId()); - putIfNotNull(data, HistoryJsonConstants.REFERENCE_TYPE, processInstance.getReferenceType()); - putIfNotNull(data, HistoryJsonConstants.PROPAGATED_STAGE_INSTANCE_ID, processInstance.getPropagatedStageInstanceId()); - putIfNotNull(data, HistoryJsonConstants.TENANT_ID, processInstance.getTenantId()); - - addProcessDefinitionFields(data, processInstance.getProcessDefinitionId()); - } - - protected void addProcessDefinitionFields(ObjectNode data, String processDefinitionId) { - if (processDefinitionId != null) { - ProcessDefinition processDefinition = processEngineConfiguration.getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId); - addProcessDefinitionFields(data, processDefinition); - } - } - - protected void addProcessDefinitionFields(ObjectNode data, ProcessDefinition processDefinition) { - if (processDefinition != null) { - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_ID, processDefinition.getId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_KEY, processDefinition.getKey()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_NAME, processDefinition.getName()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_VERSION, processDefinition.getVersion()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_CATEGORY, processDefinition.getCategory()); - putIfNotNull(data, HistoryJsonConstants.DEPLOYMENT_ID, processDefinition.getDeploymentId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITIN_DERIVED_FROM, processDefinition.getDerivedFrom()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITIN_DERIVED_FROM_ROOT, processDefinition.getDerivedFromRoot()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITIN_DERIVED_VERSION, processDefinition.getDerivedVersion()); - } - } - - protected void addCommonTaskFields(TaskEntity task, ExecutionEntity execution, ObjectNode data) { - putIfNotNull(data, HistoryJsonConstants.ID, task.getId()); - putIfNotNull(data, HistoryJsonConstants.REVISION, task.getRevision()); - putIfNotNull(data, HistoryJsonConstants.NAME, task.getName()); - putIfNotNull(data, HistoryJsonConstants.PARENT_TASK_ID, task.getParentTaskId()); - putIfNotNull(data, HistoryJsonConstants.DESCRIPTION, task.getDescription()); - putIfNotNull(data, HistoryJsonConstants.OWNER, task.getOwner()); - putIfNotNull(data, HistoryJsonConstants.ASSIGNEE, task.getAssignee()); - putIfNotNull(data, HistoryJsonConstants.CREATE_TIME, task.getCreateTime()); - putIfNotNull(data, HistoryJsonConstants.TASK_DEFINITION_KEY, task.getTaskDefinitionKey()); - putIfNotNull(data, HistoryJsonConstants.TASK_DEFINITION_ID, task.getTaskDefinitionId()); - putIfNotNull(data, HistoryJsonConstants.FORM_KEY, task.getFormKey()); - putIfNotNull(data, HistoryJsonConstants.PRIORITY, task.getPriority()); - putIfNotNull(data, HistoryJsonConstants.DUE_DATE, task.getDueDate()); - putIfNotNull(data, HistoryJsonConstants.CATEGORY, task.getCategory()); - putIfNotNull(data, HistoryJsonConstants.CLAIM_TIME, task.getClaimTime()); - putIfNotNull(data, HistoryJsonConstants.TENANT_ID, task.getTenantId()); - - if (execution != null) { - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, execution.getProcessInstanceId()); - putIfNotNull(data, HistoryJsonConstants.EXECUTION_ID, execution.getId()); - - addProcessDefinitionFields(data, execution.getProcessDefinitionId()); - - } else if (task.getProcessDefinitionId() != null) { - addProcessDefinitionFields(data, task.getProcessDefinitionId()); - - } - } - - protected void addCommonVariableFields(VariableInstanceEntity variable, ObjectNode data) { - putIfNotNull(data, HistoryJsonConstants.ID, variable.getId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, variable.getProcessInstanceId()); - putIfNotNull(data, HistoryJsonConstants.EXECUTION_ID, variable.getExecutionId()); - putIfNotNull(data, HistoryJsonConstants.TASK_ID, variable.getTaskId()); - putIfNotNull(data, HistoryJsonConstants.REVISION, variable.getRevision()); - putIfNotNull(data, HistoryJsonConstants.NAME, variable.getName()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_ID, variable.getScopeId()); - putIfNotNull(data, HistoryJsonConstants.SUB_SCOPE_ID, variable.getSubScopeId()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_TYPE, variable.getScopeType()); - - putIfNotNull(data, HistoryJsonConstants.VARIABLE_TYPE, variable.getType().getTypeName()); - putIfNotNull(data, HistoryJsonConstants.VARIABLE_TEXT_VALUE, variable.getTextValue()); - putIfNotNull(data, HistoryJsonConstants.VARIABLE_TEXT_VALUE2, variable.getTextValue2()); - putIfNotNull(data, HistoryJsonConstants.VARIABLE_DOUBLE_VALUE, variable.getDoubleValue()); - putIfNotNull(data, HistoryJsonConstants.VARIABLE_LONG_VALUE, variable.getLongValue()); - if (variable.getByteArrayRef() != null) { - putIfNotNull(data, HistoryJsonConstants.VARIABLE_BYTES_VALUE, convertToBase64(variable)); - } - putIfNotNull(data, HistoryJsonConstants.VARIABLE_META_INFO, variable.getMetaInfo()); - - - if (variable.getExecutionId() != null) { - addProcessDefinitionFields(data, variable.getProcessDefinitionId()); - } - } - - protected void addCommonIdentityLinkFields(IdentityLinkEntity identityLink, ObjectNode data) { - putIfNotNull(data, HistoryJsonConstants.ID, identityLink.getId()); - putIfNotNull(data, HistoryJsonConstants.GROUP_ID, identityLink.getGroupId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_ID, identityLink.getProcessDefinitionId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, identityLink.getProcessInstanceId()); - putIfNotNull(data, HistoryJsonConstants.TASK_ID, identityLink.getTaskId()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_DEFINITION_ID, identityLink.getScopeDefinitionId()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_ID, identityLink.getScopeId()); - putIfNotNull(data, HistoryJsonConstants.SUB_SCOPE_ID, identityLink.getSubScopeId()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_TYPE, identityLink.getScopeType()); - putIfNotNull(data, HistoryJsonConstants.IDENTITY_LINK_TYPE, identityLink.getType()); - putIfNotNull(data, HistoryJsonConstants.USER_ID, identityLink.getUserId()); - } - - protected void addCommonEntityLinkFields(EntityLinkEntity entityLink, ObjectNode data) { - putIfNotNull(data, HistoryJsonConstants.ID, entityLink.getId()); - putIfNotNull(data, HistoryJsonConstants.ENTITY_LINK_TYPE, entityLink.getLinkType()); - putIfNotNull(data, HistoryJsonConstants.CREATE_TIME, entityLink.getCreateTime()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_ID, entityLink.getScopeId()); - putIfNotNull(data, HistoryJsonConstants.SUB_SCOPE_ID, entityLink.getSubScopeId()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_TYPE, entityLink.getScopeType()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_DEFINITION_ID, entityLink.getScopeDefinitionId()); - putIfNotNull(data, HistoryJsonConstants.PARENT_ELEMENT_ID, entityLink.getParentElementId()); - putIfNotNull(data, HistoryJsonConstants.REF_SCOPE_ID, entityLink.getReferenceScopeId()); - putIfNotNull(data, HistoryJsonConstants.REF_SCOPE_TYPE, entityLink.getReferenceScopeType()); - putIfNotNull(data, HistoryJsonConstants.REF_SCOPE_DEFINITION_ID, entityLink.getReferenceScopeDefinitionId()); - putIfNotNull(data, HistoryJsonConstants.ROOT_SCOPE_ID, entityLink.getRootScopeId()); - putIfNotNull(data, HistoryJsonConstants.ROOT_SCOPE_TYPE, entityLink.getRootScopeType()); - putIfNotNull(data, HistoryJsonConstants.HIERARCHY_TYPE, entityLink.getHierarchyType()); - } - - protected void addCommonActivityInstanceFields(ActivityInstance activityInstance, ObjectNode data) { - putIfNotNull(data, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID, activityInstance.getId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_ID, activityInstance.getProcessDefinitionId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, activityInstance.getProcessInstanceId()); - putIfNotNull(data, HistoryJsonConstants.EXECUTION_ID, activityInstance.getExecutionId()); - putIfNotNull(data, HistoryJsonConstants.ACTIVITY_ID, activityInstance.getActivityId()); - putIfNotNull(data, HistoryJsonConstants.ACTIVITY_NAME, activityInstance.getActivityName()); - putIfNotNull(data, HistoryJsonConstants.ACTIVITY_TYPE, activityInstance.getActivityType()); - if (activityInstance.getTransactionOrder() != null) { - putIfNotNull(data, HistoryJsonConstants.TRANSACTION_ORDER, activityInstance.getTransactionOrder()); - } - putIfNotNull(data, HistoryJsonConstants.TENANT_ID, activityInstance.getTenantId()); - } - - protected void addHistoricTaskLogEntryFields(HistoricTaskLogEntryBuilder taskLogEntryBuilder, ObjectNode data) { - putIfNotNull(data, HistoryJsonConstants.LOG_ENTRY_DATA, taskLogEntryBuilder.getData()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, taskLogEntryBuilder.getProcessInstanceId()); - putIfNotNull(data, HistoryJsonConstants.EXECUTION_ID, taskLogEntryBuilder.getExecutionId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_ID, taskLogEntryBuilder.getProcessDefinitionId()); - putIfNotNull(data, HistoryJsonConstants.TASK_ID, taskLogEntryBuilder.getTaskId()); - putIfNotNull(data, HistoryJsonConstants.TENANT_ID, taskLogEntryBuilder.getTenantId()); - putIfNotNull(data, HistoryJsonConstants.CREATE_TIME, taskLogEntryBuilder.getTimeStamp()); - putIfNotNull(data, HistoryJsonConstants.USER_ID, taskLogEntryBuilder.getUserId()); - putIfNotNull(data, HistoryJsonConstants.LOG_ENTRY_TYPE, taskLogEntryBuilder.getType()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_ID, taskLogEntryBuilder.getScopeId()); - putIfNotNull(data, HistoryJsonConstants.SUB_SCOPE_ID, taskLogEntryBuilder.getSubScopeId()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_TYPE, taskLogEntryBuilder.getScopeType()); - putIfNotNull(data, HistoryJsonConstants.SCOPE_DEFINITION_ID, taskLogEntryBuilder.getScopeDefinitionId()); - } -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/AsyncHistoryManager.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/AsyncHistoryManager.java deleted file mode 100644 index 931e32661d9..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/AsyncHistoryManager.java +++ /dev/null @@ -1,554 +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.engine.impl.history.async; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.putIfNotNull; - -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.api.scope.ScopeTypes; -import org.flowable.common.engine.impl.history.HistoryLevel; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.json.transformer.ProcessInstancePropertyChangedHistoryJsonTransformer; -import org.flowable.engine.impl.persistence.entity.ExecutionEntity; -import org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntity; -import org.flowable.engine.impl.util.CommandContextUtil; -import org.flowable.engine.impl.util.TaskHelper; -import org.flowable.engine.runtime.ActivityInstance; -import org.flowable.entitylink.service.impl.persistence.entity.EntityLinkEntity; -import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity; -import org.flowable.job.service.JobServiceConfiguration; -import org.flowable.job.service.impl.history.async.AsyncHistorySession; -import org.flowable.job.service.impl.history.async.AsyncHistorySession.AsyncHistorySessionData; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.api.history.HistoricTaskLogEntryBuilder; -import org.flowable.task.service.impl.persistence.entity.TaskEntity; -import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class AsyncHistoryManager extends AbstractAsyncHistoryManager { - - public AsyncHistoryManager(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - public AsyncHistorySession getAsyncHistorySession() { - return getSession(AsyncHistorySession.class); - } - - @Override - public void recordProcessInstanceStart(ExecutionEntity processInstance) { - if (getHistoryConfigurationSettings().isHistoryEnabledForProcessInstance(processInstance)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonProcessInstanceFields(processInstance, data); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_PROCESS_INSTANCE_START, data, processInstance.getTenantId()); - } - } - - @Override - public void recordProcessInstanceEnd(ExecutionEntity processInstance, String deleteReason, String activityId, Date endTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForProcessInstance(processInstance)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonProcessInstanceFields(processInstance, data); - - putIfNotNull(data, HistoryJsonConstants.DELETE_REASON, deleteReason); - putIfNotNull(data, HistoryJsonConstants.END_TIME, endTime); - putIfNotNull(data, HistoryJsonConstants.ACTIVITY_ID, activityId); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_PROCESS_INSTANCE_END, data); - } - } - - @Override - public void recordProcessInstanceNameChange(ExecutionEntity processInstanceExecution, String newName) { - if (getHistoryConfigurationSettings().isHistoryEnabledForProcessInstance(processInstanceExecution)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, processInstanceExecution.getId()); - putIfNotNull(data, HistoryJsonConstants.NAME, newName); - putIfNotNull(data, HistoryJsonConstants.REVISION, processInstanceExecution.getRevision()); - putIfNotNull(data, HistoryJsonConstants.PROPERTY, ProcessInstancePropertyChangedHistoryJsonTransformer.PROPERTY_NAME); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_PROCESS_INSTANCE_PROPERTY_CHANGED, data); - } - } - - @Override - public void recordProcessInstanceDeleted(String processInstanceId, String processDefinitionId, String processTenantId) { - if (isHistoryEnabled(processDefinitionId)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, processInstanceId); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_PROCESS_INSTANCE_DELETED, data); - } - } - - @Override - public void recordDeleteHistoricProcessInstancesByProcessDefinitionId(String processDefinitionId) { - if (isHistoryEnabled(processDefinitionId)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_ID, processDefinitionId); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_PROCESS_INSTANCE_DELETED_BY_PROCDEF_ID, data); - } - } - - @Override - public void recordBulkDeleteProcessInstances(Collection processInstanceIds) { - if (isHistoryEnabled() && processInstanceIds != null && !processInstanceIds.isEmpty()) { - getHistoricDetailEntityManager().bulkDeleteHistoricDetailsByProcessInstanceIds(processInstanceIds); - processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService().bulkDeleteHistoricVariableInstancesByProcessInstanceIds(processInstanceIds); - getHistoricActivityInstanceEntityManager().bulkDeleteHistoricActivityInstancesByProcessInstanceIds(processInstanceIds); - TaskHelper.bulkDeleteHistoricTaskInstancesForProcessInstanceIds(processInstanceIds); - processEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService().bulkDeleteHistoricIdentityLinksForProcessInstanceIds(processInstanceIds); - - if (processEngineConfiguration.isEnableEntityLinks()) { - processEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService().bulkDeleteHistoricEntityLinksForScopeTypeAndScopeIds(ScopeTypes.BPMN, processInstanceIds); - } - - getCommentEntityManager().bulkDeleteCommentsForProcessInstanceIds(processInstanceIds); - - getHistoricProcessInstanceEntityManager().bulkDeleteHistoricProcessInstances(processInstanceIds); - - // Also delete any sub-processes that may be active (ACT-821) - - List subProcessInstanceIds = getHistoricProcessInstanceEntityManager().findHistoricProcessInstanceIdsBySuperProcessInstanceIds(processInstanceIds); - if (subProcessInstanceIds != null && !subProcessInstanceIds.isEmpty()) { - processEngineConfiguration.getHistoryManager().recordBulkDeleteProcessInstances(subProcessInstanceIds); - } - } - } - - @Override - public void recordActivityStart(ActivityInstance activityInstance) { - if (activityInstance != null && getHistoryConfigurationSettings().isHistoryEnabledForActivity(activityInstance)) { - if (activityInstance.getActivityId() != null) { - - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonActivityInstanceFields(activityInstance, data); - - putIfNotNull(data, HistoryJsonConstants.START_TIME, activityInstance.getStartTime()); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_ACTIVITY_START, data, activityInstance.getTenantId()); - } - } - } - - @Override - public void recordActivityEnd(ActivityInstance activityInstance) { - if (getHistoryConfigurationSettings().isHistoryEnabledForActivity(activityInstance)) { - if (StringUtils.isNotEmpty(activityInstance.getActivityId())) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - - addCommonActivityInstanceFields(activityInstance, data); - - putIfNotNull(data, HistoryJsonConstants.DELETE_REASON, activityInstance.getDeleteReason()); - putIfNotNull(data, HistoryJsonConstants.END_TIME, activityInstance.getEndTime()); - putIfNotNull(data, HistoryJsonConstants.START_TIME, activityInstance.getStartTime()); - - ObjectNode correspondingActivityStartData = getActivityStart(activityInstance.getId(), true); - if (correspondingActivityStartData == null) { - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_ACTIVITY_END, data); - } else { - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_ACTIVITY_FULL, data); - } - } - } - } - - @Override - public void recordProcessDefinitionChange(String processInstanceId, String processDefinitionId) { - if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processDefinitionId)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, processInstanceId); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_ID, processDefinitionId); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_SET_PROCESS_DEFINITION, data); - } - } - - @Override - public void recordTaskCreated(TaskEntity task, ExecutionEntity execution) { - if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(execution, task)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonTaskFields(task, execution, data); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_TASK_CREATED, data, task.getTenantId()); - } - } - - @Override - public void recordTaskEnd(TaskEntity task, ExecutionEntity execution, String deleteReason, Date endTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(execution, task)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonTaskFields(task, execution, data); - - putIfNotNull(data, HistoryJsonConstants.DELETE_REASON, deleteReason); - putIfNotNull(data, HistoryJsonConstants.END_TIME, endTime); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_TASK_ENDED, data); - } - } - - @SuppressWarnings("unchecked") - @Override - public void recordTaskInfoChange(TaskEntity taskEntity, String runtimeActivityInstanceId, Date changeTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(taskEntity)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonTaskFields(taskEntity, null, data); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_TASK_PROPERTY_CHANGED, data); - } - - Map originalPersistentState = (Map) taskEntity.getOriginalPersistentState(); - - if ((originalPersistentState == null && taskEntity.getAssignee() != null) || - (originalPersistentState != null && !Objects.equals(originalPersistentState.get("assignee"), taskEntity.getAssignee()))) { - - handleTaskAssigneeChange(taskEntity, runtimeActivityInstanceId, changeTime); - } - - if ((originalPersistentState == null && taskEntity.getOwner() != null) || - (originalPersistentState != null && !Objects.equals(originalPersistentState.get("owner"), taskEntity.getOwner()))) { - - handleTaskOwnerChange(taskEntity, runtimeActivityInstanceId, changeTime); - } - } - - protected void handleTaskAssigneeChange(TaskEntity taskEntity, String activityInstanceId, Date changeTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForActivity(taskEntity.getProcessDefinitionId(), taskEntity.getTaskDefinitionKey())) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.ASSIGNEE, taskEntity.getAssignee()); - - if (taskEntity.getExecutionId() != null) { - ExecutionEntity executionEntity = CommandContextUtil.getExecutionEntityManager().findById(taskEntity.getExecutionId()); - putIfNotNull(data, HistoryJsonConstants.EXECUTION_ID, executionEntity.getId()); - String activityId = getActivityIdForExecution(executionEntity); - putIfNotNull(data, HistoryJsonConstants.ACTIVITY_ID, activityId); - putIfNotNull(data, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID, activityInstanceId); - - if (isHistoryLevelAtLeast(HistoryLevel.AUDIT, taskEntity.getProcessDefinitionId())) { - ObjectNode activityStartData = getActivityStart(executionEntity.getId(), activityId, false); - if (activityStartData != null) { - putIfNotNull(activityStartData, HistoryJsonConstants.ASSIGNEE, taskEntity.getAssignee()); - data.put(HistoryJsonConstants.ACTIVITY_ASSIGNEE_HANDLED, String.valueOf(true)); - } - - } else { - data.put(HistoryJsonConstants.ACTIVITY_ASSIGNEE_HANDLED, String.valueOf(true)); - } - } - - if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(taskEntity)) { - putIfNotNull(data, HistoryJsonConstants.ID, taskEntity.getId()); - putIfNotNull(data, HistoryJsonConstants.CREATE_TIME, changeTime); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_TASK_ASSIGNEE_CHANGED, data); - } - } - } - - protected void handleTaskOwnerChange(TaskEntity taskEntity, String activityInstanceId, Date changeTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForUserTask(taskEntity)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.ID, taskEntity.getId()); - putIfNotNull(data, HistoryJsonConstants.OWNER, taskEntity.getOwner()); - putIfNotNull(data, HistoryJsonConstants.CREATE_TIME, changeTime); - putIfNotNull(data, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID, activityInstanceId); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_TASK_OWNER_CHANGED, data); - } - } - - @Override - public void recordHistoricTaskDeleted(HistoricTaskInstance task) { - if (task != null && getHistoryConfigurationSettings().isHistoryEnabledForUserTask(task)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.ID, task.getId()); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_TASK_DELETED, data); - } - } - - @Override - public void recordVariableCreate(VariableInstanceEntity variable, Date createTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForVariableInstance(variable)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonVariableFields(variable, data); - - putIfNotNull(data, HistoryJsonConstants.CREATE_TIME, createTime); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_VARIABLE_CREATED, data); - } - } - - @Override - public void recordHistoricDetailVariableCreate(VariableInstanceEntity variable, ExecutionEntity sourceActivityExecution, boolean useActivityId, - String activityInstanceId, Date createTime) { - - String processDefinitionId = getProcessDefinitionId(variable, sourceActivityExecution); - if (getHistoryConfigurationSettings().isHistoryEnabledForVariableInstance(processDefinitionId, variable) - && isHistoryLevelAtLeast(HistoryLevel.FULL, processDefinitionId)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonVariableFields(variable, data); - - if (sourceActivityExecution != null && sourceActivityExecution.isMultiInstanceRoot()) { - putIfNotNull(data, HistoryJsonConstants.IS_MULTI_INSTANCE_ROOT_EXECUTION, true); - } - - putIfNotNull(data, HistoryJsonConstants.CREATE_TIME, createTime); - - putIfNotNull(data, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID, activityInstanceId); - if (useActivityId && sourceActivityExecution != null) { - String activityId = getActivityIdForExecution(sourceActivityExecution); - if (activityId != null) { - putIfNotNull(data, HistoryJsonConstants.ACTIVITY_ID, activityId); - putIfNotNull(data, HistoryJsonConstants.SOURCE_EXECUTION_ID, sourceActivityExecution.getId()); - } - } - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_HISTORIC_DETAIL_VARIABLE_UPDATE, data); - } - } - - @Override - public void recordVariableUpdate(VariableInstanceEntity variable, Date updateTime) { - if (getHistoryConfigurationSettings().isHistoryEnabledForVariableInstance(variable)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonVariableFields(variable, data); - - putIfNotNull(data, HistoryJsonConstants.LAST_UPDATED_TIME, updateTime); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_VARIABLE_UPDATED, data); - } - } - - @Override - public void recordVariableRemoved(VariableInstanceEntity variable) { - if (getHistoryConfigurationSettings().isHistoryEnabledForVariableInstance(variable)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.ID, variable.getId()); - putIfNotNull(data, HistoryJsonConstants.REVISION, variable.getRevision()); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_VARIABLE_REMOVED, data); - } - } - - @Override - public void recordFormPropertiesSubmitted(ExecutionEntity execution, Map properties, String taskId, Date createTime) { - if (isHistoryLevelAtLeast(HistoryLevel.AUDIT, execution.getProcessDefinitionId())) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addProcessDefinitionFields(data, execution.getProcessDefinitionId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, execution.getProcessInstanceId()); - putIfNotNull(data, HistoryJsonConstants.EXECUTION_ID, execution.getId()); - putIfNotNull(data, HistoryJsonConstants.TASK_ID, taskId); - - String activityId = getActivityIdForExecution(execution); - putIfNotNull(data, HistoryJsonConstants.ACTIVITY_ID, activityId); - - putIfNotNull(data, HistoryJsonConstants.CREATE_TIME, createTime); - - int counter = 1; - for (String propertyId : properties.keySet()) { - String propertyValue = properties.get(propertyId); - data.put(HistoryJsonConstants.FORM_PROPERTY_ID + counter, propertyId); - data.put(HistoryJsonConstants.FORM_PROPERTY_VALUE + counter, propertyValue); - counter++; - } - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_FORM_PROPERTIES_SUBMITTED, data); - } - } - - @Override - public void recordIdentityLinkCreated(IdentityLinkEntity identityLink) { - // It makes no sense storing historic counterpart for an identity-link that is related - // to a process-definition only as this is never kept in history - if (getHistoryConfigurationSettings().isHistoryEnabledForIdentityLink(identityLink)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonIdentityLinkFields(identityLink, data); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_IDENTITY_LINK_CREATED, data); - } - } - - @Override - public void recordIdentityLinkDeleted(IdentityLinkEntity identityLink) { - if (getHistoryConfigurationSettings().isHistoryEnabledForIdentityLink(identityLink)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.ID, identityLink.getId()); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_IDENTITY_LINK_DELETED, data); - } - } - - @Override - public void recordEntityLinkCreated(EntityLinkEntity entityLink) { - if (getHistoryConfigurationSettings().isHistoryEnabledForEntityLink(entityLink)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonEntityLinkFields(entityLink, data); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_ENTITY_LINK_CREATED, data); - } - } - - @Override - public void recordEntityLinkDeleted(EntityLinkEntity entityLink) { - if (getHistoryConfigurationSettings().isHistoryEnabledForEntityLink(entityLink)) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.ID, entityLink.getId()); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_ENTITY_LINK_DELETED, data); - } - } - - @Override - public void updateProcessBusinessKeyInHistory(ExecutionEntity processInstance) { - if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processInstance.getProcessDefinitionId())) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, processInstance.getId()); - putIfNotNull(data, HistoryJsonConstants.BUSINESS_KEY, processInstance.getBusinessKey()); - putIfNotNull(data, HistoryJsonConstants.PROPERTY, ProcessInstancePropertyChangedHistoryJsonTransformer.PROPERTY_BUSINESS_KEY); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_PROCESS_INSTANCE_PROPERTY_CHANGED, data); - } - } - - @Override - public void updateProcessBusinessStatusInHistory(ExecutionEntity processInstance) { - if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processInstance.getProcessDefinitionId())) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, processInstance.getId()); - putIfNotNull(data, HistoryJsonConstants.BUSINESS_STATUS, processInstance.getBusinessStatus()); - putIfNotNull(data, HistoryJsonConstants.PROPERTY, ProcessInstancePropertyChangedHistoryJsonTransformer.PROPERTY_BUSINESS_STATUS); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_PROCESS_INSTANCE_PROPERTY_CHANGED, data); - } - } - - @Override - public void updateProcessDefinitionIdInHistory(ProcessDefinitionEntity processDefinitionEntity, ExecutionEntity processInstance) { - if (isHistoryEnabled(processDefinitionEntity.getId())) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.PROCESS_DEFINITION_ID, processDefinitionEntity.getId()); - putIfNotNull(data, HistoryJsonConstants.PROCESS_INSTANCE_ID, processInstance.getId()); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_UPDATE_PROCESS_DEFINITION_CASCADE, data); - } - } - - @Override - public void updateHistoricActivityInstance(ActivityInstance activityInstance) { - // the update (in the new job) synchronizes changes with runtime activityInstance - if (getHistoryConfigurationSettings().isHistoryEnabledForActivity(activityInstance)) { - if (activityInstance.getExecutionId() != null) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID, activityInstance.getId()); - putIfNotNull(data, HistoryJsonConstants.TASK_ID, activityInstance.getTaskId()); - putIfNotNull(data, HistoryJsonConstants.ASSIGNEE, activityInstance.getAssignee()); - putIfNotNull(data, HistoryJsonConstants.CALLED_PROCESS_INSTANCE_ID, activityInstance.getCalledProcessInstanceId()); - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_UPDATE_HISTORIC_ACTIVITY_INSTANCE, data); - } - } - } - - @Override - public void createHistoricActivityInstance(ActivityInstance activityInstance) { - // create (in the new job) new historic activity instance from runtime activityInstance template - if (getHistoryConfigurationSettings().isHistoryEnabledForActivity(activityInstance)) { - if (activityInstance.getExecutionId() != null) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addCommonActivityInstanceFields(activityInstance, data); - putIfNotNull(data, HistoryJsonConstants.START_TIME, activityInstance.getStartTime()); - putIfNotNull(data, HistoryJsonConstants.END_TIME, activityInstance.getEndTime()); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_ACTIVITY_FULL, data); - } - } - } - - @Override - public void recordHistoricUserTaskLogEntry(HistoricTaskLogEntryBuilder taskLogEntryBuilder) { - if (processEngineConfiguration.isEnableHistoricTaskLogging()) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - addHistoricTaskLogEntryFields(taskLogEntryBuilder, data); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_HISTORIC_TASK_LOG_RECORD, data, - taskLogEntryBuilder.getTenantId()); - } - } - - @Override - public void deleteHistoryUserTaskLog(long logNumber) { - if (processEngineConfiguration.isEnableHistoricTaskLogging()) { - ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); - putIfNotNull(data, HistoryJsonConstants.LOG_ENTRY_LOGNUMBER, logNumber); - - getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_HISTORIC_TASK_LOG_DELETE, data); - } - } - - /* Helper methods */ - - protected ObjectNode getActivityStart(String executionId, String activityId, boolean removeFromAsyncHistorySession) { - Map sessionData = getAsyncHistorySession().getSessionData(); - if (sessionData != null) { - AsyncHistorySessionData asyncHistorySessionData = sessionData.get(getJobServiceConfiguration()); - if (asyncHistorySessionData != null) { - Map> jobData = asyncHistorySessionData.getJobData(); - if (jobData != null && jobData.containsKey(HistoryJsonConstants.TYPE_ACTIVITY_START)) { - List activityStartDataList = jobData.get(HistoryJsonConstants.TYPE_ACTIVITY_START); - Iterator activityStartDataIterator = activityStartDataList.iterator(); - while (activityStartDataIterator.hasNext()) { - ObjectNode activityStartData = activityStartDataIterator.next(); - if (activityId.equals(getStringFromJson(activityStartData, HistoryJsonConstants.ACTIVITY_ID)) - && executionId.equals(getStringFromJson(activityStartData, HistoryJsonConstants.EXECUTION_ID))) { - if (removeFromAsyncHistorySession) { - activityStartDataIterator.remove(); - } - return activityStartData; - } - } - } - } - } - return null; - } - - protected ObjectNode getActivityStart(String runtimeActivityInstanceId, boolean removeFromAsyncHistorySession) { - Map sessionData = getAsyncHistorySession().getSessionData(); - if (sessionData != null) { - AsyncHistorySessionData asyncHistorySessionData = sessionData.get(getJobServiceConfiguration()); - if (asyncHistorySessionData != null) { - Map> jobData = asyncHistorySessionData.getJobData(); - if (jobData != null && jobData.containsKey(HistoryJsonConstants.TYPE_ACTIVITY_START)) { - List activityStartDataList = jobData.get(HistoryJsonConstants.TYPE_ACTIVITY_START); - Iterator activityStartDataIterator = activityStartDataList.iterator(); - while (activityStartDataIterator.hasNext()) { - ObjectNode activityStartData = activityStartDataIterator.next(); - if (runtimeActivityInstanceId.equals(getStringFromJson(activityStartData, - HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID))) { - if (removeFromAsyncHistorySession) { - activityStartDataIterator.remove(); - } - return activityStartData; - } - } - } - } - } - return null; - } - - protected JobServiceConfiguration getJobServiceConfiguration() { - return getProcessEngineConfiguration().getJobServiceConfiguration(); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/HistoryJsonConstants.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/HistoryJsonConstants.java deleted file mode 100644 index 1ff3c826c53..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/HistoryJsonConstants.java +++ /dev/null @@ -1,244 +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.engine.impl.history.async; - -import java.util.Arrays; -import java.util.List; - -public interface HistoryJsonConstants { - - String JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY = "async-history"; // Backwards compatibility: process engine used this first before the handler was reused - - String JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED = "async-history-zipped"; // Backwards compatibility: process engine used this first before the handler was reused - - String TYPE = "type"; - - List ORDERED_TYPES = Arrays.asList( - HistoryJsonConstants.TYPE_PROCESS_INSTANCE_START, - HistoryJsonConstants.TYPE_PROCESS_INSTANCE_PROPERTY_CHANGED, - HistoryJsonConstants.TYPE_ACTIVITY_START, - HistoryJsonConstants.TYPE_ACTIVITY_END, - HistoryJsonConstants.TYPE_ACTIVITY_FULL, - HistoryJsonConstants.TYPE_TASK_CREATED, - HistoryJsonConstants.TYPE_TASK_ASSIGNEE_CHANGED, - HistoryJsonConstants.TYPE_TASK_OWNER_CHANGED, - HistoryJsonConstants.TYPE_TASK_PROPERTY_CHANGED, - HistoryJsonConstants.TYPE_TASK_ENDED, - HistoryJsonConstants.TYPE_TASK_DELETED, - HistoryJsonConstants.TYPE_VARIABLE_CREATED, - HistoryJsonConstants.TYPE_VARIABLE_UPDATED, - HistoryJsonConstants.TYPE_VARIABLE_REMOVED, - HistoryJsonConstants.TYPE_HISTORIC_DETAIL_VARIABLE_UPDATE, - HistoryJsonConstants.TYPE_FORM_PROPERTIES_SUBMITTED, - HistoryJsonConstants.TYPE_SET_PROCESS_DEFINITION, - HistoryJsonConstants.TYPE_SUBPROCESS_INSTANCE_START, - HistoryJsonConstants.TYPE_IDENTITY_LINK_CREATED, - HistoryJsonConstants.TYPE_IDENTITY_LINK_DELETED, - HistoryJsonConstants.TYPE_PROCESS_INSTANCE_DELETED_BY_PROCDEF_ID, - HistoryJsonConstants.TYPE_PROCESS_INSTANCE_DELETED, - HistoryJsonConstants.TYPE_PROCESS_INSTANCE_END - ); - - String TYPE_PROCESS_INSTANCE_START = "process-instance-start"; - String TYPE_SUBPROCESS_INSTANCE_START = "subprocess-instance-start"; - String TYPE_PROCESS_INSTANCE_PROPERTY_CHANGED = "process-instance-property-changed"; - String TYPE_SET_PROCESS_DEFINITION = "set-process-definition"; - String TYPE_UPDATE_PROCESS_DEFINITION_CASCADE = "update-process-definition-cascade"; - String TYPE_ACTIVITY_START = "activity-start"; - String TYPE_ACTIVITY_END = "activity-end"; - String TYPE_ACTIVITY_FULL = "activity-full"; - String TYPE_FORM_PROPERTIES_SUBMITTED = "form-properties-submitted"; - String TYPE_HISTORIC_DETAIL_VARIABLE_UPDATE = "historic-detail-variable-update"; - String TYPE_IDENTITY_LINK_CREATED = "identitylink-created"; - String TYPE_IDENTITY_LINK_DELETED = "identitylink-deleted"; - String TYPE_ENTITY_LINK_CREATED = "entitylink-created"; - String TYPE_ENTITY_LINK_DELETED = "entitylink-deleted"; - String TYPE_TASK_CREATED = "task-created"; - String TYPE_TASK_ASSIGNEE_CHANGED = "task-assignee-changed"; - String TYPE_TASK_OWNER_CHANGED = "task-owner-changed"; - String TYPE_TASK_PROPERTY_CHANGED = "task-property-changed"; - String TYPE_TASK_ENDED = "task-ended"; - String TYPE_TASK_DELETED = "task-deleted"; - String TYPE_VARIABLE_CREATED = "variable-created"; - String TYPE_VARIABLE_UPDATED = "variable-updated"; - String TYPE_VARIABLE_REMOVED = "variable-removed"; - String TYPE_PROCESS_INSTANCE_END = "process-instance-end"; - String TYPE_PROCESS_INSTANCE_DELETED = "process-instance-deleted"; - String TYPE_PROCESS_INSTANCE_DELETED_BY_PROCDEF_ID = "process-instance-deleted-by-process-definition-id"; - String TYPE_UPDATE_HISTORIC_ACTIVITY_INSTANCE = "activity-update"; - String TYPE_HISTORIC_TASK_LOG_RECORD = "historic-user-task-log-record"; - String TYPE_HISTORIC_TASK_LOG_DELETE = "historic-user-task-log-delete"; - - - String DATA = "data"; - - String ID = "id"; - - String NAME = "name"; - - String DESCRIPTION = "description"; - - String REVISION = "revision"; - - String CATEGORY = "category"; - - String EXECUTION_ID = "executionId"; - - String SOURCE_EXECUTION_ID = "sourceExecutionId"; - - String IS_MULTI_INSTANCE_ROOT_EXECUTION = "isMiRootExecution"; - - String PROCESS_INSTANCE_ID = "processInstanceId"; - - String TASK_ID = "taskId"; - - String BUSINESS_KEY = "businessKey"; - - String BUSINESS_STATUS = "businessStatus"; - - String PROCESS_DEFINITION_ID = "processDefinitionId"; - - String PROCESS_DEFINITION_KEY = "processDefinitionKey"; - - String PROCESS_DEFINITION_NAME = "processDefinitionName"; - - String PROCESS_DEFINITION_VERSION = "processDefinitionVersion"; - - String PROCESS_DEFINITION_CATEGORY = "processDefinitionCategory"; - - String PROCESS_DEFINITIN_DERIVED_FROM = "processDefinitionDerivedFrom"; - - String PROCESS_DEFINITIN_DERIVED_FROM_ROOT = "processDefinitionDerivedFromRoot"; - - String PROCESS_DEFINITIN_DERIVED_VERSION = "processDefinitionDerivedVersion"; - - String DEPLOYMENT_ID = "deploymentId"; - - String START_TIME = "startTime"; - - String END_TIME = "endTime"; - - String CREATE_TIME = "createTime"; - - String CLAIM_TIME = "claimTime"; - - String LAST_UPDATED_TIME = "lastUpdatedTime"; - - String START_USER_ID = "startUserId"; - - String START_ACTIVITY_ID = "startActivityId"; - - String ACTIVITY_ID = "activityId"; - - String ACTIVITY_NAME = "activityName"; - - String ACTIVITY_TYPE = "activityType"; - - String TRANSACTION_ORDER = "transactionOrder"; - - String SUPER_PROCESS_INSTANCE_ID = "superProcessInstanceId"; - - String DELETE_REASON = "deleteReason"; - - String PARENT_TASK_ID = "parentTaskId"; - - String ASSIGNEE = "assignee"; - - String ACTIVITY_ASSIGNEE_HANDLED = "activityAssigneeHandled"; - - String OWNER = "owner"; - - String IDENTITY_LINK_TYPE = "identityLinkType"; - - String ENTITY_LINK_TYPE = "entityLinkType"; - - String TASK_DEFINITION_KEY = "taskDefinitionKey"; - - String TASK_DEFINITION_ID = "taskDefinitionId"; - - String FORM_KEY = "formKey"; - - String PRIORITY = "priority"; - - String DUE_DATE = "dueDate"; - - String PROPERTY = "property"; - - String VARIABLE_TYPE = "variableType"; - - String VARIABLE_TEXT_VALUE = "variableTextValue"; - - String VARIABLE_TEXT_VALUE2 = "variableTextValue2"; - - String VARIABLE_DOUBLE_VALUE = "variableDoubleValue"; - - String VARIABLE_LONG_VALUE = "variableLongValue"; - - String VARIABLE_BYTES_VALUE = "variableBytesValue"; - - String VARIABLE_META_INFO = "variableMetaInfo"; - - String FORM_PROPERTY_ID = "formPropertyId"; - - String FORM_PROPERTY_VALUE = "formPropertyValue"; - - String USER_ID = "userId"; - - String GROUP_ID = "groupId"; - - String TENANT_ID = "tenantId"; - - String CALLBACK_ID = "callbackId"; - - String CALLBACK_TYPE = "callbackType"; - - String REFERENCE_ID = "referenceId"; - - String REFERENCE_TYPE = "referenceType"; - - String PROPAGATED_STAGE_INSTANCE_ID = "propagatedStageInstanceId"; - - String CALLED_PROCESS_INSTANCE_ID = "calledProcessInstanceId"; - - String SCOPE_ID = "scopeId"; - - String SUB_SCOPE_ID = "subScopeId"; - - String SCOPE_TYPE = "scopeType"; - - String SCOPE_DEFINITION_ID = "scopeDefinitionId"; - - String PARENT_ELEMENT_ID = "parentElementId"; - - String REF_SCOPE_ID = "referenceScopeId"; - - String REF_SCOPE_TYPE = "referenceScopeType"; - - String REF_SCOPE_DEFINITION_ID = "referenceScopeDefinitionId"; - - String ROOT_SCOPE_ID = "rootScopeId"; - - String ROOT_SCOPE_TYPE = "rootScopeType"; - - String HIERARCHY_TYPE = "hierarchyType"; - - String RUNTIME_ACTIVITY_INSTANCE_ID = "runtimeActivityInstanceId"; - - String TIMESTAMP = "__timeStamp"; // Two underscores to avoid clashes with other fields - - String LOG_ENTRY_TYPE = "logEntryType"; - - String LOG_ENTRY_DATA = "logEntryData"; - - String LOG_ENTRY_LOGNUMBER = "logNumber"; -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractHistoryJsonTransformer.java deleted file mode 100644 index aa0caa72d1c..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractHistoryJsonTransformer.java +++ /dev/null @@ -1,164 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.api.delegate.event.FlowableEvent; -import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntityManager; -import org.flowable.engine.impl.util.CommandContextUtil; -import org.flowable.job.service.impl.history.async.transformer.HistoryJsonTransformer; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public abstract class AbstractHistoryJsonTransformer implements HistoryJsonTransformer { - - protected ProcessEngineConfigurationImpl processEngineConfiguration; - - public AbstractHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - this.processEngineConfiguration = processEngineConfiguration; - } - - protected void dispatchEvent(CommandContext commandContext, FlowableEvent event) { - FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher(); - if (eventDispatcher != null && eventDispatcher.isEnabled()) { - eventDispatcher.dispatchEvent(event, processEngineConfiguration.getEngineCfgKey()); - } - } - - public boolean historicActivityInstanceExistsForData(ObjectNode historicalData, CommandContext commandContext) { - String runtimeActivityInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID); - if (runtimeActivityInstanceId != null) { - return processEngineConfiguration.getHistoricActivityInstanceEntityManager().findById(runtimeActivityInstanceId) != null; - } else { - String executionId = getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID); - if (StringUtils.isNotEmpty(executionId)) { - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - - if (StringUtils.isNotEmpty(activityId)) { - HistoricActivityInstanceEntity historicActivityInstanceEntity = findUnfinishedHistoricActivityInstance(commandContext, executionId, - activityId); - return historicActivityInstanceEntity != null; - } - } - } - return false; - } - - public boolean historicActivityInstanceExistsForDataIncludingFinished(ObjectNode historicalData, CommandContext commandContext) { - String runtimeActivityInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID); - if (StringUtils.isNotEmpty(runtimeActivityInstanceId)) { - HistoricActivityInstanceEntity historicActivityInstanceEntity = CommandContextUtil.getHistoricActivityInstanceEntityManager(commandContext).findById(runtimeActivityInstanceId); - return historicActivityInstanceEntity != null; - } else { - String executionId = getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID); - if (StringUtils.isNotEmpty(executionId)) { - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - - if (StringUtils.isNotEmpty(activityId)) { - HistoricActivityInstanceEntity historicActivityInstanceEntity = findHistoricActivityInstance(commandContext, executionId, activityId); - return historicActivityInstanceEntity != null; - } - } - return false; - } - } - - protected HistoricActivityInstanceEntity findUnfinishedHistoricActivityInstance(CommandContext commandContext, String executionId, String activityId) { - if (executionId == null || activityId == null) { - return null; - } - - HistoricActivityInstanceEntity historicActivityInstanceEntity = getUnfinishedHistoricActivityInstanceFromCache(commandContext, executionId, activityId); - if (historicActivityInstanceEntity == null) { - List historicActivityInstances = processEngineConfiguration.getHistoricActivityInstanceEntityManager() - .findUnfinishedHistoricActivityInstancesByExecutionAndActivityId(executionId, activityId); - if (!historicActivityInstances.isEmpty()) { - historicActivityInstanceEntity = historicActivityInstances.get(0); - } - } - return historicActivityInstanceEntity; - } - - protected HistoricActivityInstanceEntity getUnfinishedHistoricActivityInstanceFromCache(CommandContext commandContext, - String executionId, String activityId) { - - List cachedHistoricActivityInstances = CommandContextUtil.getEntityCache(commandContext).findInCache(HistoricActivityInstanceEntity.class); - for (HistoricActivityInstanceEntity cachedHistoricActivityInstance : cachedHistoricActivityInstances) { - if (activityId != null - && activityId.equals(cachedHistoricActivityInstance.getActivityId()) - && cachedHistoricActivityInstance.getEndTime() == null - && executionId.equals(cachedHistoricActivityInstance.getExecutionId())) { - - return cachedHistoricActivityInstance; - } - } - return null; - } - - protected HistoricActivityInstanceEntity findHistoricActivityInstance(CommandContext commandContext, String executionId, String activityId) { - if (executionId == null || activityId == null) { - return null; - } - - HistoricActivityInstanceEntity historicActivityInstanceEntity = getHistoricActivityInstanceFromCache(commandContext, executionId, activityId); - if (historicActivityInstanceEntity == null) { - List historicActivityInstances = processEngineConfiguration.getHistoricActivityInstanceEntityManager() - .findHistoricActivityInstancesByExecutionAndActivityId(executionId, activityId); - if (!historicActivityInstances.isEmpty()) { - historicActivityInstanceEntity = historicActivityInstances.get(0); - } - } - return historicActivityInstanceEntity; - } - - protected HistoricActivityInstanceEntity getHistoricActivityInstanceFromCache(CommandContext commandContext, - String executionId, String activityId) { - - List cachedHistoricActivityInstances = CommandContextUtil.getEntityCache(commandContext).findInCache(HistoricActivityInstanceEntity.class); - for (HistoricActivityInstanceEntity cachedHistoricActivityInstance : cachedHistoricActivityInstances) { - if (activityId != null - && activityId.equals(cachedHistoricActivityInstance.getActivityId()) - && executionId.equals(cachedHistoricActivityInstance.getExecutionId())) { - - return cachedHistoricActivityInstance; - } - } - return null; - } - - protected HistoricActivityInstanceEntity createHistoricActivityInstanceEntity(ObjectNode historicalData, CommandContext commandContext, - HistoricActivityInstanceEntityManager historicActivityInstanceEntityManager) { - String runtimeActivityId = getStringFromJson(historicalData, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID); - HistoricActivityInstanceEntity historicActivityInstanceEntity = historicActivityInstanceEntityManager.create(); - if (StringUtils.isEmpty(runtimeActivityId)) { - if (processEngineConfiguration.isUsePrefixId()) { - historicActivityInstanceEntity.setId(historicActivityInstanceEntity.getIdPrefix() + processEngineConfiguration.getIdGenerator().getNextId()); - } else { - historicActivityInstanceEntity.setId(processEngineConfiguration.getIdGenerator().getNextId()); - } - } else { - historicActivityInstanceEntity.setId(runtimeActivityId); - } - return historicActivityInstanceEntity; - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsHistoricActivityHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsHistoricActivityHistoryJsonTransformer.java deleted file mode 100644 index c10e158ba8a..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsHistoricActivityHistoryJsonTransformer.java +++ /dev/null @@ -1,31 +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.engine.impl.history.async.json.transformer; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public abstract class AbstractNeedsHistoricActivityHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public AbstractNeedsHistoricActivityHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return historicActivityInstanceExistsForDataIncludingFinished(historicalData, commandContext); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsProcessInstanceHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsProcessInstanceHistoryJsonTransformer.java deleted file mode 100644 index 73a709037bf..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsProcessInstanceHistoryJsonTransformer.java +++ /dev/null @@ -1,37 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public abstract class AbstractNeedsProcessInstanceHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public AbstractNeedsProcessInstanceHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - String processInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID); - HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager = processEngineConfiguration.getHistoricProcessInstanceEntityManager(); - return historicProcessInstanceEntityManager.findById(processInstanceId) != null; - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsTaskHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsTaskHistoryJsonTransformer.java deleted file mode 100644 index e8f6dff7881..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsTaskHistoryJsonTransformer.java +++ /dev/null @@ -1,35 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public abstract class AbstractNeedsTaskHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public AbstractNeedsTaskHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - String taskId = getStringFromJson(historicalData, HistoryJsonConstants.ID); - return processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().getHistoricTask(taskId) != null; - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsUnfinishedHistoricActivityHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsUnfinishedHistoricActivityHistoryJsonTransformer.java deleted file mode 100644 index 30d533b5cf9..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractNeedsUnfinishedHistoricActivityHistoryJsonTransformer.java +++ /dev/null @@ -1,31 +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.engine.impl.history.async.json.transformer; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public abstract class AbstractNeedsUnfinishedHistoricActivityHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public AbstractNeedsUnfinishedHistoricActivityHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return historicActivityInstanceExistsForData(historicalData, commandContext); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractProcessInstanceDeleteHistoryTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractProcessInstanceDeleteHistoryTransformer.java deleted file mode 100644 index bd717e54857..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/AbstractProcessInstanceDeleteHistoryTransformer.java +++ /dev/null @@ -1,56 +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.engine.impl.history.async.json.transformer; - -import java.util.List; - -import org.flowable.common.engine.api.scope.ScopeTypes; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager; -import org.flowable.engine.impl.util.TaskHelper; -import org.flowable.entitylink.service.EntityLinkServiceConfiguration; - -public abstract class AbstractProcessInstanceDeleteHistoryTransformer extends AbstractHistoryJsonTransformer { - - public AbstractProcessInstanceDeleteHistoryTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - protected void deleteProcessInstance(String processInstanceId, CommandContext commandContext) { - HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager = processEngineConfiguration.getHistoricProcessInstanceEntityManager(); - HistoricProcessInstanceEntity historicProcessInstance = historicProcessInstanceEntityManager.findById(processInstanceId); - - processEngineConfiguration.getHistoricDetailEntityManager().deleteHistoricDetailsByProcessInstanceId(processInstanceId); - processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService().deleteHistoricVariableInstancesByProcessInstanceId(processInstanceId); - processEngineConfiguration.getHistoricActivityInstanceEntityManager().deleteHistoricActivityInstancesByProcessInstanceId(processInstanceId); - TaskHelper.deleteHistoricTaskInstancesByProcessInstanceId(processInstanceId); - processEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService().deleteHistoricIdentityLinksByProcessInstanceId(processInstanceId); - EntityLinkServiceConfiguration entityLinkServiceConfiguration = processEngineConfiguration.getEntityLinkServiceConfiguration(); - if (entityLinkServiceConfiguration != null) { - entityLinkServiceConfiguration.getHistoricEntityLinkService().deleteHistoricEntityLinksByScopeIdAndScopeType(processInstanceId, ScopeTypes.BPMN); - } - processEngineConfiguration.getCommentEntityManager().deleteCommentsByProcessInstanceId(processInstanceId); - - historicProcessInstanceEntityManager.delete(historicProcessInstance, false); - - // Also delete any sub-processes that may be active (ACT-821) - - List selectList = historicProcessInstanceEntityManager.findHistoricProcessInstancesBySuperProcessInstanceId(processInstanceId); - for (HistoricProcessInstance child : selectList) { - deleteProcessInstance(child.getId(), commandContext); - } - } -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityEndHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityEndHistoryJsonTransformer.java deleted file mode 100644 index 81357af670a..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityEndHistoryJsonTransformer.java +++ /dev/null @@ -1,79 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.delegate.event.impl.FlowableEventBuilder; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ActivityEndHistoryJsonTransformer extends AbstractNeedsUnfinishedHistoricActivityHistoryJsonTransformer { - - public ActivityEndHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_ACTIVITY_END); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - boolean isApplicable = super.isApplicable(historicalData, commandContext); - - if (!isApplicable - && !historicalData.has(HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID) - && historicalData.has(HistoryJsonConstants.EXECUTION_ID) - && historicalData.has(HistoryJsonConstants.ACTIVITY_ID)) { - // This is old data, before the runtime activities were used. - // As such, the transformJson can be tried (the null check will make sure no wrong instance is changed) - isApplicable = true; - } - - return isApplicable; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String executionId = getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID); - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - HistoricActivityInstanceEntity historicActivityInstanceEntity = findUnfinishedHistoricActivityInstance(commandContext, executionId, activityId); - if (historicActivityInstanceEntity != null) { - Date endTime = getDateFromJson(historicalData, HistoryJsonConstants.END_TIME); - historicActivityInstanceEntity.setEndTime(endTime); - historicActivityInstanceEntity.setDeleteReason(getStringFromJson(historicalData, HistoryJsonConstants.DELETE_REASON)); - - Date startTime = historicActivityInstanceEntity.getStartTime(); - if (startTime != null && endTime != null) { - historicActivityInstanceEntity.setDurationInMillis(endTime.getTime() - startTime.getTime()); - } - - dispatchEvent(commandContext, FlowableEventBuilder.createEntityEvent( - FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, historicActivityInstanceEntity)); - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityFullHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityFullHistoryJsonTransformer.java deleted file mode 100644 index 7b2915deb89..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityFullHistoryJsonTransformer.java +++ /dev/null @@ -1,83 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getIntegerFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.delegate.event.impl.FlowableEventBuilder; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntityManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ActivityFullHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public ActivityFullHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_ACTIVITY_FULL); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricActivityInstanceEntityManager historicActivityInstanceEntityManager = processEngineConfiguration.getHistoricActivityInstanceEntityManager(); - - HistoricActivityInstanceEntity historicActivityInstanceEntity = createHistoricActivityInstanceEntity(historicalData, commandContext, historicActivityInstanceEntityManager); - - historicActivityInstanceEntity.setProcessDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID)); - historicActivityInstanceEntity.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicActivityInstanceEntity.setExecutionId(getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID)); - historicActivityInstanceEntity.setActivityId(getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID)); - historicActivityInstanceEntity.setActivityName(getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_NAME)); - historicActivityInstanceEntity.setActivityType(getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_TYPE)); - historicActivityInstanceEntity.setStartTime(getDateFromJson(historicalData, HistoryJsonConstants.START_TIME)); - historicActivityInstanceEntity.setTenantId(getStringFromJson(historicalData, HistoryJsonConstants.TENANT_ID)); - historicActivityInstanceEntity.setTransactionOrder(getIntegerFromJson(historicalData, HistoryJsonConstants.TRANSACTION_ORDER)); - - Date endTime = getDateFromJson(historicalData, HistoryJsonConstants.END_TIME); - historicActivityInstanceEntity.setEndTime(endTime); - historicActivityInstanceEntity.setDeleteReason(getStringFromJson(historicalData, HistoryJsonConstants.DELETE_REASON)); - - Date startTime = historicActivityInstanceEntity.getStartTime(); - if (startTime != null && endTime != null) { - historicActivityInstanceEntity.setDurationInMillis(endTime.getTime() - startTime.getTime()); - } - - historicActivityInstanceEntityManager.insert(historicActivityInstanceEntity); - dispatchEvent(commandContext, FlowableEventBuilder.createEntityEvent( - FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstanceEntity)); - - dispatchEvent(commandContext, FlowableEventBuilder.createEntityEvent( - FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, historicActivityInstanceEntity)); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityStartHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityStartHistoryJsonTransformer.java deleted file mode 100644 index 7d9aaf24576..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityStartHistoryJsonTransformer.java +++ /dev/null @@ -1,72 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getIntegerFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.delegate.event.impl.FlowableEventBuilder; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntityManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ActivityStartHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public ActivityStartHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_ACTIVITY_START); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricActivityInstanceEntityManager historicActivityInstanceEntityManager = processEngineConfiguration.getHistoricActivityInstanceEntityManager(); - - HistoricActivityInstanceEntity historicActivityInstanceEntity = createHistoricActivityInstanceEntity(historicalData, commandContext, - historicActivityInstanceEntityManager); - - historicActivityInstanceEntity.setProcessDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID)); - historicActivityInstanceEntity.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicActivityInstanceEntity.setExecutionId(getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID)); - historicActivityInstanceEntity.setActivityId(getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID)); - historicActivityInstanceEntity.setActivityName(getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_NAME)); - historicActivityInstanceEntity.setActivityType(getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_TYPE)); - historicActivityInstanceEntity.setAssignee(getStringFromJson(historicalData, HistoryJsonConstants.ASSIGNEE)); - historicActivityInstanceEntity.setStartTime(getDateFromJson(historicalData, HistoryJsonConstants.START_TIME)); - historicActivityInstanceEntity.setTransactionOrder(getIntegerFromJson(historicalData, HistoryJsonConstants.TRANSACTION_ORDER)); - historicActivityInstanceEntity.setTenantId(getStringFromJson(historicalData, HistoryJsonConstants.TENANT_ID)); - - historicActivityInstanceEntityManager.insert(historicActivityInstanceEntity); - dispatchEvent(commandContext, FlowableEventBuilder.createEntityEvent( - FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstanceEntity)); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityUpdateHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityUpdateHistoryJsonTransformer.java deleted file mode 100644 index 2fdf5af5661..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ActivityUpdateHistoryJsonTransformer.java +++ /dev/null @@ -1,84 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntityManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author martin.grofcik - */ -public class ActivityUpdateHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public ActivityUpdateHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_UPDATE_HISTORIC_ACTIVITY_INSTANCE); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - String activityInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID); - if (StringUtils.isNotEmpty(activityInstanceId)) { - HistoricActivityInstanceEntity historicActivityInstance = processEngineConfiguration.getHistoricActivityInstanceEntityManager().findById(activityInstanceId); - if (historicActivityInstance == null) { - return false; - } - } - return true; - - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String activityInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID); - if (StringUtils.isNotEmpty(activityInstanceId)) { - HistoricActivityInstanceEntityManager historicActivityInstanceEntityManager = processEngineConfiguration.getHistoricActivityInstanceEntityManager(); - HistoricActivityInstanceEntity historicActivityInstance = historicActivityInstanceEntityManager.findById(activityInstanceId); - if (historicActivityInstance != null) { - if (historicalData.has(HistoryJsonConstants.TASK_ID)) { - String taskId = getStringFromJson(historicalData, HistoryJsonConstants.TASK_ID); - historicActivityInstance.setTaskId(taskId); - } - - if (historicalData.has(HistoryJsonConstants.ASSIGNEE)) { - String assignee = getStringFromJson(historicalData, HistoryJsonConstants.ASSIGNEE); - historicActivityInstance.setAssignee(assignee); - } - - if (historicalData.has(HistoryJsonConstants.CALLED_PROCESS_INSTANCE_ID)) { - String calledProcessInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.CALLED_PROCESS_INSTANCE_ID); - historicActivityInstance.setCalledProcessInstanceId(calledProcessInstanceId); - } - } - - } - - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/EntityLinkCreatedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/EntityLinkCreatedHistoryJsonTransformer.java deleted file mode 100644 index 2173ec0e219..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/EntityLinkCreatedHistoryJsonTransformer.java +++ /dev/null @@ -1,67 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.entitylink.api.history.HistoricEntityLinkService; -import org.flowable.entitylink.service.impl.persistence.entity.HistoricEntityLinkEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class EntityLinkCreatedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public EntityLinkCreatedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_ENTITY_LINK_CREATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricEntityLinkService historicEntityLinkService = processEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService(); - HistoricEntityLinkEntity historicEntityLinkEntity = (HistoricEntityLinkEntity) historicEntityLinkService.createHistoricEntityLink(); - historicEntityLinkEntity.setId(getStringFromJson(historicalData, HistoryJsonConstants.ID)); - historicEntityLinkEntity.setLinkType(getStringFromJson(historicalData, HistoryJsonConstants.ENTITY_LINK_TYPE)); - historicEntityLinkEntity.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); - historicEntityLinkEntity.setScopeId(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_ID)); - historicEntityLinkEntity.setSubScopeId(getStringFromJson(historicalData, HistoryJsonConstants.SUB_SCOPE_ID)); - historicEntityLinkEntity.setScopeType(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_TYPE)); - historicEntityLinkEntity.setScopeDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_DEFINITION_ID)); - historicEntityLinkEntity.setParentElementId(getStringFromJson(historicalData, HistoryJsonConstants.PARENT_ELEMENT_ID)); - historicEntityLinkEntity.setReferenceScopeId(getStringFromJson(historicalData, HistoryJsonConstants.REF_SCOPE_ID)); - historicEntityLinkEntity.setReferenceScopeType(getStringFromJson(historicalData, HistoryJsonConstants.REF_SCOPE_TYPE)); - historicEntityLinkEntity.setReferenceScopeDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.REF_SCOPE_DEFINITION_ID)); - historicEntityLinkEntity.setRootScopeId(getStringFromJson(historicalData, HistoryJsonConstants.ROOT_SCOPE_ID)); - historicEntityLinkEntity.setRootScopeType(getStringFromJson(historicalData, HistoryJsonConstants.ROOT_SCOPE_TYPE)); - historicEntityLinkEntity.setHierarchyType(getStringFromJson(historicalData, HistoryJsonConstants.HIERARCHY_TYPE)); - historicEntityLinkService.insertHistoricEntityLink(historicEntityLinkEntity, false); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/EntityLinkDeletedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/EntityLinkDeletedHistoryJsonTransformer.java deleted file mode 100644 index c9306abdce3..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/EntityLinkDeletedHistoryJsonTransformer.java +++ /dev/null @@ -1,50 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.entitylink.api.history.HistoricEntityLinkService; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class EntityLinkDeletedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public EntityLinkDeletedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_ENTITY_LINK_DELETED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricEntityLinkService historicEntityLinkService = processEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService(); - historicEntityLinkService.deleteHistoricEntityLink(getStringFromJson(historicalData, HistoryJsonConstants.ID)); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/FormPropertiesSubmittedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/FormPropertiesSubmittedHistoryJsonTransformer.java deleted file mode 100644 index 6177e21f59a..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/FormPropertiesSubmittedHistoryJsonTransformer.java +++ /dev/null @@ -1,93 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricDetailEntityManager; -import org.flowable.engine.impl.persistence.entity.HistoricFormPropertyEntity; -import org.flowable.engine.impl.persistence.entity.data.HistoricDetailDataManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class FormPropertiesSubmittedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public FormPropertiesSubmittedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_FORM_PROPERTIES_SUBMITTED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - if (StringUtils.isNotEmpty(activityId)) { - HistoricActivityInstance historicActivityInstance = findHistoricActivityInstance(commandContext, - getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID), activityId); - - if (historicActivityInstance == null) { - return false; - } - } - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricDetailDataManager historicDetailDataManager = processEngineConfiguration.getHistoricDetailDataManager(); - - int counter = 1; - while (true) { - - String propertyId = getStringFromJson(historicalData, HistoryJsonConstants.FORM_PROPERTY_ID + counter); - if (StringUtils.isEmpty(propertyId)) { - break; - } - - HistoricFormPropertyEntity historicFormPropertyEntity = historicDetailDataManager.createHistoricFormProperty(); - historicFormPropertyEntity.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicFormPropertyEntity.setExecutionId(getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID)); - historicFormPropertyEntity.setTaskId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_ID)); - historicFormPropertyEntity.setPropertyId(propertyId); - historicFormPropertyEntity.setPropertyValue(getStringFromJson(historicalData, HistoryJsonConstants.FORM_PROPERTY_VALUE + counter)); - historicFormPropertyEntity.setTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); - - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - if (StringUtils.isNotEmpty(activityId)) { - HistoricActivityInstance activityInstance = findHistoricActivityInstance(commandContext, - getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID), activityId); - - historicFormPropertyEntity.setActivityInstanceId(activityInstance.getId()); - } - - HistoricDetailEntityManager historicDetailEntityManager = processEngineConfiguration.getHistoricDetailEntityManager(); - historicDetailEntityManager.insert(historicFormPropertyEntity); - - counter++; - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricDetailVariableUpdateHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricDetailVariableUpdateHistoryJsonTransformer.java deleted file mode 100644 index 3206ad1f347..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricDetailVariableUpdateHistoryJsonTransformer.java +++ /dev/null @@ -1,120 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getBooleanFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDoubleFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getIntegerFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getLongFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Base64; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricDetailEntityManager; -import org.flowable.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity; -import org.flowable.engine.impl.persistence.entity.data.HistoricDetailDataManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.variable.api.types.VariableType; -import org.flowable.variable.api.types.VariableTypes; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class HistoricDetailVariableUpdateHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public HistoricDetailVariableUpdateHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_HISTORIC_DETAIL_VARIABLE_UPDATE); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - - // Variables for a mi root execution (like nrOfInstances, nrOfCompletedInstance, etc.) are stored without a reference to the historical activity. - Boolean isMiRootExecution = getBooleanFromJson(historicalData, HistoryJsonConstants.IS_MULTI_INSTANCE_ROOT_EXECUTION, false); - - if (!isMiRootExecution && StringUtils.isNotEmpty(activityId)) { - HistoricActivityInstance activityInstance = findHistoricActivityInstance(commandContext, - getStringFromJson(historicalData, HistoryJsonConstants.SOURCE_EXECUTION_ID), activityId); - if (activityInstance == null) { - return false; - } - } - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricDetailDataManager historicDetailDataManager = processEngineConfiguration.getHistoricDetailDataManager(); - HistoricDetailVariableInstanceUpdateEntity historicDetailEntity = historicDetailDataManager.createHistoricDetailVariableInstanceUpdate(); - historicDetailEntity.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicDetailEntity.setExecutionId(getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID)); - historicDetailEntity.setTaskId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_ID)); - historicDetailEntity.setRevision(getIntegerFromJson(historicalData, HistoryJsonConstants.REVISION)); - historicDetailEntity.setName(getStringFromJson(historicalData, HistoryJsonConstants.NAME)); - - Boolean isMiRootExecution = getBooleanFromJson(historicalData, HistoryJsonConstants.IS_MULTI_INSTANCE_ROOT_EXECUTION, false); - if (!isMiRootExecution) { - String runtimeActivityInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID); - if (StringUtils.isNotEmpty(runtimeActivityInstanceId)) { - historicDetailEntity.setActivityInstanceId(runtimeActivityInstanceId); - } else { - // there can be still jobs in the queue without runtimeActivityInstanceId - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - if (StringUtils.isNotEmpty(activityId)) { - HistoricActivityInstance activityInstance = findHistoricActivityInstance(commandContext, - getStringFromJson(historicalData, HistoryJsonConstants.SOURCE_EXECUTION_ID), activityId); - - if (activityInstance != null) { - historicDetailEntity.setActivityInstanceId(activityInstance.getId()); - } - } - } - } - - VariableTypes variableTypes = processEngineConfiguration.getVariableTypes(); - VariableType variableType = variableTypes.getVariableType(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_TYPE)); - - historicDetailEntity.setVariableType(variableType); - - historicDetailEntity.setTextValue(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_TEXT_VALUE)); - historicDetailEntity.setTextValue2(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_TEXT_VALUE2)); - historicDetailEntity.setDoubleValue(getDoubleFromJson(historicalData, HistoryJsonConstants.VARIABLE_DOUBLE_VALUE)); - historicDetailEntity.setLongValue(getLongFromJson(historicalData, HistoryJsonConstants.VARIABLE_LONG_VALUE)); - - String variableBytes = getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_BYTES_VALUE); - if (StringUtils.isNotEmpty(variableBytes)) { - historicDetailEntity.setBytes(Base64.getDecoder().decode(variableBytes)); - } - - Date time = getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME); - historicDetailEntity.setTime(time); - - HistoricDetailEntityManager historicDetailEntityManager = processEngineConfiguration.getHistoricDetailEntityManager(); - historicDetailEntityManager.insert(historicDetailEntity); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricUserTaskLogDeleteJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricUserTaskLogDeleteJsonTransformer.java deleted file mode 100644 index 6a7c1977b3b..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricUserTaskLogDeleteJsonTransformer.java +++ /dev/null @@ -1,53 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getLongFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author martin.grofcik - */ -public class HistoricUserTaskLogDeleteJsonTransformer extends AbstractHistoryJsonTransformer { - - public HistoricUserTaskLogDeleteJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_HISTORIC_TASK_LOG_DELETE); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - Long logNumber = getLongFromJson(historicalData, HistoryJsonConstants.LOG_ENTRY_LOGNUMBER); - if (logNumber != null) { - processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().deleteHistoricTaskLogEntry(logNumber); - } - } -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricUserTaskLogRecordJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricUserTaskLogRecordJsonTransformer.java deleted file mode 100644 index 50c67667f4b..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/HistoricUserTaskLogRecordJsonTransformer.java +++ /dev/null @@ -1,68 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.service.impl.BaseHistoricTaskLogEntryBuilderImpl; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author martin.grofcik - */ -public class HistoricUserTaskLogRecordJsonTransformer extends AbstractHistoryJsonTransformer { - - public HistoricUserTaskLogRecordJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_HISTORIC_TASK_LOG_RECORD); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - BaseHistoricTaskLogEntryBuilderImpl taskLogEntryBuilder = new BaseHistoricTaskLogEntryBuilderImpl(); - - taskLogEntryBuilder.data(getStringFromJson(historicalData, HistoryJsonConstants.LOG_ENTRY_DATA)); - taskLogEntryBuilder.processInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - taskLogEntryBuilder.executionId(getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID)); - taskLogEntryBuilder.processDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID)); - taskLogEntryBuilder.taskId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_ID)); - taskLogEntryBuilder.tenantId(getStringFromJson(historicalData, HistoryJsonConstants.TENANT_ID)); - taskLogEntryBuilder.timeStamp(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); - taskLogEntryBuilder.type(getStringFromJson(historicalData, HistoryJsonConstants.LOG_ENTRY_TYPE)); - taskLogEntryBuilder.userId(getStringFromJson(historicalData, HistoryJsonConstants.USER_ID)); - taskLogEntryBuilder.scopeType(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_TYPE)); - taskLogEntryBuilder.scopeId(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_ID)); - taskLogEntryBuilder.subScopeId(getStringFromJson(historicalData, HistoryJsonConstants.SUB_SCOPE_ID)); - taskLogEntryBuilder.scopeDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_DEFINITION_ID)); - - processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().createHistoricTaskLogEntry(taskLogEntryBuilder); - } -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/IdentityLinkCreatedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/IdentityLinkCreatedHistoryJsonTransformer.java deleted file mode 100644 index bc30b0321b1..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/IdentityLinkCreatedHistoryJsonTransformer.java +++ /dev/null @@ -1,61 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.identitylink.service.HistoricIdentityLinkService; -import org.flowable.identitylink.service.impl.persistence.entity.HistoricIdentityLinkEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class IdentityLinkCreatedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public IdentityLinkCreatedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_IDENTITY_LINK_CREATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricIdentityLinkService historicIdentityLinkService = processEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService(); - HistoricIdentityLinkEntity historicIdentityLinkEntity = historicIdentityLinkService.createHistoricIdentityLink(); - historicIdentityLinkEntity.setId(getStringFromJson(historicalData, HistoryJsonConstants.ID)); - historicIdentityLinkEntity.setGroupId(getStringFromJson(historicalData, HistoryJsonConstants.GROUP_ID)); - historicIdentityLinkEntity.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicIdentityLinkEntity.setTaskId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_ID)); - historicIdentityLinkEntity.setScopeDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_DEFINITION_ID)); - historicIdentityLinkEntity.setScopeId(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_ID)); - historicIdentityLinkEntity.setScopeType(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_TYPE)); - historicIdentityLinkEntity.setType(getStringFromJson(historicalData, HistoryJsonConstants.IDENTITY_LINK_TYPE)); - historicIdentityLinkEntity.setUserId(getStringFromJson(historicalData, HistoryJsonConstants.USER_ID)); - historicIdentityLinkService.insertHistoricIdentityLink(historicIdentityLinkEntity, false); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/IdentityLinkDeletedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/IdentityLinkDeletedHistoryJsonTransformer.java deleted file mode 100644 index 5b243a75618..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/IdentityLinkDeletedHistoryJsonTransformer.java +++ /dev/null @@ -1,50 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.identitylink.service.HistoricIdentityLinkService; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class IdentityLinkDeletedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public IdentityLinkDeletedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_IDENTITY_LINK_DELETED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricIdentityLinkService historicIdentityLinkService = processEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService(); - historicIdentityLinkService.deleteHistoricIdentityLink(getStringFromJson(historicalData, HistoryJsonConstants.ID)); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceDeleteHistoryByProcessDefinitionIdJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceDeleteHistoryByProcessDefinitionIdJsonTransformer.java deleted file mode 100644 index cf12a0eed4f..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceDeleteHistoryByProcessDefinitionIdJsonTransformer.java +++ /dev/null @@ -1,51 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ProcessInstanceDeleteHistoryByProcessDefinitionIdJsonTransformer extends AbstractProcessInstanceDeleteHistoryTransformer { - - public ProcessInstanceDeleteHistoryByProcessDefinitionIdJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_PROCESS_INSTANCE_DELETED_BY_PROCDEF_ID); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String processDefinitionId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID); - List processInstanceIds = processEngineConfiguration.getHistoricProcessInstanceEntityManager().findHistoricProcessInstanceIdsByProcessDefinitionId(processDefinitionId); - for (String processInstanceId : processInstanceIds) { - deleteProcessInstance(processInstanceId, commandContext); - } - } -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceDeleteHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceDeleteHistoryJsonTransformer.java deleted file mode 100644 index 72fd1c684ec..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceDeleteHistoryJsonTransformer.java +++ /dev/null @@ -1,51 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ProcessInstanceDeleteHistoryJsonTransformer extends AbstractProcessInstanceDeleteHistoryTransformer { - - public ProcessInstanceDeleteHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_PROCESS_INSTANCE_DELETED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - String id = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID); - HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager = processEngineConfiguration.getHistoricProcessInstanceEntityManager(); - return historicProcessInstanceEntityManager.findById(id) != null; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String processInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID); - deleteProcessInstance(processInstanceId, commandContext); - } -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceEndHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceEndHistoryJsonTransformer.java deleted file mode 100644 index 477c616b005..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceEndHistoryJsonTransformer.java +++ /dev/null @@ -1,107 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.delegate.event.impl.FlowableEventBuilder; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ProcessInstanceEndHistoryJsonTransformer extends AbstractNeedsProcessInstanceHistoryJsonTransformer { - - public ProcessInstanceEndHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_PROCESS_INSTANCE_END); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager = processEngineConfiguration.getHistoricProcessInstanceEntityManager(); - - String processInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID); - HistoricProcessInstanceEntity historicProcessInstance = historicProcessInstanceEntityManager.findById(processInstanceId); - - if (historicProcessInstance != null) { - historicProcessInstance.setEndActivityId(getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID)); - - Date endTime = getDateFromJson(historicalData, HistoryJsonConstants.END_TIME); - historicProcessInstance.setEndTime(endTime); - historicProcessInstance.setDeleteReason(getStringFromJson(historicalData, HistoryJsonConstants.DELETE_REASON)); - - Date startTime = historicProcessInstance.getStartTime(); - if (startTime != null && endTime != null) { - historicProcessInstance.setDurationInMillis(endTime.getTime() - startTime.getTime()); - } - - } else { - historicProcessInstance = historicProcessInstanceEntityManager.create(); - historicProcessInstance.setId(getStringFromJson(historicalData, HistoryJsonConstants.ID)); - historicProcessInstance.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicProcessInstance.setBusinessKey(getStringFromJson(historicalData, HistoryJsonConstants.BUSINESS_KEY)); - historicProcessInstance.setBusinessStatus(getStringFromJson(historicalData, HistoryJsonConstants.BUSINESS_STATUS)); - historicProcessInstance.setProcessDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID)); - historicProcessInstance.setProcessDefinitionKey(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_KEY)); - historicProcessInstance.setProcessDefinitionName(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_NAME)); - String versionString = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_VERSION); - historicProcessInstance.setProcessDefinitionVersion(versionString != null ? Integer.valueOf(versionString) : 0); - historicProcessInstance.setDeploymentId(getStringFromJson(historicalData, HistoryJsonConstants.DEPLOYMENT_ID)); - historicProcessInstance.setStartTime(getDateFromJson(historicalData, HistoryJsonConstants.START_TIME)); - historicProcessInstance.setStartUserId(getStringFromJson(historicalData, HistoryJsonConstants.START_USER_ID)); - historicProcessInstance.setStartActivityId(getStringFromJson(historicalData, HistoryJsonConstants.START_ACTIVITY_ID)); - historicProcessInstance.setSuperProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.SUPER_PROCESS_INSTANCE_ID)); - historicProcessInstance.setCallbackId(getStringFromJson(historicalData, HistoryJsonConstants.CALLBACK_ID)); - historicProcessInstance.setCallbackType(getStringFromJson(historicalData, HistoryJsonConstants.CALLBACK_TYPE)); - historicProcessInstance.setReferenceId(getStringFromJson(historicalData, HistoryJsonConstants.REFERENCE_ID)); - historicProcessInstance.setReferenceType(getStringFromJson(historicalData, HistoryJsonConstants.REFERENCE_TYPE)); - historicProcessInstance.setPropagatedStageInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROPAGATED_STAGE_INSTANCE_ID)); - historicProcessInstance.setTenantId(getStringFromJson(historicalData, HistoryJsonConstants.TENANT_ID)); - - historicProcessInstanceEntityManager.insert(historicProcessInstance, false); - - dispatchEvent(commandContext, FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance)); - - historicProcessInstance.setEndActivityId(getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID)); - - Date endTime = getDateFromJson(historicalData, HistoryJsonConstants.END_TIME); - historicProcessInstance.setEndTime(endTime); - historicProcessInstance.setDeleteReason(getStringFromJson(historicalData, HistoryJsonConstants.DELETE_REASON)); - - Date startTime = historicProcessInstance.getStartTime(); - if (startTime != null && endTime != null) { - historicProcessInstance.setDurationInMillis(endTime.getTime() - startTime.getTime()); - } - - historicProcessInstanceEntityManager.update(historicProcessInstance, false); - - } - dispatchEvent(commandContext, FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_PROCESS_INSTANCE_ENDED, historicProcessInstance)); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstancePropertyChangedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstancePropertyChangedHistoryJsonTransformer.java deleted file mode 100644 index 0e5bd20294f..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstancePropertyChangedHistoryJsonTransformer.java +++ /dev/null @@ -1,63 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ProcessInstancePropertyChangedHistoryJsonTransformer extends AbstractNeedsProcessInstanceHistoryJsonTransformer { - - public static final String PROPERTY_NAME = "name"; - public static final String PROPERTY_BUSINESS_KEY = "businessKey"; - public static final String PROPERTY_BUSINESS_STATUS = "businessStatus"; - - public ProcessInstancePropertyChangedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_PROCESS_INSTANCE_PROPERTY_CHANGED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String processInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID); - String property = getStringFromJson(historicalData, HistoryJsonConstants.PROPERTY); - if (StringUtils.isNotEmpty(processInstanceId) && StringUtils.isNotEmpty(property)) { - HistoricProcessInstanceEntity historicProcessInstance = processEngineConfiguration.getHistoricProcessInstanceEntityManager().findById(processInstanceId); - - if (PROPERTY_NAME.equals(property)) { - historicProcessInstance.setName(getStringFromJson(historicalData, HistoryJsonConstants.NAME)); - - } else if (PROPERTY_BUSINESS_KEY.equals(property)) { - historicProcessInstance.setBusinessKey(getStringFromJson(historicalData, HistoryJsonConstants.BUSINESS_KEY)); - - } else if (PROPERTY_BUSINESS_STATUS.equals(property)) { - historicProcessInstance.setBusinessStatus(getStringFromJson(historicalData, HistoryJsonConstants.BUSINESS_STATUS)); - } - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceStartHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceStartHistoryJsonTransformer.java deleted file mode 100644 index 79d253848ac..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/ProcessInstanceStartHistoryJsonTransformer.java +++ /dev/null @@ -1,88 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.delegate.event.impl.FlowableEventBuilder; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ProcessInstanceStartHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public ProcessInstanceStartHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_PROCESS_INSTANCE_START); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager = processEngineConfiguration.getHistoricProcessInstanceEntityManager(); - - String id = getStringFromJson(historicalData, "id"); - HistoricProcessInstanceEntity historicProcessInstance = historicProcessInstanceEntityManager.findById(id); - if (historicProcessInstance == null) { - historicProcessInstance = historicProcessInstanceEntityManager.create(); - historicProcessInstance.setId(getStringFromJson(historicalData, HistoryJsonConstants.ID)); - historicProcessInstance.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicProcessInstance.setName(getStringFromJson(historicalData, HistoryJsonConstants.NAME)); - historicProcessInstance.setBusinessKey(getStringFromJson(historicalData, HistoryJsonConstants.BUSINESS_KEY)); - historicProcessInstance.setBusinessStatus(getStringFromJson(historicalData, HistoryJsonConstants.BUSINESS_STATUS)); - historicProcessInstance.setProcessDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID)); - historicProcessInstance.setProcessDefinitionKey(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_KEY)); - historicProcessInstance.setProcessDefinitionName(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_NAME)); - String versionString = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_VERSION); - historicProcessInstance.setProcessDefinitionVersion(versionString != null ? Integer.valueOf(versionString) : 0); - historicProcessInstance.setDeploymentId(getStringFromJson(historicalData, HistoryJsonConstants.DEPLOYMENT_ID)); - historicProcessInstance.setStartTime(getDateFromJson(historicalData, HistoryJsonConstants.START_TIME)); - historicProcessInstance.setStartUserId(getStringFromJson(historicalData, HistoryJsonConstants.START_USER_ID)); - historicProcessInstance.setStartActivityId(getStringFromJson(historicalData, HistoryJsonConstants.START_ACTIVITY_ID)); - historicProcessInstance.setSuperProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.SUPER_PROCESS_INSTANCE_ID)); - historicProcessInstance.setCallbackId(getStringFromJson(historicalData, HistoryJsonConstants.CALLBACK_ID)); - historicProcessInstance.setCallbackType(getStringFromJson(historicalData, HistoryJsonConstants.CALLBACK_TYPE)); - historicProcessInstance.setReferenceId(getStringFromJson(historicalData, HistoryJsonConstants.REFERENCE_ID)); - historicProcessInstance.setReferenceType(getStringFromJson(historicalData, HistoryJsonConstants.REFERENCE_TYPE)); - historicProcessInstance.setPropagatedStageInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROPAGATED_STAGE_INSTANCE_ID)); - historicProcessInstance.setTenantId(getStringFromJson(historicalData, HistoryJsonConstants.TENANT_ID)); - - historicProcessInstanceEntityManager.insert(historicProcessInstance, false); - - dispatchEvent(commandContext, FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance)); - - } else { - historicProcessInstance.setStartActivityId(getStringFromJson(historicalData, HistoryJsonConstants.START_ACTIVITY_ID)); - historicProcessInstanceEntityManager.update(historicProcessInstance, false); - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/SetProcessDefinitionHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/SetProcessDefinitionHistoryJsonTransformer.java deleted file mode 100644 index 37f421b43ed..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/SetProcessDefinitionHistoryJsonTransformer.java +++ /dev/null @@ -1,47 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class SetProcessDefinitionHistoryJsonTransformer extends AbstractNeedsProcessInstanceHistoryJsonTransformer { - - public SetProcessDefinitionHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_SET_PROCESS_DEFINITION); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String processInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID); - String processDefinitionId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID); - HistoricProcessInstanceEntity historicProcessInstance = processEngineConfiguration.getHistoricProcessInstanceEntityManager().findById(processInstanceId); - historicProcessInstance.setProcessDefinitionId(processDefinitionId); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/SubProcessInstanceStartHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/SubProcessInstanceStartHistoryJsonTransformer.java deleted file mode 100644 index 6e910ff7635..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/SubProcessInstanceStartHistoryJsonTransformer.java +++ /dev/null @@ -1,105 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.delegate.event.impl.FlowableEventBuilder; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class SubProcessInstanceStartHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public SubProcessInstanceStartHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_SUBPROCESS_INSTANCE_START); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - HistoricActivityInstance activityInstance = findHistoricActivityInstance(commandContext, - getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID), activityId); - - if (activityInstance == null) { - return false; - } - - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager = processEngineConfiguration.getHistoricProcessInstanceEntityManager(); - - String id = getStringFromJson(historicalData, HistoryJsonConstants.ID); - String processInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID); - HistoricProcessInstanceEntity historicProcessInstance = historicProcessInstanceEntityManager.findById(id); - if (historicProcessInstance == null) { - HistoricProcessInstanceEntity subProcessInstance = historicProcessInstanceEntityManager.create(); - - subProcessInstance.setId(id); - subProcessInstance.setProcessInstanceId(processInstanceId); - subProcessInstance.setBusinessKey(getStringFromJson(historicalData, HistoryJsonConstants.BUSINESS_KEY)); - subProcessInstance.setBusinessStatus(getStringFromJson(historicalData, HistoryJsonConstants.BUSINESS_STATUS)); - subProcessInstance.setProcessDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID)); - subProcessInstance.setProcessDefinitionKey(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_KEY)); - subProcessInstance.setProcessDefinitionName(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_NAME)); - String versionString = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_VERSION); - subProcessInstance.setProcessDefinitionVersion(versionString != null ? Integer.valueOf(versionString) : 0); - subProcessInstance.setDeploymentId(getStringFromJson(historicalData, HistoryJsonConstants.DEPLOYMENT_ID)); - subProcessInstance.setStartTime(getDateFromJson(historicalData, HistoryJsonConstants.START_TIME)); - subProcessInstance.setStartUserId(getStringFromJson(historicalData, HistoryJsonConstants.START_USER_ID)); - subProcessInstance.setStartActivityId(getStringFromJson(historicalData, HistoryJsonConstants.START_ACTIVITY_ID)); - subProcessInstance.setSuperProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.SUPER_PROCESS_INSTANCE_ID)); - subProcessInstance.setCallbackId(getStringFromJson(historicalData, HistoryJsonConstants.CALLBACK_ID)); - subProcessInstance.setCallbackType(getStringFromJson(historicalData, HistoryJsonConstants.CALLBACK_TYPE)); - subProcessInstance.setReferenceId(getStringFromJson(historicalData, HistoryJsonConstants.REFERENCE_ID)); - subProcessInstance.setReferenceType(getStringFromJson(historicalData, HistoryJsonConstants.REFERENCE_TYPE)); - subProcessInstance.setPropagatedStageInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROPAGATED_STAGE_INSTANCE_ID)); - subProcessInstance.setTenantId(getStringFromJson(historicalData, HistoryJsonConstants.TENANT_ID)); - - historicProcessInstanceEntityManager.insert(subProcessInstance, false); - - // Fire event - dispatchEvent(commandContext, FlowableEventBuilder.createEntityEvent( - FlowableEngineEventType.HISTORIC_PROCESS_INSTANCE_CREATED, subProcessInstance)); - } - - String executionId = getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID); - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - - HistoricActivityInstanceEntity activityInstance = findHistoricActivityInstance(commandContext, executionId, activityId); - if (activityInstance != null) { - activityInstance.setCalledProcessInstanceId(processInstanceId); - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskAssigneeChangedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskAssigneeChangedHistoryJsonTransformer.java deleted file mode 100644 index d9a75c9b527..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskAssigneeChangedHistoryJsonTransformer.java +++ /dev/null @@ -1,102 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.identitylink.api.IdentityLinkType; -import org.flowable.identitylink.service.HistoricIdentityLinkService; -import org.flowable.identitylink.service.impl.persistence.entity.HistoricIdentityLinkEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class TaskAssigneeChangedHistoryJsonTransformer extends AbstractNeedsTaskHistoryJsonTransformer { - - public TaskAssigneeChangedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_TASK_ASSIGNEE_CHANGED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - String activityAssigneeHandled = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ASSIGNEE_HANDLED); - if (activityAssigneeHandled != null && Boolean.valueOf(activityAssigneeHandled)) { - return super.isApplicable(historicalData, commandContext); - - } else { - String executionId = getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID); - if (StringUtils.isNotEmpty(executionId)) { - return super.isApplicable(historicalData, commandContext) - && historicActivityInstanceExistsForDataIncludingFinished(historicalData, commandContext); - - } else { - return super.isApplicable(historicalData, commandContext); - } - } - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String assignee = getStringFromJson(historicalData, HistoryJsonConstants.ASSIGNEE); - - String executionId = getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID); - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - String runtimeActivityInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID); - if (StringUtils.isNotEmpty(executionId) && StringUtils.isNotEmpty(activityId)) { - - String activityAssigneeHandled = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ASSIGNEE_HANDLED); - - if (activityAssigneeHandled == null || !Boolean.valueOf(activityAssigneeHandled)) { - HistoricActivityInstanceEntity historicActivityInstanceEntity; - if (StringUtils.isEmpty(runtimeActivityInstanceId)) { - historicActivityInstanceEntity = findHistoricActivityInstance(commandContext, executionId, activityId); - } else { - historicActivityInstanceEntity = processEngineConfiguration.getHistoricActivityInstanceEntityManager().findById(runtimeActivityInstanceId); - } - - if (historicActivityInstanceEntity == null) { - // activity instance not found, ignoring event - return; - } - - historicActivityInstanceEntity.setAssignee(assignee); - } - } - - String taskId = getStringFromJson(historicalData, HistoryJsonConstants.ID); - if (StringUtils.isNotEmpty(taskId)) { - HistoricIdentityLinkService historicIdentityLinkService = processEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService(); - HistoricIdentityLinkEntity historicIdentityLinkEntity = historicIdentityLinkService.createHistoricIdentityLink(); - historicIdentityLinkEntity.setTaskId(taskId); - historicIdentityLinkEntity.setType(IdentityLinkType.ASSIGNEE); - historicIdentityLinkEntity.setUserId(assignee); - historicIdentityLinkEntity.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); - historicIdentityLinkService.insertHistoricIdentityLink(historicIdentityLinkEntity, false); - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskCreatedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskCreatedHistoryJsonTransformer.java deleted file mode 100644 index 47c28447af5..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskCreatedHistoryJsonTransformer.java +++ /dev/null @@ -1,100 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getIntegerFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.service.HistoricTaskService; -import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class TaskCreatedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public TaskCreatedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_TASK_CREATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricTaskService historicTaskService = processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService(); - - String taskId = getStringFromJson(historicalData, HistoryJsonConstants.ID); - String executionId = getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID); - - HistoricTaskInstanceEntity historicTaskInstance = historicTaskService.getHistoricTask(taskId); - - if (historicTaskInstance == null) { - historicTaskInstance = historicTaskService.createHistoricTask(); - historicTaskInstance.setId(taskId); - historicTaskInstance.setProcessDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID)); - historicTaskInstance.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicTaskInstance.setExecutionId(executionId); - historicTaskInstance.setName(getStringFromJson(historicalData, HistoryJsonConstants.NAME)); - historicTaskInstance.setParentTaskId(getStringFromJson(historicalData, HistoryJsonConstants.PARENT_TASK_ID)); - historicTaskInstance.setDescription(getStringFromJson(historicalData, HistoryJsonConstants.DESCRIPTION)); - historicTaskInstance.setOwner(getStringFromJson(historicalData, HistoryJsonConstants.OWNER)); - historicTaskInstance.setAssignee(getStringFromJson(historicalData, HistoryJsonConstants.ASSIGNEE)); - if (historicalData.has(HistoryJsonConstants.CREATE_TIME)) { - historicTaskInstance.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); - } else { - // For backwards compatibility. New async data uses the CREATE_TIME. This should be removed eventually - historicTaskInstance.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.START_TIME)); - } - historicTaskInstance.setTaskDefinitionKey(getStringFromJson(historicalData, HistoryJsonConstants.TASK_DEFINITION_KEY)); - historicTaskInstance.setTaskDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_DEFINITION_ID)); - historicTaskInstance.setFormKey(getStringFromJson(historicalData, HistoryJsonConstants.FORM_KEY)); - historicTaskInstance.setPriority(getIntegerFromJson(historicalData, HistoryJsonConstants.PRIORITY)); - historicTaskInstance.setDueDate(getDateFromJson(historicalData, HistoryJsonConstants.DUE_DATE)); - historicTaskInstance.setCategory(getStringFromJson(historicalData, HistoryJsonConstants.CATEGORY)); - historicTaskInstance.setClaimTime(getDateFromJson(historicalData, HistoryJsonConstants.CLAIM_TIME)); - historicTaskInstance.setTenantId(getStringFromJson(historicalData, HistoryJsonConstants.TENANT_ID)); - historicTaskInstance.setLastUpdateTime(getDateFromJson(historicalData, HistoryJsonConstants.TIMESTAMP)); - - historicTaskService.insertHistoricTask(historicTaskInstance, true); - } - - // there can be still job in the queue which can have activityId in and we should be able to handle it - if (StringUtils.isNotEmpty(executionId)) { - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - if (StringUtils.isNotEmpty(activityId)) { - HistoricActivityInstanceEntity historicActivityInstanceEntity = findHistoricActivityInstance(commandContext, executionId, activityId); - if (historicActivityInstanceEntity != null) { - historicActivityInstanceEntity.setTaskId(taskId); - } - } - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskDeletedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskDeletedHistoryJsonTransformer.java deleted file mode 100644 index 7a61dc7adde..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskDeletedHistoryJsonTransformer.java +++ /dev/null @@ -1,45 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.engine.impl.util.TaskHelper; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class TaskDeletedHistoryJsonTransformer extends AbstractNeedsTaskHistoryJsonTransformer { - - public TaskDeletedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_TASK_DELETED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String taskId = getStringFromJson(historicalData, HistoryJsonConstants.ID); - TaskHelper.deleteHistoricTask(taskId); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskEndedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskEndedHistoryJsonTransformer.java deleted file mode 100644 index 38516ff8b0f..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskEndedHistoryJsonTransformer.java +++ /dev/null @@ -1,139 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getIntegerFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.service.HistoricTaskService; -import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class TaskEndedHistoryJsonTransformer extends AbstractNeedsTaskHistoryJsonTransformer { - - public TaskEndedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_TASK_ENDED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String taskId = getStringFromJson(historicalData, HistoryJsonConstants.ID); - HistoricTaskService historicTaskService = processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService(); - HistoricTaskInstanceEntity historicTaskInstance = historicTaskService.getHistoricTask(taskId); - - if (historicTaskInstance != null) { - Date lastUpdateTime = getDateFromJson(historicalData, HistoryJsonConstants.TIMESTAMP); - if (historicTaskInstance.getLastUpdateTime() == null || !historicTaskInstance.getLastUpdateTime().after(lastUpdateTime)) { - historicTaskInstance.setLastUpdateTime(lastUpdateTime); - - historicTaskInstance.setName(getStringFromJson(historicalData, HistoryJsonConstants.NAME)); - historicTaskInstance.setParentTaskId(getStringFromJson(historicalData, HistoryJsonConstants.PARENT_TASK_ID)); - historicTaskInstance.setDescription(getStringFromJson(historicalData, HistoryJsonConstants.DESCRIPTION)); - historicTaskInstance.setOwner(getStringFromJson(historicalData, HistoryJsonConstants.OWNER)); - historicTaskInstance.setAssignee(getStringFromJson(historicalData, HistoryJsonConstants.ASSIGNEE)); - if (historicalData.has(HistoryJsonConstants.CREATE_TIME)) { - historicTaskInstance.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); - } else { - // For backwards compatibility. New async data uses the CREATE_TIME. This should be removed eventually - historicTaskInstance.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.START_TIME)); - } - historicTaskInstance.setTaskDefinitionKey(getStringFromJson(historicalData, HistoryJsonConstants.TASK_DEFINITION_KEY)); - historicTaskInstance.setTaskDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_DEFINITION_ID)); - historicTaskInstance.setPriority(getIntegerFromJson(historicalData, HistoryJsonConstants.PRIORITY)); - historicTaskInstance.setDueDate(getDateFromJson(historicalData, HistoryJsonConstants.DUE_DATE)); - historicTaskInstance.setCategory(getStringFromJson(historicalData, HistoryJsonConstants.CATEGORY)); - historicTaskInstance.setFormKey(getStringFromJson(historicalData, HistoryJsonConstants.FORM_KEY)); - historicTaskInstance.setClaimTime(getDateFromJson(historicalData, HistoryJsonConstants.CLAIM_TIME)); - historicTaskInstance.setTenantId(getStringFromJson(historicalData, HistoryJsonConstants.TENANT_ID)); - - } - - Date endTime = getDateFromJson(historicalData, HistoryJsonConstants.END_TIME); - historicTaskInstance.setEndTime(endTime); - historicTaskInstance.setDeleteReason(getStringFromJson(historicalData, HistoryJsonConstants.DELETE_REASON)); - - Date startTime = historicTaskInstance.getStartTime(); - if (startTime != null && endTime != null) { - historicTaskInstance.setDurationInMillis(endTime.getTime() - startTime.getTime()); - } - - } else { - String executionId = getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID); - - historicTaskInstance = historicTaskService.createHistoricTask(); - historicTaskInstance.setId(taskId); - historicTaskInstance.setProcessDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID)); - historicTaskInstance.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicTaskInstance.setExecutionId(executionId); - historicTaskInstance.setName(getStringFromJson(historicalData, HistoryJsonConstants.NAME)); - historicTaskInstance.setParentTaskId(getStringFromJson(historicalData, HistoryJsonConstants.PARENT_TASK_ID)); - historicTaskInstance.setDescription(getStringFromJson(historicalData, HistoryJsonConstants.DESCRIPTION)); - historicTaskInstance.setOwner(getStringFromJson(historicalData, HistoryJsonConstants.OWNER)); - historicTaskInstance.setAssignee(getStringFromJson(historicalData, HistoryJsonConstants.ASSIGNEE)); - if (historicalData.has(HistoryJsonConstants.CREATE_TIME)) { - historicTaskInstance.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); - } else { - // For backwards compatibility. New async data uses the CREATE_TIME. This should be removed eventually - historicTaskInstance.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.START_TIME)); - } - historicTaskInstance.setTaskDefinitionKey(getStringFromJson(historicalData, HistoryJsonConstants.TASK_DEFINITION_KEY)); - historicTaskInstance.setTaskDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_DEFINITION_ID)); - historicTaskInstance.setPriority(getIntegerFromJson(historicalData, HistoryJsonConstants.PRIORITY)); - historicTaskInstance.setDueDate(getDateFromJson(historicalData, HistoryJsonConstants.DUE_DATE)); - historicTaskInstance.setCategory(getStringFromJson(historicalData, HistoryJsonConstants.CATEGORY)); - historicTaskInstance.setFormKey(getStringFromJson(historicalData, HistoryJsonConstants.FORM_KEY)); - historicTaskInstance.setClaimTime(getDateFromJson(historicalData, HistoryJsonConstants.CLAIM_TIME)); - historicTaskInstance.setTenantId(getStringFromJson(historicalData, HistoryJsonConstants.TENANT_ID)); - historicTaskInstance.setLastUpdateTime(getDateFromJson(historicalData, HistoryJsonConstants.TIMESTAMP)); - - Date endTime = getDateFromJson(historicalData, HistoryJsonConstants.END_TIME); - historicTaskInstance.setEndTime(endTime); - historicTaskInstance.setDeleteReason(getStringFromJson(historicalData, HistoryJsonConstants.DELETE_REASON)); - - Date startTime = historicTaskInstance.getStartTime(); - if (startTime != null && endTime != null) { - historicTaskInstance.setDurationInMillis(endTime.getTime() - startTime.getTime()); - } - - historicTaskService.insertHistoricTask(historicTaskInstance, true); - - if (StringUtils.isNotEmpty(executionId)) { - String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); - if (StringUtils.isNotEmpty(activityId)) { - HistoricActivityInstanceEntity historicActivityInstanceEntity = findHistoricActivityInstance(commandContext, executionId, activityId); - if (historicActivityInstanceEntity != null) { - historicActivityInstanceEntity.setTaskId(taskId); - } - } - } - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskOwnerChangedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskOwnerChangedHistoryJsonTransformer.java deleted file mode 100644 index 3672f6275e4..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskOwnerChangedHistoryJsonTransformer.java +++ /dev/null @@ -1,56 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.identitylink.api.IdentityLinkType; -import org.flowable.identitylink.service.HistoricIdentityLinkService; -import org.flowable.identitylink.service.impl.persistence.entity.HistoricIdentityLinkEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class TaskOwnerChangedHistoryJsonTransformer extends AbstractNeedsTaskHistoryJsonTransformer { - - public TaskOwnerChangedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_TASK_OWNER_CHANGED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String owner = getStringFromJson(historicalData, HistoryJsonConstants.OWNER); - String taskId = getStringFromJson(historicalData, HistoryJsonConstants.ID); - - HistoricIdentityLinkService historicIdentityLinkService = processEngineConfiguration.getIdentityLinkServiceConfiguration().getHistoricIdentityLinkService(); - HistoricIdentityLinkEntity historicIdentityLinkEntity = historicIdentityLinkService.createHistoricIdentityLink(); - historicIdentityLinkEntity.setTaskId(taskId); - historicIdentityLinkEntity.setType(IdentityLinkType.OWNER); - historicIdentityLinkEntity.setUserId(owner); - historicIdentityLinkEntity.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); - historicIdentityLinkService.insertHistoricIdentityLink(historicIdentityLinkEntity, false); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskPropertyChangedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskPropertyChangedHistoryJsonTransformer.java deleted file mode 100644 index 5510be80531..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/TaskPropertyChangedHistoryJsonTransformer.java +++ /dev/null @@ -1,78 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getIntegerFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class TaskPropertyChangedHistoryJsonTransformer extends AbstractNeedsTaskHistoryJsonTransformer { - - private static final Logger LOGGER = LoggerFactory.getLogger(TaskPropertyChangedHistoryJsonTransformer.class); - - public TaskPropertyChangedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_TASK_PROPERTY_CHANGED); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String taskId = getStringFromJson(historicalData, HistoryJsonConstants.ID); - if (StringUtils.isNotEmpty(taskId)) { - HistoricTaskInstanceEntity historicTaskInstance = processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().getHistoricTask(taskId); - - Date lastUpdateTime = getDateFromJson(historicalData, HistoryJsonConstants.TIMESTAMP); - if (historicTaskInstance.getLastUpdateTime() == null || !historicTaskInstance.getLastUpdateTime().after(lastUpdateTime)) { - historicTaskInstance.setName(getStringFromJson(historicalData, HistoryJsonConstants.NAME)); - historicTaskInstance.setDescription(getStringFromJson(historicalData, HistoryJsonConstants.DESCRIPTION)); - historicTaskInstance.setAssignee(getStringFromJson(historicalData, HistoryJsonConstants.ASSIGNEE)); - historicTaskInstance.setOwner(getStringFromJson(historicalData, HistoryJsonConstants.OWNER)); - historicTaskInstance.setClaimTime(getDateFromJson(historicalData, HistoryJsonConstants.CLAIM_TIME)); - historicTaskInstance.setDueDate(getDateFromJson(historicalData, HistoryJsonConstants.DUE_DATE)); - historicTaskInstance.setPriority(getIntegerFromJson(historicalData, HistoryJsonConstants.PRIORITY)); - historicTaskInstance.setCategory(getStringFromJson(historicalData, HistoryJsonConstants.CATEGORY)); - historicTaskInstance.setFormKey(getStringFromJson(historicalData, HistoryJsonConstants.FORM_KEY)); - historicTaskInstance.setParentTaskId(getStringFromJson(historicalData, HistoryJsonConstants.PARENT_TASK_ID)); - historicTaskInstance.setTaskDefinitionKey(getStringFromJson(historicalData, HistoryJsonConstants.TASK_DEFINITION_KEY)); - historicTaskInstance.setTaskDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_DEFINITION_ID)); - historicTaskInstance.setProcessDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID)); - historicTaskInstance.setLastUpdateTime(lastUpdateTime); - - } else { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("History job (id={}) has expired and will be ignored.", job.getId()); - } - } - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/UpdateProcessDefinitionCascadeHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/UpdateProcessDefinitionCascadeHistoryJsonTransformer.java deleted file mode 100644 index ee634eed564..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/UpdateProcessDefinitionCascadeHistoryJsonTransformer.java +++ /dev/null @@ -1,83 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.engine.impl.HistoricActivityInstanceQueryImpl; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntityManager; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntity; -import org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.service.HistoricTaskService; -import org.flowable.task.service.impl.HistoricTaskInstanceQueryImpl; -import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class UpdateProcessDefinitionCascadeHistoryJsonTransformer extends AbstractNeedsProcessInstanceHistoryJsonTransformer { - - public UpdateProcessDefinitionCascadeHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_UPDATE_PROCESS_DEFINITION_CASCADE); - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - String processDefinitionId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_DEFINITION_ID); - String processInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID); - - HistoricProcessInstanceEntityManager historicProcessInstanceEntityManager = processEngineConfiguration.getHistoricProcessInstanceEntityManager(); - HistoricProcessInstanceEntity historicProcessInstance = (HistoricProcessInstanceEntity) historicProcessInstanceEntityManager.findById(processInstanceId); - historicProcessInstance.setProcessDefinitionId(processDefinitionId); - historicProcessInstanceEntityManager.update(historicProcessInstance); - - HistoricTaskService historicTaskService = processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService(); - HistoricTaskInstanceQueryImpl taskQuery = new HistoricTaskInstanceQueryImpl(); - taskQuery.processInstanceId(processInstanceId); - List historicTasks = historicTaskService.findHistoricTaskInstancesByQueryCriteria(taskQuery); - if (historicTasks != null) { - for (HistoricTaskInstance historicTaskInstance : historicTasks) { - HistoricTaskInstanceEntity taskEntity = (HistoricTaskInstanceEntity) historicTaskInstance; - taskEntity.setProcessDefinitionId(processDefinitionId); - historicTaskService.updateHistoricTask(taskEntity, true); - } - } - - HistoricActivityInstanceEntityManager historicActivityInstanceEntityManager = processEngineConfiguration.getHistoricActivityInstanceEntityManager(); - HistoricActivityInstanceQueryImpl activityQuery = new HistoricActivityInstanceQueryImpl(); - activityQuery.processInstanceId(processInstanceId); - List historicActivities = historicActivityInstanceEntityManager.findHistoricActivityInstancesByQueryCriteria(activityQuery); - if (historicActivities != null) { - for (HistoricActivityInstance historicActivityInstance : historicActivities) { - HistoricActivityInstanceEntity activityEntity = (HistoricActivityInstanceEntity) historicActivityInstance; - activityEntity.setProcessDefinitionId(processDefinitionId); - historicActivityInstanceEntityManager.update(activityEntity); - } - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableCreatedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableCreatedHistoryJsonTransformer.java deleted file mode 100644 index 761238a4424..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableCreatedHistoryJsonTransformer.java +++ /dev/null @@ -1,92 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDoubleFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getIntegerFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getLongFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Base64; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.variable.api.types.VariableType; -import org.flowable.variable.api.types.VariableTypes; -import org.flowable.variable.service.HistoricVariableService; -import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class VariableCreatedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public VariableCreatedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_VARIABLE_CREATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return true; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricVariableService historicVariableService = processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService(); - HistoricVariableInstanceEntity historicVariableInstanceEntity = historicVariableService.createHistoricVariableInstance(); - historicVariableInstanceEntity.setId(getStringFromJson(historicalData, HistoryJsonConstants.ID)); - historicVariableInstanceEntity.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); - historicVariableInstanceEntity.setExecutionId(getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID)); - historicVariableInstanceEntity.setTaskId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_ID)); - historicVariableInstanceEntity.setRevision(getIntegerFromJson(historicalData, HistoryJsonConstants.REVISION)); - historicVariableInstanceEntity.setName(getStringFromJson(historicalData, HistoryJsonConstants.NAME)); - historicVariableInstanceEntity.setScopeId(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_ID)); - historicVariableInstanceEntity.setSubScopeId(getStringFromJson(historicalData, HistoryJsonConstants.SUB_SCOPE_ID)); - historicVariableInstanceEntity.setScopeType(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_TYPE)); - - VariableTypes variableTypes = processEngineConfiguration.getVariableTypes(); - VariableType variableType = variableTypes.getVariableType(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_TYPE)); - - historicVariableInstanceEntity.setVariableType(variableType); - - historicVariableInstanceEntity.setTextValue(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_TEXT_VALUE)); - historicVariableInstanceEntity.setTextValue2(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_TEXT_VALUE2)); - historicVariableInstanceEntity.setDoubleValue(getDoubleFromJson(historicalData, HistoryJsonConstants.VARIABLE_DOUBLE_VALUE)); - historicVariableInstanceEntity.setLongValue(getLongFromJson(historicalData, HistoryJsonConstants.VARIABLE_LONG_VALUE)); - - String variableBytes = getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_BYTES_VALUE); - if (StringUtils.isNotEmpty(variableBytes)) { - historicVariableInstanceEntity.setBytes(Base64.getDecoder().decode(variableBytes)); - } - - historicVariableInstanceEntity.setMetaInfo(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_META_INFO)); - - Date time = getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME); - historicVariableInstanceEntity.setCreateTime(time); - historicVariableInstanceEntity.setLastUpdatedTime(time); - - historicVariableService.insertHistoricVariableInstance(historicVariableInstanceEntity); - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableRemovedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableRemovedHistoryJsonTransformer.java deleted file mode 100644 index 7586fd8dfd5..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableRemovedHistoryJsonTransformer.java +++ /dev/null @@ -1,56 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Collections; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.variable.service.HistoricVariableService; -import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class VariableRemovedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public VariableRemovedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_VARIABLE_REMOVED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService() - .getHistoricVariableInstance(getStringFromJson(historicalData, HistoryJsonConstants.ID)) != null; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricVariableService historicVariableService = processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService(); - HistoricVariableInstanceEntity historicVariable = historicVariableService.getHistoricVariableInstance(getStringFromJson(historicalData, HistoryJsonConstants.ID)); - - if (historicVariable != null) { - historicVariableService.deleteHistoricVariableInstance(historicVariable); - } - } - -} diff --git a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableUpdatedHistoryJsonTransformer.java b/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableUpdatedHistoryJsonTransformer.java deleted file mode 100644 index c25f944daa9..00000000000 --- a/modules/flowable-engine/src/main/java/org/flowable/engine/impl/history/async/json/transformer/VariableUpdatedHistoryJsonTransformer.java +++ /dev/null @@ -1,89 +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.engine.impl.history.async.json.transformer; - -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDateFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getDoubleFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getLongFromJson; -import static org.flowable.job.service.impl.history.async.util.AsyncHistoryJsonUtil.getStringFromJson; - -import java.util.Base64; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.variable.api.types.VariableType; -import org.flowable.variable.api.types.VariableTypes; -import org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class VariableUpdatedHistoryJsonTransformer extends AbstractHistoryJsonTransformer { - - public VariableUpdatedHistoryJsonTransformer(ProcessEngineConfigurationImpl processEngineConfiguration) { - super(processEngineConfiguration); - } - - @Override - public List getTypes() { - return Collections.singletonList(HistoryJsonConstants.TYPE_VARIABLE_UPDATED); - } - - @Override - public boolean isApplicable(ObjectNode historicalData, CommandContext commandContext) { - return processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService() - .getHistoricVariableInstance(getStringFromJson(historicalData, HistoryJsonConstants.ID)) != null; - } - - @Override - public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { - HistoricVariableInstanceEntity historicVariable = processEngineConfiguration.getVariableServiceConfiguration().getHistoricVariableService() - .getHistoricVariableInstance(getStringFromJson(historicalData, HistoryJsonConstants.ID)); - - Date time = getDateFromJson(historicalData, HistoryJsonConstants.LAST_UPDATED_TIME); - if (historicVariable.getLastUpdatedTime().after(time)) { - // If the historic variable already has a later time, we don't need to change its details - // to something that is already superseded by later data. - return; - } - - VariableTypes variableTypes = processEngineConfiguration.getVariableTypes(); - VariableType variableType = variableTypes.getVariableType(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_TYPE)); - - historicVariable.setVariableType(variableType); - - historicVariable.setTextValue(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_TEXT_VALUE)); - historicVariable.setTextValue2(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_TEXT_VALUE2)); - historicVariable.setDoubleValue(getDoubleFromJson(historicalData, HistoryJsonConstants.VARIABLE_DOUBLE_VALUE)); - historicVariable.setLongValue(getLongFromJson(historicalData, HistoryJsonConstants.VARIABLE_LONG_VALUE)); - - String variableBytes = getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_BYTES_VALUE); - if (StringUtils.isNotEmpty(variableBytes)) { - historicVariable.setBytes(Base64.getDecoder().decode(variableBytes)); - } else { - // It is possible that the value of the bytes changed from non null to null. - // We need to still set them so that the byte array ref can be deleted - historicVariable.setBytes(null); - } - - historicVariable.setMetaInfo(getStringFromJson(historicalData, HistoryJsonConstants.VARIABLE_META_INFO)); - - historicVariable.setLastUpdatedTime(time); - } - -} diff --git a/modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/AsyncHistoryTest.java b/modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/AsyncHistoryTest.java deleted file mode 100644 index 0a6db230661..00000000000 --- a/modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/AsyncHistoryTest.java +++ /dev/null @@ -1,1172 +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.standalone.history.async; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.text.SimpleDateFormat; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType; -import org.flowable.common.engine.api.delegate.event.FlowableEvent; -import org.flowable.common.engine.api.delegate.event.FlowableEventListener; -import org.flowable.common.engine.impl.interceptor.Command; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.common.engine.impl.util.CollectionUtil; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.util.CommandContextUtil; -import org.flowable.engine.runtime.Execution; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.engine.test.Deployment; -import org.flowable.engine.test.impl.CustomConfigurationFlowableTestCase; -import org.flowable.identitylink.api.IdentityLinkType; -import org.flowable.job.api.HistoryJob; -import org.flowable.job.api.Job; -import org.flowable.job.service.JobServiceConfiguration; -import org.flowable.job.service.impl.asyncexecutor.AbstractAsyncExecutor; -import org.flowable.job.service.impl.asyncexecutor.ResetExpiredJobsRunnable; -import org.flowable.job.service.impl.history.async.AsyncHistoryDateUtil; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.task.api.history.HistoricTaskLogEntry; -import org.flowable.task.api.history.HistoricTaskLogEntryBuilder; -import org.flowable.task.api.history.HistoricTaskLogEntryType; -import org.flowable.variable.service.VariableServiceConfiguration; -import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity; -import org.junit.Assert; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class AsyncHistoryTest extends CustomConfigurationFlowableTestCase { - - private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - - public AsyncHistoryTest() { - super("asyncHistoryTest"); - } - - @Override - protected void configureConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration) { - // Enable it, but don't start the executor automatically, it will be started in the tests themselves. - processEngineConfiguration.setAsyncHistoryEnabled(true); - processEngineConfiguration.setAsyncHistoryJsonGroupingEnabled(true); - processEngineConfiguration.setAsyncHistoryJsonGroupingThreshold(1); - processEngineConfiguration.setAsyncFailedJobWaitTime(100); - processEngineConfiguration.setDefaultFailedJobWaitTime(100); - processEngineConfiguration.setAsyncHistoryExecutorNumberOfRetries(100); - processEngineConfiguration.setAsyncHistoryExecutorDefaultAsyncJobAcquireWaitTime(100); - processEngineConfiguration.setAsyncExecutorActivate(false); - processEngineConfiguration.setAsyncHistoryExecutorActivate(false); - } - - @AfterEach - protected void tearDown() throws Exception { - // The tests are doing deployments, which trigger async history. Therefore, we need to invoke them manually and then wait for the jobs to finish - // so there can be clean data in the DB - for (String autoDeletedDeploymentId : deploymentIdsForAutoCleanup) { - deleteDeployment(autoDeletedDeploymentId); - } - deploymentIdsForAutoCleanup.clear(); - - for (Job job : managementService.createJobQuery().list()) { - if (job.getJobHandlerType().equals(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY) - || job.getJobHandlerType().equals(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED)) { - managementService.deleteJob(job.getId()); - } - } - } - - @Test - public void testOneTaskProcess() { - deployOneTaskTestProcess(); - for (int i = 0; i < 10; i++) { // Run this multiple times, as order of jobs processing can be different each run - String processInstanceId = runtimeService.createProcessInstanceBuilder() - .processDefinitionKey("oneTaskProcess") - .name("testName") - .businessKey("testBusinessKey") - .callbackId("testCallbackId") - .callbackType("testCallbackType") - .referenceId("testReferenceId") - .referenceType("testReferenceType") - .start() - .getId(); - taskService.complete(taskService.createTaskQuery().singleResult().getId()); - - List jobs = managementService.createHistoryJobQuery().list(); - for (HistoryJob job : jobs) { - assertThat(managementService.getHistoryJobHistoryJson(job.getId())).isNotEmpty(); - } - - int expectedNrOfJobs = 11; - if (processEngineConfiguration.isAsyncHistoryJsonGroupingEnabled() && - expectedNrOfJobs > processEngineConfiguration.getAsyncHistoryJsonGroupingThreshold()) { - expectedNrOfJobs = 2; // 1 job for start, 1 for complete - } - - assertThat(jobs).hasSize(expectedNrOfJobs); - for (HistoryJob job : jobs) { - if (processEngineConfiguration.isAsyncHistoryJsonGzipCompressionEnabled()) { - assertThat(job.getJobHandlerType()).isEqualTo(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED); - } else { - assertThat(job.getJobHandlerType()).isEqualTo(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY); - } - assertThat(((HistoryJobEntity) job).getAdvancedJobHandlerConfigurationByteArrayRef()).isNotNull(); - } - - assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstanceId).count()).isZero(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 200L); - - assertThat(historyService.createHistoricTaskLogEntryQuery().processInstanceId(processInstanceId).count()).isEqualTo(2); - - HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId) - .singleResult(); - assertThat(historicProcessInstance).isNotNull(); - assertThat(historicProcessInstance.getEndTime()).isNotNull(); - - assertThat(historicProcessInstance.getBusinessKey()).isEqualTo("testBusinessKey"); - assertThat(historicProcessInstance.getReferenceId()).isEqualTo("testReferenceId"); - assertThat(historicProcessInstance.getReferenceType()).isEqualTo("testReferenceType"); - assertThat(historicProcessInstance.getCallbackId()).isEqualTo("testCallbackId"); - assertThat(historicProcessInstance.getCallbackType()).isEqualTo("testCallbackType"); - - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).singleResult(); - assertThat(historicTaskInstance.getName()).isNotNull(); - assertThat(historicTaskInstance.getExecutionId()).isNotNull(); - assertThat(historicTaskInstance.getProcessInstanceId()).isNotNull(); - assertThat(historicTaskInstance.getProcessDefinitionId()).isNotNull(); - assertThat(historicTaskInstance.getTaskDefinitionKey()).isNotNull(); - assertThat(historicTaskInstance.getCreateTime()).isNotNull(); - assertThat(historicTaskInstance.getEndTime()).isNotNull(); - assertThat(historicTaskInstance.getDurationInMillis()).isNotNull(); - - List historicActivityInstances = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId) - .list(); - assertThat(historicActivityInstances).hasSize(5); - for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) { - assertThat(historicActivityInstance.getActivityId()).isNotNull(); - assertThat(historicActivityInstance.getActivityType()).isNotNull(); - if (!"sequenceFlow".equals(historicActivityInstance.getActivityType())) { - assertThat(historicActivityInstance.getActivityName()).isNotNull(); - } - assertThat(historicActivityInstance.getProcessDefinitionId()).isNotNull(); - assertThat(historicActivityInstance.getProcessInstanceId()).isNotNull(); - assertThat(historicActivityInstance.getExecutionId()).isNotNull(); - assertThat(historicActivityInstance.getDurationInMillis()).isNotNull(); - assertThat(historicActivityInstance.getStartTime()).isNotNull(); - assertThat(historicActivityInstance.getEndTime()).isNotNull(); - assertThat(historicActivityInstance.getTransactionOrder()).isNotNull(); - } - - for (String activityId : Arrays.asList("start", "theTask", "theEnd")) { - assertThat(historyService.createHistoricActivityInstanceQuery() - .activityId(activityId).processInstanceId(processInstanceId).list()).isNotNull(); - } - } - } - - @Test - public void testExecuteThroughManagementService() { - deployOneTaskTestProcess(); - - String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId(); - - List jobs = managementService.createHistoryJobQuery().list(); - assertThat(jobs).hasSize(1); - assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).count()).isZero(); - - managementService.executeHistoryJob(jobs.get(0).getId()); - - jobs = managementService.createHistoryJobQuery().list(); - assertThat(jobs).isEmpty(); - assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).count()).isEqualTo(1); - } - - @Test - @Deployment - public void testSimpleStraightThroughProcess() { - String processInstanceId = runtimeService.startProcessInstanceByKey("testSimpleStraightThroughProcess", - CollectionUtil.singletonMap("counter", 0)).getId(); - - final List jobs = managementService.createHistoryJobQuery().list(); - assertThat(jobs.size()).isPositive(); - - waitForHistoryJobExecutorToProcessAllJobs(70000L, 200L); - assertThat(managementService.createHistoryJobQuery().singleResult()).isNull(); - - // 203 -> (start, 1) + -->(1) + (service task, 50) + -->(50) + (gateway, 50), + <--(49) + -->(1) + (end, 1) - assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).count()).isEqualTo(203); - } - - @Test - @Deployment(resources = { "org/flowable/standalone/history/async/testSTPWithInstanceLevel.bpmn" }) - public void testSTPWithInstanceLevel() { - String processInstanceId = runtimeService.startProcessInstanceByKey("test", CollectionUtil.singletonMap("counter", 0)).getId(); - - final List jobs = managementService.createHistoryJobQuery().list(); - assertThat(jobs.size()).isPositive(); - - waitForHistoryJobExecutorToProcessAllJobs(10000L, 200L); - assertThat(managementService.createHistoryJobQuery().singleResult()).isNull(); - - assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult()).isNotNull(); - assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).count()).isZero(); - assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).count()).isZero(); - } - - @Test - @Deployment(resources = { "org/flowable/standalone/history/async/testProcessWithTaskLevel.bpmn" }) - public void testProcessWithTaskLevel() { - String processInstanceId = runtimeService.startProcessInstanceByKey("test", CollectionUtil.singletonMap("counter", 0)).getId(); - - List jobs = managementService.createHistoryJobQuery().list(); - assertThat(jobs.size()).isPositive(); - - waitForHistoryJobExecutorToProcessAllJobs(10000L, 200L); - assertThat(managementService.createHistoryJobQuery().singleResult()).isNull(); - - assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult()).isNotNull(); - assertThat(historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).count()).isEqualTo(1); - assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).count()).isZero(); - assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).count()).isZero(); - - Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); - taskService.complete(task.getId()); - - jobs = managementService.createHistoryJobQuery().list(); - assertThat(jobs.size()).isPositive(); - - waitForHistoryJobExecutorToProcessAllJobs(10000L, 200L); - assertThat(managementService.createHistoryJobQuery().singleResult()).isNull(); - - assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult()).isNotNull(); - assertThat(historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).count()).isEqualTo(1); - assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).count()).isZero(); - assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).count()).isZero(); - } - - @Test - @Deployment(resources = { "org/flowable/standalone/history/async/testSTPWithCustomHistoryLevel.bpmn" }) - public void testSTPWithCustomHistoryLevel() { - String processInstanceId = runtimeService.startProcessInstanceByKey("test", CollectionUtil.singletonMap("counter", 0)).getId(); - - final List jobs = managementService.createHistoryJobQuery().list(); - assertThat(jobs.size()).isPositive(); - - waitForHistoryJobExecutorToProcessAllJobs(70000L, 200L); - assertThat(managementService.createHistoryJobQuery().singleResult()).isNull(); - - assertThat(historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult()).isNotNull(); - assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).count()).isEqualTo(10); - assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).count()).isZero(); - } - - @Test - public void testCreateTaskHistory() { - Task task = taskService.createTaskBuilder().id("task1").create(); - assertThat(historyService.createHistoricTaskInstanceQuery().taskId("task1").singleResult()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(70000L, 200L); - - assertThat(historyService.createHistoricTaskInstanceQuery().taskId("task1").singleResult()).isNotNull(); - assertThat(task.getId()).isEqualTo("task1"); - - taskService.deleteTask(task.getId(), true); - } - - @Test - public void testDeleteHistoricTask() { - Task task = taskService.createTaskBuilder().id("task1").create(); - taskService.complete(task.getId()); - - waitForHistoryJobExecutorToProcessAllJobs(70000L, 200L); - - assertThat(historyService.createHistoricTaskInstanceQuery().taskId("task1").singleResult()).isNotNull(); - historyService.deleteHistoricTaskInstance("task1"); - - waitForHistoryJobExecutorToProcessAllJobs(70000L, 200L); - - assertThat(historyService.createHistoricTaskInstanceQuery().taskId("task1").singleResult()).isNull(); - } - - @Test - public void testTaskAssigneeChange() { - Task task = startOneTaskprocess(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery() - .activityId("theTask").singleResult(); - assertThat(historicActivityInstance.getAssignee()).isEqualTo("kermit"); - - task = taskService.createTaskQuery().singleResult(); - taskService.setAssignee(task.getId(), "johnDoe"); - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("theTask").singleResult(); - assertThat(historicActivityInstance.getAssignee()).isEqualTo("johnDoe"); - - finishOneTaskProcess(task); - } - - @Test - public void testTaskAssigneeChangeToNull() { - Task task = startOneTaskprocess(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery() - .activityId("theTask").singleResult(); - assertThat(historicActivityInstance.getAssignee()).isEqualTo("kermit"); - - task = taskService.createTaskQuery().singleResult(); - taskService.setAssignee(task.getId(), null); - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("theTask").singleResult(); - assertThat(historicActivityInstance.getAssignee()).isNull(); - - finishOneTaskProcess(task); - } - - @Test - public void testClaimTask() { - Task task = startOneTaskprocess(); - taskService.setAssignee(task.getId(), null); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getClaimTime()).isNull(); - - taskService.claim(historicTaskInstance.getId(), "johnDoe"); - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getClaimTime()).isNotNull(); - assertThat(historicTaskInstance.getAssignee()).isNotNull(); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskOwner() { - Task task = startOneTaskprocess(); - assertThat(task.getOwner()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getOwner()).isNull(); - - taskService.setOwner(task.getId(), "johnDoe"); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getOwner()).isEqualTo("johnDoe"); - - taskService.setOwner(task.getId(), null); - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getOwner()).isNull(); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskName() { - Task task = startOneTaskprocess(); - assertThat(task.getName()).isEqualTo("The Task"); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getName()).isEqualTo("The Task"); - - task.setName("new name"); - taskService.saveTask(task); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getName()).isEqualTo("new name"); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskDescription() { - Task task = startOneTaskprocess(); - assertThat(task.getDescription()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getDescription()).isNull(); - - task.setDescription("test description"); - taskService.saveTask(task); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getDescription()).isNotNull(); - - task = taskService.createTaskQuery().taskId(task.getId()).singleResult(); - task.setDescription(null); - taskService.saveTask(task); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getDescription()).isNull(); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskDueDate() { - Task task = startOneTaskprocess(); - assertThat(task.getDueDate()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getDueDate()).isNull(); - - taskService.setDueDate(task.getId(), new Date()); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getDueDate()).isNotNull(); - - taskService.setDueDate(task.getId(), null); - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getDueDate()).isNull(); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskPriority() { - Task task = startOneTaskprocess(); - assertThat(task.getPriority()).isEqualTo(Task.DEFAULT_PRIORITY); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getPriority()).isEqualTo(Task.DEFAULT_PRIORITY); - - taskService.setPriority(task.getId(), 1); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getPriority()).isEqualTo(1); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskCategory() { - Task task = startOneTaskprocess(); - assertThat(task.getCategory()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getCategory()).isNull(); - - task.setCategory("test category"); - taskService.saveTask(task); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getCategory()).isEqualTo("test category"); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskFormKey() { - Task task = startOneTaskprocess(); - assertThat(task.getFormKey()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getFormKey()).isNull(); - task.setFormKey("test form key"); - taskService.saveTask(task); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getFormKey()).isEqualTo("test form key"); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskStartTime() { - Task task = startOneTaskprocess(); - - finishOneTaskProcess(task); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getStartTime()).isNotNull(); - assertThat(historicTaskInstance.getEndTime()).isNotNull(); - assertThat(historicTaskInstance.getStartTime()).isEqualTo(task.getCreateTime()); - } - - @Test - public void testSetTaskParentId() { - Task parentTask1 = taskService.newTask(); - parentTask1.setName("Parent task 1"); - taskService.saveTask(parentTask1); - - Task parentTask2 = taskService.newTask(); - parentTask2.setName("Parent task 2"); - taskService.saveTask(parentTask2); - - Task childTask = taskService.newTask(); - childTask.setName("child task"); - childTask.setParentTaskId(parentTask1.getId()); - taskService.saveTask(childTask); - assertThat(taskService.getSubTasks(parentTask1.getId())).hasSize(1); - assertThat(taskService.getSubTasks(parentTask2.getId())).isEmpty(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(childTask.getId()).singleResult(); - assertThat(historicTaskInstance.getParentTaskId()).isEqualTo(parentTask1.getId()); - - childTask = taskService.createTaskQuery().taskId(childTask.getId()).singleResult(); - childTask.setParentTaskId(parentTask2.getId()); - taskService.saveTask(childTask); - assertThat(taskService.getSubTasks(parentTask1.getId())).isEmpty(); - assertThat(taskService.getSubTasks(parentTask2.getId())).hasSize(1); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(childTask.getId()).singleResult(); - assertThat(historicTaskInstance.getParentTaskId()).isEqualTo(parentTask2.getId()); - - taskService.deleteTask(parentTask1.getId(), true); - taskService.deleteTask(parentTask2.getId(), true); - } - - @Test - public void testResetExpiredJobs() { - - // Need to do this to initialize everything properly - processEngineConfiguration.getAsyncHistoryExecutor().start(); - Runnable runnable = ((AbstractAsyncExecutor) processEngineConfiguration.getAsyncHistoryExecutor()).getResetExpiredJobsRunnable(); - assertThat(runnable).isNotNull(); - processEngineConfiguration.getAsyncHistoryExecutor().shutdown(); - - startOneTaskprocess(); - assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(1); - - // Force job to be expired - managementService.executeCommand(new Command() { - - @Override - public Void execute(CommandContext commandContext) { - HistoryJob historyJob = managementService.createHistoryJobQuery().singleResult(); - ((HistoryJobEntity) historyJob).setLockOwner("test"); - ((HistoryJobEntity) historyJob).setLockExpirationTime(new Date(Instant.now().minus(100, ChronoUnit.DAYS).toEpochMilli())); - return null; - } - }); - - assertThat(((HistoryJobEntity) managementService.createHistoryJobQuery().singleResult()).getLockExpirationTime()).isNotNull(); - - // Manually trigger the reset - ResetExpiredJobsRunnable resetExpiredJobsRunnable = ((ResetExpiredJobsRunnable) runnable); - resetExpiredJobsRunnable.setInterrupted(false); // the shutdown() above will have interrupted the runnable, hence why it needs to be reset - resetExpiredJobsRunnable.resetJobs(); - - // The lock expiration time should be null now - assertThat(((HistoryJobEntity) managementService.createHistoryJobQuery().singleResult()).getLockExpirationTime()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - } - - @Test - @Deployment( - resources = { - "org/flowable/engine/test/api/runtime/callActivity.bpmn20.xml", - "org/flowable/engine/test/api/runtime/calledActivity.bpmn20.xml" - } - ) - public void callSubProcess() { - ProcessInstance pi = this.runtimeService.startProcessInstanceByKey("callActivity"); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricActivityInstance callSubProcessActivityInstance = historyService.createHistoricActivityInstanceQuery().processInstanceId(pi.getId()) - .activityId("callSubProcess").singleResult(); - assertThat(callSubProcessActivityInstance) - .extracting(HistoricActivityInstance::getCalledProcessInstanceId) - .isEqualTo(runtimeService.createProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult().getId()); - } - - @Test - public void createUserTaskLogEntity() { - HistoricTaskLogEntryBuilder historicTaskLogEntryBuilder = historyService.createHistoricTaskLogEntryBuilder(); - - Date todayDate = new Date(); - historicTaskLogEntryBuilder.taskId("1"); - historicTaskLogEntryBuilder.type("testType"); - historicTaskLogEntryBuilder.userId("testUserId"); - historicTaskLogEntryBuilder.data("testData"); - historicTaskLogEntryBuilder.processInstanceId("processInstanceId"); - historicTaskLogEntryBuilder.processDefinitionId("testDefinitionId"); - historicTaskLogEntryBuilder.executionId("testExecutionId"); - historicTaskLogEntryBuilder.timeStamp(todayDate); - historicTaskLogEntryBuilder.tenantId("testTenant"); - - historicTaskLogEntryBuilder.create(); - - HistoricTaskLogEntry historicTaskLogEntry = null; - try { - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId("1").count()).isZero(); - waitForHistoryJobExecutorToProcessAllJobs(7000, 200); - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId("1").count()).isEqualTo(1); - - historicTaskLogEntry = historyService.createHistoricTaskLogEntryQuery().taskId("1").singleResult(); - assertThat(historicTaskLogEntry.getLogNumber()).isPositive(); - assertThat(historicTaskLogEntry.getTaskId()).isEqualTo("1"); - assertThat(historicTaskLogEntry.getType()).isEqualTo("testType"); - assertThat(historicTaskLogEntry.getUserId()).isEqualTo("testUserId"); - assertThat(historicTaskLogEntry.getProcessInstanceId()).isEqualTo("processInstanceId"); - assertThat(historicTaskLogEntry.getProcessDefinitionId()).isEqualTo("testDefinitionId"); - assertThat(historicTaskLogEntry.getExecutionId()).isEqualTo("testExecutionId"); - assertThat(historicTaskLogEntry.getData()).isEqualTo("testData"); - assertThat(historicTaskLogEntry.getLogNumber()).isPositive(); - assertThat(simpleDateFormat.format(historicTaskLogEntry.getTimeStamp())).isEqualTo(simpleDateFormat.format(todayDate)); - assertThat(historicTaskLogEntry.getTenantId()).isEqualTo("testTenant"); - - } finally { - if (historicTaskLogEntry != null) { - historyService.deleteHistoricTaskLogEntry(historicTaskLogEntry.getLogNumber()); - waitForHistoryJobExecutorToProcessAllJobs(7000, 200); - } - } - - } - - @Test - public void testAsynchUsertTaskLogEntries() { - deployOneTaskTestProcess(); - ProcessInstance oneTaskProcess = runtimeService.startProcessInstanceByKey("oneTaskProcess"); - - Task task = taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult(); - task.setName("newName"); - task.setPriority(0); - taskService.saveTask(task); - taskService.setAssignee(task.getId(), "newAssignee"); - taskService.setOwner(task.getId(), "newOwner"); - taskService.setDueDate(task.getId(), new Date()); - taskService.addUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT); - taskService.addGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT); - taskService.deleteUserIdentityLink(task.getId(), "testUser", IdentityLinkType.PARTICIPANT); - taskService.deleteGroupIdentityLink(task.getId(), "testGroup", IdentityLinkType.PARTICIPANT); - runtimeService.suspendProcessInstanceById(oneTaskProcess.getId()); - runtimeService.activateProcessInstanceById(oneTaskProcess.getId()); - taskService.complete(task.getId()); - - assertThat(historyService.createHistoricTaskLogEntryQuery().count()).isZero(); - assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(12); - - waitForHistoryJobExecutorToProcessAllJobs(7000, 200); - - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).count()).isEqualTo(13); - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_CREATED.name()).count()) - .isEqualTo(1); - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_NAME_CHANGED.name()).count()) - .isEqualTo(1); - assertThat( - historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_PRIORITY_CHANGED.name()).count()) - .isEqualTo(1); - assertThat( - historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_ASSIGNEE_CHANGED.name()).count()) - .isEqualTo(1); - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_OWNER_CHANGED.name()).count()) - .isEqualTo(1); - assertThat( - historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_DUEDATE_CHANGED.name()).count()) - .isEqualTo(1); - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_SUSPENSIONSTATE_CHANGED.name()) - .count()).isEqualTo(2); - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_ADDED.name()) - .count()).isEqualTo(2); - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_IDENTITY_LINK_REMOVED.name()) - .count()).isEqualTo(2); - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).type(HistoricTaskLogEntryType.USER_TASK_COMPLETED.name()).count()) - .isEqualTo(1); - } - - @Test - public void testDeleteAsynchUserTaskLogEntries() { - deployOneTaskTestProcess(); - ProcessInstance oneTaskProcess = runtimeService.startProcessInstanceByKey("oneTaskProcess"); - - Task task = taskService.createTaskQuery().processInstanceId(oneTaskProcess.getId()).singleResult(); - assertThat(historyService.createHistoricTaskLogEntryQuery().count()).isZero(); - assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(1); - waitForHistoryJobExecutorToProcessAllJobs(7000, 200); - List historicTaskLogEntries = historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).list(); - assertThat(historicTaskLogEntries).hasSize(1); - - historyService.deleteHistoricTaskLogEntry(historicTaskLogEntries.get(0).getLogNumber()); - - assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(1); - waitForHistoryJobExecutorToProcessAllJobs(7000, 200); - assertThat(historyService.createHistoricTaskLogEntryQuery().taskId(task.getId()).count()).isZero(); - } - - @Test - @Deployment - public void testInclusiveGatewayEndTimeSet() { - ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testInclusiveGateway"); - List tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).orderByTaskName().asc().list(); - assertThat(tasks).extracting(Task::getName).containsExactly("Always", "Always"); - - for (Task task : tasks) { - taskService.complete(task.getId()); - } - - waitForHistoryJobExecutorToProcessAllJobs(10000, 200); - - HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()) - .singleResult(); - assertThat(historicProcessInstance.getEndTime()).isNotNull(); - - } - - @Test - @Deployment(resources = "org/flowable/engine/test/bpmn/event/signal/SignalEventTest.testSignalWaitOnUserTaskBoundaryEvent.bpmn20.xml") - public void testSignalWaitOnUserTaskBoundaryEvent() { - ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signal-wait"); - waitForHistoryJobExecutorToProcessAllJobs(10000, 200); - - Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).signalEventSubscriptionName("waitsig") - .singleResult(); - assertThat(execution).isNotNull(); - runtimeService.signalEventReceived("waitsig", execution.getId()); - execution = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).signalEventSubscriptionName("waitsig").singleResult(); - assertThat(execution).isNull(); - org.flowable.task.api.Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); - assertThat(task).isNotNull(); - assertThat(task.getName()).isEqualTo("Wait2"); - } - - // Test for a bug when using non-interrupting boundary event (any type) with async history - @Test - @Deployment(extraResources = "org/flowable/engine/test/api/oneTaskProcess.bpmn20.xml") - public void testNonInterruptingTimerBoundaryEventOnCallActivityWithOldData() { - - // In earlier versions of Flowable, there used to be a bug that would not generate a historic activity instance when it was expected to, - // when using a non-interrupting boundary event on a call activity. - // More precisely: the activity-end for the boundary event was triggered twice (but only one activity-start), - // which led to failure when using asynchronous history (as no start for the end exists). - // This unit test mimics this setup and validates that the problem is solved now. - // - // Side-note: non-interrupting boundary events such as signals/messages are repeating by default. - // For timer boundary events, the timer should be made repeating (the child execution is still created if it isn't) - - ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess"); - - // Mimic timer firing - Job timerJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult(); - assertThat(timerJob).isNotNull(); - Job executableJob = managementService.moveTimerToExecutableJob(timerJob.getId()); - managementService.executeJob(executableJob.getId()); - - waitForHistoryJobExecutorToProcessAllJobs(10000, 200); - - List timerBoundaryEvents = historyService.createHistoricActivityInstanceQuery().activityId("timerBoundaryEvent").list(); - assertThat(timerBoundaryEvents).hasSize(2); - - // Mimic the bug by removing the latest activity instance (runtime and historical) - this was not created before - HistoricActivityInstance historicActivityInstanceToDelete = timerBoundaryEvents.stream() - .filter(historicActivityInstance -> historicActivityInstance.getEndTime() == null).findFirst().get(); - managementService.executeCommand(commandContext -> { - CommandContextUtil.getProcessEngineConfiguration(commandContext).getActivityInstanceEntityManager().delete(historicActivityInstanceToDelete.getId()); - CommandContextUtil.getProcessEngineConfiguration(commandContext).getHistoricActivityInstanceEntityManager().delete(historicActivityInstanceToDelete.getId()); - return null; - }); - - taskService.complete(taskService.createTaskQuery().singleResult().getId()); - - // Additionally, an extra activity-end was generated - // (not anymore, due to recent changes in ActivityInstanceEntityManagerImpl#recordActivityInstanceEnd - hence why it needs to be inserted manually here) - ObjectNode historyJson = processEngineConfiguration.getObjectMapper().createObjectNode(); - historyJson.put("type", "activity-end"); - ObjectNode dataNode = historyJson.putObject("data"); - - // Note the lack of runtimeActivityInstanceId. This is because at that time, - // there would be no runtime activity and it would fallback to the execution based logic (that's there for backwards compatibility) - dataNode.put("processDefinitionId", historicActivityInstanceToDelete.getProcessDefinitionId()); - dataNode.put("processInstanceId", historicActivityInstanceToDelete.getProcessInstanceId()); - dataNode.put("executionId", historicActivityInstanceToDelete.getExecutionId()); - dataNode.put("activityId", "timerBoundaryEvent"); - dataNode.put("activityType", "boundaryEvent"); - dataNode.put("transactionOrder", 1); - dataNode.put("tenantId", ""); - dataNode.put("startTime", AsyncHistoryDateUtil.formatDate(new Date())); - dataNode.put("__timeStamp", AsyncHistoryDateUtil.formatDate(new Date())); - addJsonToHistoryJobJson((HistoryJobEntity) managementService.createHistoryJobQuery().singleResult(), historyJson); - - waitForHistoryJobExecutorToProcessAllJobs(1000000, 200); - - timerBoundaryEvents = historyService.createHistoricActivityInstanceQuery().activityId("timerBoundaryEvent").list(); - assertThat(timerBoundaryEvents) - .extracting(HistoricActivityInstance::getStartTime, HistoricActivityInstance::getEndTime) - .doesNotContainNull(); - } - - @Test - public void testHistoryJobFailure() { - Task task = startOneTaskprocess(); - - // Fetch the first history job, and programmatically change the handler type, such that it will guaranteed fail. - HistoryJob historyJob = managementService.createHistoryJobQuery().singleResult(); - changeTransformerTypeToInvalidType((HistoryJobEntity) historyJob); - - assertThat(managementService.createDeadLetterJobQuery().count()).isEqualTo(0); - waitForHistoryJobExecutorToProcessAllJobs(20000L, 200L); - assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(0); - - Job deadLetterJob = managementService.createDeadLetterJobQuery().singleResult(); - assertThat(deadLetterJob.getJobType()).isEqualTo(HistoryJobEntity.HISTORY_JOB_TYPE); - assertThat(deadLetterJob.getExceptionMessage()).isNotEmpty(); - - String deadLetterJobExceptionStacktrace = managementService.getDeadLetterJobExceptionStacktrace(deadLetterJob.getId()); - assertThat(deadLetterJobExceptionStacktrace).isNotEmpty(); - - // The history jobs in the deadletter table have no link to the process instance, hence why a manual cleanup is needed. - runtimeService.deleteProcessInstance(task.getProcessInstanceId(), null); - managementService.createHistoryJobQuery().list().forEach(j -> managementService.deleteHistoryJob(j.getId())); - managementService.createDeadLetterJobQuery().list().forEach(j -> managementService.deleteDeadLetterJob(j.getId())); - } - - @Test - public void testBulkMoveDeadLetterJobsToHistory() { - Task task1 = startOneTaskprocess(); - Task task2 = startOneTaskprocess(); - - List historicJobList = managementService.createHistoryJobQuery().list(); - - for (HistoryJob historyJob : historicJobList) { - changeTransformerTypeToInvalidType((HistoryJobEntity) historyJob); - } - waitForHistoryJobExecutorToProcessAllJobs(20000L, 200L); - - assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(0); - - List deadLetterJobs = managementService.createDeadLetterJobQuery().list(); - - List jobIds = new ArrayList<>(); - deadLetterJobs.forEach(job -> jobIds.add(job.getId())); - - managementService.bulkMoveDeadLetterJobsToHistoryJobs(jobIds, 3); - - assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(2); - - historicJobList = managementService.createHistoryJobQuery().list(); - - for (HistoryJob historyJob : historicJobList) { - assertThat(historyJob.getCreateTime()).isNotNull(); - assertThat(historyJob.getRetries()).isEqualTo(3); - assertThat(historyJob.getExceptionMessage()).isNotNull(); // this is consistent with regular jobs - assertThat(historyJob.getJobHandlerConfiguration()).isNull(); // needs to have been reset - } - // The history jobs in the deadletter table have no link to the process instance, hence why a manual cleanup is needed. - runtimeService.deleteProcessInstance(task1.getProcessInstanceId(), null); - runtimeService.deleteProcessInstance(task2.getProcessInstanceId(), null); - - managementService.createHistoryJobQuery().list().forEach(j -> managementService.deleteHistoryJob(j.getId())); - managementService.createDeadLetterJobQuery().list().forEach(j -> managementService.deleteDeadLetterJob(j.getId())); - - } - - @Test - public void testHistoryJobMissingActivityStart() { - Task task = startOneTaskprocess(); - - // Removing the 'activity start' will fail both the processing of the starting of the process instance and the setting of the assignee - HistoryJob historyJob = managementService.createHistoryJobQuery().singleResult(); - removeActivityStart((HistoryJobEntity) historyJob, "theTask"); - - taskService.complete(task.getId()); - - assertThat(managementService.createDeadLetterJobQuery().count()).isEqualTo(0); - assertThat(historyService.createHistoricProcessInstanceQuery().list()).isEmpty(); - assertThat(historyService.createHistoricTaskInstanceQuery().list()).isEmpty(); - assertThat(historyService.createHistoricActivityInstanceQuery().activityId("theTask").list()).isEmpty(); - waitForHistoryJobExecutorToProcessAllJobs(20000L, 50L); - assertThat(managementService.createDeadLetterJobQuery().count()).isEqualTo(2); - assertThat(historyService.createHistoricTaskInstanceQuery().list()).hasSize(1); - assertThat(historyService.createHistoricActivityInstanceQuery().activityId("theTask").list()).isEmpty(); - - // Even though there are dead letter jobs, only the delta of the jobs needs to be there - // the parts that didn't fail should still create the historic process instance - - HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() - .singleResult(); - - assertThat(historicProcessInstance).isNotNull(); - assertThat(historicProcessInstance.getEndTime()).isNotNull(); - - List exceptionMessages = managementService.createDeadLetterJobQuery().list().stream().map(job -> job.getExceptionMessage()).collect(Collectors.toList()); - assertThat(exceptionMessages).containsOnly( - "Failed to process async history json. See suppressed exceptions.", - "Failed to process async history json. See suppressed exceptions." - ); - - List exceptionStacktraces = managementService.createDeadLetterJobQuery() - .list() - .stream() - .sorted(Comparator.comparing(Job::getCreateTime)) - .map(job -> managementService.getDeadLetterJobExceptionStacktrace(job.getId())) - .collect(Collectors.toList()); - - String stackTrace1 = exceptionStacktraces.get(0); - if (stackTrace1.contains("[activity-update]")) { - assertThat(stackTrace1).contains("Job is not applicable for transformer types: [activity-update]"); - - assertThat(exceptionStacktraces.get(1)) - .contains("Job is not applicable for transformer types: [activity-end]"); - - } else { - assertThat(stackTrace1).contains("Job is not applicable for transformer types: [activity-end]"); - - assertThat(exceptionStacktraces.get(1)) - .contains("Job is not applicable for transformer types: [activity-update]"); - } - - // The history jobs in the deadletter table have no link to the process instance, hence why a manual cleanup is needed. - managementService.createDeadLetterJobQuery().list().forEach(j -> managementService.deleteDeadLetterJob(j.getId())); - } - - @Test - public void testMoveDeadLetterJobBackToHistoryJob() { - TestDeadletterEventListener testDeadletterEventListener = new TestDeadletterEventListener(); - processEngineConfiguration.getEventDispatcher().addEventListener(testDeadletterEventListener, FlowableEngineEventType.JOB_MOVED_TO_DEADLETTER); - - Task task = startOneTaskprocess(); - - HistoryJob historyJob = managementService.createHistoryJobQuery().singleResult(); - changeTransformerTypeToInvalidType((HistoryJobEntity) historyJob); - - String originalAdvancedConfiguration = getAdvancedJobHandlerConfiguration(historyJob.getId()); - assertThat(originalAdvancedConfiguration).isNotEmpty(); - assertThat(TestDeadletterEventListener.COUNTER.get()).isEqualTo(0); - - waitForHistoryJobExecutorToProcessAllJobs(20000L, 200L); - - assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(0); - Job deadLetterJob = managementService.createDeadLetterJobQuery().singleResult(); - assertThat(TestDeadletterEventListener.COUNTER.get()).isEqualTo(1); - - managementService.moveDeadLetterJobToHistoryJob(deadLetterJob.getId(), 3); - assertThat(managementService.createHistoryJobQuery().count()).isEqualTo(1); - historyJob = managementService.createHistoryJobQuery().singleResult(); - - assertThat(historyJob.getCreateTime()).isNotNull(); - assertThat(historyJob.getRetries()).isEqualTo(3); - assertThat(historyJob.getExceptionMessage()).isNotNull(); // this is consistent with regular jobs - assertThat(historyJob.getJobHandlerConfiguration()).isNull(); // needs to have been reset - - String newAdvancedConfiguration = getAdvancedJobHandlerConfiguration(historyJob.getId()); - assertThat(originalAdvancedConfiguration).isEqualTo(newAdvancedConfiguration); - - // The history jobs in the deadletter table have no link to the process instance, hence why a manual cleanup is needed. - runtimeService.deleteProcessInstance(task.getProcessInstanceId(), null); - managementService.createHistoryJobQuery().list().forEach(j -> managementService.deleteHistoryJob(j.getId())); - managementService.createDeadLetterJobQuery().list().forEach(j -> managementService.deleteDeadLetterJob(j.getId())); - - assertThat(TestDeadletterEventListener.COUNTER.get()).isEqualTo(1); - processEngineConfiguration.getEventDispatcher().removeEventListener(testDeadletterEventListener); - } - - @Test - @Deployment(resources = "org/flowable/engine/test/api/twoTasksProcess.bpmn20.xml") - public void testVariableChanges() { - Map variables = new HashMap<>(); - variables.put("var1", "test"); - ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("twoTasksProcess", variables); - - Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); - variables = new HashMap<>(); - variables.put("var1", "updated"); - taskService.complete(task.getId(), variables); - - waitForHistoryJobExecutorToProcessAllJobs(20000L, 200L); - - assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) - .variableName("var1").singleResult().getValue()).isEqualTo("updated"); - - managementService.executeCommand(commandContext -> { - List variablesInstances = CommandContextUtil.getVariableService(commandContext) - .findVariableInstancesByExecutionId(processInstance.getId()); - - VariableInstanceEntity variableInstanceEntity = variablesInstances.get(0); - variableInstanceEntity.setMetaInfo("test meta info"); - VariableServiceConfiguration variableServiceConfiguration = processEngineConfiguration.getVariableServiceConfiguration(); - variableServiceConfiguration.getVariableInstanceEntityManager().update(variableInstanceEntity); - if (variableServiceConfiguration.getInternalHistoryVariableManager() != null) { - variableServiceConfiguration.getInternalHistoryVariableManager() - .recordVariableUpdate(variableInstanceEntity, commandContext.getClock().getCurrentTime()); - } - return null; - }); - - waitForHistoryJobExecutorToProcessAllJobs(20000L, 200L); - - assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) - .variableName("var1").singleResult().getValue()).isEqualTo("updated"); - assertThat(historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) - .variableName("var1").singleResult().getMetaInfo()).isEqualTo("test meta info"); - } - - static final class TestDeadletterEventListener implements FlowableEventListener { - - public static AtomicInteger COUNTER = new AtomicInteger(0); - - @Override - public void onEvent(FlowableEvent event) { - COUNTER.incrementAndGet(); - } - @Override - public boolean isFailOnException() { - return false; - } - @Override - public boolean isFireOnTransactionLifecycleEvent() { - return false; - } - @Override - public String getOnTransaction() { - return null; - } - } - - protected void changeTransformerTypeToInvalidType(HistoryJobEntity historyJob) { - processEngineConfiguration.getCommandExecutor().execute(new Command() { - - @Override - public Void execute(CommandContext commandContext) { - try { - HistoryJobEntity historyJobEntity = historyJob; - - ObjectMapper objectMapper = processEngineConfiguration.getObjectMapper(); - JsonNode historyJsonNode = objectMapper.readTree(historyJobEntity.getAdvancedJobHandlerConfiguration()); - - for (JsonNode jsonNode : historyJsonNode) { - if (jsonNode.has("type")) { - ((ObjectNode) jsonNode).put("type", "invalidType"); - } - } - - historyJobEntity.setAdvancedJobHandlerConfiguration(objectMapper.writeValueAsString(historyJsonNode)); - } catch (JsonProcessingException e) { - Assert.fail(); - } - return null; - } - }); - } - - protected void removeActivityStart(HistoryJobEntity historyJob, String activityId) { - processEngineConfiguration.getCommandExecutor().execute(new Command() { - - @Override - public Void execute(CommandContext commandContext) { - try { - - ObjectMapper objectMapper = processEngineConfiguration.getObjectMapper(); - JsonNode historyJsonNode = objectMapper.readTree(historyJob.getAdvancedJobHandlerConfiguration()); - - Iterator iterator = historyJsonNode.iterator(); - while (iterator.hasNext()) { - JsonNode jsonNode = iterator.next(); - if (jsonNode.path("data").path("activityId").asText().equals(activityId)) { - iterator.remove(); - } - } - - historyJob.setAdvancedJobHandlerConfiguration(objectMapper.writeValueAsString(historyJsonNode)); - } catch (JsonProcessingException e) { - Assert.fail(); - } - return null; - } - }); - } - - protected void addJsonToHistoryJobJson(HistoryJobEntity historyJob, ObjectNode objectNode) { - processEngineConfiguration.getCommandExecutor().execute(new Command() { - - @Override - public Void execute(CommandContext commandContext) { - try { - - ObjectMapper objectMapper = processEngineConfiguration.getObjectMapper(); - JsonNode historyJsonNode = objectMapper.readTree(historyJob.getAdvancedJobHandlerConfiguration()); - - ((ArrayNode) historyJsonNode).add(objectNode); - - historyJob.setAdvancedJobHandlerConfiguration(objectMapper.writeValueAsString(historyJsonNode)); - } catch (JsonProcessingException e) { - Assert.fail(); - } - return null; - } - }); - } - - protected String getAdvancedJobHandlerConfiguration(String historyJobId) { - return processEngineConfiguration.getCommandExecutor().execute(new Command() { - - @Override - public String execute(CommandContext commandContext) { - JobServiceConfiguration jobServiceConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext).getJobServiceConfiguration(); - HistoryJobEntity job = jobServiceConfiguration.getHistoryJobEntityManager().findById(historyJobId); - return job.getAdvancedJobHandlerConfiguration(); - } - }); - } - - protected Task startOneTaskprocess() { - deployOneTaskTestProcess(); - String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId(); - Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); - return task; - } - - protected void finishOneTaskProcess(Task task) { - taskService.complete(task.getId()); - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - assertThat(managementService.createHistoryJobQuery().singleResult()).isNull(); - } - -} diff --git a/modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/AsyncHistoryUpgradeTest.java b/modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/AsyncHistoryUpgradeTest.java deleted file mode 100644 index 85d01737622..00000000000 --- a/modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/AsyncHistoryUpgradeTest.java +++ /dev/null @@ -1,401 +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.standalone.history.async; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.flowable.common.engine.impl.util.CollectionUtil; -import org.flowable.engine.history.HistoricActivityInstance; -import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.flowable.engine.impl.history.async.HistoryJsonConstants; -import org.flowable.engine.impl.util.CommandContextUtil; -import org.flowable.engine.test.Deployment; -import org.flowable.engine.test.impl.CustomConfigurationFlowableTestCase; -import org.flowable.job.api.HistoryJob; -import org.flowable.job.api.Job; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -/** - * Upgrade from previous version should be able to run currently inserted history jobs - */ -public class AsyncHistoryUpgradeTest extends CustomConfigurationFlowableTestCase { - - private static final Collection ADD_ACTIVITY_ID_CONFIGURATIONS = Arrays.asList( - HistoryJsonConstants.TYPE_TASK_CREATED, HistoryJsonConstants.TYPE_TASK_ENDED, HistoryJsonConstants.TYPE_TASK_PROPERTY_CHANGED - ); - - public AsyncHistoryUpgradeTest() { - super("asyncHistoryTest"); - } - - @Override - protected void configureConfiguration(ProcessEngineConfigurationImpl processEngineConfiguration) { - // Enable it, but don't start the executor automatically, it will be started in the tests themselves. - processEngineConfiguration.setAsyncHistoryEnabled(true); - processEngineConfiguration.setAsyncHistoryJsonGroupingEnabled(true); - processEngineConfiguration.setAsyncHistoryJsonGroupingThreshold(1); - processEngineConfiguration.setAsyncHistoryJsonGzipCompressionEnabled(false); - processEngineConfiguration.setAsyncFailedJobWaitTime(100); - processEngineConfiguration.setDefaultFailedJobWaitTime(100); - processEngineConfiguration.setAsyncHistoryExecutorNumberOfRetries(10); - processEngineConfiguration.setAsyncHistoryExecutorDefaultAsyncJobAcquireWaitTime(100); - processEngineConfiguration.setAsyncExecutorActivate(false); - } - - @AfterEach - protected void tearDown() throws Exception { - // The tests are doing deployments, which trigger async history. Therefore, we need to invoke them manually and then wait for the jobs to finish - // so there can be clean data in the DB - for (String autoDeletedDeploymentId : deploymentIdsForAutoCleanup) { - repositoryService.deleteDeployment(autoDeletedDeploymentId, true); - } - deploymentIdsForAutoCleanup.clear(); - - waitForHistoryJobExecutorToProcessAllJobs(10000, 100); - for (Job job : managementService.createJobQuery().list()) { - if (job.getJobHandlerType().equals(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY) - || job.getJobHandlerType().equals(HistoryJsonConstants.JOB_HANDLER_TYPE_DEFAULT_ASYNC_HISTORY_ZIPPED)) { - managementService.deleteJob(job.getId()); - } - } - } - - @Test - @Deployment(resources = "org/flowable/standalone/history/async/AsyncHistoryTest.testSimpleStraightThroughProcess.bpmn") - public void testSimpleStraightThroughProcess() { - final String processInstanceId = runtimeService - .startProcessInstanceByKey("testSimpleStraightThroughProcess", CollectionUtil.singletonMap("counter", 0)).getId(); - - final List jobs = managementService.createHistoryJobQuery().list(); - assertThat(jobs.size()).isPositive(); - - removeRuntimeActivityInstances(processInstanceId); - downgradeHistoryJobConfigurations(); - - waitForHistoryJobExecutorToProcessAllJobs(70000L, 200L); - assertThat(managementService.createHistoryJobQuery().singleResult()).isNull(); - - // 203 -> (start, 1) + -->(1) + (service task, 50) + -->(50) + (gateway, 50), + <--(49) + -->(1) + (end, 1) - assertThat(historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).count()).isEqualTo(203); - } - - @Test - public void testTaskAssigneeChange() { - Task task = startOneTaskprocess(); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery() - .activityId("theTask").singleResult(); - assertThat(historicActivityInstance.getAssignee()).isEqualTo("kermit"); - assertThat(runtimeService.createActivityInstanceQuery().activityInstanceId(historicActivityInstance.getId()).count()) - .as("RuntimeActivityInstances are not created back from historicActivityInstances when they are asynchronously inserted into data store") - .isZero(); - - task = taskService.createTaskQuery().singleResult(); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - taskService.setAssignee(task.getId(), "johnDoe"); - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("theTask").singleResult(); - assertThat(historicActivityInstance.getAssignee()).isEqualTo("johnDoe"); - assertRuntimeActivityInstanceIsSame(historicActivityInstance); - - finishOneTaskProcess(task); - } - - @Test - public void testClaimTask() { - Task task = startOneTaskprocess(); - - downgradeHistoryJobConfigurations(); - waitForHistoryJobExecutorToProcessAllJobs(20000L, 100L); - - taskService.setAssignee(task.getId(), null); - downgradeHistoryJobConfigurations(); - waitForHistoryJobExecutorToProcessAllJobs(20000L, 100L); - - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getClaimTime()).isNull(); - HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().processInstanceId(task.getProcessInstanceId()) - .activityId("theTask").singleResult(); - assertThat(historicActivityInstance).extracting(HistoricActivityInstance::getTaskId).isEqualTo(task.getId()); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - taskService.claim(historicTaskInstance.getId(), "johnDoe"); - - downgradeHistoryJobConfigurations(); - - waitForHistoryJobExecutorToProcessAllJobs(20000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getClaimTime()).isNotNull(); - assertThat(historicTaskInstance.getAssignee()).isNotNull(); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskOwner() { - Task task = startOneTaskprocess(); - assertThat(task.getOwner()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getOwner()).isNull(); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - taskService.setOwner(task.getId(), "johnDoe"); - - downgradeHistoryJobConfigurations(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getOwner()).isEqualTo("johnDoe"); - - taskService.setOwner(task.getId(), null); - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getOwner()).isNull(); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskName() { - Task task = startOneTaskprocess(); - assertThat(task.getName()).isEqualTo("The Task"); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getName()).isEqualTo("The Task"); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - task.setName("new name"); - taskService.saveTask(task); - - downgradeHistoryJobConfigurations(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getName()).isEqualTo("new name"); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskDescription() { - Task task = startOneTaskprocess(); - assertThat(task.getDescription()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getDescription()).isNull(); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - task.setDescription("test description"); - taskService.saveTask(task); - - downgradeHistoryJobConfigurations(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getDescription()).isNotNull(); - - task = taskService.createTaskQuery().taskId(task.getId()).singleResult(); - task.setDescription(null); - taskService.saveTask(task); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getDescription()).isNull(); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskDueDate() { - Task task = startOneTaskprocess(); - assertThat(task.getDueDate()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getDueDate()).isNull(); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - taskService.setDueDate(task.getId(), new Date()); - - downgradeHistoryJobConfigurations(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getDueDate()).isNotNull(); - - taskService.setDueDate(task.getId(), null); - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(historicTaskInstance.getId()).singleResult(); - assertThat(historicTaskInstance.getDueDate()).isNull(); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskPriority() { - Task task = startOneTaskprocess(); - assertThat(task.getPriority()).isEqualTo(Task.DEFAULT_PRIORITY); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getPriority()).isEqualTo(Task.DEFAULT_PRIORITY); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - taskService.setPriority(task.getId(), 1); - - downgradeHistoryJobConfigurations(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getPriority()).isEqualTo(1); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskCategory() { - Task task = startOneTaskprocess(); - assertThat(task.getCategory()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getCategory()).isNull(); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - task.setCategory("test category"); - taskService.saveTask(task); - - downgradeHistoryJobConfigurations(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getCategory()).isEqualTo("test category"); - - finishOneTaskProcess(task); - } - - @Test - public void testSetTaskFormKey() { - Task task = startOneTaskprocess(); - assertThat(task.getFormKey()).isNull(); - - waitForHistoryJobExecutorToProcessAllJobs(7000L, 100L); - HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getFormKey()).isNull(); - - removeRuntimeActivityInstances(task.getProcessInstanceId()); - - task.setFormKey("test form key"); - taskService.saveTask(task); - - downgradeHistoryJobConfigurations(); - - waitForHistoryJobExecutorToProcessAllJobs(10000L, 100L); - historicTaskInstance = historyService.createHistoricTaskInstanceQuery().singleResult(); - assertThat(historicTaskInstance.getFormKey()).isEqualTo("test form key"); - - finishOneTaskProcess(task); - } - - protected void downgradeHistoryJobConfigurations() { - managementService.executeCommand(commandContext -> { - try { - HistoryJob historyJob = managementService.createHistoryJobQuery().singleResult(); - List> configurations = processEngineConfiguration.getObjectMapper().readValue( - new String(((HistoryJobEntity) historyJob).getAdvancedJobHandlerConfiguration().getBytes(), StandardCharsets.UTF_8), - List.class - ); - - List> downgradedConfigurations = configurations.stream(). - map(configuration -> { - Map data = (Map) configuration.get("data"); - String type = (String) configuration.get("type"); - data.remove(HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID); - if (ADD_ACTIVITY_ID_CONFIGURATIONS.contains(type)) { - data.put(HistoryJsonConstants.ACTIVITY_ID, "theTask"); - } - HashMap newConfiguration = new HashMap<>(); - newConfiguration.put("type", configuration.get("type")); - newConfiguration.put("data", data); - return newConfiguration; - }). - collect(Collectors.toList()); - - ((HistoryJobEntity) historyJob).setAdvancedJobHandlerConfiguration( - processEngineConfiguration.getObjectMapper().writeValueAsString(downgradedConfigurations) - ); - processEngineConfiguration.getJobServiceConfiguration().getHistoryJobEntityManager().update((HistoryJobEntity) historyJob); - } catch (IOException e) { - throw new RuntimeException(e); - } - - return null; - }); - } - - protected void removeRuntimeActivityInstances(String processInstanceId) { - managementService.executeCommand(commandContext -> { - CommandContextUtil.getActivityInstanceEntityManager(commandContext).deleteActivityInstancesByProcessInstanceId(processInstanceId); - return null; - }); - } - - protected Task startOneTaskprocess() { - deployOneTaskTestProcess(); - String processInstanceId = runtimeService.startProcessInstanceByKey("oneTaskProcess").getId(); - Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult(); - return task; - } - - protected void finishOneTaskProcess(Task task) { - taskService.complete(task.getId()); - waitForHistoryJobExecutorToProcessAllJobs(10_000L, 100L); - assertThat(managementService.createHistoryJobQuery().singleResult()).isNull(); - } - - protected void assertRuntimeActivityInstanceIsSame(HistoricActivityInstance historicActivityInstance) { - assertActivityInstancesAreSame(historicActivityInstance, - runtimeService.createActivityInstanceQuery().activityInstanceId(historicActivityInstance.getId()).singleResult()); - } - -} diff --git a/modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/TestUpCounterDelegate.java b/modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/TestUpCounterDelegate.java deleted file mode 100644 index f107edba361..00000000000 --- a/modules/flowable-engine/src/test/java/org/flowable/standalone/history/async/TestUpCounterDelegate.java +++ /dev/null @@ -1,26 +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.standalone.history.async; - -import org.flowable.engine.delegate.DelegateExecution; -import org.flowable.engine.delegate.JavaDelegate; - -public class TestUpCounterDelegate implements JavaDelegate { - - @Override - public void execute(DelegateExecution execution) { - Integer counter = (Integer) execution.getVariable("counter"); - execution.setVariable("counter", counter + 1); - } - -} diff --git a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testInclusiveGatewayEndTimeSet.bpmn b/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testInclusiveGatewayEndTimeSet.bpmn deleted file mode 100644 index 73b029aee28..00000000000 --- a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testInclusiveGatewayEndTimeSet.bpmn +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testNonInterruptingTimerBoundaryEventOnCallActivityWithOldData.bpmn20.xml b/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testNonInterruptingTimerBoundaryEventOnCallActivityWithOldData.bpmn20.xml deleted file mode 100644 index 300c64cd304..00000000000 --- a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testNonInterruptingTimerBoundaryEventOnCallActivityWithOldData.bpmn20.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - PT1S - - - - \ No newline at end of file diff --git a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testSimpleStraightThroughProcess.bpmn b/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testSimpleStraightThroughProcess.bpmn deleted file mode 100644 index 09c5b2b4fd6..00000000000 --- a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/AsyncHistoryTest.testSimpleStraightThroughProcess.bpmn +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testProcessWithTaskLevel.bpmn b/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testProcessWithTaskLevel.bpmn deleted file mode 100644 index 1b8fe94f744..00000000000 --- a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testProcessWithTaskLevel.bpmn +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - task - - - - - - - - - - - \ No newline at end of file diff --git a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testSTPWithCustomHistoryLevel.bpmn b/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testSTPWithCustomHistoryLevel.bpmn deleted file mode 100644 index a209e06a016..00000000000 --- a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testSTPWithCustomHistoryLevel.bpmn +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - instance - - - - - - - true - - - - - - - - - - - \ No newline at end of file diff --git a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testSTPWithInstanceLevel.bpmn b/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testSTPWithInstanceLevel.bpmn deleted file mode 100644 index 6f2361c6296..00000000000 --- a/modules/flowable-engine/src/test/resources/org/flowable/standalone/history/async/testSTPWithInstanceLevel.bpmn +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - instance - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/JobServiceConfiguration.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/JobServiceConfiguration.java index ad20e3c8002..7c67e34aace 100755 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/JobServiceConfiguration.java +++ b/modules/flowable-job-service/src/main/java/org/flowable/job/service/JobServiceConfiguration.java @@ -36,8 +36,6 @@ import org.flowable.job.service.impl.asyncexecutor.JobManager; import org.flowable.job.service.impl.asyncexecutor.TimerJobScheduler; import org.flowable.job.service.impl.asyncexecutor.TimerJobSchedulerImpl; -import org.flowable.job.service.impl.history.async.AsyncHistoryJobHandler; -import org.flowable.job.service.impl.history.async.transformer.HistoryJsonTransformer; import org.flowable.job.service.impl.persistence.entity.DeadLetterJobEntityManager; import org.flowable.job.service.impl.persistence.entity.DeadLetterJobEntityManagerImpl; import org.flowable.job.service.impl.persistence.entity.ExternalWorkerJobEntityManager; @@ -134,13 +132,6 @@ public class JobServiceConfiguration extends AbstractServiceConfiguration { protected Map historyJobHandlers; protected List historyJobProcessors; - protected String jobTypeAsyncHistory; - protected String jobTypeAsyncHistoryZipped; - - protected boolean asyncHistoryJsonGzipCompressionEnabled; - protected boolean asyncHistoryJsonGroupingEnabled; - protected int asyncHistoryJsonGroupingThreshold = 10; - public JobServiceConfiguration(String engineName) { super(engineName); } @@ -553,46 +544,6 @@ public JobServiceConfiguration addHistoryJobHandler(String type, HistoryJobHandl this.historyJobHandlers.put(type, historyJobHandler); return this; } - - /** - * Registers the given {@link HistoryJobHandler} under the provided type and checks for - * existing default and internal {@link HistoryJobHandler} instances to be of the same class. - * - * If no such instances are found, a {@link #addHistoryJobHandler(String, HistoryJobHandler)} is done. - * - * If such instances are found, they are merged, meaning the {@link HistoryJsonTransformer} instances of the provided {@link HistoryJobHandler} - * are copied into the already registered {@link HistoryJobHandler} and vice versa. - * - * If a type is already registered, the provided history job handler is simply ignored. - * - * This is especially useful when multiple engines (e.g. bpmn and cmmn) share an async history executor. - * In this case, both {@link AsyncHistoryJobHandler} instances should be able to handle history jobs from any engine. - */ - public JobServiceConfiguration mergeHistoryJobHandler(HistoryJobHandler historyJobHandler) { - if (historyJobHandlers != null - && historyJobHandler instanceof AsyncHistoryJobHandler - && !historyJobHandlers.containsKey(historyJobHandler.getType())) { - - for (HistoryJobHandler existingHistoryJobHandler : historyJobHandlers.values()) { - if (existingHistoryJobHandler.getClass().equals(historyJobHandler.getClass())) { - copyHistoryJsonTransformers((AsyncHistoryJobHandler) historyJobHandler, (AsyncHistoryJobHandler) existingHistoryJobHandler); - copyHistoryJsonTransformers((AsyncHistoryJobHandler) existingHistoryJobHandler, (AsyncHistoryJobHandler) historyJobHandler); - } - } - } - addHistoryJobHandler(historyJobHandler.getType(), historyJobHandler); - return this; - } - - protected void copyHistoryJsonTransformers(AsyncHistoryJobHandler source, AsyncHistoryJobHandler target) { - source.getHistoryJsonTransformers().forEach((transformerType, transformersList) -> { - for (HistoryJsonTransformer historyJsonTransformer : transformersList) { - if (!target.getHistoryJsonTransformers().containsKey(transformerType)) { - target.addHistoryJsonTransformer(historyJsonTransformer); - } - } - }); - } public int getAsyncExecutorNumberOfRetries() { return asyncExecutorNumberOfRetries; @@ -665,44 +616,4 @@ public void addEnabledJobCategory(String jobCategory) { enabledJobCategories.add(jobCategory); } - public String getJobTypeAsyncHistory() { - return jobTypeAsyncHistory; - } - - public void setJobTypeAsyncHistory(String jobTypeAsyncHistory) { - this.jobTypeAsyncHistory = jobTypeAsyncHistory; - } - - public String getJobTypeAsyncHistoryZipped() { - return jobTypeAsyncHistoryZipped; - } - - public void setJobTypeAsyncHistoryZipped(String jobTypeAsyncHistoryZipped) { - this.jobTypeAsyncHistoryZipped = jobTypeAsyncHistoryZipped; - } - - public boolean isAsyncHistoryJsonGzipCompressionEnabled() { - return asyncHistoryJsonGzipCompressionEnabled; - } - - public void setAsyncHistoryJsonGzipCompressionEnabled(boolean asyncHistoryJsonGzipCompressionEnabled) { - this.asyncHistoryJsonGzipCompressionEnabled = asyncHistoryJsonGzipCompressionEnabled; - } - - public boolean isAsyncHistoryJsonGroupingEnabled() { - return asyncHistoryJsonGroupingEnabled; - } - - public void setAsyncHistoryJsonGroupingEnabled(boolean asyncHistoryJsonGroupingEnabled) { - this.asyncHistoryJsonGroupingEnabled = asyncHistoryJsonGroupingEnabled; - } - - public int getAsyncHistoryJsonGroupingThreshold() { - return asyncHistoryJsonGroupingThreshold; - } - - public void setAsyncHistoryJsonGroupingThreshold(int asyncHistoryJsonGroupingThreshold) { - this.asyncHistoryJsonGroupingThreshold = asyncHistoryJsonGroupingThreshold; - } - } diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AbstractAsyncHistoryJobHandler.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AbstractAsyncHistoryJobHandler.java deleted file mode 100644 index a097b759f7e..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AbstractAsyncHistoryJobHandler.java +++ /dev/null @@ -1,151 +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.job.service.impl.history.async; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; - -import org.flowable.common.engine.api.FlowableException; -import org.flowable.common.engine.impl.context.Context; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.HistoryJobHandler; -import org.flowable.job.service.JobServiceConfiguration; -import org.flowable.job.service.impl.persistence.entity.DeadLetterJobEntity; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public abstract class AbstractAsyncHistoryJobHandler implements HistoryJobHandler { - - protected final Logger logger = LoggerFactory.getLogger(getClass()); - - protected boolean isAsyncHistoryJsonGroupingEnabled; - protected String jobType; - - public AbstractAsyncHistoryJobHandler(String jobType) { - this.jobType = jobType; - } - - @Override - public String getType() { - return jobType; - } - - @Override - public void execute(HistoryJobEntity job, String configuration, CommandContext commandContext, - JobServiceConfiguration jobServiceConfiguration) { - ObjectMapper objectMapper = commandContext.getObjectMapper(); - if (job.getAdvancedJobHandlerConfigurationByteArrayRef() != null) { - - JsonNode historyNode; - try { - byte[] bytes = getJobBytes(job); - historyNode = objectMapper.readTree(bytes); - } catch (Exception e) { - // The transaction will be rolled back and the job retries decremented, - // which is different from unacquiring the job where the retries are not changed. - throw new FlowableException("Could not deserialize async history json for job (id=" + job.getId() + ")", e); - } - - if (isAsyncHistoryJsonGroupingEnabled() && historyNode.isArray()) { - List failedNodes = null; - Exception exception = null; - ArrayNode arrayNode = (ArrayNode) historyNode; - for (JsonNode jsonNode : arrayNode) { - try { - processHistoryJson(commandContext, job, jsonNode); - - } catch (Exception ex) { - if (failedNodes == null) { - failedNodes = new ArrayList<>(); - } - failedNodes.add((ObjectNode) jsonNode); - - if (exception == null) { - exception = new FlowableException("Failed to process async history json. See suppressed exceptions."); - } - exception.addSuppressed(ex); - } - } - - if (failedNodes != null && !failedNodes.isEmpty()) { - List newHistoryJobs = getAsyncHistoryListener(commandContext) - .historyDataGenerated(jobServiceConfiguration, failedNodes, Context.getTransactionContext()); - - StringWriter stringWriter = new StringWriter(); - exception.printStackTrace(new PrintWriter(stringWriter)); - String exceptionStacktrace = stringWriter.toString(); - - for (HistoryJobEntity historyJob : newHistoryJobs) { - historyJob.setExceptionMessage(exception.getMessage()); - historyJob.setExceptionStacktrace(exceptionStacktrace); - if (job.getRetries() == 0) { - // If the job has no more retries then we should create a dead letter job out of it - DeadLetterJobEntity deadLetterJob = jobServiceConfiguration.getJobManager().createDeadLetterJobFromHistoryJob(historyJob); - jobServiceConfiguration.getDeadLetterJobDataManager().insert(deadLetterJob); - jobServiceConfiguration.getHistoryJobEntityManager().deleteNoCascade(historyJob); // no cascade -> the bytearray ref is reused for either the new history job or the deadletter job - } else { - // The historyJob is a new job with new data - // However, we still should decrement the retries - historyJob.setRetries(job.getRetries() - 1); - } - } - } - } else { - try { - processHistoryJson(commandContext, job, historyNode); - - } catch (AsyncHistoryJobNotApplicableException e) { - throw e; - - } catch (Exception e) { - - if (!(e instanceof FlowableException) || (e instanceof FlowableException && ((FlowableException) e).isLogged())) { - logger.warn("Could not execute history job", e); - } - - // The transaction will be rolled back and the job retries decremented, - // which is different from unacquiring the job where the retries are not changed. - throw new FlowableException("Failed to process async history json for job (id=" + job.getId() + ")", e); - } - - } - } - } - - protected AsyncHistoryListener getAsyncHistoryListener(CommandContext commandContext) { - return commandContext.getSession(AsyncHistorySession.class).getAsyncHistoryListener(); - } - - protected byte[] getJobBytes(HistoryJobEntity job) { - return job.getAdvancedJobHandlerConfigurationByteArrayRef().getBytes(job.getScopeType()); - } - - protected abstract void processHistoryJson(CommandContext commandContext, HistoryJobEntity job, JsonNode historyNode); - - public boolean isAsyncHistoryJsonGroupingEnabled() { - return isAsyncHistoryJsonGroupingEnabled; - } - - public void setAsyncHistoryJsonGroupingEnabled(boolean isAsyncHistoryJsonGroupingEnabled) { - this.isAsyncHistoryJsonGroupingEnabled = isAsyncHistoryJsonGroupingEnabled; - } - -} diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryCommittedTransactionListener.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryCommittedTransactionListener.java deleted file mode 100644 index 4a6e23e269b..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryCommittedTransactionListener.java +++ /dev/null @@ -1,47 +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.job.service.impl.history.async; - -import java.util.ArrayList; -import java.util.List; - -import org.flowable.common.engine.impl.cfg.TransactionListener; -import org.flowable.common.engine.impl.interceptor.CommandContext; - -/** - * @author Joram Barrez - */ -public class AsyncHistoryCommittedTransactionListener implements TransactionListener { - - protected List runnables = new ArrayList<>(); - - public void addRunnable(Runnable runnable) { - runnables.add(runnable); - } - - @Override - public void execute(CommandContext commandContext) { - for (Runnable runnable : runnables) { - runnable.run(); - } - } - - public List getRunnables() { - return runnables; - } - - public void setRunnables(List runnables) { - this.runnables = runnables; - } - -} diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobHandler.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobHandler.java deleted file mode 100644 index e220b65a0aa..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobHandler.java +++ /dev/null @@ -1,112 +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.job.service.impl.history.async; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.impl.history.async.transformer.HistoryJsonTransformer; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class AsyncHistoryJobHandler extends AbstractAsyncHistoryJobHandler { - - protected Map> historyJsonTransformers = new HashMap<>(); - protected HistoryJsonTransformer defaultHistoryJsonTransformer; - - public AsyncHistoryJobHandler(String jobType) { - super(jobType); - } - - public void addHistoryJsonTransformer(HistoryJsonTransformer historyJsonTransformer) { - List types = historyJsonTransformer.getTypes(); - - for (String type : types) { - if (!historyJsonTransformers.containsKey(type)) { - historyJsonTransformers.put(type, new ArrayList<>()); - } - historyJsonTransformers.get(type).add(historyJsonTransformer); - } - } - - @Override - protected void processHistoryJson(CommandContext commandContext, HistoryJobEntity job, JsonNode historyNode) { - - String type = null; - if (historyNode.has(HistoryJsonTransformer.FIELD_NAME_TYPE)) { - type = historyNode.get(HistoryJsonTransformer.FIELD_NAME_TYPE).asText(); - } - ObjectNode historicalJsonData = (ObjectNode) historyNode.get(HistoryJsonTransformer.FIELD_NAME_DATA); - - if (logger.isTraceEnabled()) { - logger.trace("Handling async history job (id={}, type={})", job.getId(), type); - } - - List transformers = historyJsonTransformers.get(type); - if (transformers != null && !transformers.isEmpty()) { - executeHistoryTransformers(commandContext, job, historicalJsonData, transformers); - } else { - handleNoMatchingHistoryTransformer(commandContext, job, historicalJsonData, type); - } - } - - protected void executeHistoryTransformers(CommandContext commandContext, HistoryJobEntity job, - ObjectNode historicalJsonData, List transformers) { - for (HistoryJsonTransformer transformer : transformers) { - if (transformer.isApplicable(historicalJsonData, commandContext)) { - transformer.transformJson(job, historicalJsonData, commandContext); - - } else { - if (logger.isDebugEnabled()) { - logger.debug("Could not handle history job (id={}) for transformer {}. as it is not applicable. Unacquiring. {}", job.getId(), transformer.getTypes(), historicalJsonData); - } - throw new AsyncHistoryJobNotApplicableException("Job is not applicable for transformer types: " + transformer.getTypes()); - - } - } - } - - protected void handleNoMatchingHistoryTransformer(CommandContext commandContext, HistoryJobEntity job, ObjectNode historicalData, String type) { - if (defaultHistoryJsonTransformer != null) { - if (defaultHistoryJsonTransformer.isApplicable(historicalData, commandContext)) { - defaultHistoryJsonTransformer.transformJson(job, historicalData, commandContext); - } else { - throw new AsyncHistoryJobNotApplicableException("Job is not applicable for default history json transformer types: " + defaultHistoryJsonTransformer.getTypes()); - } - } else { - throw new AsyncHistoryJobNotApplicableException("Cannot transform history json: no transformers found for type " + type); - } - } - - public Map> getHistoryJsonTransformers() { - return historyJsonTransformers; - } - - public void setHistoryJsonTransformers(Map> historyJsonTransformers) { - this.historyJsonTransformers = historyJsonTransformers; - } - - public HistoryJsonTransformer getDefaultHistoryJsonTransformer() { - return defaultHistoryJsonTransformer; - } - - public void setDefaultHistoryJsonTransformer(HistoryJsonTransformer defaultHistoryJsonTransformer) { - this.defaultHistoryJsonTransformer = defaultHistoryJsonTransformer; - } - -} diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobNotApplicableException.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobNotApplicableException.java deleted file mode 100644 index 54da480c324..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobNotApplicableException.java +++ /dev/null @@ -1,30 +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.job.service.impl.history.async; - -import org.flowable.common.engine.api.FlowableException; - -public class AsyncHistoryJobNotApplicableException extends FlowableException { - - private static final long serialVersionUID = 1L; - - public AsyncHistoryJobNotApplicableException() { - this(null); - } - - public AsyncHistoryJobNotApplicableException(String message) { - super(message); - this.isLogged = false; - } - -} diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobZippedHandler.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobZippedHandler.java deleted file mode 100644 index 026bb278b74..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryJobZippedHandler.java +++ /dev/null @@ -1,48 +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.job.service.impl.history.async; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.zip.GZIPInputStream; - -import org.flowable.common.engine.impl.util.IoUtil; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -/** - * @author Joram Barrez - */ -public class AsyncHistoryJobZippedHandler extends AsyncHistoryJobHandler { - - public AsyncHistoryJobZippedHandler(String jobType) { - super(jobType); - } - - @Override - protected byte[] getJobBytes(HistoryJobEntity job) { - byte[] bytes = job.getAdvancedJobHandlerConfigurationByteArrayRef().getBytes(job.getScopeType()); - bytes = decompress(bytes); - return bytes; - } - - protected byte[] decompress(final byte[] compressed) { - try (ByteArrayInputStream bais = new ByteArrayInputStream(compressed)) { - try (GZIPInputStream gis = new GZIPInputStream(bais)) { - return IoUtil.readInputStream(gis, "async-history-configuration"); - } - } catch (IOException e) { - throw new RuntimeException("Error while decompressing json bytes", e); - } - } - -} diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryListener.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryListener.java deleted file mode 100644 index cd9a2e91f8c..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistoryListener.java +++ /dev/null @@ -1,27 +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.job.service.impl.history.async; - -import java.util.List; - -import org.flowable.common.engine.impl.cfg.TransactionContext; -import org.flowable.job.service.JobServiceConfiguration; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public interface AsyncHistoryListener { - - List historyDataGenerated(JobServiceConfiguration jobServiceConfiguration, List historyObjectNodes, TransactionContext transactionContext); - -} diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySession.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySession.java deleted file mode 100644 index 1ffc020e24b..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySession.java +++ /dev/null @@ -1,159 +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.job.service.impl.history.async; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.flowable.common.engine.impl.cfg.TransactionContext; -import org.flowable.common.engine.impl.context.Context; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.common.engine.impl.interceptor.CommandContextCloseListener; -import org.flowable.common.engine.impl.interceptor.Session; -import org.flowable.job.service.JobServiceConfiguration; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class AsyncHistorySession implements Session { - - public static final String TIMESTAMP = "__timeStamp"; // Two underscores to avoid clashes with other fields - - protected CommandContext commandContext; - protected AsyncHistoryListener asyncHistoryListener; - protected CommandContextCloseListener commandContextCloseListener; - - // A list of the different types of history for which jobs will be created - // Note that the ordering of the types is important, as it will define the order of job creation. - protected List jobDataTypes; - - protected TransactionContext transactionContext; - protected String tenantId; - protected Map sessionData; - - public AsyncHistorySession(CommandContext commandContext, AsyncHistoryListener asyncHistoryJobListener) { - this.commandContext = commandContext; - this.asyncHistoryListener = asyncHistoryJobListener; - - // A command context close listener is registered to avoid creating the async history data if it wouldn't be needed - initCommandContextCloseListener(); - - // The transaction context is captured now, as it might be gone by the time - // the history job entities are created in the command context close listener - this.transactionContext = Context.getTransactionContext(); - } - - public AsyncHistorySession(CommandContext commandContext, AsyncHistoryListener asyncHistoryJobListener, List jobDataTypes) { - this(commandContext, asyncHistoryJobListener); - this.jobDataTypes = jobDataTypes; - } - - protected void initCommandContextCloseListener() { - this.commandContextCloseListener = new AsyncHistorySessionCommandContextCloseListener(this, asyncHistoryListener); - } - - public void addHistoricData(JobServiceConfiguration jobServiceConfiguration, String type, ObjectNode data) { - addHistoricData(jobServiceConfiguration, type, data, null); - } - - public void addHistoricData(JobServiceConfiguration jobServiceConfiguration, String type, ObjectNode data, String tenantId) { - data.put(TIMESTAMP, AsyncHistoryDateUtil.formatDate(jobServiceConfiguration.getClock().getCurrentTime())); - - if (sessionData == null) { - sessionData = new HashMap<>(); - commandContext.addCloseListener(commandContextCloseListener); - } - - AsyncHistorySessionData asyncHistorySessionData = sessionData.get(jobServiceConfiguration); - if (asyncHistorySessionData == null) { - asyncHistorySessionData = new AsyncHistorySessionData(); - sessionData.put(jobServiceConfiguration, asyncHistorySessionData); - } - - if (tenantId != null) { - this.tenantId = tenantId; - } - - asyncHistorySessionData.addJobData(type, data); - } - - @Override - public void flush() { - - } - - @Override - public void close() { - - } - - public AsyncHistoryListener getAsyncHistoryListener() { - return asyncHistoryListener; - } - - public String getTenantId() { - return tenantId; - } - - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - public Map getSessionData() { - return sessionData; - } - - public void setSessionData(Map sessionData) { - this.sessionData = sessionData; - } - - public List getJobDataTypes() { - return jobDataTypes; - } - - public void setJobDataTypes(List jobDataTypes) { - this.jobDataTypes = jobDataTypes; - } - - public TransactionContext getTransactionContext() { - return transactionContext; - } - - public void setTransactionContext(TransactionContext transactionContext) { - this.transactionContext = transactionContext; - } - - /** - * Wrapper for the async history job data, to avoid messing with maps and lists. - */ - public static class AsyncHistorySessionData { - - protected Map> jobData = new LinkedHashMap<>(); // A map of {type, list of map-data (the historical event)}. Linked because insertion order is important - - public Map> getJobData() { - return jobData; - } - public void setJobData(Map> jobData) { - this.jobData = jobData; - } - public void addJobData(String type, ObjectNode data) { - if (!jobData.containsKey(type)) { - jobData.put(type, new ArrayList<>(1)); - } - jobData.get(type).add(data); - } - - } -} diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySessionCommandContextCloseListener.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySessionCommandContextCloseListener.java deleted file mode 100644 index f19f31c2a55..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySessionCommandContextCloseListener.java +++ /dev/null @@ -1,166 +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.job.service.impl.history.async; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.common.engine.impl.interceptor.CommandContextCloseListener; -import org.flowable.job.service.JobServiceConfiguration; -import org.flowable.job.service.impl.history.async.AsyncHistorySession.AsyncHistorySessionData; -import org.flowable.job.service.impl.history.async.transformer.HistoryJsonTransformer; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * A listener for command context lifecycle close events that generates JSON - * (using Jackson) and corresponding {@link HistoryJobEntity} when the - * {@link CommandContext} closes and adds them to the list of entities that will - * be inserted to the database. - * - * The reason why this is done at the very end, is because that way the historical data - * can be optimized (some events cancel others, can be grouped, etc.) - * - * @author Joram Barrez - */ -public class AsyncHistorySessionCommandContextCloseListener implements CommandContextCloseListener { - - protected AsyncHistorySession asyncHistorySession; - protected AsyncHistoryListener asyncHistoryListener; - - // The field name under which the type and actual will be stored - protected String typeFieldName = HistoryJsonTransformer.FIELD_NAME_TYPE; - protected String dataFieldName = HistoryJsonTransformer.FIELD_NAME_DATA; - - public AsyncHistorySessionCommandContextCloseListener() { - - } - - public AsyncHistorySessionCommandContextCloseListener(AsyncHistorySession asyncHistorySession, AsyncHistoryListener asyncHistoryListener) { - this.asyncHistorySession = asyncHistorySession; - this.asyncHistoryListener = asyncHistoryListener; - } - - @Override - public void closing(CommandContext commandContext) { - - // This logic needs to be done before the dbSqlSession is flushed - // which means it can't be done in the transaction pre-commit - - Map sessionData = asyncHistorySession.getSessionData(); - if (sessionData == null) { - return; - } - - for (JobServiceConfiguration jobServiceConfiguration : sessionData.keySet()) { - - Map> jobData = sessionData.get(jobServiceConfiguration).getJobData(); - if (!jobData.isEmpty()) { - List objectNodes = new ArrayList<>(); - - // First, the registered types - for (String type : asyncHistorySession.getJobDataTypes()) { - if (jobData.containsKey(type)) { - generateJson(jobServiceConfiguration, jobData, objectNodes, type); - jobData.remove(type); - } - } - - // Additional data for which the type is not registered - if (!jobData.isEmpty()) { - for (String type : jobData.keySet()) { - generateJson(jobServiceConfiguration, jobData, objectNodes, type); - } - } - - // History job needs to be created in the context of which it originated - asyncHistoryListener.historyDataGenerated(jobServiceConfiguration, objectNodes, asyncHistorySession.getTransactionContext()); - - } - } - } - - protected void generateJson(JobServiceConfiguration jobServiceConfiguration, Map> jobData, List objectNodes, String type) { - List historicDataList = jobData.get(type); - for (ObjectNode historicData: historicDataList) { - ObjectNode historyJson = generateJson(jobServiceConfiguration, type, historicData); - objectNodes.add(historyJson); - } - } - - protected ObjectNode generateJson(JobServiceConfiguration jobServiceConfiguration, String type, ObjectNode historicData) { - ObjectNode elementObjectNode = jobServiceConfiguration.getObjectMapper().createObjectNode(); - elementObjectNode.put(typeFieldName, type); - - elementObjectNode.set(dataFieldName, historicData); - return elementObjectNode; - } - - @Override - public void closed(CommandContext commandContext) { - } - - @Override - public void closeFailure(CommandContext commandContext) { - } - - @Override - public void afterSessionsFlush(CommandContext commandContext) { - } - - @Override - public Integer order() { - return 1000; - } - - @Override - public boolean multipleAllowed() { - return false; - } - - public AsyncHistorySession getAsyncHistorySession() { - return asyncHistorySession; - } - - public void setAsyncHistorySession(AsyncHistorySession asyncHistorySession) { - this.asyncHistorySession = asyncHistorySession; - } - - public AsyncHistoryListener getAsyncHistoryListener() { - return asyncHistoryListener; - } - - public void setAsyncHistoryListener(AsyncHistoryListener asyncHistoryListener) { - this.asyncHistoryListener = asyncHistoryListener; - } - - public String getTypeFieldName() { - return typeFieldName; - } - - public void setTypeFieldName(String typeFieldName) { - this.typeFieldName = typeFieldName; - } - - public String getDataFieldName() { - return dataFieldName; - } - - public void setDataFieldName(String dataFieldName) { - this.dataFieldName = dataFieldName; - } - -} diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySessionFactory.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySessionFactory.java deleted file mode 100644 index 76585668fe6..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/AsyncHistorySessionFactory.java +++ /dev/null @@ -1,56 +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.job.service.impl.history.async; - -import java.util.ArrayList; -import java.util.List; - -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.common.engine.impl.interceptor.Session; -import org.flowable.common.engine.impl.interceptor.SessionFactory; - -public class AsyncHistorySessionFactory implements SessionFactory { - - protected AsyncHistoryListener asyncHistoryListener; - protected List registeredJobDataTypes = new ArrayList<>(); - - @Override - public Class getSessionType() { - return AsyncHistorySession.class; - } - - @Override - public Session openSession(CommandContext commandContext) { - return new AsyncHistorySession(commandContext, asyncHistoryListener, registeredJobDataTypes); - } - - public void registerJobDataTypes(List registeredJobDataTypes) { - this.registeredJobDataTypes.addAll(registeredJobDataTypes); - } - - public AsyncHistoryListener getAsyncHistoryListener() { - return asyncHistoryListener; - } - - public void setAsyncHistoryListener(AsyncHistoryListener asyncHistoryListener) { - this.asyncHistoryListener = asyncHistoryListener; - } - - public List getRegisteredJobDataTypes() { - return registeredJobDataTypes; - } - - public void setRegisteredJobDataTypes(List registeredJobDataTypes) { - this.registeredJobDataTypes = registeredJobDataTypes; - } -} diff --git a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/DefaultAsyncHistoryJobProducer.java b/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/DefaultAsyncHistoryJobProducer.java deleted file mode 100644 index cdbfc67742c..00000000000 --- a/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/history/async/DefaultAsyncHistoryJobProducer.java +++ /dev/null @@ -1,126 +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.job.service.impl.history.async; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.zip.GZIPOutputStream; - -import org.flowable.common.engine.api.FlowableException; -import org.flowable.common.engine.impl.cfg.TransactionContext; -import org.flowable.common.engine.impl.context.Context; -import org.flowable.common.engine.impl.interceptor.CommandContext; -import org.flowable.job.service.JobServiceConfiguration; -import org.flowable.job.service.impl.persistence.entity.HistoryJobEntity; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class DefaultAsyncHistoryJobProducer implements AsyncHistoryListener { - - @Override - public List historyDataGenerated(JobServiceConfiguration jobServiceConfiguration, List historyObjectNodes, TransactionContext transactionContext) { - CommandContext commandContext = Context.getCommandContext(); - List historyJobEntities = createJobsWithHistoricalData(commandContext, jobServiceConfiguration, historyObjectNodes); - processHistoryJobEntities(commandContext, jobServiceConfiguration, historyObjectNodes, historyJobEntities); - scheduleJobs(transactionContext, jobServiceConfiguration, historyJobEntities); - return historyJobEntities; - } - - protected List createJobsWithHistoricalData(CommandContext commandContext, - JobServiceConfiguration jobServiceConfiguration, List historyObjectNodes) { - - AsyncHistorySession asyncHistorySession = commandContext.getSession(AsyncHistorySession.class); - if (jobServiceConfiguration.isAsyncHistoryJsonGroupingEnabled() && historyObjectNodes.size() >= jobServiceConfiguration.getAsyncHistoryJsonGroupingThreshold()) { - String jobType = getJobType(jobServiceConfiguration, true); - HistoryJobEntity jobEntity = createJob(commandContext, asyncHistorySession, jobServiceConfiguration, jobType); - ArrayNode arrayNode = jobServiceConfiguration.getObjectMapper().createArrayNode(); - for (ObjectNode historyJsonNode : historyObjectNodes) { - arrayNode.add(historyJsonNode); - } - addJsonToJob(commandContext, jobServiceConfiguration, jobEntity, arrayNode, jobServiceConfiguration.isAsyncHistoryJsonGzipCompressionEnabled()); - return Collections.singletonList(jobEntity); - - } else { - List historyJobEntities = new ArrayList<>(historyObjectNodes.size()); - String jobType = getJobType(jobServiceConfiguration, false); - for (ObjectNode historyJsonNode : historyObjectNodes) { - HistoryJobEntity jobEntity = createJob(commandContext, asyncHistorySession, jobServiceConfiguration, jobType); - addJsonToJob(commandContext, jobServiceConfiguration, jobEntity, historyJsonNode, false); - historyJobEntities.add(jobEntity); - } - return historyJobEntities; - - } - } - - protected HistoryJobEntity createJob(CommandContext commandContext, AsyncHistorySession asyncHistorySession, - JobServiceConfiguration jobServiceConfiguration, String jobType) { - HistoryJobEntity currentJobEntity = jobServiceConfiguration.getHistoryJobEntityManager().create(); - currentJobEntity.setJobHandlerType(jobType); - currentJobEntity.setRetries(jobServiceConfiguration.getAsyncHistoryExecutorNumberOfRetries()); - currentJobEntity.setTenantId(asyncHistorySession.getTenantId()); - currentJobEntity.setCreateTime(jobServiceConfiguration.getClock().getCurrentTime()); - currentJobEntity.setScopeType(jobServiceConfiguration.getHistoryJobExecutionScope()); - return currentJobEntity; - } - - protected void scheduleJobs(TransactionContext transactionContext, JobServiceConfiguration jobServiceConfiguration, List historyJobEntities) { - for (HistoryJobEntity historyJobEntity : historyJobEntities) { - jobServiceConfiguration.getJobManager().scheduleHistoryJob(historyJobEntity, transactionContext); - } - } - - protected void addJsonToJob(CommandContext commandContext, JobServiceConfiguration jobServiceConfiguration, HistoryJobEntity jobEntity, JsonNode rootObjectNode, boolean applyCompression) { - try { - byte[] bytes = jobServiceConfiguration.getObjectMapper().writeValueAsBytes(rootObjectNode); - if (applyCompression) { - bytes = compress(bytes); - } - jobEntity.setAdvancedJobHandlerConfigurationBytes(bytes); - } catch (JsonProcessingException e) { - throw new FlowableException("Could not serialize historic data for async history", e); - } - } - - protected byte[] compress(final byte[] bytes) { - try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - try (GZIPOutputStream gos = new GZIPOutputStream(baos)) { - gos.write(bytes); - } - return baos.toByteArray(); - } catch (IOException e) { - throw new FlowableException("Error while compressing json", e); - } - } - - protected String getJobType(JobServiceConfiguration jobServiceConfiguration, boolean groupingEnabled) { - if (groupingEnabled) { - return jobServiceConfiguration.isAsyncHistoryJsonGzipCompressionEnabled() ? - jobServiceConfiguration.getJobTypeAsyncHistoryZipped() : jobServiceConfiguration.getJobTypeAsyncHistory(); - } else { - return jobServiceConfiguration.getJobTypeAsyncHistory(); - } - } - - protected void processHistoryJobEntities(CommandContext commandContext, JobServiceConfiguration jobServiceConfiguration, - List historyObjectNodes, List historyJobEntities) { - // Meant to be overridden in case something extra needs to happen with the created history job entities. - } - -} diff --git a/modules/flowable-spring/src/test/java/org/flowable/spring/test/jobexecutor/SpringAsyncHistoryExecutorTest.java b/modules/flowable-spring/src/test/java/org/flowable/spring/test/jobexecutor/SpringAsyncHistoryExecutorTest.java deleted file mode 100644 index 55ca17454d0..00000000000 --- a/modules/flowable-spring/src/test/java/org/flowable/spring/test/jobexecutor/SpringAsyncHistoryExecutorTest.java +++ /dev/null @@ -1,75 +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.spring.test.jobexecutor; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -import org.flowable.common.engine.impl.test.CleanTest; -import org.flowable.engine.HistoryService; -import org.flowable.engine.ManagementService; -import org.flowable.engine.ProcessEngineConfiguration; -import org.flowable.engine.RuntimeService; -import org.flowable.engine.TaskService; -import org.flowable.engine.impl.test.HistoryTestHelper; -import org.flowable.engine.runtime.ProcessInstance; -import org.flowable.spring.impl.test.SpringFlowableTestCase; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; - -@CleanTest -// We need to use per class as the test uses auto deployments. If they are deleted then the other tests will fail -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@ContextConfiguration("classpath:org/flowable/spring/test/components/SpringAsyncHistoryJobExecutorTest-context.xml") -public class SpringAsyncHistoryExecutorTest extends SpringFlowableTestCase { - - @Autowired - protected ManagementService managementService; - - @Autowired - protected RuntimeService runtimeService; - - @Autowired - protected TaskService taskService; - - @Autowired - protected HistoryService historyService; - - @Autowired - protected ProcessEngineConfiguration processEngineConfiguration; - - @Test - public void testHistoryDataGenerated() throws Exception { - ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); - List tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); - while (!tasks.isEmpty()) { - taskService.complete(tasks.get(0).getId()); - tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); - } - - HistoryTestHelper.waitForJobExecutorToProcessAllHistoryJobs(processEngineConfiguration, managementService, 20000L, 200L, false); - - List historicTasks = historyService.createHistoricTaskInstanceQuery() - .processInstanceId(processInstance.getId()).orderByTaskName().asc().list(); - - assertThat(historicTasks) - .extracting(HistoricTaskInstance::getName) - .containsExactly("Task a", "Task b1", "Task b2", "Task c"); - } - -} diff --git a/modules/flowable-spring/src/test/resources/org/flowable/spring/test/components/SpringAsyncHistoryJobExecutorTest-context.xml b/modules/flowable-spring/src/test/resources/org/flowable/spring/test/components/SpringAsyncHistoryJobExecutorTest-context.xml deleted file mode 100644 index 435febbc2f7..00000000000 --- a/modules/flowable-spring/src/test/resources/org/flowable/spring/test/components/SpringAsyncHistoryJobExecutorTest-context.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - classpath:/org/flowable/spring/test/components/SpringAsyncHistory.testUsersTasks.bpmn20.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/history/InternalHistoryVariableManager.java b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/history/InternalHistoryVariableManager.java index 4d9379f5ed6..aeb02294fb6 100644 --- a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/history/InternalHistoryVariableManager.java +++ b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/history/InternalHistoryVariableManager.java @@ -32,6 +32,5 @@ public interface InternalHistoryVariableManager { * Record a variable has been deleted, if audit history is enabled. */ void recordVariableRemoved(VariableInstanceEntity variable, Date removeTime); - - void initAsyncHistoryCommandContextCloseListener(); + } diff --git a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JsonType.java b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JsonType.java index f81ff445610..b4f828331f1 100644 --- a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JsonType.java +++ b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/JsonType.java @@ -158,7 +158,6 @@ protected void traceValue(JsonNode value, ValueFields valueFields) { new TraceableObject<>(this, value, value.deepCopy(), (VariableInstanceEntity) valueFields) )); - variableServiceConfiguration.getInternalHistoryVariableManager().initAsyncHistoryCommandContextCloseListener(); } } } diff --git a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/SerializableType.java b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/SerializableType.java index cb47016d1bb..c2b9868d07a 100644 --- a/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/SerializableType.java +++ b/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/types/SerializableType.java @@ -99,7 +99,6 @@ protected void traceValue(Object value, byte[] valueBytes, ValueFields valueFiel commandContext.addCloseListener(new TraceableVariablesCommandContextCloseListener( new TraceableObject<>(this, value, valueBytes, (VariableInstanceEntity) valueFields) )); - variableServiceConfiguration.getInternalHistoryVariableManager().initAsyncHistoryCommandContextCloseListener(); } } }