Search in sources :

Example 1 with DmnDecisionEvaluationListener

use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener in project camunda-engine-dmn by camunda.

the class DefaultDmnEngineConfigurationApiTest method shouldBeFluentConfigurable.

@Test
public void shouldBeFluentConfigurable() {
    DefaultEngineMetricCollector metricCollector = new DefaultEngineMetricCollector();
    ArrayList<DmnDecisionTableEvaluationListener> preListeners = new ArrayList<DmnDecisionTableEvaluationListener>();
    preListeners.add(new DefaultEngineMetricCollector());
    ArrayList<DmnDecisionTableEvaluationListener> postListeners = new ArrayList<DmnDecisionTableEvaluationListener>();
    preListeners.add(new DefaultEngineMetricCollector());
    ArrayList<DmnDecisionEvaluationListener> preDecisionListeners = new ArrayList<DmnDecisionEvaluationListener>();
    preDecisionListeners.add(new TestDecisionEvaluationListener());
    ArrayList<DmnDecisionEvaluationListener> postDecisionListeners = new ArrayList<DmnDecisionEvaluationListener>();
    postDecisionListeners.add(new TestDecisionEvaluationListener());
    DefaultScriptEngineResolver scriptEngineResolver = new DefaultScriptEngineResolver();
    ElProvider elProvider = new JuelElProvider();
    FeelEngineFactory feelEngineFactory = new FeelEngineFactoryImpl();
    DmnTransformer transformer = new DefaultDmnTransformer();
    DmnEngine engine = configuration.engineMetricCollector(metricCollector).customPreDecisionTableEvaluationListeners(preListeners).customPostDecisionTableEvaluationListeners(postListeners).customPreDecisionEvaluationListeners(preDecisionListeners).customPostDecisionEvaluationListeners(postDecisionListeners).scriptEngineResolver(scriptEngineResolver).elProvider(elProvider).feelEngineFactory(feelEngineFactory).defaultInputExpressionExpressionLanguage("camunda").defaultInputEntryExpressionLanguage("camunda").defaultOutputEntryExpressionLanguage("camunda").transformer(transformer).buildEngine();
    configuration = (DefaultDmnEngineConfiguration) engine.getConfiguration();
    assertThat(configuration.getEngineMetricCollector()).isEqualTo(metricCollector);
    assertThat(configuration.getCustomPreDecisionTableEvaluationListeners()).containsExactlyElementsOf(preListeners);
    assertThat(configuration.getCustomPostDecisionTableEvaluationListeners()).containsExactlyElementsOf(postListeners);
    assertThat(configuration.getCustomPreDecisionEvaluationListeners()).containsExactlyElementsOf(preDecisionListeners);
    assertThat(configuration.getCustomPostDecisionEvaluationListeners()).containsExactlyElementsOf(postDecisionListeners);
    assertThat(configuration.getScriptEngineResolver()).isEqualTo(scriptEngineResolver);
    assertThat(configuration.getElProvider()).isEqualTo(elProvider);
    assertThat(configuration.getFeelEngineFactory()).isEqualTo(feelEngineFactory);
    assertThat(configuration.getDefaultInputExpressionExpressionLanguage()).isEqualTo("camunda");
    assertThat(configuration.getDefaultInputEntryExpressionLanguage()).isEqualTo("camunda");
    assertThat(configuration.getDefaultOutputEntryExpressionLanguage()).isEqualTo("camunda");
    assertThat(configuration.getTransformer()).isEqualTo(transformer);
}
Also used : DmnDecisionEvaluationListener(org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener) ArrayList(java.util.ArrayList) DefaultDmnTransformer(org.camunda.bpm.dmn.engine.impl.transform.DefaultDmnTransformer) DefaultEngineMetricCollector(org.camunda.bpm.dmn.engine.impl.metrics.DefaultEngineMetricCollector) FeelEngineFactory(org.camunda.bpm.dmn.feel.impl.FeelEngineFactory) FeelEngineFactoryImpl(org.camunda.bpm.dmn.feel.impl.juel.FeelEngineFactoryImpl) ElProvider(org.camunda.bpm.dmn.engine.impl.spi.el.ElProvider) JuelElProvider(org.camunda.bpm.dmn.engine.impl.el.JuelElProvider) DefaultDmnEngine(org.camunda.bpm.dmn.engine.impl.DefaultDmnEngine) DmnEngine(org.camunda.bpm.dmn.engine.DmnEngine) JuelElProvider(org.camunda.bpm.dmn.engine.impl.el.JuelElProvider) DefaultDmnTransformer(org.camunda.bpm.dmn.engine.impl.transform.DefaultDmnTransformer) DmnTransformer(org.camunda.bpm.dmn.engine.impl.spi.transform.DmnTransformer) DefaultScriptEngineResolver(org.camunda.bpm.dmn.engine.impl.el.DefaultScriptEngineResolver) DmnDecisionTableEvaluationListener(org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener) Test(org.junit.Test)

