Announcement

Collapse
No announcement yet.

channlId in deploy script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • channlId in deploy script

    channelId doesn't seem to be working in deploy script when I am trying to put it in a globalMap. Sorry to add this is in mirth 3.0 version.
    I see the following error on the dashboard while deploying the channel

    [2014-06-02 20:17:31,951] ERROR (com.mirth.connect.server.controllers.DonkeyEngine Controller:174): Error executing global deploy script.
    com.mirth.connect.server.util.javascript.JavaScrip tExecutorException: com.mirth.connect.server.MirthJavascriptTransforme rException: SOURCE CODE:
    LINE NUMBER:
    6549DETAILS:
    ReferenceError: "channelId" is not defined.
    at Deploy:6549 (doScript)
    at Deploy:6555
    at com.mirth.connect.server.util.javascript.JavaScrip tUtil.execute(JavaScriptUtil.java:62)
    at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeGlobalDeployScript(JavaScriptUtil.jav a:395)
    at com.mirth.connect.server.controllers.DefaultScript Controller.executeGlobalDeployScript(DefaultScript Controller.java:137)
    at com.mirth.connect.server.controllers.DonkeyEngineC ontroller.deployChannels(DonkeyEngineController.ja va:172)
    at com.mirth.connect.server.servlets.EngineServlet.do Post(EngineServlet.java:64)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:820)
    at org.eclipse.jetty.servlet.ServletHolder.handle(Ser vletHolder.java:652)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle( ServletHandler.java:447)
    at org.eclipse.jetty.server.session.SessionHandler.do Handle(SessionHandler.java:225)
    at org.eclipse.jetty.server.handler.ContextHandler.do Handle(ContextHandler.java:1038)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(S ervletHandler.java:374)
    at org.eclipse.jetty.server.session.SessionHandler.do Scope(SessionHandler.java:189)
    at org.eclipse.jetty.server.handler.ContextHandler.do Scope(ContextHandler.java:972)
    at org.eclipse.jetty.server.handler.ScopedHandler.han dle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.HandlerList.handl e(HandlerList.java:52)
    at org.eclipse.jetty.server.handler.HandlerWrapper.ha ndle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java :363)
    at org.eclipse.jetty.server.AbstractHttpConnection.ha ndleRequest(AbstractHttpConnection.java:483)
    at org.eclipse.jetty.server.AbstractHttpConnection.co ntent(AbstractHttpConnection.java:931)
    at org.eclipse.jetty.server.AbstractHttpConnection$Re questHandler.content(AbstractHttpConnection.java:9 92)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpPa rser.java:856)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(H ttpParser.java:240)
    at org.eclipse.jetty.server.AsyncHttpConnection.handl e(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SslConnection.handle(SslC onnection.java:196)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.han dle(SelectChannelEndPoint.java:627)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.r un(SelectChannelEndPoint.java:51)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.run Job(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.r un(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:662)Caused by: com.mirth.connect.server.MirthJavascriptTransforme rException: SOURCE CODE:
    LINE NUMBER:
    6549DETAILS:
    ReferenceError: "channelId" is not defined.
    at Deploy:6549 (doScript)
    at Deploy:6555
    at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:490)
    at com.mirth.connect.server.util.javascript.JavaScrip tUtil$4.call(JavaScriptUtil.java:401)
    at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.jav a:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    ... 1 more
    Last edited by Anirudh; 06-02-2014, 12:23 PM.

  • #2
    That is expected. The global deploy script is channel-agnostic; it runs once whenever you deploy one or more channels. Therefore, you don't have access to the "channelId" variable in there.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


    • #3
      Thanks for the reply. Is there any other way that I can put channelId in a global Map

      Comment


      • #4
        Originally posted by Anirudh View Post
        Thanks for the reply. Is there any other way that I can put channelId in a global Map
        A channel's deploy script has access to the channel ID, so you can do whatever you need there. If you're going to be reusing the same code in multiple channels, it'd probably make sense to use a code template.
        Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

        Nicholas Rupley
        Work: 949-237-6069
        Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


        - How do I foo?
        - You just bar.

        Comment


        • #5
          Originally posted by narupley View Post
          A channel's deploy script has access to the channel ID, so you can do whatever you need there. If you're going to be reusing the same code in multiple channels, it'd probably make sense to use a code template.
          I did see the channelId variable is accessible through deploy script when I place it in a global map

          globalMap.put('ADT-CHANNELID',channelId);

          I am trying to use the channelId in one of the other channels. The only way I can use the channelId is getting the value from globalMap. Any other suggestions are welcome.

          Comment


          • #6
            I don't quite understand what you're trying to do. Maybe try rephrasing your question, with more clear examples?
            Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

            Nicholas Rupley
            Work: 949-237-6069
            Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


            - How do I foo?
            - You just bar.

            Comment


            • #7
              Originally posted by narupley View Post
              I don't quite understand what you're trying to do. Maybe try rephrasing your question, with more clear examples?
              Sorry for the late response. Below is what I am trying to do:

              1. Reading channel id's and channel name's from database.
              2. Once I have the channel Id's from the database I am planning to compare the with the channelId's of the channels which are deployed.
              3. Each channel has a set of global maps which I will be using as a part of monitoring channel.
              4. If the channelId matches use the global maps of the channel this is where I require globalMap of channel id's of the channel.

              If there is any other way that I can get channelId's in a global map that can be used by a channel that would be great.

              Comment


              • #8
                Nick, How can I get the globalMaps from a channel based on ChannelID. Any inputs please.

                Comment


                • #9
                  You mean the globalChannelMaps from another channel? e.g.

                  Code:
                  var myChannelId = "15aad193-8205-476b-8d05-4db4c0532c77";
                  var otherChannelglobalChannelMap = com.mirth.connect.server.util.GlobalChannelVariableStoreFactory.getInstance().get(myChannelId).getVariables();
                  
                  logger.info(otherChannelglobalChannelMap.get("test"));

                  Comment


                  • #10
                    Thanks Seaston I will try this one out .I am trying to get GlobalMaps from all the channels and if there is a variable defined in global map I will use it otherwise I will use default value. Will give this a try.

                    Comment


                    • #11
                      Originally posted by seaston View Post
                      You mean the globalChannelMaps from another channel? e.g.

                      Code:
                      var myChannelId = "15aad193-8205-476b-8d05-4db4c0532c77";
                      var otherChannelglobalChannelMap = com.mirth.connect.server.util.GlobalChannelVariableStoreFactory.getInstance().get(myChannelId).getVariables();
                      
                      logger.info(otherChannelglobalChannelMap.get("test"));
                      Hey, your solution doesn't see to work right. Let me know if know I am missing anything.

                      var myChannelId = result.getString("ID").trim().toString();
                      var otherChannelglobalChannelMap = com.mirth.connect.server.util.GlobalChannelVariabl eStoreFactory.getInstance().get(myChannelId).getVa riables();
                      logger.info(otherChannelglobalChannelMap.get(myCha nnelId));

                      Logger doesn't show any values.

                      Comment


                      • #12
                        Are you sure you have a map variable saved that is the same as the channel ID?

                        Once you have set 'otherChannelglobalChannelMap' you should be able to get any values set within this map. It worked for me.

                        Comment


                        • #13
                          Just put
                          Code:
                          logger.info(otherChannelglobalChannelMap);
                          and see if anything shows up?

                          Comment


                          • #14
                            Each channel has a global map in deploy script. Do I need to place the channelId in deploy script to get all the global map variables ?

                            I have this in the deploy script for a channel.

                            globalMap.put('MessageThreshold',10);
                            globalMap.put('Female',F);

                            Comment


                            • #15
                              I see empty braces

                              [2014-06-03 20:46:58,775] INFO (js-connector:?): {}

                              Comment

                              Working...
                              X