Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

KOGITO-3661 Integrate boxed-expression-component inside dmn-loader and define jsInterop classes for loading/saving expressions #104

Merged
merged 96 commits into from Sep 20, 2021

Conversation

vpellegrino
Copy link
Contributor

@vpellegrino vpellegrino commented Sep 8, 2021

Showcase boxed-expression-component: https://boxed-expression-editor.netlify.app/
Tasks solved by this PR: KOGITO-3666, KOGITO-3663, KOGITO-3661

Since the goal of integrating the boxed-expression-component inside the DMN Editor is ambitious, the process will be incremental, thanks to the usage of Stable/Beta flags.

karreiro and others added 30 commits August 4, 2021 11:45
…chanism to enable the new boxed expression editor as a toggle feature
# Conflicts:
#	kie-wb-common-dmn/kie-wb-common-dmn-client/src/main/java/org/kie/workbench/common/dmn/client/editors/expressions/ExpressionEditorViewImpl.html
#	kie-wb-common-dmn/kie-wb-common-dmn-client/src/main/java/org/kie/workbench/common/dmn/client/editors/expressions/ExpressionEditorViewImpl.java
#	kie-wb-common-dmn/kie-wb-common-dmn-client/src/test/java/org/kie/workbench/common/dmn/client/editors/expressions/ExpressionEditorViewImplTest.java
Co-authored-by: Kogito Tooling Bot <kietooling@gmail.com>
@vpellegrino
Copy link
Contributor Author

@vpellegrino For you info: about the tests, if you are planning to cover more than ExpressionFiller as @jomarko pointed, don't worry too much about ExpressionEditorViewImpl because it will be changed with the undo/redo. Most of its logic will be in commands.

Ok @danielzhe thanks for your feedback!
I'm going to add tests to cover ExpressionFiller

@vpellegrino
Copy link
Contributor Author

@jomarko, let me update you:

  1. Https://issues.redhat.com/browse/KOGITO-4588 will cover it - feel free to mention this acceptance criterion
  2. It Seems an issue related to the Resizer feature. @karreiro is looking on. To unblock this PR, we may trace it with a separate JIRA. Let me know.
  3. Solved
  4. Solved
  5. Solved
  6. Solved

Covered Filler classes with test cases. As stated by @danielzhe, the ExpressionEditorViewImpl will be extended and covered by his test cases.

Thanks again for your review. Would you mind letting me know if you have any further doubt?

@jomarko
Copy link

jomarko commented Sep 16, 2021

@jomarko
Copy link

jomarko commented Sep 16, 2021

re review

1 - I am fine with separate issue
2 - reported https://issues.redhat.com/browse/KOGITO-5909
3 - ok
4 - ok
5 - ok
6 - ok

Copy link

@jomarko jomarko left a comment

Choose a reason for hiding this comment

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

Some comments to code, no more defects found in manual review. Thank you @vpellegrino

}

