web stats
ChannelUtil.getDeployedChannelIds() - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-10-2019, 01:20 PM
SeanSpeer SeanSpeer is offline
Mirth Newb
 
Join Date: Nov 2016
Posts: 11
SeanSpeer is on a distinguished road
Default ChannelUtil.getDeployedChannelIds()

I have been all over this forum and can't find a way to accomplish what I'm looking to accomplish.

I want to be able to pull all of the deployed channel ID's and populate a database.

When using the ChannelUtil.getDeployedChannelIds() in a source or destination transformer like so:

var guidList = ChannelUtil.getDeployedChannelIds();

I get this result: guidList: [3a9154ae-eb66-443e-ad82-3e69d1deba7c, 119cdd7d-bc60-457e-8b77-50001f59b177, 5ceafcb6-b259-4d72-93d3-3f85bbbd81b5, a852286a-3894-49c5-9dc4-f4c58c74c48f, 6beb50c4-61f6-4601-bdf3-50a2c244e7cb, 74bce66e-b50a-4b6a-9b35-e401d186e694, 588a90a7-886b-4f4d-93e7-2ed1c61c2687]

I don't know what this is as I can't use it as an array. I was looking to have an array and iterated through that array into a db.

Thoughts?
Reply With Quote
  #2  
Old 10-10-2019, 01:27 PM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,298
cory_cole is on a distinguished road
Default

That is a list of the channels (GUID). It is comma delimited. Do you know that there is already a table with all of the channels?
Reply With Quote
  #3  
Old 10-10-2019, 01:33 PM
SeanSpeer SeanSpeer is offline
Mirth Newb
 
Join Date: Nov 2016
Posts: 11
SeanSpeer is on a distinguished road
Default

Thx Cory... yes, I know of this table. I was wondering how to do it with this ChannelUtil.getDeployedChannelIds() if it would be easier to do some custom reporting that I am interested in.

My plan was to use the ChannelUtil as versus pulling the XML from the mirthdb, parsing through and capturing my data and then posting it to the custom DB where I was going to do dynamic reporting. I will be capturing other aspects of the ChannelUtil calls. Those are easy tho because they are all a single value.

I reckon that I would pull that string in and split it on the <comma><space> and put that into an array?

Not sure how that is all done. I've been trying but I'm not successful.

Thx!
Reply With Quote
  #4  
Old 10-10-2019, 01:39 PM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,298
cory_cole is on a distinguished road
Default

There is also a getChannelById() that will give you name of the channel base on those GUIDs.

Do keep in mind that if you delete channel and recreate it. Or create a clone and delete the channel, that ID changes.
Reply With Quote
  #5  
Old 10-10-2019, 02:05 PM
SeanSpeer SeanSpeer is offline
Mirth Newb
 
Join Date: Nov 2016
Posts: 11
SeanSpeer is on a distinguished road
Default

I can use the getChannelById() just fine. I can use any of the get*() when I pass the name through... what I can't seem to handle (insert joke here... I can handle it) is the call to any that return the static List<String>.
Reply With Quote
  #6  
Old 10-11-2019, 06:09 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 999
agermano is on a distinguished road
Default

It's a Java List. https://docs.oracle.com/javase/8/doc...util/List.html

You can iterate directly over the list like this:

Code:
for (var channelId in Iterator(ChannelUtil.getDeployedChannelIds())) {
    logger.info(channelId);
}
Or convert to a (Java, not javascript) array by calling:

Code:
var guidList = ChannelUtil.getDeployedChannelIds().toArray();
Reply With Quote
  #7  
Old 10-11-2019, 06:46 AM
SeanSpeer SeanSpeer is offline
Mirth Newb
 
Join Date: Nov 2016
Posts: 11
SeanSpeer is on a distinguished road
Default

Code:
for (var channelId in Iterator(ChannelUtil.getDeployedChannelIds())) {
    logger.info(channelId);
}
The first set of code WORKED WONDERS!

The second code you provided returned an object and I am unable to pull the data in.

Thank you so much! I appreciate your time!
Reply With Quote
Reply

Tags
channelutil

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 06:21 PM.


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