当前位置:网站首页>Comments on flowable source code (XXXV) timer activation process definition processor, process instance migration job processor
Comments on flowable source code (XXXV) timer activation process definition processor, process instance migration job processor
2022-07-06 01:35:00 【jinyangjie0】
Flowable Source code address :https://github.com/flowable/flowable-engine
Flowable-6.7.2 Source code comment address :https://github.com/solojin/flowable-6.7.2-annotated
Package path :org.flowable.engine.impl.jobexecutor
TimerActivateProcessDefinitionHandler Timer activation process definition processor
/** * Timer activation process definition processor * * @author Joram Barrez */
public class TimerActivateProcessDefinitionHandler extends TimerChangeProcessDefinitionSuspensionStateJobHandler {
// type : Activate the process definition
public static final String TYPE = "activate-processdefinition";
// Access to type
@Override
public String getType() {
return TYPE;
}
// Perform operation ,job Operation entity ,configuration To configure ,variableScope Variable range ,commandContext Command context
@Override
public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
boolean activateProcessInstances = false;
try {
JsonNode configNode = processEngineConfiguration.getObjectMapper().readTree(configuration);
activateProcessInstances = getIncludeProcessInstances(configNode);
} catch (Exception e) {
// Read json Error in value
throw new FlowableException("Error reading json value " + configuration, e);
}
String processDefinitionId = job.getProcessDefinitionId();
ActivateProcessDefinitionCmd activateProcessDefinitionCmd = new ActivateProcessDefinitionCmd(processDefinitionId, null, activateProcessInstances, null, job.getTenantId());
activateProcessDefinitionCmd.execute(commandContext);
}
}
AbstractProcessInstanceMigrationJobHandler Abstract process instance migration job processor
/** * Abstract process instance migration job processor */
public abstract class AbstractProcessInstanceMigrationJobHandler implements JobHandler {
// Batch result status label
public static final String BATCH_RESULT_STATUS_LABEL = "resultStatus";
// Batch result information label
public static final String BATCH_RESULT_MESSAGE_LABEL = "resultMessage";
protected static final String CFG_LABEL_BATCH_ID = "batchId";
protected static final String CFG_LABEL_BATCH_PART_ID = "batchPartId";
protected static String getBatchIdFromHandlerCfg(String handlerCfg) {
try {
JsonNode cfgAsJson = getObjectMapper().readTree(handlerCfg);
if (cfgAsJson.has(CFG_LABEL_BATCH_ID)) {
return cfgAsJson.get(CFG_LABEL_BATCH_ID).asText();
}
return null;
} catch (IOException e) {
return null;
}
}
protected static String getBatchPartIdFromHandlerCfg(String handlerCfg) {
try {
JsonNode cfgAsJson = getObjectMapper().readTree(handlerCfg);
if (cfgAsJson.has(CFG_LABEL_BATCH_PART_ID)) {
return cfgAsJson.get(CFG_LABEL_BATCH_PART_ID).asText();
}
return null;
} catch (IOException e) {
return null;
}
}
public static String getHandlerCfgForBatchId(String batchId) {
ObjectNode handlerCfg = getObjectMapper().createObjectNode();
handlerCfg.put(CFG_LABEL_BATCH_ID, batchId);
return handlerCfg.toString();
}
public static String getHandlerCfgForBatchPartId(String batchPartId) {
ObjectNode handlerCfg = getObjectMapper().createObjectNode();
handlerCfg.put(CFG_LABEL_BATCH_PART_ID, batchPartId);
return handlerCfg.toString();
}
protected static ObjectMapper getObjectMapper() {
if (CommandContextUtil.getCommandContext() != null) {
return CommandContextUtil.getProcessEngineConfiguration().getObjectMapper();
} else {
return new ObjectMapper();
}
}
}
ProcessInstanceMigrationJobHandler Process instance migration job processor
/** * Process instance migration job processor */
public class ProcessInstanceMigrationJobHandler extends AbstractProcessInstanceMigrationJobHandler {
// type : Process migration
public static final String TYPE = "process-migration";
@Override
public String getType() {
return TYPE;
}
@Override
public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
BatchService batchService = processEngineConfiguration.getBatchServiceConfiguration().getBatchService();
ProcessInstanceMigrationManager processInstanceMigrationManager = processEngineConfiguration.getProcessInstanceMigrationManager();
String batchPartId = getBatchPartIdFromHandlerCfg(configuration);
BatchPart batchPart = batchService.getBatchPart(batchPartId);
Batch batch = batchService.getBatch(batchPart.getBatchId());
ProcessInstanceMigrationDocument migrationDocument = ProcessInstanceMigrationDocumentImpl.fromJson(batch.getBatchDocumentJson(processEngineConfiguration.getEngineCfgKey()));
String exceptionMessage = null;
try {
processInstanceMigrationManager.migrateProcessInstance(batchPart.getScopeId(), migrationDocument, commandContext);
} catch (FlowableException e) {
exceptionMessage = e.getMessage();
}
String resultAsJsonString = prepareResultAsJsonString(exceptionMessage);
if (exceptionMessage != null) {
batchService.completeBatchPart(batchPartId, ProcessInstanceBatchMigrationResult.RESULT_FAIL, resultAsJsonString);
} else {
batchService.completeBatchPart(batchPartId, ProcessInstanceBatchMigrationResult.RESULT_SUCCESS, resultAsJsonString);
}
}
protected static String prepareResultAsJsonString(String exceptionMessage) {
ObjectNode objectNode = getObjectMapper().createObjectNode();
if (exceptionMessage == null) {
objectNode.put(BATCH_RESULT_STATUS_LABEL, ProcessInstanceBatchMigrationResult.RESULT_SUCCESS);
} else {
objectNode.put(BATCH_RESULT_STATUS_LABEL, ProcessInstanceBatchMigrationResult.RESULT_FAIL);
objectNode.put(BATCH_RESULT_MESSAGE_LABEL, exceptionMessage);
}
return objectNode.toString();
}
}
边栏推荐
- Paddle框架:PaddleNLP概述【飞桨自然语言处理开发库】
- 干货!通过软硬件协同设计加速稀疏神经网络
- How to see the K-line chart of gold price trend?
- [技术发展-28]:信息通信网大全、新的技术形态、信息通信行业高质量发展概览
- Paging of a scratch (page turning processing)
- 2022年广西自治区中职组“网络空间安全”赛题及赛题解析(超详细)
- 【Flask】官方教程(Tutorial)-part1:项目布局、应用程序设置、定义和访问数据库
- 国家级非遗传承人高清旺《四大美人》皮影数字藏品惊艳亮相!
- VMware Tools installation error: unable to automatically install vsock driver
- Basic process and testing idea of interface automation
猜你喜欢
![[detailed] several ways to quickly realize object mapping](/img/e5/70c7f8fee4556d14f969fe33938971.gif)
[detailed] several ways to quickly realize object mapping

