Sidebar

How to get source node path and destination node path in mapping script?

0 votes
931 views
asked Jul 30, 2018 by (330 points)

i am unziping a file from a location.and i am using the code mentioned below:


var zipFilePath="D:\\readytodelete\\folder\\Test.zip";
var unzipPath="D:\\readytodelete\\folder";

var zipFile = null;

try {
   zipFile = new java.util.zip.ZipFile(zipFilePath);
   var entries = zipFile.entries();
   var bytes = new Packages.java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024);   
   while (entries.hasMoreElements()) {....
   ...................................................

and the code is working absolutly fine,the only problem i am facing is my zipFilePath and unzipPath become fix,i want to assign  souce node path to zipFilePath and Destination path to unzipPath ,,so my question is how do i access my source node path and Destination path in mapping script.

please tell me how to get these path as string in mapping resource? and address path should contains double backslashs lik- D:\\readytodelete\\folder\\Test.zip 
   

1 Answer

–1 vote

qie.getFileName() will get you the file name of the file. The full path would need to be entered from the source node so it would be something like this:

var zipFilePath="D:\\readytodelete\\folder\\" + qie.getFileName()

Feel free to email us @ support@qvera.com if this is not what you are looking for.

answered Jul 30, 2018 by brandon-w-8204 (33,170 points)
commented Jul 31, 2018 by (330 points)
edited Jul 31, 2018 by brandon-w-8204
basically i want to get address of file from source node
not like that
var zipFilePath="D:\\readytodelete\\folder\\" + qie.getFileName() ,,, that address "D:\\readytodelete\\folder\\"  should come from green source node path which might be return by some function like
var zipFilePath=qie.somefunction() + qie.getFileName()
commented Jul 31, 2018 by brandon-w-8204 (33,170 points)
So we currently do not have any function to get the root path from the source node only the filename. There is a way to do what you are looking for:

Create a Channel Cache and name it something like "path". Put in the root path "D:\readytodelete\folder\" and then edit the source node and enter "{cc:path}\*.ext"

Then in your mapping you can use "channelCache.getValue('path') + qie.getFileName()" to get the full path.

As for the destination node you could create your desired path in whole or part and store it in a Message Cache variable.

example code:
messageCache.setValue('destPath', 'D:\outfolder\' + qie.getFileName());

Then on the destination node put: {mc:destPath}

Let me know if this works for what you are trying to do and we are happy to help further if needed.
commented Aug 1, 2018 by (330 points)
thanx for the solution ,but my task is:- i have to read a zip file from a directory and then i have to unzip  it and after unzipping ,unzipped file i have to transefer to the destination node.
so when i execute the channel source node read the zipped file from souce path and might be remove it from there and then mapping script get start to unzip the file from source node ,but it unable to find that zipped file from source and thats why error arise... so as i understand source node might be remove the file before mapping script get start,,,and that might be the reason ,mapping script could not find the zipped file.. so what can be the solution for that ..please help me out in this..or send me a channel for this requirement..
commented Aug 1, 2018 by brandon-w-8204 (33,170 points)
I am confident we can help you get this working. I would like to setup a webex meeting with you what times work best for you.
...