private static Expression buildAndFillNestedExpression(final ExpressionProps props) {
if (LITERAL_EXPRESSION.getText().equals(props.logicType)) {
Copy link

Choose a reason for hiding this comment

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

Could we please update all these if statements to this form:

Objects.equals(LITERAL_EXPRESSION.getText(), props.logicType)

The benefit of the proposed is no NullPointerException is thrown in case (theoretical) getText or logicType is null.

final String cell = row.length <= columnIndex ? "" : row[columnIndex];
final LiteralExpression wrappedExpression = new LiteralExpression();
wrappedExpression.setText(new Text(cell));
wrappedExpression.setTypeRef(BuiltInType.STRING.asQName());
Copy link

Choose a reason for hiding this comment

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

Are all columns of a relations strings? shouln;t we use a data type of relationProps.columns[columnIndex] rather than STRING?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this method, we are setting the typeRef of the wrapped LiteralExpression (used for the cell) to string. I'm going to remove it. Thanks for letting me know

Comment on lines +233 to +236
informationItem.setTypeRef(BuiltInTypeUtils
.findBuiltInTypeByName(column.dataType)
.orElse(BuiltInType.UNDEFINED)
.asQName());
Copy link

Choose a reason for hiding this comment

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

related to previous question, shouldn't we have similar type detection on the previous commented place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI: This method is about settings name and typeRef for columns. As per #104 (comment), I'm avoiding to set string as typeRef for wrapped expression

Comment on lines 311 to 316
private void assertFormalParameters(FunctionDefinition functionExpression) {
assertThat(functionExpression.getFormalParameter()).isNotNull();
assertThat(functionExpression.getFormalParameter()).hasSize(1);
assertThat(functionExpression.getFormalParameter()).first().extracting(param -> param.getValue().getValue()).isEqualTo(PARAM_NAME);
assertThat(functionExpression.getFormalParameter()).first().extracting(param -> param.getTypeRef().getLocalPart()).isEqualTo(PARAM_DATA_TYPE);
}
Copy link

@jomarko jomarko Sep 16, 2021

Choose a reason for hiding this comment

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

Generally I think, we overuse assertThat what cause some assertions less readable, one example how they can be simplified:

    private void assertFormalParameters(FunctionDefinition functionExpression) {
        assertThat(functionExpression.getFormalParameter())
                .isNotNull()
                .hasSize(1)
                .first()
                .satisfies(param -> {
                    assertThat(param.getValue().getValue()).isEqualTo(PARAM_NAME);
                    assertThat(param.getTypeRef().getLocalPart()).isEqualTo(PARAM_DATA_TYPE);
                });
    }

@vpellegrino
Copy link
Contributor Author

Some comments to code, no more defects found in manual review. Thank you @vpellegrino

@jomarko answered, and accomplished comments as well.
Thank you!

Copy link

@jomarko jomarko left a comment

Choose a reason for hiding this comment

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

@vpellegrino thank you

@danielzhe
Copy link
Contributor

danielzhe commented Sep 16, 2021

Hi, @vpellegrino ! I've been working with this branch to do undo/redo. Very good job!
I found just a strange issue. Looks like that when we set a Function we got a infinite call to broadcastFunctionExpressionDefinition(final FunctionProps functionProps) https://github.com/kiegroup/kogito-editors-java/pull/104/files#diff-165ca4e61d69efdf36647961ef3e2a1d315633ada4516c6137f7b7c4959f3d21R404

To reproduce, just put a break point there and set the expression to "Function". You'll notice that it starts to loop forever.

@vpellegrino
Copy link
Contributor Author

Hi, @vpellegrino ! I've been working with this branch to do undo/redo. Very good job!
I found just a strange issue. Looks like that when we set a Function we got a infinite call to broadcastFunctionExpressionDefinition(final FunctionProps functionProps) https://github.com/kiegroup/kogito-editors-java/pull/104/files#diff-165ca4e61d69efdf36647961ef3e2a1d315633ada4516c6137f7b7c4959f3d21R404

To reproduce, just put a break point there and set the expression to "Function". You'll notice that it starts to loop forever.

Hi @danielzhe yeah, I already noticed it.
Indeed, it is an issue caused by the Resizer (the class responsible for auto resize the tables) that @karreiro is already working on!
Thanks a lot for raising the flag. It's nice you help in debugging the editor 😉☺️

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you for this PR, @vpellegrino. Great stuff!

I have only two questions:

1) Enable it on Kogito channels

I've noticed we're removing the display: none property from the ExpressionEditorViewImpl.html template. So, we're actually enabling this component in the editor.

However, only the kie-wb-common-dmn-webapp-kogito-testing web app requires our React assets. Thus, I believe if we build the .vsix extension or other Kogito channel, our component won't load (because Kogito channels rely on the kie-wb-common-dmn-webapp-kogito-runtime module).

Thus, I believe we have two alternatives:

  • Add the static assets to the the kie-wb-common-dmn-webapp-kogito-runtime
  • Bring the "display: none" back to the ExpressionEditorViewImpl.html and enable the component in another PR

Wdyt about this?

2) Use of JSNI

We're relying on JSNI in the BoxedExpressionService.java, which is something we must really avoid; instead, we should rely on the JsInterop API like we're doing in the DMNLoader.java. Do you prefer to raise a Jira to handle this in a different PR or handle it here?

--

Thanks a lot for this PR, @vpellegrino! It's really exciting to see the new boxed expression editor alive 🚀

@vpellegrino
Copy link
Contributor Author

vpellegrino commented Sep 20, 2021

@karreiro

  1. I put the "display: none" back
  2. should be fixed

Thanks for your review!

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you, @vpellegrino 🚀

@sonarcloud
Copy link

sonarcloud bot commented Sep 20, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@karreiro karreiro merged commit 60cb829 into kiegroup:main Sep 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
10 participants