File upload vulnerability test based on DVWA

Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition

Yii console method call, Yii console scheduled task

Basic operations of database and table ----- delete data table

How does the crystal oscillator vibrate?

Basic operations of databases and tables ----- unique constraints

dried food! Accelerating sparse neural network through hardware and software co design

You are using pip version 21.1.1; however, version 22.0.3 is available. You should consider upgradin
Folio.ink 免费、快速、易用的图片分享工具
随机推荐
MUX VLAN configuration
You are using pip version 21.1.1; however, version 22.0.3 is available. You should consider upgradin
【Flask】静态文件与模板渲染
Flutter Doctor:Xcode 安装不完整
2022 Guangxi Autonomous Region secondary vocational group "Cyberspace Security" competition and its analysis (super detailed)
Hcip---ipv6 experiment
MATLB | real time opportunity constrained decision making and its application in power system
现货白银的一般操作方法
Kotlin basics 1
Redis-字符串类型
ORA-00030
WGet: command line download tool
Unity VR solves the problem that the handle ray keeps flashing after touching the button of the UI
Tcpdump: monitor network traffic
Superfluid_ HQ hacked analysis
Condition and AQS principle
XSS learning XSS lab problem solution
Crawler request module
How does the crystal oscillator vibrate?
普通人下场全球贸易,新一轮结构性机会浮出水面