Example 2 with DmnDecisionEvaluationListener

use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener in project camunda-engine-dmn by camunda.

the class DmnEngineConfigurationApiTest method shouldBeFluentConfigurable.

@Test
public void shouldBeFluentConfigurable() {
    DefaultEngineMetricCollector metricCollector = new DefaultEngineMetricCollector();
    ArrayList<DmnDecisionTableEvaluationListener> preListeners = new ArrayList<DmnDecisionTableEvaluationListener>();
    preListeners.add(new DefaultEngineMetricCollector());
    ArrayList<DmnDecisionTableEvaluationListener> postListeners = new ArrayList<DmnDecisionTableEvaluationListener>();
    preListeners.add(new DefaultEngineMetricCollector());
    ArrayList<DmnDecisionEvaluationListener> preDecisionListeners = new ArrayList<DmnDecisionEvaluationListener>();
    preDecisionListeners.add(new TestDecisionEvaluationListener());
    ArrayList<DmnDecisionEvaluationListener> postDecisionListeners = new ArrayList<DmnDecisionEvaluationListener>();
    postDecisionListeners.add(new TestDecisionEvaluationListener());
    DmnEngine engine = DmnEngineConfiguration.createDefaultDmnEngineConfiguration().engineMetricCollector(metricCollector).customPreDecisionTableEvaluationListeners(preListeners).customPostDecisionTableEvaluationListeners(postListeners).customPreDecisionEvaluationListeners(preDecisionListeners).customPostDecisionEvaluationListeners(postDecisionListeners).buildEngine();
    DmnEngineConfiguration configuration = engine.getConfiguration();
    assertThat(configuration.getEngineMetricCollector()).isEqualTo(metricCollector);
    assertThat(configuration.getCustomPreDecisionTableEvaluationListeners()).containsExactlyElementsOf(preListeners);
    assertThat(configuration.getCustomPostDecisionTableEvaluationListeners()).containsExactlyElementsOf(postListeners);
    assertThat(configuration.getCustomPreDecisionEvaluationListeners()).containsExactlyElementsOf(preDecisionListeners);
    assertThat(configuration.getCustomPostDecisionEvaluationListeners()).containsExactlyElementsOf(postDecisionListeners);
}
Also used : DmnEngine(org.camunda.bpm.dmn.engine.DmnEngine) DmnDecisionEvaluationListener(org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener) ArrayList(java.util.ArrayList) DefaultEngineMetricCollector(org.camunda.bpm.dmn.engine.impl.metrics.DefaultEngineMetricCollector) DmnDecisionTableEvaluationListener(org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener) DmnEngineConfiguration(org.camunda.bpm.dmn.engine.DmnEngineConfiguration) DefaultDmnEngineConfiguration(org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration) Test(org.junit.Test)

Example 3 with DmnDecisionEvaluationListener

use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener in project camunda-engine-dmn by camunda.

the class DefaultDmnDecisionContext method generateDecisionEvaluationEvent.

protected void generateDecisionEvaluationEvent(List<DmnDecisionLogicEvaluationEvent> evaluatedEvents) {
    DmnDecisionLogicEvaluationEvent rootEvaluatedEvent = null;
    DmnDecisionEvaluationEventImpl decisionEvaluationEvent = new DmnDecisionEvaluationEventImpl();
    long executedDecisionElements = 0L;
    for (DmnDecisionLogicEvaluationEvent evaluatedEvent : evaluatedEvents) {
        executedDecisionElements += evaluatedEvent.getExecutedDecisionElements();
        rootEvaluatedEvent = evaluatedEvent;
    }
    decisionEvaluationEvent.setDecisionResult(rootEvaluatedEvent);
    decisionEvaluationEvent.setExecutedDecisionElements(executedDecisionElements);
    evaluatedEvents.remove(rootEvaluatedEvent);
    decisionEvaluationEvent.setRequiredDecisionResults(evaluatedEvents);
    for (DmnDecisionEvaluationListener evaluationListener : evaluationListeners) {
        evaluationListener.notify(decisionEvaluationEvent);
    }
}
Also used : DmnDecisionEvaluationListener(org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener) DmnDecisionLogicEvaluationEvent(org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent) DmnDecisionEvaluationEventImpl(org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionEvaluationEventImpl)

Example 4 with DmnDecisionEvaluationListener

use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener in project camunda-bpm-platform by camunda.

the class DmnEngineConfigurationBuilder method build.

/**
 * Modify the given DMN engine configuration and return it.
 */
