MVEL Expression Language - Studio
MVEL Expression Language - Studio
Table of Contents
1 MVEL Expressions.............................................................................................................................. 5
1.1 Naming Conventions.......................................................................................................................... 5
1.2 MVEL Autocomplete:......................................................................................................................... 5
1.3 MVEL 2.x expressions....................................................................................................................... 6
2 Operators............................................................................................................................................. 8
2.1 Unary Operator:................................................................................................................................. 8
2.2 Comparison Operator......................................................................................................................... 8
2.3 Logical Operators............................................................................................................................. 10
2.4 Arithmetic Operators........................................................................................................................ 11
2.5 Other Operators............................................................................................................................... 12
3 Assignment........................................................................................................................................ 13
3.1 Literals:............................................................................................................................................ 13
3.2 Difference b/w Assignment and Equal............................................................................................. 14
4 Launch Parameter:............................................................................................................................ 15
4.1 Simple Type Parameter:.................................................................................................................. 15
4.2 Reference Type Parameter:............................................................................................................. 16
4.3 Convert Array Values to String......................................................................................................... 17
4.4 Date From Launch Parameter.......................................................................................................... 19
5 Integration Attributes:....................................................................................................................... 20
5.1 Simple Type Parameter:.................................................................................................................. 20
5.2 Reference Type Parameter:............................................................................................................. 20
5.3 Convert Array Values to String......................................................................................................... 20
6 Integration MAP........................................................................................................................... 22
7 Sequence Generator......................................................................................................................... 24
8 Da: Document Accessor(To retrieve Input File).............................................................................25
9 Evaluate Xpath: parts[].................................................................................................................. 26
9.1 Format Date..................................................................................................................................... 26
9.2 Format Number................................................................................................................................ 27
9.3 Right/Left Justification (Padding)..................................................................................................... 27
10 Mvel Functions.................................................................................................................................. 28
10.1 Substring....................................................................................................................................... 28
10.2 Index of......................................................................................................................................... 28
10.3 Substring-before........................................................................................................................... 29
10.4 Substring-after.............................................................................................................................. 29
10.5 Replace or Translate..................................................................................................................... 29
10.6 Contains........................................................................................................................................ 29
10.7 Normalize space:.......................................................................................................................... 29
10.8 Length:.......................................................................................................................................... 30
10.9 Concat.......................................................................................................................................... 30
2
MVEL Expression Language
3
MVEL Expression Language
4
MVEL Expression Language
1 MVEL Expressions
MVEL is an incredibly powerful expression language which is tightly integration into the Workday ESB's Assembly
framework. With MVEL is it possible to construct powerful and flexible expressions for manipulating Assembly context
variables and associated Java objects, but as ever, with great power comes great responsibility!
A large number of properties are added to the mediation context by the ESB and some of the
shared components. Prefixing the properties you declare within your integration name will
making them easier to find when debugging the assembly and add a conceptual scope to the
properties. For example:
props['payforce.company.name']
If you set properties to contain the values of integration attributes, use "ia" as the prefix. For
example:
props['ia.include.job.code']
For Launch parameter : props['lp.include.job.code']
Always ensure that your property names are meaningful. Do not be tempted to abbreviate
property names. Descriptive and meaningful property names aid readability, and reduce the
overall cost of maintaining the code over subsequent revision.
Need help with the syntax of particular operations or with the names of
elements in your flow?, you can always access MVEL suggestions by
pressing Ctrl + Space Bar.
5
MVEL Expression Language
Property expressions
Boolean expressions
Method invocations
Variable expression
Function definitions
context.getProperty('myProperty')
6
MVEL Expression Language
props.myProperty
The following expression returns the property value set by a custom Spring bean:
You may write scripts with an arbitrary number of statements using the semi-colon to
denote the termination of a statement. This is required in all cases except in cases where
Syntax:
vars['payroll.payee.in.extract']
props[‘user.name’] = vars['payroll.payee.in.extract']
7
MVEL Expression Language
2 Operators
2.1 Unary Operator:
2.1.1 new
Object instantiation or instance of class and allocating memory to the object.
props['p.ee.hash.map'] = new java.util.HashMap()
10 == 10 then true
8
MVEL Expression Language
Less Than Check. Checks to see if the value on the left side of the operator is less than value on the right.
2.2.7 Contains
Value Containment Check. Checks to see if the value on the left contains the value on the right
9
MVEL Expression Language
2.3.2 Logical OR : ||
Logical OR. Checks to see if either the value on the left or the right is true.
props['count'] || props['employee.count']
2.3.3 Chained OR : or
Chained OR. Checks a sequence of values for emptiness and returns the first non-empty value
Result: props['emp'] = 'Employee' since first property has value so it won’t check next property.
Result: props['emp'] = 'Contingent' since first property is null So it checked next property and
returned it value.
10
MVEL Expression Language
2.4.1 Addition: +
Result: props['emp'] = 15
2.4.2 Subtraction: -
Result: props['emp'] = 5
2.4.3 Division: /
props['count'] = 4; props['employee.count'] = 2
Result: props['emp'] = 2
2.4.4 Multiplication: *
props['count'] = 4; props['employee.count'] = 2
Result: props['emp'] = 8
2.4.5 Modulus: %
props['count'] = 9; props['employee.count'] = 4
11
MVEL Expression Language
props['emp']="Contingent"; props['emp1']="Worker"
2.5.3 Assignment: =
Assignment. Assigns the value on the right to the variable on the left.
props['num'] = 12
props['num'] = true
props['emp'] = ''
12
MVEL Expression Language
3 Assignment
MVEL allows you assign variable in your expression, either for extraction from the runtime,
or for use inside the expression.
3.1 Literals:
3.1.1 Strings
props[‘user.name’] = '<hello>world</hello>'
props['employee_id_string'] = '<wd:Employee_Reference><wd:Integration_ID_Reference><wd:ID
wd:System_ID="WD-EMPLID">' + props['file_empid'] +
'</wd:ID></wd:Integration_ID_Reference></wd:Employee_Reference>'
Assigning mimeType:
3.1.2 Numerics
props['count'] = 0
props['count'] = 1+2
13
MVEL Expression Language
3.1.3 Boolean
Boolean literals are represented by the reserved keywords true and false.
props['count'] = true
props['count'] = false
The null literal is denoted by the reserved keywords null or nil or '' or empty.
props['count'] = null
props['count'] = nil
props['count'] = ''
props['count'] = empty
props['count'] = 0
props['count'] = empty
props['count'] = true
Equal: Here checking or testing this property is equal to that value or not
props['count'] == 0
props['count'] == empty
props['count'] == true
14
MVEL Expression Language
4 Launch Parameter:
Mvel helper class is lp: Provides access to the integration launch parameters. The lp variable
is only applicable to Workday internal server and integration Cloud developers.
Mvel helper class for launch parameter is lp and to get data from simple type launch parameter need to use
getSimpleData('label') and here label should be your prompt name “Tax Frequency Value”.
Type lp. then press CNTRL + Space Bar then you will get all related methods.
EG: lp.getSimpleData('label')
if we want to pass this below simple type prompt property value to Raas Report prompt
should convert it to string then you call this property to raas call to give input to your raas
report prompt.
props['lp.cc.wid']=lp.getSimpleData('Cost Centers')
props['get.cc.wid.prompt'] = props['lp.cc.wid'].toString()
15
MVEL Expression Language
@{intsys.reportService.g
etExtrapath('costcenterpr
omptvaluegiven')}? 4.2 Reference Type Parameter:
Cost_Center!
WID=@{props['get.cc.wi Reference Type Parameter is nothing but prompt on your webservices fields.
d.prompt']} By clicking yellow arrow mark in the below screenshot you can access
webservice fields. There to find the fields directly you can select CRF(class
report fields) and you can type the fields on search bar or else you can take it
by expanding the webservice requests.
16
MVEL Expression Language
props['lp.run.category'] =
lp.getReferenceData('Ru
n Category Type', 4.3 Convert Array Values to String
'Run_Category_ID')
To convert an array list to a string, the following can be used
(Array of Workers converted to a string to be used in a REST
or URL for RaaS):
props['lp.run.category'] =
lp.getReferenceData('Ru
n Category Type', ‘WID’)
To use Multi Instance reference type prompt value we need to use any one
of the below method
17
MVEL Expression Language
props['lp.cc.wid'] = lp.getWIDs('label')
or
props['lp.cc.wid'] = lp.getReferenceDataList('label', 'type')
To get the multiple values or list of values selected in Launch Parameter prompt use below
methods :
or
Should convert this output format to following format which would be supported by raas report. To convert
as below should use below property.
6cb77610a8a543aea2d6bc10457e35d4!bc33aa3152ec42d4995f4791a106ed09!
80938777cac5440fab50d729f9634969!c4f78be1a8f14da0ab49ce1162348a5e
props['get.cc.wid.prompt']=props['lp.cc.wid']!=empty?
util.listToCommaDelimString(context.getProperty('lp.cc.wid')).replace(',','!') : null
should pass this property props['get.cc.wid.prompt'] to raas Report now. will now be a string of cost
center WIDs. The commas (,) are replaced by exlamation marks (!) as this is how you separate IDs in a
REST URL for Workday RaaS end points.
output: 6cb77610a8a543aea2d6bc10457e35d4!bc33aa3152ec42d4995f4791a106ed09!
80938777cac5440fab50d729f9634969!c4f78be1a8f14da0ab49ce1162348a5e
18
MVEL Expression Language
@{intsys.reportService.g
etExtrapath('costcenterpr
omptvaluegiven')}? In background input should go to raas report in below
Cost_Center! format:
WID=@{props['get.cc.wi
d.prompt']} customreport2/medtronic4/jthangaraj/MyCustomReport?
CostCenters!WID=6cb77610a8a543aea2d6bc10457e35d4!
bc33aa3152ec42d4995f4791a106ed09!
80938777cac5440fab50d729f9634969!
c4f78be1a8f14da0ab49ce1162348a5e
props['date'] = lp.getDate('label')
props['lp.lastsuccessful.date']=props['lp.lastsuccessful.datetime'].substring(0,10)
19
MVEL Expression Language
5 Integration Attributes:
Mvel helper class is intsys: Provides access to the integration system configuration for this assembly.
Syntax: props['sftpEndPoint']=intsys.getAttribute('label')
props['sftpEndPoint']=intsys.getAttribute('SFTP Endpoint')
props['ia.run.category']=intsys.getAttributeReferenceData('RunCategoryType','Run_Category_ID')
or
props['ia.run.category']=intsys.getAttributeReferenceData('RunCategoryType','WID')
To convert an array list to a string, the following can be used (Array of Workers converted to a string to be
used in a REST URL for RaaS):
20
MVEL Expression Language
xmlns:is="java:com.workday.esb.intsys.xpath.ParsedIntegrationSystemFunctions"
is:getIntegrationAttributeValue('Entity Name')
(note the alternative mechanism for passing attribute values into XSLT in the next
paragraph):
21
MVEL Expression Language
6 Integration MAP
Syntax:
simpleTextTypeMap
enumTypeMap
referenceTypeMap
Syntax:
simpleTextTypeMap
22
MVEL Expression Language
enumTypeMap
props['ia.enum.map'] = intsys.integrationMapReverseLookup('enumTypeMap', 1)
referenceTypeMap
In XSLT or STX, first declare the "is" namespace in stylesheet: Then call the method from an XPath expression
xmlns:is="java:com.workday.esb.intsys.xpath.ParsedIntegrationSystemFunctions"
is:getIntegrationMapValue('Time_Off_Codes','Time_Off_Type_ID')
(note the alternative mechanism for passing attribute values into XSLT in the next paragraph):
S
Declare a stylesheet parameter in the XSLT as follows:
<xsl:value-of select="$ia.simple.map"></xsl:value-of>
23
MVEL Expression Language
7 Sequence Generator
which you can use to generate unique, sequenced file names. If your integration system needs to create a different
file name each time it runs, you can associate a sequence generator service with your Workday-in transport to
generate the file name. You define the service with one or more named sequencers in Studio, then configure the
sequencers in Workday.
props['lp.batch.id.seq'] = lp.getSequencedValue('label')
props['lp.batch.id.seq'] = lp.getSequencedValue('BatchIDSequence')
24
MVEL Expression Language
The following example gets a document from the Integration Event with filename
eib_transform_output.txt and adds is as a variable named var1:
da.toVar('eib_transform_output.txt', 'var1')
or
25
MVEL Expression Language
For example, to get the content of first attachment, the root part:
parts[0].text
parts[1].text
props['eval.xpath']=parts[0].xpath('/env:Envelope/env:Body/wd:Get_Workers_Response/wd:Response_Data/
wd:Worker/wd:Worker_Data/wd:User_ID')
props['row.employee.id'] = parts[0].xpath('payment_Offcycle/EMPLID',props['namespace.row'])
To format a date using MVEL instead of XSLT, it can be done using the following example
(yyyy-MM-dd converted to MM/dd/yyyy):
props['p.input.date'] = '2013-10-03'
26
MVEL Expression Language
To format a number using MVEL instead of XSLT, it can be done using the following example
(##0.0000 converted to ##0.00):
Output: 0000001234
Output: 1234000000
27
MVEL Expression Language
10 Mvel Functions
10.1 Substring
Returns the substring from the start position to the specified length. Index of the first character is 1 here. If length is
omitted it returns the substring from the start position to the end
Example: substring('Beatles',1,4)
Result: 'Beat'
For String:
props['lastupddttm'] = 'Beatles'
props['lastupd_dt'] = props['lastupddttm'].toString().substring(1, 4)
For Integer:
props['Birth.Date']=props['birth.date'].substring(0,10)
props['payment'] = parts[0].xpath("//Payment_Date").substring(2)
props['payment'] = 14-03-30T00:00:00.000-07:00
10.2 Index of
Returns the positions within the sequence of items that are equal to the search item
argument. Index starts with 0 here.
Result: 2
28
MVEL Expression Language
props['p.index.separator'] = parts[0].xpath("//Payment_Date").indexOf("-")
10.3 Substring-before
parts[0].xpath("//Payment_Date") returns 2014-03-30T00:00:00.000-07:00
props['p.index.separator'] = parts[0].xpath("//Payment_Date").indexOf("-")
props['p.substring.before']= parts[0].xpath("//Payment_Date").substring(0,props['p.index.separator']);
Result: 2014
10.4 Substring-after
props['p.index.separator'] = parts[0].xpath("//Payment_Date").indexOf("-")
props['p.substring.after']=parts[0].xpath("//
Payment_Date").substring(props['p.index.separator']+1);
props['Worker_Type'] = "Active_Worker"
input: gray12345-2014.pdf
props['p'] = gray12345-2014.pdf
props['p.cleaned'] = props['p'].replaceAll('[^0-9]','')
output: 123452014
props['p.cleaned'].substring(0,5)
output: 12345
29
MVEL Expression Language
10.7 Contains
props['managerNotInWDError']=props['manager.errmessageback'].toString().contains('not a valid ID')
Example: Employee Id is not a valid id contains not a valid id string then returns true
Removes leading and trailing spaces from the specified string, and replaces
all internal sequences of white space with one and returns the result. If
there is no string argument it does the same on the current node
props['row.plan.id']= parts[0].xpath("normalize-space(/record/PLAN_ID)")
10.9 Length:
props['EmployeeID'] = '20558'
props['emp.length'] = (props['EmployeeID'].length()
Result: props['emp.length'] = 5
10.10 Concat
props['lp.batch.id.seq']= lp.getSequencedValue('BatchIDSequence').toString().concat(props['Location'])
30
MVEL Expression Language
props['payment']=parts[0].xpath("//Payment_Date").equalsIgnoreCase('2014')
Result: props['payment']= true (If it equals will return true otherwise false)
props['total.taxes.paid.processed']= parts[0].xpath("sum(//Total_SOT_Processed)")
10.13.2 Count
EG: Do count the number of nodes
props['multiple.state.tax.election']=parts[0].xpath("count(/Worker_Tax_Election/State_Tax_Election)")
count with namespace used:
props['total_message_count_from_report']=
parts[0].xpath("count(Cost_Center_Data/Cost_Centers)",props['namespace.row'])
10.14 Lowercase
props['lowercas']=parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').toLowerCase()
10.15 UpperCase:
31
MVEL Expression Language
props['lowercas'] =parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').startsWith('prefix')
props['lowercas'] =parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').startsWith('W')
EG: Word starts with W (Condition satisfies then returns true or else returns false).
props['lowercas'] =parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').endsWith('suffix')
props['lowercas'] =parts[0].xpath('/Off-cycle_Input_Data/Deduction_Reference/ID').endsWith('r')
EG: Colour ends with r (Condition satisfies then returns true or else returns false)
props['ap.worker.past.map'].clear()
props['p.ee.hash.map'].remove(props['p.employee.id'])
10.19 Append
props['ap.page.worker.wids.sb'] = new java.lang.StringBuilder()
if(props['worker.hired.exists']==false){props['ap.page.worker.wids.sb'].append(props['current.worker.wid']).append(',') }
32
MVEL Expression Language
11.1 if
11.2 If else
Syntax: if(props['p.is.boolean']){/*do something here*/}else]){/*do something here*/}
if(props['row.employee.id']!=props['last.employee.id']){props['worker.offcycle.priority.out']=0;}
else{props['worker.offcycle.priority.out']=empty;}
11.3 else if
Syntax:if(props['p.is.boolean']){/*dosomethinghere*/}elseif(props['row.employee.id']==props['last.employee.id']) {/*do
something here*/}else{/*do something here*/}
if(props['row.employee.id']!=props['last.employee.id'])
{ props['worker.offcycle.priority.out']=0;}elseif(props['row.employee.id']==props['last.employee.id'])
{props['worker.offcycle.priority.out']=1;}else{props['worker.offcycle.priority.out']=empty;}
33
MVEL Expression Language
12 Ternary Operator:
12.1 Ternary statements:
if props['count'] > 0 it returns Employee otherwise it will check whether props['count'] == 1 returns Contingent
Otherwise returns Worker
34
MVEL Expression Language
props['p.hash.key.value']=parts[0].xpath("wd:Report_Entry/wd:Employee_ID")
props['p.ee.hash.map'].put(props['p.hash.key.value'], parts[0].text)
After splitter Compare Input File with rass or websrvice call and get employee id:
props['p.employee.id']=parts[0].xpath("record/EmployeeID")
vars['p.ee.node']=props['p.ee.hash.map'].get(props['p.employee.id'])
if employee is found get custom id which is put along with employee id in hashmap
props['p.current.custom.id'] =if(vars['p.ee.node']!=empty){vars['p.ee.node'].xpath("wd:Report_Entry/wd:Custom_ID");}
Use this logic to convert an array into a single HashMap. In this example, we are just checking that a value exists in
the HashMap. A common use case is you only want to process employees who are in a certain organization defined
by an integration multi-value attribute. If the Map returns a '1' value, this translates to a the get() being successful
2) Get your Array list. In this case, it's a multi-value integration attribute
35
MVEL Expression Language
props['p.myAttributesList.count'] = props['p.myAttributeList'].size()
4) Loop through the Array for each p.myAttributesList.count and put the list values in the HashMap
foreach(x : props['p.myAttributesList.count']){props['p.myHashMap'].put(props['p.myAttributeList'].get(x-1),'1')}
Note:If we add or put our data to list or array list then only we can use for loop or for-each statement in mvel
expressions.
list = context.getProperty('list');
props['id']=parts[0].xpath('/Put_Payroll_Off-cycle_Payment_Request/Payroll_Off-cycle_Payment_Data/Payment_ID')
list.add(props['id']); context.setProperty('list',list);
After aggregator
list = context.getProperty('list');
props['excluded-dce'] = false
36
MVEL Expression Language
props['p.my.value']=parts[0].xpath("wd:Report_Entry/wd:Employee_ID")
if(!props['p.my.array.list'].contains(props['p.my.value'])) {props['p.my.array.list'].add(props['p.my.value']); }
When you need to check if the data exists, you can do the following which returns a boolean:
37
MVEL Expression Language
props['p.hash.key.value']=parts[0].xpath("wd:Report_Entry/wd:Employee_ID")
props['p.ee.hash.map'].put(props['p.hash.key.value'], parts[0].text)
props['p.remaining.keys'] = props['p.ee.hash.map'].keySet()
props['p.employee.id']=parts[0].xpath("record/EmployeeID")
vars['p.ee.node']=props['p.ee.hash.map'].get(props['p.employee.id'])
props['p.ee.hash.map'].remove(props['p.employee.id'])
38
MVEL Expression Language
<root>
@foreach{props['p.remaining.keys'] as id}
<ee>@{id}</ee>
@end{}
</root>
<root>
@if{props['p.is.boolean']}
<ee>*Do Something Here*</ee>
@end{}
</root>
<wd:Workday_Account_for_Worker_Update
xmlns:wd="urn:com.workday/bsvc"
wd:version="v21.1">
<wd:Worker_Reference>
@{props['employee_id_string']}
</wd:Worker_Reference>
<wd:Workday_Account_for_Worker_Data>
@if{(props['worker_status'] == 'Inactive' && props['company_reference_id'] == 'MNA' &&
props['ia_allow_inactive_accounts'] == true) || (props['worker_status'] == 'Active' && props['company_reference_id'] ==
'MNA') || (props['worker_status'] == 'Inactive' && props['ia_allow_inactive_accounts'] == true)}
<wd:Account_Disabled>true</wd:Account_Disabled>
@end{}
@if{props['worker_status'] == 'Active' && props['company_reference_id'] != 'MNA'}
<wd:Account_Disabled>false</wd:Account_Disabled>
@end{}
</wd:Worker_Reference>
</wd:Workday_Account_for_Worker_Update>
</env:Body>
</env:Envelope>
39
MVEL Expression Language
props['total.count'] =0
After Splitter
props['total.count'] = props['total.count'] + 1
props['total.count']=parts[0].xpath("count(/Worker_Tax_Election/State_Tax_Election)")
props['prop.success.count']=0
props['prop.success.count'] = props['prop.success.count'] + 1
props['prop.error.count'] =0
After handling send error component where we use our webservice request
props['prop.error.count'] = props['prop.error.count'] + 1
40
MVEL Expression Language
props['prop.percentage.change'] == true
props['prop.current.percentage']+'% complete.'
41
MVEL Expression Language
Varia
Description Usage examples
ble
con Provides access to the The following expression gets the value of the property
tex MediationContext object, myProperty on the MediationContext:
t which is the main context
object used to pass information context.getProperty('myProperty')
around in assemblies. This
class contains various objects
used to store and pass the data
between the assembly
components, including:
MediationMessage
variables
properties
assembly audit
customer id
dynamic endpoint
da Within a Workday Studio The following example gets a document from the
integration, you can use the Integration Event with filename
Document Accessor (da) eib_transform_output.txt and adds is as a
variable within an eval step's variable named var1:
MVEL expression to access a
document. da.toVar('eib_transform_output.txt', 'var1')
env Provides access to the JVM The following example returns the cc.hostname
system properties. environment property set as -Dcc.hostname on the
command line:
env['cc.hostname']
42
MVEL Expression Language
Varia
Description Usage examples
ble
epg Provides access to the The following MVEL expressions return various results
wd.external.paygroupsMediati from calls to the Get_External_Paygroups Web
onContext property, which service:
contains the result of a call to
the epg.isSet() == true
Get_External_Paygroups
Web service operation. The epg.getExternalPayGroups('descriptor'
epg variable is only applicable )
to Workday internal server and
integration Cloud developers.
epg.getExternalPayGroupWID('descripto
r')
epg.getStartDate('periodWid')
epg.getStartDate('payGroupWid,
'periodWid')
epg.getEndDate('periodWid')
epg.getEndDate('payGroupWid,
'periodWid')
epg.getPaymentDate('periodWid')
epg.getPaymentDate('payGroupWid',
'periodWid')
epg.getWIDForStartDate('date')
epg.getWIDForStartDate('payGroupWid',
'date')
epg.getWIDForEndDate('date')
epg.getWIDForEndDate('payGroupWid',
'date')
epg.getWIDForPaymentDate('date')
epg.getWIDForPaymentDate('payGroupWid
', 'date')
epg.getCurrentPeriod('date')
43
MVEL Expression Language
Varia
Description Usage examples
ble
epg.getCurrentPeriod('payGroupWid',
'date')
epg.getPreviousPeriod('date')
epg.getPreviousPeriod('payGroupWid',
'date')
epg.getNextPeriodReference()
epg.getNextPeriodReference('payGroupW
id')
ftp Returns the result of an ftp list The following MVEL expressions return true:
operation. The ftp variable is
bound to an instance of the ftp.isSftp('sftp://
MVELFTPHelper utility class. It myserver.somewhere.com/myDirectory')
can be used to test URI
protocol schemes used to ftp.isExplicitSSL('ftpse:/
represent FTP, SFTP, FTPS, myserver.somewhere.com/myDirectory')
FTPSE (FTPS with explicit
mode SSL), and FTPSI (FTPS
with implicit mode SSL).
44
MVEL Expression Language
Varia
Description Usage examples
ble
lp Provides access to the The following MVEL expressions return various results
integration launch parameters. from the Launch_Integration_Event_Data Web
The lp variable is only service operation, where the label value is the
applicable to Workday internal wd:Parameter_Name value or its wd:Label value:
server and integration Cloud
developers. The lp.getUserName()
implementation class for this
variable is:
lp.getUserNameWID()
com.workday.integration.launch.L
aunchParametersHelper lp.getIntegrationEventWID()
45
MVEL Expression Language
Varia
Description Usage examples
ble
mes Provides access to the The following expression gets the root part of the
sag MediationMessage interface. message as text from the MediationMessage interface:
e
message.rootPartAsText
mta Provides access to the The following expression sets data in an MTable:
ble MTableAdapter interface,
which defines the operations on mtable['my_property'].set(0, 'Data_Column', 'my_test_data')
an MTable instance, where
MTable is an in-memory table The following expression gets data from an MTable:
of data.
mtable['my_property'].get(0, 'Data_Column')
par Provides array-based access to For example, to get the content of part 0, the root part:
ts message parts using the
MessageAdapter interface. parts[0].text
The root part is part 0, the first
attachment is part 1. To get the content of the first attachment:
parts[1].text
46
MVEL Expression Language
Varia
Description Usage examples
ble
parts[0].getHeader('someHeader')
parts[0].mimeType
parts[0].getAs(DOMSource)
parts[0].getAs(String)
parts[0].xpath('/a/b')
parts[0].xpathB('/a/b')
47
MVEL Expression Language
Varia
Description Usage examples
ble
parts[0].xpathF('/a/b')
You can also use set accessors for text, headers, and
MIME types, for example:
props['bean.property']
spr Provides access to the Spring The following expression gets the name attribute of the
ing context for the WSAR using the bean called Fred in the Spring context:
ApplicationContext interface.
spring.getBean('fred').name
uti Provides access to utilities for You can use the following expression in conjunction with
l working with MVEL the splitter component to check whether the current
expressions. The util variable message in the MediationContext is the last message
is bound to an instance of the that the splitter will generate:
MVELUtilHelper utility class,
which provides handy functions props['is.last.record'] =
for use within MVEL
expressions such as time and
48
MVEL Expression Language
Varia
Description Usage examples
ble
var Provides access to the For example, to get the text of the variable myVariable:
s MessageContextVariables
interface as a Map. To access vars['myVariable'].text
variables, use the following
notation: To determine if a variable is defined:
vars['myVariable'] vars['myVariable'] != null
vars['myVariable'].mimeType
vars['myVariable'].xpath('/a/b')
vars['myVariable'].xpath('/xx:a/xx:b', 'xx
http://www.somewhere.com')
vars['myVariable'].xpathB('/a/b')
vars['myVariable'].xpathF('/a/b')
49
MVEL Expression Language
Varia
Description Usage examples
ble
namespace parameter.
xml Returns the result of the The following expression checks whether there are
dif xmldiff step as a Java object differences between the two documents:
f of type XMLDiffStepResult,
xmldiff.isDifferent() == true
which is also available as a
property called
For more examples of the xmldiff MVEL variable
wd.xmldiff.step.result in the
usage, see “Sample MVEL Usage”.
MediationContext.
<wd:Request_References wd:Skip_Non_Existing_Instances="true">
@foreach{props['Workers'] as emp}
<wd:Worker_Reference>
<wd:ID wd:type="Employee_ID">@{emp}</wd:ID>
</wd:Worker_Reference>
@end{}
</wd:Request_References>
</wd:Get_Workers_Request>
50
MVEL Expression Language
<root>
@if{props['p.is.boolean']}
@elseif{props['p.numeric.value'] == 1}
@else{}
<ee>*Else*</ee>
@end{}
</root>
51
MVEL Expression Language
17 USEFUL Links:
http://mvel.codehaus.org/Home
http://www.mulesoft.org/documentation/display/current/Mule+Fundamentals
http://mulesoft.github.io/mule-module-mvel/usage.html#mvel-fundamentals
http://www.w3schools.com/xpath/xpath_nodes.asp
52