forked from apache/incubator-kie-kogito-apps
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[incubator-kie-issues#1541] Add “evaluationHitIds” to the response of…
… jitexecutor-dmn’s “/dmnresult” route (apache#2120) * exp_dmn_result_mapped_to_input * [exp_dmn_result_mapped_to_input] WIP * [incubator-kie-issues#1541] WIP * [incubator-kie-issues#1541] Implemented retrieval and population of "evaluationHitIds" field * [incubator-kie-issues#1541] Fixed tests. Minor refactoring * [incubator-kie-issues#1541] Fix formatting * [incubator-kie-issues#1541] Fix as per suggestion * [incubator-kie-issues#1541] Fix as per suggestion * kie-issues#1541: Extend test coverage - test DMN model where a decision table is nested under conditional expression - test DMN model where collection data type is used as input and output * Collections -> MultipleHitRules * [incubator-kie-issues#1541] Remove duplicated test * [incubator-kie-issues#1541] Fix imports --------- Co-authored-by: Gabriele-Cardosi <[email protected]> Co-authored-by: Jozef Marko <[email protected]>
- Loading branch information
1 parent
3bce465
commit eca7df5
Showing
6 changed files
with
325 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
jitexecutor/jitexecutor-dmn/src/main/java/org/kie/kogito/jitexecutor/dmn/JITDMNListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.kie.kogito.jitexecutor.dmn; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.kie.dmn.api.core.event.AfterConditionalEvaluationEvent; | ||
import org.kie.dmn.api.core.event.AfterEvaluateAllEvent; | ||
import org.kie.dmn.api.core.event.AfterEvaluateBKMEvent; | ||
import org.kie.dmn.api.core.event.AfterEvaluateContextEntryEvent; | ||
import org.kie.dmn.api.core.event.AfterEvaluateDecisionEvent; | ||
import org.kie.dmn.api.core.event.AfterEvaluateDecisionServiceEvent; | ||
import org.kie.dmn.api.core.event.AfterEvaluateDecisionTableEvent; | ||
import org.kie.dmn.api.core.event.AfterInvokeBKMEvent; | ||
import org.kie.dmn.api.core.event.DMNEvent; | ||
import org.kie.dmn.api.core.event.DMNRuntimeEventListener; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class JITDMNListener implements DMNRuntimeEventListener { | ||
|
||
private final List<String> evaluationHitIds = new ArrayList<>(); | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(JITDMNListener.class); | ||
|
||
@Override | ||
public void afterEvaluateDecisionTable(AfterEvaluateDecisionTableEvent event) { | ||
logEvent(event); | ||
evaluationHitIds.addAll(event.getSelectedIds()); | ||
} | ||
|
||
@Override | ||
public void afterEvaluateDecision(AfterEvaluateDecisionEvent event) { | ||
logEvent(event); | ||
} | ||
|
||
@Override | ||
public void afterEvaluateBKM(AfterEvaluateBKMEvent event) { | ||
logEvent(event); | ||
} | ||
|
||
@Override | ||
public void afterEvaluateContextEntry(AfterEvaluateContextEntryEvent event) { | ||
logEvent(event); | ||
} | ||
|
||
@Override | ||
public void afterEvaluateDecisionService(AfterEvaluateDecisionServiceEvent event) { | ||
logEvent(event); | ||
} | ||
|
||
@Override | ||
public void afterInvokeBKM(AfterInvokeBKMEvent event) { | ||
logEvent(event); | ||
} | ||
|
||
@Override | ||
public void afterEvaluateAll(AfterEvaluateAllEvent event) { | ||
logEvent(event); | ||
} | ||
|
||
@Override | ||
public void afterConditionalEvaluation(AfterConditionalEvaluationEvent event) { | ||
logEvent(event); | ||
evaluationHitIds.add(event.getExecutedId()); | ||
} | ||
|
||
public List<String> getEvaluationHitIds() { | ||
return evaluationHitIds; | ||
} | ||
|
||
private void logEvent(DMNEvent toLog) { | ||
LOGGER.info("{} event {}", toLog.getClass().getSimpleName(), toLog); | ||
} | ||
|
||
private void logEvent(AfterConditionalEvaluationEvent toLog) { | ||
LOGGER.info("{} event {}", toLog.getClass().getSimpleName(), toLog); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.