package Ġio . hol unda . camunda . task pool . en r icher Ċ Ċ import Ġio . hol unda . camunda . task pool . api . task .* Ċ import Ġorg . camunda . bpm . engine . Runtime Service Ċ import Ġorg . camunda . bpm . engine . variable . Variable Map Ċ import Ġorg . camunda . bpm . engine . variable . Variables Ċ import Ġorg . springframework . context . event . EventListener Ċ Ċ class ĠProcess Variables Create Command En r icher ( runtime Service : ĠRuntime Service , Ġfilter : ĠProcess Variables Filter , Ġcorre lator : ĠProcess Variables Corre lator ) ĊĠ Ġ: ĠCreate Command En r icher , ĠProcess Variables Task Command En r icher ( runtime Service , Ġfilter , Ġcorre lator ) Ġ{ ĊĠ Ġ@ EventListener ( condition Ġ= Ġ"# command . en ric hed Ġ== Ġfalse ") ĊĠ Ġoverride Ġfun Ġen rich ( command : ĠCreate Task Command ): ĠCreate Task Command Ġ= Ġsuper . en rich ( command ) Ċ } Ċ Ċ class ĠProcess Variables Complete Command En r icher ( runtime Service : ĠRuntime Service , Ġfilter : ĠProcess Variables Filter , Ġcorre lator : ĠProcess Variables Corre lator ) ĊĠ Ġ: ĠComplete Command En r icher , ĠProcess Variables Task Command En r icher ( runtime Service , Ġfilter , Ġcorre lator ) Ġ{ ĊĠ Ġ@ EventListener ( condition Ġ= Ġ"# command . en ric hed Ġ== Ġfalse ") ĊĠ Ġoverride Ġfun Ġen rich ( command : ĠComplete Task Command ): ĠComplete Task Command Ġ= Ġsuper . en rich ( command ) Ċ } Ċ Ċ class ĠProcess Variables Delete Command En r icher ( runtime Service : ĠRuntime Service , Ġfilter : ĠProcess Variables Filter , Ġcorre lator : ĠProcess Variables Corre lator ) ĊĠ Ġ: ĠDelete Command En r icher , ĠProcess Variables Task Command En r icher ( runtime Service , Ġfilter , Ġcorre lator ) Ġ{ ĊĠ Ġ@ EventListener ( condition Ġ= Ġ"# command . en ric hed Ġ== Ġfalse ") ĊĠ Ġoverride Ġfun Ġen rich ( command : ĠDelete Task Command ): ĠDelete Task Command Ġ= Ġsuper . en rich ( command ) Ċ } Ċ Ċ class ĠProcess Variables Assign Command En r icher ( runtime Service : ĠRuntime Service , Ġfilter : ĠProcess Variables Filter , Ġcorre lator : ĠProcess Variables Corre lator ) ĊĠ Ġ: ĠAssign Command En r icher , ĠProcess Variables Task Command En r icher ( runtime Service , Ġfilter , Ġcorre lator ) Ġ{ ĊĠ Ġ@ EventListener ( condition Ġ= Ġ"# command . en ric hed Ġ== Ġfalse ") ĊĠ Ġoverride Ġfun Ġen rich ( command : ĠAssign Task Command ): ĠAssign Task Command Ġ= Ġsuper . en rich ( command ) Ċ } Ċ Ċ /** Ċ Ġ* ĠEn ric hes Ġcommands Ġwith Ġprocess Ġvariables Ġfrom Ġthe ĠVariable Context . Ċ Ġ* Ġ@ param Ġruntime Service ĠCam unda ĠAPI Ġto Ġaccess Ġthe Ġexecution . Ċ Ġ* Ġ@ param Ġprocess Variables Filter Ġfilter Ġto Ġwhitelist Ġor Ġblacklist Ġthe Ġvariables Ġwhich Ġshould Ġbe Ġadded Ġto Ġthe Ġtask . Ċ Ġ*/ Ċ open Ġclass ĠProcess Variables Task Command En r icher ( ĊĠ Ġprivate Ġval Ġruntime Service : ĠRuntime Service , ĊĠ Ġprivate Ġval Ġprocess Variables Filter : ĠProcess Variables Filter , ĊĠ Ġprivate Ġval Ġprocess Var ri ables Corre lator : ĠProcess Variables Corre lator Ċ ) Ġ{ ĊĠ Ġprotected Ġfun Ġ< T Ġ: ĠTask Command > Ġen rich ( command : ĠT ): ĠT Ġ{ ĊĊĠĠĠ Ġ// ĠPayload Ġen rich ment ĊĠĠĠ Ġcommand . payload . put All Typed ( ĊĠĠĠĠĠ Ġprocess Variables Filter . filter Variables ( ĊĠĠĠĠĠĠĠ Ġcommand . source Reference . definition Key , ĊĠĠĠĠĠĠĠ Ġcommand . task Definition Key , ĊĠĠĠĠĠĠĠ Ġruntime Service . get Variables Typed ( command . source Reference . execution Id ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ// ĠCorre lations ĊĠĠĠ Ġcommand . corre lations . put All Typed ( ĊĠĠĠĠĠ Ġprocess Var ri ables Corre lator . corre late Variables ( ĊĠĠĠĠĠĠĠ Ġcommand . source Reference . definition Key , ĊĠĠĠĠĠĠĠ Ġcommand . task Definition Key , ĊĠĠĠĠĠĠĠ Ġruntime Service . get Variables Typed ( command . source Reference . execution Id ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ// ĠMark Ġas Ġen ric hed ĊĠĠĠ Ġcommand . en ric hed Ġ= Ġtrue ĊĠĠĠ Ġreturn Ġcommand ĊĠ Ġ} Ċ } Ċ Ċ fun ĠVariable Map . put All Typed ( source : ĠVariable Map ) Ġ{ ĊĠ Ġsource . keys . forEach Ġ{ ĊĠĠĠ Ġthis . put Value Typed ( it , Ġsource . getValue Typed ( it )) ĊĠ Ġ} Ċ } Ċ Ċ inline Ġfun ĠVariable Map . filter Keys ( predicate : Ġ( String ) Ġ-> ĠBoolean ): ĠVariable Map Ġ{ ĊĠ Ġval Ġresult Ġ= ĠVariables . create Variables () ĊĠ Ġfor Ġ( entry Ġin Ġthis ) Ġ{ ĊĠĠĠ Ġif Ġ( predicate ( entry . key )) Ġ{ ĊĠĠĠĠĠ Ġresult [ entry . key ] Ġ= Ġentry . value ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĠ Ġreturn Ġresult Ċ } Ċ