|
4 | 4 | package executor |
5 | 5 |
|
6 | 6 | import ( |
| 7 | + "encoding/base64" |
7 | 8 | "fmt" |
8 | 9 | "log" |
9 | 10 | "strings" |
@@ -437,6 +438,86 @@ func (fb *flowBuilder) addCallJavaScriptActionAction(s *ast.CallJavaScriptAction |
437 | 438 | return activity.ID |
438 | 439 | } |
439 | 440 |
|
| 441 | +// addCallWebServiceAction creates a legacy SOAP WebServiceCallAction. |
| 442 | +func (fb *flowBuilder) addCallWebServiceAction(s *ast.CallWebServiceStmt) model.ID { |
| 443 | + activityX := fb.posX |
| 444 | + action := µflows.WebServiceCallAction{ |
| 445 | + BaseElement: model.BaseElement{ID: model.ID(types.GenerateID())}, |
| 446 | + ErrorHandlingType: convertErrorHandlingType(s.ErrorHandling), |
| 447 | + ServiceID: model.ID(s.ServiceID), |
| 448 | + OperationName: s.OperationName, |
| 449 | + SendMappingID: model.ID(fb.resolveMappingRefForWrite(s.SendMappingID, true)), |
| 450 | + ReceiveMappingID: model.ID(fb.resolveMappingRefForWrite(s.ReceiveMappingID, false)), |
| 451 | + OutputVariable: s.OutputVariable, |
| 452 | + UseReturnVariable: s.OutputVariable != "", |
| 453 | + } |
| 454 | + if s.RawBSONBase64 != "" { |
| 455 | + raw, err := base64.StdEncoding.DecodeString(s.RawBSONBase64) |
| 456 | + if err != nil { |
| 457 | + fb.addError("invalid raw web service action payload: %v", err) |
| 458 | + } else { |
| 459 | + action.RawBSON = raw |
| 460 | + } |
| 461 | + } |
| 462 | + if s.Timeout != nil { |
| 463 | + action.TimeoutExpression = fb.exprToString(s.Timeout) |
| 464 | + } |
| 465 | + |
| 466 | + activity := µflows.ActionActivity{ |
| 467 | + BaseActivity: microflows.BaseActivity{ |
| 468 | + BaseMicroflowObject: microflows.BaseMicroflowObject{ |
| 469 | + BaseElement: model.BaseElement{ID: model.ID(types.GenerateID())}, |
| 470 | + Position: model.Point{X: fb.posX, Y: fb.posY}, |
| 471 | + Size: model.Size{Width: ActivityWidth, Height: ActivityHeight}, |
| 472 | + }, |
| 473 | + AutoGenerateCaption: true, |
| 474 | + ErrorHandlingType: convertErrorHandlingType(s.ErrorHandling), |
| 475 | + }, |
| 476 | + Action: action, |
| 477 | + } |
| 478 | + |
| 479 | + fb.objects = append(fb.objects, activity) |
| 480 | + fb.posX += fb.spacing |
| 481 | + |
| 482 | + if s.OutputVariable != "" && fb.declaredVars != nil { |
| 483 | + fb.declaredVars[s.OutputVariable] = "Unknown" |
| 484 | + } |
| 485 | + |
| 486 | + if s.ErrorHandling != nil && len(s.ErrorHandling.Body) > 0 { |
| 487 | + errorY := fb.posY + VerticalSpacing |
| 488 | + mergeID := fb.addErrorHandlerFlow(activity.ID, activityX, s.ErrorHandling.Body) |
| 489 | + fb.handleErrorHandlerMerge(mergeID, activity.ID, errorY) |
| 490 | + } |
| 491 | + |
| 492 | + return activity.ID |
| 493 | +} |
| 494 | + |
| 495 | +func (fb *flowBuilder) resolveMappingRefForWrite(ref string, preferExport bool) string { |
| 496 | + if ref == "" || !strings.Contains(ref, ".") || fb.backend == nil { |
| 497 | + return ref |
| 498 | + } |
| 499 | + moduleName, name, ok := strings.Cut(ref, ".") |
| 500 | + if !ok || moduleName == "" || name == "" { |
| 501 | + return ref |
| 502 | + } |
| 503 | + if preferExport { |
| 504 | + if mapping, err := fb.backend.GetExportMappingByQualifiedName(moduleName, name); err == nil && mapping != nil { |
| 505 | + return string(mapping.ID) |
| 506 | + } |
| 507 | + if mapping, err := fb.backend.GetImportMappingByQualifiedName(moduleName, name); err == nil && mapping != nil { |
| 508 | + return string(mapping.ID) |
| 509 | + } |
| 510 | + } else { |
| 511 | + if mapping, err := fb.backend.GetImportMappingByQualifiedName(moduleName, name); err == nil && mapping != nil { |
| 512 | + return string(mapping.ID) |
| 513 | + } |
| 514 | + if mapping, err := fb.backend.GetExportMappingByQualifiedName(moduleName, name); err == nil && mapping != nil { |
| 515 | + return string(mapping.ID) |
| 516 | + } |
| 517 | + } |
| 518 | + return ref |
| 519 | +} |
| 520 | + |
440 | 521 | // addCallExternalActionAction creates a CALL EXTERNAL ACTION statement. |
441 | 522 | func (fb *flowBuilder) addCallExternalActionAction(s *ast.CallExternalActionStmt) model.ID { |
442 | 523 | serviceQN := s.ServiceName.Module + "." + s.ServiceName.Name |
|
0 commit comments