Object executeScript ( String jsScript , Map < String , Object > parameters ) { EntityType entityType = entityTypeFactory . create ( "entity" ) ; Set < String > attributeNames = parameters . keySet ( ) ; attributeNames . forEach ( key -> entityType . addAttribute ( attributeFactory . create ( ) . setName ( key ) ) ) ; if ( attributeNames . iterator ( ) . hasNext ( ) ) { entityType . getAttribute ( attributeNames . iterator ( ) . next ( ) ) . setIdAttribute ( true ) ; } Entity entity = new DynamicEntity ( entityType ) ; parameters . forEach ( entity :: set ) ; return jsMagmaScriptEvaluator . eval ( jsScript , entity ) ; }
Execute a JavaScript using the Magma API