forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: chenxiaoxiong <chenxiaoxiong@huawei.com> Co-committed-by: chenxiaoxiong <chenxiaoxiong@huawei.com>
133 lines
14 KiB
HTML
133 lines
14 KiB
HTML
<a name="dataartsstudio_01_4803"></a><a name="dataartsstudio_01_4803"></a>
|
|
|
|
<h1 class="topictitle1">Examples of Common EL Expressions</h1>
|
|
<div id="body0000001486073500"><p id="dataartsstudio_01_4803__p8060118">This section describes common EL expressions and examples.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dataartsstudio_01_4803__en-us_topic_0132846497_table14461689017" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Common EL expressions</caption><thead align="left"><tr id="dataartsstudio_01_4803__en-us_topic_0132846497_row2446087010"><th align="left" class="cellrowborder" valign="top" width="21.52%" id="mcps1.3.2.2.4.1.1"><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p444698004">Method</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="38.97%" id="mcps1.3.2.2.4.1.2"><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p14461485016">Description</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="39.51%" id="mcps1.3.2.2.4.1.3"><p id="dataartsstudio_01_4803__p174611843131310">Example</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dataartsstudio_01_4803__en-us_topic_0132846497_row1440191316465"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p144411113164610">String getNodeStatus(String nodeName)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p54411313204616">Obtains the running status of a specified node. If the node runs properly, success is returned. If the node fails to run, fail is returned.</p>
|
|
<p id="dataartsstudio_01_4803__p5944185517125">For example, to check whether a node is running successfully, you can use the following command, where <strong id="dataartsstudio_01_4803__en-us_topic_0181380779_b385515722216">test</strong> indicates the node name:</p>
|
|
<p id="dataartsstudio_01_4803__p5601638111118"><strong id="dataartsstudio_01_4803__en-us_topic_0181380779_b1539912315233">#{(Job.getNodeStatus("test")) == "success" }</strong></p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><p id="dataartsstudio_01_4803__p1854612377146">Obtains the running status of the test node:</p>
|
|
<p id="dataartsstudio_01_4803__p11461124318132">#{Job.getNodeStatus("test")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__en-us_topic_0132846497_row74461885010"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p1044611814010">String getNodeOutput(String nodeName)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p104461088020">Obtains the output of a specified node. This method can only obtain the output of the previous dependent node.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><ul id="dataartsstudio_01_4803__ul1846618186203"><li id="dataartsstudio_01_4803__en-us_topic_0181380779_li195472311206">Obtains the output of the test node:<p id="dataartsstudio_01_4803__en-us_topic_0181380779_p196541123172010"><a name="dataartsstudio_01_4803__en-us_topic_0181380779_li195472311206"></a><a name="en-us_topic_0181380779_li195472311206"></a>#{Job.getNodeOutput("test")}</p>
|
|
</li><li id="dataartsstudio_01_4803__en-us_topic_0181380779_li2182216122812">If the previous node has no execution result, the output is null.</li><li id="dataartsstudio_01_4803__en-us_topic_0181380779_li846661813203">If the output of a node is a field, the output result is in the format like <strong id="dataartsstudio_01_4803__en-us_topic_0181380779_b1370115071015">[["000"]]</strong>. In this case, you can use the EL expression to split the string result and obtain the field value output by the previous node. Note that the output result type is string. If you want to output the original data type, you need to use the EL expression of the For Each node and the loop embedded objects supported by the node.<p id="dataartsstudio_01_4803__en-us_topic_0181380779_p38004205209">#{StringUtil.split(StringUtil.split(StringUtil.split(Job.getNodeOutput("Name of the previous node"),"]")[0],"[")[0],"\\"")[0]}</p>
|
|
</li><li id="dataartsstudio_01_4803__en-us_topic_0181380779_li9843713182711">If the output of a node contains two or more fields, the output result is in the format like <strong id="dataartsstudio_01_4803__en-us_topic_0181380779_b165142610152">[["000"],["001"]]</strong>. In this case, you need to obtain the output result using the EL expression of the For Each node and the loop embedded objects supported by the node, for example, <strong id="dataartsstudio_01_4803__en-us_topic_0181380779_b16826129175915">#{Loop.current[0]}</strong>.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__en-us_topic_0132846497_row1244611818019"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p1446581604">String getParam(String key)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__p11150133719402">Obtains job parameters.</p>
|
|
<p id="dataartsstudio_01_4803__p7739747114213">This method only obtains the parameter values configured for the current job, but not parameter values passed from the parent job or the global variables configured for the workspace.</p>
|
|
<p id="dataartsstudio_01_4803__en-us_topic_0132846497_p144462081400">To obtain the parameter values passed from the parent job and the global variables configured for the workspace, you are advised to use the ${job_param_name} expression.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><p id="dataartsstudio_01_4803__p10461184361318">Obtains the value of the <strong id="dataartsstudio_01_4803__en-us_topic_0181380779_b1525312489192">test</strong> parameter:</p>
|
|
<p id="dataartsstudio_01_4803__p351915173162">#{Job.getParam("test")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__en-us_topic_0132846497_row1344688307"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p24461781011">String getPlanTime(String pattern)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p204461881204">Obtains the plan time character string in a specified pattern. Pattern indicates the date and time mode. For details, see <a href="dataartsstudio_01_0496.html">Date and Time Mode</a>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><p id="dataartsstudio_01_4803__p142797322177">Obtains the planned job scheduling time, which is accurate to millisecond:</p>
|
|
<p id="dataartsstudio_01_4803__p19279163271714">#{Job.getPlanTime("yyyy-MM-dd HH:mm:ss:SSS")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__en-us_topic_0132846497_row14461083020"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p2446148805">String getYesterday(String pattern)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p10446383018">Obtains the time character string of the day before the plan time. Pattern indicates the date and time mode. For details, see <a href="dataartsstudio_01_0496.html">Date and Time Mode</a>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><p id="dataartsstudio_01_4803__p8154154321715">Obtains the time on the previous day of the planned job scheduling time, which is accurate to date:</p>
|
|
<p id="dataartsstudio_01_4803__p1484558162016">#{Job.getYesterday("yyyy-MM-dd HH:mm:ss:SSS")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__en-us_topic_0132846497_row184461381903"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p194461688018">String getLastHour(String pattern)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__en-us_topic_0132846497_p11446108105">Obtains the time character string of last hour before the plan time. Pattern indicates the date and time mode. For details, see <a href="dataartsstudio_01_0496.html">Date and Time Mode</a>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><p id="dataartsstudio_01_4803__p4775456102313">Obtains the time one hour before the planned job scheduling time, which is accurate to hour:</p>
|
|
<p id="dataartsstudio_01_4803__p117764562235">#{Job.getLastHour("yyyy-MM-dd HH:mm:ss:SSS")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__row1336019511758"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__en-us_topic_0132846499_p36229173170">Date addDays(Date date, int amount)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__en-us_topic_0132846499_p762291715173">After the specified number of days is added to Date, the new Date object is returned. The amount can be a negative number.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><p id="dataartsstudio_01_4803__p112741632133810">Subtracts one day from the planned job scheduling time and convert the time to the yyyy-MM-dd format.</p>
|
|
<p id="dataartsstudio_01_4803__p72744328384">#{DateUtil.format(DateUtil.addDays(Job.planTime,-1),"yyyy-MM-dd")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__row11436125873116"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__p2430658143113">int getDay(Date date)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__p7430165893118">Obtains the day from the date. For example, if the date is 2018-09-14, 14 is returned.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><p id="dataartsstudio_01_4803__p9430135818313">Obtain the day from the job scheduling plan.</p>
|
|
<p id="dataartsstudio_01_4803__p11430175818312">#{DateUtil.getDay(Job.planTime)}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__row316110018321"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__p51587012324">Date now()</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__p1215811013219">Returns the current time.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><p id="dataartsstudio_01_4803__p915817083218">Return the current time accurate to second.</p>
|
|
<p id="dataartsstudio_01_4803__p1715890193210">#{DateUtil.format(DateUtil.now(),"yyyy-MM-dd HH:mm:ss")}</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__row293313481350"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__p1492274818351">Object path(String jsonStr,String jsonPath)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__p15922048113519">Returns the field value in a path specified by the JSON character string. This method is similar to XPath and can be used to retrieve or set JSON by path. You can use . or [] in the path to access members and values. For example, tables[0].table_name.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><div class="p" id="dataartsstudio_01_4803__p16922248163511">The content of variable str is as follows:<pre class="screen" id="dataartsstudio_01_4803__en-us_topic_0181380782_screen17391191243310">{
|
|
"cities": [{
|
|
"name": "city1",
|
|
"areaCode": "1000"
|
|
},
|
|
{
|
|
"name": "city2",
|
|
"areaCode": "2000"
|
|
},
|
|
{
|
|
"name": "city3",
|
|
"areaCode": "3000"
|
|
}]
|
|
}</pre>
|
|
</div>
|
|
<div class="p" id="dataartsstudio_01_4803__p39221948133514">The expression for obtaining the area code of city1 is as follows:<pre class="screen" id="dataartsstudio_01_4803__en-us_topic_0181380782_screen839291211331">#{JSONUtil.path(str,"cities[0].areaCode")}</pre>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr id="dataartsstudio_01_4803__row2932048153512"><td class="cellrowborder" valign="top" width="21.52%" headers="mcps1.3.2.2.4.1.1 "><p id="dataartsstudio_01_4803__p1292216483353">current</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="38.97%" headers="mcps1.3.2.2.4.1.2 "><p id="dataartsstudio_01_4803__p14922748123513">For Each nodes process data in a dataset by row. <strong id="dataartsstudio_01_4803__en-us_topic_0227436054_b14108183511394">Loop.current</strong> indicates a row of a two-dimensional array defined in the dataset of the For Each node. This row is a one-dimensional array.</p>
|
|
<p id="dataartsstudio_01_4803__p292244833516">Generally, the format is similar to <strong id="dataartsstudio_01_4803__en-us_topic_0227436054_b1256618126414">#{Loop.current[0]}</strong>, <strong id="dataartsstudio_01_4803__en-us_topic_0227436054_b963232064110">#{Loop.current[1]}</strong>, or others. <strong id="dataartsstudio_01_4803__en-us_topic_0227436054_b953123810416">[0]</strong> indicates the first value in the current row, <strong id="dataartsstudio_01_4803__en-us_topic_0227436054_b1695914614414">[1]</strong> indicates the second value in the current row, and so on.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="39.51%" headers="mcps1.3.2.2.4.1.3 "><p id="dataartsstudio_01_4803__p129222489353">The value of <strong id="dataartsstudio_01_4803__en-us_topic_0227436054_b38633123428">Subjob Parameter</strong> for the For Each node indicates that the second value in the traversed row of the two-dimensional array in the dataset is always used in the loop traversal of the For Each node.</p>
|
|
<p id="dataartsstudio_01_4803__p492216484351">#{Loop.current[1]}</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dataartsstudio_01_0493.html">EL Expression Reference</a></div>
|
|
</div>
|
|
</div>
|
|
|