mule - Dataweave key value set from database to HashMap -


my flow goes this:

i receive payload following:

['bobsfirststatus', 'bobssecondstatus', 'bobseightstatus']

and have lookup table in database so:

id_|_bobstatusname___|_internalstatusname_____ 1  | bobsfirststatus | internal_1ststatus 2  | bobssecondstatus| internal_2ndstatus 3  | bobseighstatus  | internal_3rdstatus 

i want read data database, , load hashmap so:

{   "bobsfirststatus": "internal_1ststatus",   "bobssecondstatus": "internal_2ndstatus",   "bobseighstatus": "internal_3rdstatus" } 

this way, can in data weave statement can "flowvars.lookup[payload.bobstatus]" retrieve our internal mapping of status.

anyone done before? seems useful...

solid plan, although don't doing in flow variable. can make lookup flow, , call dwl like so. you'll want use cache scope avoid doing every time.

i have done in spring bean before too, , i'm happy final result. lookup tables expect change when application released, or less often.

  1. create bean of type map. can use native spring <util:map> this. configure lookup keys , values using spring <entry> elements

    <util:map id="statustable">

    <entry key="bobsfirststatus" value="internal_1ststatus" />

    <entry key="bobssecondstatus" value="internal_2ndstatus" />

    <entry key="bobseighstatus" value="internal_3rdstatus" />

    </util:map>

  2. refer bean using mel app context object

    #[app.registry.statustable[flowvars.status]]


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -