YS

Hello
I am trying to change the save location of the report file.
On Ariscommunity.com I found a topic "Path to Output File"  
(https://www.ariscommunity.com/users/martinmiskovic/2015-07-15-path-output-file).
But in this topic, an Excel file was used, and I need to output an XML file.
  
It's my code:

function outputFileToFolder( folderName, fileName, oData ) {
     var oFile = new java.io.File(folderName+fileName);
     var oOS  = new java.io.FileOutputStream(oFile);
     oOS.write(oData);   // Error: nullPointerException, because oData is empty
     oOS.close();
  }

function main() {
var xmlOutput = Context.createXMLOutputObject(Context.getSelectedFile(), "Root");

//then I fill the file with content using methods "addElement" and "setAttribute"

//at the end I do this:
Context.addOutputFileName ("101.xml");

xmlOutput.WriteReport();     // it's default folder

var oData = Context.getFile("101.xml", Constants.LOCATION_OUTPUT);  // <- oData  // is null, because file "101.xml" not apeared in default folder

outputFileToFolder( "C://TEMP//output", "Data.xml", oData );  // it's my folder
}

But if I run this script without the last two lines,

   var oData = Context.getFile("101.xml", Constants.LOCATION_OUTPUT);  
   outputFileToFolder( "C://TEMP//output", "Data.xml", oData ); 

then the file "101.xml" appears in the default folder.
Tell me please, how can I set my folder for creation report by script?

by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Thu, 11/26/2020 - 16:11

Hi,

well perhaps the problem is that the ARIS report creates the output files always on temporary folders on the server and later on, those files are "delivered" to the client pc and the temporary folders (and files) should be deleted.

You could just create an additional output file and use this one:

Context.addOutputFileName(sLogFileName);

This command will add the file names sLogFileName and transfer it to the client pc at the rend of the report.

Regards,

Robert

 

0
by Yuriy Stolyarov Author
Posted on Fri, 11/27/2020 - 09:08

In reply to by rgoldenbaum

Hello Robert

Thank you for your answer!

I wanted to set up communication with another system.
I.e.
1) An xml file comes from another system to the "input" folder, the ARIS system processes it - I did it.
2) After processing, the ARIS system generates a response (report file) and places it in the "output" folder from which another system takes this file - I cannot configure the path for saving the report to the "output" folder.

Both "input" and "output" folders are located on the ARIS server. Subsequently, I plan to poll the "input" folder automatically on a schedule.

0
by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Fri, 11/27/2020 - 10:18

Well, you could save the file directly on a specific windows folder on the server.

            oFile = Context.getFile(Context.getSelectedFile(), Constants.LOCATION_OUTPUT);
            oByteArrayInputStream = new java.io.ByteArrayInputStream(oFile);
            oInputStream = new java.io.BufferedInputStream(oByteArrayInputStream);
 

        sFileName = g_tOptions.sOutputPath + "/" + sName;
        oFile = new java.io.File(sFileName);
        oOutputStream = new java.io.FileOutputStream(oFile);
        oBufferedOutStream = new java.io.BufferedOutputStream(oOutputStream);
        while ((aByte = oInputStream.read()) != -1){
            oBufferedOutStream.write(aByte);
        }
        oBufferedOutStream.close();
 

Should work like this (more or less)...

Regards,

Robert

0
by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Fri, 11/27/2020 - 10:19

ahm, the upper part and the lower part should use a different variable not the same one.

I copied this from two different scripts...

0
by Yuriy Stolyarov Author
Posted on Tue, 12/01/2020 - 22:01

In reply to by rgoldenbaum

Hello, Robert

Thank you very much!

You have really help me!!!

function outputFileToFolder( folderName, fileName, oData ) {
      var oFile = Context.getFile(Context.getSelectedFile(), Constants.LOCATION_OUTPUT);
      var oByteArrayInputStream = new java.io.ByteArrayInputStream(oFile);
      var oInputStream = new java.io.BufferedInputStream(oByteArrayInputStream);
      
      var sFileName = folderName + "/" + fileName;
      oFile = new java.io.File(sFileName);
      var oOutputStream = new java.io.FileOutputStream(oFile);
      var oBufferedOutStream = new java.io.BufferedOutputStream(oOutputStream);
      while ((aByte = oInputStream.read()) != -1){
          oBufferedOutStream.write(aByte);
      }
      oBufferedOutStream.close();
}

 

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock