mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
feat: support inject workflow context directly
This commit is contained in:
parent
54524553c1
commit
bdd9b978f9
@ -177,11 +177,26 @@ public class WorkflowInstanceManager {
|
||||
newWfInstance.setExpectedTriggerTime(expectTriggerTime);
|
||||
newWfInstance.setActualTriggerTime(System.currentTimeMillis());
|
||||
newWfInstance.setWfInitParams(initParams);
|
||||
// 初始化上下文
|
||||
Map<String, String> wfContextMap = Maps.newHashMap();
|
||||
wfContextMap.put(WorkflowContextConstant.CONTEXT_INIT_PARAMS_KEY, initParams);
|
||||
newWfInstance.setWfContext(JsonUtils.toJSONString(wfContextMap));
|
||||
|
||||
// 如果 initParams 是个合法的 Map<String,String> JSON 串则直接将其注入 wfContext
|
||||
boolean injectDirect = false;
|
||||
try {
|
||||
Map<String, String> parseRes = JSON.parseObject(initParams, new TypeReference<Map<String, String>>() {
|
||||
});
|
||||
if (parseRes != null && !parseRes.isEmpty()) {
|
||||
injectDirect = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
if (injectDirect) {
|
||||
newWfInstance.setWfContext(initParams);
|
||||
} else {
|
||||
// 初始化上下文
|
||||
Map<String, String> wfContextMap = Maps.newHashMap();
|
||||
wfContextMap.put(WorkflowContextConstant.CONTEXT_INIT_PARAMS_KEY, initParams);
|
||||
newWfInstance.setWfContext(JsonUtils.toJSONString(wfContextMap));
|
||||
}
|
||||
newWfInstance.setGmtCreate(now);
|
||||
newWfInstance.setGmtModified(now);
|
||||
return newWfInstance;
|
||||
|
Loading…
x
Reference in New Issue
Block a user