Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   ChannelUtil question (http://www.mirthcorp.com/community/forums/showthread.php?t=215192)

Rubicon 12-02-2015 10:54 AM

ChannelUtil question
 
Hello all,
I read all the threads that have to do with ChannelUtil, but I am a little confused on where or how to implement that class.

Does the ChannelUtil go in the Preprocessor or Transformer or a Code Template.

What I am trying to do is get the Channel Name, Channel ID and the connectors into one readable file.

Does any on have an example that they can share?

Thank you,
Rubi

jadams4 12-03-2015 05:02 AM

Hi Rubi,

I do not have an example but here is a link to ChannelUtil.

http://javadocs.mirthcorp.com/connec...annelUtil.html

This is for version 3.2.2 not sure what version you are on?

I usually use it in a javascript transformer step. You could also do:
Code:

logger.info(ChannelUtil.getChannelNames());
to see what results you are getting.

Also don't forget about auto complete Mirth has added, you can type ChannelUtil. and a list will appear with uses.

Can you clarify more the use you need? You want the channel name/channel id/ and connectors of each channel in connect?

Hope this helps some!

Rubicon 12-03-2015 05:16 AM

Hi jadams4,

I am on version 3.2.0 and Yes I am looking to get the Channel Name/Channel ID/ Is the Channel Enabled or disabled/Connectors and if connectors are Enabled or disabled.

Wouldn't the logger.info(ChannelUtil.getChannelNames()); just place the message in the Dash board? I am looking to write it to a file.

mcalKno 12-03-2015 05:17 AM

Quote:

Originally Posted by Rubicon (Post 252314)
Hi jadams4,

I am on version 3.2.0 and Yes I am looking to get the Channel Name/Channel ID/ Is the Channel Enabled or disabled/Connectors and if connectors are Enabled or disabled.

Wouldn't the logger.info(ChannelUtil.getChannelNames()); just place the message in the Dash board? I am looking to write it to a file.

To write to file, you could code that within a transformer step.

Rubicon 12-03-2015 05:24 AM

I'm not sure on how to do that. What would be the source? Where do I put the transformer? In source Tab or destination Tab?

jadams4 12-03-2015 05:44 AM

Yes, this would place it in the dashboard. I meant you could use this to see if the information you want is correct. Then once you have what you want, for example:

logger.info("Is channel deployed: " +ChannelUtil.getChannelState());
logger.info(whatever other info you want here);
// keep logging until you have everything you want

Once you verify everything you want is working how you intend in the dashboard, you could create a destination with these transformers that is a file write. Then save this info in the channelmap and use it in the template to write to a file.

mcalKno 12-03-2015 05:57 AM

Destination Transformer:
Code:

var fileContents = 'ChannelId: '+channelId+'\n'+'Channel Name: '+ChannelUtil.getChannelName(channelId);
channelMap.put('fileContents', fileContents);

Destination File writer template:
Code:

${fileContents}

Rubicon 12-03-2015 06:24 AM

1 Attachment(s)
Thank you mcalKno,
I am getting an error of:
Java class "com.mirth.connect.server.userutil.ChannelUtil " has no public instance field or method named "getChannelName".

Attached is my Channel

mcalKno 12-03-2015 06:26 AM

Quote:

Originally Posted by Rubicon (Post 252319)
Thank you mcalKno,
I am getting an error of:
Java class "com.mirth.connect.server.userutil.ChannelUtil " has no public instance field or method named "getChannelName".

Attached is my Channel

This worked for me, so I'm thinking it is a version difference. I'm running the latest 3.3.

Rubicon 12-03-2015 06:28 AM

Can you post you channel?


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

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