web stats
Accessing Database Reader Settings in Transformers and Filters - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-29-2014, 08:12 AM
mmaund mmaund is offline
Mirth Newb
 
Join Date: Mar 2008
Posts: 13
mmaund
Question Accessing Database Reader Settings in Transformers and Filters

Using Mirth Connect v3.0.1

Does anyone know if it is possible to access the "Database Reader Settings" in JavaScript Source Transformer?

Currently, I am "Using JavaScript" to read from the DB but need to access the DB for other reasons in the Source Transformer and Destination Filters and Transformers. To do this, I need to create GlobalMap variables in the Source JavaScript as follows and use the global variable to open the database in Transformers and Filters.:

globalMap.put('dbConnectionString', 'jdbc:jtds:sqlserver://localhost:1433/database');
globalMap.put('dbUsername', 'user');
globalMap.put('dbPassword', 'password');

I would like to make use of the "URL:" "Username:" and "Password:" values instead of creating separate globalMap variables in the Source JavaScript.

Are these values accessible in the Filters and Transformers or is setting globalMap variables the only way.

I hope this makes sense.

Thanks,

Mark

Last edited by mmaund; 01-29-2014 at 08:17 AM. Reason: Add Mirth Version information.
Reply With Quote
  #2  
Old 01-29-2014, 10:30 AM
mmaund mmaund is offline
Mirth Newb
 
Join Date: Mar 2008
Posts: 13
mmaund
Default

I was poking around a little more and found another thread asking a similar question about a File Reader Channel.

http://www.mirthcorp.com/community/f...tor+properties

From there, I was able to get the following to work.

var dbURL = Packages.com.mirth.connect.server.controllers.Chan nelController.getInstance().getDeployedChannelById (channelId).getSourceConnector().getProperties().g etUrl();
var dbUsername = Packages.com.mirth.connect.server.controllers.Chan nelController.getInstance().getDeployedChannelById (channelId).getSourceConnector().getProperties().g etUsername();
var dbPassword = Packages.com.mirth.connect.server.controllers.Chan nelController.getInstance().getDeployedChannelById (channelId).getSourceConnector().getProperties().g etPassword();

channelMap.put('dbConnectionString', dbURL);
channelMap.put('dbUsername', dbUsername);
channelMap.put('dbPassword', dbPassword);

Would this be considered the correct way to get Source Connector Properties or do I run the risk of this method being deprecated in the future? If so, is there a more direct way?

Any help would be appreciated.

Mark
Reply With Quote
  #3  
Old 01-29-2014, 10:40 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,098
narupley is on a distinguished road
Default

That certainly does run the risk of being not just deprecated, but removed altogether in a future release. The more "correct" way to go about it is to store those values in the global channel map beforehand using the channel deploy script. Then use those variables both in the source connector settings, and later on in the transformer script.
__________________
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.
Reply With Quote
  #4  
Old 01-31-2014, 12:38 PM
mmaund mmaund is offline
Mirth Newb
 
Join Date: Mar 2008
Posts: 13
mmaund
Default

I appreciate your quick reply on this.

That is what I thought. We have been using the globalMap method for quite some time. Although it works well, The way we use this sometimes, setting a channelMap variable for this would work better when we want multiple clones of the same channel working with different sources.

Short of giving all my reasons, we would like to create one channel, then clone it and minimize the changes we would have to make in the clone. Just changing the source DB would be nice. Using globals, we need to make sure globalMaps in one channel don't stomp on or interfere with globalMaps in another channel running on the same Mirth Instance.

Any alternative suggestions are welcome but not necessary.

Mark
Reply With Quote
Reply

Tags
database reader, global map, variables

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 05:55 AM.


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