3333import com .uber .m3 .tally .Scope ;
3434import io .grpc .Deadline ;
3535import io .grpc .Status ;
36+ import io .temporal .api .command .v1 .Command ;
3637import io .temporal .api .common .v1 .Payloads ;
3738import io .temporal .api .common .v1 .WorkflowExecution ;
38- import io .temporal .api .decision .v1 .Decision ;
39- import io .temporal .api .enums .v1 .DecisionType ;
39+ import io .temporal .api .enums .v1 .CommandType ;
4040import io .temporal .api .enums .v1 .EventType ;
4141import io .temporal .api .enums .v1 .HistoryEventFilterType ;
4242import io .temporal .api .enums .v1 .RetryState ;
8888public class WorkflowExecutionUtils {
8989
9090 /**
91- * Indentation for history and decisions pretty printing. Do not change it from 2 spaces. The gson
91+ * Indentation for history and commands pretty printing. Do not change it from 2 spaces. The gson
9292 * pretty printer has it hardcoded and changing it breaks the indentation of exception stack
9393 * traces.
9494 */
@@ -173,7 +173,7 @@ private static Optional<Payloads> getResultFromCloseEvent(
173173 WorkflowExecutionFailedEventAttributes failed =
174174 closeEvent .getWorkflowExecutionFailedEventAttributes ();
175175 throw new WorkflowExecutionFailedException (
176- failed .getFailure (), failed .getDecisionTaskCompletedEventId (), failed .getRetryState ());
176+ failed .getFailure (), failed .getWorkflowTaskCompletedEventId (), failed .getRetryState ());
177177 case EVENT_TYPE_WORKFLOW_EXECUTION_TERMINATED :
178178 WorkflowExecutionTerminatedEventAttributes terminated =
179179 closeEvent .getWorkflowExecutionTerminatedEventAttributes ();
@@ -413,13 +413,13 @@ public static boolean isWorkflowExecutionCompletedEvent(HistoryEventOrBuilder ev
413413 || event .getEventType () == EventType .EVENT_TYPE_WORKFLOW_EXECUTION_TERMINATED ));
414414 }
415415
416- public static boolean isWorkflowExecutionCompleteDecision ( Decision decision ) {
417- return ((decision != null )
418- && (decision . getDecisionType () == DecisionType . DECISION_TYPE_COMPLETE_WORKFLOW_EXECUTION
419- || decision . getDecisionType () == DecisionType . DECISION_TYPE_CANCEL_WORKFLOW_EXECUTION
420- || decision . getDecisionType () == DecisionType . DECISION_TYPE_FAIL_WORKFLOW_EXECUTION
421- || decision . getDecisionType ()
422- == DecisionType . DECISION_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION ));
416+ public static boolean isWorkflowExecutionCompleteCommand ( Command command ) {
417+ return ((command != null )
418+ && (command . getCommandType () == CommandType . COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION
419+ || command . getCommandType () == CommandType . COMMAND_TYPE_CANCEL_WORKFLOW_EXECUTION
420+ || command . getCommandType () == CommandType . COMMAND_TYPE_FAIL_WORKFLOW_EXECUTION
421+ || command . getCommandType ()
422+ == CommandType . COMMAND_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION ));
423423 }
424424
425425 public static boolean isActivityTaskClosedEvent (HistoryEvent event ) {
@@ -678,7 +678,7 @@ public static String prettyPrintHistory(
678678 /**
679679 * Returns workflow instance history in a human readable format.
680680 *
681- * @param showWorkflowTasks when set to false workflow task events (decider events) are not
681+ * @param showWorkflowTasks when set to false workflow task events (command events) are not
682682 * included
683683 * @param metricsScope
684684 */
@@ -731,7 +731,7 @@ private void getNextPage() {
731731 /**
732732 * Returns workflow instance history in a human readable format.
733733 *
734- * @param showWorkflowTasks when set to false workflow task events (decider events) are not
734+ * @param showWorkflowTasks when set to false workflow task events (command events) are not
735735 * included
736736 * @param history Workflow instance history
737737 */
@@ -752,10 +752,10 @@ public static String prettyPrintHistory(
752752 return result .toString ();
753753 }
754754
755- public static String prettyPrintDecisions (Iterable <Decision > decisions ) {
755+ public static String prettyPrintCommands (Iterable <Command > commands ) {
756756 StringBuilder result = new StringBuilder ();
757- for (Decision decision : decisions ) {
758- result .append (prettyPrintObject (decision ));
757+ for (Command command : commands ) {
758+ result .append (prettyPrintObject (command ));
759759 }
760760 return result .toString ();
761761 }
@@ -791,8 +791,8 @@ private static void fixStackTrace(JsonElement json, String stackIndentation) {
791791 }
792792 }
793793
794- /** Is this an event that was created to mirror a decision ? */
795- public static boolean isDecisionEvent (HistoryEvent event ) {
794+ /** Is this an event that was created to mirror a command ? */
795+ public static boolean isCommandEvent (HistoryEvent event ) {
796796 EventType eventType = event .getEventType ();
797797 boolean result =
798798 ((event != null )
@@ -815,36 +815,36 @@ public static boolean isDecisionEvent(HistoryEvent event) {
815815 return result ;
816816 }
817817
818- public static EventType getEventTypeForDecision ( DecisionType decisionType ) {
819- switch (decisionType ) {
820- case DECISION_TYPE_SCHEDULE_ACTIVITY_TASK :
818+ public static EventType getEventTypeForCommand ( CommandType commandType ) {
819+ switch (commandType ) {
820+ case COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK :
821821 return EventType .EVENT_TYPE_ACTIVITY_TASK_SCHEDULED ;
822- case DECISION_TYPE_REQUEST_CANCEL_ACTIVITY_TASK :
822+ case COMMAND_TYPE_REQUEST_CANCEL_ACTIVITY_TASK :
823823 return EventType .EVENT_TYPE_ACTIVITY_TASK_CANCEL_REQUESTED ;
824- case DECISION_TYPE_START_TIMER :
824+ case COMMAND_TYPE_START_TIMER :
825825 return EventType .EVENT_TYPE_TIMER_STARTED ;
826- case DECISION_TYPE_COMPLETE_WORKFLOW_EXECUTION :
826+ case COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION :
827827 return EventType .EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED ;
828- case DECISION_TYPE_FAIL_WORKFLOW_EXECUTION :
828+ case COMMAND_TYPE_FAIL_WORKFLOW_EXECUTION :
829829 return EventType .EVENT_TYPE_WORKFLOW_EXECUTION_FAILED ;
830- case DECISION_TYPE_CANCEL_TIMER :
830+ case COMMAND_TYPE_CANCEL_TIMER :
831831 return EventType .EVENT_TYPE_TIMER_CANCELED ;
832- case DECISION_TYPE_CANCEL_WORKFLOW_EXECUTION :
832+ case COMMAND_TYPE_CANCEL_WORKFLOW_EXECUTION :
833833 return EventType .EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED ;
834- case DECISION_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION :
834+ case COMMAND_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION :
835835 return EventType .EVENT_TYPE_EXTERNAL_WORKFLOW_EXECUTION_CANCEL_REQUESTED ;
836- case DECISION_TYPE_RECORD_MARKER :
836+ case COMMAND_TYPE_RECORD_MARKER :
837837 return EventType .EVENT_TYPE_MARKER_RECORDED ;
838- case DECISION_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION :
838+ case COMMAND_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION :
839839 return EventType .EVENT_TYPE_WORKFLOW_EXECUTION_CONTINUED_AS_NEW ;
840- case DECISION_TYPE_START_CHILD_WORKFLOW_EXECUTION :
840+ case COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION :
841841 return EventType .EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED ;
842- case DECISION_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION :
842+ case COMMAND_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION :
843843 return EventType .EVENT_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED ;
844- case DECISION_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES :
844+ case COMMAND_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES :
845845 return EventType .EVENT_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES ;
846846 }
847- throw new IllegalArgumentException ("Unknown decisionType " );
847+ throw new IllegalArgumentException ("Unknown commandType " );
848848 }
849849
850850 public static WorkflowExecutionHistory readHistoryFromResource (String resourceFileName )
0 commit comments