Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git Issue - 2749: Add decisionInstanceId to evaluate DMN decision api response #4197

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kmannuru
Copy link

@kmannuru kmannuru commented Mar 21, 2024

GIT Issue: #2749

@CLAassistant
Copy link

CLAassistant commented Mar 21, 2024

CLA assistant check
All committers have signed the CLA.

@kmannuru kmannuru changed the title ENTDAPCOE-94: Add decisionInstanceId to evaluate DMN decision api response Git Issue - 2749: Add decisionInstanceId to evaluate DMN decision api response Mar 21, 2024
@yanavasileva
Copy link
Member

Hi @kmannuru,

Thank you for raising this.
I will have a look at it and get back to you.
Please note before merge, you need to sign one time only Contributor License Agreement (CLA).

Best,
Yana

@kmannuru
Copy link
Author

kmannuru commented Apr 4, 2024

@yanavasileva Did you get a chance to review my code changes. Thanks

@yanavasileva
Copy link
Member

Hi @kmannuru, I will need more time to review the PR as the change is not trivial.
Please stay tuned and thank you for your patience in advance.

@yanavasileva
Copy link
Member

Hi, just checking in.
I am not sure about the proposed approach, I will discuss the topic with the team and get back to you.
Some points that I can already raise after checking the engine implementation:

  • What will happen if a user has a variable that's called decisionInstanceId? I don't we should mess with the variables that are passed for evaluating a decision.
  • The test coverage (in the dmn-engine and engine) doesn't seem sufficient at first glance.
  • Would it be possible to avoid changing the scope of commons-lang3?

Best,
Yana

@kmannuru
Copy link
Author

@yanavasileva thanks for your feedback. I'll update the PR with additional unit test coverage and change scope of commons-lang3.
Regarding user variable map, I'm planning to keep it more dynamic building variable map key prefix with decisionDefinitionKey.
variables.put(decisionDefinition.getKey()+"decisionInstanceId", decisionInstanceId);
Please let me know if I can proceed with this approach. Thank you.

@yanavasileva
Copy link
Member

@kmannuru,
We don't want to pass the decisionInstanceId via the variables, as I mentioned earlier, I confirmed it with the team as well. You can try to explore other options to pass the id to the evaluated result. My initial proposal that I didn't weighted thoroughly is to pass it via the DecisionInvocation. Maybe you can check the options there.
Nevertheless, we won't proceed with the variables approach.

Copy link
Member

@yanavasileva yanavasileva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will wait for adjusting the handling of decisionInstanceId before continuing with the review.

@yanavasileva
Copy link
Member

Closing due to inactivity. The PR can be reopened again when you get back to the topic.

@kmannuru
Copy link
Author

@yanavasileva I'm currently working on the changes to create decisionInstanceId part of the invocation logic in DecisionInvocation.java and not pass part of variable map. The decisionInstanceId will be passed as method parameter to DefaultDmnDecisionContext.java. Can you please help reopen the PR as i'm planning to push my changes shortly. Thank you.

@yanavasileva yanavasileva reopened this May 22, 2024
@brianwarner brianwarner force-pushed the feature/evaluate_dmn_with_dec_instant_id branch 2 times, most recently from 7de6638 to 03d06ee Compare May 24, 2024 19:45
@kmannuru
Copy link
Author

@yanavasileva I've made changes to the PR as per your recommendation. Please help review my code changes. Thanks.

@kmannuru
Copy link
Author

kmannuru commented Jun 5, 2024

@yanavasileva Did you get a chance to review my code changes. Thanks

Copy link
Member

@yanavasileva yanavasileva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kmannuru,

Thank you for your patience with this. I have started the review but unfortunately there are open questions that I won't have a look with fresh mind.
Nevertheless, the changes look promising and I added initial round of feedback that you can check to clean up the contribution.

Best,
Yana

}

