@@ -39,12 +39,7 @@ func formatActivity(
3939 return formatAction (ctx , activity .Action , entityNames , microflowNames )
4040
4141 case * microflows.ExclusiveSplit :
42- condition := "true"
43- if activity .SplitCondition != nil {
44- if exprCond , ok := activity .SplitCondition .(* microflows.ExpressionSplitCondition ); ok {
45- condition = exprCond .Expression
46- }
47- }
42+ condition := formatSplitCondition (activity .SplitCondition )
4843 return fmt .Sprintf ("if %s then" , condition )
4944
5045 case * microflows.ExclusiveMerge :
@@ -1159,3 +1154,42 @@ func (e *Executor) formatListOperation(op microflows.ListOperation, outputVar st
11591154func (e * Executor ) formatRestCallAction (a * microflows.RestCallAction ) string {
11601155 return formatRestCallAction (e .newExecContext (context .Background ()), a )
11611156}
1157+
1158+ // formatSplitCondition renders an ExclusiveSplit's condition as an MDL expression.
1159+ // ExpressionSplitCondition is emitted verbatim. RuleSplitCondition is rendered as
1160+ // a rule call expression using the rule's qualified name — Mendix expressions
1161+ // allow calling a rule the same way as a microflow, so this is re-parseable.
1162+ // Unknown or nil conditions fall back to "true" so the describer still produces
1163+ // valid MDL; callers should rely on the original Caption (emitted via @caption)
1164+ // to preserve human-readable intent.
1165+ func formatSplitCondition (cond microflows.SplitCondition ) string {
1166+ switch c := cond .(type ) {
1167+ case * microflows.ExpressionSplitCondition :
1168+ expr := strings .TrimRight (c .Expression , " \t \n \r " )
1169+ if expr == "" {
1170+ return "true"
1171+ }
1172+ return expr
1173+ case * microflows.RuleSplitCondition :
1174+ name := c .RuleQualifiedName
1175+ if name == "" {
1176+ return "true"
1177+ }
1178+ args := make ([]string , 0 , len (c .ParameterMappings ))
1179+ for _ , pm := range c .ParameterMappings {
1180+ paramName := pm .ParameterName
1181+ if idx := strings .LastIndex (paramName , "." ); idx >= 0 {
1182+ paramName = paramName [idx + 1 :]
1183+ }
1184+ arg := strings .TrimRight (pm .Argument , " \t \n \r " )
1185+ if paramName != "" {
1186+ args = append (args , fmt .Sprintf ("%s = %s" , paramName , arg ))
1187+ } else {
1188+ args = append (args , arg )
1189+ }
1190+ }
1191+ return fmt .Sprintf ("%s(%s)" , name , strings .Join (args , ", " ))
1192+ default :
1193+ return "true"
1194+ }
1195+ }
0 commit comments