public DefaultDmnEngineConfiguration build() {
    List<DmnDecisionEvaluationListener> decisionEvaluationListeners = createCustomPostDecisionEvaluationListeners();
    dmnEngineConfiguration.setCustomPostDecisionEvaluationListeners(decisionEvaluationListeners);
    // override the decision table handler
    DmnTransformer dmnTransformer = dmnEngineConfiguration.getTransformer();
    dmnTransformer.getElementTransformHandlerRegistry().addHandler(Definitions.class, new DecisionRequirementsDefinitionTransformHandler());
    dmnTransformer.getElementTransformHandlerRegistry().addHandler(Decision.class, new DecisionDefinitionHandler());
    // do not override the script engine resolver if set
    if (dmnEngineConfiguration.getScriptEngineResolver() == null) {
        ensureNotNull("scriptEngineResolver", scriptEngineResolver);
        dmnEngineConfiguration.setScriptEngineResolver(scriptEngineResolver);
    }
    // do not override the el provider if set
    if (dmnEngineConfiguration.getElProvider() == null) {
        ensureNotNull("expressionManager", expressionManager);
        ProcessEngineElProvider elProvider = new ProcessEngineElProvider(expressionManager);
        dmnEngineConfiguration.setElProvider(elProvider);
    }
    return dmnEngineConfiguration;
}
Also used : DecisionDefinitionHandler(org.camunda.bpm.engine.impl.dmn.transformer.DecisionDefinitionHandler) DmnDecisionEvaluationListener(org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener) DecisionRequirementsDefinitionTransformHandler(org.camunda.bpm.engine.impl.dmn.transformer.DecisionRequirementsDefinitionTransformHandler) ProcessEngineElProvider(org.camunda.bpm.engine.impl.dmn.el.ProcessEngineElProvider) DmnTransformer(org.camunda.bpm.dmn.engine.impl.spi.transform.DmnTransformer)

Example 5 with DmnDecisionEvaluationListener

use of org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener in project camunda-bpm-platform by camunda.

the class DmnEngineConfigurationBuilder method createCustomPostDecisionEvaluationListeners.

protected List<DmnDecisionEvaluationListener> createCustomPostDecisionEvaluationListeners() {
    ensureNotNull("dmnHistoryEventProducer", dmnHistoryEventProducer);
    // note that the history level may be null - see CAM-5165
    HistoryDecisionEvaluationListener historyDecisionEvaluationListener = new HistoryDecisionEvaluationListener(dmnHistoryEventProducer, historyLevel);
    List<DmnDecisionEvaluationListener> customPostDecisionEvaluationListeners = dmnEngineConfiguration.getCustomPostDecisionEvaluationListeners();
    customPostDecisionEvaluationListeners.add(new MetricsDecisionEvaluationListener());
    customPostDecisionEvaluationListeners.add(historyDecisionEvaluationListener);
    return customPostDecisionEvaluationListeners;
}
Also used : DmnDecisionEvaluationListener(org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener) HistoryDecisionEvaluationListener(org.camunda.bpm.engine.impl.history.parser.HistoryDecisionEvaluationListener) MetricsDecisionEvaluationListener(org.camunda.bpm.engine.impl.metrics.dmn.MetricsDecisionEvaluationListener)

Aggregations

DmnDecisionEvaluationListener (org.camunda.bpm.dmn.engine.delegate.DmnDecisionEvaluationListener)5 ArrayList (java.util.ArrayList)2 DmnEngine (org.camunda.bpm.dmn.engine.DmnEngine)2 DmnDecisionTableEvaluationListener (org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener)2 DefaultEngineMetricCollector (org.camunda.bpm.dmn.engine.impl.metrics.DefaultEngineMetricCollector)2 DmnTransformer (org.camunda.bpm.dmn.engine.impl.spi.transform.DmnTransformer)2 Test (org.junit.Test)2 DmnEngineConfiguration (org.camunda.bpm.dmn.engine.DmnEngineConfiguration)1 DmnDecisionLogicEvaluationEvent (org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent)1 DefaultDmnEngine (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngine)1 DefaultDmnEngineConfiguration (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration)1 DmnDecisionEvaluationEventImpl (org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionEvaluationEventImpl)1 DefaultScriptEngineResolver (org.camunda.bpm.dmn.engine.impl.el.DefaultScriptEngineResolver)1 JuelElProvider (org.camunda.bpm.dmn.engine.impl.el.JuelElProvider)1 ElProvider (org.camunda.bpm.dmn.engine.impl.spi.el.ElProvider)1 DefaultDmnTransformer (org.camunda.bpm.dmn.engine.impl.transform.DefaultDmnTransformer)1 FeelEngineFactory (org.camunda.bpm.dmn.feel.impl.FeelEngineFactory)1 FeelEngineFactoryImpl (org.camunda.bpm.dmn.feel.impl.juel.FeelEngineFactoryImpl)1 ProcessEngineElProvider (org.camunda.bpm.engine.impl.dmn.el.ProcessEngineElProvider)1 DecisionDefinitionHandler (org.camunda.bpm.engine.impl.dmn.transformer.DecisionDefinitionHandler)1