Mirth Connect
  1. Mirth Connect
  2. MIRTH-3150

Code template inclusion is no longer restricted by the template scope (Message/Channel/etc.)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.0, 3.0.1
    • Fix Version/s: 3.0.2
    • Component/s: Server
    • Labels:
      None

      Description

      In 2.x, the inclusion/exclusion of certain context types was different across the board. Some scripts included all functions, some didn't. Currently in 3.x, all function code templates are being included all the time. So in general it shouldn't cause any problems, but it's still possible for things to break from 2.x to 3.x if the user was dependent on certain templates not being included in certain scopes. Remember that you don't have to only include function definitions in a function code template. You can include any arbitrary code you want, and that code will be compiled in with your channel's scripts, such that when the scripts run, the code template code will also run.

      I think part of this may be figuring out / deciding what the different context types should mean (MIRTH-1547).

        Issue Links

          Activity

          Hide
          Nick Rupley added a comment -

          So the comparison being done in appendCodeTemplates appears to be correct now, but the bigger problem is that the actual context used is always Global. Instead compileAndAddScript in JSU should take in the context, and each place that needs to compile scripts should be explicitly passing it in.

          Show
          Nick Rupley added a comment - So the comparison being done in appendCodeTemplates appears to be correct now, but the bigger problem is that the actual context used is always Global. Instead compileAndAddScript in JSU should take in the context, and each place that needs to compile scripts should be explicitly passing it in.
          Hide
          Nick Rupley added a comment -

          Revision 7125: Fixed function code template inclusion so that it works the same as it did in 2.x. The only differences are that Channel code templates are now available in the channel deploy/shutdown/preprocessor/batch scripts where they weren't available before. The attachment script (new in 3.x) allows Channel or higher, and the response transformer (also new) allows Message or higher (i.e. all templates).

          In the global scripts panel, we're now actually restricting the available templates shown in the UI to only Global Channel or Global. This is because although Channel templates are available for the postprocessor, they aren't available for the other scripts, and the panel doesn't differentiate between different script types when showing the reference list.

          To hopefully make it a bit easier to understand, here's what 2.x allowed:

          Script Message Channel Global Channel Global
          Global scripts (-post) N N Y Y
          Global postprocessor N Y Y Y
          Channel scripts (-post) N N Y Y
          Channel postprocessor N Y Y Y
          Batch N N Y Y
          Filter/Transformer Y Y Y Y
          JavaScript Reader Y Y Y Y
          JavaScript Writer Y Y Y Y
          Database Reader Y Y Y Y
          Database Writer Y Y Y Y
          Database Reader ACK Y Y Y Y


          And here's what 3.0.2 will allow:

          Script Message Channel Global Channel Global
          Global scripts (-post) N N Y Y
          Global postprocessor N Y Y Y
          Channel scripts (-post) N Y Y Y
          Channel postprocessor N Y Y Y
          Attachment N Y Y Y
          Batch N Y Y Y
          Filter/Transformer Y Y Y Y
          Response Transformer Y Y Y Y
          JavaScript Reader Y Y Y Y
          JavaScript Writer Y Y Y Y
          Database Reader Y Y Y Y
          Database Writer Y Y Y Y
          Database Reader ACK Y Y Y Y
          Show
          Nick Rupley added a comment - Revision 7125: Fixed function code template inclusion so that it works the same as it did in 2.x. The only differences are that Channel code templates are now available in the channel deploy/shutdown/preprocessor/batch scripts where they weren't available before. The attachment script (new in 3.x) allows Channel or higher, and the response transformer (also new) allows Message or higher (i.e. all templates). In the global scripts panel, we're now actually restricting the available templates shown in the UI to only Global Channel or Global. This is because although Channel templates are available for the postprocessor, they aren't available for the other scripts, and the panel doesn't differentiate between different script types when showing the reference list. To hopefully make it a bit easier to understand, here's what 2.x allowed: Script Message Channel Global Channel Global Global scripts (-post) N N Y Y Global postprocessor N Y Y Y Channel scripts (-post) N N Y Y Channel postprocessor N Y Y Y Batch N N Y Y Filter/Transformer Y Y Y Y JavaScript Reader Y Y Y Y JavaScript Writer Y Y Y Y Database Reader Y Y Y Y Database Writer Y Y Y Y Database Reader ACK Y Y Y Y And here's what 3.0.2 will allow: Script Message Channel Global Channel Global Global scripts (-post) N N Y Y Global postprocessor N Y Y Y Channel scripts (-post) N Y Y Y Channel postprocessor N Y Y Y Attachment N Y Y Y Batch N Y Y Y Filter/Transformer Y Y Y Y Response Transformer Y Y Y Y JavaScript Reader Y Y Y Y JavaScript Writer Y Y Y Y Database Reader Y Y Y Y Database Writer Y Y Y Y Database Reader ACK Y Y Y Y
          Hide
          Wayne Huang (Inactive) added a comment -

          Verified

          Show
          Wayne Huang (Inactive) added a comment - Verified
          Hide
          Sticky Bandit added a comment -

          So why not just set them all to global? What is being gained by shortening the scope?

          Show
          Sticky Bandit added a comment - So why not just set them all to global? What is being gained by shortening the scope?
          Hide
          Nick Rupley added a comment -

          Certain templates only make sense within the context of a filter or transformer script, specifically ones having to do with mapping E4X fields to or from msg/tmp. So it's just meant for convenience, and so that all code templates aren't necessarily compiled in with all scripts. Currently Message-context code templates aren't compiled in with the channel/global scripts (pre/post/deploy/shutdown). If you set everything to global, then they will get included unnecessarily.

          And just to clarify, no scopes were shortened; if anything they were expanded because the batch script and channel postprocessor scripts now have access to Channel-context code templates.

          Show
          Nick Rupley added a comment - Certain templates only make sense within the context of a filter or transformer script, specifically ones having to do with mapping E4X fields to or from msg/tmp. So it's just meant for convenience, and so that all code templates aren't necessarily compiled in with all scripts. Currently Message-context code templates aren't compiled in with the channel/global scripts (pre/post/deploy/shutdown). If you set everything to global, then they will get included unnecessarily. And just to clarify, no scopes were shortened; if anything they were expanded because the batch script and channel postprocessor scripts now have access to Channel-context code templates.

            People

            • Assignee:
              Nick Rupley
              Reporter:
              Nick Rupley
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development