warning PAGE UPDATED
https://support.questetra.com/ja/addons/questetra-addon-xml-file-extract-configs-2022/
Questetra-Addon-XMLファイル, コンフィグ情報の抽出 (Questetra-Addon-XML file, Extract Configs)
自動工程のコンフィグ情報を抽出します。Addon-XML ファイル(Questetra BPMS 自動処理工程用)がパースされ、summary、last-modified、config などの情報が抽出されます。
Configs
- A: Addon-XML が格納されているファイル型データを選択してください(複数添付は不可) *
- B: どの言語で抽出するかをセットしてください (例 “ja”, “”)#{EL}
- C: タイトル(Label)が格納される文字列型データを選択してください (更新)
- C2: 英文タイトル(Label)が格納される文字列型データを選択してください (更新)
- D: Summary が格納される文字列型データを選択してください (更新)
- E: HelpPageUrl が格納される文字列型データを選択してください (更新)
- F: LastModified が格納される文字列型データを選択してください (更新)
- G: EngineType が格納される文字列型データを選択してください (更新)
- H: License が格納される文字列型データを選択してください (更新)
- I: Script が格納される文字列型データを選択してください (更新)
- J: Configs HTML が格納される文字列型データを選択してください (更新)
- K: Base64 image が格納される文字列型データを選択してください (更新)
Script (click to open)
// GraalJS Script (engine type: 2)
/*
Notes:
- Ends with an error, if the number of files is not one.
- Element without locale attribute is required for all definition-elements
- EngineType: "0" = Rhino (deprecated), "1" = Nashorn, "2" = GraalJS
- Configs definition with multiple child elements outputs LI-HTML with fontawesome5
- 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
- HTML Escape: "#{#escapeXml(#q_xml_data)}"
- https://questetra.zendesk.com/hc/en-us/articles/360024292872-R2272
Notes(ja):
- ファイルの数が1でない場合、エラー終了します
- 全ての定義(XML要素)につきデフォルト設定(locale 属性をもたない要素)が必須です
- EngineType: "0"= Rhino (deprecated), "1"= Nashorn, "2"= GraalJS
- 複数子要素を持つConfigs定義については箇条書HTMLを出力します(fontawesome5 icons)
- 抽出情報をもとにWebサイト原稿を生成したい場合、エスケープやテンプレ挿入を後置します
- M227: 業務データの結合や四則演算が自動実行されるように設定する
- https://questetra.zendesk.com/hc/ja/articles/360002260571-M227
- HTMLエスケープ: "#{#escapeXml(#q_xml_data)}"
- https://questetra.zendesk.com/hc/ja/articles/360024292872-R2272
*/
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const filesPocketAddon = configs.getObject( "SelectConfA" ); // required
const strLocaleCode = configs.get ( "StrConfB" ) + "";
const strPocketLabel = configs.getObject( "SelectConfC" );
const strPocketLabelEn = configs.getObject( "SelectConfC2");
const strPocketSummary = configs.getObject( "SelectConfD" );
const strPocketHelpUrl = configs.getObject( "SelectConfE" );
const strPocketLastMod = configs.getObject( "SelectConfF" );
const strPocketEngine = configs.getObject( "SelectConfG" );
const strPocketLicense = configs.getObject( "SelectConfH" );
const strPocketScript = configs.getObject( "SelectConfI" );
const strPocketConfigs = configs.getObject( "SelectConfJ" );
const strPocketImage = configs.getObject( "SelectConfK" );
//// == Data Retrieving / ワークフローデータの参照 ==
let fileAddon = engine.findData( filesPocketAddon );
// java.util.ArrayList
if( fileAddon === null ) {
throw new Error( "\n AutomatedTask UnexpectedFilesError:" +
" Files {A} not found \n" );
}
if ( fileAddon.size() > 1) {
throw new Error( "\n AutomatedTask UnexpectedFilesError:" +
" Files {A} must be single: " +
fileAddon.size() + " files attached \n" );
}
//// == Calculating / 演算 ==
/// load text (XML)
let strAddonXml = '';
let numLineCounter = 0;
fileRepository.readFile( fileAddon.get(0), "UTF-8", function(line) {
// com.questetra.bpms.core.event.scripttask.FileRepositoryWrapper
// https://questetra.zendesk.com/hc/ja/articles/360024574471-R2300#FileRepositoryWrapper
strAddonXml += 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
// /label /help-page-url /summary /license /engine-type /last-modified
// /script /configs /configs/config /icon
/// extract Label (Addon title)
let xpathLabel = "/service-task-definition/label[@locale='" + strLocaleCode + "']";
if( xpath.findNodeList( strAddonXml, xpathLabel ).getLength() == 0 ){
engine.log( " XPATH: 'locale=\"" + strLocaleCode + "\"' not found in 'label' " );
xpathLabel = "/service-task-definition/label[not(@locale)]";
}
const strLabel = xpath.findNodeText( strAddonXml, xpathLabel );
/// extract default-Label (Addon english title)
let xpathLabelEn = "/service-task-definition/label[not(@locale)]";
const strLabelEn = xpath.findNodeText( strAddonXml, xpathLabelEn );
/// extract Summary
let xpathSummary = "/service-task-definition/summary[@locale='" + strLocaleCode + "']";
if( xpath.findNodeList( strAddonXml, xpathSummary ).getLength() == 0 ){
engine.log( " XPATH: 'locale=\"" + strLocaleCode + "\"' not found in 'summary' " );
xpathSummary = "/service-task-definition/summary[not(@locale)]";
}
const strSummary = xpath.findNodeText( strAddonXml, xpathSummary );
/// extract HelpPageUrl
let xpathHelpUrl = "/service-task-definition/help-page-url[@locale='" + strLocaleCode + "']";
if( xpath.findNodeList( strAddonXml, xpathHelpUrl ).getLength() == 0 ){
engine.log( " XPATH: 'locale=\"" + strLocaleCode + "\"' not found in 'help-page-url' " );
xpathHelpUrl = "/service-task-definition/help-page-url[not(@locale)]";
}
const strHelpUrl = xpath.findNodeText( strAddonXml, xpathHelpUrl );
/// extract LastModified
let xpathLastMod = "/service-task-definition/last-modified[@locale='" + strLocaleCode + "']";
if( xpath.findNodeList( strAddonXml, xpathLastMod ).getLength() == 0 ){
engine.log( " XPATH: 'locale=\"" + strLocaleCode + "\"' not found in 'last-modified' " );
xpathLastMod = "/service-task-definition/last-modified[not(@locale)]";
}
const strLastMod = xpath.findNodeText( strAddonXml, xpathLastMod );
/// extract EngineType
let xpathEngine = "/service-task-definition/engine-type[@locale='" + strLocaleCode + "']";
if( xpath.findNodeList( strAddonXml, xpathEngine ).getLength() == 0 ){
engine.log( " XPATH: 'locale=\"" + strLocaleCode + "\"' not found in 'engine-type' " );
xpathEngine = "/service-task-definition/engine-type[not(@locale)]";
}
const strEngine = xpath.findNodeText( strAddonXml, xpathEngine );
/// extract License
let xpathLicense = "/service-task-definition/license[@locale='" + strLocaleCode + "']";
if( xpath.findNodeList( strAddonXml, xpathLicense ).getLength() == 0 ){
engine.log( " XPATH: 'locale=\"" + strLocaleCode + "\"' not found in 'license' " );
xpathLicense = "/service-task-definition/license[not(@locale)]";
}
const strLicense = xpath.findNodeText( strAddonXml, xpathLicense );
/// extract Script (not escaped)
let xpathScript = "/service-task-definition/script";
const strScript = xpath.findNodeText( strAddonXml, xpathScript );
/// extract ConfigsHTML (not escaped)
let strConfigs = "";
const xmlNodesConfig = xpath.findNodeList( strAddonXml,
'/service-task-definition/configs/config');
engine.log( " AutomatedTask XmlParsed: NumOf 'Config' = " + xmlNodesConfig.getLength() );
for( let i = 0; i < xmlNodesConfig.getLength(); i++ ){
let xpathTmp = "/service-task-definition/configs/config[" + (i+1) + "]";
// "li" prefix
strConfigs += '<li><span class="fa-li">';
if( xpath.findNodeText( strAddonXml, xpathTmp + "/@form-type" ) == "SELECT" ){
if( xpath.findNodeList( strAddonXml, xpathTmp + "[@editable='true']" )
.getLength() == 1 ){
strConfigs += '<i class="far fa-caret-square-down fa-lg"></i>';
}else{
strConfigs += '<i class="fal fa-caret-square-down fa-lg"></i>';
}
}else if( xpath.findNodeText( strAddonXml, xpathTmp + "/@form-type" ) == "TEXTFIELD" ){
strConfigs += '<i class="far fa-pen-square fa-lg"></i>';
}else if( xpath.findNodeText( strAddonXml, xpathTmp + "/@form-type" ) == "TEXTAREA" ){
strConfigs += '<i class="far fa-edit fa-lg"></i>';
}else if( xpath.findNodeText( strAddonXml, xpathTmp + "/@form-type" ) == "QUSER" ){
strConfigs += '<i class="fal fa-user fa-lg"></i>';
}else{ // "OAUTH2"
strConfigs += '<i class="fal fa-badge-check fa-lg"></i>';
}
strConfigs += '</span> ';
// "li" body
let xpathTmp2 = xpathTmp + "/label[@locale='" + strLocaleCode + "']";
if( xpath.findNodeList( strAddonXml, xpathTmp2 ).getLength() == 0 ){
engine.log( " XPATH: 'locale=\"" + strLocaleCode +
"\"' not found in 'config[" + (i+1) + "]' " );
xpathTmp2 = xpathTmp + "/label[not(@locale)]";
}
strConfigs += xpath.findNodeText( strAddonXml, xpathTmp2 );
// "li" postfix
if( xpath.findNodeList( strAddonXml, xpathTmp + "[@required='true']" )
.getLength() == 1 ){
strConfigs += '<span style="color:#990000;"> *</span>';
}
if( xpath.findNodeList( strAddonXml, xpathTmp + "[@el-enabled='true']" )
.getLength() == 1 ){
strConfigs += '<span style="color:#000099;"><sup style="font-style:italic;">#{EL}</sup></span>';
}
strConfigs += "</li>\n";
}
/// extract Base64 Encoded Image
let xpathImage = "/service-task-definition/icon";
const strImage = xpath.findNodeText( strAddonXml, xpathImage );
//// == Data Updating / ワークフローデータへの代入 ==
if( strPocketLabel !== null ){
engine.setData( strPocketLabel, strLabel );
}
if( strPocketLabelEn !== null ){
engine.setData( strPocketLabelEn, strLabelEn );
}
if( strPocketSummary !== null ){
engine.setData( strPocketSummary, strSummary );
}
if( strPocketHelpUrl !== null ){
engine.setData( strPocketHelpUrl, strHelpUrl );
}
if( strPocketLastMod !== null ){
engine.setData( strPocketLastMod, strLastMod );
}
if( strPocketEngine !== null ){
engine.setData( strPocketEngine, strEngine );
}
if( strPocketLicense !== null ){
engine.setData( strPocketLicense, strLicense );
}
if( strPocketScript !== null ){
engine.setData( strPocketScript, strScript );
}
if( strPocketConfigs !== null ){
engine.setData( strPocketConfigs, strConfigs );
}
if( strPocketImage !== null ){
engine.setData( strPocketImage, strImage );
}
} //////// END "main()" /////////////////////////////////////////////////////////////////
Download
2020-09-04 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/ja/addons/questetra-addon-xml-file-extract-configs/
Addonファイルのインポートは Professional でのみご利用いただけます
Notes
- ファイルの数が1でない場合、エラー終了します
- 全ての定義(XML要素)につきデフォルト設定(locale 属性をもたない要素)が必須です
- EngineType: “0”= Rhino (deprecated), “1”= Nashorn, “2”= GraalJS
- 複数子要素を持つConfigs定義については箇条書HTMLを出力します(fontawesome5 icons)
- 抽出情報をもとにWebサイト原稿を生成したい場合、エスケープやテンプレ挿入を後置します
- M227: 業務データの結合や四則演算が自動実行されるように設定する
- HTMLエスケープ: “#{#escapeXml(#q_xml_data)}”
- R2272: EL式による文字列としての出力(データ設定式)
- M227: 業務データの結合や四則演算が自動実行されるように設定する
Capture

