|
| 1 | +-- ============================================================================ |
| 2 | +-- Bug #352 (part): Java action result variable type inference |
| 3 | +-- ============================================================================ |
| 4 | +-- |
| 5 | +-- Symptom (before fix): |
| 6 | +-- The microflow builder looked up Java action definitions to format |
| 7 | +-- entity-typed parameters, but it did NOT register the Java action's |
| 8 | +-- return type on the output variable. Subsequent statements that |
| 9 | +-- touched the result (`change`, `commit`, `$Result/Attribute`, |
| 10 | +-- association paths) had no type info, so: |
| 11 | +-- - the writer fell back to untyped expressions |
| 12 | +-- - `mx check` could surface CE0117 on dependent activities |
| 13 | +-- - describe re-emitted the call without the right variable |
| 14 | +-- declaration shape |
| 15 | +-- |
| 16 | +-- After fix: |
| 17 | +-- `addCallJavaActionAction` consults the Java action's `ReturnType` |
| 18 | +-- and registers the output variable as the appropriate object/list |
| 19 | +-- type (`Module.Entity`, `List of Module.Entity`, `System.FileDocument`, |
| 20 | +-- etc.) so downstream activities resolve correctly. |
| 21 | +-- |
| 22 | +-- Usage: |
| 23 | +-- mxcli exec mdl-examples/bug-tests/352-java-action-return-type-inference.mdl -p app.mpr |
| 24 | +-- mxcli -p app.mpr -c "describe microflow BugTest352b.MF_UseJavaResult" |
| 25 | +-- `mx check` against the resulting MPR must report 0 errors. |
| 26 | +-- ============================================================================ |
| 27 | + |
| 28 | +create module BugTest352b; |
| 29 | + |
| 30 | +create persistent entity BugTest352b.LogEntry ( |
| 31 | + Message : string(500) |
| 32 | +); |
| 33 | +/ |
| 34 | + |
| 35 | +-- Java action returning an entity object — the result variable type must |
| 36 | +-- be inferred so downstream `change` / `commit` resolve. |
| 37 | +create java action BugTest352b.CreateLogEntry ( |
| 38 | + Msg: string not null |
| 39 | +) returns BugTest352b.LogEntry |
| 40 | +as $$ |
| 41 | +return new com.mendix.systemwideinterfaces.core.IMendixObject(); |
| 42 | +$$; |
| 43 | +/ |
| 44 | + |
| 45 | +-- Caller microflow that depends on the inferred return type. The change |
| 46 | +-- statement on `$Entry/Message` would fail validation if the Java action |
| 47 | +-- result variable type is not registered. |
| 48 | +create microflow BugTest352b.MF_UseJavaResult ( |
| 49 | + $Msg: string |
| 50 | +) |
| 51 | +returns BugTest352b.LogEntry as $Entry |
| 52 | +begin |
| 53 | + $Entry = call java action BugTest352b.CreateLogEntry (Msg = $Msg); |
| 54 | + change $Entry (Message = $Msg + ' (processed)'); |
| 55 | +end; |
| 56 | +/ |
0 commit comments