Reputation: 109
We are migrating a project from mule3 to mule4 and encountered below MEL or DW code after migrating using MMA. Any inputs on how to convert these into mule4 code is appreciated. There are variables which might confuse for eg. tempMonthlyData, dataRecord, MonthlyData, etc. and "Property Code" is a String. All the variables are json objects
payload.get(flowVars.processingSheet)
mel:payload.key.split(" ")[0].toLowerCase()
flowVars.appendix.get(flowVars.propertyKey) != null
vars.dataRecord.put("Property Code", yardiPropList.get(referenceId))
mel:propertiesNotInmule.remove(referenceId)
mel:tempMonthlyData.add(dataRecord)
mel:payload.replace("MonthlyData", tempMonthlyData)
mel:dataRecord.put("Property Code", "")
Upvotes: 0
Views: 84
Reputation: 25837
The question lacks in context and details. I'll have to make some educated guesses in the answers to mitigate that. See the answers by method.
Note, none of these are Mule operations. It is all the equivalent of Java code inside MEL expressions. You need to be aware exactly of what is the Java class and method, to find an equivalent.
get() If the payload is a org.json.JSONObject then the get() method returns the value of the attribute with key flowVars.processingSheet
.
payload.get(flowVars.processingSheet)
Mule 4 doesn't use org.json but it uses DataWeave to transform JSON values. The equivalent is:
payload[vars.processingSheet]
split() I assume that this is the Java String split() method.
payload.key.split(" ")[0].toLowerCase()
The equivalent expression in DataWeave is:
lower((payload.key splitBy (" "))[0])
put()
If this is the JSONObject.put() method then using the update operator in upsert mode would be similar:
%dw 2.0
output application/json
---
vars.someVariable update {
case .DataRecord! -> vars.yardiPropList
}
replace()
Assuming it is a Map method because it doesn't exist in JSONObject use the update operator without the upsert feature (!
).
remove() If this is the Map.remove() method, you can achieve a similar result with the minus operator:
payload - vars.referenceId
add() assuming it is a Java List then you can just use the concatenation operator:
vars.tempMonthlyData ++ vars.dataRecord
Note that DataWeave is a functional programming language and doesn't has side effects, so it is not changing the inputs, but creating a new output. You need to assign that output to the payload or variable.
Upvotes: 1