Questetra-Model-XMLファイル, 定義情報の抽出
Questetra-Model-XMLファイル, 定義情報の抽出 (Questetra-Model-XML file, Extract Definitions)
ワークフローアプリの工程名とデータ項目名(変数名)を抽出します。Model-XML ファイルがパースされ、ヒューマン工程なのか自動工程なのか、データ型は何か、などの情報が抽出されます。
Configs
  • A: Model-XML が格納されているファイル型データを選択してください(複数添付は不可) *
  • B: 工程名称およびデータ項目名称(Markdown)が格納される複数行文字列型データを選択してください (更新)
  • C: 工程等の名称(TSV)が格納される複数行文字列型データを選択してください (更新)
  • C2: 工程等の名称(HTML)が格納される複数行文字列型データを選択してください (更新)
  • D: データ項目の名称(TSV)が格納される複数行文字列型データを選択してください (更新)
  • D2: データ項目の名称(HTML)が格納される複数行文字列型データを選択してください (更新)
  • D3: インポート用ファイルが格納されるファイル型データを選択してください(追加)
Script (click to open)
// GraalJS Script (engine type: 2)

/*
Notes:
- ModelXML is one file in the compressed folder QAR.
- Ends with an error, if the number of files is not one.
- Step Names (Nodes info)
    - /processModel/nodes/node[i]
        - /{@number,nodeType,name,note}
- DataItem Names (Variables info)
    - /processModel/process-data-definitions/process-data-definition[i]
        - /{@number,data-type,name,var-name,note,init-value}
        - /*/ns2:required='true'
- Markdown, TSV or LI-html (with fontawesome5 icons) will be output.
- Escape processing and template processing are required for website HTML code.
    - M227: Auto Executing Data Binding, Arithmetic Operations
    - https://questetra.zendesk.com/hc/en-us/articles/360002260571-M227
- An import file (TSV) will be also generated.
    - Data definition in similar apps or downstream apps becomes easier.
    - OUTPUT: Item Name, Data Type, Field Name, Required
    - The file entity consists of tab-separated-values (utf-16le-bom)

Notes(ja):
- ModelXML は、圧縮フォルダ QAR 内の1ファイルです。
- ファイルの数が1でない場合、エラー終了します
- 工程名(BPMNアイコン情報)
    - /processModel/nodes/node[i]
        - /{@number,nodeType,name,note}
- 変数名(データ定義の名前)
    - /processModel/process-data-definitions/process-data-definition[i]
        - /{@number,data-type,name,var-name,note,init-value}
        - /*/ns2:required='true'
- MarkdownもしくはTSVもしくは箇条書HTML(fontawesome5 icons)で出力されます
    - メモ等の文章はHTMLエスケープされます
- 抽出情報をもとにWebサイト原稿を生成したい場合、テンプレ挿入を後置します
    - M227: 業務データの結合や四則演算が自動実行されるように設定する
    - https://questetra.zendesk.com/hc/ja/articles/360002260571-M227
- あわせてインポート用ファイル(TSV)の生成も可能です。
    - 類似アプリ・下流アプリにおけるデータ定義が一括処理できるようになります。
    - 出力4項目: Item Name, Data Type, Field Name, Required
    - ファイル実体は tab-separated-values (utf-16le-bom) です
*/

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

//// == Config Retrieving / 工程コンフィグの参照 ==
const filesPocketModel   = configs.getObject( "SelectConfA" ); // required
const strPocketMarkdown  = configs.getObject( "SelectConfB" );
const strPocketIconsTsv  = configs.getObject( "SelectConfC" );
const strPocketIconsHtml = configs.getObject( "SelectConfC2");
const strPocketVarsTsv   = configs.getObject( "SelectConfD" );
const strPocketVarsHtml  = configs.getObject( "SelectConfD2" );
const filesPocketImport  = configs.getObject( "SelectConfD3" );


