@After public void after() { feel.removeListener( errorsCountingListener ); }
/** * Convert row to DTDecisionRule * @param mainCtx the main context is used to identify the hosted FEELEventManager * @param embeddedFEEL a possibly cached embedded FEEL to compile the output expression, error will be reported up to the mainCtx * @param index * @param rule * @param inputSize * @return */ private static DTDecisionRule toDecisionRule(EvaluationContext mainCtx, FEEL embeddedFEEL, int index, List<?> rule, int inputSize) { // TODO should be check indeed block of inputSize n inputs, followed by block of outputs. DTDecisionRule dr = new DTDecisionRule( index ); for ( int i = 0; i < rule.size(); i++ ) { Object o = rule.get( i ); if ( i < inputSize ) { dr.getInputEntry().add( toUnaryTest( mainCtx, o ) ); } else { FEELEventListener ruleListener = event -> mainCtx.notifyEvt( () -> new FEELEventBase(event.getSeverity(), Msg.createMessage(Msg.ERROR_COMPILE_EXPR_DT_FUNCTION_RULE_IDX, index+1, event.getMessage()), event.getSourceException())); embeddedFEEL.addListener(ruleListener); CompiledExpression compiledExpression = embeddedFEEL.compile((String) o, embeddedFEEL.newCompilerContext()); dr.getOutputEntry().add( compiledExpression ); embeddedFEEL.removeListener(ruleListener); } } return dr; }