@@ -47,12 +47,7 @@ public WorkflowStateStartResponse handleWorkflowStateStart(final WorkflowStateSt
4747 final Object input = workerOptions .getObjectEncoder ().decode (stateInput , state .getWorkflowState ().getInputType ());
4848 final DataObjectsRWImpl dataObjectsRW =
4949 createDataObjectsRW (req .getWorkflowType (), req .getDataObjects ());
50- final Context context = ImmutableContext .builder ()
51- .workflowId (req .getContext ().getWorkflowId ())
52- .workflowRunId (req .getContext ().getWorkflowRunId ())
53- .workflowStartTimestampSeconds (req .getContext ().getWorkflowStartedTimestamp ())
54- .stateExecutionId (req .getContext ().getStateExecutionId ())
55- .build ();
50+ final Context context = fromIdlContext (req .getContext ());
5651 final StateLocalsImpl stateLocals = new StateLocalsImpl (toMap (null ), workerOptions .getObjectEncoder ());
5752 final Map <String , SearchAttributeValueType > saTypeMap = registry .getSearchAttributeKeyToTypeMap (req .getWorkflowType ());
5853 final SearchAttributeRWImpl searchAttributeRW = new SearchAttributeRWImpl (saTypeMap , req .getSearchAttributes ());
@@ -113,12 +108,7 @@ public WorkflowStateDecideResponse handleWorkflowStateDecide(final WorkflowState
113108 final DataObjectsRWImpl dataObjectsRW =
114109 createDataObjectsRW (req .getWorkflowType (), req .getDataObjects ());
115110
116- final Context context = ImmutableContext .builder ()
117- .workflowId (req .getContext ().getWorkflowId ())
118- .workflowRunId (req .getContext ().getWorkflowRunId ())
119- .workflowStartTimestampSeconds (req .getContext ().getWorkflowStartedTimestamp ())
120- .stateExecutionId (req .getContext ().getStateExecutionId ())
121- .build ();
111+ final Context context = fromIdlContext (req .getContext ());
122112 final StateLocalsImpl stateLocals = new StateLocalsImpl (toMap (req .getStateLocals ()), workerOptions .getObjectEncoder ());
123113 final Map <String , SearchAttributeValueType > saTypeMap = registry .getSearchAttributeKeyToTypeMap (req .getWorkflowType ());
124114 final SearchAttributeRWImpl searchAttributeRW = new SearchAttributeRWImpl (saTypeMap , req .getSearchAttributes ());
@@ -250,4 +240,25 @@ private List<SearchAttribute> createUpsertSearchAttributes(
250240 });
251241 return sas ;
252242 }
243+
244+ private Context fromIdlContext (final io .iworkflow .gen .models .Context context ) {
245+ int attempt = -1 ; //unsupported
246+ if (context .getAttempt () != null ) {
247+ attempt = context .getAttempt ();
248+ }
249+ long firstAttemptTimestamp = -1 ; //unsupported
250+ if (context .getFirstAttemptTimestamp () != null ) {
251+ firstAttemptTimestamp = context .getFirstAttemptTimestamp ();
252+ }
253+
254+ return ImmutableContext .builder ()
255+ .workflowId (context .getWorkflowId ())
256+ .workflowRunId (context .getWorkflowRunId ())
257+ .workflowStartTimestampSeconds (context .getWorkflowStartedTimestamp ())
258+ .stateExecutionId (context .getStateExecutionId ())
259+ .attempt (attempt )
260+ .firstAttemptTimestampSeconds (firstAttemptTimestamp )
261+ .build ();
262+ }
253263}
264+
0 commit comments