MVEL Function
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/
![](https://docs.3dolphins.ai/~gitbook/image?url=https%3A%2F%2F765826444-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYDAnLjpg2T8z2BplJOS%252Fuploads%252FBWco3GLdq39TB0QGLehb%252FMVEL%2520Function.png%3Falt%3Dmedia%26token%3Dfb58cbe2-7db6-418f-8a4e-2f14e5c2748a&width=768&dpr=4&quality=100&sign=ed77d745&sv=1)
Component Explanation:
Name | 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. |
MVEL Script
Consider the workflow example below.
![](https://docs.3dolphins.ai/~gitbook/image?url=https%3A%2F%2F765826444-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYDAnLjpg2T8z2BplJOS%252Fuploads%252FgvODmN1QxCILQbKctPi7%252FPublic%2520Holiday%2520workflow.png%3Falt%3Dmedia%26token%3Dd096fcc3-1564-4ebe-bf40-55a63a702979&width=768&dpr=4&quality=100&sign=92795a25&sv=1)
Click the MVEL component then type your script to get information about a national calendar of all 2020 holidays, such images below.
![](https://docs.3dolphins.ai/~gitbook/image?url=https%3A%2F%2F765826444-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYDAnLjpg2T8z2BplJOS%252Fuploads%252F2Jr3Els0ePRT0TjM7nLQ%252FMVEL%2520Settings.png%3Falt%3Dmedia%26token%3Ddd585685-8e0d-48a3-9f6a-bca7e2bfd63a&width=768&dpr=4&quality=100&sign=d2589ee3&sv=1)
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. |
MVEL Output
Output form MVEL script (display information about a national calendar of all 2020 holidays).
![](https://docs.3dolphins.ai/~gitbook/image?url=https%3A%2F%2F765826444-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FLYDAnLjpg2T8z2BplJOS%252Fuploads%252FZ3XPnkCJnOYyYSgMIFnS%252FMVEL%2520Output%2520edit.png%3Falt%3Dmedia%26token%3D231d300f-de29-46db-842c-f3d8270d69d1&width=768&dpr=4&quality=100&sign=3a0b75e5&sv=1)
Last updated