//// == Data Retrieving / ワークフローデータの参照 ==
let fileModel = engine.findData( filesPocketModel ); 
// java.util.ArrayList
if( fileModel === null ) {
  throw new Error( "\n AutomatedTask UnexpectedFilesError:" + 
                   " Files {A} not found \n" );
}
if ( fileModel.size() > 1) {
  throw new Error( "\n AutomatedTask UnexpectedFilesError:" + 
                   " Files {A} must be single: " + 
                     fileModel.size() + " files attached \n" );
}

let filesImport = engine.findData( filesPocketImport ); 
if( filesImport === null ){
  filesImport = new java.util.ArrayList();
  // java.util.ArrayList
  // - com.questetra.bpms.core.event.scripttask.QfileView
}


//// == Calculating / 演算 ==
/// load text (XML)
let strModelXml = '';
let numLineCounter = 0;
fileRepository.readFile( fileModel.get(0), "UTF-8", function(line) {
// com.questetra.bpms.core.event.scripttask.FileRepositoryWrapper
// https://questetra.zendesk.com/hc/ja/articles/360024574471-R2300#FileRepositoryWrapper
    strModelXml += line + '\n';
    numLineCounter ++;
});
engine.log( " AutomatedTask FileLoaded: Number of lines = " + numLineCounter );


/// parse XML
// com.questetra.bpms.core.event.scripttask.XPathWrapper
// - https://questetra.zendesk.com/hc/ja/articles/360024574471-R2300#XPathWrapper
// com.questetra.bpms.core.event.scripttask.XPathWrapper.NodeWrapper
// com.questetra.bpms.core.event.scripttask.XPathWrapper.NodeListWrapper

let strMarkdown = ""; // for Icons-Vars in Markdown

/// extract BpmnIcon (Bpmn node) info
let xpathBpmnIcon = "/processModel/nodes/node";
const xmlNodesBpmnIcon = xpath.findNodeList( strModelXml, xpathBpmnIcon );
engine.log( " AutomatedTask XmlParsed: NumOf 'BpmnIcons' = " +
                                       xmlNodesBpmnIcon.getLength() );
// store Icon-properties in array
let arrObjIcons = new Array( xmlNodesBpmnIcon.getLength() );
for( let i = 0; i < xmlNodesBpmnIcon.getLength(); i++ ){
  let xpathIcon = "/processModel/nodes/node[" + (i+1) + "]";
  arrObjIcons[i] = {};
  arrObjIcons[i].number = xpath.findNodeText( strModelXml, xpathIcon + "/@number" );
  arrObjIcons[i].type   = xpath.findNodeText( strModelXml, xpathIcon + "/nodeType" );
  arrObjIcons[i].name   = xpath.findNodeText( strModelXml, xpathIcon + "/name" );
  arrObjIcons[i].note   = "";
  if( xpath.findNodeList( strModelXml, xpathIcon + "/note" ).getLength() !== 0 ){
    arrObjIcons[i].note = xpath.findNodeText( strModelXml, xpathIcon + "/note" ).replace(/\n/g,"");
  }
}
// sort node-properties by name unicode
function compareObjNames(a, b) {
  if(a.name > b.name) return 1;
  if(a.name < b.name) return -1;
  return 0;
}
arrObjIcons.sort(compareObjNames);
engine.log( " AutomatedTask Sorted by NODE NAME " );

// describe BpmnIcons in tsv (and markdown)
let strTsvBpmnIcons = "";
    strMarkdown += "### BPMN Nodes\n";
