in src/main/java/com/uber/cadence/internal/replay/WorkflowDecisionContext.java [99:174]
Consumer<Exception> startChildWorkflow(
StartChildWorkflowExecutionParameters parameters,
Consumer<WorkflowExecution> executionCallback,
BiConsumer<byte[], Exception> callback) {
final StartChildWorkflowExecutionDecisionAttributes attributes =
new StartChildWorkflowExecutionDecisionAttributes();
attributes.setWorkflowType(parameters.getWorkflowType());
String workflowId = parameters.getWorkflowId();
if (workflowId == null) {
workflowId = randomUUID().toString();
}
attributes.setWorkflowId(workflowId);
if (parameters.getDomain() == null) {
// Could be removed as soon as server allows null for domain.
attributes.setDomain(workflowContext.getDomain());
} else {
attributes.setDomain(parameters.getDomain());
}
attributes.setInput(parameters.getInput());
if (parameters.getExecutionStartToCloseTimeoutSeconds() == 0) {
// TODO: Substract time passed since the parent start
attributes.setExecutionStartToCloseTimeoutSeconds(
workflowContext.getExecutionStartToCloseTimeoutSeconds());
} else {
attributes.setExecutionStartToCloseTimeoutSeconds(
(int) parameters.getExecutionStartToCloseTimeoutSeconds());
}
if (parameters.getTaskStartToCloseTimeoutSeconds() == 0) {
attributes.setTaskStartToCloseTimeoutSeconds(workflowContext.getDecisionTaskTimeoutSeconds());
} else {
attributes.setTaskStartToCloseTimeoutSeconds(
(int) parameters.getTaskStartToCloseTimeoutSeconds());
}
String taskList = parameters.getTaskList();
TaskList tl = new TaskList();
if (taskList != null && !taskList.isEmpty()) {
tl.setName(taskList);
} else {
tl.setName(workflowContext.getTaskList());
}
attributes.setTaskList(tl);
attributes.setWorkflowIdReusePolicy(parameters.getWorkflowIdReusePolicy());
RetryParameters retryParameters = parameters.getRetryParameters();
if (retryParameters != null) {
attributes.setRetryPolicy(retryParameters.toRetryPolicy());
}
if (!Strings.isNullOrEmpty(parameters.getCronSchedule())) {
attributes.setCronSchedule(parameters.getCronSchedule());
}
attributes.setHeader(toHeaderThrift(parameters.getContext()));
ParentClosePolicy parentClosePolicy = parameters.getParentClosePolicy();
if (parentClosePolicy != null) {
attributes.setParentClosePolicy(parentClosePolicy);
}
Map<String, Object> memoMap = parameters.getMemo();
if (memoMap != null) {
attributes.setMemo(InternalUtils.convertMapToMemo(memoMap));
}
Map<String, Object> searchAttributesMap = parameters.getSearchAttributes();
if (searchAttributesMap != null) {
attributes.setSearchAttributes(
InternalUtils.convertMapToSearchAttributes(searchAttributesMap));
}
long initiatedEventId = decisions.startChildWorkflowExecution(attributes);
final OpenChildWorkflowRequestInfo context =
new OpenChildWorkflowRequestInfo(executionCallback);
context.setCompletionHandle(callback);
scheduledExternalWorkflows.put(initiatedEventId, context);
return new ChildWorkflowCancellationHandler(initiatedEventId, attributes.getWorkflowId());
}