public DmnDecisionResult evaluateDecision(DmnDecision decision, VariableContext variableContext) {
public DmnDecisionResult evaluateDecision(DmnDecision decision, VariableContext variableContext, String decisionInsanceId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public DmnDecisionResult evaluateDecision(DmnDecision decision, VariableContext variableContext, String decisionInsanceId) {
public DmnDecisionResult evaluateDecision(DmnDecision decision, VariableContext variableContext, String decisionInstanceId) {

ensureNotNull("decision", decision);
ensureNotNull("variableContext", variableContext);

if (decision instanceof DmnDecisionImpl) {
DefaultDmnDecisionContext decisionContext = new DefaultDmnDecisionContext(dmnEngineConfiguration);
return decisionContext.evaluateDecision(decision, variableContext);
return decisionContext.evaluateDecision(decision, variableContext, decisionInsanceId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return decisionContext.evaluateDecision(decision, variableContext, decisionInsanceId);
return decisionContext.evaluateDecision(decision, variableContext, decisionInstanceId);

engine/pom.xml Outdated
Comment on lines 59 to 67
<!-- <dependency>-->
<!-- <groupId>org.camunda.bpm.juel</groupId>-->
<!-- <artifactId>camunda-juel</artifactId>-->
<!-- </dependency>-->

<dependency>
<groupId>org.camunda.bpm.juel</groupId>
<artifactId>camunda-juel</artifactId>
<version>7.20.0</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ The version of the juel module is the current project version:

Suggested change
<!-- <dependency>-->
<!-- <groupId>org.camunda.bpm.juel</groupId>-->
<!-- <artifactId>camunda-juel</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.camunda.bpm.juel</groupId>
<artifactId>camunda-juel</artifactId>
<version>7.20.0</version>
<dependency>
<groupId>org.camunda.bpm.juel</groupId>
<artifactId>camunda-juel</artifactId>

@@ -111,4 +111,15 @@ public interface DmnDecisionResult extends List<DmnDecisionResultEntries>, Seria
*/
<T extends TypedValue> T getSingleEntryTyped();

/** Returns the value of decisionInstanceId that's part of DMN decision evaluation
* @return the decisionInstanceId generated
* GIT Issue: https://github.com/camunda/camunda-bpm-platform/issues/2749
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Please remove all of the git ticket references from the code. The modern IDE and GitHub offer enough support to track the origins to ticket and pull request.

Suggested change
* GIT Issue: https://github.com/camunda/camunda-bpm-platform/issues/2749

Comment on lines 433 to 436
public boolean isNotBlank(String value) {
return value != null && !value.isEmpty();
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Reuse existing utils.

Suggested change
public boolean isNotBlank(String value) {
return value != null && !value.isEmpty();
}

* Setting the generated decisionInstanceId to the root event
* Generating custom decisionInstanceId to persist the history event and return the id in the response
*/
if(isNotBlank(evaluationEvent.getDecisionInstanceId())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Reuse existing utils (don't forget to add import):

Suggested change
if(isNotBlank(evaluationEvent.getDecisionInstanceId())) {
if(StringUtil.hasText(evaluationEvent.getDecisionInstanceId())) {

* Generating custom decisionInstanceId to persist the history event and return the id in the response
*/
if(isNotBlank(evaluationEvent.getDecisionInstanceId())) {
rootDecisionEvent.setId(evaluationEvent.getDecisionInstanceId());
Copy link
Member

@yanavasileva yanavasileva Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to myself:
❓ Shouldn't the id of the root to be pointing to the root event DI id? What's the reference (ROOT_DEC_INST_ID_, ROOT_PROC_INST_ID_, history cleanup)?

@Path("/evaluate-with-id")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
DecisionEvaluationDto evaluateDecisionWithId(@Context UriInfo context, EvaluateDecisionDto parameters);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to myself:
❓ Could we avoid adding the new endpoint?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📓 There's a compilation error in OpenAPI tests, please have a look. Hints:
cd engine-rest
mvn clean install
Let me know if you need more guidance

@github-actions github-actions bot added the group:stale DRI: Yana label Jun 14, 2024
@kmannuru
Copy link
Author

@yanavasileva Thanks for your feedback. I'm currently working on changes to incorporate your review comments. I'll share the updated PR shortly. Thanks.

@@ -155,16 +155,16 @@ public DmnDecisionTableResult evaluateDecisionTable(String decisionKey, DmnModel
public DmnDecisionResult evaluateDecision(DmnDecision decision, Map<String, Object> variables) {
ensureNotNull("decision", decision);
ensureNotNull("variables", variables);
return evaluateDecision(decision, Variables.fromMap(variables).asVariableContext());
return evaluateDecision(decision, Variables.fromMap(variables).asVariableContext(), null);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be replaced with evaluateDecision(decision, variableContext)

@@ -181,7 +181,7 @@ public DmnDecisionResult evaluateDecision(String decisionKey, InputStream inputS
List<DmnDecision> decisions = parseDecisions(inputStream);
for (DmnDecision decision : decisions) {
if (decisionKey.equals(decision.getKey())) {
return evaluateDecision(decision, variableContext);
return evaluateDecision(decision, variableContext, null);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be replaced with evaluateDecision(decision, variableContext)

@@ -197,7 +197,7 @@ public DmnDecisionResult evaluateDecision(String decisionKey, DmnModelInstance d
List<DmnDecision> decisions = parseDecisions(dmnModelInstance);
for (DmnDecision decision : decisions) {
if (decisionKey.equals(decision.getKey())) {
return evaluateDecision(decision, variableContext);
return evaluateDecision(decision, variableContext, null);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be replaced with evaluateDecision(decision, variableContext)

@@ -112,7 +112,7 @@ public DmnDecisionTableResult evaluateDecisionTable(DmnDecision decision, Variab
if (decision instanceof DmnDecisionImpl && decision.isDecisionTable()) {
DefaultDmnDecisionContext decisionContext = new DefaultDmnDecisionContext(dmnEngineConfiguration);

DmnDecisionResult decisionResult = decisionContext.evaluateDecision(decision, variableContext);
DmnDecisionResult decisionResult = decisionContext.evaluateDecision(decision, variableContext, null);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yanavasileva This will not change because we need to pass the decisionInsanceId to decisionContext.evaluateDecision(decision, variableContext, null);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you are ready, please submit your changes, I will have a look then.

@github-actions github-actions bot added group:stale DRI: Yana and removed group:stale DRI: Yana labels Jun 18, 2024
Copy link

Closing due to lack of requested feedback. If you would like us to look at this, please provide the requested information to re-open the PR.

@kmannuru
Copy link
Author

@yanavasileva Can you please help reopen the PR so I can merge my changes for your review? Thanks

@yanavasileva
Copy link
Member

PR reopened.

@kmannuru
Copy link
Author

@yanavasileva Please help review the PR. The latest commit on the PR includes the changes that addresses the review comments. Thanks.

@yanavasileva
Copy link
Member

yanavasileva commented Sep 12, 2024

@kmannuru, I don't see any new changes pushed to the PR. Have you added everything?

@kmannuru
Copy link
Author

@kmannuru, I don't see any new changes pushed to the PR. Have you added everything?

@yanavasileva Yes. The PR is updated with the changes to reflect the review comments.
Here's the commit: cddcc56

Please help review when you get a chance. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants