web stats
Unable to get ChannelName in Deploy Script - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-03-2014, 08:20 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 06-03-2014, 08:31 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

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
Reply With Quote
  #3  
Old 06-03-2014, 09:17 AM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

Please see http://www.mirthcorp.com/community/i...wse/MIRTH-3315
Reply With Quote
  #4  
Old 06-03-2014, 11:42 AM
Anirudh Anirudh is offline
OBX.3 Kenobi
 
Join Date: Sep 2012
Posts: 135
Anirudh is on a distinguished road
Default

Quote:
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..
Reply With Quote
  #5  
Old 06-03-2014, 02:11 PM
seaston seaston is offline
OBX.3 Kenobi
 
Join Date: Feb 2010
Location: London, UK
Posts: 168
seaston is on a distinguished road
Default

Not sure what you mean Anirudh.
Quote:
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
Reply With Quote
Reply

Tags
channelid, deploy

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:01 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation