我需要在流程的不同位置重复使用少量数据编织功能。但这些都是使用pluwe等数据编织运算符。那么有没有办法使它们成为全球性的。
%function formatterm(a) (a pluck (null when $==null otherwise "term" : {'$$':$})) -null
%function formatterms(a) (a pluck (null when $==null otherwise "terms" : {'$$':$})) -null
%function formatquerystring(a) (a pluck (null when $==null otherwise ("query_string" : "query": '$$' ++ ':' ++ $) )) - null
由于 Sushma
答案 0 :(得分:1)
您可以创建全局MEL功能。从MEL你可以调用dataweave,例如:
https://docs.mulesoft.com/mule-user-guide/v/3.8/mel-dataweave-functions
有关详细信息,请参阅https://docs.mulesoft.com/mule-user-guide/v/3.8/mel-dataweave-functions。
你必须小心引用:
def formatquerystring(a) {
return dw("("+ a + " pluck (null when $==null otherwise
(\"query_string\" : \"query\": '$$' ++ ':' ++ $) )) - null")
}
适合我。但是这样你就可以动态创建一个必须编译的dwl脚本。并注意代码注入。
最好在MEL中编写formatquerystring。