Converter (TextFile to String)
Converts the text file to a string. All lines of the file are extracted and stored in string type data. It is also possible to save the number of file lines.
https://support.questetra.com/addons/converter-textfile-to-string/
2018-11-29 (C) Questetra, Inc. (MIT License)
Configs
  • A: Select Text FILES DATA (Multiple not supported) *
  • B: Select STRING DATA for Text (update)
  • C: Select STRING/NUMERIC DATA for #File Lines (update)
Script
// (c) 2018, Questetra, Inc. (the MIT License)

//////// START "main()" ////////
main();
function main(){ 

//// == Config Retrieving / 工程コンフィグの参照 ==
var dataIdA = configs.get( "conf_DataIdA" ) + "";
var dataIdB = configs.get( "conf_DataIdB" ) + "";
var dataIdC = configs.get( "conf_DataIdC" ) + "";
// 'java.lang.String' (String Obj) to javascript primitive 'string'


//// == Data Retrieving / ワークフローデータの参照 ==
var myFiles = engine.findDataByNumber( dataIdA ); 
// java.util.ArrayList
if (myFiles === null || myFiles.size() != 1) {
  throw new Error( 'Attachment of multiple files can not be supported.' );
}


//// == Calculating / 演算 ==
var myFileText = '';
var myLineCounter = 0;
fileRepository.readFile(myFiles.get(0), "UTF-8", function(line) {
    myFileText += line + '\n';
    myLineCounter++;
});
// com.questetra.bpms.core.event.scripttask.FileRepositoryWrapper


//// == Data Updating / ワークフローデータへの代入 ==
if( dataIdB !== "" ){
  engine.setDataByNumber( dataIdB, myFileText );
}
if( dataIdC !== "" ){
  if( engine.findDataDefinitionByNumber( dataIdC ).matchDataType( "DECIMAL" ) ){
    engine.setDataByNumber( dataIdC, new java.math.BigDecimal(myLineCounter) );
  }else{
    engine.setDataByNumber( dataIdC, myLineCounter );
  }
}

} //////// END "main()" ////////

Download

Converter-TextFile-to-String.xml

Capture

See also

Questetra-Addon-XML Generate Digest-HTML

1 thought on “Converter (TextFile to String)”

  1. Pingback: Questetra-Addon-XML Generate Digest-HTML – Questetra Support

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.