MVEL Function
Last updated
Last updated
MVEL has largely been inspired by Java syntax, but has some fundamental differences aimed at making it more efficient as an expression language, such as operators that directly support collection, array and string matching, as well as regular expressions. MVEL is used to evaluate expressions written using Java syntax.
In addition to the expression language, MVEL serves as a templating language for configuration and string construction. To view example of MVEL expression language please refer to : http://mvel.documentnode.com/
Component explanation :
Component | Description |
MVEL Script Name | The node_id in the workflow component. |
MVEL Script | This section for develop script from a series of process flow. |
MVEL Output | Output form MVEL script. |
Evaluate | To run the node. |
Add | To save the node. |
Consider the workflow example below.
Click the MVEL component then type your script to get information about a national calendar of all 2020 holidays, such as images below.
A detailed description of the script, can be seen in the table below :
Name | Description |
Size | To get the number of public holiday objects from "response": { "holidays": [ which is on the response of node 'HttpHoliday'. |
import java.text.ParseException; | To Import class of java parse exception |
import java.text.SimpleDateFormat; | To Import class of java simple date format |
import java.util.Date; | To Import class of java simple date format date |
import java.time.LocalDateTime; | To Import class of java local date time |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | To declare sdf variable as ‘simple date format’ with yyyy-MM-dd format |
def getHoliday() | To declare a function (get holiday) |
result = ""; | Declare a result variable with an empty value (""). |
Date now = new Date(); | To declare a variable now as a date, the value is the variable date in the declaration. |
for (int i=0;i<size;i++) | looping formula |
Date date = sdf.parse(response.response.holidays[i].date.iso); | To declare a variable now as a date, the value is a public holiday date. |
if (date.after(now) && response.response.holidays[i].date.iso.length < 12) | The formula for knowing whether the date of the public holiday is past from the date of the variable now in the declaration, and the ISO date must be under 12 letters. |
result += response.response.holidays[i].date.iso + " : " + response.response.holidays[i].name +"\n"; | If the formula = true, will display response (date.iso and name of public holiday) |
return result; | Returns the result of the getHoliday function |
return getHoliday(); | Return the result of the MVEL function has been made. |
Output form MVEL script (display information about a national calendar of all 2020 holidays).