Announcement

Collapse
No announcement yet.

Unable to get ChannelName in Deploy Script

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

  • Unable to get ChannelName in Deploy Script

    Similar query to Anirudh in http://www.mirthcorp.com/community/f...ad.php?t=10809

    I have a code template function that I wish to run in the deploy script of channels:

    Code:
     
     function Load_Mappings(csvpath,mapname) {
     // write code here.
     //var channelName = Packages.com.mirth.connect.server.controllers.ChannelController.getInstance().getDeployedChannelById(channelId).getName();
     //var channelName = Packages.com.mirth.connect.server.controllers.ChannelController.getInstance().getDeployedChannelById(channelId).getName(); 
     //var channelName = "";
     //var channelName = ChannelUtil.getDeployedChannelName(channelId);
     var channelName = channelId;
      logger.info(channelName + " - Loading mappings for " + mapname + " from " + csvpath);
     globalChannelMap.put(mapname,{})
      for each (pair in org.apache.commons.io.FileUtils.readFileToString(new java.io.File(csvpath)).split('\r\n|\r|\n')) {
      if (!(pair.substring(0,1) == "#")) {
       //logger.info("first char = " + pair.substring(0,1));
       var newvalue = pair.split(',')[1];
       if (!newvalue) newvalue = ""; // convert undefined to empty string
       $gc(mapname)[pair.split(',')[0]] = newvalue;
       logger.info(channelName + " - Mapping " + mapname + " item [" + pair.split(',')[0] + "] to [" + newvalue + "]");
      }
     }
     return;
    }
    I know that the channelId is available here, but when I attempt to set

    Code:
    var channelName = ChannelUtil.getDeployedChannelName(channelId);
    the channelName is returned back as null, presumably because the channel has not actually been deployed at that point.

    Any idea how I can pull in the name of the channel?

    Simon

  • #2
    Actually, this seems to work:


    Code:
    function getChannelName(channelID) {
    var controller = com.mirth.connect.server.controllers.ControllerFactory.getFactory().createChannelController();
    var channelName = controller.getChannelById(channelID).name;
    return channelName;
    }
    but it would be nice if this function were possible using ChannelUtil

    Comment


    • #3
      Please see http://www.mirthcorp.com/community/i...wse/MIRTH-3315

      Comment


      • #4
        Originally posted by seaston View Post
        Seaston, quick question is there any way I can put globalChannelId's in channel Deploy script. I am working on the following requirement:

        1. Monitoring channel to check for queued messages.
        2. Each channel has its own threshold value.
        3. I am querying db to get channel ids and names.
        4. if(channelIdFromDB == globalMap.get(channelId){
        useGlobalMapIds.get values
        }
        else{
        default values
        }

        I am trying to figure out the best way to do as the monitoring channel has to compare the channelid's. Any thoughts..

        Comment


        • #5
          Not sure what you mean Anirudh.
          put globalChannelId's in channel Deploy script
          Do you mean that you want to put channelIds into the globalMap when the channels are deployed? Is this just because you want to loop though a list of deployed channels rather than read from the database?

          Simon

          Comment

          Working...
          X