for( let i = 0; i < xmlNodesBpmnIcon.getLength(); i++ ){
  strTsvBpmnIcons += arrObjIcons[i].number + "\t";
  if( arrObjIcons[i].type === "0" ){
    strTsvBpmnIcons += "HUMAN\t";
    strMarkdown += "- HUMAN **" + (arrObjIcons[i].name ?
      encodeHTML(arrObjIcons[i].name) : '<span style="font-style:italic;">(no name)</span>');
    strMarkdown += "** " + encodeHTML(arrObjIcons[i].note) + "\n";
  }else if(arrObjIcons[i].type === "3" || arrObjIcons[i].type === "4" || arrObjIcons[i].type === "5"){
    strTsvBpmnIcons += "SYSTEM\t";
    strMarkdown += "- SYSTEM **" + (arrObjIcons[i].name ?
      encodeHTML(arrObjIcons[i].name) : '<span style="font-style:italic;">(no name)</span>');
    strMarkdown += "** " + encodeHTML(arrObjIcons[i].note) + "\n";
  }else if( arrObjIcons[i].type === "1" ){
    strTsvBpmnIcons += "EVENT\t";
  }else{
    strTsvBpmnIcons += "XMISC\t";
  }
  strTsvBpmnIcons += arrObjIcons[i].name + "\t";
  strTsvBpmnIcons += arrObjIcons[i].note;
  if( i !== xmlNodesBpmnIcon.getLength() - 1 ){
    strTsvBpmnIcons += "\n";
  }
}
// describe BpmnIcons in html
let strHumanTasks     = ""; // type:0
let strAutomatedTasks = ""; // type:3,4(Script),5(Webhook)
let strEvents         = ""; // type:1
let strGateways       = ""; // type:2 etc
for( let i = 0; i < xmlNodesBpmnIcon.getLength(); i++ ){
  if( arrObjIcons[i].type === "0" ){
    strHumanTasks += '<li><span class="fa-li">';
      strHumanTasks += '<span class="fa-layers fa-fw">';
      strHumanTasks += '<i class="far fa-rectangle-landscape fa-lg" style="color:#4a86e8;"></i>';
      strHumanTasks += '<span class="fa-layers-text" data-fa-transform="shrink-8">';
      strHumanTasks += arrObjIcons[i].number;
      strHumanTasks += '</span>';
      strHumanTasks += '</span>';
    strHumanTasks += '</span> <strong>';
    strHumanTasks += arrObjIcons[i].name ? encodeHTML(arrObjIcons[i].name) : 
                                               '<span style="font-style:italic;">(no name)</span>';
    strHumanTasks += '</strong> ' + encodeHTML(arrObjIcons[i].note) + '</li>\n';
  }else if(arrObjIcons[i].type === "3" || arrObjIcons[i].type === "4" || arrObjIcons[i].type === "5"){
    strAutomatedTasks += '<li><span class="fa-li">';
      strAutomatedTasks += '<span class="fa-layers fa-fw">';
      strAutomatedTasks += '<i class="fal fa-rectangle-landscape fa-lg" style="color:#666666;"></i>';
      strAutomatedTasks += '<span class="fa-layers-text" data-fa-transform="shrink-8">';
      strAutomatedTasks += arrObjIcons[i].number;
      strAutomatedTasks += '</span>';
      strAutomatedTasks += '</span>';
    strAutomatedTasks += '</span> <strong>';
    strAutomatedTasks += arrObjIcons[i].name ? encodeHTML(arrObjIcons[i].name) :
                                               '<span style="font-style:italic;">(no name)</span>';
    strAutomatedTasks += '</strong> ' + encodeHTML(arrObjIcons[i].note) + '</li>\n';
  }else if( arrObjIcons[i].type === "1" ){
    strEvents += '<li><span class="fa-li">';
      strEvents += '<span class="fa-layers fa-fw">';
      strEvents += '<i class="far fa-circle fa-lg" style="color:#741b47;"></i>';
      strEvents += '<span class="fa-layers-text" data-fa-transform="shrink-8">';
      strEvents += arrObjIcons[i].number;
      strEvents += '</span>';
      strEvents += '</span>';
    strEvents += '</span> <strong>';
    strEvents += arrObjIcons[i].name ? encodeHTML(arrObjIcons[i].name) : 
                                               '<span style="font-style:italic;">(no name)</span>';
    strEvents += '</strong> ' + encodeHTML(arrObjIcons[i].note) + '</li>\n';
  }else{ // "2"
    strGateways += '<li><span class="fa-li">';
      strGateways += '<span class="fa-layers fa-fw">';
      strGateways += '<i class="far fa-diamond fa-lg" style="color:#38761d;"></i>';
      strGateways += '<span class="fa-layers-text" data-fa-transform="shrink-8">';
      strGateways += arrObjIcons[i].number;
      strGateways += '</span>';
      strGateways += '</span>';
    strGateways += '</span> <strong>';
    strGateways += arrObjIcons[i].name ? encodeHTML(arrObjIcons[i].name) : 
                                               '<span style="font-style:italic;">(no name)</span>';
    strGateways += '</strong> ' + encodeHTML(arrObjIcons[i].note) + '</li>\n';
  }
}
let strHtmlBpmnIcons = "";
    strHtmlBpmnIcons += strHumanTasks;
    strHtmlBpmnIcons += strAutomatedTasks;
// Comment in if Events and Gateway are needed.
//    strHtmlBpmnIcons += strEvents;
//    strHtmlBpmnIcons += strGateways;


/// extract Variable Definition info
let xpathVarsDef = "/processModel/process-data-definitions/process-data-definition";
const xmlNodesVar = xpath.findNodeList( strModelXml, xpathVarsDef );
engine.log( " AutomatedTask XmlParsed: NumOf 'Variable Defs' = " +
                                       xmlNodesVar.getLength() );
// store Variable-properties in array
let arrObjVars = new Array( xmlNodesVar.getLength() );
for( let i = 0; i < xmlNodesVar.getLength(); i++ ){
  let xpathVar = "/processModel/process-data-definitions/process-data-definition[" + (i+1) + "]";
  arrObjVars[i] = {};
  arrObjVars[i].order  = parseInt( xpath.findNodeText( strModelXml, xpathVar + "/view-order" ), 10);
  arrObjVars[i].number = xpath.findNodeText( strModelXml, xpathVar + "/@number" );

  arrObjVars[i].name   = xpath.findNodeText( strModelXml, xpathVar + "/name" );
  arrObjVars[i].field  = "";
  if( xpath.findNodeList( strModelXml, xpathVar + "/var-name" ).getLength() == 1 ){
    arrObjVars[i].field  = xpath.findNodeText( strModelXml, xpathVar + "/var-name" );
  }
  arrObjVars[i].note   = xpath.findNodeText( strModelXml, xpathVar + "/note" );
  arrObjVars[i].initval= xpath.findNodeText( strModelXml, xpathVar + "/init-value" );
  engine.log( " initval: " + arrObjVars[i].initval );

  arrObjVars[i].type   = xpath.findNodeText( strModelXml, xpathVar + "/data-type" );
  arrObjVars[i].type2  = "";
  arrObjVars[i].required = "0";
  if( arrObjVars[i].type === "0" ){ /// STRING
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- string " );
    arrObjVars[i].type2 = xpath.findNodeText( strModelXml, xpathVar + "/form-type" );
    if( arrObjVars[i].type2 === "0" ){ /// STRING_TEXTFIELD
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:string-detail" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }else if( arrObjVars[i].type2 === "1" ){ /// STRING_TEXTAREA
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:string-detail" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }
  }else if( arrObjVars[i].type === "12" ){ /// DECIMAL
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- decimal " );
    if( xpath.findNodeText( strModelXml, xpathVar +
                          "/process-data-definition-detail:decimal-detail" +
                          "/process-data-definition-detail:required" ) === "true" ){
      arrObjVars[i].required= "1";
    }
  }else if( arrObjVars[i].type === "11" ){ /// SELECT ("select-detail" → "*")
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- select " );
    arrObjVars[i].type2 = xpath.findNodeText( strModelXml, xpathVar + "/form-type" );
    if( arrObjVars[i].type2 === "2" ){ /// SELECT_RADIO
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:*" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }else if( arrObjVars[i].type2 === "4" ){ /// SELECT_SELECT
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:*" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }else if( arrObjVars[i].type2 === "5" ){ /// SELECT_SELECT_QUERY
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:*" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }else if( arrObjVars[i].type2 === "3" ){ /// SELECT_CHECKBOX
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:*" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }
  }else if( arrObjVars[i].type === "5" ){ /// DATE
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- date " );
    arrObjVars[i].type2 = xpath.findNodeText( strModelXml, xpathVar + "/sub-type" );
    if( arrObjVars[i].type2 === "0" ){ /// DATE_YMD
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:basic-detail" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }else if( arrObjVars[i].type2 === "1" ){ /// DATE_YM
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:basic-detail" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }else if( arrObjVars[i].type2 === "2" ){ /// DATE_Y
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:basic-detail" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }else if( arrObjVars[i].type2 === "3" ){ /// DATE_MD
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:basic-detail" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }
  }else if( arrObjVars[i].type === "10" ){ /// DATETIME
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- datetime " );
    if( xpath.findNodeText( strModelXml, xpathVar +
                          "/process-data-definition-detail:basic-detail" +
                          "/process-data-definition-detail:required" ) === "true" ){
      arrObjVars[i].required= "1";
    }
  }else if( arrObjVars[i].type === "14" ){ /// FILE
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- file " );
    if( xpath.findNodeText( strModelXml, xpathVar +
                          "/process-data-definition-detail:file-detail" +
                          "/process-data-definition-detail:required" ) === "true" ){
      arrObjVars[i].required= "1";
    }
  }else if( arrObjVars[i].type === "8" ){ /// QUSER
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- quser " );
    arrObjVars[i].type2 = xpath.findNodeText( strModelXml, xpathVar + "/form-type" );
    if( arrObjVars[i].type2 === "4" ){ /// QUSER
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:basic-detail" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }else if( arrObjVars[i].type2 === "5" ){ /// QUSER_SELECT_QUERY
      if( xpath.findNodeText( strModelXml, xpathVar +
                              "/process-data-definition-detail:basic-detail" +
                              "/process-data-definition-detail:required" ) === "true" ){
        arrObjVars[i].required= "1";
      }
    }
  }else if( arrObjVars[i].type === "16" ){ /// QGROUP
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- qgroup " );
    if( xpath.findNodeText( strModelXml, xpathVar +
                          "/process-data-definition-detail:basic-detail" +
                          "/process-data-definition-detail:required" ) === "true" ){
      arrObjVars[i].required= "1";
    }
  }else if( arrObjVars[i].type === "9" ){ /// DISCUSSION
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- discuss " );
  }else if( arrObjVars[i].type === "13" ){ /// LIST
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- list " );
    if( xpath.findNodeText( strModelXml, xpathVar +
                          "/process-data-definition-detail:list-detail" +
                          "/process-data-definition-detail:required" ) === "true" ){
      arrObjVars[i].required= "1";
    }
  }else if( arrObjVars[i].type === "15" ){ /// HTML_PANEL
    engine.log( "node " + i + ": type " + arrObjVars[i].type + " -- panel " );
  }else{
    engine.log( "node " + i + ": type ERROR" );
  }
}
// sort data-properties by Order
function compareObjOrders(a, b) {
  return a.order - b.order;
}
arrObjVars.sort(compareObjOrders);
engine.log( " AutomatedTask Sorted by VIEW ORDER" );

// describe Vars in tsv (and markdown)
let strVarsTsv = "";
    strMarkdown += "\n### Variables\n";
for( let i = 0; i < xmlNodesVar.getLength(); i++ ){
  // name (Item Name)
  strVarsTsv += arrObjVars[i].name + "\t";
  strMarkdown += "- **" + encodeHTML(arrObjVars[i].name) + "** ";
  strMarkdown += arrObjVars[i].field + " " + arrObjVars[i].number;
  if( arrObjVars[i].required == "1" ){
    strMarkdown += " *" ;
  }

  // type (Data Type)
  if( arrObjVars[i].type === "0" && arrObjVars[i].type2 === "0" ){
    strVarsTsv += "STRING_TEXTFIELD\t";
    strMarkdown += " - STRING_TEXTFIELD\n";
  }else if( arrObjVars[i].type === "0" && arrObjVars[i].type2 === "1" ){
    strVarsTsv += "STRING_TEXTAREA\t";
    strMarkdown += " - STRING_TEXTAREA\n";
  }else if( arrObjVars[i].type === "12" ){
    strVarsTsv += "DECIMAL\t";
    strMarkdown += " - DECIMAL\n";
  }else if( arrObjVars[i].type === "11" && arrObjVars[i].type2 === "2" ){
    strVarsTsv += "SELECT_RADIO\t";
    strMarkdown += " - SELECT_RADIO\n";
  }else if( arrObjVars[i].type === "11" && arrObjVars[i].type2 === "4" ){
    strVarsTsv += "SELECT_SELECT\t";
    strMarkdown += " - SELECT_SELECT\n";
  }else if( arrObjVars[i].type === "11" && arrObjVars[i].type2 === "5" ){
    strVarsTsv += "SELECT_SELECT_QUERY\t";
    strMarkdown += " - SELECT_SELECT_QUERY\n";
  }else if( arrObjVars[i].type === "11" && arrObjVars[i].type2 === "3" ){
    strVarsTsv += "SELECT_CHECKBOX\t";
    strMarkdown += " - SELECT_CHECKBOX\n";
  }else if( arrObjVars[i].type === "5" && arrObjVars[i].type2 === "0" ){
    strVarsTsv += "DATE_YMD\t";
    strMarkdown += " - DATE_YMD\n";
  }else if( arrObjVars[i].type === "5" && arrObjVars[i].type2 === "1" ){
    strVarsTsv += "DATE_YM\t";
    strMarkdown += " - DATE_YM\n";
  }else if( arrObjVars[i].type === "5" && arrObjVars[i].type2 === "2" ){
    strVarsTsv += "DATE_Y\t";
    strMarkdown += " - DATE_Y\n";
  }else if( arrObjVars[i].type === "5" && arrObjVars[i].type2 === "3" ){
    strVarsTsv += "DATE_MD\t";
    strMarkdown += " - DATE_MD\n";
  }else if( arrObjVars[i].type === "10" ){
    strVarsTsv += "DATETIME\t";
    strMarkdown += " - DATETIME\n";
  }else if( arrObjVars[i].type === "14" ){
    strVarsTsv += "FILE\t";
    strMarkdown += " - FILE\n";
  }else if( arrObjVars[i].type === "8" && arrObjVars[i].type2 === "4" ){
    strVarsTsv += "QUSER\t";
    strMarkdown += " - QUSER\n";
  }else if( arrObjVars[i].type === "8" && arrObjVars[i].type2 === "5" ){
    strVarsTsv += "QUSER\t"; // "QUSER_SELECT_QUERY\t";
    strMarkdown += " - QUSER_SELECT_QUERY\n";
  }else if( arrObjVars[i].type === "16" ){
    strVarsTsv += "QGROUP\t";
    strMarkdown += " - QGROUP\n";
  }else if( arrObjVars[i].type === "9" ){
    strVarsTsv += "DISCUSSION\t";
    strMarkdown += " - DISCUSSION\n";
  }else if( arrObjVars[i].type === "13" ){
    strVarsTsv += "LIST\t";
    strMarkdown += " - LIST\n";
  }else if( arrObjVars[i].type === "15" ){
    strVarsTsv += "HTML_PANEL\t";
    strMarkdown += " - HTML_PANEL\n";
  }

  // Field Name
  strVarsTsv += arrObjVars[i].field + "\t";
  // Required
  strVarsTsv += arrObjVars[i].required;
  if( arrObjVars[i].note !== "" ){
    strMarkdown += "    - note) " + encodeHTML(arrObjVars[i].note) + "\n";
  }
  if( arrObjVars[i].initval !== "" ){
    strMarkdown += "    - init) " + encodeHTML(arrObjVars[i].initval) + "\n";
  }
  // (tsv line feed)
  if( i !== xmlNodesVar.getLength() - 1 ){
    strVarsTsv += "\n";
  }
}

// import file
let strImport = "Item Name\tData Type\tField Name\tRequired\n";
    strImport += strVarsTsv;
filesImport.add(
  new com.questetra.bpms.core.event.scripttask.NewQfile(
    (fileModel.get(0).getName().slice(0, -4) + ".csv"),
     "text/tab-separated-values; charset=x-UTF-16LE-BOM", strImport
  )
);

// describe Vars in html
let strVarsHtml = "";
for( let i = 0; i < xmlNodesVar.getLength(); i++ ){
  strVarsHtml += '<li><span class="fa-li">';

  if( arrObjVars[i].type === "0" && arrObjVars[i].type2 === "0" ){
    strVarsHtml += '<i class="fal fa-font fa-lg" style="color:#B40404;" title="String (Text Box single line)"></i>';
  }else if( arrObjVars[i].type === "0" && arrObjVars[i].type2 === "1" ){
    strVarsHtml += '<i class="fal fa-font fa-lg" style="color:#B40404;" title="String (Text Box multiple lines)"></i>';
  }else if( arrObjVars[i].type === "12" ){
    strVarsHtml += '<i class="fal fa-percent fa-lg" style="color:#B45F04;" title="Numeric"></i>';
  }else if( arrObjVars[i].type === "11" && arrObjVars[i].type2 === "2" ){
    strVarsHtml += '<i class="fal fa-list-alt fa-lg" style="color:#AEB404;" title="Select (Radio Button)"></i>';
  }else if( arrObjVars[i].type === "11" && arrObjVars[i].type2 === "4" ){
    strVarsHtml += '<i class="fal fa-list-alt fa-lg" style="color:#AEB404;" title="Select (Select Box)"></i>';
  }else if( arrObjVars[i].type === "11" && arrObjVars[i].type2 === "5" ){
    strVarsHtml += '<i class="fal fa-list-alt fa-lg" style="color:#AEB404;" title="Select (Search Select Box)"></i>';
  }else if( arrObjVars[i].type === "11" && arrObjVars[i].type2 === "3" ){
    strVarsHtml += '<i class="fal fa-list-alt fa-lg" style="color:#AEB404;" title="Select (Check Box)"></i>';
  }else if( arrObjVars[i].type === "5" && arrObjVars[i].type2 === "0" ){
    strVarsHtml += '<i class="fal fa-calendar-alt fa-lg" style="color:#5FB404;" title="Date (Y/M/D)"></i>';
  }else if( arrObjVars[i].type === "5" && arrObjVars[i].type2 === "1" ){
    strVarsHtml += '<i class="fal fa-calendar-alt fa-lg" style="color:#5FB404;" title="Date (Y/M)"></i>';
  }else if( arrObjVars[i].type === "5" && arrObjVars[i].type2 === "2" ){
    strVarsHtml += '<i class="fal fa-calendar-alt fa-lg" style="color:#5FB404;" title="Date (M/D)"></i>';
  }else if( arrObjVars[i].type === "5" && arrObjVars[i].type2 === "3" ){
    strVarsHtml += '<i class="fal fa-calendar-alt fa-lg" style="color:#5FB404;" title="Date (Y)"></i>';
  }else if( arrObjVars[i].type === "10" ){
    strVarsHtml += '<i class="fal fa-clock fa-lg" style="color:#5FB404;" title="Datetime"></i>';
  }else if( arrObjVars[i].type === "14" ){
    strVarsHtml += '<i class="fal fa-copy fa-lg" style="color:#04B404;" title="File"></i>';
  }else if( arrObjVars[i].type === "8" && arrObjVars[i].type2 === "4" ){
    strVarsHtml += '<i class="fal fa-user fa-lg" style="color:#04B45F;" title="User (Select Box)"></i>';
  }else if( arrObjVars[i].type === "8" && arrObjVars[i].type2 === "5" ){
    strVarsHtml += '<i class="fal fa-user fa-lg" style="color:#04B45F;" title="User (Search Select Box)"></i>';
  }else if( arrObjVars[i].type === "16" ){
    strVarsHtml += '<i class="fal fa-sitemap fa-lg" style="color:#04B4AE;" title="Organization"></i>';
  }else if( arrObjVars[i].type === "9" ){
    strVarsHtml += '<i class="fal fa-comments fa-lg" style="color:#045FB4;" title="Discussion"></i>';
  }else if( arrObjVars[i].type === "13" ){
    strVarsHtml += '<i class="fal fa-table fa-lg" style="color:#0404B4;" title="Table"></i>';
  }else if( arrObjVars[i].type === "15" ){
    strVarsHtml += '<i class="fal fa-info fa-lg" style="color:#5F04B4;" title="Guide Panel"></i>';
  }else{
    strVarsHtml += '?';
  }

  strVarsHtml += '</span> <strong>';
  strVarsHtml += arrObjVars[i].name ? encodeHTML(arrObjVars[i].name) : 
                                          '<span style="font-style:italic;">(no name)</span>';
  strVarsHtml += '</strong> <span style="font-style:italic;">' + arrObjVars[i].field;
  strVarsHtml += ' ' + arrObjVars[i].number + '</span>';
  if( arrObjVars[i].required === "1" ){
    strVarsHtml += '<span style="color:#990000;">*</span>';
  }
  strVarsHtml += ': ' + encodeHTML(arrObjVars[i].note);
  if( arrObjVars[i].initval != "" ){
    strVarsHtml += ' <span style="color:#9DCCE0;">' + encodeHTML(arrObjVars[i].initval) + '</span>';
  }
  strVarsHtml += '</li>\n';
}


//// == Data Updating / ワークフローデータへの代入 ==
if( strPocketMarkdown !== null ){
  engine.setData( strPocketMarkdown, strMarkdown );
}
if( strPocketIconsTsv !== null ){
  engine.setData( strPocketIconsTsv, strTsvBpmnIcons );
}
if( strPocketIconsHtml !== null ){
  engine.setData( strPocketIconsHtml, strHtmlBpmnIcons );
}
if( strPocketVarsTsv !== null ){
  engine.setData( strPocketVarsTsv, strVarsTsv );
}
if( strPocketVarsHtml !== null ){
  engine.setData( strPocketVarsHtml, strVarsHtml );
}
if( filesPocketImport !== null ){
  engine.setData( filesPocketImport, filesImport );
}

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


function encodeHTML( str ){
  return str.replace(/&/g, '&amp;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;')
            .replace(/"/g, '&quot;')
            .replace(/'/g, '&apos;');
}

Download

2020-09-24 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/ja/addons/questetra-model-xml-file-extract-definitions/
Addonファイルのインポートは Professional もしくは Enterprise でのみご利用いただけます

Notes

  • ModelXML は、圧縮フォルダ QAR 内の1ファイルです。
  • ファイルの数が1でない場合、エラー終了します
  • 工程名(BPMNアイコン情報)
    • /processModel/nodes/node[i]
      • /{@number,nodeType,name,note}
  • 変数名(データ定義の名前)
    • /processModel/process-data-definitions/process-data-definition[i]
      • /{@number,data-type,name,var-name,note,init-value}
      • /*/ns2:required=’true’
  • MarkdownもしくはTSVもしくは箇条書HTML(fontawesome5 icons)で出力されます
    • メモ等の文章はHTMLエスケープされます
  • 抽出情報をもとにWebサイト原稿を生成したい場合、テンプレ挿入を後置します
  • あわせてインポート用ファイル(TSV)の生成も可能です。
    • 類似アプリ・下流アプリにおけるデータ定義が一括処理できるようになります。
    • 出力4項目: Item Name, Data Type, Field Name, Required
    • ファイル実体は tab-separated-values (utf-16le-bom) です

Capture

ワークフローアプリの工程名とデータ項目名(変数名)を抽出します。Model-XML ファイルがパースされ、ヒューマン工程なのか自動工程なのか、データ型は何か、などの情報が抽出されます。

See also

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

%d人のブロガーが「いいね」をつけました。